]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: dsa: mv88e6xxx: Add serdes register read/write helper
authorAndrew Lunn <andrew@lunn.ch>
Thu, 9 Aug 2018 13:38:43 +0000 (15:38 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 9 Aug 2018 18:08:20 +0000 (11:08 -0700)
Add a helper for accessing SERDES registers of the 6390 family.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/mv88e6xxx/serdes.c
drivers/net/dsa/mv88e6xxx/serdes.h

index 496d422170effbfd78f06f6f4ebaf4f07db129c6..36050e4299243c0fb67d7a0d91bb75101852d475 100644 (file)
@@ -35,6 +35,22 @@ static int mv88e6352_serdes_write(struct mv88e6xxx_chip *chip, int reg,
                                        reg, val);
 }
 
+static int mv88e6390_serdes_read(struct mv88e6xxx_chip *chip,
+                                int lane, int device, int reg, u16 *val)
+{
+       int reg_c45 = MII_ADDR_C45 | device << 16 | reg;
+
+       return mv88e6xxx_phy_read(chip, lane, reg_c45, val);
+}
+
+static int mv88e6390_serdes_write(struct mv88e6xxx_chip *chip,
+                                 int lane, int device, int reg, u16 val)
+{
+       int reg_c45 = MII_ADDR_C45 | device << 16 | reg;
+
+       return mv88e6xxx_phy_write(chip, lane, reg_c45, val);
+}
+
 static int mv88e6352_serdes_power_set(struct mv88e6xxx_chip *chip, bool on)
 {
        u16 val, new_val;
@@ -298,12 +314,11 @@ static int mv88e6390_serdes_power_10g(struct mv88e6xxx_chip *chip, int lane,
                                      bool on)
 {
        u16 val, new_val;
-       int reg_c45;
        int err;
 
-       reg_c45 = MII_ADDR_C45 | MV88E6390_SERDES_DEVICE |
-               MV88E6390_PCS_CONTROL_1;
-       err = mv88e6xxx_phy_read(chip, lane, reg_c45, &val);
+       err = mv88e6390_serdes_read(chip, lane, MDIO_MMD_PHYXS,
+                                   MV88E6390_PCS_CONTROL_1, &val);
+
        if (err)
                return err;
 
@@ -315,7 +330,8 @@ static int mv88e6390_serdes_power_10g(struct mv88e6xxx_chip *chip, int lane,
                new_val = val | MV88E6390_PCS_CONTROL_1_PDOWN;
 
        if (val != new_val)
-               err = mv88e6xxx_phy_write(chip, lane, reg_c45, new_val);
+               err = mv88e6390_serdes_write(chip, lane, MDIO_MMD_PHYXS,
+                                            MV88E6390_PCS_CONTROL_1, new_val);
 
        return err;
 }
@@ -325,12 +341,10 @@ static int mv88e6390_serdes_power_sgmii(struct mv88e6xxx_chip *chip, int lane,
                                        bool on)
 {
        u16 val, new_val;
-       int reg_c45;
        int err;
 
-       reg_c45 = MII_ADDR_C45 | MV88E6390_SERDES_DEVICE |
-               MV88E6390_SGMII_CONTROL;
-       err = mv88e6xxx_phy_read(chip, lane, reg_c45, &val);
+       err = mv88e6390_serdes_read(chip, lane, MDIO_MMD_PHYXS,
+                                   MV88E6390_SGMII_CONTROL, &val);
        if (err)
                return err;
 
@@ -342,7 +356,8 @@ static int mv88e6390_serdes_power_sgmii(struct mv88e6xxx_chip *chip, int lane,
                new_val = val | MV88E6390_SGMII_CONTROL_PDOWN;
 
        if (val != new_val)
-               err = mv88e6xxx_phy_write(chip, lane, reg_c45, new_val);
+               err = mv88e6390_serdes_write(chip, lane, MDIO_MMD_PHYXS,
+                                            MV88E6390_SGMII_CONTROL, new_val);
 
        return err;
 }
index 05c4825c36e49ea0547cfc88a2a26085f28c0054..a64ca1974988453c5e37fa660005ffd22ae1777f 100644 (file)
@@ -29,7 +29,6 @@
 #define MV88E6390_PORT10_LANE1         0x15
 #define MV88E6390_PORT10_LANE2         0x16
 #define MV88E6390_PORT10_LANE3         0x17
-#define MV88E6390_SERDES_DEVICE                (4 << 16)
 
 /* 10GBASE-R and 10GBASE-X4/X2 */
 #define MV88E6390_PCS_CONTROL_1                0x1000