Lines Matching refs:pdata
251 static enum axgbe_an_mode axgbe_phy_an_mode(struct axgbe_port *pdata);
253 static int axgbe_phy_i2c_xfer(struct axgbe_port *pdata, in axgbe_phy_i2c_xfer() argument
256 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_i2c_xfer()
262 return pdata->i2c_if.i2c_xfer(pdata, i2c_op); in axgbe_phy_i2c_xfer()
265 static int axgbe_phy_redrv_write(struct axgbe_port *pdata, unsigned int reg, in axgbe_phy_redrv_write() argument
268 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_redrv_write()
296 ret = axgbe_phy_i2c_xfer(pdata, &i2c_op); in axgbe_phy_redrv_write()
310 ret = axgbe_phy_i2c_xfer(pdata, &i2c_op); in axgbe_phy_redrv_write()
326 static int axgbe_phy_i2c_read(struct axgbe_port *pdata, unsigned int target, in axgbe_phy_i2c_read() argument
340 ret = axgbe_phy_i2c_xfer(pdata, &i2c_op); in axgbe_phy_i2c_read()
355 ret = axgbe_phy_i2c_xfer(pdata, &i2c_op); in axgbe_phy_i2c_read()
362 static int axgbe_phy_sfp_put_mux(struct axgbe_port *pdata) in axgbe_phy_sfp_put_mux() argument
364 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_sfp_put_mux()
378 return axgbe_phy_i2c_xfer(pdata, &i2c_op); in axgbe_phy_sfp_put_mux()
381 static int axgbe_phy_sfp_get_mux(struct axgbe_port *pdata) in axgbe_phy_sfp_get_mux() argument
383 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_sfp_get_mux()
397 return axgbe_phy_i2c_xfer(pdata, &i2c_op); in axgbe_phy_sfp_get_mux()
400 static void axgbe_phy_put_comm_ownership(struct axgbe_port *pdata) in axgbe_phy_put_comm_ownership() argument
402 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_put_comm_ownership()
406 pthread_mutex_unlock(&pdata->phy_mutex); in axgbe_phy_put_comm_ownership()
409 static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata) in axgbe_phy_get_comm_ownership() argument
411 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_get_comm_ownership()
419 pthread_mutex_lock(&pdata->phy_mutex); in axgbe_phy_get_comm_ownership()
425 XP_IOWRITE(pdata, XP_I2C_MUTEX, AXGBE_MUTEX_RELEASE); in axgbe_phy_get_comm_ownership()
426 XP_IOWRITE(pdata, XP_MDIO_MUTEX, AXGBE_MUTEX_RELEASE); in axgbe_phy_get_comm_ownership()
436 if (XP_IOREAD(pdata, XP_I2C_MUTEX) || in axgbe_phy_get_comm_ownership()
437 XP_IOREAD(pdata, XP_MDIO_MUTEX)) { in axgbe_phy_get_comm_ownership()
443 XP_IOWRITE(pdata, XP_I2C_MUTEX, mutex_id); in axgbe_phy_get_comm_ownership()
444 XP_IOWRITE(pdata, XP_MDIO_MUTEX, mutex_id); in axgbe_phy_get_comm_ownership()
450 pthread_mutex_unlock(&pdata->phy_mutex); in axgbe_phy_get_comm_ownership()
457 static void axgbe_phy_sfp_phy_settings(struct axgbe_port *pdata) in axgbe_phy_sfp_phy_settings() argument
459 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_sfp_phy_settings()
462 pdata->phy.speed = SPEED_UNKNOWN; in axgbe_phy_sfp_phy_settings()
463 pdata->phy.duplex = DUPLEX_UNKNOWN; in axgbe_phy_sfp_phy_settings()
464 pdata->phy.autoneg = AUTONEG_ENABLE; in axgbe_phy_sfp_phy_settings()
465 pdata->phy.advertising = pdata->phy.supported; in axgbe_phy_sfp_phy_settings()
468 pdata->phy.advertising &= ~ADVERTISED_Autoneg; in axgbe_phy_sfp_phy_settings()
469 pdata->phy.advertising &= ~ADVERTISED_TP; in axgbe_phy_sfp_phy_settings()
470 pdata->phy.advertising &= ~ADVERTISED_FIBRE; in axgbe_phy_sfp_phy_settings()
471 pdata->phy.advertising &= ~ADVERTISED_100baseT_Full; in axgbe_phy_sfp_phy_settings()
472 pdata->phy.advertising &= ~ADVERTISED_1000baseT_Full; in axgbe_phy_sfp_phy_settings()
473 pdata->phy.advertising &= ~ADVERTISED_10000baseT_Full; in axgbe_phy_sfp_phy_settings()
474 pdata->phy.advertising &= ~ADVERTISED_10000baseR_FEC; in axgbe_phy_sfp_phy_settings()
481 pdata->phy.speed = SPEED_UNKNOWN; in axgbe_phy_sfp_phy_settings()
482 pdata->phy.duplex = DUPLEX_UNKNOWN; in axgbe_phy_sfp_phy_settings()
483 pdata->phy.autoneg = AUTONEG_ENABLE; in axgbe_phy_sfp_phy_settings()
484 pdata->phy.advertising |= ADVERTISED_Autoneg; in axgbe_phy_sfp_phy_settings()
492 pdata->phy.speed = SPEED_10000; in axgbe_phy_sfp_phy_settings()
493 pdata->phy.duplex = DUPLEX_FULL; in axgbe_phy_sfp_phy_settings()
494 pdata->phy.autoneg = AUTONEG_DISABLE; in axgbe_phy_sfp_phy_settings()
502 pdata->phy.advertising |= ADVERTISED_TP; in axgbe_phy_sfp_phy_settings()
505 pdata->phy.advertising |= ADVERTISED_FIBRE; in axgbe_phy_sfp_phy_settings()
511 pdata->phy.advertising |= ADVERTISED_100baseT_Full; in axgbe_phy_sfp_phy_settings()
513 pdata->phy.advertising |= ADVERTISED_1000baseT_Full; in axgbe_phy_sfp_phy_settings()
517 pdata->phy.advertising |= ADVERTISED_1000baseT_Full; in axgbe_phy_sfp_phy_settings()
521 pdata->phy.advertising |= ADVERTISED_10000baseT_Full; in axgbe_phy_sfp_phy_settings()
526 pdata->phy.advertising |= ADVERTISED_10000baseT_Full; in axgbe_phy_sfp_phy_settings()
528 pdata->phy.advertising |= ADVERTISED_1000baseT_Full; in axgbe_phy_sfp_phy_settings()
530 pdata->phy.advertising |= ADVERTISED_100baseT_Full; in axgbe_phy_sfp_phy_settings()
558 static void axgbe_phy_sfp_external_phy(struct axgbe_port *pdata) in axgbe_phy_sfp_external_phy() argument
560 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_sfp_external_phy()
571 static bool axgbe_phy_belfuse_parse_quirks(struct axgbe_port *pdata) in axgbe_phy_belfuse_parse_quirks() argument
573 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_belfuse_parse_quirks()
591 static bool axgbe_phy_sfp_parse_quirks(struct axgbe_port *pdata) in axgbe_phy_sfp_parse_quirks() argument
593 if (axgbe_phy_belfuse_parse_quirks(pdata)) in axgbe_phy_sfp_parse_quirks()
599 static void axgbe_phy_sfp_parse_eeprom(struct axgbe_port *pdata) in axgbe_phy_sfp_parse_eeprom() argument
601 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_sfp_parse_eeprom()
613 axgbe_phy_sfp_parse_quirks(pdata); in axgbe_phy_sfp_parse_eeprom()
677 static int axgbe_phy_sfp_read_eeprom(struct axgbe_port *pdata) in axgbe_phy_sfp_read_eeprom() argument
679 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_sfp_read_eeprom()
684 ret = axgbe_phy_sfp_get_mux(pdata); in axgbe_phy_sfp_read_eeprom()
692 ret = axgbe_phy_i2c_read(pdata, AXGBE_SFP_SERIAL_ID_ADDRESS, in axgbe_phy_sfp_read_eeprom()
732 axgbe_phy_sfp_put_mux(pdata); in axgbe_phy_sfp_read_eeprom()
737 static void axgbe_phy_sfp_signals(struct axgbe_port *pdata) in axgbe_phy_sfp_signals() argument
739 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_sfp_signals()
746 ret = axgbe_phy_i2c_read(pdata, phy_data->sfp_gpio_address, in axgbe_phy_sfp_signals()
773 static void axgbe_phy_sfp_mod_absent(struct axgbe_port *pdata) in axgbe_phy_sfp_mod_absent() argument
775 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_sfp_mod_absent()
819 static void axgbe_phy_sfp_detect(struct axgbe_port *pdata) in axgbe_phy_sfp_detect() argument
821 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_sfp_detect()
827 ret = axgbe_phy_get_comm_ownership(pdata); in axgbe_phy_sfp_detect()
832 axgbe_phy_sfp_signals(pdata); in axgbe_phy_sfp_detect()
834 axgbe_phy_sfp_mod_absent(pdata); in axgbe_phy_sfp_detect()
838 ret = axgbe_phy_sfp_read_eeprom(pdata); in axgbe_phy_sfp_detect()
842 axgbe_phy_sfp_mod_absent(pdata); in axgbe_phy_sfp_detect()
846 axgbe_phy_sfp_parse_eeprom(pdata); in axgbe_phy_sfp_detect()
847 axgbe_phy_sfp_external_phy(pdata); in axgbe_phy_sfp_detect()
853 axgbe_phy_sfp_phy_settings(pdata); in axgbe_phy_sfp_detect()
854 axgbe_phy_put_comm_ownership(pdata); in axgbe_phy_sfp_detect()
857 static void axgbe_phy_phydev_flowctrl(struct axgbe_port *pdata) in axgbe_phy_phydev_flowctrl() argument
859 pdata->phy.tx_pause = 0; in axgbe_phy_phydev_flowctrl()
860 pdata->phy.rx_pause = 0; in axgbe_phy_phydev_flowctrl()
863 static enum axgbe_mode axgbe_phy_an73_redrv_outcome(struct axgbe_port *pdata) in axgbe_phy_an73_redrv_outcome() argument
865 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_an73_redrv_outcome()
869 pdata->phy.lp_advertising |= ADVERTISED_Autoneg; in axgbe_phy_an73_redrv_outcome()
870 pdata->phy.lp_advertising |= ADVERTISED_Backplane; in axgbe_phy_an73_redrv_outcome()
873 if (pdata->phy.pause_autoneg) in axgbe_phy_an73_redrv_outcome()
874 axgbe_phy_phydev_flowctrl(pdata); in axgbe_phy_an73_redrv_outcome()
877 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 1); in axgbe_phy_an73_redrv_outcome()
878 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA + 1); in axgbe_phy_an73_redrv_outcome()
880 pdata->phy.lp_advertising |= ADVERTISED_10000baseKR_Full; in axgbe_phy_an73_redrv_outcome()
882 pdata->phy.lp_advertising |= ADVERTISED_1000baseKX_Full; in axgbe_phy_an73_redrv_outcome()
924 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 2); in axgbe_phy_an73_redrv_outcome()
925 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA + 2); in axgbe_phy_an73_redrv_outcome()
927 pdata->phy.lp_advertising |= ADVERTISED_10000baseR_FEC; in axgbe_phy_an73_redrv_outcome()
932 static enum axgbe_mode axgbe_phy_an73_outcome(struct axgbe_port *pdata) in axgbe_phy_an73_outcome() argument
937 pdata->phy.lp_advertising |= ADVERTISED_Autoneg; in axgbe_phy_an73_outcome()
938 pdata->phy.lp_advertising |= ADVERTISED_Backplane; in axgbe_phy_an73_outcome()
941 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE); in axgbe_phy_an73_outcome()
942 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA); in axgbe_phy_an73_outcome()
944 pdata->phy.lp_advertising |= ADVERTISED_Pause; in axgbe_phy_an73_outcome()
946 pdata->phy.lp_advertising |= ADVERTISED_Asym_Pause; in axgbe_phy_an73_outcome()
948 if (pdata->phy.pause_autoneg) { in axgbe_phy_an73_outcome()
950 pdata->phy.tx_pause = 0; in axgbe_phy_an73_outcome()
951 pdata->phy.rx_pause = 0; in axgbe_phy_an73_outcome()
954 pdata->phy.tx_pause = 1; in axgbe_phy_an73_outcome()
955 pdata->phy.rx_pause = 1; in axgbe_phy_an73_outcome()
958 pdata->phy.rx_pause = 1; in axgbe_phy_an73_outcome()
960 pdata->phy.tx_pause = 1; in axgbe_phy_an73_outcome()
965 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 1); in axgbe_phy_an73_outcome()
966 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA + 1); in axgbe_phy_an73_outcome()
968 pdata->phy.lp_advertising |= ADVERTISED_10000baseKR_Full; in axgbe_phy_an73_outcome()
970 pdata->phy.lp_advertising |= ADVERTISED_1000baseKX_Full; in axgbe_phy_an73_outcome()
981 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 2); in axgbe_phy_an73_outcome()
982 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA + 2); in axgbe_phy_an73_outcome()
984 pdata->phy.lp_advertising |= ADVERTISED_10000baseR_FEC; in axgbe_phy_an73_outcome()
989 static enum axgbe_mode axgbe_phy_an37_sgmii_outcome(struct axgbe_port *pdata) in axgbe_phy_an37_sgmii_outcome() argument
993 pdata->phy.lp_advertising |= ADVERTISED_Autoneg; in axgbe_phy_an37_sgmii_outcome()
994 pdata->phy.lp_advertising |= ADVERTISED_1000baseT_Full; in axgbe_phy_an37_sgmii_outcome()
996 if (pdata->phy.pause_autoneg) in axgbe_phy_an37_sgmii_outcome()
997 axgbe_phy_phydev_flowctrl(pdata); in axgbe_phy_an37_sgmii_outcome()
999 switch (pdata->an_status & AXGBE_SGMII_AN_LINK_SPEED) { in axgbe_phy_an37_sgmii_outcome()
1001 if (pdata->an_status & AXGBE_SGMII_AN_LINK_DUPLEX) { in axgbe_phy_an37_sgmii_outcome()
1002 pdata->phy.lp_advertising |= ADVERTISED_100baseT_Full; in axgbe_phy_an37_sgmii_outcome()
1009 if (pdata->an_status & AXGBE_SGMII_AN_LINK_DUPLEX) { in axgbe_phy_an37_sgmii_outcome()
1010 pdata->phy.lp_advertising |= ADVERTISED_1000baseT_Full; in axgbe_phy_an37_sgmii_outcome()
1024 static enum axgbe_mode axgbe_phy_an_outcome(struct axgbe_port *pdata) in axgbe_phy_an_outcome() argument
1026 switch (pdata->an_mode) { in axgbe_phy_an_outcome()
1028 return axgbe_phy_an73_outcome(pdata); in axgbe_phy_an_outcome()
1030 return axgbe_phy_an73_redrv_outcome(pdata); in axgbe_phy_an_outcome()
1033 return axgbe_phy_an37_sgmii_outcome(pdata); in axgbe_phy_an_outcome()
1039 static unsigned int axgbe_phy_an_advertising(struct axgbe_port *pdata) in axgbe_phy_an_advertising() argument
1041 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_an_advertising()
1046 return pdata->phy.advertising; in axgbe_phy_an_advertising()
1049 advertising = pdata->phy.advertising; in axgbe_phy_an_advertising()
1092 static int axgbe_phy_an_config(struct axgbe_port *pdata __rte_unused) in axgbe_phy_an_config()
1114 static enum axgbe_an_mode axgbe_phy_an_mode(struct axgbe_port *pdata) in axgbe_phy_an_mode() argument
1116 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_an_mode()
1144 static int axgbe_phy_set_redrv_mode_mdio(struct axgbe_port *pdata, in axgbe_phy_set_redrv_mode_mdio() argument
1147 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_set_redrv_mode_mdio()
1153 return pdata->hw_if.write_ext_mii_regs(pdata, phy_data->redrv_addr, in axgbe_phy_set_redrv_mode_mdio()
1157 static int axgbe_phy_set_redrv_mode_i2c(struct axgbe_port *pdata, in axgbe_phy_set_redrv_mode_i2c() argument
1160 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_set_redrv_mode_i2c()
1167 ret = axgbe_phy_redrv_write(pdata, redrv_reg, mode); in axgbe_phy_set_redrv_mode_i2c()
1172 static void axgbe_phy_set_redrv_mode(struct axgbe_port *pdata) in axgbe_phy_set_redrv_mode() argument
1174 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_set_redrv_mode()
1187 ret = axgbe_phy_get_comm_ownership(pdata); in axgbe_phy_set_redrv_mode()
1192 axgbe_phy_set_redrv_mode_i2c(pdata, mode); in axgbe_phy_set_redrv_mode()
1194 axgbe_phy_set_redrv_mode_mdio(pdata, mode); in axgbe_phy_set_redrv_mode()
1196 axgbe_phy_put_comm_ownership(pdata); in axgbe_phy_set_redrv_mode()
1199 static void axgbe_phy_start_ratechange(struct axgbe_port *pdata) in axgbe_phy_start_ratechange() argument
1202 if (XP_IOREAD_BITS(pdata, XP_DRIVER_INT_RO, STATUS)) in axgbe_phy_start_ratechange()
1208 static void axgbe_phy_complete_ratechange(struct axgbe_port *pdata) in axgbe_phy_complete_ratechange() argument
1215 if (!XP_IOREAD_BITS(pdata, XP_DRIVER_INT_RO, STATUS)) in axgbe_phy_complete_ratechange()
1223 static void axgbe_phy_rrc(struct axgbe_port *pdata) in axgbe_phy_rrc() argument
1227 axgbe_phy_start_ratechange(pdata); in axgbe_phy_rrc()
1235 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_0, s0); in axgbe_phy_rrc()
1236 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_1, 0); in axgbe_phy_rrc()
1237 XP_IOWRITE_BITS(pdata, XP_DRIVER_INT_REQ, REQUEST, 1); in axgbe_phy_rrc()
1239 axgbe_phy_complete_ratechange(pdata); in axgbe_phy_rrc()
1244 static void axgbe_phy_power_off(struct axgbe_port *pdata) in axgbe_phy_power_off() argument
1246 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_power_off()
1248 axgbe_phy_start_ratechange(pdata); in axgbe_phy_power_off()
1251 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_0, 0); in axgbe_phy_power_off()
1252 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_1, 0); in axgbe_phy_power_off()
1253 XP_IOWRITE_BITS(pdata, XP_DRIVER_INT_REQ, REQUEST, 1); in axgbe_phy_power_off()
1254 axgbe_phy_complete_ratechange(pdata); in axgbe_phy_power_off()
1260 static void axgbe_phy_sfi_mode(struct axgbe_port *pdata) in axgbe_phy_sfi_mode() argument
1262 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_sfi_mode()
1265 axgbe_phy_set_redrv_mode(pdata); in axgbe_phy_sfi_mode()
1267 axgbe_phy_start_ratechange(pdata); in axgbe_phy_sfi_mode()
1284 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_0, s0); in axgbe_phy_sfi_mode()
1285 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_1, 0); in axgbe_phy_sfi_mode()
1286 XP_IOWRITE_BITS(pdata, XP_DRIVER_INT_REQ, REQUEST, 1); in axgbe_phy_sfi_mode()
1287 axgbe_phy_complete_ratechange(pdata); in axgbe_phy_sfi_mode()
1293 static void axgbe_phy_kr_mode(struct axgbe_port *pdata) in axgbe_phy_kr_mode() argument
1295 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_kr_mode()
1298 axgbe_phy_set_redrv_mode(pdata); in axgbe_phy_kr_mode()
1300 axgbe_phy_start_ratechange(pdata); in axgbe_phy_kr_mode()
1308 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_0, s0); in axgbe_phy_kr_mode()
1309 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_1, 0); in axgbe_phy_kr_mode()
1310 XP_IOWRITE_BITS(pdata, XP_DRIVER_INT_REQ, REQUEST, 1); in axgbe_phy_kr_mode()
1311 axgbe_phy_complete_ratechange(pdata); in axgbe_phy_kr_mode()
1317 static void axgbe_phy_kx_2500_mode(struct axgbe_port *pdata) in axgbe_phy_kx_2500_mode() argument
1319 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_kx_2500_mode()
1322 axgbe_phy_set_redrv_mode(pdata); in axgbe_phy_kx_2500_mode()
1324 axgbe_phy_start_ratechange(pdata); in axgbe_phy_kx_2500_mode()
1329 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_0, s0); in axgbe_phy_kx_2500_mode()
1330 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_1, 0); in axgbe_phy_kx_2500_mode()
1332 XP_IOWRITE_BITS(pdata, XP_DRIVER_INT_REQ, REQUEST, 1); in axgbe_phy_kx_2500_mode()
1337 static void axgbe_phy_sgmii_1000_mode(struct axgbe_port *pdata) in axgbe_phy_sgmii_1000_mode() argument
1339 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_sgmii_1000_mode()
1342 axgbe_phy_set_redrv_mode(pdata); in axgbe_phy_sgmii_1000_mode()
1345 axgbe_phy_start_ratechange(pdata); in axgbe_phy_sgmii_1000_mode()
1350 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_0, s0); in axgbe_phy_sgmii_1000_mode()
1351 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_1, 0); in axgbe_phy_sgmii_1000_mode()
1353 XP_IOWRITE_BITS(pdata, XP_DRIVER_INT_REQ, REQUEST, 1); in axgbe_phy_sgmii_1000_mode()
1358 static enum axgbe_mode axgbe_phy_cur_mode(struct axgbe_port *pdata) in axgbe_phy_cur_mode() argument
1360 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_cur_mode()
1365 static enum axgbe_mode axgbe_phy_switch_baset_mode(struct axgbe_port *pdata) in axgbe_phy_switch_baset_mode() argument
1367 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_switch_baset_mode()
1371 return axgbe_phy_cur_mode(pdata); in axgbe_phy_switch_baset_mode()
1373 switch (axgbe_phy_cur_mode(pdata)) { in axgbe_phy_switch_baset_mode()
1383 static enum axgbe_mode axgbe_phy_switch_bp_2500_mode(struct axgbe_port *pdata in axgbe_phy_switch_bp_2500_mode()
1389 static enum axgbe_mode axgbe_phy_switch_bp_mode(struct axgbe_port *pdata) in axgbe_phy_switch_bp_mode() argument
1392 switch (axgbe_phy_cur_mode(pdata)) { in axgbe_phy_switch_bp_mode()
1401 static enum axgbe_mode axgbe_phy_switch_mode(struct axgbe_port *pdata) in axgbe_phy_switch_mode() argument
1403 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_switch_mode()
1407 return axgbe_phy_switch_bp_mode(pdata); in axgbe_phy_switch_mode()
1409 return axgbe_phy_switch_bp_2500_mode(pdata); in axgbe_phy_switch_mode()
1413 return axgbe_phy_switch_baset_mode(pdata); in axgbe_phy_switch_mode()
1418 return axgbe_phy_cur_mode(pdata); in axgbe_phy_switch_mode()
1495 static enum axgbe_mode axgbe_phy_get_mode(struct axgbe_port *pdata, in axgbe_phy_get_mode() argument
1498 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_get_mode()
1519 static void axgbe_phy_set_mode(struct axgbe_port *pdata, enum axgbe_mode mode) in axgbe_phy_set_mode() argument
1523 axgbe_phy_kr_mode(pdata); in axgbe_phy_set_mode()
1526 axgbe_phy_sfi_mode(pdata); in axgbe_phy_set_mode()
1529 axgbe_phy_kx_2500_mode(pdata); in axgbe_phy_set_mode()
1532 axgbe_phy_sgmii_1000_mode(pdata); in axgbe_phy_set_mode()
1539 static bool axgbe_phy_check_mode(struct axgbe_port *pdata, in axgbe_phy_check_mode() argument
1542 if (pdata->phy.autoneg == AUTONEG_ENABLE) { in axgbe_phy_check_mode()
1543 if (pdata->phy.advertising & advert) in axgbe_phy_check_mode()
1548 cur_mode = axgbe_phy_get_mode(pdata, pdata->phy.speed); in axgbe_phy_check_mode()
1556 static bool axgbe_phy_use_basex_mode(struct axgbe_port *pdata, in axgbe_phy_use_basex_mode() argument
1561 return axgbe_phy_check_mode(pdata, mode, in axgbe_phy_use_basex_mode()
1564 return axgbe_phy_check_mode(pdata, mode, in axgbe_phy_use_basex_mode()
1571 static bool axgbe_phy_use_baset_mode(struct axgbe_port *pdata, in axgbe_phy_use_baset_mode() argument
1576 return axgbe_phy_check_mode(pdata, mode, in axgbe_phy_use_baset_mode()
1579 return axgbe_phy_check_mode(pdata, mode, in axgbe_phy_use_baset_mode()
1582 return axgbe_phy_check_mode(pdata, mode, in axgbe_phy_use_baset_mode()
1589 static bool axgbe_phy_use_sfp_mode(struct axgbe_port *pdata, in axgbe_phy_use_sfp_mode() argument
1592 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_use_sfp_mode()
1598 return axgbe_phy_check_mode(pdata, mode, in axgbe_phy_use_sfp_mode()
1603 return axgbe_phy_check_mode(pdata, mode, in axgbe_phy_use_sfp_mode()
1608 return axgbe_phy_check_mode(pdata, mode, in axgbe_phy_use_sfp_mode()
1611 return axgbe_phy_check_mode(pdata, mode, in axgbe_phy_use_sfp_mode()
1618 static bool axgbe_phy_use_bp_2500_mode(struct axgbe_port *pdata, in axgbe_phy_use_bp_2500_mode() argument
1623 return axgbe_phy_check_mode(pdata, mode, in axgbe_phy_use_bp_2500_mode()
1630 static bool axgbe_phy_use_bp_mode(struct axgbe_port *pdata, in axgbe_phy_use_bp_mode() argument
1635 return axgbe_phy_check_mode(pdata, mode, in axgbe_phy_use_bp_mode()
1638 return axgbe_phy_check_mode(pdata, mode, in axgbe_phy_use_bp_mode()
1645 static bool axgbe_phy_use_mode(struct axgbe_port *pdata, enum axgbe_mode mode) in axgbe_phy_use_mode() argument
1647 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_use_mode()
1651 return axgbe_phy_use_bp_mode(pdata, mode); in axgbe_phy_use_mode()
1653 return axgbe_phy_use_bp_2500_mode(pdata, mode); in axgbe_phy_use_mode()
1657 return axgbe_phy_use_baset_mode(pdata, mode); in axgbe_phy_use_mode()
1660 return axgbe_phy_use_basex_mode(pdata, mode); in axgbe_phy_use_mode()
1662 return axgbe_phy_use_sfp_mode(pdata, mode); in axgbe_phy_use_mode()
1668 static int axgbe_phy_link_status(struct axgbe_port *pdata, int *an_restart) in axgbe_phy_link_status() argument
1670 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_link_status()
1677 axgbe_phy_sfp_detect(pdata); in axgbe_phy_link_status()
1691 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); in axgbe_phy_link_status()
1692 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); in axgbe_phy_link_status()
1699 axgbe_phy_rrc(pdata); in axgbe_phy_link_status()
1705 static void axgbe_phy_sfp_gpio_setup(struct axgbe_port *pdata) in axgbe_phy_sfp_gpio_setup() argument
1707 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_sfp_gpio_setup()
1710 reg = XP_IOREAD(pdata, XP_PROP_3); in axgbe_phy_sfp_gpio_setup()
1727 static void axgbe_phy_sfp_comm_setup(struct axgbe_port *pdata) in axgbe_phy_sfp_comm_setup() argument
1729 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_sfp_comm_setup()
1732 reg = XP_IOREAD(pdata, XP_PROP_4); in axgbe_phy_sfp_comm_setup()
1744 static void axgbe_phy_sfp_setup(struct axgbe_port *pdata) in axgbe_phy_sfp_setup() argument
1746 axgbe_phy_sfp_comm_setup(pdata); in axgbe_phy_sfp_setup()
1747 axgbe_phy_sfp_gpio_setup(pdata); in axgbe_phy_sfp_setup()
1774 static int axgbe_phy_mdio_reset_setup(struct axgbe_port *pdata) in axgbe_phy_mdio_reset_setup() argument
1776 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_mdio_reset_setup()
1781 reg = XP_IOREAD(pdata, XP_PROP_3); in axgbe_phy_mdio_reset_setup()
1807 static bool axgbe_phy_port_mode_mismatch(struct axgbe_port *pdata) in axgbe_phy_port_mode_mismatch() argument
1809 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_port_mode_mismatch()
1859 static bool axgbe_phy_conn_type_mismatch(struct axgbe_port *pdata) in axgbe_phy_conn_type_mismatch() argument
1861 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_conn_type_mismatch()
1888 static bool axgbe_phy_port_enabled(struct axgbe_port *pdata) in axgbe_phy_port_enabled() argument
1892 reg = XP_IOREAD(pdata, XP_PROP_0); in axgbe_phy_port_enabled()
1901 static void axgbe_phy_cdr_track(struct axgbe_port *pdata) in axgbe_phy_cdr_track() argument
1903 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_cdr_track()
1905 if (!pdata->vdata->an_cdr_workaround) in axgbe_phy_cdr_track()
1913 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_VEND2_PMA_CDR_CONTROL, in axgbe_phy_cdr_track()
1920 static void axgbe_phy_cdr_notrack(struct axgbe_port *pdata) in axgbe_phy_cdr_notrack() argument
1922 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_cdr_notrack()
1924 if (!pdata->vdata->an_cdr_workaround) in axgbe_phy_cdr_notrack()
1930 XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_VEND2_PMA_CDR_CONTROL, in axgbe_phy_cdr_notrack()
1934 axgbe_phy_rrc(pdata); in axgbe_phy_cdr_notrack()
1939 static void axgbe_phy_kr_training_post(struct axgbe_port *pdata) in axgbe_phy_kr_training_post() argument
1941 if (!pdata->cdr_track_early) in axgbe_phy_kr_training_post()
1942 axgbe_phy_cdr_track(pdata); in axgbe_phy_kr_training_post()
1945 static void axgbe_phy_kr_training_pre(struct axgbe_port *pdata) in axgbe_phy_kr_training_pre() argument
1947 if (pdata->cdr_track_early) in axgbe_phy_kr_training_pre()
1948 axgbe_phy_cdr_track(pdata); in axgbe_phy_kr_training_pre()
1951 static void axgbe_phy_an_post(struct axgbe_port *pdata) in axgbe_phy_an_post() argument
1953 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_an_post()
1955 switch (pdata->an_mode) { in axgbe_phy_an_post()
1961 axgbe_phy_cdr_track(pdata); in axgbe_phy_an_post()
1963 switch (pdata->an_result) { in axgbe_phy_an_post()
1978 static void axgbe_phy_an_pre(struct axgbe_port *pdata) in axgbe_phy_an_pre() argument
1980 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_an_pre()
1982 switch (pdata->an_mode) { in axgbe_phy_an_pre()
1988 axgbe_phy_cdr_notrack(pdata); in axgbe_phy_an_pre()
1995 static void axgbe_phy_stop(struct axgbe_port *pdata) in axgbe_phy_stop() argument
1997 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_stop()
2001 axgbe_phy_sfp_mod_absent(pdata); in axgbe_phy_stop()
2004 axgbe_phy_cdr_track(pdata); in axgbe_phy_stop()
2007 axgbe_phy_power_off(pdata); in axgbe_phy_stop()
2010 pdata->i2c_if.i2c_stop(pdata); in axgbe_phy_stop()
2013 static int axgbe_phy_start(struct axgbe_port *pdata) in axgbe_phy_start() argument
2015 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_start()
2019 ret = pdata->i2c_if.i2c_start(pdata); in axgbe_phy_start()
2024 axgbe_phy_set_mode(pdata, phy_data->start_mode); in axgbe_phy_start()
2027 axgbe_phy_cdr_track(pdata); in axgbe_phy_start()
2032 axgbe_phy_sfp_detect(pdata); in axgbe_phy_start()
2037 pdata->phy.advertising &= axgbe_phy_an_advertising(pdata); in axgbe_phy_start()
2042 static int axgbe_phy_reset(struct axgbe_port *pdata) in axgbe_phy_reset() argument
2044 struct axgbe_phy_data *phy_data = pdata->phy_data; in axgbe_phy_reset()
2049 axgbe_phy_power_off(pdata); in axgbe_phy_reset()
2051 axgbe_phy_set_mode(pdata, cur_mode); in axgbe_phy_reset()
2055 static int axgbe_phy_init(struct axgbe_port *pdata) in axgbe_phy_init() argument
2062 if (!axgbe_phy_port_enabled(pdata)) { in axgbe_phy_init()
2068 ret = pdata->i2c_if.i2c_init(pdata); in axgbe_phy_init()
2077 pdata->phy_data = phy_data; in axgbe_phy_init()
2079 reg = XP_IOREAD(pdata, XP_PROP_0); in axgbe_phy_init()
2086 reg = XP_IOREAD(pdata, XP_PROP_4); in axgbe_phy_init()
2094 if (axgbe_phy_conn_type_mismatch(pdata)) { in axgbe_phy_init()
2101 if (axgbe_phy_port_mode_mismatch(pdata)) { in axgbe_phy_init()
2108 ret = axgbe_phy_mdio_reset_setup(pdata); in axgbe_phy_init()
2117 pdata->kr_redrv = phy_data->redrv; in axgbe_phy_init()
2123 pdata->phy.supported = 0; in axgbe_phy_init()
2128 pdata->phy.supported |= SUPPORTED_Autoneg; in axgbe_phy_init()
2129 pdata->phy.supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause; in axgbe_phy_init()
2130 pdata->phy.supported |= SUPPORTED_Backplane; in axgbe_phy_init()
2132 pdata->phy.supported |= SUPPORTED_1000baseKX_Full; in axgbe_phy_init()
2136 pdata->phy.supported |= SUPPORTED_10000baseKR_Full; in axgbe_phy_init()
2137 if (pdata->fec_ability & MDIO_PMA_10GBR_FECABLE_ABLE) in axgbe_phy_init()
2138 pdata->phy.supported |= in axgbe_phy_init()
2146 pdata->phy.supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause; in axgbe_phy_init()
2147 pdata->phy.supported |= SUPPORTED_Backplane; in axgbe_phy_init()
2148 pdata->phy.supported |= SUPPORTED_2500baseX_Full; in axgbe_phy_init()
2156 pdata->phy.supported |= SUPPORTED_Autoneg; in axgbe_phy_init()
2157 pdata->phy.supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause; in axgbe_phy_init()
2158 pdata->phy.supported |= SUPPORTED_TP; in axgbe_phy_init()
2160 pdata->phy.supported |= SUPPORTED_100baseT_Full; in axgbe_phy_init()
2164 pdata->phy.supported |= SUPPORTED_1000baseT_Full; in axgbe_phy_init()
2173 pdata->phy.supported |= SUPPORTED_Autoneg; in axgbe_phy_init()
2174 pdata->phy.supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause; in axgbe_phy_init()
2175 pdata->phy.supported |= SUPPORTED_FIBRE; in axgbe_phy_init()
2176 pdata->phy.supported |= SUPPORTED_1000baseT_Full; in axgbe_phy_init()
2184 pdata->phy.supported |= SUPPORTED_Autoneg; in axgbe_phy_init()
2185 pdata->phy.supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause; in axgbe_phy_init()
2186 pdata->phy.supported |= SUPPORTED_TP; in axgbe_phy_init()
2188 pdata->phy.supported |= SUPPORTED_100baseT_Full; in axgbe_phy_init()
2192 pdata->phy.supported |= SUPPORTED_1000baseT_Full; in axgbe_phy_init()
2196 pdata->phy.supported |= SUPPORTED_2500baseX_Full; in axgbe_phy_init()
2205 pdata->phy.supported |= SUPPORTED_Autoneg; in axgbe_phy_init()
2206 pdata->phy.supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause; in axgbe_phy_init()
2207 pdata->phy.supported |= SUPPORTED_TP; in axgbe_phy_init()
2209 pdata->phy.supported |= SUPPORTED_100baseT_Full; in axgbe_phy_init()
2213 pdata->phy.supported |= SUPPORTED_1000baseT_Full; in axgbe_phy_init()
2217 pdata->phy.supported |= SUPPORTED_10000baseT_Full; in axgbe_phy_init()
2226 pdata->phy.supported |= SUPPORTED_Autoneg; in axgbe_phy_init()
2227 pdata->phy.supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause; in axgbe_phy_init()
2228 pdata->phy.supported |= SUPPORTED_TP; in axgbe_phy_init()
2229 pdata->phy.supported |= SUPPORTED_10000baseT_Full; in axgbe_phy_init()
2230 if (pdata->fec_ability & MDIO_PMA_10GBR_FECABLE_ABLE) in axgbe_phy_init()
2231 pdata->phy.supported |= SUPPORTED_10000baseR_FEC; in axgbe_phy_init()
2239 pdata->phy.supported |= SUPPORTED_Autoneg; in axgbe_phy_init()
2240 pdata->phy.supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause; in axgbe_phy_init()
2241 pdata->phy.supported |= SUPPORTED_TP; in axgbe_phy_init()
2242 pdata->phy.supported |= SUPPORTED_FIBRE; in axgbe_phy_init()
2244 pdata->phy.supported |= SUPPORTED_100baseT_Full; in axgbe_phy_init()
2248 pdata->phy.supported |= SUPPORTED_1000baseT_Full; in axgbe_phy_init()
2252 pdata->phy.supported |= SUPPORTED_10000baseT_Full; in axgbe_phy_init()
2254 if (pdata->fec_ability & MDIO_PMA_10GBR_FECABLE_ABLE) in axgbe_phy_init()
2255 pdata->phy.supported |= in axgbe_phy_init()
2261 axgbe_phy_sfp_setup(pdata); in axgbe_phy_init()
2269 ret = pdata->hw_if.set_ext_mii_mode(pdata, phy_data->mdio_addr, in axgbe_phy_init()
2279 ret = pdata->hw_if.set_ext_mii_mode(pdata, phy_data->redrv_addr, in axgbe_phy_init()