From patchwork Mon Aug 5 10:25:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13753481 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 00556C3DA4A for ; Mon, 5 Aug 2024 10:30:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ldegGhyH398a5LToFGWUu8u+63Wh+yZiitEXtG3A7zI=; b=aFJl8KV6rEwnhACU3R22o5McLZ o/zrcj9Hy1wfre2Lm5oM0MLVUq/Eq/5bJ72PAwf+II47WHh6YC9PPpMgVWLf/wANuDM7uP2hBGiP+ 6QbwqsOyPnKVe803obdPIKUz6fePdRaUFDcHQR2sxrutzGQqvF3XwWwlWlfmDoVpwQxsyRh8MSnD2 64rZ59i0f9+P0FBshOeHaLLuSL/nU83se5cUS4CkcesmFgqIJHjUUJt3vW4d5IhSVUDrBZH8Wuc5G TNkv56K4q0tDHnU4KUhPXNx9TO6CRIrD8MDaHgyo6IcpTDaMS/+o5tutgr/PWeW8MNhElV/VazCNc Exswhzkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sauyd-0000000FWnL-0Zwu; Mon, 05 Aug 2024 10:30:07 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sauuN-0000000FV8e-35T9 for linux-arm-kernel@lists.infradead.org; Mon, 05 Aug 2024 10:25:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ldegGhyH398a5LToFGWUu8u+63Wh+yZiitEXtG3A7zI=; b=lxxJhFldn9vH5B5dnncGd4CZCJ JfN7sYq1MXSmDSXlcJ9ukA7e5/rZl4OQ9GuEZXCTp425uu3VMtLlM8vHVSGdnGT0a4OihUpFsiPQO GjTmysJ0HZTQxiIvcgoiq5vbMBtrV41+KGvoe9Fg6BloTattMoVhSXouRbTnYE2arh80v6aj25mK0 K8L3jG8oRWwQ3BjrDiQ6/3ODYcrZJdL8OMhJfQkPwXP16Fq8MgfiQ0fXQfR9oJJi7qkIBcQF4wLqL ZL+3GZIr7ZGkqlrbj/LuNnGnkS0efH+2XTtMvwQZTLUu03+QYrobTbvesyH8frSL915B5HK3BGIR3 kUqu8hiA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:44314 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sauu3-0002dz-1K; Mon, 05 Aug 2024 11:25:23 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sauu7-000tva-N1; Mon, 05 Aug 2024 11:25:27 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Alexandre Torgue , Alexei Starovoitov , Andrew Halaney , Bartosz Golaszewski , bpf@vger.kernel.org, Daniel Borkmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Jose Abreu , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Sneh Shah , Vinod Koul Subject: [PATCH RFC net-next v4 10/14] net: stmmac: move dwmac_ctrl_ane() into stmmac_pcs.c MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Mon, 05 Aug 2024 11:25:27 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240805_032543_965717_D3FB26CA X-CRM114-Status: GOOD ( 16.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Move dwmac_ctrl_ane() into stmmac_pcs.c, changing its arguments to take the stmmac_priv structure. Update it to use the previously provided __dwmac_ctrl_ane() function, which makes use of the stmmac_pcs struct and thus does not require passing the PCS base address offset. This removes the core-specific functions, instead pointing the method at the generic method in stmmac_pcs.c. Reviewed-by: Andrew Halaney Signed-off-by: Russell King (Oracle) --- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 8 +--- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 12 ++---- .../net/ethernet/stmicro/stmmac/stmmac_pcs.c | 16 ++++++++ .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 37 ++----------------- 4 files changed, 23 insertions(+), 50 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index 05b2df08cb0f..d2defa2e4996 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -365,12 +365,6 @@ static void dwmac1000_set_eee_timer(struct mac_device_info *hw, int ls, int tw) writel(value, ioaddr + LPI_TIMER_CTRL); } -static void dwmac1000_ctrl_ane(struct stmmac_priv *priv, bool ane, - bool srgmi_ral, bool loopback) -{ - dwmac_ctrl_ane(priv->ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback); -} - static int dwmac1000_mii_pcs_enable(struct phylink_pcs *pcs) { struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs); @@ -527,7 +521,7 @@ const struct stmmac_ops dwmac1000_ops = { .set_eee_timer = dwmac1000_set_eee_timer, .set_eee_pls = dwmac1000_set_eee_pls, .debug = dwmac1000_debug, - .pcs_ctrl_ane = dwmac1000_ctrl_ane, + .pcs_ctrl_ane = dwmac_ctrl_ane, .set_mac_loopback = dwmac1000_set_mac_loopback, }; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 0d261709bee6..2f02bb47c952 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -750,12 +750,6 @@ static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex, } } -static void dwmac4_ctrl_ane(struct stmmac_priv *priv, bool ane, bool srgmi_ral, - bool loopback) -{ - dwmac_ctrl_ane(priv->ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback); -} - static int dwmac4_mii_pcs_enable(struct phylink_pcs *pcs) { struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs); @@ -1227,7 +1221,7 @@ const struct stmmac_ops dwmac4_ops = { .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer, .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, - .pcs_ctrl_ane = dwmac4_ctrl_ane, + .pcs_ctrl_ane = dwmac_ctrl_ane, .debug = dwmac4_debug, .set_filter = dwmac4_set_filter, .set_mac_loopback = dwmac4_set_mac_loopback, @@ -1271,7 +1265,7 @@ const struct stmmac_ops dwmac410_ops = { .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer, .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, - .pcs_ctrl_ane = dwmac4_ctrl_ane, + .pcs_ctrl_ane = dwmac_ctrl_ane, .debug = dwmac4_debug, .set_filter = dwmac4_set_filter, .flex_pps_config = dwmac5_flex_pps_config, @@ -1319,7 +1313,7 @@ const struct stmmac_ops dwmac510_ops = { .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer, .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, - .pcs_ctrl_ane = dwmac4_ctrl_ane, + .pcs_ctrl_ane = dwmac_ctrl_ane, .debug = dwmac4_debug, .set_filter = dwmac4_set_filter, .safety_feat_config = dwmac5_safety_feat_config, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c index 292c039c9778..e435facc9849 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c @@ -30,6 +30,22 @@ static void __dwmac_ctrl_ane(struct stmmac_pcs *spcs, bool ane, bool srgmi_ral, writel(val, spcs->pcs_base + GMAC_AN_CTRL(0)); } +/** + * dwmac_ctrl_ane - To program the AN Control Register. + * @priv: pointer to &struct stmmac_priv + * @ane: to enable the auto-negotiation + * @srgmi_ral: to manage MAC-2-MAC SGMII connections. + * @loopback: to cause the PHY to loopback tx data into rx path. + * Description: this is the main function to configure the AN control register + * and init the ANE, select loopback (usually for debugging purpose) and + * configure SGMII RAL. + */ +void dwmac_ctrl_ane(struct stmmac_priv *priv, bool ane, bool srgmi_ral, + bool loopback) +{ + __dwmac_ctrl_ane(&priv->hw->mac_pcs, ane, srgmi_ral, loopback); +} + int dwmac_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, phy_interface_t interface, const unsigned long *advertising, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h index f0d6442711ff..083128e0013c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h @@ -89,40 +89,6 @@ static inline void dwmac_pcs_isr(void __iomem *ioaddr, u32 reg, } } -/** - * dwmac_ctrl_ane - To program the AN Control Register. - * @ioaddr: IO registers pointer - * @reg: Base address of the AN Control Register. - * @ane: to enable the auto-negotiation - * @srgmi_ral: to manage MAC-2-MAC SGMII connections. - * @loopback: to cause the PHY to loopback tx data into rx path. - * Description: this is the main function to configure the AN control register - * and init the ANE, select loopback (usually for debugging purpose) and - * configure SGMII RAL. - */ -static inline void dwmac_ctrl_ane(void __iomem *ioaddr, u32 reg, bool ane, - bool srgmi_ral, bool loopback) -{ - u32 value = readl(ioaddr + GMAC_AN_CTRL(reg)); - - /* Enable and restart the Auto-Negotiation */ - if (ane) - value |= GMAC_AN_CTRL_ANE | GMAC_AN_CTRL_RAN; - else - value &= ~GMAC_AN_CTRL_ANE; - - /* In case of MAC-2-MAC connection, block is configured to operate - * according to MAC conf register. - */ - if (srgmi_ral) - value |= GMAC_AN_CTRL_SGMRAL; - - if (loopback) - value |= GMAC_AN_CTRL_ELE; - - writel(value, ioaddr + GMAC_AN_CTRL(reg)); -} - static inline bool dwmac_rs_decode_stat(struct phylink_link_state *state, uint16_t rs_stat) { @@ -154,6 +120,9 @@ static inline bool dwmac_rs_decode_stat(struct phylink_link_state *state, return true; } +void dwmac_ctrl_ane(struct stmmac_priv *priv, bool ane, bool srgmi_ral, + bool loopback); + int dwmac_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, phy_interface_t interface, const unsigned long *advertising,