Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1082972rwb; Thu, 19 Jan 2023 06:28:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXsGtUEFbB5W1S0ph+tH36rqg5HT33JiMZ/cyFX+AtUcWKcevZJf3sgpCF/18vuCs53o10z3 X-Received: by 2002:a17:90b:38c9:b0:229:f8f3:6485 with SMTP id nn9-20020a17090b38c900b00229f8f36485mr500706pjb.20.1674138528817; Thu, 19 Jan 2023 06:28:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674138528; cv=none; d=google.com; s=arc-20160816; b=tXdnOWuaT09kAn4xKDGHv+C0/L8N8/moZS5z/2yqYNhsKX3d4knbGZ2p+dBhkz86IN C/+aSLAub3+3j2a0jLMp61C+JPeKX354EEkKbhCcjH0C7hBVr4/4Grym1viiLWpO5pCq 0cqY+WSTAaJU8Fvwt86InRWrlf2l2O5ATC1mDzGuASBGGTFfsBMuvKj2z1eUxTFFG27o NJ/f8ETO3FwzkHPMOIeF7E/PrxlhwQv82BCU951RrRjdiT59xaEzRyebDli8BDxwP7Fo 0s3TlTM6V3FCLd1RVyP86dsqVazeA7mvczn/fjrwETdOi8ShZAw1s9HoF+0LF95Gk10x z/3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=sRewExaJYO5J9rPtU6PAS30GDIB1ngdlxtahlS4Y4rY=; b=XbSjAE5H2KIJRwhALPxkh8coe7vxmKRvneM2u5NchBNxDisHoiphuF3STxI25v6XDL 3ka/albjpXLFXovlnmT96Qfp4E/yL0AnY6WP8ENMDjNxK0QoohDkKrssGT05J5NS/OXp 4ovl1q4EY4n6zdyGBfYvelwBJ4f1HbZoo7eUystYxBU8C9tLs+hkU1T9jeVT9N2KQPwV IUuxe7+hY+EBnTDe5XB4kk7f86HXgWHrdbLZSQEozT8ssMuW5L51uCwo0CxAdnzirNgx bGHne6Stz+mPqx3d9ikZtbBUtUT5Kwa0M2DuOnDW5lpTk2zAcy7AAH6AmHtMfYQTWhG+ CvTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e7-20020a654787000000b00479079b77a6si38345719pgs.105.2023.01.19.06.28.42; Thu, 19 Jan 2023 06:28:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231168AbjASNTB (ORCPT + 44 others); Thu, 19 Jan 2023 08:19:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230266AbjASNSf (ORCPT ); Thu, 19 Jan 2023 08:18:35 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 558BC3ABD for ; Thu, 19 Jan 2023 05:18:34 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pIUoD-0005uJ-4J; Thu, 19 Jan 2023 14:18:25 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pIUoC-0079jT-G6; Thu, 19 Jan 2023 14:18:24 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pIUoB-00G51L-Bm; Thu, 19 Jan 2023 14:18:23 +0100 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com Subject: [PATCH net-next v1 4/4] net: dsa: microchip: enable EEE support Date: Thu, 19 Jan 2023 14:18:21 +0100 Message-Id: <20230119131821.3832456-5-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230119131821.3832456-1-o.rempel@pengutronix.de> References: <20230119131821.3832456-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some of KSZ9477 family switches provides EEE support. To enable it, we just need to register set_mac_eee/set_mac_eee handlers and validate supported chip version and port. Signed-off-by: Oleksij Rempel --- drivers/net/dsa/microchip/ksz_common.c | 35 ++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 5e1e5bd555d2..2f1f71b3be86 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -2645,6 +2645,39 @@ static int ksz_max_mtu(struct dsa_switch *ds, int port) return -EOPNOTSUPP; } +static int ksz_validate_eee(struct dsa_switch *ds, int port) +{ + struct ksz_device *dev = ds->priv; + + if (!dev->info->internal_phy[port]) + return -EOPNOTSUPP; + + switch (dev->chip_id) { + case KSZ8563_CHIP_ID: + case KSZ9477_CHIP_ID: + case KSZ9563_CHIP_ID: + case KSZ9567_CHIP_ID: + case KSZ9893_CHIP_ID: + case KSZ9896_CHIP_ID: + case KSZ9897_CHIP_ID: + return 0; + } + + return -EOPNOTSUPP; +} + +static int ksz_get_mac_eee(struct dsa_switch *ds, int port, + struct ethtool_eee *e) +{ + return ksz_validate_eee(ds, port); +} + +static int ksz_set_mac_eee(struct dsa_switch *ds, int port, + struct ethtool_eee *e) +{ + return ksz_validate_eee(ds, port); +} + static void ksz_set_xmii(struct ksz_device *dev, int port, phy_interface_t interface) { @@ -3006,6 +3039,8 @@ static const struct dsa_switch_ops ksz_switch_ops = { .port_hwtstamp_set = ksz_hwtstamp_set, .port_txtstamp = ksz_port_txtstamp, .port_rxtstamp = ksz_port_rxtstamp, + .get_mac_eee = ksz_get_mac_eee, + .set_mac_eee = ksz_set_mac_eee, }; struct ksz_device *ksz_switch_alloc(struct device *base, void *priv) -- 2.30.2