Lines Matching refs:pdata
390 static enum xgbe_an_mode xgbe_phy_an_mode(struct xgbe_prv_data *pdata);
391 static void xgbe_phy_rrc(struct xgbe_prv_data *pdata);
392 static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata,
396 static int xgbe_phy_i2c_xfer(struct xgbe_prv_data *pdata, in xgbe_phy_i2c_xfer() argument
399 return pdata->i2c_if.i2c_xfer(pdata, i2c_op); in xgbe_phy_i2c_xfer()
402 static int xgbe_phy_redrv_write(struct xgbe_prv_data *pdata, unsigned int reg, in xgbe_phy_redrv_write() argument
405 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_redrv_write()
433 ret = xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_redrv_write()
447 ret = xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_redrv_write()
456 netif_dbg(pdata, drv, pdata->netdev, in xgbe_phy_redrv_write()
464 static int xgbe_phy_i2c_write(struct xgbe_prv_data *pdata, unsigned int target, in xgbe_phy_i2c_write() argument
477 ret = xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_i2c_write()
484 static int xgbe_phy_i2c_read(struct xgbe_prv_data *pdata, unsigned int target, in xgbe_phy_i2c_read() argument
498 ret = xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_i2c_read()
513 ret = xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_i2c_read()
520 static int xgbe_phy_sfp_put_mux(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_put_mux() argument
522 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_put_mux()
536 return xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_sfp_put_mux()
539 static int xgbe_phy_sfp_get_mux(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_get_mux() argument
541 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_get_mux()
555 return xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_sfp_get_mux()
558 static void xgbe_phy_put_comm_ownership(struct xgbe_prv_data *pdata) in xgbe_phy_put_comm_ownership() argument
563 static int xgbe_phy_get_comm_ownership(struct xgbe_prv_data *pdata) in xgbe_phy_get_comm_ownership() argument
565 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_get_comm_ownership()
576 XP_IOWRITE(pdata, XP_I2C_MUTEX, XGBE_MUTEX_RELEASE); in xgbe_phy_get_comm_ownership()
577 XP_IOWRITE(pdata, XP_MDIO_MUTEX, XGBE_MUTEX_RELEASE); in xgbe_phy_get_comm_ownership()
587 if (XP_IOREAD(pdata, XP_I2C_MUTEX) || in xgbe_phy_get_comm_ownership()
588 XP_IOREAD(pdata, XP_MDIO_MUTEX)) { in xgbe_phy_get_comm_ownership()
594 XP_IOWRITE(pdata, XP_I2C_MUTEX, mutex_id); in xgbe_phy_get_comm_ownership()
595 XP_IOWRITE(pdata, XP_MDIO_MUTEX, mutex_id); in xgbe_phy_get_comm_ownership()
602 netdev_err(pdata->netdev, "unable to obtain hardware mutexes\n"); in xgbe_phy_get_comm_ownership()
607 static int xgbe_phy_mdio_mii_write_c22(struct xgbe_prv_data *pdata, int addr, in xgbe_phy_mdio_mii_write_c22() argument
610 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mdio_mii_write_c22()
615 return pdata->hw_if.write_ext_mii_regs_c22(pdata, addr, reg, val); in xgbe_phy_mdio_mii_write_c22()
618 static int xgbe_phy_mdio_mii_write_c45(struct xgbe_prv_data *pdata, int addr, in xgbe_phy_mdio_mii_write_c45() argument
621 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mdio_mii_write_c45()
626 return pdata->hw_if.write_ext_mii_regs_c45(pdata, addr, devad, in xgbe_phy_mdio_mii_write_c45()
630 static int xgbe_phy_i2c_mii_write(struct xgbe_prv_data *pdata, int reg, u16 val) in xgbe_phy_i2c_mii_write() argument
636 ret = xgbe_phy_sfp_get_mux(pdata); in xgbe_phy_i2c_mii_write()
644 ret = xgbe_phy_i2c_write(pdata, XGBE_SFP_PHY_ADDRESS, in xgbe_phy_i2c_mii_write()
647 xgbe_phy_sfp_put_mux(pdata); in xgbe_phy_i2c_mii_write()
655 struct xgbe_prv_data *pdata = mii->priv; in xgbe_phy_mii_write_c22() local
656 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mii_write_c22()
659 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_mii_write_c22()
664 ret = xgbe_phy_i2c_mii_write(pdata, reg, val); in xgbe_phy_mii_write_c22()
666 ret = xgbe_phy_mdio_mii_write_c22(pdata, addr, reg, val); in xgbe_phy_mii_write_c22()
670 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_mii_write_c22()
678 struct xgbe_prv_data *pdata = mii->priv; in xgbe_phy_mii_write_c45() local
679 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mii_write_c45()
682 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_mii_write_c45()
689 ret = xgbe_phy_mdio_mii_write_c45(pdata, addr, devad, reg, val); in xgbe_phy_mii_write_c45()
693 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_mii_write_c45()
698 static int xgbe_phy_mdio_mii_read_c22(struct xgbe_prv_data *pdata, int addr, in xgbe_phy_mdio_mii_read_c22() argument
701 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mdio_mii_read_c22()
706 return pdata->hw_if.read_ext_mii_regs_c22(pdata, addr, reg); in xgbe_phy_mdio_mii_read_c22()
709 static int xgbe_phy_mdio_mii_read_c45(struct xgbe_prv_data *pdata, int addr, in xgbe_phy_mdio_mii_read_c45() argument
712 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mdio_mii_read_c45()
717 return pdata->hw_if.read_ext_mii_regs_c45(pdata, addr, devad, reg); in xgbe_phy_mdio_mii_read_c45()
720 static int xgbe_phy_i2c_mii_read(struct xgbe_prv_data *pdata, int reg) in xgbe_phy_i2c_mii_read() argument
726 ret = xgbe_phy_sfp_get_mux(pdata); in xgbe_phy_i2c_mii_read()
731 ret = xgbe_phy_i2c_read(pdata, XGBE_SFP_PHY_ADDRESS, in xgbe_phy_i2c_mii_read()
737 xgbe_phy_sfp_put_mux(pdata); in xgbe_phy_i2c_mii_read()
744 struct xgbe_prv_data *pdata = mii->priv; in xgbe_phy_mii_read_c22() local
745 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mii_read_c22()
748 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_mii_read_c22()
753 ret = xgbe_phy_i2c_mii_read(pdata, reg); in xgbe_phy_mii_read_c22()
755 ret = xgbe_phy_mdio_mii_read_c22(pdata, addr, reg); in xgbe_phy_mii_read_c22()
759 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_mii_read_c22()
767 struct xgbe_prv_data *pdata = mii->priv; in xgbe_phy_mii_read_c45() local
768 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mii_read_c45()
771 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_mii_read_c45()
778 ret = xgbe_phy_mdio_mii_read_c45(pdata, addr, devad, reg); in xgbe_phy_mii_read_c45()
782 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_mii_read_c45()
787 static void xgbe_phy_sfp_phy_settings(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_phy_settings() argument
789 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_sfp_phy_settings()
790 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_phy_settings()
798 pdata->phy.speed = SPEED_UNKNOWN; in xgbe_phy_sfp_phy_settings()
799 pdata->phy.duplex = DUPLEX_UNKNOWN; in xgbe_phy_sfp_phy_settings()
800 pdata->phy.autoneg = AUTONEG_ENABLE; in xgbe_phy_sfp_phy_settings()
801 pdata->phy.pause_autoneg = AUTONEG_ENABLE; in xgbe_phy_sfp_phy_settings()
819 pdata->phy.speed = SPEED_UNKNOWN; in xgbe_phy_sfp_phy_settings()
820 pdata->phy.duplex = DUPLEX_UNKNOWN; in xgbe_phy_sfp_phy_settings()
821 pdata->phy.autoneg = AUTONEG_ENABLE; in xgbe_phy_sfp_phy_settings()
822 pdata->phy.pause_autoneg = AUTONEG_ENABLE; in xgbe_phy_sfp_phy_settings()
843 pdata->phy.speed = SPEED_10000; in xgbe_phy_sfp_phy_settings()
844 pdata->phy.duplex = DUPLEX_FULL; in xgbe_phy_sfp_phy_settings()
845 pdata->phy.autoneg = AUTONEG_DISABLE; in xgbe_phy_sfp_phy_settings()
846 pdata->phy.pause_autoneg = AUTONEG_DISABLE; in xgbe_phy_sfp_phy_settings()
870 pdata->phy.speed = SPEED_UNKNOWN; in xgbe_phy_sfp_phy_settings()
871 pdata->phy.duplex = DUPLEX_UNKNOWN; in xgbe_phy_sfp_phy_settings()
872 pdata->phy.autoneg = AUTONEG_DISABLE; in xgbe_phy_sfp_phy_settings()
873 pdata->phy.pause_autoneg = AUTONEG_DISABLE; in xgbe_phy_sfp_phy_settings()
912 static void xgbe_phy_free_phy_device(struct xgbe_prv_data *pdata) in xgbe_phy_free_phy_device() argument
914 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_free_phy_device()
924 static bool xgbe_phy_finisar_phy_quirks(struct xgbe_prv_data *pdata) in xgbe_phy_finisar_phy_quirks() argument
927 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_finisar_phy_quirks()
959 netif_dbg(pdata, drv, pdata->netdev, in xgbe_phy_finisar_phy_quirks()
965 static bool xgbe_phy_belfuse_phy_quirks(struct xgbe_prv_data *pdata) in xgbe_phy_belfuse_phy_quirks() argument
968 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_belfuse_phy_quirks()
981 pdata->an_again = 1; in xgbe_phy_belfuse_phy_quirks()
1040 netif_dbg(pdata, drv, pdata->netdev, in xgbe_phy_belfuse_phy_quirks()
1046 static void xgbe_phy_external_phy_quirks(struct xgbe_prv_data *pdata) in xgbe_phy_external_phy_quirks() argument
1048 if (xgbe_phy_belfuse_phy_quirks(pdata)) in xgbe_phy_external_phy_quirks()
1051 if (xgbe_phy_finisar_phy_quirks(pdata)) in xgbe_phy_external_phy_quirks()
1055 static int xgbe_phy_find_phy_device(struct xgbe_prv_data *pdata) in xgbe_phy_find_phy_device() argument
1057 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_find_phy_device()
1058 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_find_phy_device()
1067 pdata->an_again = 0; in xgbe_phy_find_phy_device()
1079 ret = pdata->hw_if.set_ext_mii_mode(pdata, phy_data->mdio_addr, in xgbe_phy_find_phy_device()
1082 netdev_err(pdata->netdev, in xgbe_phy_find_phy_device()
1092 netdev_err(pdata->netdev, "get_phy_device failed\n"); in xgbe_phy_find_phy_device()
1095 netif_dbg(pdata, drv, pdata->netdev, "external PHY id is %#010x\n", in xgbe_phy_find_phy_device()
1102 netdev_err(pdata->netdev, "phy_device_register failed\n"); in xgbe_phy_find_phy_device()
1107 ret = phy_attach_direct(pdata->netdev, phydev, phydev->dev_flags, in xgbe_phy_find_phy_device()
1110 netdev_err(pdata->netdev, "phy_attach_direct failed\n"); in xgbe_phy_find_phy_device()
1117 xgbe_phy_external_phy_quirks(pdata); in xgbe_phy_find_phy_device()
1127 static void xgbe_phy_sfp_external_phy(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_external_phy() argument
1129 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_external_phy()
1141 ret = xgbe_phy_i2c_mii_read(pdata, MII_BMCR); in xgbe_phy_sfp_external_phy()
1192 static void xgbe_phy_sfp_parse_eeprom(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_parse_eeprom() argument
1194 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_parse_eeprom()
1262 static void xgbe_phy_sfp_eeprom_info(struct xgbe_prv_data *pdata, in xgbe_phy_sfp_eeprom_info() argument
1268 netif_dbg(pdata, drv, pdata->netdev, "SFP detected:\n"); in xgbe_phy_sfp_eeprom_info()
1272 netif_dbg(pdata, drv, pdata->netdev, " vendor: %s\n", in xgbe_phy_sfp_eeprom_info()
1278 netif_dbg(pdata, drv, pdata->netdev, " part number: %s\n", in xgbe_phy_sfp_eeprom_info()
1284 netif_dbg(pdata, drv, pdata->netdev, " revision level: %s\n", in xgbe_phy_sfp_eeprom_info()
1290 netif_dbg(pdata, drv, pdata->netdev, " serial number: %s\n", in xgbe_phy_sfp_eeprom_info()
1304 static int xgbe_phy_sfp_read_eeprom(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_read_eeprom() argument
1306 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_read_eeprom()
1311 ret = xgbe_phy_sfp_get_mux(pdata); in xgbe_phy_sfp_read_eeprom()
1313 dev_err_once(pdata->dev, "%s: I2C error setting SFP MUX\n", in xgbe_phy_sfp_read_eeprom()
1314 netdev_name(pdata->netdev)); in xgbe_phy_sfp_read_eeprom()
1320 ret = xgbe_phy_i2c_read(pdata, XGBE_SFP_SERIAL_ID_ADDRESS, in xgbe_phy_sfp_read_eeprom()
1324 dev_err_once(pdata->dev, "%s: I2C error reading SFP EEPROM\n", in xgbe_phy_sfp_read_eeprom()
1325 netdev_name(pdata->netdev)); in xgbe_phy_sfp_read_eeprom()
1348 if (netif_msg_drv(pdata)) in xgbe_phy_sfp_read_eeprom()
1349 xgbe_phy_sfp_eeprom_info(pdata, &sfp_eeprom); in xgbe_phy_sfp_read_eeprom()
1353 xgbe_phy_free_phy_device(pdata); in xgbe_phy_sfp_read_eeprom()
1359 xgbe_phy_sfp_put_mux(pdata); in xgbe_phy_sfp_read_eeprom()
1364 static void xgbe_phy_sfp_signals(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_signals() argument
1366 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_signals()
1372 ret = xgbe_phy_i2c_read(pdata, phy_data->sfp_gpio_address, in xgbe_phy_sfp_signals()
1376 dev_err_once(pdata->dev, "%s: I2C error reading SFP GPIOs\n", in xgbe_phy_sfp_signals()
1377 netdev_name(pdata->netdev)); in xgbe_phy_sfp_signals()
1386 static void xgbe_phy_sfp_mod_absent(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_mod_absent() argument
1388 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_mod_absent()
1390 xgbe_phy_free_phy_device(pdata); in xgbe_phy_sfp_mod_absent()
1407 static void xgbe_phy_sfp_detect(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_detect() argument
1409 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_detect()
1415 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_sfp_detect()
1420 xgbe_phy_sfp_signals(pdata); in xgbe_phy_sfp_detect()
1422 xgbe_phy_sfp_mod_absent(pdata); in xgbe_phy_sfp_detect()
1426 ret = xgbe_phy_sfp_read_eeprom(pdata); in xgbe_phy_sfp_detect()
1430 xgbe_phy_sfp_mod_absent(pdata); in xgbe_phy_sfp_detect()
1434 xgbe_phy_sfp_parse_eeprom(pdata); in xgbe_phy_sfp_detect()
1436 xgbe_phy_sfp_external_phy(pdata); in xgbe_phy_sfp_detect()
1439 xgbe_phy_sfp_phy_settings(pdata); in xgbe_phy_sfp_detect()
1441 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_sfp_detect()
1444 static int xgbe_phy_module_eeprom(struct xgbe_prv_data *pdata, in xgbe_phy_module_eeprom() argument
1447 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_module_eeprom()
1470 if (!netif_running(pdata->netdev)) { in xgbe_phy_module_eeprom()
1480 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_module_eeprom()
1486 ret = xgbe_phy_sfp_get_mux(pdata); in xgbe_phy_module_eeprom()
1488 netdev_err(pdata->netdev, "I2C error setting SFP MUX\n"); in xgbe_phy_module_eeprom()
1495 ret = xgbe_phy_i2c_read(pdata, XGBE_SFP_SERIAL_ID_ADDRESS, in xgbe_phy_module_eeprom()
1499 netdev_err(pdata->netdev, in xgbe_phy_module_eeprom()
1510 ret = xgbe_phy_i2c_read(pdata, XGBE_SFP_DIAG_INFO_ADDRESS, in xgbe_phy_module_eeprom()
1515 netdev_err(pdata->netdev, in xgbe_phy_module_eeprom()
1532 xgbe_phy_sfp_put_mux(pdata); in xgbe_phy_module_eeprom()
1535 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_module_eeprom()
1543 static int xgbe_phy_module_info(struct xgbe_prv_data *pdata, in xgbe_phy_module_info() argument
1546 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_module_info()
1551 if (!netif_running(pdata->netdev)) in xgbe_phy_module_info()
1568 static void xgbe_phy_phydev_flowctrl(struct xgbe_prv_data *pdata) in xgbe_phy_phydev_flowctrl() argument
1570 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_phydev_flowctrl()
1571 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_phydev_flowctrl()
1575 pdata->phy.tx_pause = 0; in xgbe_phy_phydev_flowctrl()
1576 pdata->phy.rx_pause = 0; in xgbe_phy_phydev_flowctrl()
1594 pdata->phy.tx_pause = 1; in xgbe_phy_phydev_flowctrl()
1596 pdata->phy.rx_pause = 1; in xgbe_phy_phydev_flowctrl()
1599 static enum xgbe_mode xgbe_phy_an37_sgmii_outcome(struct xgbe_prv_data *pdata) in xgbe_phy_an37_sgmii_outcome() argument
1601 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_an37_sgmii_outcome()
1608 if (pdata->phy.pause_autoneg) in xgbe_phy_an37_sgmii_outcome()
1609 xgbe_phy_phydev_flowctrl(pdata); in xgbe_phy_an37_sgmii_outcome()
1611 switch (pdata->an_status & XGBE_SGMII_AN_LINK_SPEED) { in xgbe_phy_an37_sgmii_outcome()
1613 if (pdata->an_status & XGBE_SGMII_AN_LINK_DUPLEX) { in xgbe_phy_an37_sgmii_outcome()
1623 if (pdata->an_status & XGBE_SGMII_AN_LINK_DUPLEX) { in xgbe_phy_an37_sgmii_outcome()
1633 if (pdata->an_status & XGBE_SGMII_AN_LINK_DUPLEX) { in xgbe_phy_an37_sgmii_outcome()
1649 static enum xgbe_mode xgbe_phy_an37_outcome(struct xgbe_prv_data *pdata) in xgbe_phy_an37_outcome() argument
1651 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_an37_outcome()
1659 ad_reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_VEND2_AN_ADVERTISE); in xgbe_phy_an37_outcome()
1660 lp_reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_VEND2_AN_LP_ABILITY); in xgbe_phy_an37_outcome()
1666 if (pdata->phy.pause_autoneg) { in xgbe_phy_an37_outcome()
1668 pdata->phy.tx_pause = 0; in xgbe_phy_an37_outcome()
1669 pdata->phy.rx_pause = 0; in xgbe_phy_an37_outcome()
1672 pdata->phy.tx_pause = 1; in xgbe_phy_an37_outcome()
1673 pdata->phy.rx_pause = 1; in xgbe_phy_an37_outcome()
1676 pdata->phy.rx_pause = 1; in xgbe_phy_an37_outcome()
1678 pdata->phy.tx_pause = 1; in xgbe_phy_an37_outcome()
1692 static enum xgbe_mode xgbe_phy_an73_redrv_outcome(struct xgbe_prv_data *pdata) in xgbe_phy_an73_redrv_outcome() argument
1694 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_an73_redrv_outcome()
1695 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_an73_redrv_outcome()
1703 if (pdata->phy.pause_autoneg) in xgbe_phy_an73_redrv_outcome()
1704 xgbe_phy_phydev_flowctrl(pdata); in xgbe_phy_an73_redrv_outcome()
1707 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 1); in xgbe_phy_an73_redrv_outcome()
1708 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA + 1); in xgbe_phy_an73_redrv_outcome()
1770 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 2); in xgbe_phy_an73_redrv_outcome()
1771 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA + 2); in xgbe_phy_an73_redrv_outcome()
1778 static enum xgbe_mode xgbe_phy_an73_outcome(struct xgbe_prv_data *pdata) in xgbe_phy_an73_outcome() argument
1780 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_an73_outcome()
1788 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE); in xgbe_phy_an73_outcome()
1789 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA); in xgbe_phy_an73_outcome()
1795 if (pdata->phy.pause_autoneg) { in xgbe_phy_an73_outcome()
1797 pdata->phy.tx_pause = 0; in xgbe_phy_an73_outcome()
1798 pdata->phy.rx_pause = 0; in xgbe_phy_an73_outcome()
1801 pdata->phy.tx_pause = 1; in xgbe_phy_an73_outcome()
1802 pdata->phy.rx_pause = 1; in xgbe_phy_an73_outcome()
1805 pdata->phy.rx_pause = 1; in xgbe_phy_an73_outcome()
1807 pdata->phy.tx_pause = 1; in xgbe_phy_an73_outcome()
1812 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 1); in xgbe_phy_an73_outcome()
1813 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA + 1); in xgbe_phy_an73_outcome()
1828 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 2); in xgbe_phy_an73_outcome()
1829 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA + 2); in xgbe_phy_an73_outcome()
1836 static enum xgbe_mode xgbe_phy_an_outcome(struct xgbe_prv_data *pdata) in xgbe_phy_an_outcome() argument
1838 switch (pdata->an_mode) { in xgbe_phy_an_outcome()
1840 return xgbe_phy_an73_outcome(pdata); in xgbe_phy_an_outcome()
1842 return xgbe_phy_an73_redrv_outcome(pdata); in xgbe_phy_an_outcome()
1844 return xgbe_phy_an37_outcome(pdata); in xgbe_phy_an_outcome()
1846 return xgbe_phy_an37_sgmii_outcome(pdata); in xgbe_phy_an_outcome()
1852 static void xgbe_phy_an_advertising(struct xgbe_prv_data *pdata, in xgbe_phy_an_advertising() argument
1855 struct ethtool_link_ksettings *slks = &pdata->phy.lks; in xgbe_phy_an_advertising()
1856 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_an_advertising()
1869 if (pdata->fec_ability & MDIO_PMA_10GBR_FECABLE_ABLE) in xgbe_phy_an_advertising()
1917 static int xgbe_phy_an_config(struct xgbe_prv_data *pdata) in xgbe_phy_an_config() argument
1919 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_an_config()
1920 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_an_config()
1923 ret = xgbe_phy_find_phy_device(pdata); in xgbe_phy_an_config()
1930 phy_data->phydev->autoneg = pdata->phy.autoneg; in xgbe_phy_an_config()
1935 if (pdata->phy.autoneg != AUTONEG_ENABLE) { in xgbe_phy_an_config()
1936 phy_data->phydev->speed = pdata->phy.speed; in xgbe_phy_an_config()
1937 phy_data->phydev->duplex = pdata->phy.duplex; in xgbe_phy_an_config()
1959 static enum xgbe_an_mode xgbe_phy_an_mode(struct xgbe_prv_data *pdata) in xgbe_phy_an_mode() argument
1961 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_an_mode()
1990 static int xgbe_phy_set_redrv_mode_mdio(struct xgbe_prv_data *pdata, in xgbe_phy_set_redrv_mode_mdio() argument
1993 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_set_redrv_mode_mdio()
1999 return pdata->hw_if.write_ext_mii_regs_c22(pdata, phy_data->redrv_addr, in xgbe_phy_set_redrv_mode_mdio()
2003 static int xgbe_phy_set_redrv_mode_i2c(struct xgbe_prv_data *pdata, in xgbe_phy_set_redrv_mode_i2c() argument
2006 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_set_redrv_mode_i2c()
2013 ret = xgbe_phy_redrv_write(pdata, redrv_reg, mode); in xgbe_phy_set_redrv_mode_i2c()
2018 static void xgbe_phy_set_redrv_mode(struct xgbe_prv_data *pdata) in xgbe_phy_set_redrv_mode() argument
2020 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_set_redrv_mode()
2033 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_set_redrv_mode()
2038 xgbe_phy_set_redrv_mode_i2c(pdata, mode); in xgbe_phy_set_redrv_mode()
2040 xgbe_phy_set_redrv_mode_mdio(pdata, mode); in xgbe_phy_set_redrv_mode()
2042 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_set_redrv_mode()
2049 static void xgbe_set_rx_adap_mode(struct xgbe_prv_data *pdata, in xgbe_set_rx_adap_mode() argument
2052 if (pdata->rx_adapt_retries++ >= MAX_RX_ADAPT_RETRIES) { in xgbe_set_rx_adap_mode()
2053 pdata->rx_adapt_retries = 0; in xgbe_set_rx_adap_mode()
2057 xgbe_phy_perform_ratechange(pdata, in xgbe_set_rx_adap_mode()
2064 static void xgbe_rx_adaptation(struct xgbe_prv_data *pdata) in xgbe_rx_adaptation() argument
2066 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_rx_adaptation()
2070 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_RX_EQ_CTRL4, in xgbe_rx_adaptation()
2077 reg = XMDIO_READ(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_PHY_RX_EQ_CEU); in xgbe_rx_adaptation()
2080 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_RX_EQ_CTRL4, in xgbe_rx_adaptation()
2092 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); in xgbe_rx_adaptation()
2093 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); in xgbe_rx_adaptation()
2098 netif_dbg(pdata, link, pdata->netdev, "Block_lock done"); in xgbe_rx_adaptation()
2099 pdata->rx_adapt_done = true; in xgbe_rx_adaptation()
2100 pdata->mode_set = false; in xgbe_rx_adaptation()
2105 xgbe_set_rx_adap_mode(pdata, phy_data->cur_mode); in xgbe_rx_adaptation()
2108 static void xgbe_phy_rx_adaptation(struct xgbe_prv_data *pdata) in xgbe_phy_rx_adaptation() argument
2113 reg = XMDIO_READ_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_RX_LSTS, in xgbe_phy_rx_adaptation()
2118 netif_dbg(pdata, link, pdata->netdev, in xgbe_phy_rx_adaptation()
2120 xgbe_phy_rrc(pdata); in xgbe_phy_rx_adaptation()
2121 if (pdata->rx_adapt_retries++ >= MAX_RX_ADAPT_RETRIES) { in xgbe_phy_rx_adaptation()
2122 pdata->rx_adapt_retries = 0; in xgbe_phy_rx_adaptation()
2129 xgbe_rx_adaptation(pdata); in xgbe_phy_rx_adaptation()
2132 static void xgbe_phy_rx_reset(struct xgbe_prv_data *pdata) in xgbe_phy_rx_reset() argument
2136 reg = XMDIO_READ_BITS(pdata, MDIO_MMD_PCS, MDIO_PCS_DIGITAL_STAT, in xgbe_phy_rx_reset()
2143 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_RX_CTRL1, in xgbe_phy_rx_reset()
2146 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_RX_CTRL1, in xgbe_phy_rx_reset()
2149 netif_err(pdata, link, pdata->netdev, "firmware mailbox reset performed\n"); in xgbe_phy_rx_reset()
2153 static void xgbe_phy_pll_ctrl(struct xgbe_prv_data *pdata, bool enable) in xgbe_phy_pll_ctrl() argument
2156 if (pdata->phy.autoneg != AUTONEG_DISABLE) in xgbe_phy_pll_ctrl()
2159 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_VEND2_PMA_MISC_CTRL0, in xgbe_phy_pll_ctrl()
2168 static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata, in xgbe_phy_perform_ratechange() argument
2175 xgbe_phy_pll_ctrl(pdata, false); in xgbe_phy_perform_ratechange()
2178 if (XP_IOREAD_BITS(pdata, XP_DRIVER_INT_RO, STATUS)) { in xgbe_phy_perform_ratechange()
2179 netif_dbg(pdata, link, pdata->netdev, in xgbe_phy_perform_ratechange()
2181 xgbe_phy_rx_reset(pdata); in xgbe_phy_perform_ratechange()
2189 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_0, s0); in xgbe_phy_perform_ratechange()
2190 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_1, 0); in xgbe_phy_perform_ratechange()
2191 XP_IOWRITE_BITS(pdata, XP_DRIVER_INT_REQ, REQUEST, 1); in xgbe_phy_perform_ratechange()
2196 if (!XP_IOREAD_BITS(pdata, XP_DRIVER_INT_RO, STATUS)) in xgbe_phy_perform_ratechange()
2202 netif_dbg(pdata, link, pdata->netdev, in xgbe_phy_perform_ratechange()
2206 xgbe_phy_rx_reset(pdata); in xgbe_phy_perform_ratechange()
2210 if (pdata->en_rx_adap && sub_cmd == XGBE_MB_SUBCMD_RX_ADAP && in xgbe_phy_perform_ratechange()
2212 netif_dbg(pdata, link, pdata->netdev, in xgbe_phy_perform_ratechange()
2214 pdata->mode_set = true; in xgbe_phy_perform_ratechange()
2215 xgbe_phy_rx_adaptation(pdata); in xgbe_phy_perform_ratechange()
2226 xgbe_phy_pll_ctrl(pdata, true); in xgbe_phy_perform_ratechange()
2229 static void xgbe_phy_rrc(struct xgbe_prv_data *pdata) in xgbe_phy_rrc() argument
2232 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_RRC, XGBE_MB_SUBCMD_NONE); in xgbe_phy_rrc()
2234 netif_dbg(pdata, link, pdata->netdev, "receiver reset complete\n"); in xgbe_phy_rrc()
2237 static void xgbe_phy_power_off(struct xgbe_prv_data *pdata) in xgbe_phy_power_off() argument
2239 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_power_off()
2242 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_POWER_OFF, XGBE_MB_SUBCMD_NONE); in xgbe_phy_power_off()
2246 netif_dbg(pdata, link, pdata->netdev, "phy powered off\n"); in xgbe_phy_power_off()
2249 static bool enable_rx_adap(struct xgbe_prv_data *pdata, enum xgbe_mode mode) in enable_rx_adap() argument
2251 struct xgbe_phy_data *phy_data = pdata->phy_data; in enable_rx_adap()
2255 ver = XGMAC_GET_BITS(pdata->hw_feat.version, MAC_VR, SNPSVER); in enable_rx_adap()
2270 pdata->en_rx_adap = 1; in enable_rx_adap()
2274 static void xgbe_phy_sfi_mode(struct xgbe_prv_data *pdata) in xgbe_phy_sfi_mode() argument
2276 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfi_mode()
2278 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_sfi_mode()
2282 pdata->en_rx_adap = 0; in xgbe_phy_sfi_mode()
2283 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_10G_SFI, XGBE_MB_SUBCMD_ACTIVE); in xgbe_phy_sfi_mode()
2285 (enable_rx_adap(pdata, XGBE_MODE_SFI))) { in xgbe_phy_sfi_mode()
2286 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_10G_SFI, in xgbe_phy_sfi_mode()
2290 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_10G_SFI, in xgbe_phy_sfi_mode()
2293 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_10G_SFI, in xgbe_phy_sfi_mode()
2296 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_10G_SFI, in xgbe_phy_sfi_mode()
2302 netif_dbg(pdata, link, pdata->netdev, "10GbE SFI mode set\n"); in xgbe_phy_sfi_mode()
2305 static void xgbe_phy_x_mode(struct xgbe_prv_data *pdata) in xgbe_phy_x_mode() argument
2307 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_x_mode()
2309 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_x_mode()
2312 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_1G, XGBE_MB_SUBCMD_1G_KX); in xgbe_phy_x_mode()
2316 netif_dbg(pdata, link, pdata->netdev, "1GbE X mode set\n"); in xgbe_phy_x_mode()
2319 static void xgbe_phy_sgmii_1000_mode(struct xgbe_prv_data *pdata) in xgbe_phy_sgmii_1000_mode() argument
2321 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sgmii_1000_mode()
2323 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_sgmii_1000_mode()
2326 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_1G, XGBE_MB_SUBCMD_1G_SGMII); in xgbe_phy_sgmii_1000_mode()
2330 netif_dbg(pdata, link, pdata->netdev, "1GbE SGMII mode set\n"); in xgbe_phy_sgmii_1000_mode()
2333 static void xgbe_phy_sgmii_100_mode(struct xgbe_prv_data *pdata) in xgbe_phy_sgmii_100_mode() argument
2335 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sgmii_100_mode()
2337 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_sgmii_100_mode()
2340 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_1G, XGBE_MB_SUBCMD_100MBITS); in xgbe_phy_sgmii_100_mode()
2344 netif_dbg(pdata, link, pdata->netdev, "100MbE SGMII mode set\n"); in xgbe_phy_sgmii_100_mode()
2347 static void xgbe_phy_sgmii_10_mode(struct xgbe_prv_data *pdata) in xgbe_phy_sgmii_10_mode() argument
2349 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sgmii_10_mode()
2351 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_sgmii_10_mode()
2354 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_1G, XGBE_MB_SUBCMD_10MBITS); in xgbe_phy_sgmii_10_mode()
2358 netif_dbg(pdata, link, pdata->netdev, "10MbE SGMII mode set\n"); in xgbe_phy_sgmii_10_mode()
2361 static void xgbe_phy_kr_mode(struct xgbe_prv_data *pdata) in xgbe_phy_kr_mode() argument
2363 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_kr_mode()
2365 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_kr_mode()
2368 if (enable_rx_adap(pdata, XGBE_MODE_KR)) in xgbe_phy_kr_mode()
2369 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_10G_KR, in xgbe_phy_kr_mode()
2372 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_10G_KR, in xgbe_phy_kr_mode()
2377 netif_dbg(pdata, link, pdata->netdev, "10GbE KR mode set\n"); in xgbe_phy_kr_mode()
2380 static void xgbe_phy_kx_2500_mode(struct xgbe_prv_data *pdata) in xgbe_phy_kx_2500_mode() argument
2382 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_kx_2500_mode()
2384 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_kx_2500_mode()
2387 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_2_5G, XGBE_MB_SUBCMD_NONE); in xgbe_phy_kx_2500_mode()
2391 netif_dbg(pdata, link, pdata->netdev, "2.5GbE KX mode set\n"); in xgbe_phy_kx_2500_mode()
2394 static void xgbe_phy_kx_1000_mode(struct xgbe_prv_data *pdata) in xgbe_phy_kx_1000_mode() argument
2396 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_kx_1000_mode()
2398 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_kx_1000_mode()
2401 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_1G, XGBE_MB_SUBCMD_1G_KX); in xgbe_phy_kx_1000_mode()
2405 netif_dbg(pdata, link, pdata->netdev, "1GbE KX mode set\n"); in xgbe_phy_kx_1000_mode()
2408 static enum xgbe_mode xgbe_phy_cur_mode(struct xgbe_prv_data *pdata) in xgbe_phy_cur_mode() argument
2410 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_cur_mode()
2415 static enum xgbe_mode xgbe_phy_switch_baset_mode(struct xgbe_prv_data *pdata) in xgbe_phy_switch_baset_mode() argument
2417 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_switch_baset_mode()
2421 return xgbe_phy_cur_mode(pdata); in xgbe_phy_switch_baset_mode()
2423 switch (xgbe_phy_cur_mode(pdata)) { in xgbe_phy_switch_baset_mode()
2436 static enum xgbe_mode xgbe_phy_switch_bp_2500_mode(struct xgbe_prv_data *pdata) in xgbe_phy_switch_bp_2500_mode() argument
2441 static enum xgbe_mode xgbe_phy_switch_bp_mode(struct xgbe_prv_data *pdata) in xgbe_phy_switch_bp_mode() argument
2444 switch (xgbe_phy_cur_mode(pdata)) { in xgbe_phy_switch_bp_mode()
2453 static enum xgbe_mode xgbe_phy_switch_mode(struct xgbe_prv_data *pdata) in xgbe_phy_switch_mode() argument
2455 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_switch_mode()
2460 return xgbe_phy_switch_bp_mode(pdata); in xgbe_phy_switch_mode()
2462 return xgbe_phy_switch_bp_2500_mode(pdata); in xgbe_phy_switch_mode()
2466 return xgbe_phy_switch_baset_mode(pdata); in xgbe_phy_switch_mode()
2471 return xgbe_phy_cur_mode(pdata); in xgbe_phy_switch_mode()
2552 static enum xgbe_mode xgbe_phy_get_mode(struct xgbe_prv_data *pdata, in xgbe_phy_get_mode() argument
2555 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_get_mode()
2577 static void xgbe_phy_set_mode(struct xgbe_prv_data *pdata, enum xgbe_mode mode) in xgbe_phy_set_mode() argument
2581 xgbe_phy_kx_1000_mode(pdata); in xgbe_phy_set_mode()
2584 xgbe_phy_kx_2500_mode(pdata); in xgbe_phy_set_mode()
2587 xgbe_phy_kr_mode(pdata); in xgbe_phy_set_mode()
2590 xgbe_phy_sgmii_10_mode(pdata); in xgbe_phy_set_mode()
2593 xgbe_phy_sgmii_100_mode(pdata); in xgbe_phy_set_mode()
2596 xgbe_phy_sgmii_1000_mode(pdata); in xgbe_phy_set_mode()
2599 xgbe_phy_x_mode(pdata); in xgbe_phy_set_mode()
2602 xgbe_phy_sfi_mode(pdata); in xgbe_phy_set_mode()
2609 static bool xgbe_phy_check_mode(struct xgbe_prv_data *pdata, in xgbe_phy_check_mode() argument
2612 if (pdata->phy.autoneg == AUTONEG_ENABLE) { in xgbe_phy_check_mode()
2617 cur_mode = xgbe_phy_get_mode(pdata, pdata->phy.speed); in xgbe_phy_check_mode()
2625 static bool xgbe_phy_use_basex_mode(struct xgbe_prv_data *pdata, in xgbe_phy_use_basex_mode() argument
2628 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_use_basex_mode()
2632 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_basex_mode()
2635 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_basex_mode()
2642 static bool xgbe_phy_use_baset_mode(struct xgbe_prv_data *pdata, in xgbe_phy_use_baset_mode() argument
2645 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_use_baset_mode()
2649 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_baset_mode()
2652 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_baset_mode()
2655 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_baset_mode()
2658 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_baset_mode()
2661 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_baset_mode()
2668 static bool xgbe_phy_use_sfp_mode(struct xgbe_prv_data *pdata, in xgbe_phy_use_sfp_mode() argument
2671 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_use_sfp_mode()
2672 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_use_sfp_mode()
2678 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_sfp_mode()
2683 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_sfp_mode()
2688 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_sfp_mode()
2693 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_sfp_mode()
2698 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_sfp_mode()
2709 static bool xgbe_phy_use_bp_2500_mode(struct xgbe_prv_data *pdata, in xgbe_phy_use_bp_2500_mode() argument
2712 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_use_bp_2500_mode()
2716 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_bp_2500_mode()
2723 static bool xgbe_phy_use_bp_mode(struct xgbe_prv_data *pdata, in xgbe_phy_use_bp_mode() argument
2726 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_use_bp_mode()
2730 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_bp_mode()
2733 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_bp_mode()
2740 static bool xgbe_phy_use_mode(struct xgbe_prv_data *pdata, enum xgbe_mode mode) in xgbe_phy_use_mode() argument
2742 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_use_mode()
2747 return xgbe_phy_use_bp_mode(pdata, mode); in xgbe_phy_use_mode()
2749 return xgbe_phy_use_bp_2500_mode(pdata, mode); in xgbe_phy_use_mode()
2753 return xgbe_phy_use_baset_mode(pdata, mode); in xgbe_phy_use_mode()
2756 return xgbe_phy_use_basex_mode(pdata, mode); in xgbe_phy_use_mode()
2758 return xgbe_phy_use_sfp_mode(pdata, mode); in xgbe_phy_use_mode()
2777 static bool xgbe_phy_valid_speed_baset_mode(struct xgbe_prv_data *pdata, in xgbe_phy_valid_speed_baset_mode() argument
2780 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_valid_speed_baset_mode()
2786 ver = XGMAC_GET_BITS(pdata->hw_feat.version, MAC_VR, SNPSVER); in xgbe_phy_valid_speed_baset_mode()
2801 static bool xgbe_phy_valid_speed_sfp_mode(struct xgbe_prv_data *pdata, in xgbe_phy_valid_speed_sfp_mode() argument
2804 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_valid_speed_sfp_mode()
2810 ver = XGMAC_GET_BITS(pdata->hw_feat.version, MAC_VR, SNPSVER); in xgbe_phy_valid_speed_sfp_mode()
2846 static bool xgbe_phy_valid_speed(struct xgbe_prv_data *pdata, int speed) in xgbe_phy_valid_speed() argument
2848 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_valid_speed()
2859 return xgbe_phy_valid_speed_baset_mode(pdata, speed); in xgbe_phy_valid_speed()
2864 return xgbe_phy_valid_speed_sfp_mode(pdata, speed); in xgbe_phy_valid_speed()
2870 static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart) in xgbe_phy_link_status() argument
2872 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_link_status()
2880 xgbe_phy_sfp_detect(pdata); in xgbe_phy_link_status()
2888 if (pdata->en_rx_adap) in xgbe_phy_link_status()
2889 pdata->rx_adapt_done = false; in xgbe_phy_link_status()
2900 if ((pdata->phy.autoneg == AUTONEG_ENABLE) && in xgbe_phy_link_status()
2911 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); in xgbe_phy_link_status()
2912 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); in xgbe_phy_link_status()
2914 if (pdata->en_rx_adap) { in xgbe_phy_link_status()
2918 if ((reg & MDIO_STAT1_LSTATUS) && pdata->rx_adapt_done) in xgbe_phy_link_status()
2924 if (pdata->mode_set) { in xgbe_phy_link_status()
2925 xgbe_phy_rx_adaptation(pdata); in xgbe_phy_link_status()
2927 pdata->rx_adapt_done = false; in xgbe_phy_link_status()
2928 xgbe_phy_set_mode(pdata, phy_data->cur_mode); in xgbe_phy_link_status()
2932 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); in xgbe_phy_link_status()
2933 if ((reg & MDIO_STAT1_LSTATUS) && pdata->rx_adapt_done) in xgbe_phy_link_status()
2938 if (pdata->phy.autoneg == AUTONEG_ENABLE && in xgbe_phy_link_status()
2940 if (!test_bit(XGBE_LINK_INIT, &pdata->dev_state)) { in xgbe_phy_link_status()
2941 netif_carrier_off(pdata->netdev); in xgbe_phy_link_status()
2947 if (pdata->vdata->enable_rrc && phy_data->rrc_count++ > XGBE_RRC_FREQUENCY) { in xgbe_phy_link_status()
2949 xgbe_phy_rrc(pdata); in xgbe_phy_link_status()
2955 static void xgbe_phy_sfp_gpio_setup(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_gpio_setup() argument
2957 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_gpio_setup()
2960 XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2963 phy_data->sfp_gpio_mask = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2966 phy_data->sfp_gpio_rx_los = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2968 phy_data->sfp_gpio_tx_fault = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2970 phy_data->sfp_gpio_mod_absent = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2972 phy_data->sfp_gpio_rate_select = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2975 if (netif_msg_probe(pdata)) { in xgbe_phy_sfp_gpio_setup()
2976 dev_dbg(pdata->dev, "SFP: gpio_address=%#x\n", in xgbe_phy_sfp_gpio_setup()
2978 dev_dbg(pdata->dev, "SFP: gpio_mask=%#x\n", in xgbe_phy_sfp_gpio_setup()
2980 dev_dbg(pdata->dev, "SFP: gpio_rx_los=%u\n", in xgbe_phy_sfp_gpio_setup()
2982 dev_dbg(pdata->dev, "SFP: gpio_tx_fault=%u\n", in xgbe_phy_sfp_gpio_setup()
2984 dev_dbg(pdata->dev, "SFP: gpio_mod_absent=%u\n", in xgbe_phy_sfp_gpio_setup()
2986 dev_dbg(pdata->dev, "SFP: gpio_rate_select=%u\n", in xgbe_phy_sfp_gpio_setup()
2991 static void xgbe_phy_sfp_comm_setup(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_comm_setup() argument
2993 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_comm_setup()
2996 mux_addr_hi = XP_GET_BITS(pdata->pp4, XP_PROP_4, MUX_ADDR_HI); in xgbe_phy_sfp_comm_setup()
2997 mux_addr_lo = XP_GET_BITS(pdata->pp4, XP_PROP_4, MUX_ADDR_LO); in xgbe_phy_sfp_comm_setup()
3003 phy_data->sfp_mux_channel = XP_GET_BITS(pdata->pp4, XP_PROP_4, in xgbe_phy_sfp_comm_setup()
3006 if (netif_msg_probe(pdata)) { in xgbe_phy_sfp_comm_setup()
3007 dev_dbg(pdata->dev, "SFP: mux_address=%#x\n", in xgbe_phy_sfp_comm_setup()
3009 dev_dbg(pdata->dev, "SFP: mux_channel=%u\n", in xgbe_phy_sfp_comm_setup()
3014 static void xgbe_phy_sfp_setup(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_setup() argument
3016 xgbe_phy_sfp_comm_setup(pdata); in xgbe_phy_sfp_setup()
3017 xgbe_phy_sfp_gpio_setup(pdata); in xgbe_phy_sfp_setup()
3020 static int xgbe_phy_int_mdio_reset(struct xgbe_prv_data *pdata) in xgbe_phy_int_mdio_reset() argument
3022 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_int_mdio_reset()
3025 ret = pdata->hw_if.set_gpio(pdata, phy_data->mdio_reset_gpio); in xgbe_phy_int_mdio_reset()
3029 ret = pdata->hw_if.clr_gpio(pdata, phy_data->mdio_reset_gpio); in xgbe_phy_int_mdio_reset()
3034 static int xgbe_phy_i2c_mdio_reset(struct xgbe_prv_data *pdata) in xgbe_phy_i2c_mdio_reset() argument
3036 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_i2c_mdio_reset()
3042 ret = xgbe_phy_i2c_read(pdata, phy_data->mdio_reset_addr, in xgbe_phy_i2c_mdio_reset()
3060 ret = xgbe_phy_i2c_write(pdata, phy_data->mdio_reset_addr, in xgbe_phy_i2c_mdio_reset()
3072 ret = xgbe_phy_i2c_write(pdata, phy_data->mdio_reset_addr, in xgbe_phy_i2c_mdio_reset()
3078 static int xgbe_phy_mdio_reset(struct xgbe_prv_data *pdata) in xgbe_phy_mdio_reset() argument
3080 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mdio_reset()
3086 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_mdio_reset()
3091 ret = xgbe_phy_i2c_mdio_reset(pdata); in xgbe_phy_mdio_reset()
3093 ret = xgbe_phy_int_mdio_reset(pdata); in xgbe_phy_mdio_reset()
3095 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_mdio_reset()
3124 static int xgbe_phy_mdio_reset_setup(struct xgbe_prv_data *pdata) in xgbe_phy_mdio_reset_setup() argument
3126 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mdio_reset_setup()
3131 phy_data->mdio_reset = XP_GET_BITS(pdata->pp3, XP_PROP_3, MDIO_RESET); in xgbe_phy_mdio_reset_setup()
3138 dev_err(pdata->dev, "unsupported MDIO reset (%#x)\n", in xgbe_phy_mdio_reset_setup()
3145 XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_mdio_reset_setup()
3147 phy_data->mdio_reset_gpio = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_mdio_reset_setup()
3150 phy_data->mdio_reset_gpio = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_mdio_reset_setup()
3157 static bool xgbe_phy_port_mode_mismatch(struct xgbe_prv_data *pdata) in xgbe_phy_port_mode_mismatch() argument
3159 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_port_mode_mismatch()
3163 ver = XGMAC_GET_BITS(pdata->hw_feat.version, MAC_VR, SNPSVER); in xgbe_phy_port_mode_mismatch()
3221 static bool xgbe_phy_conn_type_mismatch(struct xgbe_prv_data *pdata) in xgbe_phy_conn_type_mismatch() argument
3223 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_conn_type_mismatch()
3251 static bool xgbe_phy_port_enabled(struct xgbe_prv_data *pdata) in xgbe_phy_port_enabled() argument
3253 if (!XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_SPEEDS)) in xgbe_phy_port_enabled()
3255 if (!XP_GET_BITS(pdata->pp0, XP_PROP_0, CONN_TYPE)) in xgbe_phy_port_enabled()
3261 static void xgbe_phy_cdr_track(struct xgbe_prv_data *pdata) in xgbe_phy_cdr_track() argument
3263 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_cdr_track()
3265 if (!pdata->debugfs_an_cdr_workaround) in xgbe_phy_cdr_track()
3274 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_VEND2_PMA_CDR_CONTROL, in xgbe_phy_cdr_track()
3281 static void xgbe_phy_cdr_notrack(struct xgbe_prv_data *pdata) in xgbe_phy_cdr_notrack() argument
3283 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_cdr_notrack()
3285 if (!pdata->debugfs_an_cdr_workaround) in xgbe_phy_cdr_notrack()
3291 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_VEND2_PMA_CDR_CONTROL, in xgbe_phy_cdr_notrack()
3295 xgbe_phy_rrc(pdata); in xgbe_phy_cdr_notrack()
3300 static void xgbe_phy_kr_training_post(struct xgbe_prv_data *pdata) in xgbe_phy_kr_training_post() argument
3302 if (!pdata->debugfs_an_cdr_track_early) in xgbe_phy_kr_training_post()
3303 xgbe_phy_cdr_track(pdata); in xgbe_phy_kr_training_post()
3306 static void xgbe_phy_kr_training_pre(struct xgbe_prv_data *pdata) in xgbe_phy_kr_training_pre() argument
3308 if (pdata->debugfs_an_cdr_track_early) in xgbe_phy_kr_training_pre()
3309 xgbe_phy_cdr_track(pdata); in xgbe_phy_kr_training_pre()
3312 static void xgbe_phy_an_post(struct xgbe_prv_data *pdata) in xgbe_phy_an_post() argument
3314 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_an_post()
3316 switch (pdata->an_mode) { in xgbe_phy_an_post()
3322 xgbe_phy_cdr_track(pdata); in xgbe_phy_an_post()
3324 switch (pdata->an_result) { in xgbe_phy_an_post()
3341 static void xgbe_phy_an_pre(struct xgbe_prv_data *pdata) in xgbe_phy_an_pre() argument
3343 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_an_pre()
3345 switch (pdata->an_mode) { in xgbe_phy_an_pre()
3351 xgbe_phy_cdr_notrack(pdata); in xgbe_phy_an_pre()
3358 static void xgbe_phy_stop(struct xgbe_prv_data *pdata) in xgbe_phy_stop() argument
3360 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_stop()
3363 xgbe_phy_free_phy_device(pdata); in xgbe_phy_stop()
3367 xgbe_phy_sfp_mod_absent(pdata); in xgbe_phy_stop()
3370 xgbe_phy_cdr_track(pdata); in xgbe_phy_stop()
3373 xgbe_phy_power_off(pdata); in xgbe_phy_stop()
3376 pdata->i2c_if.i2c_stop(pdata); in xgbe_phy_stop()
3379 static int xgbe_phy_start(struct xgbe_prv_data *pdata) in xgbe_phy_start() argument
3381 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_start()
3385 ret = pdata->i2c_if.i2c_start(pdata); in xgbe_phy_start()
3391 ret = pdata->hw_if.set_ext_mii_mode(pdata, phy_data->redrv_addr, in xgbe_phy_start()
3394 netdev_err(pdata->netdev, in xgbe_phy_start()
3402 xgbe_phy_set_mode(pdata, phy_data->start_mode); in xgbe_phy_start()
3405 xgbe_phy_cdr_track(pdata); in xgbe_phy_start()
3410 xgbe_phy_sfp_detect(pdata); in xgbe_phy_start()
3417 ret = xgbe_phy_find_phy_device(pdata); in xgbe_phy_start()
3424 pdata->i2c_if.i2c_stop(pdata); in xgbe_phy_start()
3429 static int xgbe_phy_reset(struct xgbe_prv_data *pdata) in xgbe_phy_reset() argument
3431 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_reset()
3437 xgbe_phy_power_off(pdata); in xgbe_phy_reset()
3438 xgbe_phy_set_mode(pdata, cur_mode); in xgbe_phy_reset()
3444 ret = xgbe_phy_mdio_reset(pdata); in xgbe_phy_reset()
3451 static void xgbe_phy_exit(struct xgbe_prv_data *pdata) in xgbe_phy_exit() argument
3453 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_exit()
3459 static int xgbe_phy_init(struct xgbe_prv_data *pdata) in xgbe_phy_init() argument
3461 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_init()
3467 if (!xgbe_phy_port_enabled(pdata)) { in xgbe_phy_init()
3468 dev_info(pdata->dev, "device is not enabled\n"); in xgbe_phy_init()
3473 ret = pdata->i2c_if.i2c_init(pdata); in xgbe_phy_init()
3477 phy_data = devm_kzalloc(pdata->dev, sizeof(*phy_data), GFP_KERNEL); in xgbe_phy_init()
3480 pdata->phy_data = phy_data; in xgbe_phy_init()
3482 phy_data->port_mode = XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_MODE); in xgbe_phy_init()
3483 phy_data->port_id = XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_ID); in xgbe_phy_init()
3484 phy_data->port_speeds = XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_SPEEDS); in xgbe_phy_init()
3485 phy_data->conn_type = XP_GET_BITS(pdata->pp0, XP_PROP_0, CONN_TYPE); in xgbe_phy_init()
3486 phy_data->mdio_addr = XP_GET_BITS(pdata->pp0, XP_PROP_0, MDIO_ADDR); in xgbe_phy_init()
3487 if (netif_msg_probe(pdata)) { in xgbe_phy_init()
3488 dev_dbg(pdata->dev, "port mode=%u\n", phy_data->port_mode); in xgbe_phy_init()
3489 dev_dbg(pdata->dev, "port id=%u\n", phy_data->port_id); in xgbe_phy_init()
3490 dev_dbg(pdata->dev, "port speeds=%#x\n", phy_data->port_speeds); in xgbe_phy_init()
3491 dev_dbg(pdata->dev, "conn type=%u\n", phy_data->conn_type); in xgbe_phy_init()
3492 dev_dbg(pdata->dev, "mdio addr=%u\n", phy_data->mdio_addr); in xgbe_phy_init()
3495 phy_data->redrv = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_PRESENT); in xgbe_phy_init()
3496 phy_data->redrv_if = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_IF); in xgbe_phy_init()
3497 phy_data->redrv_addr = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_ADDR); in xgbe_phy_init()
3498 phy_data->redrv_lane = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_LANE); in xgbe_phy_init()
3499 phy_data->redrv_model = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_MODEL); in xgbe_phy_init()
3500 if (phy_data->redrv && netif_msg_probe(pdata)) { in xgbe_phy_init()
3501 dev_dbg(pdata->dev, "redrv present\n"); in xgbe_phy_init()
3502 dev_dbg(pdata->dev, "redrv i/f=%u\n", phy_data->redrv_if); in xgbe_phy_init()
3503 dev_dbg(pdata->dev, "redrv addr=%#x\n", phy_data->redrv_addr); in xgbe_phy_init()
3504 dev_dbg(pdata->dev, "redrv lane=%u\n", phy_data->redrv_lane); in xgbe_phy_init()
3505 dev_dbg(pdata->dev, "redrv model=%u\n", phy_data->redrv_model); in xgbe_phy_init()
3509 if (xgbe_phy_conn_type_mismatch(pdata)) { in xgbe_phy_init()
3510 dev_err(pdata->dev, "phy mode/connection mismatch (%#x/%#x)\n", in xgbe_phy_init()
3516 if (xgbe_phy_port_mode_mismatch(pdata)) { in xgbe_phy_init()
3517 dev_err(pdata->dev, "phy mode/speed mismatch (%#x/%#x)\n", in xgbe_phy_init()
3523 ret = xgbe_phy_mdio_reset_setup(pdata); in xgbe_phy_init()
3529 dev_err(pdata->dev, "phy re-driver settings error\n"); in xgbe_phy_init()
3532 pdata->kr_redrv = phy_data->redrv; in xgbe_phy_init()
3555 if (pdata->fec_ability & MDIO_PMA_10GBR_FECABLE_ABLE) in xgbe_phy_init()
3672 if (pdata->fec_ability & MDIO_PMA_10GBR_FECABLE_ABLE) in xgbe_phy_init()
3697 xgbe_phy_sfp_setup(pdata); in xgbe_phy_init()
3703 if (netif_msg_probe(pdata)) in xgbe_phy_init()
3704 dev_dbg(pdata->dev, "phy supported=0x%*pb\n", in xgbe_phy_init()
3710 ret = pdata->hw_if.set_ext_mii_mode(pdata, phy_data->mdio_addr, in xgbe_phy_init()
3713 dev_err(pdata->dev, in xgbe_phy_init()
3721 ret = pdata->hw_if.set_ext_mii_mode(pdata, phy_data->redrv_addr, in xgbe_phy_init()
3724 dev_err(pdata->dev, in xgbe_phy_init()
3734 mii = devm_mdiobus_alloc(pdata->dev); in xgbe_phy_init()
3736 dev_err(pdata->dev, "mdiobus_alloc failed\n"); in xgbe_phy_init()
3740 mii->priv = pdata; in xgbe_phy_init()
3746 mii->parent = pdata->dev; in xgbe_phy_init()
3748 snprintf(mii->id, sizeof(mii->id), "%s", dev_name(pdata->dev)); in xgbe_phy_init()
3751 dev_err(pdata->dev, "mdiobus_register failed\n"); in xgbe_phy_init()