phy: add RTBI mode for m88e1111
authorLiu Yu-B13201 <Yu.Liu@freescale.com>
Wed, 13 Jan 2010 22:13:19 +0000 (22:13 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 Jan 2010 09:17:56 +0000 (01:17 -0800)
Signed-off-by: Liu Yu <yu.liu@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/marvell.c

index 6f69b9ba0df8994736e9f1a0eaad78b0a52f497f..65ed385c2ceb430f091cf26ef0b1acfc87a6978a 100644 (file)
@@ -63,6 +63,7 @@
 #define MII_M1111_HWCFG_MODE_COPPER_RGMII      0xb
 #define MII_M1111_HWCFG_MODE_FIBER_RGMII       0x3
 #define MII_M1111_HWCFG_MODE_SGMII_NO_CLK      0x4
+#define MII_M1111_HWCFG_MODE_COPPER_RTBI       0x9
 #define MII_M1111_HWCFG_FIBER_COPPER_AUTO      0x8000
 #define MII_M1111_HWCFG_FIBER_COPPER_RES       0x2000
 
@@ -269,6 +270,43 @@ static int m88e1111_config_init(struct phy_device *phydev)
                        return err;
        }
 
+       if (phydev->interface == PHY_INTERFACE_MODE_RTBI) {
+               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 | MII_M1111_HWCFG_FIBER_COPPER_RES);
+               temp |= 0x7 | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
+               err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
+               if (err < 0)
+                       return err;
+
+               /* soft reset */
+               err = phy_write(phydev, MII_BMCR, BMCR_RESET);
+               if (err < 0)
+                       return err;
+               do
+                       temp = phy_read(phydev, MII_BMCR);
+               while (temp & BMCR_RESET);
+
+               temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
+               if (temp < 0)
+                       return temp;
+               temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
+               temp |= MII_M1111_HWCFG_MODE_COPPER_RTBI | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
+               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;