Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1030389lqg; Sat, 2 Mar 2024 11:58:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXnvZ7h7lLE7q2MkFD9Bb3K6zVOc9w3dGLv8Qth3ro6rAmdErIP1hEIRL1KkN5UiCVwoo4p+k/AoHh+S86wGlx7V1BPkB3+1yrpPsHLhA== X-Google-Smtp-Source: AGHT+IGqwwfE7UcGTcD/beTE2KP8wfHHN8uHWn98dMIuweZLJsHsYt2MWIIvHIY+jVAApvZuP9xJ X-Received: by 2002:a17:902:daca:b0:1dc:d116:1a3a with SMTP id q10-20020a170902daca00b001dcd1161a3amr5210337plx.62.1709409490986; Sat, 02 Mar 2024 11:58:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709409490; cv=pass; d=google.com; s=arc-20160816; b=JZG18ZjP3IITgheoaYEUfvJy3xf3y8NZNBcA543kwDHy0zXOACXRBXLSPA2dQLk0p3 l7E+7jD3VjImVSo11t5ce0yZOOBk2xNEI2oSsjMISkOwdzly/oz0lWsCr7Ho84MkMzP1 H9EK8Oeb6Lc9h7kEYaNG7apuFQHHtc+RB3dr0oT8U/2yrKriTzh3ppaosNqV3WWHqEOV cVrsb7sCPnmtCCXY6sRb4R9c+5r/ajigstd1MJxk/LRf8l03dNqFoy4WvJycaqSH29fz Ny0owoGB4IDkz05ZaVHQLqVrgH5IDibxyphT6+Xpoqzzq1MeH+X5XE9CyFy729WT03Pv G8PQ== 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=lKrFHoNsMoS6j9iLSy+hdJS1SByVhgKcxw1i2koyFtDDDKskMM4gN3ZcuuauuA+/2S wrhMQS4JCSKNOnaZhF227xG6ccF958Xnj6lngteTF1ljWSLjF2lF+NNlKgh7zP/e5Nps /K6AH2cymvnHBQVfDHozAqqzglHACF3hAA3Eeo+IQN/6ITcF9OsJxhfdN7ZqIusy2qk3 3Jbc3YY5onRietDZeG3OtTgWt2TCU7hD7ddpnyHFUY67Q8pMYjSsuAXntrt8g+6atzll 9fPE1/qjdAoS9atOP6rGoGj5vyOKWKF1pNW1uFa6Y8IQDvAyXT5OElz9Hk4K+rroKOBh lThA==; 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-89575-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89575-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l13-20020a170903244d00b001dcc8b6d8a0si5919561pls.163.2024.03.02.11.58.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 11:58:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89575-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-89575-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89575-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 14D3BB2351A for ; Sat, 2 Mar 2024 19:55:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E58874D5AA; Sat, 2 Mar 2024 19:53:24 +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 549AF4206E for ; Sat, 2 Mar 2024 19:53:22 +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=1709409204; cv=none; b=FPcZEYUv+bDnyb9FxxxXG2tKZKZLm9Q9vHNIWF+tTZNdaVfRW2hItjIsH57GfLBH6bIVZ274vKQ7+UHZ4SYyuJC9LTFla0RjochwEua3o1Uv51xO4/EXogFZISrbEwKsWGq6w71UsiVWrr2K3lXguHZ5Kb3zraZO/57XidKm6aU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709409204; c=relaxed/simple; bh=pwl/nm8VqR5HxU43/b+GLZActVEhfzu3cSXEyZSs9Ng=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=G/jF56XsXf1zPcLOmK1HQVMarCqQFGnVrfTSAi55X3Y5nvjScNoML8mGXLXb3SAsCxWP2+GH5ezP5xZrxaCDtTyCL9aonR+rAxF2D7FhuOKFuGA/RTCIH8Mq6ShWqToqUjK4cY6vrwtL1ZC21qxeFxmlFh8HIn666M5ZGLFyzVA= 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 1rgVPx-0007Gy-Ln; Sat, 02 Mar 2024 20:53:09 +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 1rgVPv-0041mK-Rt; Sat, 02 Mar 2024 20:53:07 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rgVPv-00DSUs-2S; Sat, 02 Mar 2024 20:53:07 +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 v9 6/7] net: fec: Move fec_enet_eee_mode_set() and helper earlier Date: Sat, 2 Mar 2024 20:53:05 +0100 Message-Id: <20240302195306.3207716-7-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240302195306.3207716-1-o.rempel@pengutronix.de> References: <20240302195306.3207716-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