From patchwork Mon Feb 6 13:50:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 13129895 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69767C61DA4 for ; Mon, 6 Feb 2023 13:52:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230477AbjBFNwK (ORCPT ); Mon, 6 Feb 2023 08:52:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230461AbjBFNvd (ORCPT ); Mon, 6 Feb 2023 08:51:33 -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 4383E234EB for ; Mon, 6 Feb 2023 05:51:15 -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 1pP1tY-0007Hk-Bm; Mon, 06 Feb 2023 14:50:56 +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 1pP1tW-0034eH-8Z; Mon, 06 Feb 2023 14:50:55 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pP1tV-00DaQJ-1A; Mon, 06 Feb 2023 14:50:53 +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 , Wei Fang , Heiner Kallweit Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Arun.Ramadoss@microchip.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next v5 16/23] net: fec: add support for PHYs with SmartEEE support Date: Mon, 6 Feb 2023 14:50:43 +0100 Message-Id: <20230206135050.3237952-17-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230206135050.3237952-1-o.rempel@pengutronix.de> References: <20230206135050.3237952-1-o.rempel@pengutronix.de> MIME-Version: 1.0 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: netdev@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Ethernet controller in i.MX6*/i.MX7* series do not provide EEE support. But this chips are used sometimes in combinations with SmartEEE capable PHYs. So, instead of aborting get/set_eee access on MACs without EEE support, ask PHY if it is able to do the EEE job by using SmartEEE. Signed-off-by: Oleksij Rempel --- drivers/net/ethernet/freescale/fec_main.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index c73e25f8995e..00f3703db69d 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3102,8 +3102,15 @@ fec_enet_get_eee(struct net_device *ndev, struct ethtool_eee *edata) struct fec_enet_private *fep = netdev_priv(ndev); struct ethtool_eee *p = &fep->eee; - if (!(fep->quirks & FEC_QUIRK_HAS_EEE)) - return -EOPNOTSUPP; + if (!(fep->quirks & FEC_QUIRK_HAS_EEE)) { + if (!netif_running(ndev)) + return -ENETDOWN; + + if (!phy_has_smarteee(ndev->phydev)) + return -EOPNOTSUPP; + + return phy_ethtool_get_eee(ndev->phydev, edata); + } if (!netif_running(ndev)) return -ENETDOWN; @@ -3123,8 +3130,15 @@ fec_enet_set_eee(struct net_device *ndev, struct ethtool_eee *edata) struct ethtool_eee *p = &fep->eee; int ret = 0; - if (!(fep->quirks & FEC_QUIRK_HAS_EEE)) - return -EOPNOTSUPP; + if (!(fep->quirks & FEC_QUIRK_HAS_EEE)) { + if (!netif_running(ndev)) + return -ENETDOWN; + + if (!phy_has_smarteee(ndev->phydev)) + return -EOPNOTSUPP; + + return phy_ethtool_set_eee(ndev->phydev, edata); + } if (!netif_running(ndev)) return -ENETDOWN;