net: dsa: mv88e6xxx: Introduce _mv88e6xxx_phy_page_{read,write}
Subsystems (3)
PATCH v3 1/2 net: dsa: mv88e6xxx: Introduce _mv88e6xxx_phy_page_{read,write}
Add versions of the phy_page_read and _write functions to be used in a context where the SMI mutex is held.
--- drivers/net/dsa/mv88e6xxx.c | 49 +++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 13 deletions(-)
drivers/net/dsa/mv88e6xxx.c +36 -13
@@ -2264,6 +2264,38 @@ static void mv88e6xxx_bridge_work(struct work_struct *work)mutex_unlock (&ps->smi_mutex); } +static int _mv88e6xxx_phy_page_write (struct dsa_switch *ds,int port,int page, +int reg,int val) +{ +int ret; + + ret =_mv88e6xxx_phy_write_indirect (ds, port,0x16 , page); +if (ret <0 ) + goto restore_page_0; + + ret =_mv88e6xxx_phy_write_indirect (ds, port, reg, val); +restore_page_0: +_mv88e6xxx_phy_write_indirect (ds, port,0x16 ,0x0 ); + +return ret; +} + +static int _mv88e6xxx_phy_page_read (struct dsa_switch *ds,int port,int page, +int reg) +{ +int ret; + + ret =_mv88e6xxx_phy_write_indirect (ds, port,0x16 , page); +if (ret <0 ) + goto restore_page_0; + + ret =_mv88e6xxx_phy_read_indirect (ds, port, reg); +restore_page_0: +_mv88e6xxx_phy_write_indirect (ds, port,0x16 ,0x0 ); + +return ret; +} +static int mv88e6xxx_setup_port (struct dsa_switch *ds,int port) {struct mv88e6xxx_priv_state *ps =ds_to_priv (ds);
@@ -2714,13 +2746,9 @@ int mv88e6xxx_phy_page_read(struct dsa_switch *ds, int port, int page, int reg)int ret;mutex_lock (&ps->smi_mutex); - ret =_mv88e6xxx_phy_write_indirect (ds, port,0x16 , page); -if (ret <0 ) - goto error; - ret =_mv88e6xxx_phy_read_indirect (ds, port, reg); -error: -_mv88e6xxx_phy_write_indirect (ds, port,0x16 ,0x0 ); + ret =_mv88e6xxx_phy_page_read (ds, port, page, reg);mutex_unlock (&ps->smi_mutex); +return ret; }
@@ -2731,14 +2759,9 @@ int mv88e6xxx_phy_page_write(struct dsa_switch *ds, int port, int page,int ret;mutex_lock (&ps->smi_mutex); - ret =_mv88e6xxx_phy_write_indirect (ds, port,0x16 , page); -if (ret <0 ) - goto error; - - ret =_mv88e6xxx_phy_write_indirect (ds, port, reg, val); -error: -_mv88e6xxx_phy_write_indirect (ds, port,0x16 ,0x0 ); + ret =_mv88e6xxx_phy_page_write (ds, port, page, reg, val);mutex_unlock (&ps->smi_mutex); +return ret; }
Signature · 1 line
2.7.4
PATCH v3 2/2 net: dsa: mv88e6xxx: Clear the PDOWN bit on setup
Some of the vendor-specific bootloaders set up this part of the initialization for us, so this was never added. However, since upstream bootloaders don't initialize the chip specifically, they leave the fiber MII's PDOWN flag set, which means that the CPU port doesn't connect.
This patch checks whether this flag has been clear prior by something else, and if not make us clear it.
--- drivers/net/dsa/mv88e6xxx.c | 36 ++++++++++++++++++++++++++++++++++++ drivers/net/dsa/mv88e6xxx.h | 8 ++++++++ 2 files changed, 44 insertions(+)
drivers/net/dsa/mv88e6xxx.c +36 -0
@@ -2296,6 +2296,25 @@ restore_page_0:return ret; } +static int mv88e6xxx_power_on_serdes (struct dsa_switch *ds) +{ +int ret; + + ret =_mv88e6xxx_phy_page_read (ds,REG_FIBER_SERDES ,PAGE_FIBER_SERDES , +MII_BMCR ); +if (ret <0 ) +return ret; + +if (ret &BMCR_PDOWN ) { + ret &= ~BMCR_PDOWN ; + ret =_mv88e6xxx_phy_page_write (ds,REG_FIBER_SERDES , +PAGE_FIBER_SERDES ,MII_BMCR , + ret); + } + +return ret; +} +static int mv88e6xxx_setup_port (struct dsa_switch *ds,int port) {struct mv88e6xxx_priv_state *ps =ds_to_priv (ds);
@@ -2399,6 +2418,23 @@ static int mv88e6xxx_setup_port(struct dsa_switch *ds, int port) goto abort; } +/* If this port is connected to a SerDes, make sure the SerDes is not +* powered down. +*/ +if (mv88e6xxx_6352_family (ds)) { + ret =_mv88e6xxx_reg_read (ds,REG_PORT (port),PORT_STATUS ); +if (ret <0 ) + goto abort; + ret &=PORT_STATUS_CMODE_MASK ; +if ((ret ==PORT_STATUS_CMODE_100BASE_X ) || + (ret ==PORT_STATUS_CMODE_1000BASE_X ) || + (ret ==PORT_STATUS_CMODE_SGMII )) { + ret =mv88e6xxx_power_on_serdes (ds); +if (ret <0 ) + goto abort; + } + } +/* Port Control 2: don't force a good FCS, set the maximum frame size to * 10240 bytes, disable 802.1q tags checking, don't discard tagged or * untagged frames on this port, do a destination address lookup on all
drivers/net/dsa/mv88e6xxx.h +8 -0
@@ -28,6 +28,10 @@#define SMI_CMD_OP_45_READ_DATA_INC ((3 << 10) | SMI_CMD_BUSY)#define SMI_DATA 0x01 +/* Fiber/SERDES Registers are located at SMI address F, page 1 */ +#define REG_FIBER_SERDES 0x0f +#define PAGE_FIBER_SERDES 0x01 +#define REG_PORT (p) (0x10 + (p))#define PORT_STATUS 0x00#define PORT_STATUS_PAUSE_EN BIT(15)
@@ -45,6 +49,10 @@#define PORT_STATUS_MGMII BIT(6)/* 6185 */ #define PORT_STATUS_TX_PAUSED BIT(5)#define PORT_STATUS_FLOW_CTRL BIT(4) +#define PORT_STATUS_CMODE_MASK 0x0f +#define PORT_STATUS_CMODE_100BASE_X 0x8 +#define PORT_STATUS_CMODE_1000BASE_X 0x9 +#define PORT_STATUS_CMODE_SGMII 0xa#define PORT_PCS_CTRL 0x01#define PORT_PCS_CTRL_RGMII_DELAY_RXCLK BIT(15)#define PORT_PCS_CTRL_RGMII_DELAY_TXCLK BIT(14)
Signature · 1 line
2.7.4
Re: [PATCH net-next v3 2/2] net: dsa: mv88e6xxx: Clear the PDOWN bit on setup
Quoted 11 lines · Patrick Uiterwijk
Some of the vendor-specific bootloaders set up this part of the initialization for us, so this was never added. However, since upstream bootloaders don't initialize the chip specifically, they leave the fiber MII's PDOWN flag set, which means that the CPU port doesn't connect.
This patch checks whether this flag has been clear prior by something else, and if not make us clear it.
Reviewed-by Andrew Lunn <[email protected]>Signed-off-by Patrick Uiterwijk <[email protected]>
This fixes the SerDes link on my single 6352 x86 platform.
Thanks!
Vivien
Hi,
Could this patch and the patch 2/2 v3 "net: dsa: mv88e6xxx: Clear the PDOWN bit on setup" be put
on net, since this fixes a bug with the clearfog, which was introduced in v4.5?
Thanks,
Patrick
Quoted 7 lines · Patrick Uiterwijk
Add versions of the
phy_page_readand_writefunctions to be used in a context where the SMI mutex is held.Tested-by Vivien Didelot <[email protected]>Reviewed-by Vivien Didelot <[email protected]>Signed-off-by Patrick Uiterwijk <[email protected]>---
From: Patrick Uiterwijk <[email protected]>
Date: Wed, 30 Mar 2016 01:39:40 +0000
Quoted 6 lines
Add versions of the
phy_page_readand_writefunctions to be used in a context where the SMI mutex is held.Tested-by Vivien Didelot <[email protected]>Reviewed-by Vivien Didelot <[email protected]>Signed-off-by Patrick Uiterwijk <[email protected]>
Applied.
Re: [PATCH net-next v3 2/2] net: dsa: mv88e6xxx: Clear the PDOWN bit on setup
In reply to Patrick UiterwijkFrom: Patrick Uiterwijk <[email protected]>
Date: Wed, 30 Mar 2016 01:39:41 +0000
Quoted 11 lines
Some of the vendor-specific bootloaders set up this part of the initialization for us, so this was never added. However, since upstream bootloaders don't initialize the chip specifically, they leave the fiber MII's PDOWN flag set, which means that the CPU port doesn't connect.
This patch checks whether this flag has been clear prior by something else, and if not make us clear it.
Reviewed-by Andrew Lunn <[email protected]>Signed-off-by Patrick Uiterwijk <[email protected]>
Applied, thank you.