diff options
author | Vivien Didelot <vivien.didelot@gmail.com> | 2019-08-31 23:18:33 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-09-01 22:16:38 +0300 |
commit | dc272f600eb3c3453c1289b095c6749d3241ae81 (patch) | |
tree | b43ab2dcb6f5ca0d5051433b7ed7308b0795fe7a /drivers/net/dsa/mv88e6xxx/serdes.c | |
parent | 6600d8e5822d9b3f98c82db3e96df6895b1e87d8 (diff) | |
download | linux-dc272f600eb3c3453c1289b095c6749d3241ae81.tar.xz |
net: dsa: mv88e6xxx: pass lane to .serdes_power
Now the first step of all .serdes_power implementations is getting
the lane mapping. Since we have an operation for that, call it in
the wrapper and pass the lane down to the .serdes_power operation.
This also allows to avoid querying the SERDES lane twice in
mv88e6xxx_port_set_cmode.
At the same time provide mv88e6xxx_serdes_power_{up,down} helpers
and prefer up/down instead of on/off as in the documentation.
Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/dsa/mv88e6xxx/serdes.c')
-rw-r--r-- | drivers/net/dsa/mv88e6xxx/serdes.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/drivers/net/dsa/mv88e6xxx/serdes.c b/drivers/net/dsa/mv88e6xxx/serdes.c index e8ad66987be9..e3ea8cca85b0 100644 --- a/drivers/net/dsa/mv88e6xxx/serdes.c +++ b/drivers/net/dsa/mv88e6xxx/serdes.c @@ -49,19 +49,17 @@ static int mv88e6390_serdes_write(struct mv88e6xxx_chip *chip, return mv88e6xxx_phy_write(chip, lane, reg_c45, val); } -int mv88e6352_serdes_power(struct mv88e6xxx_chip *chip, int port, bool on) +int mv88e6352_serdes_power(struct mv88e6xxx_chip *chip, int port, u8 lane, + bool up) { u16 val, new_val; int err; - if (!mv88e6xxx_serdes_get_lane(chip, port)) - return 0; - err = mv88e6352_serdes_read(chip, MII_BMCR, &val); if (err) return err; - if (on) + if (up) new_val = val & ~BMCR_PDOWN; else new_val = val | BMCR_PDOWN; @@ -409,9 +407,9 @@ u8 mv88e6390x_serdes_get_lane(struct mv88e6xxx_chip *chip, int port) return lane; } -/* Set the power on/off for 10GBASE-R and 10GBASE-X4/X2 */ +/* Set power up/down for 10GBASE-R and 10GBASE-X4/X2 */ static int mv88e6390_serdes_power_10g(struct mv88e6xxx_chip *chip, u8 lane, - bool on) + bool up) { u16 val, new_val; int err; @@ -422,7 +420,7 @@ static int mv88e6390_serdes_power_10g(struct mv88e6xxx_chip *chip, u8 lane, if (err) return err; - if (on) + if (up) new_val = val & ~(MV88E6390_PCS_CONTROL_1_RESET | MV88E6390_PCS_CONTROL_1_LOOPBACK | MV88E6390_PCS_CONTROL_1_PDOWN); @@ -436,9 +434,9 @@ static int mv88e6390_serdes_power_10g(struct mv88e6xxx_chip *chip, u8 lane, return err; } -/* Set the power on/off for SGMII and 1000Base-X */ +/* Set power up/down for SGMII and 1000Base-X */ static int mv88e6390_serdes_power_sgmii(struct mv88e6xxx_chip *chip, u8 lane, - bool on) + bool up) { u16 val, new_val; int err; @@ -448,7 +446,7 @@ static int mv88e6390_serdes_power_sgmii(struct mv88e6xxx_chip *chip, u8 lane, if (err) return err; - if (on) + if (up) new_val = val & ~(MV88E6390_SGMII_CONTROL_RESET | MV88E6390_SGMII_CONTROL_LOOPBACK | MV88E6390_SGMII_CONTROL_PDOWN); @@ -462,23 +460,19 @@ static int mv88e6390_serdes_power_sgmii(struct mv88e6xxx_chip *chip, u8 lane, return err; } -int mv88e6390_serdes_power(struct mv88e6xxx_chip *chip, int port, bool on) +int mv88e6390_serdes_power(struct mv88e6xxx_chip *chip, int port, u8 lane, + bool up) { u8 cmode = chip->ports[port].cmode; - u8 lane; - - lane = mv88e6xxx_serdes_get_lane(chip, port); - if (!lane) - return 0; switch (cmode) { case MV88E6XXX_PORT_STS_CMODE_SGMII: case MV88E6XXX_PORT_STS_CMODE_1000BASEX: case MV88E6XXX_PORT_STS_CMODE_2500BASEX: - return mv88e6390_serdes_power_sgmii(chip, lane, on); + return mv88e6390_serdes_power_sgmii(chip, lane, up); case MV88E6XXX_PORT_STS_CMODE_XAUI: case MV88E6XXX_PORT_STS_CMODE_RXAUI: - return mv88e6390_serdes_power_10g(chip, lane, on); + return mv88e6390_serdes_power_10g(chip, lane, up); } return 0; |