net: mv643xx_eth: support MII/GMII/RGMII modes
Subsystems (3)
PATCH 1/1 net: mv643xx_eth: support MII/GMII/RGMII modes
On device reset all ports are automatically set to RGMII mode. MII mode must be explicitly enabled.
If SoC has two Ethernet controllers, by setting both of them into MII mode, the first controller enters GMII mode, while the second controller is effectively disabled. This requires configuring (and maybe enabling) the second controller in the device tree, even though it cannot be used.
--- drivers/net/ethernet/marvell/mv643xx_eth.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/net/ethernet/marvell/mv643xx_eth.c +16 -0
@@ -108,6 +108,7 @@ static char mv643xx_eth_driver_version[] = "1.4";#define TXQ_COMMAND 0x0048#define TXQ_FIX_PRIO_CONF 0x004c#define PORT_SERIAL_CONTROL1 0x004c +#define RGMII_EN 0x00000008#define CLK125_BYPASS_EN 0x00000010#define TX_BW_RATE 0x0050#define TX_BW_MTU 0x0058
@@ -1245,6 +1246,21 @@ static void mv643xx_eth_adjust_link(struct net_device *dev) out_write:wrlp (mp,PORT_SERIAL_CONTROL , pscr); + +/* If two Ethernet controllers present in the SoC, MII modes follow the +* following matrix: +* +* Port0 Mode Port1 Mode Port0 RGMII_EN Port1 RGMII_EN +* RGMII RGMII 1 1 +* RGMII MII/MMII 1 0 +* MII/MMII RGMII 0 1 +* GMII N/A 0 0 +* +* To enable GMII on Port 0, Port 1 must also disable RGMII_EN too. +*/ +if (!phy_interface_is_rgmii (dev->phydev)) +wrlp (mp,PORT_SERIAL_CONTROL1 , +rdlp (mp,PORT_SERIAL_CONTROL1 ) & ~RGMII_EN ); }/* statistics ***************************************************************/
Signature · 1 line
2.35.1
Quoted 35 lines · David Yang
On device reset all ports are automatically set to RGMII mode. MII mode must be explicitly enabled.
If SoC has two Ethernet controllers, by setting both of them into MII mode, the first controller enters GMII mode, while the second controller is effectively disabled. This requires configuring (and maybe enabling) the second controller in the device tree, even though it cannot be used.
Signed-off-by David Yang <[email protected]>--- drivers/net/ethernet/marvell/mv643xx_eth.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/net/ethernet/marvell/mv643xx_eth.c +6
-0@@ -108,6 +108,7 @@ static char mv643xx_eth_driver_version[] = "1.4";#define TXQ_COMMAND 0x0048#define TXQ_FIX_PRIO_CONF 0x004c#define PORT_SERIAL_CONTROL1 0x004c +#define RGMII_EN 0x00000008#define CLK125_BYPASS_EN 0x00000010#define TX_BW_RATE 0x0050#define TX_BW_MTU 0x0058@@ -1245,6 +1246,21 @@ static void mv643xx_eth_adjust_link(struct net_device *dev) out_write:wrlp (mp,PORT_SERIAL_CONTROL , pscr); + +/* If two Ethernet controllers present in the SoC, MII modes follow the +* following matrix: +* +* Port0 Mode Port1 Mode Port0 RGMII_EN Port1 RGMII_EN
drivers/net/ethernet/marvell/mv643xx_eth.c static void mv643xx_eth_adjust_link(struct net_device *dev) · line 1263
Quoted 10 lines
drivers/net/ethernet/marvell/mv643xx_eth.c +10
-0+* RGMII RGMII 1 1 +* RGMII MII/MMII 1 0 +* MII/MMII RGMII 0 1 +* GMII N/A 0 0 +* +* To enable GMII on Port 0, Port 1 must also disable RGMII_EN too. +*/ +if (!phy_interface_is_rgmii (dev->phydev)) +wrlp (mp,PORT_SERIAL_CONTROL1 , +rdlp (mp,PORT_SERIAL_CONTROL1 ) & ~RGMII_EN );
I could be reading this wrong, but doesn't this break the third line:
drivers/net/ethernet/marvell/mv643xx_eth.c static void mv643xx_eth_adjust_link(struct net_device *dev) · line 1256
Quoted 1 line
drivers/net/ethernet/marvell/mv643xx_eth.c +1
-0+* MII/MMII RGMII 0 1
Port 1 probes first, phy_interface is rgmii, so nothing happens, port1 RGMII_EN is left true.
Port 0 then probes, MII/MMII is not RGMII, so port1 RGMII_EN is cleared, breaking port1.
I think you need to be more specific with the comparison.
Andrew
PATCH v2 1/1 net: mv643xx_eth: support MII/GMII/RGMII modes
Support mode switch properly, which is not available before.
If SoC has two Ethernet controllers, by setting both of them into MII mode, the first controller enters GMII mode, while the second controller is effectively disabled. This requires configuring (and maybe enabling) the second controller in the device tree, even though it cannot be used.
---
v2: clarify modes work on controllers, read default value from PSC1
drivers/net/ethernet/marvell/mv643xx_eth.c | 36 ++++++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-)
drivers/net/ethernet/marvell/mv643xx_eth.c +33 -3
@@ -108,6 +108,7 @@ static char mv643xx_eth_driver_version[] = "1.4";#define TXQ_COMMAND 0x0048#define TXQ_FIX_PRIO_CONF 0x004c#define PORT_SERIAL_CONTROL1 0x004c +#define RGMII_EN 0x00000008#define CLK125_BYPASS_EN 0x00000010#define TX_BW_RATE 0x0050#define TX_BW_MTU 0x0058
@@ -1215,6 +1216,7 @@ static void mv643xx_eth_adjust_link(struct net_device *dev)DISABLE_AUTO_NEG_SPEED_GMII |DISABLE_AUTO_NEG_FOR_FLOW_CTRL |DISABLE_AUTO_NEG_FOR_DUPLEX ; +u32 psc1r =rdlp (mp,PORT_SERIAL_CONTROL1 );if (dev->phydev->autoneg ==AUTONEG_ENABLE ) {/* enable auto negotiation */
@@ -1245,6 +1247,30 @@ static void mv643xx_eth_adjust_link(struct net_device *dev) out_write:wrlp (mp,PORT_SERIAL_CONTROL , pscr); + +/* If two Ethernet controllers present in the SoC, and both of them have +* RGMII_EN disabled, the first controller will be in GMII mode and the +* second one is effectively disabled, instead of two MII interfaces. +* +* To enable GMII in the first controller, the second one must also be +* configured (and may be enabled) with RGMII_EN disabled too, even +* though it cannot be used at all. +*/ +switch (dev->phydev->interface) { +case PHY_INTERFACE_MODE_MII : +case PHY_INTERFACE_MODE_GMII : +wrlp (mp,PORT_SERIAL_CONTROL1 , psc1r & ~RGMII_EN ); +break ; +case PHY_INTERFACE_MODE_RGMII : +case PHY_INTERFACE_MODE_RGMII_ID : +case PHY_INTERFACE_MODE_RGMII_RXID : +case PHY_INTERFACE_MODE_RGMII_TXID : +wrlp (mp,PORT_SERIAL_CONTROL1 , psc1r |RGMII_EN ); +break ; +default : +/* Unknown; don't touch */ +break ; + } }/* statistics ***************************************************************/
@@ -2975,11 +3001,15 @@ static int get_phy_mode(struct mv643xx_eth_private *mp)if (dev->of_node) err =of_get_phy_mode (dev->of_node, &iface); -/* Historical default if unspecified. We could also read/write -* the interface state in the PSC1 +/* Read the interface state in the PSC1. +* +* Modes of two devices may interact; see comments in +* mv643xx_eth_adjust_link. Currently there is no way to detect another +* device within this scope; blindly set MII here. */ if (!dev->of_node || err) - iface =PHY_INTERFACE_MODE_GMII ; + iface =rdlp (mp,PORT_SERIAL_CONTROL1 ) &RGMII_EN ? +PHY_INTERFACE_MODE_RGMII :PHY_INTERFACE_MODE_MII ;return iface; }
Signature · 1 line
2.35.1
Paolo Abeni
maintainerHello,
Quoted 9 lines · David Yang
Support mode switch properly, which is not available before.
If SoC has two Ethernet controllers, by setting both of them into MII mode, the first controller enters GMII mode, while the second controller is effectively disabled. This requires configuring (and maybe enabling) the second controller in the device tree, even though it cannot be used.
Signed-off-by David Yang <[email protected]>
It looks like that despite the subj change, this is superseded by:
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/
I'm updating the PW accordingly. Please let me know if you intended otherwise.
Thanks,
Paolo
Quoted 55 lines · Andrew Lunn <[email protected]> 于2022年10月1日周六 04:28写道:
Quoted 35 lines · David Yang
On device reset all ports are automatically set to RGMII mode. MII mode must be explicitly enabled.
If SoC has two Ethernet controllers, by setting both of them into MII mode, the first controller enters GMII mode, while the second controller is effectively disabled. This requires configuring (and maybe enabling) the second controller in the device tree, even though it cannot be used.
Signed-off-by David Yang <[email protected]>--- drivers/net/ethernet/marvell/mv643xx_eth.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/net/ethernet/marvell/mv643xx_eth.c +6
-0@@ -108,6 +108,7 @@ static char mv643xx_eth_driver_version[] = "1.4";#define TXQ_COMMAND 0x0048#define TXQ_FIX_PRIO_CONF 0x004c#define PORT_SERIAL_CONTROL1 0x004c +#define RGMII_EN 0x00000008#define CLK125_BYPASS_EN 0x00000010#define TX_BW_RATE 0x0050#define TX_BW_MTU 0x0058@@ -1245,6 +1246,21 @@ static void mv643xx_eth_adjust_link(struct net_device *dev) out_write:wrlp (mp,PORT_SERIAL_CONTROL , pscr); + +/* If two Ethernet controllers present in the SoC, MII modes follow the +* following matrix: +* +* Port0 Mode Port1 Mode Port0 RGMII_EN Port1 RGMII_EN drivers/net/ethernet/marvell/mv643xx_eth.c static void mv643xx_eth_adjust_link(struct net_device *dev) · line 1263
Quoted 10 lines
drivers/net/ethernet/marvell/mv643xx_eth.c +10
-0+* RGMII RGMII 1 1 +* RGMII MII/MMII 1 0 +* MII/MMII RGMII 0 1 +* GMII N/A 0 0 +* +* To enable GMII on Port 0, Port 1 must also disable RGMII_EN too. +*/ +if (!phy_interface_is_rgmii (dev->phydev)) +wrlp (mp,PORT_SERIAL_CONTROL1 , +rdlp (mp,PORT_SERIAL_CONTROL1 ) & ~RGMII_EN );I could be reading this wrong, but doesn't this break the third line:
drivers/net/ethernet/marvell/mv643xx_eth.c static void mv643xx_eth_adjust_link(struct net_device *dev) · line 1256
Quoted 1 line
drivers/net/ethernet/marvell/mv643xx_eth.c +1
-0+* MII/MMII RGMII 0 1 Port 1 probes first,
phy_interfaceis rgmii, so nothing happens, port1RGMII_ENis left true.
Quoted 6 lines
Port 0 then probes, MII/MMII is not RGMII, so port1
RGMII_ENis cleared, breaking port1.I think you need to be more specific with the comparison.
Andrew
Oh, I see. So you mean "phy-mode" property should belong to controller, not port? I thought one controller can have at most one port.
Quoted 59 lines · Yangfl
Quoted 58 lines · Andrew Lunn <[email protected]> 于2022年10月1日周六 04:28写道:
Quoted 35 lines · David Yang
On device reset all ports are automatically set to RGMII mode. MII mode must be explicitly enabled.
If SoC has two Ethernet controllers, by setting both of them into MII mode, the first controller enters GMII mode, while the second controller is effectively disabled. This requires configuring (and maybe enabling) the second controller in the device tree, even though it cannot be used.
Signed-off-by David Yang <[email protected]>--- drivers/net/ethernet/marvell/mv643xx_eth.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/net/ethernet/marvell/mv643xx_eth.c +6
-0@@ -108,6 +108,7 @@ static char mv643xx_eth_driver_version[] = "1.4";#define TXQ_COMMAND 0x0048#define TXQ_FIX_PRIO_CONF 0x004c#define PORT_SERIAL_CONTROL1 0x004c +#define RGMII_EN 0x00000008#define CLK125_BYPASS_EN 0x00000010#define TX_BW_RATE 0x0050#define TX_BW_MTU 0x0058@@ -1245,6 +1246,21 @@ static void mv643xx_eth_adjust_link(struct net_device *dev) out_write:wrlp (mp,PORT_SERIAL_CONTROL , pscr); + +/* If two Ethernet controllers present in the SoC, MII modes follow the +* following matrix: +* +* Port0 Mode Port1 Mode Port0 RGMII_EN Port1 RGMII_EN drivers/net/ethernet/marvell/mv643xx_eth.c static void mv643xx_eth_adjust_link(struct net_device *dev) · line 1263
Quoted 10 lines
drivers/net/ethernet/marvell/mv643xx_eth.c +10
-0+* RGMII RGMII 1 1 +* RGMII MII/MMII 1 0 +* MII/MMII RGMII 0 1 +* GMII N/A 0 0 +* +* To enable GMII on Port 0, Port 1 must also disable RGMII_EN too. +*/ +if (!phy_interface_is_rgmii (dev->phydev)) +wrlp (mp,PORT_SERIAL_CONTROL1 , +rdlp (mp,PORT_SERIAL_CONTROL1 ) & ~RGMII_EN );I could be reading this wrong, but doesn't this break the third line:
drivers/net/ethernet/marvell/mv643xx_eth.c static void mv643xx_eth_adjust_link(struct net_device *dev) · line 1256
Quoted 1 line
drivers/net/ethernet/marvell/mv643xx_eth.c +1
-0+* MII/MMII RGMII 0 1 Port 1 probes first,
phy_interfaceis rgmii, so nothing happens, port1RGMII_ENis left true.Port 0 then probes, MII/MMII is not RGMII, so port1
RGMII_ENis cleared, breaking port1.
Quoted 7 lines
Quoted 3 lines
I think you need to be more specific with the comparison.
Andrew
Oh, I see. So you mean "phy-mode" property should belong to controller, not port? I thought one controller can have at most one port.
If you look at mv643xx_eth_shared_of_probe(), it appears a controller can have multiple ports. And:
if (dev_num == 3) {
dev_err(&pdev->dev, "too many ports registered\n");
return -EINVAL;
}I don't know the details?
Andrew
PATCH v3 1/1 net: mv643xx_eth: support MII/GMII/RGMII modes for Kirkwood
Support mode switch properly, which is not available before.
If SoC has two Ethernet controllers, by setting both of them into MII mode, the first controller enters GMII mode, while the second controller is effectively disabled. This requires configuring (and maybe enabling) the second controller in the device tree, even though it cannot be used.
---
v2: clarify modes work on controllers, read default value from PSC1
v3: Kirkwood only
drivers/net/ethernet/marvell/mv643xx_eth.c | 48 ++++++++++++++++++++-- 1 file changed, 44 insertions(+), 4 deletions(-)
drivers/net/ethernet/marvell/mv643xx_eth.c +44 -4
@@ -108,6 +108,7 @@ static char mv643xx_eth_driver_version[] = "1.4";#define TXQ_COMMAND 0x0048#define TXQ_FIX_PRIO_CONF 0x004c#define PORT_SERIAL_CONTROL1 0x004c +#define RGMII_EN 0x00000008#define CLK125_BYPASS_EN 0x00000010#define TX_BW_RATE 0x0050#define TX_BW_MTU 0x0058
@@ -367,6 +368,7 @@ struct mv643xx_eth_private {struct mv643xx_eth_shared_private *shared;void __iomem *base;int port_num; +bool kirkwood;struct net_device *dev;
@@ -1215,6 +1217,7 @@ static void mv643xx_eth_adjust_link(struct net_device *dev)DISABLE_AUTO_NEG_SPEED_GMII |DISABLE_AUTO_NEG_FOR_FLOW_CTRL |DISABLE_AUTO_NEG_FOR_DUPLEX ; +u32 psc1r;if (dev->phydev->autoneg ==AUTONEG_ENABLE ) {/* enable auto negotiation */
@@ -1245,6 +1248,36 @@ static void mv643xx_eth_adjust_link(struct net_device *dev) out_write:wrlp (mp,PORT_SERIAL_CONTROL , pscr); + +if (mp->kirkwood) { + psc1r =rdlp (mp,PORT_SERIAL_CONTROL1 ); +/* On Kirkwood with two Ethernet controllers, if both of them +* have RGMII_EN disabled, the first controller will be in GMII +* mode and the second one is effectively disabled, instead of +* two MII interfaces. +* +* To enable GMII in the first controller, the second one must +* also be configured (and may be enabled) with RGMII_EN +* disabled too, even though it cannot be used at all. +*/ +switch (dev->phydev->interface) { +case PHY_INTERFACE_MODE_MII : +case PHY_INTERFACE_MODE_GMII : + psc1r &= ~RGMII_EN ; +break ; +case PHY_INTERFACE_MODE_RGMII : +case PHY_INTERFACE_MODE_RGMII_ID : +case PHY_INTERFACE_MODE_RGMII_RXID : +case PHY_INTERFACE_MODE_RGMII_TXID : + psc1r |=RGMII_EN ; +break ; +default : +/* Unknown; don't touch */ +break ; + } + +wrlp (mp,PORT_SERIAL_CONTROL1 , psc1r); + } }/* statistics ***************************************************************/
@@ -2975,11 +3008,16 @@ static int get_phy_mode(struct mv643xx_eth_private *mp)if (dev->of_node) err =of_get_phy_mode (dev->of_node, &iface); -/* Historical default if unspecified. We could also read/write -* the interface state in the PSC1 +/* Read the interface state in the PSC1. +* +* Modes of two devices may interact on Kirkwood. Currently there is no +* way to detect another device within this scope; blindly set MII +* here. */ if (!dev->of_node || err) - iface =PHY_INTERFACE_MODE_GMII ; + iface =rdlp (mp,PORT_SERIAL_CONTROL1 ) &RGMII_EN ? +PHY_INTERFACE_MODE_RGMII : mp->kirkwood ? +PHY_INTERFACE_MODE_MII :PHY_INTERFACE_MODE_GMII ;return iface; }
@@ -3124,9 +3162,11 @@ static int mv643xx_eth_probe(struct platform_device *pdev)* all other SoCs/System Controllers using this driver. */ if (of_device_is_compatible (pdev->dev.of_node, -"marvell,kirkwood-eth-port" )) +"marvell,kirkwood-eth-port" )) {wrlp (mp,PORT_SERIAL_CONTROL1 ,rdlp (mp,PORT_SERIAL_CONTROL1 ) & ~CLK125_BYPASS_EN ); + mp->kirkwood =1 ; + }/* * Start with a default rate, and if there is a clock, allow
Signature · 1 line
2.35.1
PATCH v4 1/1 net: mv643xx_eth: support MII/GMII/RGMII modes for Kirkwood
Support mode switch properly, which is not available before.
If SoC has two Ethernet controllers, by setting both of them into MII mode, the first controller enters GMII mode, while the second controller is effectively disabled. This requires configuring (and maybe enabling) the second controller in the device tree, even though it cannot be used.
---
v2: clarify modes work on controllers, read default value from PSC1
v3: Kirkwood only
v4: cleanup
drivers/net/ethernet/marvell/mv643xx_eth.c | 57 +++++++++++++++++++--- 1 file changed, 51 insertions(+), 6 deletions(-)
drivers/net/ethernet/marvell/mv643xx_eth.c +51 -6
@@ -108,6 +108,7 @@ static char mv643xx_eth_driver_version[] = "1.4";#define TXQ_COMMAND 0x0048#define TXQ_FIX_PRIO_CONF 0x004c#define PORT_SERIAL_CONTROL1 0x004c +#define RGMII_EN 0x00000008#define CLK125_BYPASS_EN 0x00000010#define TX_BW_RATE 0x0050#define TX_BW_MTU 0x0058
@@ -1215,6 +1216,7 @@ static void mv643xx_eth_adjust_link(struct net_device *dev)DISABLE_AUTO_NEG_SPEED_GMII |DISABLE_AUTO_NEG_FOR_FLOW_CTRL |DISABLE_AUTO_NEG_FOR_DUPLEX ; +u32 psc1r;if (dev->phydev->autoneg ==AUTONEG_ENABLE ) {/* enable auto negotiation */
@@ -1245,6 +1247,38 @@ static void mv643xx_eth_adjust_link(struct net_device *dev) out_write:wrlp (mp,PORT_SERIAL_CONTROL , pscr); + +if (dev->dev->of_node && +of_device_is_compatible (dev->dev->of_node, +"marvell,kirkwood-eth-port" )) { + psc1r =rdlp (mp,PORT_SERIAL_CONTROL1 ); +/* On Kirkwood with two Ethernet controllers, if both of them +* have RGMII_EN disabled, the first controller will be in GMII +* mode and the second one is effectively disabled, instead of +* two MII interfaces. +* +* To enable GMII in the first controller, the second one must +* also be configured (and may be enabled) with RGMII_EN +* disabled too, even though it cannot be used at all. +*/ +switch (dev->phydev->interface) { +case PHY_INTERFACE_MODE_MII : +case PHY_INTERFACE_MODE_GMII : + psc1r &= ~RGMII_EN ; +break ; +case PHY_INTERFACE_MODE_RGMII : +case PHY_INTERFACE_MODE_RGMII_ID : +case PHY_INTERFACE_MODE_RGMII_RXID : +case PHY_INTERFACE_MODE_RGMII_TXID : + psc1r |=RGMII_EN ; +break ; +default : +/* Unknown; don't touch */ +break ; + } + +wrlp (mp,PORT_SERIAL_CONTROL1 , psc1r); + } }/* statistics ***************************************************************/
@@ -2972,15 +3006,26 @@ static int get_phy_mode(struct mv643xx_eth_private *mp)phy_interface_t iface;int err; -if (dev->of_node) +if (dev->of_node) { err =of_get_phy_mode (dev->of_node, &iface); +if (!err) +return iface; + } + +/* Read the interface state in the PSC1 */ +if (rdlp (mp,PORT_SERIAL_CONTROL1 ) &RGMII_EN ) +return PHY_INTERFACE_MODE_RGMII ; -/* Historical default if unspecified. We could also read/write -* the interface state in the PSC1 +/* Modes of two devices may interact on Kirkwood. Currently there is no +* way to detect another device within this scope; blindly set MII +* here. */ -if (!dev->of_node || err) - iface =PHY_INTERFACE_MODE_GMII ; -return iface; +if (dev->of_node && +of_device_is_compatible (dev->of_node,"marvell,kirkwood-eth" )) +return PHY_INTERFACE_MODE_MII ; + +/* Historical default if unspecified */ +return PHY_INTERFACE_MODE_GMII ; } static struct phy_device *phy_scan(struct mv643xx_eth_private *mp,
Signature · 1 line
2.35.1
Jakub Kicinski
maintainerRe: [PATCH v4] net: mv643xx_eth: support MII/GMII/RGMII modes for Kirkwood
Quoted 7 lines · On Sat, 1 Oct 2022 06:25:39 +0800 David Yang wrote:
Support mode switch properly, which is not available before.
If SoC has two Ethernet controllers, by setting both of them into MII mode, the first controller enters GMII mode, while the second controller is effectively disabled. This requires configuring (and maybe enabling) the second controller in the device tree, even though it cannot be used.
Well, this version does not build:
drivers/net/ethernet/marvell/mv643xx_eth.c:1252:38: error: member reference type 'struct device' is not a pointer; did you mean to use '.'?
of_device_is_compatible(dev->dev->of_node,
~~~~~~~~^~
.PATCH v5 1/1 net: mv643xx_eth: support MII/GMII/RGMII modes for Kirkwood
Support mode switch properly, which is not available before.
If SoC has two Ethernet controllers, by setting both of them into MII mode, the first controller enters GMII mode, while the second controller is effectively disabled. This requires configuring (and maybe enabling) the second controller in the device tree, even though it cannot be used.
---
v2: clarify modes work on controllers, read default value from PSC1
v3: Kirkwood only
v4: cleanup
v5: test on 88f6282
drivers/net/ethernet/marvell/mv643xx_eth.c | 49 ++++++++++++++++++---- include/linux/mv643xx_eth.h | 1 + 2 files changed, 43 insertions(+), 7 deletions(-)
drivers/net/ethernet/marvell/mv643xx_eth.c +42 -7
@@ -108,6 +108,7 @@ static char mv643xx_eth_driver_version[] = "1.4";#define TXQ_COMMAND 0x0048#define TXQ_FIX_PRIO_CONF 0x004c#define PORT_SERIAL_CONTROL1 0x004c +#define RGMII_EN 0x00000008#define CLK125_BYPASS_EN 0x00000010#define TX_BW_RATE 0x0050#define TX_BW_MTU 0x0058
@@ -2761,6 +2762,8 @@ static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev,mv643xx_eth_property (pnp,"rx-sram-addr" , ppd.rx_sram_addr);mv643xx_eth_property (pnp,"rx-sram-size" , ppd.rx_sram_size); +of_get_phy_mode (pnp, &ppd.interface); + ppd.phy_node =of_parse_phandle (pnp,"phy-handle" ,0 );if (!ppd.phy_node) { ppd.phy_addr =MV643XX_ETH_PHY_NONE ;
@@ -3092,6 +3095,7 @@ static int mv643xx_eth_probe(struct platform_device *pdev)struct mv643xx_eth_private *mp;struct net_device *dev;struct phy_device *phydev =NULL ; +u32 psc1r;int err, irq; pd =dev_get_platdata (&pdev->dev);
@@ -3119,14 +3123,45 @@ static int mv643xx_eth_probe(struct platform_device *pdev) mp->dev = dev; -/* Kirkwood resets some registers on gated clocks. Especially -* CLK125_BYPASS_EN must be cleared but is not available on -* all other SoCs/System Controllers using this driver. -*/ if (of_device_is_compatible (pdev->dev.of_node, -"marvell,kirkwood-eth-port" )) -wrlp (mp,PORT_SERIAL_CONTROL1 , -rdlp (mp,PORT_SERIAL_CONTROL1 ) & ~CLK125_BYPASS_EN ); +"marvell,kirkwood-eth-port" )) { + psc1r =rdlp (mp,PORT_SERIAL_CONTROL1 ); + +/* Kirkwood resets some registers on gated clocks. Especially +* CLK125_BYPASS_EN must be cleared but is not available on +* all other SoCs/System Controllers using this driver. +*/ + psc1r &= ~CLK125_BYPASS_EN ; + +/* On Kirkwood with two Ethernet controllers, if both of them +* have RGMII_EN disabled, the first controller will be in GMII +* mode and the second one is effectively disabled, instead of +* two MII interfaces. +* +* To enable GMII in the first controller, the second one must +* also be configured (and may be enabled) with RGMII_EN +* disabled too, even though it cannot be used at all. +*/ +switch (pd->interface) { +/* Use internal to denote second controller being disabled */ +case PHY_INTERFACE_MODE_INTERNAL : +case PHY_INTERFACE_MODE_MII : +case PHY_INTERFACE_MODE_GMII : + psc1r &= ~RGMII_EN ; +break ; +case PHY_INTERFACE_MODE_RGMII : +case PHY_INTERFACE_MODE_RGMII_ID : +case PHY_INTERFACE_MODE_RGMII_RXID : +case PHY_INTERFACE_MODE_RGMII_TXID : + psc1r |=RGMII_EN ; +break ; +default : +/* Unknown; don't touch */ +break ; + } + +wrlp (mp,PORT_SERIAL_CONTROL1 , psc1r); + }/* * Start with a default rate, and if there is a clock, allow
include/linux/mv643xx_eth.h +1 -0
@@ -59,6 +59,7 @@ struct mv643xx_eth_platform_data {*/ int speed;int duplex; +phy_interface_t interface;/* * How many RX/TX queues to use.
Signature · 1 line
2.35.1