phy: marvell: Add support for 88E3016 FastEthernet PHY
authorSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Wed, 22 Oct 2014 18:26:44 +0000 (20:26 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 24 Oct 2014 19:49:20 +0000 (15:49 -0400)
Marvell 88E3016 is a FastEthernet PHY that also can be found in Marvell
Berlin SoCs as integrated PHY.

Tested-by: Antoine Ténart <antoine.tenart@free-electrons.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/marvell.c
include/linux/marvell_phy.h

index bd37e45c89c0e13f8128c82ac284c4ba6530d52d..d2b2f2f795d503ad9488a623c7e3cc8f279535f1 100644 (file)
 
 #define MII_M1116R_CONTROL_REG_MAC     21
 
+#define MII_88E3016_PHY_SPEC_CTRL      0x10
+#define MII_88E3016_DISABLE_SCRAMBLER  0x0200
+#define MII_88E3016_AUTO_MDIX_CROSSOVER        0x0030
 
 MODULE_DESCRIPTION("Marvell PHY driver");
 MODULE_AUTHOR("Andy Fleming");
@@ -434,6 +437,25 @@ static int m88e1116r_config_init(struct phy_device *phydev)
        return 0;
 }
 
+static int m88e3016_config_init(struct phy_device *phydev)
+{
+       int reg;
+
+       /* Enable Scrambler and Auto-Crossover */
+       reg = phy_read(phydev, MII_88E3016_PHY_SPEC_CTRL);
+       if (reg < 0)
+               return reg;
+
+       reg &= ~MII_88E3016_DISABLE_SCRAMBLER;
+       reg |= MII_88E3016_AUTO_MDIX_CROSSOVER;
+
+       reg = phy_write(phydev, MII_88E3016_PHY_SPEC_CTRL, reg);
+       if (reg < 0)
+               return reg;
+
+       return 0;
+}
+
 static int m88e1111_config_init(struct phy_device *phydev)
 {
        int err;
@@ -770,6 +792,12 @@ static int marvell_read_status(struct phy_device *phydev)
        return 0;
 }
 
+static int marvell_aneg_done(struct phy_device *phydev)
+{
+       int retval = phy_read(phydev, MII_M1011_PHY_STATUS);
+       return (retval < 0) ? retval : (retval & MII_M1011_PHY_STATUS_RESOLVED);
+}
+
 static int m88e1121_did_interrupt(struct phy_device *phydev)
 {
        int imask;
@@ -1050,6 +1078,23 @@ static struct phy_driver marvell_drivers[] = {
                .suspend = &genphy_suspend,
                .driver = { .owner = THIS_MODULE },
        },
+       {
+               .phy_id = MARVELL_PHY_ID_88E3016,
+               .phy_id_mask = MARVELL_PHY_ID_MASK,
+               .name = "Marvell 88E3016",
+               .features = PHY_BASIC_FEATURES,
+               .flags = PHY_HAS_INTERRUPT,
+               .config_aneg = &genphy_config_aneg,
+               .config_init = &m88e3016_config_init,
+               .aneg_done = &marvell_aneg_done,
+               .read_status = &marvell_read_status,
+               .ack_interrupt = &marvell_ack_interrupt,
+               .config_intr = &marvell_config_intr,
+               .did_interrupt = &m88e1121_did_interrupt,
+               .resume = &genphy_resume,
+               .suspend = &genphy_suspend,
+               .driver = { .owner = THIS_MODULE },
+       },
 };
 
 static int __init marvell_init(void)
@@ -1079,6 +1124,7 @@ static struct mdio_device_id __maybe_unused marvell_tbl[] = {
        { MARVELL_PHY_ID_88E1318S, MARVELL_PHY_ID_MASK },
        { MARVELL_PHY_ID_88E1116R, MARVELL_PHY_ID_MASK },
        { MARVELL_PHY_ID_88E1510, MARVELL_PHY_ID_MASK },
+       { MARVELL_PHY_ID_88E3016, MARVELL_PHY_ID_MASK },
        { }
 };
 
index 8e9a029e093d6522b68c0929aad93704f47c3ad5..e6982ac3200d65a537f2561bd51c2a0696b62e70 100644 (file)
@@ -16,6 +16,7 @@
 #define MARVELL_PHY_ID_88E1318S                0x01410e90
 #define MARVELL_PHY_ID_88E1116R                0x01410e40
 #define MARVELL_PHY_ID_88E1510         0x01410dd0
+#define MARVELL_PHY_ID_88E3016         0x01410e60
 
 /* struct phy_device dev_flags definitions */
 #define MARVELL_PHY_M1145_FLAGS_RESISTANCE     0x00000001