net: phy: Adding SGMII support for Marvell 88ee1145 driver
authorViet Nga Dao <vndao@altera.com>
Fri, 24 Oct 2014 02:41:53 +0000 (19:41 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 28 Oct 2014 18:49:32 +0000 (14:49 -0400)
Additional code to m88e1145_config_init function to allow the driver to
support SGMII mode.

Signed-off-by: Viet Nga Dao <vndao@altera.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/marvell.c

index d2b2f2f795d503ad9488a623c7e3cc8f279535f1..3e3d7cadeb27239a9d33c0c86c00f65ac17aab08 100644 (file)
 #define MII_M1011_PHY_SCR              0x10
 #define MII_M1011_PHY_SCR_AUTO_CROSS   0x0060
 
+#define MII_M1145_PHY_EXT_SR           0x1b
 #define MII_M1145_PHY_EXT_CR           0x14
 #define MII_M1145_RGMII_RX_DELAY       0x0080
 #define MII_M1145_RGMII_TX_DELAY       0x0002
+#define MII_M1145_HWCFG_MODE_SGMII_NO_CLK      0x4
+#define MII_M1145_HWCFG_MODE_MASK              0xf
+#define MII_M1145_HWCFG_FIBER_COPPER_AUTO      0x8000
 
 #define MII_M1111_PHY_LED_CONTROL      0x18
 #define MII_M1111_PHY_LED_DIRECT       0x4100
@@ -642,6 +646,7 @@ static int m88e1149_config_init(struct phy_device *phydev)
 static int m88e1145_config_init(struct phy_device *phydev)
 {
        int err;
+       int temp;
 
        /* Take care of errata E0 & E1 */
        err = phy_write(phydev, 0x1d, 0x001b);
@@ -698,6 +703,20 @@ static int m88e1145_config_init(struct phy_device *phydev)
                }
        }
 
+       if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
+               temp = phy_read(phydev, MII_M1145_PHY_EXT_SR);
+               if (temp < 0)
+                       return temp;
+
+               temp &= ~(MII_M1145_HWCFG_MODE_MASK);
+               temp |= MII_M1145_HWCFG_MODE_SGMII_NO_CLK;
+               temp |= MII_M1145_HWCFG_FIBER_COPPER_AUTO;
+
+               err = phy_write(phydev, MII_M1145_PHY_EXT_SR, temp);
+               if (err < 0)
+                       return err;
+       }
+
        err = marvell_of_reg_init(phydev);
        if (err < 0)
                return err;