Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp188082lqg; Fri, 1 Mar 2024 02:02:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVg9mqmRW+1ExI7+Ca2Y2KL3tlMIgnoVphLZv3xhk4yESUAp5joLatvUCTcsKMeYNlsx/r+Fn+fntelQsul/1FRozxZY0nUoUdX58jQKQ== X-Google-Smtp-Source: AGHT+IGCanCtCmxkEK9caP6oHj/g7r2W/4BHT7EAwKNr3KkRRGdvESO3Ld1p7FlRT3wu6hMZpq5I X-Received: by 2002:a50:c90d:0:b0:563:c54e:ee with SMTP id o13-20020a50c90d000000b00563c54e00eemr988770edh.2.1709287362298; Fri, 01 Mar 2024 02:02:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709287362; cv=pass; d=google.com; s=arc-20160816; b=1AxO+Dx4eHr4W4Jqk1ajvQAKfByNGhZB1L089JIlom2UYCYxMFBAleUTKQ/adKFHF2 bBWWdRI72X5pobfzNGup53nDkz7bPb9sVbcynWVBS9sdlIRDxRDoU4VlSCbaIf2FGL5O dmS2U5KEF24yeW7Eej9t1QBMWmQKTImzkf/dVCUh1sNMYF4W9dIVQmXwGmTAFONGeRyp KvZGdhZgB13x5JuzbggX+Z7AGafbJNIaZJRAOh32Nss9XW2PzQSzX4ONUFx/qTuU2dQ1 ATVXKNJlQDChuJFHDDy4eHCtEtuyO1ltsRj3DV0FPVGxwNm0I9rg5dOy2V013WsMED7B tEBg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=lUismf8tEPtJCxV3VOiEko0mhPuHABId0keZQzFBC/o=; fh=Ie8Lg/4B6LRJEAkd22XcdyKITG9FXA4PEPaBJgtxF+0=; b=LqTjrfJPI9b4y7wwKtAGwGUtqmVugFTTaIMi+GsZPyiGJ5iMZ+aFZ96nTzZ86XDD32 9w+s49RnfmCPWfSWdTeTqM2mfH7bNpG57juMHuHxcKZHA2cf1kJNabctjI7ZWs62dJ8F PUvBcoavQSUEm+90gBG9BQY525ajv/2qSAeHXcFTeaKDoATLgU5NzNHUUdghKdpdTYh2 zu233eQhVclc6T5ct0sv96vhJXXM2mIaWNVuK+p21pPJiPDlZzejLjjh+NUJbHIl2vLt CZWtSLKBYSak4b826f896Hna6hOPKTZgh8pds2gROWWGX6FDH1bLUhr0Rv7jwxYAd3S5 n6kw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-88219-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88219-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b20-20020a056402351400b0056692024bfbsi1358781edd.20.2024.03.01.02.02.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 02:02:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88219-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-88219-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88219-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 93D971F22C59 for ; Fri, 1 Mar 2024 10:02:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 05ED86BFAB; Fri, 1 Mar 2024 10:02:09 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2609B6A8B8 for ; Fri, 1 Mar 2024 10:02:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709287328; cv=none; b=JhRnjy8nfQ1BI99mWypo+lC2/ENUVeyLn271FGssr3aKNfEmb99b5ufzggxL+P9iFzqLotNhzwVyU3YRmZplP+R/LOHdJ/hi7gHOCwidnc6kCqm4bSbCSLI62OIK2LON3Scbya+17QxaQhodaKlWdqsiF81MwWqegLFFWG4aQtw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709287328; c=relaxed/simple; bh=pwl/nm8VqR5HxU43/b+GLZActVEhfzu3cSXEyZSs9Ng=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HnNBlxODqW0mv5DyXIcr6kE8U2cjMfVoOpmopekxDnYc5qAxSuOr3WsXz6AwdTff/KQFxEhN7Y44WJwM0J9OUXamDt4gKzik6flVueMZ5SSSRRYkEAYgK0roK/8Go73JBRuc4ipzpkQictCDRuBjJ69NUwMQwbDCyoAcLzwdOmc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rfziG-0003ok-BB; Fri, 01 Mar 2024 11:01:56 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rfziE-003kqD-Mc; Fri, 01 Mar 2024 11:01:54 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rfziE-003tNK-1r; Fri, 01 Mar 2024 11:01:54 +0100 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team Subject: [PATCH net-next v8 7/8] net: fec: Move fec_enet_eee_mode_set() and helper earlier Date: Fri, 1 Mar 2024 11:01:52 +0100 Message-Id: <20240301100153.927743-8-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240301100153.927743-1-o.rempel@pengutronix.de> References: <20240301100153.927743-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org From: Andrew Lunn FEC is about to get its EEE code re-written. To allow this, move fec_enet_eee_mode_set() before fec_enet_adjust_link() which will need to call it. Signed-off-by: Andrew Lunn Signed-off-by: Oleksij Rempel Reviewed-by: Wei Fang --- drivers/net/ethernet/freescale/fec_main.c | 75 ++++++++++++----------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 207f1f66c117a..a2c786550342f 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -2017,6 +2017,44 @@ static int fec_get_mac(struct net_device *ndev) /* * Phy section */ + +/* LPI Sleep Ts count base on tx clk (clk_ref). + * The lpi sleep cnt value = X us / (cycle_ns). + */ +static int fec_enet_us_to_tx_cycle(struct net_device *ndev, int us) +{ + struct fec_enet_private *fep = netdev_priv(ndev); + + return us * (fep->clk_ref_rate / 1000) / 1000; +} + +static int fec_enet_eee_mode_set(struct net_device *ndev, bool enable) +{ + struct fec_enet_private *fep = netdev_priv(ndev); + struct ethtool_keee *p = &fep->eee; + unsigned int sleep_cycle, wake_cycle; + int ret = 0; + + if (enable) { + ret = phy_init_eee(ndev->phydev, false); + if (ret) + return ret; + + sleep_cycle = fec_enet_us_to_tx_cycle(ndev, p->tx_lpi_timer); + wake_cycle = sleep_cycle; + } else { + sleep_cycle = 0; + wake_cycle = 0; + } + + p->tx_lpi_enabled = enable; + + writel(sleep_cycle, fep->hwp + FEC_LPI_SLEEP); + writel(wake_cycle, fep->hwp + FEC_LPI_WAKE); + + return 0; +} + static void fec_enet_adjust_link(struct net_device *ndev) { struct fec_enet_private *fep = netdev_priv(ndev); @@ -3121,43 +3159,6 @@ static int fec_enet_set_coalesce(struct net_device *ndev, return 0; } -/* LPI Sleep Ts count base on tx clk (clk_ref). - * The lpi sleep cnt value = X us / (cycle_ns). - */ -static int fec_enet_us_to_tx_cycle(struct net_device *ndev, int us) -{ - struct fec_enet_private *fep = netdev_priv(ndev); - - return us * (fep->clk_ref_rate / 1000) / 1000; -} - -static int fec_enet_eee_mode_set(struct net_device *ndev, bool enable) -{ - struct fec_enet_private *fep = netdev_priv(ndev); - struct ethtool_keee *p = &fep->eee; - unsigned int sleep_cycle, wake_cycle; - int ret = 0; - - if (enable) { - ret = phy_init_eee(ndev->phydev, false); - if (ret) - return ret; - - sleep_cycle = fec_enet_us_to_tx_cycle(ndev, p->tx_lpi_timer); - wake_cycle = sleep_cycle; - } else { - sleep_cycle = 0; - wake_cycle = 0; - } - - p->tx_lpi_enabled = enable; - - writel(sleep_cycle, fep->hwp + FEC_LPI_SLEEP); - writel(wake_cycle, fep->hwp + FEC_LPI_WAKE); - - return 0; -} - static int fec_enet_get_eee(struct net_device *ndev, struct ethtool_keee *edata) { -- 2.39.2