Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp850195rdb; Fri, 23 Feb 2024 01:47:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWHAV4IvGsLggdKN5Yvzfc9cGfRupMq97WzvcdnKw1SiFrPs+dPKincSMSw788aGCJ2LdlnSYPMCoiHOZPydAJBuosQKXnyDgx8yqKX4w== X-Google-Smtp-Source: AGHT+IGiQdQhET7/q+c+vSlFErwzZxdPb0E+bgsCRCWnImMFoNOxrDeNQHjg8G8Im1Rz5ekb0Yj+ X-Received: by 2002:a05:6358:57a9:b0:17b:7769:25f3 with SMTP id m41-20020a05635857a900b0017b776925f3mr1254142rwf.32.1708681660571; Fri, 23 Feb 2024 01:47:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708681660; cv=pass; d=google.com; s=arc-20160816; b=SFWZJO4LRDOuUkXnj1GTPk/d6NgH1q+waPfLTQlGILc4E9fx8hB2GGNNsm+4RkrXY/ RUKRBIhO9ePYNgRuSNn2/Us33iU1RpAUGFU4RnRKnfZzNMy2HHRWwlvovnvtbQsR+QZ0 KGS65dvQ+IGRd1ixO2Ys6YjP4SPOJAkBKHd5nX/whAlg6Preps/LzT6o7hS0KZdo8grB FP5wAWub223DPoOBBrw+NeuXkK8LjOzQxGRMp9PqyKyAcVaHLxEMGu7qoZrSQlKPLppA XP1mizHIGeoat6hp0RfEHhkjfXMnKbhJzjxyNIWRuk0vXHUCEC20f4XlilKU2qqqTsyO YqMQ== 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=itjR1WvG8tov6WBmnWp0zImRYwxk+J2bqa+1guHXKQA=; fh=Ie8Lg/4B6LRJEAkd22XcdyKITG9FXA4PEPaBJgtxF+0=; b=akVpsatqLmgPOKGe3dtwWWmY6fcz/S8BJFUSz6aFdhNkD6Li8RS+o0doIAcTIb1QZO sp3p6ll85wcs7L/IL0rmAbHRrjtPCDccvvvBjSc//ofsn21sluszQL7Txek/0s2vM8q9 Rv/L55gMQJlj8jOOH/fMtVPfZevxFKVKCIiVpD+G23RuA5i6U9BFN5J4QXGB+oLnLEHg XHdBqriWl20kkIzCUySZQQlz/GXToqGzzSGN8RPpYZcDTiCJ8QQqa3iJv5wFsq46eMAV ebENaXZuUyl7M78VEXGi2tO3/BQxgj96W3uTXqfL6ol65uCR6U2YyqG+zQrG9fMZwWpz Jgfw==; 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-78063-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78063-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l62-20020a639141000000b005dc87994572si11933301pge.346.2024.02.23.01.47.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 01:47:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78063-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-78063-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78063-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0FB25282338 for ; Fri, 23 Feb 2024 09:47:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 88EE35F579; Fri, 23 Feb 2024 09:44:58 +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 7A45F5CDC2 for ; Fri, 23 Feb 2024 09:44:41 +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=1708681494; cv=none; b=k7K9ubd15JUcr1GWNs+Hn0Iz4spEy6/vllY0ktGrc/6W8zXaPhBQG7IdzheX3TIpdhYEVnXuK/KCVXyaq2tYvID2dlhdZwuj9j/iDGFg9G6yWwB8AIHt1fCCdKK/KWT5U/EhLItI0SBDic8bU1qlh9OsW5LdKsAp0PI6RaI9mug= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681494; c=relaxed/simple; bh=RUBXoykfHsI8g81DTZ9jhWky7Ii6+Okm8CvBUDS9aVU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CLBS47GRz7i+LwfmGQwtcW+qUKJXcdQC2hqqjeDRsi2VAvDbP20B1RRH3T1HCWoLvjybrvjZiO7YLL0EsVajA0w8glTSs1wTYeAWQf44jB85jzObF/dMOuc4egDt2/1d88qVFE6ddGzD4Cam/PYvF2UdPWIe9E6rREa6zI8njEY= 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 1rdS6W-00080r-F4; Fri, 23 Feb 2024 10:44:28 +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 1rdS6V-002Okb-Fa; Fri, 23 Feb 2024 10:44:27 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rdS6V-002tqR-17; Fri, 23 Feb 2024 10:44:27 +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 v6 7/8] net: fec: Move fec_enet_eee_mode_set() and helper earlier Date: Fri, 23 Feb 2024 10:44:24 +0100 Message-Id: <20240223094425.691209-8-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223094425.691209-1-o.rempel@pengutronix.de> References: <20240223094425.691209-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 207f1f66c117..a2c786550342 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