Received: by 2002:ab2:2997:0:b0:1ec:cbc4:63fb with SMTP id n23csp458083lqb; Thu, 29 Feb 2024 06:08:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWjqc/L5ZWAGSXPLadtX9kBLtzJBjNoUVnE/itCwMUtq8BFyXPr7OQLTxhqwBBWMpLHN+I0z2wtDkSbU65AcOIpzVf+mv2+Ca3uWCzI6Q== X-Google-Smtp-Source: AGHT+IFT2z3EYqs2HZHri9fcMEOPUgA7Do4j+G+YsuZS0V62LKB8EMzM8lUEZQQRtKqdWJs8n/jY X-Received: by 2002:a17:906:3442:b0:a44:46a:def8 with SMTP id d2-20020a170906344200b00a44046adef8mr1577650ejb.43.1709215710030; Thu, 29 Feb 2024 06:08:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709215710; cv=pass; d=google.com; s=arc-20160816; b=mflUpbrarancOmOZTc+u+txMb76VDEzo5KQOsSJboiCJLJDMCP8CTTDOADDAmtrMJL 3o53CDNBSRs5kwuq0okNSk5nXJnQnfdY5fDqhKodfBZ8QEMhN+cOSPpVtyAFcKPOEP2P lCUquvdxOv1S4tmGz20alEJ87AZySg2YnplkQEYJboD83LZRzqLxUTXCSlCd7qnA6gNe AA+ecqtA3bxwOjpNSoKDzKdso49CqMdRn2C3UIc07wT62vxXtfDQp+hRHVH0JueEMIdX tpRkJ7X+oOXkD0BIgzS8eUcn4z6hd9JArNVI+MYIW5QYzAoBbqqsMCOD9Ly3snyL2poW HH5Q== 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=b1It6eOY3eLJCx7PTpt0c92is38DjseB8xIYkQzGf7yINQTDFzBudXH7I0fH2rwA4i 6/MPdnLzkC+8LQivBZyFw4oGXAoAnhLwsI/YqtZalcTEK+9w3U5oswRZG/iWAW0g7YQd n/oUiafB6lccaLZ4w5erxaNpLl13QAxPJGUhqVGyS+lfEWKTP9FYeujRcxGCr3rscy43 dr8JkQ5P6kC1A8vuD9eOlSlx4mGPXn87yzmZqMVCWFKaPhafIRWvlvsF6TgY8ZB04cOf TE6woNJfTpnB7Xkhkumw8mwO2fje48CZ3vqqMnhLfCxELF3AeZHdJTVc0B0GDj2ne3ug jBWw==; 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-86796-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86796-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 qw9-20020a1709066a0900b00a42f6cb6bafsi643172ejc.294.2024.02.29.06.08.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 06:08:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86796-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-86796-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86796-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 C3E291F228DB for ; Thu, 29 Feb 2024 14:08:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4129012FB29; Thu, 29 Feb 2024 14:08:23 +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 C942012CDB5 for ; Thu, 29 Feb 2024 14:08:20 +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=1709215702; cv=none; b=fuSklXg5BIRLttgyZlZeZ6vZmw972cZrrY/qLSHCk4jBQQvUmRZBwxodLnOw0saCMZvxrAbOHnGM7XrdP54kYHKWjU7tD7iDhdgQ1KWjTDNKuOEw9mCKWW/AYf8vk5ZnAi0WGlJmhZRldYT450fTdn1v3PHeP5Q2kiMV32ay1xw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709215702; c=relaxed/simple; bh=pwl/nm8VqR5HxU43/b+GLZActVEhfzu3cSXEyZSs9Ng=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pIrCuuyhekclLYqYnJrJZmpdrDkKn1tc6wSD+DqdW1ktMdH9IeJTXYvEce4L6gGFe+C2dfpKhrvsapeMHeWwCF3aPxNylnzL0xD/1HYmFnluCRvnRrRv0zwCIzxjMb95zRL5XOlxqlA/Y7XmDcof16lfCqqZuKYhJ+C6oAkBmvg= 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 1rfh4t-0000Sy-CD; Thu, 29 Feb 2024 15:08:03 +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 1rfh4s-003ba6-7F; Thu, 29 Feb 2024 15:08:02 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rfh4s-00ELnB-08; Thu, 29 Feb 2024 15:08:02 +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 v7 7/8] net: fec: Move fec_enet_eee_mode_set() and helper earlier Date: Thu, 29 Feb 2024 15:07:59 +0100 Message-Id: <20240229140800.3420180-8-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240229140800.3420180-1-o.rempel@pengutronix.de> References: <20240229140800.3420180-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