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
1982 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_VEND2_PMA_MISC_CTRL0, in xgbe_phy_pll_ctrl()
1991 static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata, in xgbe_phy_perform_ratechange() argument
1998 xgbe_phy_pll_ctrl(pdata, false); in xgbe_phy_perform_ratechange()
2001 if (XP_IOREAD_BITS(pdata, XP_DRIVER_INT_RO, STATUS)) { in xgbe_phy_perform_ratechange()
2002 netif_dbg(pdata, link, pdata->netdev, in xgbe_phy_perform_ratechange()
2004 xgbe_phy_rx_reset(pdata); in xgbe_phy_perform_ratechange()
2012 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_0, s0); in xgbe_phy_perform_ratechange()
2013 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_1, 0); in xgbe_phy_perform_ratechange()
2014 XP_IOWRITE_BITS(pdata, XP_DRIVER_INT_REQ, REQUEST, 1); in xgbe_phy_perform_ratechange()
2019 if (!XP_IOREAD_BITS(pdata, XP_DRIVER_INT_RO, STATUS)) in xgbe_phy_perform_ratechange()
2025 netif_dbg(pdata, link, pdata->netdev, in xgbe_phy_perform_ratechange()
2029 xgbe_phy_rx_reset(pdata); in xgbe_phy_perform_ratechange()
2033 xgbe_phy_pll_ctrl(pdata, true); in xgbe_phy_perform_ratechange()
2036 static void xgbe_phy_rrc(struct xgbe_prv_data *pdata) in xgbe_phy_rrc() argument
2039 xgbe_phy_perform_ratechange(pdata, 5, 0); in xgbe_phy_rrc()
2041 netif_dbg(pdata, link, pdata->netdev, "receiver reset complete\n"); in xgbe_phy_rrc()
2044 static void xgbe_phy_power_off(struct xgbe_prv_data *pdata) in xgbe_phy_power_off() argument
2046 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_power_off()
2049 xgbe_phy_perform_ratechange(pdata, 0, 0); in xgbe_phy_power_off()
2053 netif_dbg(pdata, link, pdata->netdev, "phy powered off\n"); in xgbe_phy_power_off()
2056 static void xgbe_phy_sfi_mode(struct xgbe_prv_data *pdata) in xgbe_phy_sfi_mode() argument
2058 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfi_mode()
2060 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_sfi_mode()
2064 xgbe_phy_perform_ratechange(pdata, 3, 0); in xgbe_phy_sfi_mode()
2067 xgbe_phy_perform_ratechange(pdata, 3, 1); in xgbe_phy_sfi_mode()
2069 xgbe_phy_perform_ratechange(pdata, 3, 2); in xgbe_phy_sfi_mode()
2071 xgbe_phy_perform_ratechange(pdata, 3, 3); in xgbe_phy_sfi_mode()
2076 netif_dbg(pdata, link, pdata->netdev, "10GbE SFI mode set\n"); in xgbe_phy_sfi_mode()
2079 static void xgbe_phy_x_mode(struct xgbe_prv_data *pdata) in xgbe_phy_x_mode() argument
2081 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_x_mode()
2083 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_x_mode()
2086 xgbe_phy_perform_ratechange(pdata, 1, 3); in xgbe_phy_x_mode()
2090 netif_dbg(pdata, link, pdata->netdev, "1GbE X mode set\n"); in xgbe_phy_x_mode()
2093 static void xgbe_phy_sgmii_1000_mode(struct xgbe_prv_data *pdata) in xgbe_phy_sgmii_1000_mode() argument
2095 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sgmii_1000_mode()
2097 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_sgmii_1000_mode()
2100 xgbe_phy_perform_ratechange(pdata, 1, 2); in xgbe_phy_sgmii_1000_mode()
2104 netif_dbg(pdata, link, pdata->netdev, "1GbE SGMII mode set\n"); in xgbe_phy_sgmii_1000_mode()
2107 static void xgbe_phy_sgmii_100_mode(struct xgbe_prv_data *pdata) in xgbe_phy_sgmii_100_mode() argument
2109 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sgmii_100_mode()
2111 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_sgmii_100_mode()
2114 xgbe_phy_perform_ratechange(pdata, 1, 1); in xgbe_phy_sgmii_100_mode()
2118 netif_dbg(pdata, link, pdata->netdev, "100MbE SGMII mode set\n"); in xgbe_phy_sgmii_100_mode()
2121 static void xgbe_phy_kr_mode(struct xgbe_prv_data *pdata) in xgbe_phy_kr_mode() argument
2123 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_kr_mode()
2125 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_kr_mode()
2128 xgbe_phy_perform_ratechange(pdata, 4, 0); in xgbe_phy_kr_mode()
2132 netif_dbg(pdata, link, pdata->netdev, "10GbE KR mode set\n"); in xgbe_phy_kr_mode()
2135 static void xgbe_phy_kx_2500_mode(struct xgbe_prv_data *pdata) in xgbe_phy_kx_2500_mode() argument
2137 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_kx_2500_mode()
2139 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_kx_2500_mode()
2142 xgbe_phy_perform_ratechange(pdata, 2, 0); in xgbe_phy_kx_2500_mode()
2146 netif_dbg(pdata, link, pdata->netdev, "2.5GbE KX mode set\n"); in xgbe_phy_kx_2500_mode()
2149 static void xgbe_phy_kx_1000_mode(struct xgbe_prv_data *pdata) in xgbe_phy_kx_1000_mode() argument
2151 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_kx_1000_mode()
2153 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_kx_1000_mode()
2156 xgbe_phy_perform_ratechange(pdata, 1, 3); in xgbe_phy_kx_1000_mode()
2160 netif_dbg(pdata, link, pdata->netdev, "1GbE KX mode set\n"); in xgbe_phy_kx_1000_mode()
2163 static enum xgbe_mode xgbe_phy_cur_mode(struct xgbe_prv_data *pdata) in xgbe_phy_cur_mode() argument
2165 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_cur_mode()
2170 static enum xgbe_mode xgbe_phy_switch_baset_mode(struct xgbe_prv_data *pdata) in xgbe_phy_switch_baset_mode() argument
2172 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_switch_baset_mode()
2176 return xgbe_phy_cur_mode(pdata); in xgbe_phy_switch_baset_mode()
2178 switch (xgbe_phy_cur_mode(pdata)) { in xgbe_phy_switch_baset_mode()
2188 static enum xgbe_mode xgbe_phy_switch_bp_2500_mode(struct xgbe_prv_data *pdata) in xgbe_phy_switch_bp_2500_mode() argument
2193 static enum xgbe_mode xgbe_phy_switch_bp_mode(struct xgbe_prv_data *pdata) in xgbe_phy_switch_bp_mode() argument
2196 switch (xgbe_phy_cur_mode(pdata)) { in xgbe_phy_switch_bp_mode()
2205 static enum xgbe_mode xgbe_phy_switch_mode(struct xgbe_prv_data *pdata) in xgbe_phy_switch_mode() argument
2207 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_switch_mode()
2212 return xgbe_phy_switch_bp_mode(pdata); in xgbe_phy_switch_mode()
2214 return xgbe_phy_switch_bp_2500_mode(pdata); in xgbe_phy_switch_mode()
2218 return xgbe_phy_switch_baset_mode(pdata); in xgbe_phy_switch_mode()
2223 return xgbe_phy_cur_mode(pdata); in xgbe_phy_switch_mode()
2300 static enum xgbe_mode xgbe_phy_get_mode(struct xgbe_prv_data *pdata, in xgbe_phy_get_mode() argument
2303 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_get_mode()
2325 static void xgbe_phy_set_mode(struct xgbe_prv_data *pdata, enum xgbe_mode mode) in xgbe_phy_set_mode() argument
2329 xgbe_phy_kx_1000_mode(pdata); in xgbe_phy_set_mode()
2332 xgbe_phy_kx_2500_mode(pdata); in xgbe_phy_set_mode()
2335 xgbe_phy_kr_mode(pdata); in xgbe_phy_set_mode()
2338 xgbe_phy_sgmii_100_mode(pdata); in xgbe_phy_set_mode()
2341 xgbe_phy_sgmii_1000_mode(pdata); in xgbe_phy_set_mode()
2344 xgbe_phy_x_mode(pdata); in xgbe_phy_set_mode()
2347 xgbe_phy_sfi_mode(pdata); in xgbe_phy_set_mode()
2354 static bool xgbe_phy_check_mode(struct xgbe_prv_data *pdata, in xgbe_phy_check_mode() argument
2357 if (pdata->phy.autoneg == AUTONEG_ENABLE) { in xgbe_phy_check_mode()
2362 cur_mode = xgbe_phy_get_mode(pdata, pdata->phy.speed); in xgbe_phy_check_mode()
2370 static bool xgbe_phy_use_basex_mode(struct xgbe_prv_data *pdata, in xgbe_phy_use_basex_mode() argument
2373 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_use_basex_mode()
2377 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_basex_mode()
2380 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_basex_mode()
2387 static bool xgbe_phy_use_baset_mode(struct xgbe_prv_data *pdata, in xgbe_phy_use_baset_mode() argument
2390 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_use_baset_mode()
2394 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_baset_mode()
2397 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_baset_mode()
2400 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_baset_mode()
2403 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_baset_mode()
2410 static bool xgbe_phy_use_sfp_mode(struct xgbe_prv_data *pdata, in xgbe_phy_use_sfp_mode() argument
2413 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_use_sfp_mode()
2414 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_use_sfp_mode()
2420 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_sfp_mode()
2425 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_sfp_mode()
2430 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_sfp_mode()
2435 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_sfp_mode()
2446 static bool xgbe_phy_use_bp_2500_mode(struct xgbe_prv_data *pdata, in xgbe_phy_use_bp_2500_mode() argument
2449 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_use_bp_2500_mode()
2453 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_bp_2500_mode()
2460 static bool xgbe_phy_use_bp_mode(struct xgbe_prv_data *pdata, in xgbe_phy_use_bp_mode() argument
2463 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_use_bp_mode()
2467 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_bp_mode()
2470 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_bp_mode()
2477 static bool xgbe_phy_use_mode(struct xgbe_prv_data *pdata, enum xgbe_mode mode) in xgbe_phy_use_mode() argument
2479 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_use_mode()
2484 return xgbe_phy_use_bp_mode(pdata, mode); in xgbe_phy_use_mode()
2486 return xgbe_phy_use_bp_2500_mode(pdata, mode); in xgbe_phy_use_mode()
2490 return xgbe_phy_use_baset_mode(pdata, mode); in xgbe_phy_use_mode()
2493 return xgbe_phy_use_basex_mode(pdata, mode); in xgbe_phy_use_mode()
2495 return xgbe_phy_use_sfp_mode(pdata, mode); in xgbe_phy_use_mode()
2567 static bool xgbe_phy_valid_speed(struct xgbe_prv_data *pdata, int speed) in xgbe_phy_valid_speed() argument
2569 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_valid_speed()
2591 static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart) in xgbe_phy_link_status() argument
2593 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_link_status()
2601 xgbe_phy_sfp_detect(pdata); in xgbe_phy_link_status()
2618 if ((pdata->phy.autoneg == AUTONEG_ENABLE) && in xgbe_phy_link_status()
2629 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); in xgbe_phy_link_status()
2630 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); in xgbe_phy_link_status()
2634 if (pdata->phy.autoneg == AUTONEG_ENABLE && in xgbe_phy_link_status()
2636 if (!test_bit(XGBE_LINK_INIT, &pdata->dev_state)) { in xgbe_phy_link_status()
2637 netif_carrier_off(pdata->netdev); in xgbe_phy_link_status()
2645 xgbe_phy_rrc(pdata); in xgbe_phy_link_status()
2651 static void xgbe_phy_sfp_gpio_setup(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_gpio_setup() argument
2653 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_gpio_setup()
2656 XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2659 phy_data->sfp_gpio_mask = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2662 phy_data->sfp_gpio_rx_los = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2664 phy_data->sfp_gpio_tx_fault = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2666 phy_data->sfp_gpio_mod_absent = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2668 phy_data->sfp_gpio_rate_select = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2671 if (netif_msg_probe(pdata)) { in xgbe_phy_sfp_gpio_setup()
2672 dev_dbg(pdata->dev, "SFP: gpio_address=%#x\n", in xgbe_phy_sfp_gpio_setup()
2674 dev_dbg(pdata->dev, "SFP: gpio_mask=%#x\n", in xgbe_phy_sfp_gpio_setup()
2676 dev_dbg(pdata->dev, "SFP: gpio_rx_los=%u\n", in xgbe_phy_sfp_gpio_setup()
2678 dev_dbg(pdata->dev, "SFP: gpio_tx_fault=%u\n", in xgbe_phy_sfp_gpio_setup()
2680 dev_dbg(pdata->dev, "SFP: gpio_mod_absent=%u\n", in xgbe_phy_sfp_gpio_setup()
2682 dev_dbg(pdata->dev, "SFP: gpio_rate_select=%u\n", in xgbe_phy_sfp_gpio_setup()
2687 static void xgbe_phy_sfp_comm_setup(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_comm_setup() argument
2689 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_comm_setup()
2692 mux_addr_hi = XP_GET_BITS(pdata->pp4, XP_PROP_4, MUX_ADDR_HI); in xgbe_phy_sfp_comm_setup()
2693 mux_addr_lo = XP_GET_BITS(pdata->pp4, XP_PROP_4, MUX_ADDR_LO); in xgbe_phy_sfp_comm_setup()
2699 phy_data->sfp_mux_channel = XP_GET_BITS(pdata->pp4, XP_PROP_4, in xgbe_phy_sfp_comm_setup()
2702 if (netif_msg_probe(pdata)) { in xgbe_phy_sfp_comm_setup()
2703 dev_dbg(pdata->dev, "SFP: mux_address=%#x\n", in xgbe_phy_sfp_comm_setup()
2705 dev_dbg(pdata->dev, "SFP: mux_channel=%u\n", in xgbe_phy_sfp_comm_setup()
2710 static void xgbe_phy_sfp_setup(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_setup() argument
2712 xgbe_phy_sfp_comm_setup(pdata); in xgbe_phy_sfp_setup()
2713 xgbe_phy_sfp_gpio_setup(pdata); in xgbe_phy_sfp_setup()
2716 static int xgbe_phy_int_mdio_reset(struct xgbe_prv_data *pdata) in xgbe_phy_int_mdio_reset() argument
2718 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_int_mdio_reset()
2721 ret = pdata->hw_if.set_gpio(pdata, phy_data->mdio_reset_gpio); in xgbe_phy_int_mdio_reset()
2725 ret = pdata->hw_if.clr_gpio(pdata, phy_data->mdio_reset_gpio); in xgbe_phy_int_mdio_reset()
2730 static int xgbe_phy_i2c_mdio_reset(struct xgbe_prv_data *pdata) in xgbe_phy_i2c_mdio_reset() argument
2732 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_i2c_mdio_reset()
2738 ret = xgbe_phy_i2c_read(pdata, phy_data->mdio_reset_addr, in xgbe_phy_i2c_mdio_reset()
2756 ret = xgbe_phy_i2c_write(pdata, phy_data->mdio_reset_addr, in xgbe_phy_i2c_mdio_reset()
2768 ret = xgbe_phy_i2c_write(pdata, phy_data->mdio_reset_addr, in xgbe_phy_i2c_mdio_reset()
2774 static int xgbe_phy_mdio_reset(struct xgbe_prv_data *pdata) in xgbe_phy_mdio_reset() argument
2776 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mdio_reset()
2782 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_mdio_reset()
2787 ret = xgbe_phy_i2c_mdio_reset(pdata); in xgbe_phy_mdio_reset()
2789 ret = xgbe_phy_int_mdio_reset(pdata); in xgbe_phy_mdio_reset()
2791 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_mdio_reset()
2820 static int xgbe_phy_mdio_reset_setup(struct xgbe_prv_data *pdata) in xgbe_phy_mdio_reset_setup() argument
2822 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mdio_reset_setup()
2827 phy_data->mdio_reset = XP_GET_BITS(pdata->pp3, XP_PROP_3, MDIO_RESET); in xgbe_phy_mdio_reset_setup()
2834 dev_err(pdata->dev, "unsupported MDIO reset (%#x)\n", in xgbe_phy_mdio_reset_setup()
2841 XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_mdio_reset_setup()
2843 phy_data->mdio_reset_gpio = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_mdio_reset_setup()
2846 phy_data->mdio_reset_gpio = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_mdio_reset_setup()
2853 static bool xgbe_phy_port_mode_mismatch(struct xgbe_prv_data *pdata) in xgbe_phy_port_mode_mismatch() argument
2855 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_port_mode_mismatch()
2906 static bool xgbe_phy_conn_type_mismatch(struct xgbe_prv_data *pdata) in xgbe_phy_conn_type_mismatch() argument
2908 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_conn_type_mismatch()
2936 static bool xgbe_phy_port_enabled(struct xgbe_prv_data *pdata) in xgbe_phy_port_enabled() argument
2938 if (!XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_SPEEDS)) in xgbe_phy_port_enabled()
2940 if (!XP_GET_BITS(pdata->pp0, XP_PROP_0, CONN_TYPE)) in xgbe_phy_port_enabled()
2946 static void xgbe_phy_cdr_track(struct xgbe_prv_data *pdata) in xgbe_phy_cdr_track() argument
2948 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_cdr_track()
2950 if (!pdata->debugfs_an_cdr_workaround) in xgbe_phy_cdr_track()
2959 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_VEND2_PMA_CDR_CONTROL, in xgbe_phy_cdr_track()
2966 static void xgbe_phy_cdr_notrack(struct xgbe_prv_data *pdata) in xgbe_phy_cdr_notrack() argument
2968 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_cdr_notrack()
2970 if (!pdata->debugfs_an_cdr_workaround) in xgbe_phy_cdr_notrack()
2976 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_VEND2_PMA_CDR_CONTROL, in xgbe_phy_cdr_notrack()
2980 xgbe_phy_rrc(pdata); in xgbe_phy_cdr_notrack()
2985 static void xgbe_phy_kr_training_post(struct xgbe_prv_data *pdata) in xgbe_phy_kr_training_post() argument
2987 if (!pdata->debugfs_an_cdr_track_early) in xgbe_phy_kr_training_post()
2988 xgbe_phy_cdr_track(pdata); in xgbe_phy_kr_training_post()
2991 static void xgbe_phy_kr_training_pre(struct xgbe_prv_data *pdata) in xgbe_phy_kr_training_pre() argument
2993 if (pdata->debugfs_an_cdr_track_early) in xgbe_phy_kr_training_pre()
2994 xgbe_phy_cdr_track(pdata); in xgbe_phy_kr_training_pre()
2997 static void xgbe_phy_an_post(struct xgbe_prv_data *pdata) in xgbe_phy_an_post() argument
2999 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_an_post()
3001 switch (pdata->an_mode) { in xgbe_phy_an_post()
3007 xgbe_phy_cdr_track(pdata); in xgbe_phy_an_post()
3009 switch (pdata->an_result) { in xgbe_phy_an_post()
3026 static void xgbe_phy_an_pre(struct xgbe_prv_data *pdata) in xgbe_phy_an_pre() argument
3028 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_an_pre()
3030 switch (pdata->an_mode) { in xgbe_phy_an_pre()
3036 xgbe_phy_cdr_notrack(pdata); in xgbe_phy_an_pre()
3043 static void xgbe_phy_stop(struct xgbe_prv_data *pdata) in xgbe_phy_stop() argument
3045 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_stop()
3048 xgbe_phy_free_phy_device(pdata); in xgbe_phy_stop()
3052 xgbe_phy_sfp_mod_absent(pdata); in xgbe_phy_stop()
3055 xgbe_phy_cdr_track(pdata); in xgbe_phy_stop()
3058 xgbe_phy_power_off(pdata); in xgbe_phy_stop()
3061 pdata->i2c_if.i2c_stop(pdata); in xgbe_phy_stop()
3064 static int xgbe_phy_start(struct xgbe_prv_data *pdata) in xgbe_phy_start() argument
3066 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_start()
3070 ret = pdata->i2c_if.i2c_start(pdata); in xgbe_phy_start()
3076 ret = pdata->hw_if.set_ext_mii_mode(pdata, phy_data->redrv_addr, in xgbe_phy_start()
3079 netdev_err(pdata->netdev, in xgbe_phy_start()
3087 xgbe_phy_set_mode(pdata, phy_data->start_mode); in xgbe_phy_start()
3090 xgbe_phy_cdr_track(pdata); in xgbe_phy_start()
3095 xgbe_phy_sfp_detect(pdata); in xgbe_phy_start()
3102 ret = xgbe_phy_find_phy_device(pdata); in xgbe_phy_start()
3109 pdata->i2c_if.i2c_stop(pdata); in xgbe_phy_start()
3114 static int xgbe_phy_reset(struct xgbe_prv_data *pdata) in xgbe_phy_reset() argument
3116 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_reset()
3122 xgbe_phy_power_off(pdata); in xgbe_phy_reset()
3123 xgbe_phy_set_mode(pdata, cur_mode); in xgbe_phy_reset()
3129 ret = xgbe_phy_mdio_reset(pdata); in xgbe_phy_reset()
3136 static void xgbe_phy_exit(struct xgbe_prv_data *pdata) in xgbe_phy_exit() argument
3138 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_exit()
3144 static int xgbe_phy_init(struct xgbe_prv_data *pdata) in xgbe_phy_init() argument
3146 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_init()
3152 if (!xgbe_phy_port_enabled(pdata)) { in xgbe_phy_init()
3153 dev_info(pdata->dev, "device is not enabled\n"); in xgbe_phy_init()
3158 ret = pdata->i2c_if.i2c_init(pdata); in xgbe_phy_init()
3162 phy_data = devm_kzalloc(pdata->dev, sizeof(*phy_data), GFP_KERNEL); in xgbe_phy_init()
3165 pdata->phy_data = phy_data; in xgbe_phy_init()
3167 phy_data->port_mode = XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_MODE); in xgbe_phy_init()
3168 phy_data->port_id = XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_ID); in xgbe_phy_init()
3169 phy_data->port_speeds = XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_SPEEDS); in xgbe_phy_init()
3170 phy_data->conn_type = XP_GET_BITS(pdata->pp0, XP_PROP_0, CONN_TYPE); in xgbe_phy_init()
3171 phy_data->mdio_addr = XP_GET_BITS(pdata->pp0, XP_PROP_0, MDIO_ADDR); in xgbe_phy_init()
3172 if (netif_msg_probe(pdata)) { in xgbe_phy_init()
3173 dev_dbg(pdata->dev, "port mode=%u\n", phy_data->port_mode); in xgbe_phy_init()
3174 dev_dbg(pdata->dev, "port id=%u\n", phy_data->port_id); in xgbe_phy_init()
3175 dev_dbg(pdata->dev, "port speeds=%#x\n", phy_data->port_speeds); in xgbe_phy_init()
3176 dev_dbg(pdata->dev, "conn type=%u\n", phy_data->conn_type); in xgbe_phy_init()
3177 dev_dbg(pdata->dev, "mdio addr=%u\n", phy_data->mdio_addr); in xgbe_phy_init()
3180 phy_data->redrv = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_PRESENT); in xgbe_phy_init()
3181 phy_data->redrv_if = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_IF); in xgbe_phy_init()
3182 phy_data->redrv_addr = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_ADDR); in xgbe_phy_init()
3183 phy_data->redrv_lane = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_LANE); in xgbe_phy_init()
3184 phy_data->redrv_model = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_MODEL); in xgbe_phy_init()
3185 if (phy_data->redrv && netif_msg_probe(pdata)) { in xgbe_phy_init()
3186 dev_dbg(pdata->dev, "redrv present\n"); in xgbe_phy_init()
3187 dev_dbg(pdata->dev, "redrv i/f=%u\n", phy_data->redrv_if); in xgbe_phy_init()
3188 dev_dbg(pdata->dev, "redrv addr=%#x\n", phy_data->redrv_addr); in xgbe_phy_init()
3189 dev_dbg(pdata->dev, "redrv lane=%u\n", phy_data->redrv_lane); in xgbe_phy_init()
3190 dev_dbg(pdata->dev, "redrv model=%u\n", phy_data->redrv_model); in xgbe_phy_init()
3194 if (xgbe_phy_conn_type_mismatch(pdata)) { in xgbe_phy_init()
3195 dev_err(pdata->dev, "phy mode/connection mismatch (%#x/%#x)\n", in xgbe_phy_init()
3201 if (xgbe_phy_port_mode_mismatch(pdata)) { in xgbe_phy_init()
3202 dev_err(pdata->dev, "phy mode/speed mismatch (%#x/%#x)\n", in xgbe_phy_init()
3208 ret = xgbe_phy_mdio_reset_setup(pdata); in xgbe_phy_init()
3214 dev_err(pdata->dev, "phy re-driver settings error\n"); in xgbe_phy_init()
3217 pdata->kr_redrv = phy_data->redrv; in xgbe_phy_init()
3240 if (pdata->fec_ability & MDIO_PMA_10GBR_FECABLE_ABLE) in xgbe_phy_init()
3341 if (pdata->fec_ability & MDIO_PMA_10GBR_FECABLE_ABLE) in xgbe_phy_init()
3364 xgbe_phy_sfp_setup(pdata); in xgbe_phy_init()
3370 if (netif_msg_probe(pdata)) in xgbe_phy_init()
3371 dev_dbg(pdata->dev, "phy supported=0x%*pb\n", in xgbe_phy_init()
3377 ret = pdata->hw_if.set_ext_mii_mode(pdata, phy_data->mdio_addr, in xgbe_phy_init()
3380 dev_err(pdata->dev, in xgbe_phy_init()
3388 ret = pdata->hw_if.set_ext_mii_mode(pdata, phy_data->redrv_addr, in xgbe_phy_init()
3391 dev_err(pdata->dev, in xgbe_phy_init()
3401 mii = devm_mdiobus_alloc(pdata->dev); in xgbe_phy_init()
3403 dev_err(pdata->dev, "mdiobus_alloc failed\n"); in xgbe_phy_init()
3407 mii->priv = pdata; in xgbe_phy_init()
3411 mii->parent = pdata->dev; in xgbe_phy_init()
3413 snprintf(mii->id, sizeof(mii->id), "%s", dev_name(pdata->dev)); in xgbe_phy_init()
3416 dev_err(pdata->dev, "mdiobus_register failed\n"); in xgbe_phy_init()