|
@@ -1,37 +1,25 @@
|
|
|
-From 8e18c5fef75debfae3531fbd6901f3bf317d91ed Mon Sep 17 00:00:00 2001
|
|
|
+From e19de30d20809af3221ef8a2648b8a8a52e02d90 Mon Sep 17 00:00:00 2001
|
|
|
From: Daniel Golle <[email protected]>
|
|
|
-Date: Fri, 9 Sep 2022 04:28:43 +0100
|
|
|
-Subject: [PATCH] net: dsa: mt7530: add support for in-band link status
|
|
|
-To: [email protected],
|
|
|
- [email protected]
|
|
|
-Cc: Russell King <[email protected]>,
|
|
|
- Sean Wang <[email protected]>,
|
|
|
- Landen Chao <[email protected]>,
|
|
|
- DENG Qingfang <[email protected]>,
|
|
|
- Andrew Lunn <[email protected]>,
|
|
|
- Vivien Didelot <[email protected]>,
|
|
|
- Florian Fainelli <[email protected]>,
|
|
|
- Vladimir Oltean <[email protected]>,
|
|
|
- David S. Miller <[email protected]>,
|
|
|
- Eric Dumazet <[email protected]>,
|
|
|
- Jakub Kicinski <[email protected]>,
|
|
|
- Paolo Abeni <[email protected]>,
|
|
|
- Matthias Brugger <[email protected]>,
|
|
|
- Philipp Zabel <[email protected]>
|
|
|
+Date: Wed, 21 Sep 2022 01:23:14 +0100
|
|
|
+Subject: [PATCH 1/1] net: dsa: mt7530: add support for in-band link status
|
|
|
|
|
|
Read link status from SGMII PCS for in-band managed 2500Base-X and
|
|
|
1000Base-X connection on a MAC port of the MT7531. This is needed to
|
|
|
get the SFP cage working which is connected to SGMII interface of
|
|
|
port 5 of the MT7531 switch IC on the Bananapi BPi-R3 board.
|
|
|
+While at it also handle an_complete for both the autoneg and the
|
|
|
+non-autoneg codepath.
|
|
|
|
|
|
Signed-off-by: Daniel Golle <[email protected]>
|
|
|
+Signed-off-by: David S. Miller <[email protected]>
|
|
|
---
|
|
|
- drivers/net/dsa/mt7530.c | 48 +++++++++++++++++++++++++++++-----------
|
|
|
- 1 file changed, 35 insertions(+), 13 deletions(-)
|
|
|
+ drivers/net/dsa/mt7530.c | 50 +++++++++++++++++++++++++++++-----------
|
|
|
+ drivers/net/dsa/mt7530.h | 1 +
|
|
|
+ 2 files changed, 38 insertions(+), 13 deletions(-)
|
|
|
|
|
|
--- a/drivers/net/dsa/mt7530.c
|
|
|
+++ b/drivers/net/dsa/mt7530.c
|
|
|
-@@ -2703,9 +2703,6 @@ mt7531_mac_config(struct dsa_switch *ds,
|
|
|
+@@ -2699,9 +2699,6 @@ mt7531_mac_config(struct dsa_switch *ds,
|
|
|
case PHY_INTERFACE_MODE_NA:
|
|
|
case PHY_INTERFACE_MODE_1000BASEX:
|
|
|
case PHY_INTERFACE_MODE_2500BASEX:
|
|
@@ -41,7 +29,7 @@ Signed-off-by: Daniel Golle <[email protected]>
|
|
|
return mt7531_sgmii_setup_mode_force(priv, port, interface);
|
|
|
default:
|
|
|
return -EINVAL;
|
|
|
-@@ -2781,13 +2778,6 @@ unsupported:
|
|
|
+@@ -2777,13 +2774,6 @@ unsupported:
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -55,7 +43,7 @@ Signed-off-by: Daniel Golle <[email protected]>
|
|
|
mcr_cur = mt7530_read(priv, MT7530_PMCR_P(port));
|
|
|
mcr_new = mcr_cur;
|
|
|
mcr_new &= ~PMCR_LINK_SETTINGS_MASK;
|
|
|
-@@ -2924,6 +2914,9 @@ static void mt753x_phylink_get_caps(stru
|
|
|
+@@ -2920,6 +2910,9 @@ static void mt753x_phylink_get_caps(stru
|
|
|
config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
|
|
|
MAC_10 | MAC_100 | MAC_1000FD;
|
|
|
|
|
@@ -65,7 +53,15 @@ Signed-off-by: Daniel Golle <[email protected]>
|
|
|
/* This driver does not make use of the speed, duplex, pause or the
|
|
|
* advertisement in its mac_config, so it is safe to mark this driver
|
|
|
* as non-legacy.
|
|
|
-@@ -3019,16 +3012,43 @@ mt7531_sgmii_pcs_get_state_an(struct mt7
|
|
|
+@@ -2985,6 +2978,7 @@ mt7531_sgmii_pcs_get_state_an(struct mt7
|
|
|
+
|
|
|
+ status = mt7530_read(priv, MT7531_PCS_CONTROL_1(port));
|
|
|
+ state->link = !!(status & MT7531_SGMII_LINK_STATUS);
|
|
|
++ state->an_complete = !!(status & MT7531_SGMII_AN_COMPLETE);
|
|
|
+ if (state->interface == PHY_INTERFACE_MODE_SGMII &&
|
|
|
+ (status & MT7531_SGMII_AN_ENABLE)) {
|
|
|
+ val = mt7530_read(priv, MT7531_PCS_SPEED_ABILITY(port));
|
|
|
+@@ -3015,16 +3009,44 @@ mt7531_sgmii_pcs_get_state_an(struct mt7
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -80,13 +76,15 @@ Signed-off-by: Daniel Golle <[email protected]>
|
|
|
+ if (!state->link)
|
|
|
+ return;
|
|
|
+
|
|
|
++ state->an_complete = state->link;
|
|
|
++
|
|
|
+ if (state->interface == PHY_INTERFACE_MODE_2500BASEX)
|
|
|
+ state->speed = SPEED_2500;
|
|
|
+ else
|
|
|
+ state->speed = SPEED_1000;
|
|
|
+
|
|
|
+ state->duplex = DUPLEX_FULL;
|
|
|
-+ state->pause = 0;
|
|
|
++ state->pause = MLO_PAUSE_NONE;
|
|
|
+}
|
|
|
+
|
|
|
static void mt7531_pcs_get_state(struct phylink_pcs *pcs,
|
|
@@ -94,7 +92,6 @@ Signed-off-by: Daniel Golle <[email protected]>
|
|
|
{
|
|
|
struct mt7530_priv *priv = pcs_to_mt753x_pcs(pcs)->priv;
|
|
|
int port = pcs_to_mt753x_pcs(pcs)->port;
|
|
|
-+ unsigned int val;
|
|
|
|
|
|
- if (state->interface == PHY_INTERFACE_MODE_SGMII)
|
|
|
+ if (state->interface == PHY_INTERFACE_MODE_SGMII) {
|
|
@@ -112,7 +109,7 @@ Signed-off-by: Daniel Golle <[email protected]>
|
|
|
}
|
|
|
|
|
|
static int mt753x_pcs_config(struct phylink_pcs *pcs, unsigned int mode,
|
|
|
-@@ -3069,6 +3089,8 @@ mt753x_setup(struct dsa_switch *ds)
|
|
|
+@@ -3065,6 +3087,8 @@ mt753x_setup(struct dsa_switch *ds)
|
|
|
priv->pcs[i].pcs.ops = priv->info->pcs_ops;
|
|
|
priv->pcs[i].priv = priv;
|
|
|
priv->pcs[i].port = i;
|
|
@@ -121,3 +118,13 @@ Signed-off-by: Daniel Golle <[email protected]>
|
|
|
}
|
|
|
|
|
|
ret = priv->info->sw_setup(ds);
|
|
|
+--- a/drivers/net/dsa/mt7530.h
|
|
|
++++ b/drivers/net/dsa/mt7530.h
|
|
|
+@@ -373,6 +373,7 @@ enum mt7530_vlan_port_acc_frm {
|
|
|
+ #define MT7531_SGMII_LINK_STATUS BIT(18)
|
|
|
+ #define MT7531_SGMII_AN_ENABLE BIT(12)
|
|
|
+ #define MT7531_SGMII_AN_RESTART BIT(9)
|
|
|
++#define MT7531_SGMII_AN_COMPLETE BIT(21)
|
|
|
+
|
|
|
+ /* Register for SGMII PCS_SPPED_ABILITY */
|
|
|
+ #define MT7531_PCS_SPEED_ABILITY(p) MT7531_SGMII_REG(p, 0x08)
|