From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
To: Serge Semin <fancer.lancer@gmail.com>
Cc: Andrew Halaney <ahalaney@redhat.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Jose Abreu <joabreu@synopsys.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org, bpf@vger.kernel.org
Subject: [PATCH RFC net-next v2 2/8] net: stmmac: provide core phylink PCS infrastructure
Date: Fri, 31 May 2024 12:26:20 +0100 [thread overview]
Message-ID: <E1sD0Oq-00EzBo-7r@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <Zlmzu7/ANyZxOOQL@shell.armlinux.org.uk>
There are some common operations shared between the dwmac hwifs, the
only difference is where they are located within the device. These
are already present in the form of dwmac_rane(), dwmac_ctrl_ane() and
dwmac_get_adv_lp(). Rather than use these (which don't quite fit with
phylink PCS, provide phylink PCS specific versions.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/Makefile | 2 +-
.../net/ethernet/stmicro/stmmac/stmmac_pcs.c | 58 +++++++++++++++++++
.../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 10 ++++
3 files changed, 69 insertions(+), 1 deletion(-)
create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
index c2f0e91f6bf8..9e15f7615ff4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Makefile
+++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
@@ -6,7 +6,7 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o \
mmc_core.o stmmac_hwtstamp.o stmmac_ptp.o dwmac4_descs.o \
dwmac4_dma.o dwmac4_lib.o dwmac4_core.o dwmac5.o hwif.o \
stmmac_tc.o dwxgmac2_core.o dwxgmac2_dma.o dwxgmac2_descs.o \
- stmmac_xdp.o stmmac_est.o \
+ stmmac_xdp.o stmmac_est.o stmmac_pcs.o \
$(stmmac-y)
stmmac-$(CONFIG_STMMAC_SELFTESTS) += stmmac_selftests.o
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
new file mode 100644
index 000000000000..849e6f121505
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
@@ -0,0 +1,58 @@
+#include "common.h"
+#include "stmmac_pcs.h"
+
+int dwmac_pcs_config(struct mac_device_info *hw, unsigned int neg_mode,
+ phy_interface_t interface,
+ const unsigned long *advertising,
+ unsigned int reg_base)
+{
+ u32 val;
+
+ val = readl(hw->pcsr + GMAC_AN_CTRL(reg_base));
+
+ val |= GMAC_AN_CTRL_ANE | GMAC_AN_CTRL_RAN;
+
+ if (hw->ps)
+ val |= GMAC_AN_CTRL_SGMRAL;
+
+ writel(val, hw->pcsr + GMAC_AN_CTRL(reg_base));
+
+ return 0;
+}
+
+void dwmac_pcs_get_state(struct mac_device_info *hw,
+ struct phylink_link_state *state,
+ unsigned int reg_base)
+{
+ u32 val;
+
+ val = readl(hw->pcsr + GMAC_ANE_LPA(reg_base));
+
+ linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
+ state->lp_advertising);
+
+ if (val & GMAC_ANE_FD) {
+ linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
+ state->lp_advertising);
+ linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT,
+ state->lp_advertising);
+ linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT,
+ state->lp_advertising);
+ }
+
+ if (val & GMAC_ANE_HD) {
+ linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT,
+ state->lp_advertising);
+ linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT,
+ state->lp_advertising);
+ linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT,
+ state->lp_advertising);
+ }
+
+ linkmode_mod_bit(ETHTOOL_LINK_MODE_Pause_BIT,
+ state->lp_advertising,
+ FIELD_GET(GMAC_ANE_PSE, val) & STMMAC_PCS_PAUSE);
+ linkmode_mod_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
+ state->lp_advertising,
+ FIELD_GET(GMAC_ANE_PSE, val) & STMMAC_PCS_ASYM_PAUSE);
+}
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
index 1bdf87b237c4..888485fa2761 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
@@ -137,4 +137,14 @@ static inline void dwmac_get_adv_lp(void __iomem *ioaddr, u32 reg,
adv_lp->lp_pause = (value & GMAC_ANE_PSE) >> GMAC_ANE_PSE_SHIFT;
}
+
+int dwmac_pcs_config(struct mac_device_info *hw, unsigned int neg_mode,
+ phy_interface_t interface,
+ const unsigned long *advertising,
+ unsigned int reg_base);
+
+void dwmac_pcs_get_state(struct mac_device_info *hw,
+ struct phylink_link_state *state,
+ unsigned int reg_base);
+
#endif /* __STMMAC_PCS_H__ */
--
2.30.2
next prev parent reply other threads:[~2024-05-31 11:26 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-31 11:25 [PATCH RFC v2 0/8] net: stmmac: convert stmmac "pcs" to phylink Russell King (Oracle)
2024-05-31 11:26 ` Russell King (Oracle) [this message]
2024-06-03 21:39 ` Andrew Halaney
2024-06-24 13:26 ` [PATCH RFC net-next v2 09/17] net: stmmac: Introduce mac_device_info::priv pointer Serge Semin
2024-06-24 13:26 ` [PATCH RFC net-next v2 10/17] net: stmmac: Introduce internal PCS offset-based CSR access Serge Semin
2024-06-28 14:54 ` Russell King (Oracle)
2024-07-03 18:03 ` Serge Semin
2024-06-24 13:26 ` [PATCH RFC net-next v2 11/17] net: stmmac: Introduce internal PCS config register getter Serge Semin
2024-06-24 13:26 ` [PATCH RFC net-next v2 12/17] net: stmmac: Introduce internal PCS IRQ enable/disable methods Serge Semin
2024-06-24 13:26 ` [PATCH RFC net-next v2 13/17] net: stmmac: Move internal PCS ANE-control method to dwmac-qcom-ethqos.c Serge Semin
2024-06-24 13:26 ` [PATCH RFC net-next v2 14/17] net: stmmac: Move internal PCS PHYLINK ops to stmmac_pcs.c Serge Semin
2024-06-28 15:07 ` Russell King (Oracle)
2024-07-03 19:08 ` Serge Semin
2024-07-03 20:07 ` Russell King (Oracle)
2024-07-04 19:56 ` Serge Semin
2024-06-24 13:26 ` [PATCH RFC net-next v2 15/17] net: stmmac: Move internal PCS ISR " Serge Semin
2024-06-24 13:26 ` [PATCH RFC net-next v2 16/17] net: stmmac: Move internal PCS init method " Serge Semin
2024-06-28 14:36 ` Russell King (Oracle)
2024-07-04 12:55 ` Serge Semin
2024-06-24 13:26 ` [PATCH RFC net-next v2 17/17] net: stmmac: pcs: Drop the _SHIFT macros Serge Semin
2024-06-28 14:42 ` Russell King (Oracle)
2024-07-04 13:19 ` Serge Semin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1sD0Oq-00EzBo-7r@rmk-PC.armlinux.org.uk \
--to=rmk+kernel@armlinux.org.uk \
--cc=ahalaney@redhat.com \
--cc=alexandre.torgue@foss.st.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fancer.lancer@gmail.com \
--cc=hawk@kernel.org \
--cc=joabreu@synopsys.com \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox