Port the SJA1105 DSA driver to XPCS
Subsystems (8)
Vladimir Oltean
maintainerv3 cover Port the SJA1105 DSA driver to XPCS
From: Vladimir Oltean <[email protected]>
As requested when adding support for the NXP SJA1110, the SJA1105 driver could make use of the common XPCS driver, to eliminate some hardware specific code duplication.
This series modifies the XPCS driver so that it can accommodate the XPCS instantiation from NXP switches, and the SJA1105 driver so it can expose what the XPCS driver expects.
Tested on NXP SJA1105S and SJA1110A.
Changes in v3:
None. This is a resend of v2 which had "changes requested" even though there was no direct feedback.
Changes in v2:
- fix module build (pcs-xpcs-nxp.c is not a different module so this means that we need to change the name of pcs-xpcs.ko to pcs_xpcs.ko).
- delete sja1105_sgmii.h
- just check for priv->pcs[port] instead of checking the PHY interface mode each time.
- add the 2500base-x check in one place where it was missing (before mdio_device_create)
- remove it from a few places where it is no longer necessary now that we check more generically for the presence of priv->xpcs[port]
Vladimir Oltean (13):
net: pcs: xpcs: rename mdio_xpcs_args to dw_xpcs
net: stmmac: reverse Christmas tree notation in stmmac_xpcs_setup
net: stmmac: reduce indentation when calling stmmac_xpcs_setup
net: pcs: xpcs: move register bit descriptions to a header file
net: pcs: xpcs: add support for sgmii with no inband AN
net: pcs: xpcs: also ignore phy id if it's all ones
net: pcs: xpcs: add support for NXP SJA1105
net: pcs: xpcs: add support for NXP SJA1110
net: pcs: xpcs: export xpcs_do_config and xpcs_link_up
net: dsa: sja1105: migrate to xpcs for SGMII
net: dsa: sja1105: register the PCS MDIO bus for SJA1110
net: dsa: sja1105: SGMII and 2500base-x on the SJA1110 are 'special'
net: dsa: sja1105: plug in support for 2500base-x
MAINTAINERS | 2 + drivers/net/dsa/sja1105/Kconfig | 1 + drivers/net/dsa/sja1105/sja1105.h | 9 + drivers/net/dsa/sja1105/sja1105_main.c | 186 +++---------- drivers/net/dsa/sja1105/sja1105_mdio.c | 255 +++++++++++++++++ drivers/net/dsa/sja1105/sja1105_sgmii.h | 53 ---- drivers/net/dsa/sja1105/sja1105_spi.c | 17 ++ drivers/net/ethernet/stmicro/stmmac/common.h | 2 +- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 10 +- .../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 6 +- drivers/net/pcs/Makefile | 4 +- drivers/net/pcs/pcs-xpcs-nxp.c | 185 ++++++++++++ drivers/net/pcs/pcs-xpcs.c | 263 +++++++++--------- drivers/net/pcs/pcs-xpcs.h | 115 ++++++++ include/linux/pcs/pcs-xpcs.h | 21 +- 15 files changed, 772 insertions(+), 357 deletions(-) delete mode 100644 drivers/net/dsa/sja1105/sja1105_sgmii.h create mode 100644 drivers/net/pcs/pcs-xpcs-nxp.c create mode 100644 drivers/net/pcs/pcs-xpcs.h
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 1/13 net: pcs: xpcs: rename mdio_xpcs_args to dw_xpcs
From: Vladimir Oltean <[email protected]>
The struct mdio_xpcs_args is reminiscent of when a similarly named struct mdio_xpcs_ops existed. Now that that is removed, we can shorten the name to dw_xpcs (dw for DesignWare).
---v2->v3: nonev1->v2: none
drivers/net/ethernet/stmicro/stmmac/common.h | 2 +- .../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 2 +- drivers/net/pcs/pcs-xpcs.c | 73 +++++++++---------- include/linux/pcs/pcs-xpcs.h | 14 ++-- 4 files changed, 45 insertions(+), 46 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +1 -1
@@ -503,7 +503,7 @@ struct mac_device_info {const struct stmmac_hwtimestamp *ptp;const struct stmmac_tc_ops *tc;const struct stmmac_mmc_ops *mmc; -struct mdio_xpcs_args *xpcs; +struct dw_xpcs *xpcs;struct mii_regs mii;/* MII register Addresses */ struct mac_link link;void __iomem *pcsr;/* vpointer to device CSRs */
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +1 -1
@@ -401,7 +401,7 @@ int stmmac_xpcs_setup(struct mii_bus *bus) {int mode, addr;struct net_device *ndev = bus->priv; -struct mdio_xpcs_args *xpcs; +struct dw_xpcs *xpcs;struct stmmac_priv *priv;struct mdio_device *mdiodev;
drivers/net/pcs/pcs-xpcs.c +36 -37
262 lines not on this page · raw message
include/linux/pcs/pcs-xpcs.h +7 -7
@@ -17,19 +17,19 @@struct xpcs_id ; -struct mdio_xpcs_args { +struct dw_xpcs {struct mdio_device *mdiodev;const struct xpcs_id *id;struct phylink_pcs pcs; }; -int xpcs_get_an_mode (struct mdio_xpcs_args *xpcs,phy_interface_t interface); -void xpcs_validate (struct mdio_xpcs_args *xpcs,unsigned long *supported, +int xpcs_get_an_mode (struct dw_xpcs *xpcs,phy_interface_t interface); +void xpcs_validate (struct dw_xpcs *xpcs,unsigned long *supported,struct phylink_link_state *state); -int xpcs_config_eee (struct mdio_xpcs_args *xpcs,int mult_fact_100ns, +int xpcs_config_eee (struct dw_xpcs *xpcs,int mult_fact_100ns,int enable); -struct mdio_xpcs_args *xpcs_create (struct mdio_device *mdiodev, -phy_interface_t interface); -void xpcs_destroy (struct mdio_xpcs_args *xpcs); +struct dw_xpcs *xpcs_create (struct mdio_device *mdiodev, +phy_interface_t interface); +void xpcs_destroy (struct dw_xpcs *xpcs);#endif /* __LINUX_PCS_XPCS_H */
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 2/13 net: stmmac: reverse Christmas tree notation in stmmac_xpcs_setup
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Reorder the variable declarations in descending line length order, according to the networking coding style.
---v2->v3: nonev1->v2: none
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +3 -3
@@ -399,11 +399,11 @@ int stmmac_mdio_reset(struct mii_bus *bus)int stmmac_xpcs_setup (struct mii_bus *bus) { -int mode, addr;struct net_device *ndev = bus->priv; -struct dw_xpcs *xpcs; -struct stmmac_priv *priv;struct mdio_device *mdiodev; +struct stmmac_priv *priv; +struct dw_xpcs *xpcs; +int mode, addr; priv =netdev_priv (ndev); mode = priv->plat->phy_interface;
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 3/13 net: stmmac: reduce indentation when calling stmmac_xpcs_setup
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
There is no reason to embed an if within an if, we can just logically AND the two conditions.
---v2->v3: nonev1->v2: none
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -6
@@ -7003,12 +7003,10 @@ int stmmac_dvr_probe(struct device *device,if (priv->plat->speed_mode_2500) priv->plat->speed_mode_2500 (ndev, priv->plat->bsp_priv); -if (priv->plat->mdio_bus_data) { -if (priv->plat->mdio_bus_data->has_xpcs) { - ret =stmmac_xpcs_setup (priv->mii); -if (ret) - goto error_xpcs_setup; - } +if (priv->plat->mdio_bus_data && priv->plat->mdio_bus_data->has_xpcs) { + ret =stmmac_xpcs_setup (priv->mii); +if (ret) + goto error_xpcs_setup; } ret =stmmac_phy_setup (priv);
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 4/13 net: pcs: xpcs: move register bit descriptions to a header file
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Vendors which integrate the Designware XPCS might modify a few things here and there, and to support those, it's best to create separate C files in order to not clutter up the main pcs-xpcs.c.
Because the vendor files might want to access the common xpcs registers too, let's move them in a header file which is local to this driver and can be included by vendor files as appropriate.
---v2->v3: nonev1->v2: none
MAINTAINERS | 1 + drivers/net/pcs/pcs-xpcs.c | 97 +--------------------------------- drivers/net/pcs/pcs-xpcs.h | 103 +++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 96 deletions(-) create mode 100644 drivers/net/pcs/pcs-xpcs.h
MAINTAINERS +1 -0
@@ -17674,6 +17674,7 @@ M: Jose Abreu <[email protected]> L: [email protected] S: Supported F: drivers/net/pcs/pcs-xpcs.c +F: drivers/net/pcs/pcs-xpcs.h F: include/linux/pcs/pcs-xpcs.h SYNOPSYS DESIGNWARE I2C DRIVER
drivers/net/pcs/pcs-xpcs.c +1 -96
103 lines not on this page · raw message
drivers/net/pcs/pcs-xpcs.h new file +103 -0
103 lines not on this page · raw message
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 5/13 net: pcs: xpcs: add support for sgmii with no inband AN
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
In fixed-link use cases, the XPCS can disable the clause 37 in-band autoneg process, disable the "Automatic Speed Mode Change after CL37 AN" setting, and force operation in a speed dictated by management.
Add support for this operating mode.
---v2->v3: nonev1->v2: none
drivers/net/pcs/pcs-xpcs.c | 41 +++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-)
drivers/net/pcs/pcs-xpcs.c +38 -3
@@ -690,7 +690,7 @@ int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable) }EXPORT_SYMBOL_GPL (xpcs_config_eee); -static int xpcs_config_aneg_c37_sgmii (struct dw_xpcs *xpcs) +static int xpcs_config_aneg_c37_sgmii (struct dw_xpcs *xpcs,unsigned int mode) {int ret;
@@ -726,7 +726,10 @@ static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs)if (ret <0 )return ret; - ret |=DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW ; +if (phylink_autoneg_inband (mode)) + ret |=DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW ; +else + ret &= ~DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW ;return xpcs_write (xpcs,MDIO_MMD_VEND2 ,DW_VR_MII_DIG_CTRL1 , ret); }
@@ -772,7 +775,7 @@ static int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, }break ;case DW_AN_C37_SGMII : - ret =xpcs_config_aneg_c37_sgmii (xpcs); + ret =xpcs_config_aneg_c37_sgmii (xpcs, mode);if (ret)return ret;break ;
@@ -905,6 +908,36 @@ static void xpcs_get_state(struct phylink_pcs *pcs, } } +static void xpcs_link_up_sgmii (struct dw_xpcs *xpcs,unsigned int mode, +int speed,int duplex) +{ +int val, ret; + +if (phylink_autoneg_inband (mode)) +return ; + +switch (speed) { +case SPEED_1000 : + val =BMCR_SPEED1000 ; +break ; +case SPEED_100 : + val =BMCR_SPEED100 ; +break ; +case SPEED_10 : + val =BMCR_SPEED10 ; +break ; +default : +return ; + } + +if (duplex ==DUPLEX_FULL ) + val |=BMCR_FULLDPLX ; + + ret =xpcs_write (xpcs,MDIO_MMD_VEND2 ,MDIO_CTRL1 , val); +if (ret) +pr_err ("%s: xpcs_write returned %pe\n" , __func__,ERR_PTR (ret)); +} +static void xpcs_link_up (struct phylink_pcs *pcs,unsigned int mode,phy_interface_t interface,int speed,int duplex) {
@@ -912,6 +945,8 @@ static void xpcs_link_up(struct phylink_pcs *pcs, unsigned int mode,if (interface ==PHY_INTERFACE_MODE_USXGMII )return xpcs_config_usxgmii (xpcs, speed); +if (interface ==PHY_INTERFACE_MODE_SGMII ) +return xpcs_link_up_sgmii (xpcs, mode, speed, duplex); }static u32 xpcs_get_id (struct dw_xpcs *xpcs)
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 6/13 net: pcs: xpcs: also ignore phy id if it's all ones
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
xpcs_get_id() searches multiple MMDs for a known PHY ID, starting with MDIO_MMD_PCS (3). However not all integrators might have implemented that MMD on their MDIO bus. For example, the NXP SJA1105 and SJA1110 switches only implement vendor-specific MMD 1 and 2.
When there is nothing on an MDIO bus at a certain address, traditionally the bus returns 0xffff, which means that the bus remained in its default pull-up state for the duration of the MDIO transaction. The 0xffff value is widely used in drivers/net/phy/phy_device.c (see get_phy_c22_id for example) to denote a missing device.
So it makes sense for the xpcs to ignore this value as well, and continue its search, eventually finding the proper PHY ID in the vendor-specific MMDs.
---v2->v3: nonev1->v2: none
drivers/net/pcs/pcs-xpcs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/pcs/pcs-xpcs.c +4 -2
@@ -965,8 +965,10 @@ static u32 xpcs_get_id(struct dw_xpcs *xpcs)if (ret <0 )return 0xffffffff ; -/* If Device IDs are not all zeros, we found C73 AN-type device */ -if (id | ret) +/* If Device IDs are not all zeros or all ones, +* we found C73 AN-type device +*/ +if ((id | ret) && (id | ret) !=0xffffffff )return id | ret;/* Next, search C37 PCS using Vendor-Specific MII MMD */
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 7/13 net: pcs: xpcs: add support for NXP SJA1105
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
The NXP SJA1105 DSA switch integrates a Synopsys SGMII XPCS on port 4. The generic code works fine, except there is an integration issue which needs to be dealt with: in this switch, the XPCS is integrated with a PMA that has the TX lane polarity inverted by default (PLUS is MINUS, MINUS is PLUS).
To obtain normal non-inverted behavior, the TX lane polarity must be inverted in the PCS, via the DIGITAL_CONTROL_2 register.
We introduce a pma_config() method in xpcs_compat which is called by the phylink_pcs_config() implementation.
Also, the NXP SJA1105 returns all zeroes in the PHY ID registers 2 and 3. We need to hack up an ad-hoc PHY ID (OUI is zero, device ID is 1) in order for the XPCS driver to recognize it. This PHY ID is added to the public include/linux/pcs/pcs-xpcs.h for that reason (for the sja1105 driver to be able to use it in a later patch).
---v2->v3: nonev1->v2: fix module build (pcs-xpcs-nxp.c is not a different module so
this means that we need to change the name of pcs-xpcs.ko to pcs_xpcs.ko).
MAINTAINERS | 1 + drivers/net/pcs/Makefile | 4 +++- drivers/net/pcs/pcs-xpcs-nxp.c | 16 ++++++++++++++++ drivers/net/pcs/pcs-xpcs.c | 25 +++++++++++++++++++++++-- drivers/net/pcs/pcs-xpcs.h | 10 ++++++++++ include/linux/pcs/pcs-xpcs.h | 2 ++ 6 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 drivers/net/pcs/pcs-xpcs-nxp.c
MAINTAINERS +1 -0
@@ -13201,6 +13201,7 @@ M: Vladimir Oltean <[email protected]> L: [email protected] S: Maintained F: drivers/net/dsa/sja1105 +F: drivers/net/pcs/pcs-xpcs-nxp.c NXP TDA998X DRM DRIVER M: Russell King <[email protected]>
drivers/net/pcs/Makefile +3 -1
@@ -1,5 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for Linux PCS drivers -obj-$(CONFIG_PCS_XPCS) += pcs-xpcs.o +pcs_xpcs-$(CONFIG_PCS_XPCS) := pcs-xpcs.o pcs-xpcs-nxp.o + +obj-$(CONFIG_PCS_XPCS) += pcs_xpcs.o obj-$(CONFIG_PCS_LYNX) += pcs-lynx.o
drivers/net/pcs/pcs-xpcs-nxp.c new file +16 -0
@@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright 2021 NXP Semiconductors +*/ +#include <linux/pcs/pcs-xpcs.h> +#include "pcs-xpcs.h" + +/* In NXP SJA1105, the PCS is integrated with a PMA that has the TX lane +* polarity inverted by default (PLUS is MINUS, MINUS is PLUS). To obtain +* normal non-inverted behavior, the TX lane polarity must be inverted in the +* PCS, via the DIGITAL_CONTROL_2 register. +*/ +int nxp_sja1105_sgmii_pma_config (struct dw_xpcs *xpcs) +{ +return xpcs_write (xpcs,MDIO_MMD_VEND2 ,DW_VR_MII_DIG_CTRL2 , +DW_VR_MII_DIG_CTRL2_TX_POL_INV ); +}
drivers/net/pcs/pcs-xpcs.c +23 -2
@@ -117,6 +117,7 @@ struct xpcs_compat {const phy_interface_t *interface;int num_interfaces;int an_mode; +int (*pma_config)(struct dw_xpcs *xpcs); };struct xpcs_id {
@@ -168,7 +169,7 @@ static bool __xpcs_linkmode_supported(const struct xpcs_compat *compat,#define xpcs_linkmode_supported (compat, mode) \ __xpcs_linkmode_supported(compat, ETHTOOL_LINK_MODE_ ## mode ## _BIT) -static int xpcs_read (struct dw_xpcs *xpcs,int dev,u32 reg) +int xpcs_read (struct dw_xpcs *xpcs,int dev,u32 reg) {u32 reg_addr =mdiobus_c45_addr (dev, reg);struct mii_bus *bus = xpcs->mdiodev->bus;
@@ -177,7 +178,7 @@ static int xpcs_read(struct dw_xpcs *xpcs, int dev, u32 reg)return mdiobus_read (bus, addr, reg_addr); } -static int xpcs_write (struct dw_xpcs *xpcs,int dev,u32 reg,u16 val) +int xpcs_write (struct dw_xpcs *xpcs,int dev,u32 reg,u16 val) {u32 reg_addr =mdiobus_c45_addr (dev, reg);struct mii_bus *bus = xpcs->mdiodev->bus;
@@ -788,6 +789,12 @@ static int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface,return -1 ; } +if (compat->pma_config) { + ret = compat->pma_config (xpcs); +if (ret) +return ret; + } +return 0 ; }
@@ -1022,11 +1029,25 @@ static const struct xpcs_compat synopsys_xpcs_compat[DW_XPCS_INTERFACE_MAX] = { }, }; +static const struct xpcs_compat nxp_sja1105_xpcs_compat[DW_XPCS_INTERFACE_MAX ] = { + [DW_XPCS_SGMII ] = { + .supported = xpcs_sgmii_features, + .interface = xpcs_sgmii_interfaces, + .num_interfaces =ARRAY_SIZE (xpcs_sgmii_interfaces), + .an_mode =DW_AN_C37_SGMII , + .pma_config = nxp_sja1105_sgmii_pma_config, + }, +}; +static const struct xpcs_id xpcs_id_list[] = { { .id =SYNOPSYS_XPCS_ID , .mask =SYNOPSYS_XPCS_MASK , .compat = synopsys_xpcs_compat, + }, { + .id =NXP_SJA1105_XPCS_ID , + .mask =SYNOPSYS_XPCS_MASK , + .compat = nxp_sja1105_xpcs_compat, }, };
drivers/net/pcs/pcs-xpcs.h +10 -0
@@ -60,10 +60,15 @@/* EEE Mode Control Register */ #define DW_VR_MII_EEE_MCTRL0 0x8006#define DW_VR_MII_EEE_MCTRL1 0x800b +#define DW_VR_MII_DIG_CTRL2 0x80e1/* VR_MII_DIG_CTRL1 */ #define DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW BIT(9) +/* VR_MII_DIG_CTRL2 */ +#define DW_VR_MII_DIG_CTRL2_TX_POL_INV BIT(4) +#define DW_VR_MII_DIG_CTRL2_RX_POL_INV BIT(0) +/* VR_MII_AN_CTRL */ #define DW_VR_MII_AN_CTRL_TX_CONFIG_SHIFT 3#define DW_VR_MII_TX_CONFIG_MASK BIT(3)
@@ -101,3 +106,8 @@/* VR MII EEE Control 1 defines */ #define DW_VR_MII_EEE_TRN_LPI BIT(0)/* Transparent Mode Enable */ + +int xpcs_read (struct dw_xpcs *xpcs,int dev,u32 reg); +int xpcs_write (struct dw_xpcs *xpcs,int dev,u32 reg,u16 val); + +int nxp_sja1105_sgmii_pma_config (struct dw_xpcs *xpcs);
include/linux/pcs/pcs-xpcs.h +2 -0
@@ -10,6 +10,8 @@#include <linux/phy.h> #include <linux/phylink.h> +#define NXP_SJA1105_XPCS_ID 0x00000010 +/* AN mode */ #define DW_AN_C73 1#define DW_AN_C37_SGMII 2
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 8/13 net: pcs: xpcs: add support for NXP SJA1110
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
The NXP SJA1110 switch integrates its own, non-Synopsys PMA, but it manages it through the register space of the XPCS itself, in a small register window inside MDIO_MMD_VEND2 from address 0x8030 to 0x806e.
This coincides with where the registers for the default Synopsys PMA are, but the register definitions are of course not the same.
This situation is an odd hardware quirk, but the simplest way to manage it is to drive the SJA1110's PMA from within the XPCS driver.
---v2->v3: nonev1->v2: none
drivers/net/pcs/pcs-xpcs-nxp.c | 169 +++++++++++++++++++++++++++++++++ drivers/net/pcs/pcs-xpcs.c | 21 ++++ drivers/net/pcs/pcs-xpcs.h | 2 + include/linux/pcs/pcs-xpcs.h | 1 + 4 files changed, 193 insertions(+)
drivers/net/pcs/pcs-xpcs-nxp.c +169 -0
@@ -4,6 +4,66 @@#include <linux/pcs/pcs-xpcs.h> #include "pcs-xpcs.h" +/* LANE_DRIVER1_0 register */ +#define SJA1110_LANE_DRIVER1_0 0x8038 +#define SJA1110_TXDRV (x) (((x) << 12) & GENMASK(14, 12)) + +/* LANE_DRIVER2_0 register */ +#define SJA1110_LANE_DRIVER2_0 0x803a +#define SJA1110_TXDRVTRIM_LSB (x) ((x) & GENMASK_ULL(15, 0)) + +/* LANE_DRIVER2_1 register */ +#define SJA1110_LANE_DRIVER2_1 0x803b +#define SJA1110_LANE_DRIVER2_1_RSV BIT(9) +#define SJA1110_TXDRVTRIM_MSB (x) (((x) & GENMASK_ULL(23, 16)) >> 16) + +/* LANE_TRIM register */ +#define SJA1110_LANE_TRIM 0x8040 +#define SJA1110_TXTEN BIT(11) +#define SJA1110_TXRTRIM (x) (((x) << 8) & GENMASK(10, 8)) +#define SJA1110_TXPLL_BWSEL BIT(7) +#define SJA1110_RXTEN BIT(6) +#define SJA1110_RXRTRIM (x) (((x) << 3) & GENMASK(5, 3)) +#define SJA1110_CDR_GAIN BIT(2) +#define SJA1110_ACCOUPLE_RXVCM_EN BIT(0) + +/* LANE_DATAPATH_1 register */ +#define SJA1110_LANE_DATAPATH_1 0x8037 + +/* POWERDOWN_ENABLE register */ +#define SJA1110_POWERDOWN_ENABLE 0x8041 +#define SJA1110_TXPLL_PD BIT(12) +#define SJA1110_TXPD BIT(11) +#define SJA1110_RXPKDETEN BIT(10) +#define SJA1110_RXCH_PD BIT(9) +#define SJA1110_RXBIAS_PD BIT(8) +#define SJA1110_RESET_SER_EN BIT(7) +#define SJA1110_RESET_SER BIT(6) +#define SJA1110_RESET_DES BIT(5) +#define SJA1110_RCVEN BIT(4) + +/* RXPLL_CTRL0 register */ +#define SJA1110_RXPLL_CTRL0 0x8065 +#define SJA1110_RXPLL_FBDIV (x) (((x) << 2) & GENMASK(9, 2)) + +/* RXPLL_CTRL1 register */ +#define SJA1110_RXPLL_CTRL1 0x8066 +#define SJA1110_RXPLL_REFDIV (x) ((x) & GENMASK(4, 0)) + +/* TXPLL_CTRL0 register */ +#define SJA1110_TXPLL_CTRL0 0x806d +#define SJA1110_TXPLL_FBDIV (x) ((x) & GENMASK(11, 0)) + +/* TXPLL_CTRL1 register */ +#define SJA1110_TXPLL_CTRL1 0x806e +#define SJA1110_TXPLL_REFDIV (x) ((x) & GENMASK(5, 0)) + +/* RX_DATA_DETECT register */ +#define SJA1110_RX_DATA_DETECT 0x8045 + +/* RX_CDR_CTLE register */ +#define SJA1110_RX_CDR_CTLE 0x8042 +/* In NXP SJA1105, the PCS is integrated with a PMA that has the TX lane * polarity inverted by default (PLUS is MINUS, MINUS is PLUS). To obtain * normal non-inverted behavior, the TX lane polarity must be inverted in the
@@ -14,3 +74,112 @@ int nxp_sja1105_sgmii_pma_config(struct dw_xpcs *xpcs)return xpcs_write (xpcs,MDIO_MMD_VEND2 ,DW_VR_MII_DIG_CTRL2 ,DW_VR_MII_DIG_CTRL2_TX_POL_INV ); } + +static int nxp_sja1110_pma_config (struct dw_xpcs *xpcs, +u16 txpll_fbdiv,u16 txpll_refdiv, +u16 rxpll_fbdiv,u16 rxpll_refdiv, +u16 rx_cdr_ctle) +{ +u16 val; +int ret; + +/* Program TX PLL feedback divider and reference divider settings for +* correct oscillation frequency. +*/ + ret =xpcs_write (xpcs,MDIO_MMD_VEND2 ,SJA1110_TXPLL_CTRL0 , +SJA1110_TXPLL_FBDIV (txpll_fbdiv)); +if (ret <0 ) +return ret; + + ret =xpcs_write (xpcs,MDIO_MMD_VEND2 ,SJA1110_TXPLL_CTRL1 , +SJA1110_TXPLL_REFDIV (txpll_refdiv)); +if (ret <0 ) +return ret; + +/* Program transmitter amplitude and disable amplitude trimming */ + ret =xpcs_write (xpcs,MDIO_MMD_VEND2 ,SJA1110_LANE_DRIVER1_0 , +SJA1110_TXDRV (0x5 )); +if (ret <0 ) +return ret; + + val =SJA1110_TXDRVTRIM_LSB (0xffffffull ); + + ret =xpcs_write (xpcs,MDIO_MMD_VEND2 ,SJA1110_LANE_DRIVER2_0 , val); +if (ret <0 ) +return ret; + + val =SJA1110_TXDRVTRIM_MSB (0xffffffull ) |SJA1110_LANE_DRIVER2_1_RSV ; + + ret =xpcs_write (xpcs,MDIO_MMD_VEND2 ,SJA1110_LANE_DRIVER2_1 , val); +if (ret <0 ) +return ret; + +/* Enable input and output resistor terminations for low BER. */ + val =SJA1110_ACCOUPLE_RXVCM_EN |SJA1110_CDR_GAIN | +SJA1110_RXRTRIM (4 ) |SJA1110_RXTEN |SJA1110_TXPLL_BWSEL | +SJA1110_TXRTRIM (3 ) |SJA1110_TXTEN ; + + ret =xpcs_write (xpcs,MDIO_MMD_VEND2 ,SJA1110_LANE_TRIM , val); +if (ret <0 ) +return ret; + +/* Select PCS as transmitter data source. */ + ret =xpcs_write (xpcs,MDIO_MMD_VEND2 ,SJA1110_LANE_DATAPATH_1 ,0 ); +if (ret <0 ) +return ret; + +/* Program RX PLL feedback divider and reference divider for correct +* oscillation frequency. +*/ + ret =xpcs_write (xpcs,MDIO_MMD_VEND2 ,SJA1110_RXPLL_CTRL0 , +SJA1110_RXPLL_FBDIV (rxpll_fbdiv)); +if (ret <0 ) +return ret; + + ret =xpcs_write (xpcs,MDIO_MMD_VEND2 ,SJA1110_RXPLL_CTRL1 , +SJA1110_RXPLL_REFDIV (rxpll_refdiv)); +if (ret <0 ) +return ret; + +/* Program threshold for receiver signal detector. +* Enable control of RXPLL by receiver signal detector to disable RXPLL +* when an input signal is not present. +*/ + ret =xpcs_write (xpcs,MDIO_MMD_VEND2 ,SJA1110_RX_DATA_DETECT ,0x0005 ); +if (ret <0 ) +return ret; + +/* Enable TX and RX PLLs and circuits. +* Release reset of PMA to enable data flow to/from PCS. +*/ + val =xpcs_read (xpcs,MDIO_MMD_VEND2 ,SJA1110_POWERDOWN_ENABLE ); +if (val <0 ) +return val; + + val &= ~(SJA1110_TXPLL_PD |SJA1110_TXPD |SJA1110_RXCH_PD | +SJA1110_RXBIAS_PD |SJA1110_RESET_SER_EN | +SJA1110_RESET_SER |SJA1110_RESET_DES ); + val |=SJA1110_RXPKDETEN |SJA1110_RCVEN ; + + ret =xpcs_write (xpcs,MDIO_MMD_VEND2 ,SJA1110_POWERDOWN_ENABLE , val); +if (ret <0 ) +return ret; + +/* Program continuous-time linear equalizer (CTLE) settings. */ + ret =xpcs_write (xpcs,MDIO_MMD_VEND2 ,SJA1110_RX_CDR_CTLE , + rx_cdr_ctle); +if (ret <0 ) +return ret; + +return 0 ; +} + +int nxp_sja1110_sgmii_pma_config (struct dw_xpcs *xpcs) +{ +return nxp_sja1110_pma_config (xpcs,0x19 ,0x1 ,0x19 ,0x1 ,0x212a ); +} + +int nxp_sja1110_2500basex_pma_config (struct dw_xpcs *xpcs) +{ +return nxp_sja1110_pma_config (xpcs,0x7d ,0x2 ,0x7d ,0x2 ,0x732a ); +}
drivers/net/pcs/pcs-xpcs.c +21 -0
@@ -1039,6 +1039,23 @@ static const struct xpcs_compat nxp_sja1105_xpcs_compat[DW_XPCS_INTERFACE_MAX] = }, }; +static const struct xpcs_compat nxp_sja1110_xpcs_compat[DW_XPCS_INTERFACE_MAX ] = { + [DW_XPCS_SGMII ] = { + .supported = xpcs_sgmii_features, + .interface = xpcs_sgmii_interfaces, + .num_interfaces =ARRAY_SIZE (xpcs_sgmii_interfaces), + .an_mode =DW_AN_C37_SGMII , + .pma_config = nxp_sja1110_sgmii_pma_config, + }, + [DW_XPCS_2500BASEX ] = { + .supported = xpcs_2500basex_features, + .interface = xpcs_2500basex_interfaces, + .num_interfaces =ARRAY_SIZE (xpcs_2500basex_interfaces), + .an_mode =DW_2500BASEX , + .pma_config = nxp_sja1110_2500basex_pma_config, + }, +}; +static const struct xpcs_id xpcs_id_list[] = { { .id =SYNOPSYS_XPCS_ID ,
@@ -1048,6 +1065,10 @@ static const struct xpcs_id xpcs_id_list[] = { .id = NXP_SJA1105_XPCS_ID, .mask = SYNOPSYS_XPCS_MASK, .compat = nxp_sja1105_xpcs_compat, + }, { + .id = NXP_SJA1110_XPCS_ID, + .mask = SYNOPSYS_XPCS_MASK, + .compat = nxp_sja1110_xpcs_compat, }, };
drivers/net/pcs/pcs-xpcs.h +2 -0
@@ -111,3 +111,5 @@ int xpcs_read(struct dw_xpcs *xpcs, int dev, u32 reg);int xpcs_write (struct dw_xpcs *xpcs,int dev,u32 reg,u16 val);int nxp_sja1105_sgmii_pma_config (struct dw_xpcs *xpcs); +int nxp_sja1110_sgmii_pma_config (struct dw_xpcs *xpcs); +int nxp_sja1110_2500basex_pma_config (struct dw_xpcs *xpcs);
include/linux/pcs/pcs-xpcs.h +1 -0
@@ -11,6 +11,7 @@#include <linux/phylink.h> #define NXP_SJA1105_XPCS_ID 0x00000010 +#define NXP_SJA1110_XPCS_ID 0x00000020/* AN mode */ #define DW_AN_C73 1
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 9/13 net: pcs: xpcs: export xpcs_do_config and xpcs_link_up
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
The sja1105 hardware has a quirk in that some changes require a switch reset, which loses all configuration. When the reset is initiated, everything needs to be reprogrammed, including the MACs and the PCS. This is currently done in sja1105_static_config_reload() - we manually call sja1105_adjust_port_config(), sja1105_sgmii_pcs_config() and sja1105_sgmii_pcs_force_speed() which are all internal functions.
There is a desire for sja1105 to use the common xpcs driver, and that means that the equivalents of those functions, xpcs_do_config() and xpcs_link_up() respectively, will no longer be local functions.
Forcing phylink to retrigger a resolve somehow, say by doing dev_close() followed by dev_open() is not really an option, because the CPU port might have a PCS as well, and there is no net device which we can close and reopen for that. Additionally, the dev_close/dev_open sequence might force a renegotiation of the copper-side link for SGMII ports connected to a PHY, and this is undesirable as well, because the switch reset is much quicker than a PHY autoneg, so we would have a lot more downtime.
The only solution I see is for the sja1105 driver to keep doing what it's doing, and that means we need to export the equivalents from xpcs for sja1105_sgmii_pcs_config and sja1105_sgmii_pcs_force_speed, and call them directly in sja1105_static_config_reload(). This will be done during the conversion patch.
---v2->v3: nonev1->v2: none
drivers/net/pcs/pcs-xpcs.c | 10 ++++++---- include/linux/pcs/pcs-xpcs.h | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-)
drivers/net/pcs/pcs-xpcs.c +6 -4
@@ -757,8 +757,8 @@ static int xpcs_config_2500basex(struct dw_xpcs *xpcs)return xpcs_write (xpcs,MDIO_MMD_VEND2 ,DW_VR_MII_MMD_CTRL , ret); } -static int xpcs_do_config (struct dw_xpcs *xpcs,phy_interface_t interface, -unsigned int mode) +int xpcs_do_config (struct dw_xpcs *xpcs,phy_interface_t interface, +unsigned int mode) {const struct xpcs_compat *compat;int ret;
@@ -797,6 +797,7 @@ static int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface,return 0 ; } +EXPORT_SYMBOL_GPL (xpcs_do_config); static int xpcs_config(struct phylink_pcs *pcs, unsigned int mode, phy_interface_t interface,
@@ -945,8 +946,8 @@ static void xpcs_link_up_sgmii(struct dw_xpcs *xpcs, unsigned int mode,pr_err ("%s: xpcs_write returned %pe\n" , __func__,ERR_PTR (ret)); } -static void xpcs_link_up (struct phylink_pcs *pcs,unsigned int mode, -phy_interface_t interface,int speed,int duplex) +void xpcs_link_up (struct phylink_pcs *pcs,unsigned int mode, +phy_interface_t interface,int speed,int duplex) {struct dw_xpcs *xpcs =phylink_pcs_to_xpcs (pcs);
@@ -955,6 +956,7 @@ static void xpcs_link_up(struct phylink_pcs *pcs, unsigned int mode,if (interface ==PHY_INTERFACE_MODE_SGMII )return xpcs_link_up_sgmii (xpcs, mode, speed, duplex); } +EXPORT_SYMBOL_GPL (xpcs_link_up);static u32 xpcs_get_id (struct dw_xpcs *xpcs) {
include/linux/pcs/pcs-xpcs.h +4 -0
@@ -27,6 +27,10 @@ struct dw_xpcs { };int xpcs_get_an_mode (struct dw_xpcs *xpcs,phy_interface_t interface); +void xpcs_link_up (struct phylink_pcs *pcs,unsigned int mode, +phy_interface_t interface,int speed,int duplex); +int xpcs_do_config (struct dw_xpcs *xpcs,phy_interface_t interface, +unsigned int mode);void xpcs_validate (struct dw_xpcs *xpcs,unsigned long *supported,struct phylink_link_state *state); int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns,
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 10/13 net: dsa: sja1105: migrate to xpcs for SGMII
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
There is a desire to use the generic driver for the Synopsys XPCS located in drivers/net/pcs, and to achieve that, the sja1105 driver must expose an MDIO bus for the SGMII PCS, because the XPCS probes as an mdio_device.
In preparation of the SJA1110 which in fact has a different access procedure for the SJA1105, we register this PCS MDIO bus once in the common code, but we implement function pointers for the read and write methods. In this patch there is a single implementation for them.
There is exactly one MDIO bus for the PCS, this will contain all PCSes at MDIO addresses equal to the port number.
We delete a bunch of hardware support code because the xpcs driver already does what we need.
We need to hack up the MDIO reads for the PHY ID, since our XPCS instantiation returns zeroes and there are some specific fixups which need to be applied by the xpcs driver.
---v2->v3: nonev1->v2:
- delete sja1105_sgmii.h
- just check for priv->pcs[port] instead of checking the PHY interface mode each time.
drivers/net/dsa/sja1105/Kconfig | 1 + drivers/net/dsa/sja1105/sja1105.h | 6 + drivers/net/dsa/sja1105/sja1105_main.c | 171 ++++-------------------- drivers/net/dsa/sja1105/sja1105_mdio.c | 159 ++++++++++++++++++++++ drivers/net/dsa/sja1105/sja1105_sgmii.h | 53 -------- drivers/net/dsa/sja1105/sja1105_spi.c | 4 + 6 files changed, 195 insertions(+), 199 deletions(-) delete mode 100644 drivers/net/dsa/sja1105/sja1105_sgmii.h
drivers/net/dsa/sja1105/Kconfig +1 -0
@@ -3,6 +3,7 @@ config NET_DSA_SJA1105 tristate "NXP SJA1105 Ethernet switch family support" depends on NET_DSA && SPI select NET_DSA_TAG_SJA1105 + select PCS_XPCS select PACKING select CRC32 help
drivers/net/dsa/sja1105/sja1105.h +6 -0
@@ -133,6 +133,8 @@ struct sja1105_info {bool (*rxtstamp)(struct dsa_switch *ds,int port,struct sk_buff *skb);void (*txtstamp)(struct dsa_switch *ds,int port,struct sk_buff *skb);int (*clocking_setup)(struct sja1105_private *priv); +int (*pcs_mdio_read)(struct mii_bus *bus,int phy,int reg); +int (*pcs_mdio_write)(struct mii_bus *bus,int phy,int reg,u16 val);const char *name;bool supports_mii[SJA1105_MAX_NUM_PORTS ];bool supports_rmii[SJA1105_MAX_NUM_PORTS ];
@@ -265,6 +267,8 @@ struct sja1105_private {struct sja1105_cbs_entry *cbs;struct mii_bus *mdio_base_t1;struct mii_bus *mdio_base_tx; +struct mii_bus *mdio_pcs; +struct dw_xpcs *xpcs[SJA1105_MAX_NUM_PORTS ];struct sja1105_tagger_data tagger_data;struct sja1105_ptp_data ptp_data;struct sja1105_tas_data tas_data;
@@ -297,6 +301,8 @@ void sja1105_frame_memory_partitioning(struct sja1105_private *priv);/* From sja1105_mdio.c */ int sja1105_mdiobus_register (struct dsa_switch *ds);void sja1105_mdiobus_unregister (struct dsa_switch *ds); +int sja1105_pcs_mdio_read (struct mii_bus *bus,int phy,int reg); +int sja1105_pcs_mdio_write (struct mii_bus *bus,int phy,int reg,u16 val);/* From sja1105_devlink.c */ int sja1105_devlink_setup (struct dsa_switch *ds);
drivers/net/dsa/sja1105/sja1105_main.c +25 -146
252 lines not on this page · raw message
drivers/net/dsa/sja1105/sja1105_mdio.c +159 -0
190 lines not on this page · raw message
drivers/net/dsa/sja1105/sja1105_sgmii.h deleted +0 -53
53 lines not on this page · raw message
drivers/net/dsa/sja1105/sja1105_spi.c +4 -0
@@ -717,6 +717,8 @@ const struct sja1105_info sja1105r_info = { .ptp_cmd_packing = sja1105pqrs_ptp_cmd_packing, .rxtstamp = sja1105_rxtstamp, .clocking_setup = sja1105_clocking_setup, + .pcs_mdio_read = sja1105_pcs_mdio_read, + .pcs_mdio_write = sja1105_pcs_mdio_write, .regs = &sja1105pqrs_regs, .port_speed = { [SJA1105_SPEED_AUTO] = 0,
@@ -753,6 +755,8 @@ const struct sja1105_info sja1105s_info = { .ptp_cmd_packing = sja1105pqrs_ptp_cmd_packing, .rxtstamp = sja1105_rxtstamp, .clocking_setup = sja1105_clocking_setup, + .pcs_mdio_read = sja1105_pcs_mdio_read, + .pcs_mdio_write = sja1105_pcs_mdio_write, .port_speed = { [SJA1105_SPEED_AUTO] = 0, [SJA1105_SPEED_10MBPS] = 3,
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 11/13 net: dsa: sja1105: register the PCS MDIO bus for SJA1110
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
On the SJA1110, the PCS of each SERDES-capable port is accessed through a different memory window which is 0x100 bytes in size, denoted by "pcs_base".
In each PCS register access window, the XPCS MMDs are accessed in an indirect way: in pages/banks of up to 0x100 addresses each. Changing the page/bank is done by writing to a special register at the end of the access window.
The MDIO register map accessed indirectly through the indirect banked method described above is similar to what SJA1105 has: upper 5 bits are the MMD, lower 16 bits are the MDIO address within that MMD.
Since the PHY ID reported by the XPCS inside SJA1110 is also all zeroes (like SJA1105), we need to trap those reads and return a fake PHY ID so that the xpcs driver can apply some specific fixups for our integration.
---v2->v3: nonev1->v2: none
drivers/net/dsa/sja1105/sja1105.h | 3 + drivers/net/dsa/sja1105/sja1105_mdio.c | 95 ++++++++++++++++++++++++++ drivers/net/dsa/sja1105/sja1105_spi.c | 11 +++ 3 files changed, 109 insertions(+)
drivers/net/dsa/sja1105/sja1105.h +3 -0
@@ -69,6 +69,7 @@ struct sja1105_regs {u64 stats[__MAX_SJA1105_STATS_AREA][SJA1105_MAX_NUM_PORTS ];u64 mdio_100base_tx;u64 mdio_100base_t1; +u64 pcs_base[SJA1105_MAX_NUM_PORTS ]; };struct sja1105_mdio_private {
@@ -303,6 +304,8 @@ int sja1105_mdiobus_register(struct dsa_switch *ds);void sja1105_mdiobus_unregister (struct dsa_switch *ds);int sja1105_pcs_mdio_read (struct mii_bus *bus,int phy,int reg);int sja1105_pcs_mdio_write (struct mii_bus *bus,int phy,int reg,u16 val); +int sja1110_pcs_mdio_read (struct mii_bus *bus,int phy,int reg); +int sja1110_pcs_mdio_write (struct mii_bus *bus,int phy,int reg,u16 val);/* From sja1105_devlink.c */ int sja1105_devlink_setup (struct dsa_switch *ds);
drivers/net/dsa/sja1105/sja1105_mdio.c +95 -0
107 lines not on this page · raw message
drivers/net/dsa/sja1105/sja1105_spi.c +11 -0
@@ -561,6 +561,9 @@ static struct sja1105_regs sja1110_regs = { .ptpsyncts = SJA1110_SPI_ADDR(0x84), .mdio_100base_tx = 0x1c2400, .mdio_100base_t1 = 0x1c1000, + .pcs_base = {SJA1105_RSV_ADDR, 0x1c1400, 0x1c1800, 0x1c1c00, 0x1c2000, +SJA1105_RSV_ADDR ,SJA1105_RSV_ADDR ,SJA1105_RSV_ADDR , + SJA1105_RSV_ADDR, SJA1105_RSV_ADDR, SJA1105_RSV_ADDR}, }; const struct sja1105_info sja1105e_info = {
@@ -794,6 +797,8 @@ const struct sja1105_info sja1110a_info = { .rxtstamp = sja1110_rxtstamp, .txtstamp = sja1110_txtstamp, .clocking_setup = sja1110_clocking_setup, + .pcs_mdio_read = sja1110_pcs_mdio_read, + .pcs_mdio_write = sja1110_pcs_mdio_write, .port_speed = { [SJA1105_SPEED_AUTO] = 0, [SJA1105_SPEED_10MBPS] = 4,
@@ -843,6 +848,8 @@ const struct sja1105_info sja1110b_info = { .rxtstamp = sja1110_rxtstamp, .txtstamp = sja1110_txtstamp, .clocking_setup = sja1110_clocking_setup, + .pcs_mdio_read = sja1110_pcs_mdio_read, + .pcs_mdio_write = sja1110_pcs_mdio_write, .port_speed = { [SJA1105_SPEED_AUTO] = 0, [SJA1105_SPEED_10MBPS] = 4,
@@ -892,6 +899,8 @@ const struct sja1105_info sja1110c_info = { .rxtstamp = sja1110_rxtstamp, .txtstamp = sja1110_txtstamp, .clocking_setup = sja1110_clocking_setup, + .pcs_mdio_read = sja1110_pcs_mdio_read, + .pcs_mdio_write = sja1110_pcs_mdio_write, .port_speed = { [SJA1105_SPEED_AUTO] = 0, [SJA1105_SPEED_10MBPS] = 4,
@@ -941,6 +950,8 @@ const struct sja1105_info sja1110d_info = { .rxtstamp = sja1110_rxtstamp, .txtstamp = sja1110_txtstamp, .clocking_setup = sja1110_clocking_setup, + .pcs_mdio_read = sja1110_pcs_mdio_read, + .pcs_mdio_write = sja1110_pcs_mdio_write, .port_speed = { [SJA1105_SPEED_AUTO] = 0, [SJA1105_SPEED_10MBPS] = 4,
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 12/13 net: dsa: sja1105: SGMII and 2500base-x on the SJA1110 are 'special'
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
For the xMII Mode Parameters Table to be properly configured for SGMII mode on SJA1110, we need to set the "special" bit, since SGMII is officially bitwise coded as 0b0011 in SJA1105 (decimal 3, equal to XMII_MODE_SGMII), and as 0b1011 in SJA1110 (decimal 11).
---v2->v3: nonev1->v2: none
drivers/net/dsa/sja1105/sja1105_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/dsa/sja1105/sja1105_main.c +2 -0
@@ -209,12 +209,14 @@ static int sja1105_init_mii_settings(struct sja1105_private *priv) goto unsupported; mii->xmii_mode[i] =XMII_MODE_SGMII ; + mii->special[i] = true;break ;case PHY_INTERFACE_MODE_2500BASEX :if (!priv->info->supports_2500basex[i]) goto unsupported; mii->xmii_mode[i] =XMII_MODE_SGMII ; + mii->special[i] = true;break ; unsupported:default :
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 13/13 net: dsa: sja1105: plug in support for 2500base-x
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
The MAC treats 2500base-x same as SGMII (yay for that) except that it must be set to a different speed.
Extend all places that check for SGMII to also check for 2500base-x.
Also add the missing 2500base-x compatibility matrix entry for SJA1110D.
---v2->v3: nonev1->v2:
- add the 2500base-x check in one place where it was missing (before mdio_device_create)
- remove it from a few places where it is no longer necessary now that we check more generically for the presence of priv->xpcs[port]
drivers/net/dsa/sja1105/sja1105_main.c | 13 ++++++++++++- drivers/net/dsa/sja1105/sja1105_mdio.c | 3 ++- drivers/net/dsa/sja1105/sja1105_spi.c | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-)
drivers/net/dsa/sja1105/sja1105_main.c +12 -1
@@ -1056,6 +1056,9 @@ static int sja1105_adjust_port_config(struct sja1105_private *priv, int port,case SPEED_1000 : speed = priv->info->port_speed[SJA1105_SPEED_1000MBPS ];break ; +case SPEED_2500 : + speed = priv->info->port_speed[SJA1105_SPEED_2500MBPS ]; +break ;default :dev_err (dev,"Invalid speed %iMbps\n" , speed_mbps);return -EINVAL ;
@@ -1070,6 +1073,8 @@ static int sja1105_adjust_port_config(struct sja1105_private *priv, int port,*/ if (priv->phy_mode[port] ==PHY_INTERFACE_MODE_SGMII ) mac[port].speed = priv->info->port_speed[SJA1105_SPEED_1000MBPS ]; +else if (priv->phy_mode[port] ==PHY_INTERFACE_MODE_2500BASEX ) + mac[port].speed = priv->info->port_speed[SJA1105_SPEED_2500MBPS ];else mac[port].speed = speed;
@@ -1182,6 +1187,10 @@ static void sja1105_phylink_validate(struct dsa_switch *ds, int port,if (mii->xmii_mode[port] ==XMII_MODE_RGMII || mii->xmii_mode[port] ==XMII_MODE_SGMII ) phylink_set(mask, 1000baseT_Full); +if (priv->info->supports_2500basex[port]) { + phylink_set(mask, 2500baseT_Full); + phylink_set(mask, 2500baseX_Full); + }bitmap_and (supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS); bitmap_and(state->advertising, state->advertising, mask,
@@ -1942,7 +1951,9 @@ int sja1105_static_config_reload(struct sja1105_private *priv,if (!phylink_autoneg_inband (mode)) {int speed =SPEED_UNKNOWN ; -if (bmcr[i] &BMCR_SPEED1000 ) +if (priv->phy_mode[i] ==PHY_INTERFACE_MODE_2500BASEX ) + speed =SPEED_2500 ; +else if (bmcr[i] &BMCR_SPEED1000 ) speed =SPEED_1000 ;else if (bmcr[i] &BMCR_SPEED100 ) speed =SPEED_100 ;
drivers/net/dsa/sja1105/sja1105_mdio.c +2 -1
@@ -427,7 +427,8 @@ static int sja1105_mdiobus_pcs_register(struct sja1105_private *priv)if (dsa_is_unused_port (ds, port))continue ; -if (priv->phy_mode[port] !=PHY_INTERFACE_MODE_SGMII ) +if (priv->phy_mode[port] !=PHY_INTERFACE_MODE_SGMII && + priv->phy_mode[port] !=PHY_INTERFACE_MODE_2500BASEX )continue ; mdiodev =mdio_device_create (bus, port);
drivers/net/dsa/sja1105/sja1105_spi.c +2 -0
@@ -967,6 +967,8 @@ const struct sja1105_info sja1110d_info = { false, false, false, false, false, false}, .supports_sgmii = {false, true, true, true, true, false, false, false, false, false, false}, + .supports_2500basex = {false, false, false, true, true, + false, false, false, false, false, false}, .internal_phy = {SJA1105_NO_PHY, SJA1105_NO_PHY,SJA1105_NO_PHY ,SJA1105_NO_PHY , SJA1105_NO_PHY, SJA1105_PHY_BASE_T1,
Signature · 1 line
2.25.1
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 11 lines · On Fri, 11 Jun 2021 23:05:18 +0300 you wrote:
From: Vladimir Oltean <[email protected]>
As requested when adding support for the NXP SJA1110, the SJA1105 driver could make use of the common XPCS driver, to eliminate some hardware specific code duplication.
This series modifies the XPCS driver so that it can accommodate the XPCS instantiation from NXP switches, and the SJA1105 driver so it can expose what the XPCS driver expects.
[...]
Here is the summary with links:
- [v3,net-next,01/13] net: pcs: xpcs: rename mdio_xpcs_args to dw_xpcs
https://git.kernel.org/netdev/net-next/c/5673ef863804 - [v3,net-next,02/13] net: stmmac: reverse Christmas tree notation in stmmac_xpcs_setup https://git.kernel.org/netdev/net-next/c/47538dbeb701 - [v3,net-next,03/13] net: stmmac: reduce indentation when calling stmmac_xpcs_setup https://git.kernel.org/netdev/net-next/c/7413f9a6af00 - [v3,net-next,04/13] net: pcs: xpcs: move register bit descriptions to a header file https://git.kernel.org/netdev/net-next/c/d4433d5b7b34 - [v3,net-next,05/13] net: pcs: xpcs: add support for sgmii with no inband AN https://git.kernel.org/netdev/net-next/c/2031c09e6d5f - [v3,net-next,06/13] net: pcs: xpcs: also ignore phy id if it's all ones https://git.kernel.org/netdev/net-next/c/36641b045c83 - [v3,net-next,07/13] net: pcs: xpcs: add support for NXP SJA1105 https://git.kernel.org/netdev/net-next/c/dd0721ea4c7a - [v3,net-next,08/13] net: pcs: xpcs: add support for NXP SJA1110 https://git.kernel.org/netdev/net-next/c/f7380bba42fd - [v3,net-next,09/13] net: pcs: xpcs: export xpcs_do_config and xpcs_link_up https://git.kernel.org/netdev/net-next/c/a853c68e29bb - [v3,net-next,10/13] net: dsa: sja1105: migrate to xpcs for SGMII https://git.kernel.org/netdev/net-next/c/3ad1d171548e - [v3,net-next,11/13] net: dsa: sja1105: register the PCS MDIO bus for SJA1110 https://git.kernel.org/netdev/net-next/c/27871359bdf8 - [v3,net-next,12/13] net: dsa: sja1105: SGMII and 2500base-x on the SJA1110 are 'special' https://git.kernel.org/netdev/net-next/c/ece578bc3ea4 - [v3,net-next,13/13] net: dsa: sja1105: plug in support for 2500base-x https://git.kernel.org/netdev/net-next/c/56b63466333b
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html