* [PATCH net-next 1/6] net: pcs: rearrange C73 functions to prepare for C37 support later
2021-03-15 5:27 [PATCH net-next 0/6] net: pcs, stmmac: add C37 AN SGMII support Ong Boon Leong
@ 2021-03-15 5:27 ` Ong Boon Leong
2021-03-15 5:27 ` [PATCH net-next 2/6] net: pcs: add C37 SGMII AN support for intel mGbE controller Ong Boon Leong
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Ong Boon Leong @ 2021-03-15 5:27 UTC (permalink / raw)
To: Giuseppe Cavallaro, Andrew Lunn, Heiner Kallweit, Russell King i,
Alexandre Torgue, Jose Abreu, David S . Miller, Jakub Kicinski
Cc: Maxime Coquelin, netdev, linux-stm32, linux-arm-kernel,
linux-kernel, Ong Boon Leong, Voon Weifeng, Wong Vee Khee,
Fugang Duan
The current implementation for XPCS is validated for C73, so we rename them
to have _c73 suffix and introduce a set of functions to use an_mode flag
to switch between C73 and C37 AN later.
Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
---
drivers/net/pcs/pcs-xpcs.c | 94 +++++++++++++++++++++++++-----------
include/linux/pcs/pcs-xpcs.h | 4 ++
2 files changed, 70 insertions(+), 28 deletions(-)
diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index 1aa9903d602e..10def2d98696 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -125,22 +125,26 @@ static struct xpcs_id {
u32 mask;
const int *supported;
const phy_interface_t *interface;
+ int an_mode;
} xpcs_id_list[] = {
{
.id = SYNOPSYS_XPCS_USXGMII_ID,
.mask = SYNOPSYS_XPCS_MASK,
.supported = xpcs_usxgmii_features,
.interface = xpcs_usxgmii_interfaces,
+ .an_mode = DW_AN_C73,
}, {
.id = SYNOPSYS_XPCS_10GKR_ID,
.mask = SYNOPSYS_XPCS_MASK,
.supported = xpcs_10gkr_features,
.interface = xpcs_10gkr_interfaces,
+ .an_mode = DW_AN_C73,
}, {
.id = SYNOPSYS_XPCS_XLGMII_ID,
.mask = SYNOPSYS_XPCS_MASK,
.supported = xpcs_xlgmii_features,
.interface = xpcs_xlgmii_interfaces,
+ .an_mode = DW_AN_C73,
},
};
@@ -195,9 +199,17 @@ static int xpcs_poll_reset(struct mdio_xpcs_args *xpcs, int dev)
return (ret & MDIO_CTRL1_RESET) ? -ETIMEDOUT : 0;
}
-static int xpcs_soft_reset(struct mdio_xpcs_args *xpcs, int dev)
+static int xpcs_soft_reset(struct mdio_xpcs_args *xpcs)
{
- int ret;
+ int ret, dev;
+
+ switch (xpcs->an_mode) {
+ case DW_AN_C73:
+ dev = MDIO_MMD_PCS;
+ break;
+ default:
+ return -1;
+ }
ret = xpcs_write(xpcs, dev, MDIO_CTRL1, MDIO_CTRL1_RESET);
if (ret < 0)
@@ -212,8 +224,8 @@ static int xpcs_soft_reset(struct mdio_xpcs_args *xpcs, int dev)
dev_warn(&(__xpcs)->bus->dev, ##__args); \
})
-static int xpcs_read_fault(struct mdio_xpcs_args *xpcs,
- struct phylink_link_state *state)
+static int xpcs_read_fault_c73(struct mdio_xpcs_args *xpcs,
+ struct phylink_link_state *state)
{
int ret;
@@ -263,7 +275,7 @@ static int xpcs_read_fault(struct mdio_xpcs_args *xpcs,
return 0;
}
-static int xpcs_read_link(struct mdio_xpcs_args *xpcs, bool an)
+static int xpcs_read_link_c73(struct mdio_xpcs_args *xpcs, bool an)
{
bool link = true;
int ret;
@@ -357,7 +369,7 @@ static int xpcs_config_usxgmii(struct mdio_xpcs_args *xpcs, int speed)
return xpcs_write_vpcs(xpcs, MDIO_CTRL1, ret | DW_USXGMII_RST);
}
-static int xpcs_config_aneg_c73(struct mdio_xpcs_args *xpcs)
+static int _xpcs_config_aneg_c73(struct mdio_xpcs_args *xpcs)
{
int ret, adv;
@@ -401,11 +413,11 @@ static int xpcs_config_aneg_c73(struct mdio_xpcs_args *xpcs)
return xpcs_write(xpcs, MDIO_MMD_AN, DW_SR_AN_ADV1, adv);
}
-static int xpcs_config_aneg(struct mdio_xpcs_args *xpcs)
+static int xpcs_config_aneg_c73(struct mdio_xpcs_args *xpcs)
{
int ret;
- ret = xpcs_config_aneg_c73(xpcs);
+ ret = _xpcs_config_aneg_c73(xpcs);
if (ret < 0)
return ret;
@@ -418,8 +430,8 @@ static int xpcs_config_aneg(struct mdio_xpcs_args *xpcs)
return xpcs_write(xpcs, MDIO_MMD_AN, MDIO_CTRL1, ret);
}
-static int xpcs_aneg_done(struct mdio_xpcs_args *xpcs,
- struct phylink_link_state *state)
+static int xpcs_aneg_done_c73(struct mdio_xpcs_args *xpcs,
+ struct phylink_link_state *state)
{
int ret;
@@ -434,7 +446,7 @@ static int xpcs_aneg_done(struct mdio_xpcs_args *xpcs,
/* Check if Aneg outcome is valid */
if (!(ret & DW_C73_AN_ADV_SF)) {
- xpcs_config_aneg(xpcs);
+ xpcs_config_aneg_c73(xpcs);
return 0;
}
@@ -444,8 +456,8 @@ static int xpcs_aneg_done(struct mdio_xpcs_args *xpcs,
return 0;
}
-static int xpcs_read_lpa(struct mdio_xpcs_args *xpcs,
- struct phylink_link_state *state)
+static int xpcs_read_lpa_c73(struct mdio_xpcs_args *xpcs,
+ struct phylink_link_state *state)
{
int ret;
@@ -493,8 +505,8 @@ static int xpcs_read_lpa(struct mdio_xpcs_args *xpcs,
return 0;
}
-static void xpcs_resolve_lpa(struct mdio_xpcs_args *xpcs,
- struct phylink_link_state *state)
+static void xpcs_resolve_lpa_c73(struct mdio_xpcs_args *xpcs,
+ struct phylink_link_state *state)
{
int max_speed = xpcs_get_max_usxgmii_speed(state->lp_advertising);
@@ -590,27 +602,33 @@ static int xpcs_config(struct mdio_xpcs_args *xpcs,
{
int ret;
- if (state->an_enabled) {
- ret = xpcs_config_aneg(xpcs);
- if (ret)
- return ret;
+ switch (xpcs->an_mode) {
+ case DW_AN_C73:
+ if (state->an_enabled) {
+ ret = xpcs_config_aneg_c73(xpcs);
+ if (ret)
+ return ret;
+ }
+ break;
+ default:
+ return -1;
}
return 0;
}
-static int xpcs_get_state(struct mdio_xpcs_args *xpcs,
- struct phylink_link_state *state)
+static int xpcs_get_state_c73(struct mdio_xpcs_args *xpcs,
+ struct phylink_link_state *state)
{
int ret;
/* Link needs to be read first ... */
- state->link = xpcs_read_link(xpcs, state->an_enabled) > 0 ? 1 : 0;
+ state->link = xpcs_read_link_c73(xpcs, state->an_enabled) > 0 ? 1 : 0;
/* ... and then we check the faults. */
- ret = xpcs_read_fault(xpcs, state);
+ ret = xpcs_read_fault_c73(xpcs, state);
if (ret) {
- ret = xpcs_soft_reset(xpcs, MDIO_MMD_PCS);
+ ret = xpcs_soft_reset(xpcs);
if (ret)
return ret;
@@ -619,10 +637,10 @@ static int xpcs_get_state(struct mdio_xpcs_args *xpcs,
return xpcs_config(xpcs, state);
}
- if (state->an_enabled && xpcs_aneg_done(xpcs, state)) {
+ if (state->an_enabled && xpcs_aneg_done_c73(xpcs, state)) {
state->an_complete = true;
- xpcs_read_lpa(xpcs, state);
- xpcs_resolve_lpa(xpcs, state);
+ xpcs_read_lpa_c73(xpcs, state);
+ xpcs_resolve_lpa_c73(xpcs, state);
} else if (state->an_enabled) {
state->link = 0;
} else if (state->link) {
@@ -632,6 +650,24 @@ static int xpcs_get_state(struct mdio_xpcs_args *xpcs,
return 0;
}
+static int xpcs_get_state(struct mdio_xpcs_args *xpcs,
+ struct phylink_link_state *state)
+{
+ int ret;
+
+ switch (xpcs->an_mode) {
+ case DW_AN_C73:
+ ret = xpcs_get_state_c73(xpcs, state);
+ if (ret)
+ return ret;
+ break;
+ default:
+ return -1;
+ }
+
+ return 0;
+}
+
static int xpcs_link_up(struct mdio_xpcs_args *xpcs, int speed,
phy_interface_t interface)
{
@@ -676,6 +712,8 @@ static bool xpcs_check_features(struct mdio_xpcs_args *xpcs,
for (i = 0; match->supported[i] != __ETHTOOL_LINK_MODE_MASK_NBITS; i++)
set_bit(match->supported[i], xpcs->supported);
+ xpcs->an_mode = match->an_mode;
+
return true;
}
@@ -692,7 +730,7 @@ static int xpcs_probe(struct mdio_xpcs_args *xpcs, phy_interface_t interface)
match = entry;
if (xpcs_check_features(xpcs, match, interface))
- return xpcs_soft_reset(xpcs, MDIO_MMD_PCS);
+ return xpcs_soft_reset(xpcs);
}
}
diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h
index 351c1c9aedc5..a04e57c25fea 100644
--- a/include/linux/pcs/pcs-xpcs.h
+++ b/include/linux/pcs/pcs-xpcs.h
@@ -10,10 +10,14 @@
#include <linux/phy.h>
#include <linux/phylink.h>
+/* AN mode */
+#define DW_AN_C73 1
+
struct mdio_xpcs_args {
__ETHTOOL_DECLARE_LINK_MODE_MASK(supported);
struct mii_bus *bus;
int addr;
+ int an_mode;
};
struct mdio_xpcs_ops {
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 2/6] net: pcs: add C37 SGMII AN support for intel mGbE controller
2021-03-15 5:27 [PATCH net-next 0/6] net: pcs, stmmac: add C37 AN SGMII support Ong Boon Leong
2021-03-15 5:27 ` [PATCH net-next 1/6] net: pcs: rearrange C73 functions to prepare for C37 support later Ong Boon Leong
@ 2021-03-15 5:27 ` Ong Boon Leong
2021-03-15 5:27 ` [PATCH net-next 3/6] net: phylink: make phylink_parse_mode() support non-DT platform Ong Boon Leong
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Ong Boon Leong @ 2021-03-15 5:27 UTC (permalink / raw)
To: Giuseppe Cavallaro, Andrew Lunn, Heiner Kallweit, Russell King i,
Alexandre Torgue, Jose Abreu, David S . Miller, Jakub Kicinski
Cc: Maxime Coquelin, netdev, linux-stm32, linux-arm-kernel,
linux-kernel, Ong Boon Leong, Voon Weifeng, Wong Vee Khee,
Fugang Duan
XPCS IP supports C37 SGMII AN process and it is used in intel multi-GbE
controller as MAC-side SGMII.
Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
---
drivers/net/pcs/pcs-xpcs.c | 167 ++++++++++++++++++++++++++++++++++-
include/linux/pcs/pcs-xpcs.h | 1 +
2 files changed, 167 insertions(+), 1 deletion(-)
diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index 10def2d98696..944ba105cac1 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -15,6 +15,7 @@
#define SYNOPSYS_XPCS_USXGMII_ID 0x7996ced0
#define SYNOPSYS_XPCS_10GKR_ID 0x7996ced0
#define SYNOPSYS_XPCS_XLGMII_ID 0x7996ced0
+#define SYNOPSYS_XPCS_SGMII_ID 0x7996ced0
#define SYNOPSYS_XPCS_MASK 0xffffffff
/* Vendor regs access */
@@ -57,6 +58,34 @@
#define DW_C73_2500KX BIT(0)
#define DW_C73_5000KR BIT(1)
+/* Clause 37 Defines */
+/* VR MII MMD registers offsets */
+#define DW_VR_MII_DIG_CTRL1 0x8000
+#define DW_VR_MII_AN_CTRL 0x8001
+#define DW_VR_MII_AN_INTR_STS 0x8002
+
+/* VR_MII_DIG_CTRL1 */
+#define DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW BIT(9)
+
+/* VR_MII_AN_CTRL */
+#define DW_VR_MII_AN_CTRL_TX_CONFIG_SHIFT 3
+#define DW_VR_MII_TX_CONFIG_MASK BIT(3)
+#define DW_VR_MII_TX_CONFIG_PHY_SIDE_SGMII 0x1
+#define DW_VR_MII_TX_CONFIG_MAC_SIDE_SGMII 0x0
+#define DW_VR_MII_AN_CTRL_PCS_MODE_SHIFT 1
+#define DW_VR_MII_PCS_MODE_MASK GENMASK(2, 1)
+#define DW_VR_MII_PCS_MODE_C37_1000BASEX 0x0
+#define DW_VR_MII_PCS_MODE_C37_SGMII 0x2
+
+/* VR_MII_AN_INTR_STS */
+#define DW_VR_MII_AN_STS_C37_ANSGM_FD BIT(1)
+#define DW_VR_MII_AN_STS_C37_ANSGM_SP_SHIFT 2
+#define DW_VR_MII_AN_STS_C37_ANSGM_SP GENMASK(3, 2)
+#define DW_VR_MII_C37_ANSGM_SP_10 0x0
+#define DW_VR_MII_C37_ANSGM_SP_100 0x1
+#define DW_VR_MII_C37_ANSGM_SP_1000 0x2
+#define DW_VR_MII_C37_ANSGM_SP_LNKSTS BIT(4)
+
static const int xpcs_usxgmii_features[] = {
ETHTOOL_LINK_MODE_Pause_BIT,
ETHTOOL_LINK_MODE_Asym_Pause_BIT,
@@ -105,6 +134,16 @@ static const int xpcs_xlgmii_features[] = {
__ETHTOOL_LINK_MODE_MASK_NBITS,
};
+static const int xpcs_sgmii_features[] = {
+ ETHTOOL_LINK_MODE_10baseT_Half_BIT,
+ ETHTOOL_LINK_MODE_10baseT_Full_BIT,
+ ETHTOOL_LINK_MODE_100baseT_Half_BIT,
+ ETHTOOL_LINK_MODE_100baseT_Full_BIT,
+ ETHTOOL_LINK_MODE_1000baseT_Half_BIT,
+ ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
+ __ETHTOOL_LINK_MODE_MASK_NBITS,
+};
+
static const phy_interface_t xpcs_usxgmii_interfaces[] = {
PHY_INTERFACE_MODE_USXGMII,
PHY_INTERFACE_MODE_MAX,
@@ -120,6 +159,11 @@ static const phy_interface_t xpcs_xlgmii_interfaces[] = {
PHY_INTERFACE_MODE_MAX,
};
+static const phy_interface_t xpcs_sgmii_interfaces[] = {
+ PHY_INTERFACE_MODE_SGMII,
+ PHY_INTERFACE_MODE_MAX,
+};
+
static struct xpcs_id {
u32 id;
u32 mask;
@@ -145,6 +189,12 @@ static struct xpcs_id {
.supported = xpcs_xlgmii_features,
.interface = xpcs_xlgmii_interfaces,
.an_mode = DW_AN_C73,
+ }, {
+ .id = SYNOPSYS_XPCS_SGMII_ID,
+ .mask = SYNOPSYS_XPCS_MASK,
+ .supported = xpcs_sgmii_features,
+ .interface = xpcs_sgmii_interfaces,
+ .an_mode = DW_AN_C37_SGMII,
},
};
@@ -207,6 +257,9 @@ static int xpcs_soft_reset(struct mdio_xpcs_args *xpcs)
case DW_AN_C73:
dev = MDIO_MMD_PCS;
break;
+ case DW_AN_C37_SGMII:
+ dev = MDIO_MMD_VEND2;
+ break;
default:
return -1;
}
@@ -597,6 +650,47 @@ static int xpcs_validate(struct mdio_xpcs_args *xpcs,
return 0;
}
+static int xpcs_config_aneg_c37_sgmii(struct mdio_xpcs_args *xpcs)
+{
+ int ret;
+
+ /* For AN for C37 SGMII mode, the settings are :-
+ * 1) VR_MII_AN_CTRL Bit(2:1)[PCS_MODE] = 10b (SGMII AN)
+ * 2) VR_MII_AN_CTRL Bit(3) [TX_CONFIG] = 0b (MAC side SGMII)
+ * DW xPCS used with DW EQoS MAC is always MAC side SGMII.
+ * 3) VR_MII_DIG_CTRL1 Bit(9) [MAC_AUTO_SW] = 1b (Automatic
+ * speed/duplex mode change by HW after SGMII AN complete)
+ *
+ * Note: Since it is MAC side SGMII, there is no need to set
+ * SR_MII_AN_ADV. MAC side SGMII receives AN Tx Config from
+ * PHY about the link state change after C28 AN is completed
+ * between PHY and Link Partner. There is also no need to
+ * trigger AN restart for MAC-side SGMII.
+ */
+ ret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_CTRL);
+ if (ret < 0)
+ return ret;
+
+ ret &= ~(DW_VR_MII_PCS_MODE_MASK | DW_VR_MII_TX_CONFIG_MASK);
+ ret |= (DW_VR_MII_PCS_MODE_C37_SGMII <<
+ DW_VR_MII_AN_CTRL_PCS_MODE_SHIFT &
+ DW_VR_MII_PCS_MODE_MASK);
+ ret |= (DW_VR_MII_TX_CONFIG_MAC_SIDE_SGMII <<
+ DW_VR_MII_AN_CTRL_TX_CONFIG_SHIFT &
+ DW_VR_MII_TX_CONFIG_MASK);
+ ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_CTRL, ret);
+ if (ret < 0)
+ return ret;
+
+ ret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_DIG_CTRL1);
+ if (ret < 0)
+ return ret;
+
+ ret |= DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW;
+
+ return xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_DIG_CTRL1, ret);
+}
+
static int xpcs_config(struct mdio_xpcs_args *xpcs,
const struct phylink_link_state *state)
{
@@ -610,6 +704,11 @@ static int xpcs_config(struct mdio_xpcs_args *xpcs,
return ret;
}
break;
+ case DW_AN_C37_SGMII:
+ ret = xpcs_config_aneg_c37_sgmii(xpcs);
+ if (ret)
+ return ret;
+ break;
default:
return -1;
}
@@ -650,6 +749,47 @@ static int xpcs_get_state_c73(struct mdio_xpcs_args *xpcs,
return 0;
}
+static int xpcs_get_state_c37_sgmii(struct mdio_xpcs_args *xpcs,
+ struct phylink_link_state *state)
+{
+ int ret;
+
+ /* Reset link_state */
+ state->link = false;
+ state->speed = SPEED_UNKNOWN;
+ state->duplex = DUPLEX_UNKNOWN;
+ state->pause = 0;
+
+ /* For C37 SGMII mode, we check DW_VR_MII_AN_INTR_STS for link
+ * status, speed and duplex.
+ */
+ ret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS);
+ if (ret < 0)
+ return false;
+
+ if (ret & DW_VR_MII_C37_ANSGM_SP_LNKSTS) {
+ int speed_value;
+
+ state->link = true;
+
+ speed_value = (ret & DW_VR_MII_AN_STS_C37_ANSGM_SP) >>
+ DW_VR_MII_AN_STS_C37_ANSGM_SP_SHIFT;
+ if (speed_value == DW_VR_MII_C37_ANSGM_SP_1000)
+ state->speed = SPEED_1000;
+ else if (speed_value == DW_VR_MII_C37_ANSGM_SP_100)
+ state->speed = SPEED_100;
+ else
+ state->speed = SPEED_10;
+
+ if (ret & DW_VR_MII_AN_STS_C37_ANSGM_FD)
+ state->duplex = DUPLEX_FULL;
+ else
+ state->duplex = DUPLEX_HALF;
+ }
+
+ return 0;
+}
+
static int xpcs_get_state(struct mdio_xpcs_args *xpcs,
struct phylink_link_state *state)
{
@@ -661,6 +801,11 @@ static int xpcs_get_state(struct mdio_xpcs_args *xpcs,
if (ret)
return ret;
break;
+ case DW_AN_C37_SGMII:
+ ret = xpcs_get_state_c37_sgmii(xpcs, state);
+ if (ret)
+ return ret;
+ break;
default:
return -1;
}
@@ -682,6 +827,7 @@ static u32 xpcs_get_id(struct mdio_xpcs_args *xpcs)
int ret;
u32 id;
+ /* First, search C73 PCS using PCS MMD */
ret = xpcs_read(xpcs, MDIO_MMD_PCS, MII_PHYSID1);
if (ret < 0)
return 0xffffffff;
@@ -692,7 +838,26 @@ static u32 xpcs_get_id(struct mdio_xpcs_args *xpcs)
if (ret < 0)
return 0xffffffff;
- return id | ret;
+ /* If Device IDs are not all zeros, we found C73 AN-type device */
+ if (id | ret)
+ return id | ret;
+
+ /* Next, search C37 PCS using Vendor-Specific MII MMD */
+ ret = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_PHYSID1);
+ if (ret < 0)
+ return 0xffffffff;
+
+ id = ret << 16;
+
+ ret = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_PHYSID2);
+ if (ret < 0)
+ return 0xffffffff;
+
+ /* If Device IDs are not all zeros, we found C37 AN-type device */
+ if (id | ret)
+ return id | ret;
+
+ return 0xffffffff;
}
static bool xpcs_check_features(struct mdio_xpcs_args *xpcs,
diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h
index a04e57c25fea..2cb5188a7ef1 100644
--- a/include/linux/pcs/pcs-xpcs.h
+++ b/include/linux/pcs/pcs-xpcs.h
@@ -12,6 +12,7 @@
/* AN mode */
#define DW_AN_C73 1
+#define DW_AN_C37_SGMII 2
struct mdio_xpcs_args {
__ETHTOOL_DECLARE_LINK_MODE_MASK(supported);
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 3/6] net: phylink: make phylink_parse_mode() support non-DT platform
2021-03-15 5:27 [PATCH net-next 0/6] net: pcs, stmmac: add C37 AN SGMII support Ong Boon Leong
2021-03-15 5:27 ` [PATCH net-next 1/6] net: pcs: rearrange C73 functions to prepare for C37 support later Ong Boon Leong
2021-03-15 5:27 ` [PATCH net-next 2/6] net: pcs: add C37 SGMII AN support for intel mGbE controller Ong Boon Leong
@ 2021-03-15 5:27 ` Ong Boon Leong
2021-03-15 5:27 ` [PATCH net-next 4/6] net: stmmac: make in-band AN mode parsing is supported for non-DT Ong Boon Leong
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Ong Boon Leong @ 2021-03-15 5:27 UTC (permalink / raw)
To: Giuseppe Cavallaro, Andrew Lunn, Heiner Kallweit, Russell King i,
Alexandre Torgue, Jose Abreu, David S . Miller, Jakub Kicinski
Cc: Maxime Coquelin, netdev, linux-stm32, linux-arm-kernel,
linux-kernel, Ong Boon Leong, Voon Weifeng, Wong Vee Khee,
Fugang Duan
Certain platform does not support DT, so we make phylink_parse_mode() to
allow non-DT platform to use it to setup in-band AN advertising.
Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
---
drivers/net/phy/phylink.c | 5 +++--
include/linux/phylink.h | 2 ++
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index dc2800beacc3..96d8e88b4e46 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -271,8 +271,9 @@ static int phylink_parse_mode(struct phylink *pl, struct fwnode_handle *fwnode)
pl->cfg_link_an_mode = MLO_AN_FIXED;
fwnode_handle_put(dn);
- if (fwnode_property_read_string(fwnode, "managed", &managed) == 0 &&
- strcmp(managed, "in-band-status") == 0) {
+ if ((fwnode_property_read_string(fwnode, "managed", &managed) == 0 &&
+ strcmp(managed, "in-band-status") == 0) ||
+ pl->config->ovr_an_inband) {
if (pl->cfg_link_an_mode == MLO_AN_FIXED) {
phylink_err(pl,
"can't use both fixed-link and in-band-status\n");
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index d81a714cfbbd..fd2acfd9b597 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -64,6 +64,7 @@ enum phylink_op_type {
* @pcs_poll: MAC PCS cannot provide link change interrupt
* @poll_fixed_state: if true, starts link_poll,
* if MAC link is at %MLO_AN_FIXED mode.
+ * @ovr_an_inband: if true, override PCS to MLO_AN_INBAND
* @get_fixed_state: callback to execute to determine the fixed link state,
* if MAC link is at %MLO_AN_FIXED mode.
*/
@@ -72,6 +73,7 @@ struct phylink_config {
enum phylink_op_type type;
bool pcs_poll;
bool poll_fixed_state;
+ bool ovr_an_inband;
void (*get_fixed_state)(struct phylink_config *config,
struct phylink_link_state *state);
};
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 4/6] net: stmmac: make in-band AN mode parsing is supported for non-DT
2021-03-15 5:27 [PATCH net-next 0/6] net: pcs, stmmac: add C37 AN SGMII support Ong Boon Leong
` (2 preceding siblings ...)
2021-03-15 5:27 ` [PATCH net-next 3/6] net: phylink: make phylink_parse_mode() support non-DT platform Ong Boon Leong
@ 2021-03-15 5:27 ` Ong Boon Leong
2021-03-15 5:27 ` [PATCH net-next 5/6] net: stmmac: ensure phydev is attached to phylink for C37 AN Ong Boon Leong
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Ong Boon Leong @ 2021-03-15 5:27 UTC (permalink / raw)
To: Giuseppe Cavallaro, Andrew Lunn, Heiner Kallweit, Russell King i,
Alexandre Torgue, Jose Abreu, David S . Miller, Jakub Kicinski
Cc: Maxime Coquelin, netdev, linux-stm32, linux-arm-kernel,
linux-kernel, Ong Boon Leong, Voon Weifeng, Wong Vee Khee,
Fugang Duan
Not all platform uses DT, so phylink_parse_mode() will skip in-band setup
of pl->supported and pl->link_config.advertising entirely. So, we add the
setting of ovr_an_inband flag to make it works for non-DT platform.
Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 ++
include/linux/stmmac.h | 1 +
2 files changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 208cae344ffa..b64ee029d41f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1117,6 +1117,8 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
priv->phylink_config.dev = &priv->dev->dev;
priv->phylink_config.type = PHYLINK_NETDEV;
priv->phylink_config.pcs_poll = true;
+ priv->phylink_config.ovr_an_inband =
+ priv->plat->mdio_bus_data->xpcs_an_inband;
if (!fwnode)
fwnode = dev_fwnode(priv->device);
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index a302982de2d7..722dc167b5c9 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -81,6 +81,7 @@
struct stmmac_mdio_bus_data {
unsigned int phy_mask;
unsigned int has_xpcs;
+ unsigned int xpcs_an_inband;
int *irqs;
int probed_phy_irq;
bool needs_reset;
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 5/6] net: stmmac: ensure phydev is attached to phylink for C37 AN
2021-03-15 5:27 [PATCH net-next 0/6] net: pcs, stmmac: add C37 AN SGMII support Ong Boon Leong
` (3 preceding siblings ...)
2021-03-15 5:27 ` [PATCH net-next 4/6] net: stmmac: make in-band AN mode parsing is supported for non-DT Ong Boon Leong
@ 2021-03-15 5:27 ` Ong Boon Leong
2021-03-15 5:27 ` [PATCH net-next 6/6] stmmac: intel: add pcs-xpcs for Intel mGbE controller Ong Boon Leong
2021-03-15 20:00 ` [PATCH net-next 0/6] net: pcs, stmmac: add C37 AN SGMII support patchwork-bot+netdevbpf
6 siblings, 0 replies; 8+ messages in thread
From: Ong Boon Leong @ 2021-03-15 5:27 UTC (permalink / raw)
To: Giuseppe Cavallaro, Andrew Lunn, Heiner Kallweit, Russell King i,
Alexandre Torgue, Jose Abreu, David S . Miller, Jakub Kicinski
Cc: Maxime Coquelin, netdev, linux-stm32, linux-arm-kernel,
linux-kernel, Ong Boon Leong, Voon Weifeng, Wong Vee Khee,
Fugang Duan
As the support for MAC-side SGMII C37 AN is added to pcs-xpcs, phydev
should be attached to phylink during driver's open(). So, we change the
condition to "Not C73 AN" instead.
Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index b64ee029d41f..e58ff652e95f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2898,7 +2898,7 @@ static int stmmac_open(struct net_device *dev)
if (priv->hw->pcs != STMMAC_PCS_TBI &&
priv->hw->pcs != STMMAC_PCS_RTBI &&
- priv->hw->xpcs == NULL) {
+ priv->hw->xpcs_args.an_mode != DW_AN_C73) {
ret = stmmac_init_phy(dev);
if (ret) {
netdev_err(priv->dev,
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 6/6] stmmac: intel: add pcs-xpcs for Intel mGbE controller
2021-03-15 5:27 [PATCH net-next 0/6] net: pcs, stmmac: add C37 AN SGMII support Ong Boon Leong
` (4 preceding siblings ...)
2021-03-15 5:27 ` [PATCH net-next 5/6] net: stmmac: ensure phydev is attached to phylink for C37 AN Ong Boon Leong
@ 2021-03-15 5:27 ` Ong Boon Leong
2021-03-15 20:00 ` [PATCH net-next 0/6] net: pcs, stmmac: add C37 AN SGMII support patchwork-bot+netdevbpf
6 siblings, 0 replies; 8+ messages in thread
From: Ong Boon Leong @ 2021-03-15 5:27 UTC (permalink / raw)
To: Giuseppe Cavallaro, Andrew Lunn, Heiner Kallweit, Russell King i,
Alexandre Torgue, Jose Abreu, David S . Miller, Jakub Kicinski
Cc: Maxime Coquelin, netdev, linux-stm32, linux-arm-kernel,
linux-kernel, Ong Boon Leong, Voon Weifeng, Wong Vee Khee,
Fugang Duan
Intel mGbE controller such as those in EHL & TGL uses pcs-xpcs driver for
SGMII interface. To ensure mdio bus scanning does not assign phy_device
to MDIO-addressable entities like intel serdes and pcs-xpcs, we set up
to phy_mask to skip them.
Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
index 0b64f7710d17..c49646773871 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
@@ -9,6 +9,9 @@
#include "dwmac4.h"
#include "stmmac.h"
+#define INTEL_MGBE_ADHOC_ADDR 0x15
+#define INTEL_MGBE_XPCS_ADDR 0x16
+
struct intel_priv_data {
int mdio_adhoc_addr; /* mdio address for serdes & etc */
};
@@ -333,6 +336,16 @@ static int intel_mgbe_common_data(struct pci_dev *pdev,
/* Use the last Rx queue */
plat->vlan_fail_q = plat->rx_queues_to_use - 1;
+ /* Intel mgbe SGMII interface uses pcs-xcps */
+ if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII) {
+ plat->mdio_bus_data->has_xpcs = true;
+ plat->mdio_bus_data->xpcs_an_inband = true;
+ }
+
+ /* Ensure mdio bus scan skips intel serdes and pcs-xpcs */
+ plat->mdio_bus_data->phy_mask = 1 << INTEL_MGBE_ADHOC_ADDR;
+ plat->mdio_bus_data->phy_mask |= 1 << INTEL_MGBE_XPCS_ADDR;
+
return 0;
}
@@ -664,7 +677,7 @@ static int intel_eth_pci_probe(struct pci_dev *pdev,
pci_set_master(pdev);
plat->bsp_priv = intel_priv;
- intel_priv->mdio_adhoc_addr = 0x15;
+ intel_priv->mdio_adhoc_addr = INTEL_MGBE_ADHOC_ADDR;
ret = info->setup(pdev, plat);
if (ret)
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 0/6] net: pcs, stmmac: add C37 AN SGMII support
2021-03-15 5:27 [PATCH net-next 0/6] net: pcs, stmmac: add C37 AN SGMII support Ong Boon Leong
` (5 preceding siblings ...)
2021-03-15 5:27 ` [PATCH net-next 6/6] stmmac: intel: add pcs-xpcs for Intel mGbE controller Ong Boon Leong
@ 2021-03-15 20:00 ` patchwork-bot+netdevbpf
6 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-03-15 20:00 UTC (permalink / raw)
To: Ong Boon Leong
Cc: peppe.cavallaro, andrew, hkallweit1, linux, alexandre.torgue,
joabreu, davem, kuba, mcoquelin.stm32, netdev, linux-stm32,
linux-arm-kernel, linux-kernel, weifeng.voon, vee.khee.wong,
fugang.duan
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
On Mon, 15 Mar 2021 13:27:05 +0800 you wrote:
> Hi all,
>
> This patch series adds MAC-side SGMII support to stmmac driver and it is
> changed as follow:-
>
> 1/6: Refactor the current C73 implementation in pcs-xpcs to prepare for
> adding C37 AN later.
> 2/6: Add MAC-side SGMII C37 AN support to pcs-xpcs
> 3,4/6: make phylink_parse_mode() to work for non-DT platform so that
> we can use stmmac platform_data to set it.
> 5/6: Make stmmac_open() to only skip PHY init if C73 is used, otherwise
> C37 AN will need phydev to be connected to phylink.
> 6/6: Finally, add pcs-xpcs SGMII interface support to Intel mGbE
> controller.
>
> [...]
Here is the summary with links:
- [net-next,1/6] net: pcs: rearrange C73 functions to prepare for C37 support later
https://git.kernel.org/netdev/net-next/c/07a4bc51fc73
- [net-next,2/6] net: pcs: add C37 SGMII AN support for intel mGbE controller
https://git.kernel.org/netdev/net-next/c/b97b5331b8ab
- [net-next,3/6] net: phylink: make phylink_parse_mode() support non-DT platform
https://git.kernel.org/netdev/net-next/c/ab39385021d1
- [net-next,4/6] net: stmmac: make in-band AN mode parsing is supported for non-DT
https://git.kernel.org/netdev/net-next/c/e5e5b771f684
- [net-next,5/6] net: stmmac: ensure phydev is attached to phylink for C37 AN
https://git.kernel.org/netdev/net-next/c/c62808e8105f
- [net-next,6/6] stmmac: intel: add pcs-xpcs for Intel mGbE controller
https://git.kernel.org/netdev/net-next/c/7310fe538ea5
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 8+ messages in thread