Lines Matching refs:pdata

389 static enum xgbe_an_mode xgbe_phy_an_mode(struct xgbe_prv_data *pdata);
391 static int xgbe_phy_i2c_xfer(struct xgbe_prv_data *pdata, in xgbe_phy_i2c_xfer() argument
394 return pdata->i2c_if.i2c_xfer(pdata, i2c_op); in xgbe_phy_i2c_xfer()
397 static int xgbe_phy_redrv_write(struct xgbe_prv_data *pdata, unsigned int reg, in xgbe_phy_redrv_write() argument
400 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_redrv_write()
428 ret = xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_redrv_write()
442 ret = xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_redrv_write()
451 netif_dbg(pdata, drv, pdata->netdev, in xgbe_phy_redrv_write()
459 static int xgbe_phy_i2c_write(struct xgbe_prv_data *pdata, unsigned int target, in xgbe_phy_i2c_write() argument
472 ret = xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_i2c_write()
479 static int xgbe_phy_i2c_read(struct xgbe_prv_data *pdata, unsigned int target, in xgbe_phy_i2c_read() argument
493 ret = xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_i2c_read()
508 ret = xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_i2c_read()
515 static int xgbe_phy_sfp_put_mux(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_put_mux() argument
517 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_put_mux()
531 return xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_sfp_put_mux()
534 static int xgbe_phy_sfp_get_mux(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_get_mux() argument
536 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_get_mux()
550 return xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_sfp_get_mux()
553 static void xgbe_phy_put_comm_ownership(struct xgbe_prv_data *pdata) in xgbe_phy_put_comm_ownership() argument
558 static int xgbe_phy_get_comm_ownership(struct xgbe_prv_data *pdata) in xgbe_phy_get_comm_ownership() argument
560 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_get_comm_ownership()
571 XP_IOWRITE(pdata, XP_I2C_MUTEX, XGBE_MUTEX_RELEASE); in xgbe_phy_get_comm_ownership()
572 XP_IOWRITE(pdata, XP_MDIO_MUTEX, XGBE_MUTEX_RELEASE); in xgbe_phy_get_comm_ownership()
582 if (XP_IOREAD(pdata, XP_I2C_MUTEX) || in xgbe_phy_get_comm_ownership()
583 XP_IOREAD(pdata, XP_MDIO_MUTEX)) { in xgbe_phy_get_comm_ownership()
589 XP_IOWRITE(pdata, XP_I2C_MUTEX, mutex_id); in xgbe_phy_get_comm_ownership()
590 XP_IOWRITE(pdata, XP_MDIO_MUTEX, mutex_id); in xgbe_phy_get_comm_ownership()
597 netdev_err(pdata->netdev, "unable to obtain hardware mutexes\n"); in xgbe_phy_get_comm_ownership()
602 static int xgbe_phy_mdio_mii_write(struct xgbe_prv_data *pdata, int addr, in xgbe_phy_mdio_mii_write() argument
605 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mdio_mii_write()
615 return pdata->hw_if.write_ext_mii_regs(pdata, addr, reg, val); in xgbe_phy_mdio_mii_write()
618 static int xgbe_phy_i2c_mii_write(struct xgbe_prv_data *pdata, int reg, u16 val) in xgbe_phy_i2c_mii_write() argument
624 ret = xgbe_phy_sfp_get_mux(pdata); in xgbe_phy_i2c_mii_write()
632 ret = xgbe_phy_i2c_write(pdata, XGBE_SFP_PHY_ADDRESS, in xgbe_phy_i2c_mii_write()
635 xgbe_phy_sfp_put_mux(pdata); in xgbe_phy_i2c_mii_write()
642 struct xgbe_prv_data *pdata = mii->priv; in xgbe_phy_mii_write() local
643 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mii_write()
646 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_mii_write()
651 ret = xgbe_phy_i2c_mii_write(pdata, reg, val); in xgbe_phy_mii_write()
653 ret = xgbe_phy_mdio_mii_write(pdata, addr, reg, val); in xgbe_phy_mii_write()
657 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_mii_write()
662 static int xgbe_phy_mdio_mii_read(struct xgbe_prv_data *pdata, int addr, in xgbe_phy_mdio_mii_read() argument
665 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mdio_mii_read()
675 return pdata->hw_if.read_ext_mii_regs(pdata, addr, reg); in xgbe_phy_mdio_mii_read()
678 static int xgbe_phy_i2c_mii_read(struct xgbe_prv_data *pdata, int reg) in xgbe_phy_i2c_mii_read() argument
684 ret = xgbe_phy_sfp_get_mux(pdata); in xgbe_phy_i2c_mii_read()
689 ret = xgbe_phy_i2c_read(pdata, XGBE_SFP_PHY_ADDRESS, in xgbe_phy_i2c_mii_read()
695 xgbe_phy_sfp_put_mux(pdata); in xgbe_phy_i2c_mii_read()
702 struct xgbe_prv_data *pdata = mii->priv; in xgbe_phy_mii_read() local
703 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mii_read()
706 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_mii_read()
711 ret = xgbe_phy_i2c_mii_read(pdata, reg); in xgbe_phy_mii_read()
713 ret = xgbe_phy_mdio_mii_read(pdata, addr, reg); in xgbe_phy_mii_read()
717 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_mii_read()
722 static void xgbe_phy_sfp_phy_settings(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_phy_settings() argument
724 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_sfp_phy_settings()
725 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_phy_settings()
733 pdata->phy.speed = SPEED_UNKNOWN; in xgbe_phy_sfp_phy_settings()
734 pdata->phy.duplex = DUPLEX_UNKNOWN; in xgbe_phy_sfp_phy_settings()
735 pdata->phy.autoneg = AUTONEG_ENABLE; in xgbe_phy_sfp_phy_settings()
736 pdata->phy.pause_autoneg = AUTONEG_ENABLE; in xgbe_phy_sfp_phy_settings()
754 pdata->phy.speed = SPEED_UNKNOWN; in xgbe_phy_sfp_phy_settings()
755 pdata->phy.duplex = DUPLEX_UNKNOWN; in xgbe_phy_sfp_phy_settings()
756 pdata->phy.autoneg = AUTONEG_ENABLE; in xgbe_phy_sfp_phy_settings()
757 pdata->phy.pause_autoneg = AUTONEG_ENABLE; in xgbe_phy_sfp_phy_settings()
776 pdata->phy.speed = SPEED_10000; in xgbe_phy_sfp_phy_settings()
777 pdata->phy.duplex = DUPLEX_FULL; in xgbe_phy_sfp_phy_settings()
778 pdata->phy.autoneg = AUTONEG_DISABLE; in xgbe_phy_sfp_phy_settings()
779 pdata->phy.pause_autoneg = AUTONEG_DISABLE; in xgbe_phy_sfp_phy_settings()
803 pdata->phy.speed = SPEED_UNKNOWN; in xgbe_phy_sfp_phy_settings()
804 pdata->phy.duplex = DUPLEX_UNKNOWN; in xgbe_phy_sfp_phy_settings()
805 pdata->phy.autoneg = AUTONEG_DISABLE; in xgbe_phy_sfp_phy_settings()
806 pdata->phy.pause_autoneg = AUTONEG_DISABLE; in xgbe_phy_sfp_phy_settings()
845 static void xgbe_phy_free_phy_device(struct xgbe_prv_data *pdata) in xgbe_phy_free_phy_device() argument
847 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_free_phy_device()
857 static bool xgbe_phy_finisar_phy_quirks(struct xgbe_prv_data *pdata) in xgbe_phy_finisar_phy_quirks() argument
860 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_finisar_phy_quirks()
892 netif_dbg(pdata, drv, pdata->netdev, in xgbe_phy_finisar_phy_quirks()
898 static bool xgbe_phy_belfuse_phy_quirks(struct xgbe_prv_data *pdata) in xgbe_phy_belfuse_phy_quirks() argument
901 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_belfuse_phy_quirks()
914 pdata->an_again = 1; in xgbe_phy_belfuse_phy_quirks()
973 netif_dbg(pdata, drv, pdata->netdev, in xgbe_phy_belfuse_phy_quirks()
979 static void xgbe_phy_external_phy_quirks(struct xgbe_prv_data *pdata) in xgbe_phy_external_phy_quirks() argument
981 if (xgbe_phy_belfuse_phy_quirks(pdata)) in xgbe_phy_external_phy_quirks()
984 if (xgbe_phy_finisar_phy_quirks(pdata)) in xgbe_phy_external_phy_quirks()
988 static int xgbe_phy_find_phy_device(struct xgbe_prv_data *pdata) in xgbe_phy_find_phy_device() argument
990 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_find_phy_device()
991 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_find_phy_device()
1000 pdata->an_again = 0; in xgbe_phy_find_phy_device()
1012 ret = pdata->hw_if.set_ext_mii_mode(pdata, phy_data->mdio_addr, in xgbe_phy_find_phy_device()
1015 netdev_err(pdata->netdev, in xgbe_phy_find_phy_device()
1025 netdev_err(pdata->netdev, "get_phy_device failed\n"); in xgbe_phy_find_phy_device()
1028 netif_dbg(pdata, drv, pdata->netdev, "external PHY id is %#010x\n", in xgbe_phy_find_phy_device()
1035 netdev_err(pdata->netdev, "phy_device_register failed\n"); in xgbe_phy_find_phy_device()
1040 ret = phy_attach_direct(pdata->netdev, phydev, phydev->dev_flags, in xgbe_phy_find_phy_device()
1043 netdev_err(pdata->netdev, "phy_attach_direct failed\n"); in xgbe_phy_find_phy_device()
1050 xgbe_phy_external_phy_quirks(pdata); in xgbe_phy_find_phy_device()
1060 static void xgbe_phy_sfp_external_phy(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_external_phy() argument
1062 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_external_phy()
1074 ret = xgbe_phy_i2c_mii_read(pdata, MII_BMCR); in xgbe_phy_sfp_external_phy()
1125 static void xgbe_phy_sfp_parse_eeprom(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_parse_eeprom() argument
1127 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_parse_eeprom()
1195 static void xgbe_phy_sfp_eeprom_info(struct xgbe_prv_data *pdata, in xgbe_phy_sfp_eeprom_info() argument
1201 netif_dbg(pdata, drv, pdata->netdev, "SFP detected:\n"); in xgbe_phy_sfp_eeprom_info()
1205 netif_dbg(pdata, drv, pdata->netdev, " vendor: %s\n", in xgbe_phy_sfp_eeprom_info()
1211 netif_dbg(pdata, drv, pdata->netdev, " part number: %s\n", in xgbe_phy_sfp_eeprom_info()
1217 netif_dbg(pdata, drv, pdata->netdev, " revision level: %s\n", in xgbe_phy_sfp_eeprom_info()
1223 netif_dbg(pdata, drv, pdata->netdev, " serial number: %s\n", in xgbe_phy_sfp_eeprom_info()
1237 static int xgbe_phy_sfp_read_eeprom(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_read_eeprom() argument
1239 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_read_eeprom()
1244 ret = xgbe_phy_sfp_get_mux(pdata); in xgbe_phy_sfp_read_eeprom()
1246 dev_err_once(pdata->dev, "%s: I2C error setting SFP MUX\n", in xgbe_phy_sfp_read_eeprom()
1247 netdev_name(pdata->netdev)); in xgbe_phy_sfp_read_eeprom()
1253 ret = xgbe_phy_i2c_read(pdata, XGBE_SFP_SERIAL_ID_ADDRESS, in xgbe_phy_sfp_read_eeprom()
1257 dev_err_once(pdata->dev, "%s: I2C error reading SFP EEPROM\n", in xgbe_phy_sfp_read_eeprom()
1258 netdev_name(pdata->netdev)); in xgbe_phy_sfp_read_eeprom()
1281 if (netif_msg_drv(pdata)) in xgbe_phy_sfp_read_eeprom()
1282 xgbe_phy_sfp_eeprom_info(pdata, &sfp_eeprom); in xgbe_phy_sfp_read_eeprom()
1286 xgbe_phy_free_phy_device(pdata); in xgbe_phy_sfp_read_eeprom()
1292 xgbe_phy_sfp_put_mux(pdata); in xgbe_phy_sfp_read_eeprom()
1297 static void xgbe_phy_sfp_signals(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_signals() argument
1299 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_signals()
1305 ret = xgbe_phy_i2c_read(pdata, phy_data->sfp_gpio_address, in xgbe_phy_sfp_signals()
1309 dev_err_once(pdata->dev, "%s: I2C error reading SFP GPIOs\n", in xgbe_phy_sfp_signals()
1310 netdev_name(pdata->netdev)); in xgbe_phy_sfp_signals()
1319 static void xgbe_phy_sfp_mod_absent(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_mod_absent() argument
1321 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_mod_absent()
1323 xgbe_phy_free_phy_device(pdata); in xgbe_phy_sfp_mod_absent()
1340 static void xgbe_phy_sfp_detect(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_detect() argument
1342 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_detect()
1348 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_sfp_detect()
1353 xgbe_phy_sfp_signals(pdata); in xgbe_phy_sfp_detect()
1355 xgbe_phy_sfp_mod_absent(pdata); in xgbe_phy_sfp_detect()
1359 ret = xgbe_phy_sfp_read_eeprom(pdata); in xgbe_phy_sfp_detect()
1363 xgbe_phy_sfp_mod_absent(pdata); in xgbe_phy_sfp_detect()
1367 xgbe_phy_sfp_parse_eeprom(pdata); in xgbe_phy_sfp_detect()
1369 xgbe_phy_sfp_external_phy(pdata); in xgbe_phy_sfp_detect()
1372 xgbe_phy_sfp_phy_settings(pdata); in xgbe_phy_sfp_detect()
1374 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_sfp_detect()
1377 static int xgbe_phy_module_eeprom(struct xgbe_prv_data *pdata, in xgbe_phy_module_eeprom() argument
1380 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_module_eeprom()
1403 if (!netif_running(pdata->netdev)) { in xgbe_phy_module_eeprom()
1413 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_module_eeprom()
1419 ret = xgbe_phy_sfp_get_mux(pdata); in xgbe_phy_module_eeprom()
1421 netdev_err(pdata->netdev, "I2C error setting SFP MUX\n"); in xgbe_phy_module_eeprom()
1428 ret = xgbe_phy_i2c_read(pdata, XGBE_SFP_SERIAL_ID_ADDRESS, in xgbe_phy_module_eeprom()
1432 netdev_err(pdata->netdev, in xgbe_phy_module_eeprom()
1443 ret = xgbe_phy_i2c_read(pdata, XGBE_SFP_DIAG_INFO_ADDRESS, in xgbe_phy_module_eeprom()
1448 netdev_err(pdata->netdev, in xgbe_phy_module_eeprom()
1465 xgbe_phy_sfp_put_mux(pdata); in xgbe_phy_module_eeprom()
1468 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_module_eeprom()
1476 static int xgbe_phy_module_info(struct xgbe_prv_data *pdata, in xgbe_phy_module_info() argument
1479 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_module_info()
1484 if (!netif_running(pdata->netdev)) in xgbe_phy_module_info()
1501 static void xgbe_phy_phydev_flowctrl(struct xgbe_prv_data *pdata) in xgbe_phy_phydev_flowctrl() argument
1503 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_phydev_flowctrl()
1504 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_phydev_flowctrl()
1508 pdata->phy.tx_pause = 0; in xgbe_phy_phydev_flowctrl()
1509 pdata->phy.rx_pause = 0; in xgbe_phy_phydev_flowctrl()
1527 pdata->phy.tx_pause = 1; in xgbe_phy_phydev_flowctrl()
1529 pdata->phy.rx_pause = 1; in xgbe_phy_phydev_flowctrl()
1532 static enum xgbe_mode xgbe_phy_an37_sgmii_outcome(struct xgbe_prv_data *pdata) in xgbe_phy_an37_sgmii_outcome() argument
1534 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_an37_sgmii_outcome()
1541 if (pdata->phy.pause_autoneg) in xgbe_phy_an37_sgmii_outcome()
1542 xgbe_phy_phydev_flowctrl(pdata); in xgbe_phy_an37_sgmii_outcome()
1544 switch (pdata->an_status & XGBE_SGMII_AN_LINK_SPEED) { in xgbe_phy_an37_sgmii_outcome()
1546 if (pdata->an_status & XGBE_SGMII_AN_LINK_DUPLEX) { in xgbe_phy_an37_sgmii_outcome()
1556 if (pdata->an_status & XGBE_SGMII_AN_LINK_DUPLEX) { in xgbe_phy_an37_sgmii_outcome()
1572 static enum xgbe_mode xgbe_phy_an37_outcome(struct xgbe_prv_data *pdata) in xgbe_phy_an37_outcome() argument
1574 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_an37_outcome()
1582 ad_reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_VEND2_AN_ADVERTISE); in xgbe_phy_an37_outcome()
1583 lp_reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_VEND2_AN_LP_ABILITY); in xgbe_phy_an37_outcome()
1589 if (pdata->phy.pause_autoneg) { in xgbe_phy_an37_outcome()
1591 pdata->phy.tx_pause = 0; in xgbe_phy_an37_outcome()
1592 pdata->phy.rx_pause = 0; in xgbe_phy_an37_outcome()
1595 pdata->phy.tx_pause = 1; in xgbe_phy_an37_outcome()
1596 pdata->phy.rx_pause = 1; in xgbe_phy_an37_outcome()
1599 pdata->phy.rx_pause = 1; in xgbe_phy_an37_outcome()
1601 pdata->phy.tx_pause = 1; in xgbe_phy_an37_outcome()
1615 static enum xgbe_mode xgbe_phy_an73_redrv_outcome(struct xgbe_prv_data *pdata) in xgbe_phy_an73_redrv_outcome() argument
1617 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_an73_redrv_outcome()
1618 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_an73_redrv_outcome()
1626 if (pdata->phy.pause_autoneg) in xgbe_phy_an73_redrv_outcome()
1627 xgbe_phy_phydev_flowctrl(pdata); in xgbe_phy_an73_redrv_outcome()
1630 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 1); in xgbe_phy_an73_redrv_outcome()
1631 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA + 1); in xgbe_phy_an73_redrv_outcome()
1687 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 2); in xgbe_phy_an73_redrv_outcome()
1688 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA + 2); in xgbe_phy_an73_redrv_outcome()
1695 static enum xgbe_mode xgbe_phy_an73_outcome(struct xgbe_prv_data *pdata) in xgbe_phy_an73_outcome() argument
1697 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_an73_outcome()
1705 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE); in xgbe_phy_an73_outcome()
1706 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA); in xgbe_phy_an73_outcome()
1712 if (pdata->phy.pause_autoneg) { in xgbe_phy_an73_outcome()
1714 pdata->phy.tx_pause = 0; in xgbe_phy_an73_outcome()
1715 pdata->phy.rx_pause = 0; in xgbe_phy_an73_outcome()
1718 pdata->phy.tx_pause = 1; in xgbe_phy_an73_outcome()
1719 pdata->phy.rx_pause = 1; in xgbe_phy_an73_outcome()
1722 pdata->phy.rx_pause = 1; in xgbe_phy_an73_outcome()
1724 pdata->phy.tx_pause = 1; in xgbe_phy_an73_outcome()
1729 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 1); in xgbe_phy_an73_outcome()
1730 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA + 1); in xgbe_phy_an73_outcome()
1745 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 2); in xgbe_phy_an73_outcome()
1746 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA + 2); in xgbe_phy_an73_outcome()
1753 static enum xgbe_mode xgbe_phy_an_outcome(struct xgbe_prv_data *pdata) in xgbe_phy_an_outcome() argument
1755 switch (pdata->an_mode) { in xgbe_phy_an_outcome()
1757 return xgbe_phy_an73_outcome(pdata); in xgbe_phy_an_outcome()
1759 return xgbe_phy_an73_redrv_outcome(pdata); in xgbe_phy_an_outcome()
1761 return xgbe_phy_an37_outcome(pdata); in xgbe_phy_an_outcome()
1763 return xgbe_phy_an37_sgmii_outcome(pdata); in xgbe_phy_an_outcome()
1769 static void xgbe_phy_an_advertising(struct xgbe_prv_data *pdata, in xgbe_phy_an_advertising() argument
1772 struct ethtool_link_ksettings *slks = &pdata->phy.lks; in xgbe_phy_an_advertising()
1773 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_an_advertising()
1786 if (pdata->fec_ability & MDIO_PMA_10GBR_FECABLE_ABLE) in xgbe_phy_an_advertising()
1831 static int xgbe_phy_an_config(struct xgbe_prv_data *pdata) in xgbe_phy_an_config() argument
1833 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_an_config()
1834 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_an_config()
1837 ret = xgbe_phy_find_phy_device(pdata); in xgbe_phy_an_config()
1844 phy_data->phydev->autoneg = pdata->phy.autoneg; in xgbe_phy_an_config()
1849 if (pdata->phy.autoneg != AUTONEG_ENABLE) { in xgbe_phy_an_config()
1850 phy_data->phydev->speed = pdata->phy.speed; in xgbe_phy_an_config()
1851 phy_data->phydev->duplex = pdata->phy.duplex; in xgbe_phy_an_config()
1873 static enum xgbe_an_mode xgbe_phy_an_mode(struct xgbe_prv_data *pdata) in xgbe_phy_an_mode() argument
1875 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_an_mode()
1904 static int xgbe_phy_set_redrv_mode_mdio(struct xgbe_prv_data *pdata, in xgbe_phy_set_redrv_mode_mdio() argument
1907 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_set_redrv_mode_mdio()
1913 return pdata->hw_if.write_ext_mii_regs(pdata, phy_data->redrv_addr, in xgbe_phy_set_redrv_mode_mdio()
1917 static int xgbe_phy_set_redrv_mode_i2c(struct xgbe_prv_data *pdata, in xgbe_phy_set_redrv_mode_i2c() argument
1920 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_set_redrv_mode_i2c()
1927 ret = xgbe_phy_redrv_write(pdata, redrv_reg, mode); in xgbe_phy_set_redrv_mode_i2c()
1932 static void xgbe_phy_set_redrv_mode(struct xgbe_prv_data *pdata) in xgbe_phy_set_redrv_mode() argument
1934 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_set_redrv_mode()
1947 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_set_redrv_mode()
1952 xgbe_phy_set_redrv_mode_i2c(pdata, mode); in xgbe_phy_set_redrv_mode()
1954 xgbe_phy_set_redrv_mode_mdio(pdata, mode); in xgbe_phy_set_redrv_mode()
1956 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_set_redrv_mode()
1959 static void xgbe_phy_rx_reset(struct xgbe_prv_data *pdata) in xgbe_phy_rx_reset() argument
1963 reg = XMDIO_READ_BITS(pdata, MDIO_MMD_PCS, MDIO_PCS_DIGITAL_STAT, in xgbe_phy_rx_reset()
1970 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_RX_CTRL1, in xgbe_phy_rx_reset()
1973 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_RX_CTRL1, in xgbe_phy_rx_reset()
1976 netif_err(pdata, link, pdata->netdev, "firmware mailbox reset performed\n"); in xgbe_phy_rx_reset()
1980 static void xgbe_phy_pll_ctrl(struct xgbe_prv_data *pdata, bool enable) in xgbe_phy_pll_ctrl() argument
1983 if (pdata->phy.autoneg != AUTONEG_DISABLE) in xgbe_phy_pll_ctrl()
1986 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_VEND2_PMA_MISC_CTRL0, in xgbe_phy_pll_ctrl()
1995 static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata, in xgbe_phy_perform_ratechange() argument
2002 xgbe_phy_pll_ctrl(pdata, false); in xgbe_phy_perform_ratechange()
2005 if (XP_IOREAD_BITS(pdata, XP_DRIVER_INT_RO, STATUS)) { in xgbe_phy_perform_ratechange()
2006 netif_dbg(pdata, link, pdata->netdev, in xgbe_phy_perform_ratechange()
2008 xgbe_phy_rx_reset(pdata); in xgbe_phy_perform_ratechange()
2016 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_0, s0); in xgbe_phy_perform_ratechange()
2017 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_1, 0); in xgbe_phy_perform_ratechange()
2018 XP_IOWRITE_BITS(pdata, XP_DRIVER_INT_REQ, REQUEST, 1); in xgbe_phy_perform_ratechange()
2023 if (!XP_IOREAD_BITS(pdata, XP_DRIVER_INT_RO, STATUS)) in xgbe_phy_perform_ratechange()
2029 netif_dbg(pdata, link, pdata->netdev, in xgbe_phy_perform_ratechange()
2033 xgbe_phy_rx_reset(pdata); in xgbe_phy_perform_ratechange()
2039 xgbe_phy_pll_ctrl(pdata, true); in xgbe_phy_perform_ratechange()
2042 static void xgbe_phy_rrc(struct xgbe_prv_data *pdata) in xgbe_phy_rrc() argument
2045 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_RRC, XGBE_MB_SUBCMD_NONE); in xgbe_phy_rrc()
2047 netif_dbg(pdata, link, pdata->netdev, "receiver reset complete\n"); in xgbe_phy_rrc()
2050 static void xgbe_phy_power_off(struct xgbe_prv_data *pdata) in xgbe_phy_power_off() argument
2052 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_power_off()
2055 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_POWER_OFF, XGBE_MB_SUBCMD_NONE); in xgbe_phy_power_off()
2059 netif_dbg(pdata, link, pdata->netdev, "phy powered off\n"); in xgbe_phy_power_off()
2062 static void xgbe_phy_sfi_mode(struct xgbe_prv_data *pdata) in xgbe_phy_sfi_mode() argument
2064 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfi_mode()
2066 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_sfi_mode()
2070 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_10G_SFI, XGBE_MB_SUBCMD_ACTIVE); in xgbe_phy_sfi_mode()
2073 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_10G_SFI, in xgbe_phy_sfi_mode()
2076 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_10G_SFI, in xgbe_phy_sfi_mode()
2079 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_10G_SFI, in xgbe_phy_sfi_mode()
2085 netif_dbg(pdata, link, pdata->netdev, "10GbE SFI mode set\n"); in xgbe_phy_sfi_mode()
2088 static void xgbe_phy_x_mode(struct xgbe_prv_data *pdata) in xgbe_phy_x_mode() argument
2090 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_x_mode()
2092 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_x_mode()
2095 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_1G, XGBE_MB_SUBCMD_1G_KX); in xgbe_phy_x_mode()
2099 netif_dbg(pdata, link, pdata->netdev, "1GbE X mode set\n"); in xgbe_phy_x_mode()
2102 static void xgbe_phy_sgmii_1000_mode(struct xgbe_prv_data *pdata) in xgbe_phy_sgmii_1000_mode() argument
2104 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sgmii_1000_mode()
2106 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_sgmii_1000_mode()
2109 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_1G, XGBE_MB_SUBCMD_1G_SGMII); in xgbe_phy_sgmii_1000_mode()
2113 netif_dbg(pdata, link, pdata->netdev, "1GbE SGMII mode set\n"); in xgbe_phy_sgmii_1000_mode()
2116 static void xgbe_phy_sgmii_100_mode(struct xgbe_prv_data *pdata) in xgbe_phy_sgmii_100_mode() argument
2118 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sgmii_100_mode()
2120 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_sgmii_100_mode()
2123 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_1G, XGBE_MB_SUBCMD_100MBITS); in xgbe_phy_sgmii_100_mode()
2127 netif_dbg(pdata, link, pdata->netdev, "100MbE SGMII mode set\n"); in xgbe_phy_sgmii_100_mode()
2130 static void xgbe_phy_kr_mode(struct xgbe_prv_data *pdata) in xgbe_phy_kr_mode() argument
2132 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_kr_mode()
2134 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_kr_mode()
2137 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_10G_KR, XGBE_MB_SUBCMD_NONE); in xgbe_phy_kr_mode()
2141 netif_dbg(pdata, link, pdata->netdev, "10GbE KR mode set\n"); in xgbe_phy_kr_mode()
2144 static void xgbe_phy_kx_2500_mode(struct xgbe_prv_data *pdata) in xgbe_phy_kx_2500_mode() argument
2146 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_kx_2500_mode()
2148 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_kx_2500_mode()
2151 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_2_5G, XGBE_MB_SUBCMD_NONE); in xgbe_phy_kx_2500_mode()
2155 netif_dbg(pdata, link, pdata->netdev, "2.5GbE KX mode set\n"); in xgbe_phy_kx_2500_mode()
2158 static void xgbe_phy_kx_1000_mode(struct xgbe_prv_data *pdata) in xgbe_phy_kx_1000_mode() argument
2160 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_kx_1000_mode()
2162 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_kx_1000_mode()
2165 xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_1G, XGBE_MB_SUBCMD_1G_KX); in xgbe_phy_kx_1000_mode()
2169 netif_dbg(pdata, link, pdata->netdev, "1GbE KX mode set\n"); in xgbe_phy_kx_1000_mode()
2172 static enum xgbe_mode xgbe_phy_cur_mode(struct xgbe_prv_data *pdata) in xgbe_phy_cur_mode() argument
2174 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_cur_mode()
2179 static enum xgbe_mode xgbe_phy_switch_baset_mode(struct xgbe_prv_data *pdata) in xgbe_phy_switch_baset_mode() argument
2181 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_switch_baset_mode()
2185 return xgbe_phy_cur_mode(pdata); in xgbe_phy_switch_baset_mode()
2187 switch (xgbe_phy_cur_mode(pdata)) { in xgbe_phy_switch_baset_mode()
2197 static enum xgbe_mode xgbe_phy_switch_bp_2500_mode(struct xgbe_prv_data *pdata) in xgbe_phy_switch_bp_2500_mode() argument
2202 static enum xgbe_mode xgbe_phy_switch_bp_mode(struct xgbe_prv_data *pdata) in xgbe_phy_switch_bp_mode() argument
2205 switch (xgbe_phy_cur_mode(pdata)) { in xgbe_phy_switch_bp_mode()
2214 static enum xgbe_mode xgbe_phy_switch_mode(struct xgbe_prv_data *pdata) in xgbe_phy_switch_mode() argument
2216 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_switch_mode()
2221 return xgbe_phy_switch_bp_mode(pdata); in xgbe_phy_switch_mode()
2223 return xgbe_phy_switch_bp_2500_mode(pdata); in xgbe_phy_switch_mode()
2227 return xgbe_phy_switch_baset_mode(pdata); in xgbe_phy_switch_mode()
2232 return xgbe_phy_cur_mode(pdata); in xgbe_phy_switch_mode()
2309 static enum xgbe_mode xgbe_phy_get_mode(struct xgbe_prv_data *pdata, in xgbe_phy_get_mode() argument
2312 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_get_mode()
2334 static void xgbe_phy_set_mode(struct xgbe_prv_data *pdata, enum xgbe_mode mode) in xgbe_phy_set_mode() argument
2338 xgbe_phy_kx_1000_mode(pdata); in xgbe_phy_set_mode()
2341 xgbe_phy_kx_2500_mode(pdata); in xgbe_phy_set_mode()
2344 xgbe_phy_kr_mode(pdata); in xgbe_phy_set_mode()
2347 xgbe_phy_sgmii_100_mode(pdata); in xgbe_phy_set_mode()
2350 xgbe_phy_sgmii_1000_mode(pdata); in xgbe_phy_set_mode()
2353 xgbe_phy_x_mode(pdata); in xgbe_phy_set_mode()
2356 xgbe_phy_sfi_mode(pdata); in xgbe_phy_set_mode()
2363 static bool xgbe_phy_check_mode(struct xgbe_prv_data *pdata, in xgbe_phy_check_mode() argument
2366 if (pdata->phy.autoneg == AUTONEG_ENABLE) { in xgbe_phy_check_mode()
2371 cur_mode = xgbe_phy_get_mode(pdata, pdata->phy.speed); in xgbe_phy_check_mode()
2379 static bool xgbe_phy_use_basex_mode(struct xgbe_prv_data *pdata, in xgbe_phy_use_basex_mode() argument
2382 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_use_basex_mode()
2386 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_basex_mode()
2389 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_basex_mode()
2396 static bool xgbe_phy_use_baset_mode(struct xgbe_prv_data *pdata, in xgbe_phy_use_baset_mode() argument
2399 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_use_baset_mode()
2403 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_baset_mode()
2406 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_baset_mode()
2409 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_baset_mode()
2412 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_baset_mode()
2419 static bool xgbe_phy_use_sfp_mode(struct xgbe_prv_data *pdata, in xgbe_phy_use_sfp_mode() argument
2422 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_use_sfp_mode()
2423 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_use_sfp_mode()
2429 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_sfp_mode()
2434 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_sfp_mode()
2439 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_sfp_mode()
2444 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_sfp_mode()
2455 static bool xgbe_phy_use_bp_2500_mode(struct xgbe_prv_data *pdata, in xgbe_phy_use_bp_2500_mode() argument
2458 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_use_bp_2500_mode()
2462 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_bp_2500_mode()
2469 static bool xgbe_phy_use_bp_mode(struct xgbe_prv_data *pdata, in xgbe_phy_use_bp_mode() argument
2472 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_use_bp_mode()
2476 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_bp_mode()
2479 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_bp_mode()
2486 static bool xgbe_phy_use_mode(struct xgbe_prv_data *pdata, enum xgbe_mode mode) in xgbe_phy_use_mode() argument
2488 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_use_mode()
2493 return xgbe_phy_use_bp_mode(pdata, mode); in xgbe_phy_use_mode()
2495 return xgbe_phy_use_bp_2500_mode(pdata, mode); in xgbe_phy_use_mode()
2499 return xgbe_phy_use_baset_mode(pdata, mode); in xgbe_phy_use_mode()
2502 return xgbe_phy_use_basex_mode(pdata, mode); in xgbe_phy_use_mode()
2504 return xgbe_phy_use_sfp_mode(pdata, mode); in xgbe_phy_use_mode()
2576 static bool xgbe_phy_valid_speed(struct xgbe_prv_data *pdata, int speed) in xgbe_phy_valid_speed() argument
2578 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_valid_speed()
2600 static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart) in xgbe_phy_link_status() argument
2602 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_link_status()
2610 xgbe_phy_sfp_detect(pdata); in xgbe_phy_link_status()
2627 if ((pdata->phy.autoneg == AUTONEG_ENABLE) && in xgbe_phy_link_status()
2638 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); in xgbe_phy_link_status()
2639 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); in xgbe_phy_link_status()
2643 if (pdata->phy.autoneg == AUTONEG_ENABLE && in xgbe_phy_link_status()
2645 if (!test_bit(XGBE_LINK_INIT, &pdata->dev_state)) { in xgbe_phy_link_status()
2646 netif_carrier_off(pdata->netdev); in xgbe_phy_link_status()
2652 if (pdata->vdata->enable_rrc && phy_data->rrc_count++ > XGBE_RRC_FREQUENCY) { in xgbe_phy_link_status()
2654 xgbe_phy_rrc(pdata); in xgbe_phy_link_status()
2660 static void xgbe_phy_sfp_gpio_setup(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_gpio_setup() argument
2662 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_gpio_setup()
2665 XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2668 phy_data->sfp_gpio_mask = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2671 phy_data->sfp_gpio_rx_los = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2673 phy_data->sfp_gpio_tx_fault = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2675 phy_data->sfp_gpio_mod_absent = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2677 phy_data->sfp_gpio_rate_select = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2680 if (netif_msg_probe(pdata)) { in xgbe_phy_sfp_gpio_setup()
2681 dev_dbg(pdata->dev, "SFP: gpio_address=%#x\n", in xgbe_phy_sfp_gpio_setup()
2683 dev_dbg(pdata->dev, "SFP: gpio_mask=%#x\n", in xgbe_phy_sfp_gpio_setup()
2685 dev_dbg(pdata->dev, "SFP: gpio_rx_los=%u\n", in xgbe_phy_sfp_gpio_setup()
2687 dev_dbg(pdata->dev, "SFP: gpio_tx_fault=%u\n", in xgbe_phy_sfp_gpio_setup()
2689 dev_dbg(pdata->dev, "SFP: gpio_mod_absent=%u\n", in xgbe_phy_sfp_gpio_setup()
2691 dev_dbg(pdata->dev, "SFP: gpio_rate_select=%u\n", in xgbe_phy_sfp_gpio_setup()
2696 static void xgbe_phy_sfp_comm_setup(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_comm_setup() argument
2698 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_comm_setup()
2701 mux_addr_hi = XP_GET_BITS(pdata->pp4, XP_PROP_4, MUX_ADDR_HI); in xgbe_phy_sfp_comm_setup()
2702 mux_addr_lo = XP_GET_BITS(pdata->pp4, XP_PROP_4, MUX_ADDR_LO); in xgbe_phy_sfp_comm_setup()
2708 phy_data->sfp_mux_channel = XP_GET_BITS(pdata->pp4, XP_PROP_4, in xgbe_phy_sfp_comm_setup()
2711 if (netif_msg_probe(pdata)) { in xgbe_phy_sfp_comm_setup()
2712 dev_dbg(pdata->dev, "SFP: mux_address=%#x\n", in xgbe_phy_sfp_comm_setup()
2714 dev_dbg(pdata->dev, "SFP: mux_channel=%u\n", in xgbe_phy_sfp_comm_setup()
2719 static void xgbe_phy_sfp_setup(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_setup() argument
2721 xgbe_phy_sfp_comm_setup(pdata); in xgbe_phy_sfp_setup()
2722 xgbe_phy_sfp_gpio_setup(pdata); in xgbe_phy_sfp_setup()
2725 static int xgbe_phy_int_mdio_reset(struct xgbe_prv_data *pdata) in xgbe_phy_int_mdio_reset() argument
2727 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_int_mdio_reset()
2730 ret = pdata->hw_if.set_gpio(pdata, phy_data->mdio_reset_gpio); in xgbe_phy_int_mdio_reset()
2734 ret = pdata->hw_if.clr_gpio(pdata, phy_data->mdio_reset_gpio); in xgbe_phy_int_mdio_reset()
2739 static int xgbe_phy_i2c_mdio_reset(struct xgbe_prv_data *pdata) in xgbe_phy_i2c_mdio_reset() argument
2741 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_i2c_mdio_reset()
2747 ret = xgbe_phy_i2c_read(pdata, phy_data->mdio_reset_addr, in xgbe_phy_i2c_mdio_reset()
2765 ret = xgbe_phy_i2c_write(pdata, phy_data->mdio_reset_addr, in xgbe_phy_i2c_mdio_reset()
2777 ret = xgbe_phy_i2c_write(pdata, phy_data->mdio_reset_addr, in xgbe_phy_i2c_mdio_reset()
2783 static int xgbe_phy_mdio_reset(struct xgbe_prv_data *pdata) in xgbe_phy_mdio_reset() argument
2785 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mdio_reset()
2791 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_mdio_reset()
2796 ret = xgbe_phy_i2c_mdio_reset(pdata); in xgbe_phy_mdio_reset()
2798 ret = xgbe_phy_int_mdio_reset(pdata); in xgbe_phy_mdio_reset()
2800 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_mdio_reset()
2829 static int xgbe_phy_mdio_reset_setup(struct xgbe_prv_data *pdata) in xgbe_phy_mdio_reset_setup() argument
2831 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mdio_reset_setup()
2836 phy_data->mdio_reset = XP_GET_BITS(pdata->pp3, XP_PROP_3, MDIO_RESET); in xgbe_phy_mdio_reset_setup()
2843 dev_err(pdata->dev, "unsupported MDIO reset (%#x)\n", in xgbe_phy_mdio_reset_setup()
2850 XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_mdio_reset_setup()
2852 phy_data->mdio_reset_gpio = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_mdio_reset_setup()
2855 phy_data->mdio_reset_gpio = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_mdio_reset_setup()
2862 static bool xgbe_phy_port_mode_mismatch(struct xgbe_prv_data *pdata) in xgbe_phy_port_mode_mismatch() argument
2864 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_port_mode_mismatch()
2915 static bool xgbe_phy_conn_type_mismatch(struct xgbe_prv_data *pdata) in xgbe_phy_conn_type_mismatch() argument
2917 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_conn_type_mismatch()
2945 static bool xgbe_phy_port_enabled(struct xgbe_prv_data *pdata) in xgbe_phy_port_enabled() argument
2947 if (!XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_SPEEDS)) in xgbe_phy_port_enabled()
2949 if (!XP_GET_BITS(pdata->pp0, XP_PROP_0, CONN_TYPE)) in xgbe_phy_port_enabled()
2955 static void xgbe_phy_cdr_track(struct xgbe_prv_data *pdata) in xgbe_phy_cdr_track() argument
2957 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_cdr_track()
2959 if (!pdata->debugfs_an_cdr_workaround) in xgbe_phy_cdr_track()
2968 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_VEND2_PMA_CDR_CONTROL, in xgbe_phy_cdr_track()
2975 static void xgbe_phy_cdr_notrack(struct xgbe_prv_data *pdata) in xgbe_phy_cdr_notrack() argument
2977 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_cdr_notrack()
2979 if (!pdata->debugfs_an_cdr_workaround) in xgbe_phy_cdr_notrack()
2985 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_VEND2_PMA_CDR_CONTROL, in xgbe_phy_cdr_notrack()
2989 xgbe_phy_rrc(pdata); in xgbe_phy_cdr_notrack()
2994 static void xgbe_phy_kr_training_post(struct xgbe_prv_data *pdata) in xgbe_phy_kr_training_post() argument
2996 if (!pdata->debugfs_an_cdr_track_early) in xgbe_phy_kr_training_post()
2997 xgbe_phy_cdr_track(pdata); in xgbe_phy_kr_training_post()
3000 static void xgbe_phy_kr_training_pre(struct xgbe_prv_data *pdata) in xgbe_phy_kr_training_pre() argument
3002 if (pdata->debugfs_an_cdr_track_early) in xgbe_phy_kr_training_pre()
3003 xgbe_phy_cdr_track(pdata); in xgbe_phy_kr_training_pre()
3006 static void xgbe_phy_an_post(struct xgbe_prv_data *pdata) in xgbe_phy_an_post() argument
3008 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_an_post()
3010 switch (pdata->an_mode) { in xgbe_phy_an_post()
3016 xgbe_phy_cdr_track(pdata); in xgbe_phy_an_post()
3018 switch (pdata->an_result) { in xgbe_phy_an_post()
3035 static void xgbe_phy_an_pre(struct xgbe_prv_data *pdata) in xgbe_phy_an_pre() argument
3037 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_an_pre()
3039 switch (pdata->an_mode) { in xgbe_phy_an_pre()
3045 xgbe_phy_cdr_notrack(pdata); in xgbe_phy_an_pre()
3052 static void xgbe_phy_stop(struct xgbe_prv_data *pdata) in xgbe_phy_stop() argument
3054 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_stop()
3057 xgbe_phy_free_phy_device(pdata); in xgbe_phy_stop()
3061 xgbe_phy_sfp_mod_absent(pdata); in xgbe_phy_stop()
3064 xgbe_phy_cdr_track(pdata); in xgbe_phy_stop()
3067 xgbe_phy_power_off(pdata); in xgbe_phy_stop()
3070 pdata->i2c_if.i2c_stop(pdata); in xgbe_phy_stop()
3073 static int xgbe_phy_start(struct xgbe_prv_data *pdata) in xgbe_phy_start() argument
3075 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_start()
3079 ret = pdata->i2c_if.i2c_start(pdata); in xgbe_phy_start()
3085 ret = pdata->hw_if.set_ext_mii_mode(pdata, phy_data->redrv_addr, in xgbe_phy_start()
3088 netdev_err(pdata->netdev, in xgbe_phy_start()
3096 xgbe_phy_set_mode(pdata, phy_data->start_mode); in xgbe_phy_start()
3099 xgbe_phy_cdr_track(pdata); in xgbe_phy_start()
3104 xgbe_phy_sfp_detect(pdata); in xgbe_phy_start()
3111 ret = xgbe_phy_find_phy_device(pdata); in xgbe_phy_start()
3118 pdata->i2c_if.i2c_stop(pdata); in xgbe_phy_start()
3123 static int xgbe_phy_reset(struct xgbe_prv_data *pdata) in xgbe_phy_reset() argument
3125 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_reset()
3131 xgbe_phy_power_off(pdata); in xgbe_phy_reset()
3132 xgbe_phy_set_mode(pdata, cur_mode); in xgbe_phy_reset()
3138 ret = xgbe_phy_mdio_reset(pdata); in xgbe_phy_reset()
3145 static void xgbe_phy_exit(struct xgbe_prv_data *pdata) in xgbe_phy_exit() argument
3147 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_exit()
3153 static int xgbe_phy_init(struct xgbe_prv_data *pdata) in xgbe_phy_init() argument
3155 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_init()
3161 if (!xgbe_phy_port_enabled(pdata)) { in xgbe_phy_init()
3162 dev_info(pdata->dev, "device is not enabled\n"); in xgbe_phy_init()
3167 ret = pdata->i2c_if.i2c_init(pdata); in xgbe_phy_init()
3171 phy_data = devm_kzalloc(pdata->dev, sizeof(*phy_data), GFP_KERNEL); in xgbe_phy_init()
3174 pdata->phy_data = phy_data; in xgbe_phy_init()
3176 phy_data->port_mode = XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_MODE); in xgbe_phy_init()
3177 phy_data->port_id = XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_ID); in xgbe_phy_init()
3178 phy_data->port_speeds = XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_SPEEDS); in xgbe_phy_init()
3179 phy_data->conn_type = XP_GET_BITS(pdata->pp0, XP_PROP_0, CONN_TYPE); in xgbe_phy_init()
3180 phy_data->mdio_addr = XP_GET_BITS(pdata->pp0, XP_PROP_0, MDIO_ADDR); in xgbe_phy_init()
3181 if (netif_msg_probe(pdata)) { in xgbe_phy_init()
3182 dev_dbg(pdata->dev, "port mode=%u\n", phy_data->port_mode); in xgbe_phy_init()
3183 dev_dbg(pdata->dev, "port id=%u\n", phy_data->port_id); in xgbe_phy_init()
3184 dev_dbg(pdata->dev, "port speeds=%#x\n", phy_data->port_speeds); in xgbe_phy_init()
3185 dev_dbg(pdata->dev, "conn type=%u\n", phy_data->conn_type); in xgbe_phy_init()
3186 dev_dbg(pdata->dev, "mdio addr=%u\n", phy_data->mdio_addr); in xgbe_phy_init()
3189 phy_data->redrv = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_PRESENT); in xgbe_phy_init()
3190 phy_data->redrv_if = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_IF); in xgbe_phy_init()
3191 phy_data->redrv_addr = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_ADDR); in xgbe_phy_init()
3192 phy_data->redrv_lane = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_LANE); in xgbe_phy_init()
3193 phy_data->redrv_model = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_MODEL); in xgbe_phy_init()
3194 if (phy_data->redrv && netif_msg_probe(pdata)) { in xgbe_phy_init()
3195 dev_dbg(pdata->dev, "redrv present\n"); in xgbe_phy_init()
3196 dev_dbg(pdata->dev, "redrv i/f=%u\n", phy_data->redrv_if); in xgbe_phy_init()
3197 dev_dbg(pdata->dev, "redrv addr=%#x\n", phy_data->redrv_addr); in xgbe_phy_init()
3198 dev_dbg(pdata->dev, "redrv lane=%u\n", phy_data->redrv_lane); in xgbe_phy_init()
3199 dev_dbg(pdata->dev, "redrv model=%u\n", phy_data->redrv_model); in xgbe_phy_init()
3203 if (xgbe_phy_conn_type_mismatch(pdata)) { in xgbe_phy_init()
3204 dev_err(pdata->dev, "phy mode/connection mismatch (%#x/%#x)\n", in xgbe_phy_init()
3210 if (xgbe_phy_port_mode_mismatch(pdata)) { in xgbe_phy_init()
3211 dev_err(pdata->dev, "phy mode/speed mismatch (%#x/%#x)\n", in xgbe_phy_init()
3217 ret = xgbe_phy_mdio_reset_setup(pdata); in xgbe_phy_init()
3223 dev_err(pdata->dev, "phy re-driver settings error\n"); in xgbe_phy_init()
3226 pdata->kr_redrv = phy_data->redrv; in xgbe_phy_init()
3249 if (pdata->fec_ability & MDIO_PMA_10GBR_FECABLE_ABLE) in xgbe_phy_init()
3350 if (pdata->fec_ability & MDIO_PMA_10GBR_FECABLE_ABLE) in xgbe_phy_init()
3373 xgbe_phy_sfp_setup(pdata); in xgbe_phy_init()
3379 if (netif_msg_probe(pdata)) in xgbe_phy_init()
3380 dev_dbg(pdata->dev, "phy supported=0x%*pb\n", in xgbe_phy_init()
3386 ret = pdata->hw_if.set_ext_mii_mode(pdata, phy_data->mdio_addr, in xgbe_phy_init()
3389 dev_err(pdata->dev, in xgbe_phy_init()
3397 ret = pdata->hw_if.set_ext_mii_mode(pdata, phy_data->redrv_addr, in xgbe_phy_init()
3400 dev_err(pdata->dev, in xgbe_phy_init()
3410 mii = devm_mdiobus_alloc(pdata->dev); in xgbe_phy_init()
3412 dev_err(pdata->dev, "mdiobus_alloc failed\n"); in xgbe_phy_init()
3416 mii->priv = pdata; in xgbe_phy_init()
3420 mii->parent = pdata->dev; in xgbe_phy_init()
3422 snprintf(mii->id, sizeof(mii->id), "%s", dev_name(pdata->dev)); in xgbe_phy_init()
3425 dev_err(pdata->dev, "mdiobus_register failed\n"); in xgbe_phy_init()