Add support for running the Marvell m88e1111 PHY in RGMII mode
Subsystems (3)
PATCH 1/1 Add support for running the Marvell m88e1111 PHY in RGMII mode
also adds RX & TX delay bits to help boards with clock skew problems.
---
please consider for 2.6.22
drivers/net/phy/marvell.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 43 insertions(+), 0 deletions(-)
drivers/net/phy/marvell.c +43 -0
@@ -54,6 +54,12 @@#define MII_M1111_PHY_LED_CONTROL 0x18#define MII_M1111_PHY_LED_DIRECT 0x4100#define MII_M1111_PHY_LED_COMBINE 0x411c +#define MII_M1111_PHY_EXT_CR 0x14 +#define MII_M1111_RX_DELAY 0x80 +#define MII_M1111_TX_DELAY 0x2 +#define MII_M1111_PHY_EXT_SR 0x1b +#define MII_M1111_HWCFG_MODE_MASK 0xf +#define MII_M1111_HWCFG_MODE_RGMII 0xbMODULE_DESCRIPTION ("Marvell PHY driver" );MODULE_AUTHOR ("Andy Fleming" );
@@ -131,6 +137,42 @@ static int marvell_config_aneg(struct phy_device *phydev)return err; } +static int m88e1111_config_init (struct phy_device *phydev) +{ +int err; + +if (phydev->interface ==PHY_INTERFACE_MODE_RGMII ) { +int temp; + + temp =phy_read (phydev,MII_M1111_PHY_EXT_CR ); +if (temp <0 ) +return temp; + + temp |= (MII_M1111_RX_DELAY |MII_M1111_TX_DELAY ); + + err =phy_write (phydev,MII_M1111_PHY_EXT_CR , temp); +if (err <0 ) +return err; + + temp =phy_read (phydev,MII_M1111_PHY_EXT_SR ); +if (temp <0 ) +return temp; + + temp &= ~(MII_M1111_HWCFG_MODE_MASK ); + temp |=MII_M1111_HWCFG_MODE_RGMII ; + + err =phy_write (phydev,MII_M1111_PHY_EXT_SR , temp); +if (err <0 ) +return err; + } + + err =phy_write (phydev,MII_BMCR ,BMCR_RESET ); +if (err <0 ) +return err; + +return 0 ; +} +static int m88e1145_config_init (struct phy_device *phydev) {int err;
@@ -216,6 +258,7 @@ static struct phy_driver m88e1111s_driver = { .read_status = &genphy_read_status, .ack_interrupt = &marvell_ack_interrupt, .config_intr = &marvell_config_intr, + .config_init = &m88e1111_config_init, .driver = {.owner = THIS_MODULE,}, };
Signature · 1 line
1.5.0.1
Quoted 1 line · Kim Phillips
also adds RX & TX delay bits to help boards with clock skew problems.
This doesn't make sense at all.
RGMII specifies that clock and data are generated simultaneously. The necessary 1.5-2ns of clock delay is either achieved by routing the RGMII clock net to have that amount of skew, or by programming the RGMII receiver to add that amount of clock delay internally.
So, boards that have 'clock skew problems' should have RX & TX delay turned OFF. Boards that route the clock nets without any skew should have RX & TX delay turned on.
Your patch unconditionally enables clock delay in the 88e1111, which only makes sense if the RGMII data and clock nets are routed to have the approximate same amount of delay. Which means that it is entirely board-specific whether this should be enabled or not. If you enable the 88e1111 internal RX/TX clock delay feature on a board that also routes the RGMII clock nets to have the appropriate amount of skew, things are likely to break entirely.
Review
Quoted 3 lines
[...]
(quoted diff) +2
-0+ + temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
Enabling this unconditionally is just wrong.
I.e. the patch is wrong, and the description is wrong too.
Quoted 5 lines · On Wed, 11 Apr 2007 03:01:58 +0200 Lennert Buytenhek <[email protected]>…
Quoted 2 lines · Kim Phillips
also adds RX & TX delay bits to help boards with clock skew problems.
<snip>
Quoted 7 lines
Review
Quoted 4 lines
[...]
(quoted diff) +2
-0+ + temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);Enabling this unconditionally is just wrong.
I agree. There needs to be a way for the platform code to communicate board specific quirkiness to the phylib (I just haven't figured out how to yet).
Kim
Quoted 7 lines · Kim Phillips
Quoted 5 lines · Kim Phillips
Quoted 3 lines
also adds RX & TX delay bits to help boards with clock skew problems.
<snip>
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Review
Quoted 3 lines
[...]
(quoted diff) +2
-0+ + temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);Enabling this unconditionally is just wrong.
I agree. There needs to be a way for the platform code to communicate board specific quirkiness to the phylib
(I'm not sure whether it's really a quirk, as the RGMII spec allows both modes.)
Quoted 1 line
(I just haven't figured out how to yet).
Maybe offer separate RGMII and RGMII-ID[*] mode choices?
[*] RGMII with Internal Delay (RGMII specification nomenclature)