chip->ports[port].serdes_irq = 0;
}
-int mv88e6341_serdes_get_lane(struct mv88e6xxx_chip *chip, int port, u8 *lane)
+u8 mv88e6341_serdes_get_lane(struct mv88e6xxx_chip *chip, int port)
{
u8 cmode = chip->ports[port].cmode;
+ u8 lane = 0;
- if (port != 5)
- return -ENODEV;
-
- if (cmode == MV88E6XXX_PORT_STS_CMODE_1000BASEX ||
- cmode == MV88E6XXX_PORT_STS_CMODE_SGMII ||
- cmode == MV88E6XXX_PORT_STS_CMODE_2500BASEX) {
- *lane = MV88E6341_PORT5_LANE;
- return 0;
+ switch (port) {
+ case 5:
+ if (cmode == MV88E6XXX_PORT_STS_CMODE_1000BASEX ||
+ cmode == MV88E6XXX_PORT_STS_CMODE_SGMII ||
+ cmode == MV88E6XXX_PORT_STS_CMODE_2500BASEX)
+ lane = MV88E6341_PORT5_LANE;
+ break;
}
- return -ENODEV;
+ return lane;
}
-int mv88e6390_serdes_get_lane(struct mv88e6xxx_chip *chip, int port, u8 *lane)
+u8 mv88e6390_serdes_get_lane(struct mv88e6xxx_chip *chip, int port)
{
u8 cmode = chip->ports[port].cmode;
+ u8 lane = 0;
switch (port) {
case 9:
if (cmode == MV88E6XXX_PORT_STS_CMODE_1000BASEX ||
cmode == MV88E6XXX_PORT_STS_CMODE_SGMII ||
- cmode == MV88E6XXX_PORT_STS_CMODE_2500BASEX) {
- *lane = MV88E6390_PORT9_LANE0;
- return 0;
- }
+ cmode == MV88E6XXX_PORT_STS_CMODE_2500BASEX)
+ lane = MV88E6390_PORT9_LANE0;
break;
case 10:
if (cmode == MV88E6XXX_PORT_STS_CMODE_1000BASEX ||
cmode == MV88E6XXX_PORT_STS_CMODE_SGMII ||
- cmode == MV88E6XXX_PORT_STS_CMODE_2500BASEX) {
- *lane = MV88E6390_PORT10_LANE0;
- return 0;
- }
- break;
- default:
+ cmode == MV88E6XXX_PORT_STS_CMODE_2500BASEX)
+ lane = MV88E6390_PORT10_LANE0;
break;
}
- return -ENODEV;
+ return lane;
}
-int mv88e6390x_serdes_get_lane(struct mv88e6xxx_chip *chip, int port, u8 *lane)
+u8 mv88e6390x_serdes_get_lane(struct mv88e6xxx_chip *chip, int port)
{
- u8 cmode_port9, cmode_port10, cmode_port;
-
- cmode_port9 = chip->ports[9].cmode;
- cmode_port10 = chip->ports[10].cmode;
- cmode_port = chip->ports[port].cmode;
+ u8 cmode_port = chip->ports[port].cmode;
+ u8 cmode_port10 = chip->ports[10].cmode;
+ u8 cmode_port9 = chip->ports[9].cmode;
+ u8 lane = 0;
switch (port) {
case 2:
if (cmode_port9 == MV88E6XXX_PORT_STS_CMODE_1000BASEX ||
cmode_port9 == MV88E6XXX_PORT_STS_CMODE_SGMII ||
- cmode_port9 == MV88E6XXX_PORT_STS_CMODE_2500BASEX) {
- if (cmode_port == MV88E6XXX_PORT_STS_CMODE_1000BASEX) {
- *lane = MV88E6390_PORT9_LANE1;
- return 0;
- }
- }
+ cmode_port9 == MV88E6XXX_PORT_STS_CMODE_2500BASEX)
+ if (cmode_port == MV88E6XXX_PORT_STS_CMODE_1000BASEX)
+ lane = MV88E6390_PORT9_LANE1;
break;
case 3:
if (cmode_port9 == MV88E6XXX_PORT_STS_CMODE_1000BASEX ||
cmode_port9 == MV88E6XXX_PORT_STS_CMODE_SGMII ||
cmode_port9 == MV88E6XXX_PORT_STS_CMODE_2500BASEX ||
- cmode_port9 == MV88E6XXX_PORT_STS_CMODE_RXAUI) {
- if (cmode_port == MV88E6XXX_PORT_STS_CMODE_1000BASEX) {
- *lane = MV88E6390_PORT9_LANE2;
- return 0;
- }
- }
+ cmode_port9 == MV88E6XXX_PORT_STS_CMODE_RXAUI)
+ if (cmode_port == MV88E6XXX_PORT_STS_CMODE_1000BASEX)
+ lane = MV88E6390_PORT9_LANE2;
break;
case 4:
if (cmode_port9 == MV88E6XXX_PORT_STS_CMODE_1000BASEX ||
cmode_port9 == MV88E6XXX_PORT_STS_CMODE_SGMII ||
cmode_port9 == MV88E6XXX_PORT_STS_CMODE_2500BASEX ||
- cmode_port9 == MV88E6XXX_PORT_STS_CMODE_RXAUI) {
- if (cmode_port == MV88E6XXX_PORT_STS_CMODE_1000BASEX) {
- *lane = MV88E6390_PORT9_LANE3;
- return 0;
- }
- }
+ cmode_port9 == MV88E6XXX_PORT_STS_CMODE_RXAUI)
+ if (cmode_port == MV88E6XXX_PORT_STS_CMODE_1000BASEX)
+ lane = MV88E6390_PORT9_LANE3;
break;
case 5:
if (cmode_port10 == MV88E6XXX_PORT_STS_CMODE_1000BASEX ||
cmode_port10 == MV88E6XXX_PORT_STS_CMODE_SGMII ||
- cmode_port10 == MV88E6XXX_PORT_STS_CMODE_2500BASEX) {
- if (cmode_port == MV88E6XXX_PORT_STS_CMODE_1000BASEX) {
- *lane = MV88E6390_PORT10_LANE1;
- return 0;
- }
- }
+ cmode_port10 == MV88E6XXX_PORT_STS_CMODE_2500BASEX)
+ if (cmode_port == MV88E6XXX_PORT_STS_CMODE_1000BASEX)
+ lane = MV88E6390_PORT10_LANE1;
break;
case 6:
if (cmode_port10 == MV88E6XXX_PORT_STS_CMODE_1000BASEX ||
cmode_port10 == MV88E6XXX_PORT_STS_CMODE_SGMII ||
cmode_port10 == MV88E6XXX_PORT_STS_CMODE_2500BASEX ||
- cmode_port10 == MV88E6XXX_PORT_STS_CMODE_RXAUI) {
- if (cmode_port == MV88E6XXX_PORT_STS_CMODE_1000BASEX) {
- *lane = MV88E6390_PORT10_LANE2;
- return 0;
- }
- }
+ cmode_port10 == MV88E6XXX_PORT_STS_CMODE_RXAUI)
+ if (cmode_port == MV88E6XXX_PORT_STS_CMODE_1000BASEX)
+ lane = MV88E6390_PORT10_LANE2;
break;
case 7:
if (cmode_port10 == MV88E6XXX_PORT_STS_CMODE_1000BASEX ||
cmode_port10 == MV88E6XXX_PORT_STS_CMODE_SGMII ||
cmode_port10 == MV88E6XXX_PORT_STS_CMODE_2500BASEX ||
- cmode_port10 == MV88E6XXX_PORT_STS_CMODE_RXAUI) {
- if (cmode_port == MV88E6XXX_PORT_STS_CMODE_1000BASEX) {
- *lane = MV88E6390_PORT10_LANE3;
- return 0;
- }
- }
+ cmode_port10 == MV88E6XXX_PORT_STS_CMODE_RXAUI)
+ if (cmode_port == MV88E6XXX_PORT_STS_CMODE_1000BASEX)
+ lane = MV88E6390_PORT10_LANE3;
break;
case 9:
if (cmode_port9 == MV88E6XXX_PORT_STS_CMODE_1000BASEX ||
cmode_port9 == MV88E6XXX_PORT_STS_CMODE_SGMII ||
cmode_port9 == MV88E6XXX_PORT_STS_CMODE_2500BASEX ||
cmode_port9 == MV88E6XXX_PORT_STS_CMODE_XAUI ||
- cmode_port9 == MV88E6XXX_PORT_STS_CMODE_RXAUI) {
- *lane = MV88E6390_PORT9_LANE0;
- return 0;
- }
+ cmode_port9 == MV88E6XXX_PORT_STS_CMODE_RXAUI)
+ lane = MV88E6390_PORT9_LANE0;
break;
case 10:
if (cmode_port10 == MV88E6XXX_PORT_STS_CMODE_1000BASEX ||
cmode_port10 == MV88E6XXX_PORT_STS_CMODE_SGMII ||
cmode_port10 == MV88E6XXX_PORT_STS_CMODE_2500BASEX ||
cmode_port10 == MV88E6XXX_PORT_STS_CMODE_XAUI ||
- cmode_port10 == MV88E6XXX_PORT_STS_CMODE_RXAUI) {
- *lane = MV88E6390_PORT10_LANE0;
- return 0;
- }
- break;
- default:
+ cmode_port10 == MV88E6XXX_PORT_STS_CMODE_RXAUI)
+ lane = MV88E6390_PORT10_LANE0;
break;
}
- return -ENODEV;
+ return lane;
}
/* Set the power on/off for 10GBASE-R and 10GBASE-X4/X2 */
{
u8 cmode = chip->ports[port].cmode;
u8 lane;
- int err;
- err = mv88e6xxx_serdes_get_lane(chip, port, &lane);
- if (err) {
- if (err == -ENODEV)
- err = 0;
- return err;
- }
+ lane = mv88e6xxx_serdes_get_lane(chip, port);
+ if (!lane)
+ return 0;
switch (cmode) {
case MV88E6XXX_PORT_STS_CMODE_SGMII:
mv88e6xxx_reg_lock(chip);
- err = mv88e6xxx_serdes_get_lane(chip, port->port, &lane);
- if (err)
+ lane = mv88e6xxx_serdes_get_lane(chip, port->port);
+ if (!lane)
goto out;
switch (cmode) {
int err;
u8 lane;
- err = mv88e6xxx_serdes_get_lane(chip, port, &lane);
- if (err) {
- if (err == -ENODEV)
- err = 0;
- return err;
- }
+ lane = mv88e6xxx_serdes_get_lane(chip, port);
+ if (!lane)
+ return 0;
irq = mv88e6xxx_serdes_irq_mapping(chip, port);
if (!irq)
void mv88e6390_serdes_irq_free(struct mv88e6xxx_chip *chip, int port)
{
- int err;
u8 lane;
- err = mv88e6xxx_serdes_get_lane(chip, port, &lane);
- if (err) {
- if (err != -ENODEV)
- dev_err(chip->dev, "Unable to free SERDES irq: %d\n",
- err);
+ lane = mv88e6xxx_serdes_get_lane(chip, port);
+ if (!lane)
return;
- }
mv88e6390_serdes_irq_disable(chip, port, lane);
#define MV88E6390_SGMII_PHY_STATUS_SPD_DPL_VALID BIT(11)
#define MV88E6390_SGMII_PHY_STATUS_LINK BIT(10)
-/* Put the SERDES lane address a port is using into *lane. If a port has
- * multiple lanes, should put the first lane the port is using. If a port does
- * not have a lane, return -ENODEV.
- */
-static inline int mv88e6xxx_serdes_get_lane(struct mv88e6xxx_chip *chip,
- int port, u8 *lane)
-{
- if (!chip->info->ops->serdes_get_lane)
- return -EOPNOTSUPP;
-
- return chip->info->ops->serdes_get_lane(chip, port, lane);
-}
-
-int mv88e6341_serdes_get_lane(struct mv88e6xxx_chip *chip, int port, u8 *lane);
-int mv88e6390_serdes_get_lane(struct mv88e6xxx_chip *chip, int port, u8 *lane);
-int mv88e6390x_serdes_get_lane(struct mv88e6xxx_chip *chip, int port, u8 *lane);
+u8 mv88e6341_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);
+u8 mv88e6390_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);
+u8 mv88e6390x_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);
unsigned int mv88e6352_serdes_irq_mapping(struct mv88e6xxx_chip *chip,
int port);
unsigned int mv88e6390_serdes_irq_mapping(struct mv88e6xxx_chip *chip,
int mv88e6352_serdes_irq_setup(struct mv88e6xxx_chip *chip, int port);
void mv88e6352_serdes_irq_free(struct mv88e6xxx_chip *chip, int port);
+/* Return the (first) SERDES lane address a port is using, 0 otherwise. */
+static inline u8 mv88e6xxx_serdes_get_lane(struct mv88e6xxx_chip *chip,
+ int port)
+{
+ if (!chip->info->ops->serdes_get_lane)
+ return 0;
+
+ return chip->info->ops->serdes_get_lane(chip, port);
+}
+
static inline unsigned int
mv88e6xxx_serdes_irq_mapping(struct mv88e6xxx_chip *chip, int port)
{