From patchwork Mon Jun 24 13:26:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13709520 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 D93B4C2BD09 for ; Mon, 24 Jun 2024 13:29:18 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YtZp0AbrnXQs3O13v2d6+EuVN6MSe7p8ad/hbNOPJWI=; b=MynZwWlLLlg8SzNhGpRYgN3pGB xqArPFnxAWbdNQKyCOH9ULpGZnGh72qhVJn5YE61E0UMLToCBVwOef+K1MCtMJd3uUgL7dluRBMVQ gL+0ZB5Nt48pta0eq1jjN0vBAlNJU6/ESCaSaSGNXaeQzYe6RlzNIydJcqktqByx8d7RmSNDpj3Ly C47F66BYLvDHE2cZasWPOR/e0WSkNjn6zK0HBb6gfIeKd/jcJrSmnERf/vhskJJQO+Q2HD7ZpLxQx Fk0jSdmoxfVO7sMm4VgdZ3CU1INqfSC94UnpFFZ3FoeXKqYTXOr04KWvRwHhB4LKrS9SQPZBWBdQa 2A5S8a0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjkq-0000000GvFP-0MVP; Mon, 24 Jun 2024 13:29:08 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjkQ-0000000Gv1E-1hsL for linux-arm-kernel@lists.infradead.org; Mon, 24 Jun 2024 13:28:43 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-52ce0140416so1847066e87.0 for ; Mon, 24 Jun 2024 06:28:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719235720; x=1719840520; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YtZp0AbrnXQs3O13v2d6+EuVN6MSe7p8ad/hbNOPJWI=; b=X/VgYCdqAazrtSD3BhENQgjDX1yEwy9hoIn9dPTObS0pXftrzCI8reqy/dU5Ngbcgl 6eq2ImMxZs5pydWUHh17YuUB9s84sJ/1ZYC3pjlsSPHyMJ6uMdRznam00y4xJQ+btw0K FVaXjIUOzRIXZuC18r7y1oZ6NQCC/0+w4muaiPbb8qU5tcxc39AlMGwmqby8Lx6VCQQM NhJojVnLEmPV8GmVVJPoXv5rboORO3ObshdjfmZYARudFM5pB3fc2WU6Hg6Be92s+/m8 y4d5kHBtNYLoFYwQzGzIWI1QzeCd8hWgD3aAcnRlp1ao+Ovj7td5Vm6lrhB+WS5vWiBn +kJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719235720; x=1719840520; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YtZp0AbrnXQs3O13v2d6+EuVN6MSe7p8ad/hbNOPJWI=; b=okQFJhNFjaZDbcVyka2DsbEqCyH9X4e5PvE4xefCI9ZOdfSr3Mbw9I51uwrg98n8gh yhnScUttwl5aiVAweQRKpC5gaQhgD84j00+x+zsFgL/m6raK+uHAvscRClsYbC/T8kW/ u6H1M5g3NLF4POnUIXFeh7KNep8nbwOQtOUbwF5kpGc76UemgOpFvKAWclJ/yH59MRpB 9qmRf7Gpd1Hbwbi4Wc9M2csDN51kGiJt627JHRP5qUKPltZzZ2Gd1y1YGilUa3jVu0TI Heou+oZv1wLvfUuL1W0i/r3w5BcnCtYir1l6afDbw7yC/wBW4StIoMXgrSHhbqs5f7uG zn1Q== X-Forwarded-Encrypted: i=1; AJvYcCW6k4u88iQ9X28DE278JpqP/euESzri2VhKZt1Xq11icxuCMKgwrZurhCFK2w61XMXdQ5sjkFj9sZQ5SaO0PY5Rzka8UN/BIgMy3xxH1a3b6NNzGEc= X-Gm-Message-State: AOJu0YwS+av3az5PruZdASQb4snT6Oadqbu7GHCnmIOnFs/oxeBX3Ps6 PTv1uqjsQxRO8aVT0ea6Dq4p1OL6ECki7UAxW8L5DWXo+GiLZZwD X-Google-Smtp-Source: AGHT+IGnD5pCpdtBAgEV0LPviNccHChm0nS52nkrjh8YxukL2E9OFJq+KfJaFse+52g2ituyaoatpQ== X-Received: by 2002:a19:4310:0:b0:52c:b479:902d with SMTP id 2adb3069b0e04-52ce06105efmr3684613e87.4.1719235720181; Mon, 24 Jun 2024 06:28:40 -0700 (PDT) Received: from localhost ([213.79.110.82]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52cd643342dsm982999e87.231.2024.06.24.06.28.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 06:28:39 -0700 (PDT) From: Serge Semin To: Russell King , Andrew Halaney , Vinod Koul , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: Alexei Starovoitov , Jesper Dangaard Brouer , John Fastabend , Daniel Borkmann , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC net-next v2 13/17] net: stmmac: Move internal PCS ANE-control method to dwmac-qcom-ethqos.c Date: Mon, 24 Jun 2024 16:26:30 +0300 Message-ID: <20240624132802.14238-5-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240624_062842_494116_C4882697 X-CRM114-Status: GOOD ( 19.59 ) 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 The dwmac_ctrl_ane() method is not going to be utilized in the internal PCS implementation. Simplify the DW *MAC HW-abstraction interface by moving the method definition to the only user of it - dwmac-qcom-ethqos.c. Signed-off-by: Serge Semin --- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 31 ++++++++++++++--- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 7 ---- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 9 ----- drivers/net/ethernet/stmicro/stmmac/hwif.h | 4 --- .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 33 ------------------- 5 files changed, 27 insertions(+), 57 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index d0bcebe87ee8..fcd13a9afd59 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -615,6 +615,29 @@ static void ethqos_set_serdes_speed(struct qcom_ethqos *ethqos, int speed) } } +static inline void ethqos_ctrl_ane(void __iomem *pcsaddr, bool ane, + bool srgmi_ral, bool loopback) +{ + u32 value = readl(pcsaddr + PCS_AN_CTRL); + + /* Enable and restart the Auto-Negotiation */ + if (ane) + value |= PCS_AN_CTRL_ANE | PCS_AN_CTRL_RAN; + else + value &= ~PCS_AN_CTRL_ANE; + + /* In case of MAC-2-MAC connection, block is configured to operate + * according to MAC conf register. + */ + if (srgmi_ral) + value |= PCS_AN_CTRL_SGMRAL; + + if (loopback) + value |= PCS_AN_CTRL_ELE; + + writel(value, pcsaddr + PCS_AN_CTRL); +} + /* On interface toggle MAC registers gets reset. * Configure MAC block for SGMII on ethernet phy link up */ @@ -633,7 +656,7 @@ static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos) RGMII_CONFIG2_RGMII_CLK_SEL_CFG, RGMII_IO_MACRO_CONFIG2); ethqos_set_serdes_speed(ethqos, SPEED_2500); - stmmac_pcs_ctrl_ane(priv, priv->pcsaddr, 0, 0, 0); + ethqos_ctrl_ane(priv->pcsaddr, 0, 0, 0); break; case SPEED_1000: val &= ~ETHQOS_MAC_CTRL_PORT_SEL; @@ -641,12 +664,12 @@ static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos) RGMII_CONFIG2_RGMII_CLK_SEL_CFG, RGMII_IO_MACRO_CONFIG2); ethqos_set_serdes_speed(ethqos, SPEED_1000); - stmmac_pcs_ctrl_ane(priv, priv->pcsaddr, 1, 0, 0); + ethqos_ctrl_ane(priv->pcsaddr, 1, 0, 0); break; case SPEED_100: val |= ETHQOS_MAC_CTRL_PORT_SEL | ETHQOS_MAC_CTRL_SPEED_MODE; ethqos_set_serdes_speed(ethqos, SPEED_1000); - stmmac_pcs_ctrl_ane(priv, priv->pcsaddr, 1, 0, 0); + ethqos_ctrl_ane(priv->pcsaddr, 1, 0, 0); break; case SPEED_10: val |= ETHQOS_MAC_CTRL_PORT_SEL; @@ -656,7 +679,7 @@ static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos) SGMII_10M_RX_CLK_DVDR), RGMII_IO_MACRO_CONFIG); ethqos_set_serdes_speed(ethqos, SPEED_1000); - stmmac_pcs_ctrl_ane(priv, priv->pcsaddr, 1, 0, 0); + ethqos_ctrl_ane(priv->pcsaddr, 1, 0, 0); break; } diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index 99f0bbb318ec..9511ea753da7 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -395,12 +395,6 @@ static u16 dwmac1000_pcs_get_config_reg(struct mac_device_info *hw) return FIELD_GET(GMAC_RGSMIIIS_CONFIG_REG, val); } -static void dwmac1000_ctrl_ane(void __iomem *pcsaddr, bool ane, bool srgmi_ral, - bool loopback) -{ - dwmac_ctrl_ane(pcsaddr, ane, srgmi_ral, loopback); -} - static int dwmac1000_mii_pcs_validate(struct phylink_pcs *pcs, unsigned long *supported, const struct phylink_link_state *state) @@ -593,7 +587,6 @@ const struct stmmac_ops dwmac1000_ops = { .pcs_enable_irq = dwmac1000_pcs_enable_irq, .pcs_disable_irq = dwmac1000_pcs_disable_irq, .pcs_get_config_reg = dwmac1000_pcs_get_config_reg, - .pcs_ctrl_ane = dwmac1000_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 5dc8d59d3a8f..1e73c14f36ce 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -780,12 +780,6 @@ static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex, } } -static void dwmac4_ctrl_ane(void __iomem *pcsaddr, bool ane, bool srgmi_ral, - bool loopback) -{ - dwmac_ctrl_ane(pcsaddr, ane, srgmi_ral, loopback); -} - static int dwmac4_mii_pcs_validate(struct phylink_pcs *pcs, unsigned long *supported, const struct phylink_link_state *state) @@ -1294,7 +1288,6 @@ 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, .debug = dwmac4_debug, .pcs_enable_irq = dwmac4_pcs_enable_irq, .pcs_disable_irq = dwmac4_pcs_disable_irq, @@ -1341,7 +1334,6 @@ 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, .debug = dwmac4_debug, .pcs_enable_irq = dwmac4_pcs_enable_irq, .pcs_disable_irq = dwmac4_pcs_disable_irq, @@ -1392,7 +1384,6 @@ 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, .debug = dwmac4_debug, .pcs_enable_irq = dwmac4_pcs_enable_irq, .pcs_disable_irq = dwmac4_pcs_disable_irq, diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 2caa946a92f9..3d39417e906d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -379,8 +379,6 @@ struct stmmac_ops { void (*pcs_enable_irq)(struct mac_device_info *hw); void (*pcs_disable_irq)(struct mac_device_info *hw); u16 (*pcs_get_config_reg)(struct mac_device_info *hw); - void (*pcs_ctrl_ane)(void __iomem *pcsaddr, bool ane, bool srgmi_ral, - bool loopback); /* Safety Features */ int (*safety_feat_config)(void __iomem *ioaddr, unsigned int asp, struct stmmac_safety_feature_cfg *safety_cfg); @@ -501,8 +499,6 @@ struct stmmac_ops { stmmac_do_void_callback(__priv, mac, pcs_disable_irq, __args) #define stmmac_pcs_get_config_reg(__priv, __args...) \ stmmac_do_callback(__priv, mac, pcs_get_config_reg, __args) -#define stmmac_pcs_ctrl_ane(__priv, __args...) \ - stmmac_do_void_callback(__priv, mac, pcs_ctrl_ane, __args) #define stmmac_safety_feat_config(__priv, __args...) \ stmmac_do_callback(__priv, mac, safety_feat_config, __args) #define stmmac_safety_feat_irq_status(__priv, __args...) \ diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h index 62be3921ac91..76badfd208b6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h @@ -76,39 +76,6 @@ static inline void dwmac_pcs_isr(void __iomem *pcsaddr, } } -/** - * dwmac_ctrl_ane - To program the AN Control Register. - * @ioaddr: IO registers pointer - * @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 *pcsaddr, bool ane, - bool srgmi_ral, bool loopback) -{ - u32 value = readl(pcsaddr + PCS_AN_CTRL); - - /* Enable and restart the Auto-Negotiation */ - if (ane) - value |= PCS_AN_CTRL_ANE | PCS_AN_CTRL_RAN; - else - value &= ~PCS_AN_CTRL_ANE; - - /* In case of MAC-2-MAC connection, block is configured to operate - * according to MAC conf register. - */ - if (srgmi_ral) - value |= PCS_AN_CTRL_SGMRAL; - - if (loopback) - value |= PCS_AN_CTRL_ELE; - - writel(value, pcsaddr + PCS_AN_CTRL); -} - int dwmac_pcs_config(struct mac_device_info *hw, unsigned int neg_mode, phy_interface_t interface, const unsigned long *advertising);