Lines Matching refs:pdata

391 static enum xgbe_an_mode xgbe_phy_an_mode(struct xgbe_prv_data *pdata);
393 static int xgbe_phy_i2c_xfer(struct xgbe_prv_data *pdata, in xgbe_phy_i2c_xfer() argument
396 return pdata->i2c_if.i2c_xfer(pdata, i2c_op); in xgbe_phy_i2c_xfer()
399 static int xgbe_phy_redrv_write(struct xgbe_prv_data *pdata, unsigned int reg, in xgbe_phy_redrv_write() argument
402 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_redrv_write()
430 ret = xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_redrv_write()
444 ret = xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_redrv_write()
453 netif_dbg(pdata, drv, pdata->netdev, in xgbe_phy_redrv_write()
461 static int xgbe_phy_i2c_write(struct xgbe_prv_data *pdata, unsigned int target, in xgbe_phy_i2c_write() argument
474 ret = xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_i2c_write()
481 static int xgbe_phy_i2c_read(struct xgbe_prv_data *pdata, unsigned int target, in xgbe_phy_i2c_read() argument
495 ret = xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_i2c_read()
510 ret = xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_i2c_read()
517 static int xgbe_phy_sfp_put_mux(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_put_mux() argument
519 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_put_mux()
533 return xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_sfp_put_mux()
536 static int xgbe_phy_sfp_get_mux(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_get_mux() argument
538 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_get_mux()
552 return xgbe_phy_i2c_xfer(pdata, &i2c_op); in xgbe_phy_sfp_get_mux()
555 static void xgbe_phy_put_comm_ownership(struct xgbe_prv_data *pdata) in xgbe_phy_put_comm_ownership() argument
560 static int xgbe_phy_get_comm_ownership(struct xgbe_prv_data *pdata) in xgbe_phy_get_comm_ownership() argument
562 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_get_comm_ownership()
573 XP_IOWRITE(pdata, XP_I2C_MUTEX, XGBE_MUTEX_RELEASE); in xgbe_phy_get_comm_ownership()
574 XP_IOWRITE(pdata, XP_MDIO_MUTEX, XGBE_MUTEX_RELEASE); in xgbe_phy_get_comm_ownership()
584 if (XP_IOREAD(pdata, XP_I2C_MUTEX) || in xgbe_phy_get_comm_ownership()
585 XP_IOREAD(pdata, XP_MDIO_MUTEX)) { in xgbe_phy_get_comm_ownership()
591 XP_IOWRITE(pdata, XP_I2C_MUTEX, mutex_id); in xgbe_phy_get_comm_ownership()
592 XP_IOWRITE(pdata, XP_MDIO_MUTEX, mutex_id); in xgbe_phy_get_comm_ownership()
599 netdev_err(pdata->netdev, "unable to obtain hardware mutexes\n"); in xgbe_phy_get_comm_ownership()
604 static int xgbe_phy_mdio_mii_write(struct xgbe_prv_data *pdata, int addr, in xgbe_phy_mdio_mii_write() argument
607 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mdio_mii_write()
617 return pdata->hw_if.write_ext_mii_regs(pdata, addr, reg, val); in xgbe_phy_mdio_mii_write()
620 static int xgbe_phy_i2c_mii_write(struct xgbe_prv_data *pdata, int reg, u16 val) in xgbe_phy_i2c_mii_write() argument
626 ret = xgbe_phy_sfp_get_mux(pdata); in xgbe_phy_i2c_mii_write()
634 ret = xgbe_phy_i2c_write(pdata, XGBE_SFP_PHY_ADDRESS, in xgbe_phy_i2c_mii_write()
637 xgbe_phy_sfp_put_mux(pdata); in xgbe_phy_i2c_mii_write()
644 struct xgbe_prv_data *pdata = mii->priv; in xgbe_phy_mii_write() local
645 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mii_write()
648 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_mii_write()
653 ret = xgbe_phy_i2c_mii_write(pdata, reg, val); in xgbe_phy_mii_write()
655 ret = xgbe_phy_mdio_mii_write(pdata, addr, reg, val); in xgbe_phy_mii_write()
659 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_mii_write()
664 static int xgbe_phy_mdio_mii_read(struct xgbe_prv_data *pdata, int addr, in xgbe_phy_mdio_mii_read() argument
667 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mdio_mii_read()
677 return pdata->hw_if.read_ext_mii_regs(pdata, addr, reg); in xgbe_phy_mdio_mii_read()
680 static int xgbe_phy_i2c_mii_read(struct xgbe_prv_data *pdata, int reg) in xgbe_phy_i2c_mii_read() argument
686 ret = xgbe_phy_sfp_get_mux(pdata); in xgbe_phy_i2c_mii_read()
691 ret = xgbe_phy_i2c_read(pdata, XGBE_SFP_PHY_ADDRESS, in xgbe_phy_i2c_mii_read()
697 xgbe_phy_sfp_put_mux(pdata); in xgbe_phy_i2c_mii_read()
704 struct xgbe_prv_data *pdata = mii->priv; in xgbe_phy_mii_read() local
705 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mii_read()
708 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_mii_read()
713 ret = xgbe_phy_i2c_mii_read(pdata, reg); in xgbe_phy_mii_read()
715 ret = xgbe_phy_mdio_mii_read(pdata, addr, reg); in xgbe_phy_mii_read()
719 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_mii_read()
724 static void xgbe_phy_sfp_phy_settings(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_phy_settings() argument
726 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_sfp_phy_settings()
727 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_phy_settings()
735 pdata->phy.speed = SPEED_UNKNOWN; in xgbe_phy_sfp_phy_settings()
736 pdata->phy.duplex = DUPLEX_UNKNOWN; in xgbe_phy_sfp_phy_settings()
737 pdata->phy.autoneg = AUTONEG_ENABLE; in xgbe_phy_sfp_phy_settings()
738 pdata->phy.pause_autoneg = AUTONEG_ENABLE; in xgbe_phy_sfp_phy_settings()
756 pdata->phy.speed = SPEED_UNKNOWN; in xgbe_phy_sfp_phy_settings()
757 pdata->phy.duplex = DUPLEX_UNKNOWN; in xgbe_phy_sfp_phy_settings()
758 pdata->phy.autoneg = AUTONEG_ENABLE; in xgbe_phy_sfp_phy_settings()
759 pdata->phy.pause_autoneg = AUTONEG_ENABLE; in xgbe_phy_sfp_phy_settings()
778 pdata->phy.speed = SPEED_10000; in xgbe_phy_sfp_phy_settings()
779 pdata->phy.duplex = DUPLEX_FULL; in xgbe_phy_sfp_phy_settings()
780 pdata->phy.autoneg = AUTONEG_DISABLE; in xgbe_phy_sfp_phy_settings()
781 pdata->phy.pause_autoneg = AUTONEG_DISABLE; in xgbe_phy_sfp_phy_settings()
805 pdata->phy.speed = SPEED_UNKNOWN; in xgbe_phy_sfp_phy_settings()
806 pdata->phy.duplex = DUPLEX_UNKNOWN; in xgbe_phy_sfp_phy_settings()
807 pdata->phy.autoneg = AUTONEG_DISABLE; in xgbe_phy_sfp_phy_settings()
808 pdata->phy.pause_autoneg = AUTONEG_DISABLE; in xgbe_phy_sfp_phy_settings()
854 static void xgbe_phy_free_phy_device(struct xgbe_prv_data *pdata) in xgbe_phy_free_phy_device() argument
856 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_free_phy_device()
866 static bool xgbe_phy_finisar_phy_quirks(struct xgbe_prv_data *pdata) in xgbe_phy_finisar_phy_quirks() argument
869 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_finisar_phy_quirks()
901 netif_dbg(pdata, drv, pdata->netdev, in xgbe_phy_finisar_phy_quirks()
907 static bool xgbe_phy_belfuse_phy_quirks(struct xgbe_prv_data *pdata) in xgbe_phy_belfuse_phy_quirks() argument
910 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_belfuse_phy_quirks()
923 pdata->an_again = 1; in xgbe_phy_belfuse_phy_quirks()
982 netif_dbg(pdata, drv, pdata->netdev, in xgbe_phy_belfuse_phy_quirks()
988 static void xgbe_phy_external_phy_quirks(struct xgbe_prv_data *pdata) in xgbe_phy_external_phy_quirks() argument
990 if (xgbe_phy_belfuse_phy_quirks(pdata)) in xgbe_phy_external_phy_quirks()
993 if (xgbe_phy_finisar_phy_quirks(pdata)) in xgbe_phy_external_phy_quirks()
997 static int xgbe_phy_find_phy_device(struct xgbe_prv_data *pdata) in xgbe_phy_find_phy_device() argument
999 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_find_phy_device()
1000 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_find_phy_device()
1009 pdata->an_again = 0; in xgbe_phy_find_phy_device()
1021 ret = pdata->hw_if.set_ext_mii_mode(pdata, phy_data->mdio_addr, in xgbe_phy_find_phy_device()
1024 netdev_err(pdata->netdev, in xgbe_phy_find_phy_device()
1034 netdev_err(pdata->netdev, "get_phy_device failed\n"); in xgbe_phy_find_phy_device()
1037 netif_dbg(pdata, drv, pdata->netdev, "external PHY id is %#010x\n", in xgbe_phy_find_phy_device()
1044 netdev_err(pdata->netdev, "phy_device_register failed\n"); in xgbe_phy_find_phy_device()
1049 ret = phy_attach_direct(pdata->netdev, phydev, phydev->dev_flags, in xgbe_phy_find_phy_device()
1052 netdev_err(pdata->netdev, "phy_attach_direct failed\n"); in xgbe_phy_find_phy_device()
1059 xgbe_phy_external_phy_quirks(pdata); in xgbe_phy_find_phy_device()
1069 static void xgbe_phy_sfp_external_phy(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_external_phy() argument
1071 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_external_phy()
1083 ret = xgbe_phy_i2c_mii_read(pdata, MII_BMCR); in xgbe_phy_sfp_external_phy()
1134 static void xgbe_phy_sfp_parse_eeprom(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_parse_eeprom() argument
1136 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_parse_eeprom()
1202 static void xgbe_phy_sfp_eeprom_info(struct xgbe_prv_data *pdata, in xgbe_phy_sfp_eeprom_info() argument
1208 netif_dbg(pdata, drv, pdata->netdev, "SFP detected:\n"); in xgbe_phy_sfp_eeprom_info()
1212 netif_dbg(pdata, drv, pdata->netdev, " vendor: %s\n", in xgbe_phy_sfp_eeprom_info()
1218 netif_dbg(pdata, drv, pdata->netdev, " part number: %s\n", in xgbe_phy_sfp_eeprom_info()
1224 netif_dbg(pdata, drv, pdata->netdev, " revision level: %s\n", in xgbe_phy_sfp_eeprom_info()
1230 netif_dbg(pdata, drv, pdata->netdev, " serial number: %s\n", in xgbe_phy_sfp_eeprom_info()
1244 static int xgbe_phy_sfp_read_eeprom(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_read_eeprom() argument
1246 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_read_eeprom()
1251 ret = xgbe_phy_sfp_get_mux(pdata); in xgbe_phy_sfp_read_eeprom()
1253 dev_err_once(pdata->dev, "%s: I2C error setting SFP MUX\n", in xgbe_phy_sfp_read_eeprom()
1254 netdev_name(pdata->netdev)); in xgbe_phy_sfp_read_eeprom()
1260 ret = xgbe_phy_i2c_read(pdata, XGBE_SFP_SERIAL_ID_ADDRESS, in xgbe_phy_sfp_read_eeprom()
1264 dev_err_once(pdata->dev, "%s: I2C error reading SFP EEPROM\n", in xgbe_phy_sfp_read_eeprom()
1265 netdev_name(pdata->netdev)); in xgbe_phy_sfp_read_eeprom()
1288 if (netif_msg_drv(pdata)) in xgbe_phy_sfp_read_eeprom()
1289 xgbe_phy_sfp_eeprom_info(pdata, &sfp_eeprom); in xgbe_phy_sfp_read_eeprom()
1293 xgbe_phy_free_phy_device(pdata); in xgbe_phy_sfp_read_eeprom()
1299 xgbe_phy_sfp_put_mux(pdata); in xgbe_phy_sfp_read_eeprom()
1304 static void xgbe_phy_sfp_signals(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_signals() argument
1306 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_signals()
1312 ret = xgbe_phy_i2c_read(pdata, phy_data->sfp_gpio_address, in xgbe_phy_sfp_signals()
1316 dev_err_once(pdata->dev, "%s: I2C error reading SFP GPIOs\n", in xgbe_phy_sfp_signals()
1317 netdev_name(pdata->netdev)); in xgbe_phy_sfp_signals()
1326 static void xgbe_phy_sfp_mod_absent(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_mod_absent() argument
1328 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_mod_absent()
1330 xgbe_phy_free_phy_device(pdata); in xgbe_phy_sfp_mod_absent()
1347 static void xgbe_phy_sfp_detect(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_detect() argument
1349 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_detect()
1355 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_sfp_detect()
1360 xgbe_phy_sfp_signals(pdata); in xgbe_phy_sfp_detect()
1362 xgbe_phy_sfp_mod_absent(pdata); in xgbe_phy_sfp_detect()
1366 ret = xgbe_phy_sfp_read_eeprom(pdata); in xgbe_phy_sfp_detect()
1370 xgbe_phy_sfp_mod_absent(pdata); in xgbe_phy_sfp_detect()
1374 xgbe_phy_sfp_parse_eeprom(pdata); in xgbe_phy_sfp_detect()
1376 xgbe_phy_sfp_external_phy(pdata); in xgbe_phy_sfp_detect()
1379 xgbe_phy_sfp_phy_settings(pdata); in xgbe_phy_sfp_detect()
1381 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_sfp_detect()
1384 static int xgbe_phy_module_eeprom(struct xgbe_prv_data *pdata, in xgbe_phy_module_eeprom() argument
1387 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_module_eeprom()
1410 if (!netif_running(pdata->netdev)) { in xgbe_phy_module_eeprom()
1420 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_module_eeprom()
1426 ret = xgbe_phy_sfp_get_mux(pdata); in xgbe_phy_module_eeprom()
1428 netdev_err(pdata->netdev, "I2C error setting SFP MUX\n"); in xgbe_phy_module_eeprom()
1435 ret = xgbe_phy_i2c_read(pdata, XGBE_SFP_SERIAL_ID_ADDRESS, in xgbe_phy_module_eeprom()
1439 netdev_err(pdata->netdev, in xgbe_phy_module_eeprom()
1450 ret = xgbe_phy_i2c_read(pdata, XGBE_SFP_DIAG_INFO_ADDRESS, in xgbe_phy_module_eeprom()
1455 netdev_err(pdata->netdev, in xgbe_phy_module_eeprom()
1472 xgbe_phy_sfp_put_mux(pdata); in xgbe_phy_module_eeprom()
1475 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_module_eeprom()
1483 static int xgbe_phy_module_info(struct xgbe_prv_data *pdata, in xgbe_phy_module_info() argument
1486 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_module_info()
1491 if (!netif_running(pdata->netdev)) in xgbe_phy_module_info()
1508 static void xgbe_phy_phydev_flowctrl(struct xgbe_prv_data *pdata) in xgbe_phy_phydev_flowctrl() argument
1510 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_phydev_flowctrl()
1511 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_phydev_flowctrl()
1515 pdata->phy.tx_pause = 0; in xgbe_phy_phydev_flowctrl()
1516 pdata->phy.rx_pause = 0; in xgbe_phy_phydev_flowctrl()
1534 pdata->phy.tx_pause = 1; in xgbe_phy_phydev_flowctrl()
1536 pdata->phy.rx_pause = 1; in xgbe_phy_phydev_flowctrl()
1539 static enum xgbe_mode xgbe_phy_an37_sgmii_outcome(struct xgbe_prv_data *pdata) in xgbe_phy_an37_sgmii_outcome() argument
1541 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_an37_sgmii_outcome()
1548 if (pdata->phy.pause_autoneg) in xgbe_phy_an37_sgmii_outcome()
1549 xgbe_phy_phydev_flowctrl(pdata); in xgbe_phy_an37_sgmii_outcome()
1551 switch (pdata->an_status & XGBE_SGMII_AN_LINK_SPEED) { in xgbe_phy_an37_sgmii_outcome()
1553 if (pdata->an_status & XGBE_SGMII_AN_LINK_DUPLEX) { in xgbe_phy_an37_sgmii_outcome()
1563 if (pdata->an_status & XGBE_SGMII_AN_LINK_DUPLEX) { in xgbe_phy_an37_sgmii_outcome()
1579 static enum xgbe_mode xgbe_phy_an37_outcome(struct xgbe_prv_data *pdata) in xgbe_phy_an37_outcome() argument
1581 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_an37_outcome()
1589 ad_reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_VEND2_AN_ADVERTISE); in xgbe_phy_an37_outcome()
1590 lp_reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_VEND2_AN_LP_ABILITY); in xgbe_phy_an37_outcome()
1596 if (pdata->phy.pause_autoneg) { in xgbe_phy_an37_outcome()
1598 pdata->phy.tx_pause = 0; in xgbe_phy_an37_outcome()
1599 pdata->phy.rx_pause = 0; in xgbe_phy_an37_outcome()
1602 pdata->phy.tx_pause = 1; in xgbe_phy_an37_outcome()
1603 pdata->phy.rx_pause = 1; in xgbe_phy_an37_outcome()
1606 pdata->phy.rx_pause = 1; in xgbe_phy_an37_outcome()
1608 pdata->phy.tx_pause = 1; in xgbe_phy_an37_outcome()
1622 static enum xgbe_mode xgbe_phy_an73_redrv_outcome(struct xgbe_prv_data *pdata) in xgbe_phy_an73_redrv_outcome() argument
1624 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_an73_redrv_outcome()
1625 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_an73_redrv_outcome()
1633 if (pdata->phy.pause_autoneg) in xgbe_phy_an73_redrv_outcome()
1634 xgbe_phy_phydev_flowctrl(pdata); in xgbe_phy_an73_redrv_outcome()
1637 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 1); in xgbe_phy_an73_redrv_outcome()
1638 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA + 1); in xgbe_phy_an73_redrv_outcome()
1694 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 2); in xgbe_phy_an73_redrv_outcome()
1695 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA + 2); in xgbe_phy_an73_redrv_outcome()
1702 static enum xgbe_mode xgbe_phy_an73_outcome(struct xgbe_prv_data *pdata) in xgbe_phy_an73_outcome() argument
1704 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_an73_outcome()
1712 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE); in xgbe_phy_an73_outcome()
1713 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA); in xgbe_phy_an73_outcome()
1719 if (pdata->phy.pause_autoneg) { in xgbe_phy_an73_outcome()
1721 pdata->phy.tx_pause = 0; in xgbe_phy_an73_outcome()
1722 pdata->phy.rx_pause = 0; in xgbe_phy_an73_outcome()
1725 pdata->phy.tx_pause = 1; in xgbe_phy_an73_outcome()
1726 pdata->phy.rx_pause = 1; in xgbe_phy_an73_outcome()
1729 pdata->phy.rx_pause = 1; in xgbe_phy_an73_outcome()
1731 pdata->phy.tx_pause = 1; in xgbe_phy_an73_outcome()
1736 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 1); in xgbe_phy_an73_outcome()
1737 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA + 1); in xgbe_phy_an73_outcome()
1752 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 2); in xgbe_phy_an73_outcome()
1753 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA + 2); in xgbe_phy_an73_outcome()
1760 static enum xgbe_mode xgbe_phy_an_outcome(struct xgbe_prv_data *pdata) in xgbe_phy_an_outcome() argument
1762 switch (pdata->an_mode) { in xgbe_phy_an_outcome()
1764 return xgbe_phy_an73_outcome(pdata); in xgbe_phy_an_outcome()
1766 return xgbe_phy_an73_redrv_outcome(pdata); in xgbe_phy_an_outcome()
1768 return xgbe_phy_an37_outcome(pdata); in xgbe_phy_an_outcome()
1770 return xgbe_phy_an37_sgmii_outcome(pdata); in xgbe_phy_an_outcome()
1776 static void xgbe_phy_an_advertising(struct xgbe_prv_data *pdata, in xgbe_phy_an_advertising() argument
1779 struct ethtool_link_ksettings *slks = &pdata->phy.lks; in xgbe_phy_an_advertising()
1780 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_an_advertising()
1793 if (pdata->fec_ability & MDIO_PMA_10GBR_FECABLE_ABLE) in xgbe_phy_an_advertising()
1838 static int xgbe_phy_an_config(struct xgbe_prv_data *pdata) in xgbe_phy_an_config() argument
1840 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_an_config()
1841 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_an_config()
1844 ret = xgbe_phy_find_phy_device(pdata); in xgbe_phy_an_config()
1851 phy_data->phydev->autoneg = pdata->phy.autoneg; in xgbe_phy_an_config()
1856 if (pdata->phy.autoneg != AUTONEG_ENABLE) { in xgbe_phy_an_config()
1857 phy_data->phydev->speed = pdata->phy.speed; in xgbe_phy_an_config()
1858 phy_data->phydev->duplex = pdata->phy.duplex; in xgbe_phy_an_config()
1880 static enum xgbe_an_mode xgbe_phy_an_mode(struct xgbe_prv_data *pdata) in xgbe_phy_an_mode() argument
1882 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_an_mode()
1911 static int xgbe_phy_set_redrv_mode_mdio(struct xgbe_prv_data *pdata, in xgbe_phy_set_redrv_mode_mdio() argument
1914 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_set_redrv_mode_mdio()
1920 return pdata->hw_if.write_ext_mii_regs(pdata, phy_data->redrv_addr, in xgbe_phy_set_redrv_mode_mdio()
1924 static int xgbe_phy_set_redrv_mode_i2c(struct xgbe_prv_data *pdata, in xgbe_phy_set_redrv_mode_i2c() argument
1927 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_set_redrv_mode_i2c()
1934 ret = xgbe_phy_redrv_write(pdata, redrv_reg, mode); in xgbe_phy_set_redrv_mode_i2c()
1939 static void xgbe_phy_set_redrv_mode(struct xgbe_prv_data *pdata) in xgbe_phy_set_redrv_mode() argument
1941 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_set_redrv_mode()
1954 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_set_redrv_mode()
1959 xgbe_phy_set_redrv_mode_i2c(pdata, mode); in xgbe_phy_set_redrv_mode()
1961 xgbe_phy_set_redrv_mode_mdio(pdata, mode); in xgbe_phy_set_redrv_mode()
1963 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_set_redrv_mode()
1966 static void xgbe_phy_rx_reset(struct xgbe_prv_data *pdata) in xgbe_phy_rx_reset() argument
1970 reg = XMDIO_READ_BITS(pdata, MDIO_MMD_PCS, MDIO_PCS_DIGITAL_STAT, in xgbe_phy_rx_reset()
1977 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_RX_CTRL1, in xgbe_phy_rx_reset()
1980 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_RX_CTRL1, in xgbe_phy_rx_reset()
1983 netif_err(pdata, link, pdata->netdev, "firmware mailbox reset performed\n"); in xgbe_phy_rx_reset()
1987 static void xgbe_phy_pll_ctrl(struct xgbe_prv_data *pdata, bool enable) in xgbe_phy_pll_ctrl() argument
1989 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_VEND2_PMA_MISC_CTRL0, in xgbe_phy_pll_ctrl()
1998 static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata, in xgbe_phy_perform_ratechange() argument
2005 xgbe_phy_pll_ctrl(pdata, false); in xgbe_phy_perform_ratechange()
2008 if (XP_IOREAD_BITS(pdata, XP_DRIVER_INT_RO, STATUS)) { in xgbe_phy_perform_ratechange()
2009 netif_dbg(pdata, link, pdata->netdev, in xgbe_phy_perform_ratechange()
2011 xgbe_phy_rx_reset(pdata); in xgbe_phy_perform_ratechange()
2019 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_0, s0); in xgbe_phy_perform_ratechange()
2020 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_1, 0); in xgbe_phy_perform_ratechange()
2021 XP_IOWRITE_BITS(pdata, XP_DRIVER_INT_REQ, REQUEST, 1); in xgbe_phy_perform_ratechange()
2026 if (!XP_IOREAD_BITS(pdata, XP_DRIVER_INT_RO, STATUS)) in xgbe_phy_perform_ratechange()
2032 netif_dbg(pdata, link, pdata->netdev, in xgbe_phy_perform_ratechange()
2036 xgbe_phy_rx_reset(pdata); in xgbe_phy_perform_ratechange()
2040 xgbe_phy_pll_ctrl(pdata, true); in xgbe_phy_perform_ratechange()
2043 static void xgbe_phy_rrc(struct xgbe_prv_data *pdata) in xgbe_phy_rrc() argument
2046 xgbe_phy_perform_ratechange(pdata, 5, 0); in xgbe_phy_rrc()
2048 netif_dbg(pdata, link, pdata->netdev, "receiver reset complete\n"); in xgbe_phy_rrc()
2051 static void xgbe_phy_power_off(struct xgbe_prv_data *pdata) in xgbe_phy_power_off() argument
2053 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_power_off()
2056 xgbe_phy_perform_ratechange(pdata, 0, 0); in xgbe_phy_power_off()
2060 netif_dbg(pdata, link, pdata->netdev, "phy powered off\n"); in xgbe_phy_power_off()
2063 static void xgbe_phy_sfi_mode(struct xgbe_prv_data *pdata) in xgbe_phy_sfi_mode() argument
2065 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfi_mode()
2067 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_sfi_mode()
2071 xgbe_phy_perform_ratechange(pdata, 3, 0); in xgbe_phy_sfi_mode()
2074 xgbe_phy_perform_ratechange(pdata, 3, 1); in xgbe_phy_sfi_mode()
2076 xgbe_phy_perform_ratechange(pdata, 3, 2); in xgbe_phy_sfi_mode()
2078 xgbe_phy_perform_ratechange(pdata, 3, 3); in xgbe_phy_sfi_mode()
2083 netif_dbg(pdata, link, pdata->netdev, "10GbE SFI mode set\n"); in xgbe_phy_sfi_mode()
2086 static void xgbe_phy_x_mode(struct xgbe_prv_data *pdata) in xgbe_phy_x_mode() argument
2088 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_x_mode()
2090 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_x_mode()
2093 xgbe_phy_perform_ratechange(pdata, 1, 3); in xgbe_phy_x_mode()
2097 netif_dbg(pdata, link, pdata->netdev, "1GbE X mode set\n"); in xgbe_phy_x_mode()
2100 static void xgbe_phy_sgmii_1000_mode(struct xgbe_prv_data *pdata) in xgbe_phy_sgmii_1000_mode() argument
2102 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sgmii_1000_mode()
2104 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_sgmii_1000_mode()
2107 xgbe_phy_perform_ratechange(pdata, 1, 2); in xgbe_phy_sgmii_1000_mode()
2111 netif_dbg(pdata, link, pdata->netdev, "1GbE SGMII mode set\n"); in xgbe_phy_sgmii_1000_mode()
2114 static void xgbe_phy_sgmii_100_mode(struct xgbe_prv_data *pdata) in xgbe_phy_sgmii_100_mode() argument
2116 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sgmii_100_mode()
2118 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_sgmii_100_mode()
2121 xgbe_phy_perform_ratechange(pdata, 1, 1); in xgbe_phy_sgmii_100_mode()
2125 netif_dbg(pdata, link, pdata->netdev, "100MbE SGMII mode set\n"); in xgbe_phy_sgmii_100_mode()
2128 static void xgbe_phy_kr_mode(struct xgbe_prv_data *pdata) in xgbe_phy_kr_mode() argument
2130 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_kr_mode()
2132 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_kr_mode()
2135 xgbe_phy_perform_ratechange(pdata, 4, 0); in xgbe_phy_kr_mode()
2139 netif_dbg(pdata, link, pdata->netdev, "10GbE KR mode set\n"); in xgbe_phy_kr_mode()
2142 static void xgbe_phy_kx_2500_mode(struct xgbe_prv_data *pdata) in xgbe_phy_kx_2500_mode() argument
2144 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_kx_2500_mode()
2146 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_kx_2500_mode()
2149 xgbe_phy_perform_ratechange(pdata, 2, 0); in xgbe_phy_kx_2500_mode()
2153 netif_dbg(pdata, link, pdata->netdev, "2.5GbE KX mode set\n"); in xgbe_phy_kx_2500_mode()
2156 static void xgbe_phy_kx_1000_mode(struct xgbe_prv_data *pdata) in xgbe_phy_kx_1000_mode() argument
2158 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_kx_1000_mode()
2160 xgbe_phy_set_redrv_mode(pdata); in xgbe_phy_kx_1000_mode()
2163 xgbe_phy_perform_ratechange(pdata, 1, 3); in xgbe_phy_kx_1000_mode()
2167 netif_dbg(pdata, link, pdata->netdev, "1GbE KX mode set\n"); in xgbe_phy_kx_1000_mode()
2170 static enum xgbe_mode xgbe_phy_cur_mode(struct xgbe_prv_data *pdata) in xgbe_phy_cur_mode() argument
2172 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_cur_mode()
2177 static enum xgbe_mode xgbe_phy_switch_baset_mode(struct xgbe_prv_data *pdata) in xgbe_phy_switch_baset_mode() argument
2179 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_switch_baset_mode()
2183 return xgbe_phy_cur_mode(pdata); in xgbe_phy_switch_baset_mode()
2185 switch (xgbe_phy_cur_mode(pdata)) { in xgbe_phy_switch_baset_mode()
2195 static enum xgbe_mode xgbe_phy_switch_bp_2500_mode(struct xgbe_prv_data *pdata) in xgbe_phy_switch_bp_2500_mode() argument
2200 static enum xgbe_mode xgbe_phy_switch_bp_mode(struct xgbe_prv_data *pdata) in xgbe_phy_switch_bp_mode() argument
2203 switch (xgbe_phy_cur_mode(pdata)) { in xgbe_phy_switch_bp_mode()
2212 static enum xgbe_mode xgbe_phy_switch_mode(struct xgbe_prv_data *pdata) in xgbe_phy_switch_mode() argument
2214 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_switch_mode()
2219 return xgbe_phy_switch_bp_mode(pdata); in xgbe_phy_switch_mode()
2221 return xgbe_phy_switch_bp_2500_mode(pdata); in xgbe_phy_switch_mode()
2225 return xgbe_phy_switch_baset_mode(pdata); in xgbe_phy_switch_mode()
2230 return xgbe_phy_cur_mode(pdata); in xgbe_phy_switch_mode()
2307 static enum xgbe_mode xgbe_phy_get_mode(struct xgbe_prv_data *pdata, in xgbe_phy_get_mode() argument
2310 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_get_mode()
2332 static void xgbe_phy_set_mode(struct xgbe_prv_data *pdata, enum xgbe_mode mode) in xgbe_phy_set_mode() argument
2336 xgbe_phy_kx_1000_mode(pdata); in xgbe_phy_set_mode()
2339 xgbe_phy_kx_2500_mode(pdata); in xgbe_phy_set_mode()
2342 xgbe_phy_kr_mode(pdata); in xgbe_phy_set_mode()
2345 xgbe_phy_sgmii_100_mode(pdata); in xgbe_phy_set_mode()
2348 xgbe_phy_sgmii_1000_mode(pdata); in xgbe_phy_set_mode()
2351 xgbe_phy_x_mode(pdata); in xgbe_phy_set_mode()
2354 xgbe_phy_sfi_mode(pdata); in xgbe_phy_set_mode()
2361 static bool xgbe_phy_check_mode(struct xgbe_prv_data *pdata, in xgbe_phy_check_mode() argument
2364 if (pdata->phy.autoneg == AUTONEG_ENABLE) { in xgbe_phy_check_mode()
2369 cur_mode = xgbe_phy_get_mode(pdata, pdata->phy.speed); in xgbe_phy_check_mode()
2377 static bool xgbe_phy_use_basex_mode(struct xgbe_prv_data *pdata, in xgbe_phy_use_basex_mode() argument
2380 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_use_basex_mode()
2384 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_basex_mode()
2387 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_basex_mode()
2394 static bool xgbe_phy_use_baset_mode(struct xgbe_prv_data *pdata, in xgbe_phy_use_baset_mode() argument
2397 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_use_baset_mode()
2401 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_baset_mode()
2404 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_baset_mode()
2407 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_baset_mode()
2410 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_baset_mode()
2417 static bool xgbe_phy_use_sfp_mode(struct xgbe_prv_data *pdata, in xgbe_phy_use_sfp_mode() argument
2420 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_use_sfp_mode()
2421 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_use_sfp_mode()
2427 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_sfp_mode()
2432 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_sfp_mode()
2437 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_sfp_mode()
2442 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_sfp_mode()
2453 static bool xgbe_phy_use_bp_2500_mode(struct xgbe_prv_data *pdata, in xgbe_phy_use_bp_2500_mode() argument
2456 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_use_bp_2500_mode()
2460 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_bp_2500_mode()
2467 static bool xgbe_phy_use_bp_mode(struct xgbe_prv_data *pdata, in xgbe_phy_use_bp_mode() argument
2470 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_use_bp_mode()
2474 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_bp_mode()
2477 return xgbe_phy_check_mode(pdata, mode, in xgbe_phy_use_bp_mode()
2484 static bool xgbe_phy_use_mode(struct xgbe_prv_data *pdata, enum xgbe_mode mode) in xgbe_phy_use_mode() argument
2486 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_use_mode()
2491 return xgbe_phy_use_bp_mode(pdata, mode); in xgbe_phy_use_mode()
2493 return xgbe_phy_use_bp_2500_mode(pdata, mode); in xgbe_phy_use_mode()
2497 return xgbe_phy_use_baset_mode(pdata, mode); in xgbe_phy_use_mode()
2500 return xgbe_phy_use_basex_mode(pdata, mode); in xgbe_phy_use_mode()
2502 return xgbe_phy_use_sfp_mode(pdata, mode); in xgbe_phy_use_mode()
2574 static bool xgbe_phy_valid_speed(struct xgbe_prv_data *pdata, int speed) in xgbe_phy_valid_speed() argument
2576 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_valid_speed()
2598 static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart) in xgbe_phy_link_status() argument
2600 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_link_status()
2608 xgbe_phy_sfp_detect(pdata); in xgbe_phy_link_status()
2625 if ((pdata->phy.autoneg == AUTONEG_ENABLE) && in xgbe_phy_link_status()
2636 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); in xgbe_phy_link_status()
2637 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); in xgbe_phy_link_status()
2641 if (pdata->phy.autoneg == AUTONEG_ENABLE && in xgbe_phy_link_status()
2643 if (!test_bit(XGBE_LINK_INIT, &pdata->dev_state)) { in xgbe_phy_link_status()
2644 netif_carrier_off(pdata->netdev); in xgbe_phy_link_status()
2652 xgbe_phy_rrc(pdata); in xgbe_phy_link_status()
2658 static void xgbe_phy_sfp_gpio_setup(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_gpio_setup() argument
2660 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_gpio_setup()
2663 XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2666 phy_data->sfp_gpio_mask = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2669 phy_data->sfp_gpio_rx_los = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2671 phy_data->sfp_gpio_tx_fault = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2673 phy_data->sfp_gpio_mod_absent = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2675 phy_data->sfp_gpio_rate_select = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_sfp_gpio_setup()
2678 if (netif_msg_probe(pdata)) { in xgbe_phy_sfp_gpio_setup()
2679 dev_dbg(pdata->dev, "SFP: gpio_address=%#x\n", in xgbe_phy_sfp_gpio_setup()
2681 dev_dbg(pdata->dev, "SFP: gpio_mask=%#x\n", in xgbe_phy_sfp_gpio_setup()
2683 dev_dbg(pdata->dev, "SFP: gpio_rx_los=%u\n", in xgbe_phy_sfp_gpio_setup()
2685 dev_dbg(pdata->dev, "SFP: gpio_tx_fault=%u\n", in xgbe_phy_sfp_gpio_setup()
2687 dev_dbg(pdata->dev, "SFP: gpio_mod_absent=%u\n", in xgbe_phy_sfp_gpio_setup()
2689 dev_dbg(pdata->dev, "SFP: gpio_rate_select=%u\n", in xgbe_phy_sfp_gpio_setup()
2694 static void xgbe_phy_sfp_comm_setup(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_comm_setup() argument
2696 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_sfp_comm_setup()
2699 mux_addr_hi = XP_GET_BITS(pdata->pp4, XP_PROP_4, MUX_ADDR_HI); in xgbe_phy_sfp_comm_setup()
2700 mux_addr_lo = XP_GET_BITS(pdata->pp4, XP_PROP_4, MUX_ADDR_LO); in xgbe_phy_sfp_comm_setup()
2706 phy_data->sfp_mux_channel = XP_GET_BITS(pdata->pp4, XP_PROP_4, in xgbe_phy_sfp_comm_setup()
2709 if (netif_msg_probe(pdata)) { in xgbe_phy_sfp_comm_setup()
2710 dev_dbg(pdata->dev, "SFP: mux_address=%#x\n", in xgbe_phy_sfp_comm_setup()
2712 dev_dbg(pdata->dev, "SFP: mux_channel=%u\n", in xgbe_phy_sfp_comm_setup()
2717 static void xgbe_phy_sfp_setup(struct xgbe_prv_data *pdata) in xgbe_phy_sfp_setup() argument
2719 xgbe_phy_sfp_comm_setup(pdata); in xgbe_phy_sfp_setup()
2720 xgbe_phy_sfp_gpio_setup(pdata); in xgbe_phy_sfp_setup()
2723 static int xgbe_phy_int_mdio_reset(struct xgbe_prv_data *pdata) in xgbe_phy_int_mdio_reset() argument
2725 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_int_mdio_reset()
2728 ret = pdata->hw_if.set_gpio(pdata, phy_data->mdio_reset_gpio); in xgbe_phy_int_mdio_reset()
2732 ret = pdata->hw_if.clr_gpio(pdata, phy_data->mdio_reset_gpio); in xgbe_phy_int_mdio_reset()
2737 static int xgbe_phy_i2c_mdio_reset(struct xgbe_prv_data *pdata) in xgbe_phy_i2c_mdio_reset() argument
2739 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_i2c_mdio_reset()
2745 ret = xgbe_phy_i2c_read(pdata, phy_data->mdio_reset_addr, in xgbe_phy_i2c_mdio_reset()
2763 ret = xgbe_phy_i2c_write(pdata, phy_data->mdio_reset_addr, in xgbe_phy_i2c_mdio_reset()
2775 ret = xgbe_phy_i2c_write(pdata, phy_data->mdio_reset_addr, in xgbe_phy_i2c_mdio_reset()
2781 static int xgbe_phy_mdio_reset(struct xgbe_prv_data *pdata) in xgbe_phy_mdio_reset() argument
2783 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mdio_reset()
2789 ret = xgbe_phy_get_comm_ownership(pdata); in xgbe_phy_mdio_reset()
2794 ret = xgbe_phy_i2c_mdio_reset(pdata); in xgbe_phy_mdio_reset()
2796 ret = xgbe_phy_int_mdio_reset(pdata); in xgbe_phy_mdio_reset()
2798 xgbe_phy_put_comm_ownership(pdata); in xgbe_phy_mdio_reset()
2827 static int xgbe_phy_mdio_reset_setup(struct xgbe_prv_data *pdata) in xgbe_phy_mdio_reset_setup() argument
2829 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_mdio_reset_setup()
2834 phy_data->mdio_reset = XP_GET_BITS(pdata->pp3, XP_PROP_3, MDIO_RESET); in xgbe_phy_mdio_reset_setup()
2841 dev_err(pdata->dev, "unsupported MDIO reset (%#x)\n", in xgbe_phy_mdio_reset_setup()
2848 XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_mdio_reset_setup()
2850 phy_data->mdio_reset_gpio = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_mdio_reset_setup()
2853 phy_data->mdio_reset_gpio = XP_GET_BITS(pdata->pp3, XP_PROP_3, in xgbe_phy_mdio_reset_setup()
2860 static bool xgbe_phy_port_mode_mismatch(struct xgbe_prv_data *pdata) in xgbe_phy_port_mode_mismatch() argument
2862 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_port_mode_mismatch()
2913 static bool xgbe_phy_conn_type_mismatch(struct xgbe_prv_data *pdata) in xgbe_phy_conn_type_mismatch() argument
2915 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_conn_type_mismatch()
2943 static bool xgbe_phy_port_enabled(struct xgbe_prv_data *pdata) in xgbe_phy_port_enabled() argument
2945 if (!XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_SPEEDS)) in xgbe_phy_port_enabled()
2947 if (!XP_GET_BITS(pdata->pp0, XP_PROP_0, CONN_TYPE)) in xgbe_phy_port_enabled()
2953 static void xgbe_phy_cdr_track(struct xgbe_prv_data *pdata) in xgbe_phy_cdr_track() argument
2955 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_cdr_track()
2957 if (!pdata->debugfs_an_cdr_workaround) in xgbe_phy_cdr_track()
2966 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_VEND2_PMA_CDR_CONTROL, in xgbe_phy_cdr_track()
2973 static void xgbe_phy_cdr_notrack(struct xgbe_prv_data *pdata) in xgbe_phy_cdr_notrack() argument
2975 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_cdr_notrack()
2977 if (!pdata->debugfs_an_cdr_workaround) in xgbe_phy_cdr_notrack()
2983 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_VEND2_PMA_CDR_CONTROL, in xgbe_phy_cdr_notrack()
2987 xgbe_phy_rrc(pdata); in xgbe_phy_cdr_notrack()
2992 static void xgbe_phy_kr_training_post(struct xgbe_prv_data *pdata) in xgbe_phy_kr_training_post() argument
2994 if (!pdata->debugfs_an_cdr_track_early) in xgbe_phy_kr_training_post()
2995 xgbe_phy_cdr_track(pdata); in xgbe_phy_kr_training_post()
2998 static void xgbe_phy_kr_training_pre(struct xgbe_prv_data *pdata) in xgbe_phy_kr_training_pre() argument
3000 if (pdata->debugfs_an_cdr_track_early) in xgbe_phy_kr_training_pre()
3001 xgbe_phy_cdr_track(pdata); in xgbe_phy_kr_training_pre()
3004 static void xgbe_phy_an_post(struct xgbe_prv_data *pdata) in xgbe_phy_an_post() argument
3006 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_an_post()
3008 switch (pdata->an_mode) { in xgbe_phy_an_post()
3014 xgbe_phy_cdr_track(pdata); in xgbe_phy_an_post()
3016 switch (pdata->an_result) { in xgbe_phy_an_post()
3033 static void xgbe_phy_an_pre(struct xgbe_prv_data *pdata) in xgbe_phy_an_pre() argument
3035 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_an_pre()
3037 switch (pdata->an_mode) { in xgbe_phy_an_pre()
3043 xgbe_phy_cdr_notrack(pdata); in xgbe_phy_an_pre()
3050 static void xgbe_phy_stop(struct xgbe_prv_data *pdata) in xgbe_phy_stop() argument
3052 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_stop()
3055 xgbe_phy_free_phy_device(pdata); in xgbe_phy_stop()
3059 xgbe_phy_sfp_mod_absent(pdata); in xgbe_phy_stop()
3062 xgbe_phy_cdr_track(pdata); in xgbe_phy_stop()
3065 xgbe_phy_power_off(pdata); in xgbe_phy_stop()
3068 pdata->i2c_if.i2c_stop(pdata); in xgbe_phy_stop()
3071 static int xgbe_phy_start(struct xgbe_prv_data *pdata) in xgbe_phy_start() argument
3073 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_start()
3077 ret = pdata->i2c_if.i2c_start(pdata); in xgbe_phy_start()
3083 ret = pdata->hw_if.set_ext_mii_mode(pdata, phy_data->redrv_addr, in xgbe_phy_start()
3086 netdev_err(pdata->netdev, in xgbe_phy_start()
3094 xgbe_phy_set_mode(pdata, phy_data->start_mode); in xgbe_phy_start()
3097 xgbe_phy_cdr_track(pdata); in xgbe_phy_start()
3102 xgbe_phy_sfp_detect(pdata); in xgbe_phy_start()
3109 ret = xgbe_phy_find_phy_device(pdata); in xgbe_phy_start()
3116 pdata->i2c_if.i2c_stop(pdata); in xgbe_phy_start()
3121 static int xgbe_phy_reset(struct xgbe_prv_data *pdata) in xgbe_phy_reset() argument
3123 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_reset()
3129 xgbe_phy_power_off(pdata); in xgbe_phy_reset()
3130 xgbe_phy_set_mode(pdata, cur_mode); in xgbe_phy_reset()
3136 ret = xgbe_phy_mdio_reset(pdata); in xgbe_phy_reset()
3143 static void xgbe_phy_exit(struct xgbe_prv_data *pdata) in xgbe_phy_exit() argument
3145 struct xgbe_phy_data *phy_data = pdata->phy_data; in xgbe_phy_exit()
3151 static int xgbe_phy_init(struct xgbe_prv_data *pdata) in xgbe_phy_init() argument
3153 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_phy_init()
3159 if (!xgbe_phy_port_enabled(pdata)) { in xgbe_phy_init()
3160 dev_info(pdata->dev, "device is not enabled\n"); in xgbe_phy_init()
3165 ret = pdata->i2c_if.i2c_init(pdata); in xgbe_phy_init()
3169 phy_data = devm_kzalloc(pdata->dev, sizeof(*phy_data), GFP_KERNEL); in xgbe_phy_init()
3172 pdata->phy_data = phy_data; in xgbe_phy_init()
3174 phy_data->port_mode = XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_MODE); in xgbe_phy_init()
3175 phy_data->port_id = XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_ID); in xgbe_phy_init()
3176 phy_data->port_speeds = XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_SPEEDS); in xgbe_phy_init()
3177 phy_data->conn_type = XP_GET_BITS(pdata->pp0, XP_PROP_0, CONN_TYPE); in xgbe_phy_init()
3178 phy_data->mdio_addr = XP_GET_BITS(pdata->pp0, XP_PROP_0, MDIO_ADDR); in xgbe_phy_init()
3179 if (netif_msg_probe(pdata)) { in xgbe_phy_init()
3180 dev_dbg(pdata->dev, "port mode=%u\n", phy_data->port_mode); in xgbe_phy_init()
3181 dev_dbg(pdata->dev, "port id=%u\n", phy_data->port_id); in xgbe_phy_init()
3182 dev_dbg(pdata->dev, "port speeds=%#x\n", phy_data->port_speeds); in xgbe_phy_init()
3183 dev_dbg(pdata->dev, "conn type=%u\n", phy_data->conn_type); in xgbe_phy_init()
3184 dev_dbg(pdata->dev, "mdio addr=%u\n", phy_data->mdio_addr); in xgbe_phy_init()
3187 phy_data->redrv = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_PRESENT); in xgbe_phy_init()
3188 phy_data->redrv_if = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_IF); in xgbe_phy_init()
3189 phy_data->redrv_addr = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_ADDR); in xgbe_phy_init()
3190 phy_data->redrv_lane = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_LANE); in xgbe_phy_init()
3191 phy_data->redrv_model = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_MODEL); in xgbe_phy_init()
3192 if (phy_data->redrv && netif_msg_probe(pdata)) { in xgbe_phy_init()
3193 dev_dbg(pdata->dev, "redrv present\n"); in xgbe_phy_init()
3194 dev_dbg(pdata->dev, "redrv i/f=%u\n", phy_data->redrv_if); in xgbe_phy_init()
3195 dev_dbg(pdata->dev, "redrv addr=%#x\n", phy_data->redrv_addr); in xgbe_phy_init()
3196 dev_dbg(pdata->dev, "redrv lane=%u\n", phy_data->redrv_lane); in xgbe_phy_init()
3197 dev_dbg(pdata->dev, "redrv model=%u\n", phy_data->redrv_model); in xgbe_phy_init()
3201 if (xgbe_phy_conn_type_mismatch(pdata)) { in xgbe_phy_init()
3202 dev_err(pdata->dev, "phy mode/connection mismatch (%#x/%#x)\n", in xgbe_phy_init()
3208 if (xgbe_phy_port_mode_mismatch(pdata)) { in xgbe_phy_init()
3209 dev_err(pdata->dev, "phy mode/speed mismatch (%#x/%#x)\n", in xgbe_phy_init()
3215 ret = xgbe_phy_mdio_reset_setup(pdata); in xgbe_phy_init()
3221 dev_err(pdata->dev, "phy re-driver settings error\n"); in xgbe_phy_init()
3224 pdata->kr_redrv = phy_data->redrv; in xgbe_phy_init()
3247 if (pdata->fec_ability & MDIO_PMA_10GBR_FECABLE_ABLE) in xgbe_phy_init()
3348 if (pdata->fec_ability & MDIO_PMA_10GBR_FECABLE_ABLE) in xgbe_phy_init()
3371 xgbe_phy_sfp_setup(pdata); in xgbe_phy_init()
3377 if (netif_msg_probe(pdata)) in xgbe_phy_init()
3378 dev_dbg(pdata->dev, "phy supported=0x%*pb\n", in xgbe_phy_init()
3384 ret = pdata->hw_if.set_ext_mii_mode(pdata, phy_data->mdio_addr, in xgbe_phy_init()
3387 dev_err(pdata->dev, in xgbe_phy_init()
3395 ret = pdata->hw_if.set_ext_mii_mode(pdata, phy_data->redrv_addr, in xgbe_phy_init()
3398 dev_err(pdata->dev, in xgbe_phy_init()
3408 mii = devm_mdiobus_alloc(pdata->dev); in xgbe_phy_init()
3410 dev_err(pdata->dev, "mdiobus_alloc failed\n"); in xgbe_phy_init()
3414 mii->priv = pdata; in xgbe_phy_init()
3418 mii->parent = pdata->dev; in xgbe_phy_init()
3420 snprintf(mii->id, sizeof(mii->id), "%s", dev_name(pdata->dev)); in xgbe_phy_init()
3423 dev_err(pdata->dev, "mdiobus_register failed\n"); in xgbe_phy_init()