Lines Matching full:phydev
192 static int air_phy_read_page(struct phy_device *phydev) in air_phy_read_page() argument
194 return __phy_read(phydev, AIR_EXT_PAGE_ACCESS); in air_phy_read_page()
197 static int air_phy_write_page(struct phy_device *phydev, int page) in air_phy_write_page() argument
199 return __phy_write(phydev, AIR_EXT_PAGE_ACCESS, page); in air_phy_write_page()
202 static int __air_buckpbus_reg_write(struct phy_device *phydev, in __air_buckpbus_reg_write() argument
207 ret = __phy_write(phydev, AIR_BPBUS_MODE, AIR_BPBUS_MODE_ADDR_FIXED); in __air_buckpbus_reg_write()
211 ret = __phy_write(phydev, AIR_BPBUS_WR_ADDR_HIGH, in __air_buckpbus_reg_write()
216 ret = __phy_write(phydev, AIR_BPBUS_WR_ADDR_LOW, in __air_buckpbus_reg_write()
221 ret = __phy_write(phydev, AIR_BPBUS_WR_DATA_HIGH, in __air_buckpbus_reg_write()
226 ret = __phy_write(phydev, AIR_BPBUS_WR_DATA_LOW, in __air_buckpbus_reg_write()
234 static int air_buckpbus_reg_write(struct phy_device *phydev, in air_buckpbus_reg_write() argument
240 saved_page = phy_select_page(phydev, AIR_PHY_PAGE_EXTENDED_4); in air_buckpbus_reg_write()
243 ret = __air_buckpbus_reg_write(phydev, pbus_address, in air_buckpbus_reg_write()
246 phydev_err(phydev, "%s 0x%08x failed: %d\n", __func__, in air_buckpbus_reg_write()
250 return phy_restore_page(phydev, saved_page, ret); in air_buckpbus_reg_write()
253 static int __air_buckpbus_reg_read(struct phy_device *phydev, in __air_buckpbus_reg_read() argument
259 ret = __phy_write(phydev, AIR_BPBUS_MODE, AIR_BPBUS_MODE_ADDR_FIXED); in __air_buckpbus_reg_read()
263 ret = __phy_write(phydev, AIR_BPBUS_RD_ADDR_HIGH, in __air_buckpbus_reg_read()
268 ret = __phy_write(phydev, AIR_BPBUS_RD_ADDR_LOW, in __air_buckpbus_reg_read()
273 pbus_data_high = __phy_read(phydev, AIR_BPBUS_RD_DATA_HIGH); in __air_buckpbus_reg_read()
277 pbus_data_low = __phy_read(phydev, AIR_BPBUS_RD_DATA_LOW); in __air_buckpbus_reg_read()
285 static int air_buckpbus_reg_read(struct phy_device *phydev, in air_buckpbus_reg_read() argument
291 saved_page = phy_select_page(phydev, AIR_PHY_PAGE_EXTENDED_4); in air_buckpbus_reg_read()
294 ret = __air_buckpbus_reg_read(phydev, pbus_address, pbus_data); in air_buckpbus_reg_read()
296 phydev_err(phydev, "%s 0x%08x failed: %d\n", __func__, in air_buckpbus_reg_read()
300 return phy_restore_page(phydev, saved_page, ret); in air_buckpbus_reg_read()
303 static int __air_buckpbus_reg_modify(struct phy_device *phydev, in __air_buckpbus_reg_modify() argument
310 ret = __phy_write(phydev, AIR_BPBUS_MODE, AIR_BPBUS_MODE_ADDR_FIXED); in __air_buckpbus_reg_modify()
314 ret = __phy_write(phydev, AIR_BPBUS_RD_ADDR_HIGH, in __air_buckpbus_reg_modify()
319 ret = __phy_write(phydev, AIR_BPBUS_RD_ADDR_LOW, in __air_buckpbus_reg_modify()
324 pbus_data_high = __phy_read(phydev, AIR_BPBUS_RD_DATA_HIGH); in __air_buckpbus_reg_modify()
328 pbus_data_low = __phy_read(phydev, AIR_BPBUS_RD_DATA_LOW); in __air_buckpbus_reg_modify()
337 ret = __phy_write(phydev, AIR_BPBUS_WR_ADDR_HIGH, in __air_buckpbus_reg_modify()
342 ret = __phy_write(phydev, AIR_BPBUS_WR_ADDR_LOW, in __air_buckpbus_reg_modify()
347 ret = __phy_write(phydev, AIR_BPBUS_WR_DATA_HIGH, in __air_buckpbus_reg_modify()
352 ret = __phy_write(phydev, AIR_BPBUS_WR_DATA_LOW, in __air_buckpbus_reg_modify()
360 static int air_buckpbus_reg_modify(struct phy_device *phydev, in air_buckpbus_reg_modify() argument
366 saved_page = phy_select_page(phydev, AIR_PHY_PAGE_EXTENDED_4); in air_buckpbus_reg_modify()
369 ret = __air_buckpbus_reg_modify(phydev, pbus_address, mask, in air_buckpbus_reg_modify()
372 phydev_err(phydev, "%s 0x%08x failed: %d\n", __func__, in air_buckpbus_reg_modify()
376 return phy_restore_page(phydev, saved_page, ret); in air_buckpbus_reg_modify()
379 static int __air_write_buf(struct phy_device *phydev, u32 address, in __air_write_buf() argument
386 ret = __phy_write(phydev, AIR_BPBUS_MODE, AIR_BPBUS_MODE_ADDR_INCR); in __air_write_buf()
390 ret = __phy_write(phydev, AIR_BPBUS_WR_ADDR_HIGH, in __air_write_buf()
395 ret = __phy_write(phydev, AIR_BPBUS_WR_ADDR_LOW, in __air_write_buf()
402 ret = __phy_write(phydev, AIR_BPBUS_WR_DATA_HIGH, val); in __air_write_buf()
407 ret = __phy_write(phydev, AIR_BPBUS_WR_DATA_LOW, val); in __air_write_buf()
415 static int air_write_buf(struct phy_device *phydev, u32 address, in air_write_buf() argument
421 saved_page = phy_select_page(phydev, AIR_PHY_PAGE_EXTENDED_4); in air_write_buf()
424 ret = __air_write_buf(phydev, address, fw); in air_write_buf()
426 phydev_err(phydev, "%s 0x%08x failed: %d\n", __func__, in air_write_buf()
430 return phy_restore_page(phydev, saved_page, ret); in air_write_buf()
433 static int en8811h_wait_mcu_ready(struct phy_device *phydev) in en8811h_wait_mcu_ready() argument
438 ret = phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1, in en8811h_wait_mcu_ready()
443 phydev_err(phydev, "MCU not ready: 0x%x\n", reg_value); in en8811h_wait_mcu_ready()
450 static int en8811h_load_firmware(struct phy_device *phydev) in en8811h_load_firmware() argument
452 struct en8811h_priv *priv = phydev->priv; in en8811h_load_firmware()
453 struct device *dev = &phydev->mdio.dev; in en8811h_load_firmware()
465 ret = air_buckpbus_reg_write(phydev, EN8811H_FW_CTRL_1, in en8811h_load_firmware()
470 ret = air_buckpbus_reg_modify(phydev, EN8811H_FW_CTRL_2, in en8811h_load_firmware()
476 ret = air_write_buf(phydev, AIR_FW_ADDR_DM, fw1); in en8811h_load_firmware()
480 ret = air_write_buf(phydev, AIR_FW_ADDR_DSP, fw2); in en8811h_load_firmware()
484 ret = air_buckpbus_reg_modify(phydev, EN8811H_FW_CTRL_2, in en8811h_load_firmware()
489 ret = air_buckpbus_reg_write(phydev, EN8811H_FW_CTRL_1, in en8811h_load_firmware()
494 ret = en8811h_wait_mcu_ready(phydev); in en8811h_load_firmware()
496 air_buckpbus_reg_read(phydev, EN8811H_FW_VERSION, in en8811h_load_firmware()
498 phydev_info(phydev, "MD32 firmware version: %08x\n", in en8811h_load_firmware()
508 phydev_err(phydev, "Load firmware failed: %d\n", ret); in en8811h_load_firmware()
513 static int en8811h_restart_mcu(struct phy_device *phydev) in en8811h_restart_mcu() argument
517 ret = air_buckpbus_reg_write(phydev, EN8811H_FW_CTRL_1, in en8811h_restart_mcu()
522 ret = air_buckpbus_reg_write(phydev, EN8811H_FW_CTRL_1, in en8811h_restart_mcu()
527 return en8811h_wait_mcu_ready(phydev); in en8811h_restart_mcu()
530 static int air_hw_led_on_set(struct phy_device *phydev, u8 index, bool on) in air_hw_led_on_set() argument
532 struct en8811h_priv *priv = phydev->priv; in air_hw_led_on_set()
552 return phy_modify_mmd(phydev, MDIO_MMD_VEND2, in air_hw_led_on_set()
560 static int air_hw_led_blink_set(struct phy_device *phydev, u8 index, in air_hw_led_blink_set() argument
563 struct en8811h_priv *priv = phydev->priv; in air_hw_led_blink_set()
579 return phy_write_mmd(phydev, MDIO_MMD_VEND2, in air_hw_led_blink_set()
587 static int air_led_blink_set(struct phy_device *phydev, u8 index, in air_led_blink_set() argument
591 struct en8811h_priv *priv = phydev->priv; in air_led_blink_set()
604 err = air_hw_led_blink_set(phydev, index, blinking); in air_led_blink_set()
609 err = air_hw_led_on_set(phydev, index, false); in air_led_blink_set()
620 static int air_led_brightness_set(struct phy_device *phydev, u8 index, in air_led_brightness_set() argument
623 struct en8811h_priv *priv = phydev->priv; in air_led_brightness_set()
630 err = air_hw_led_blink_set(phydev, index, false); in air_led_brightness_set()
634 err = air_hw_led_on_set(phydev, index, (value != LED_OFF)); in air_led_brightness_set()
645 static int air_led_hw_control_get(struct phy_device *phydev, u8 index, in air_led_hw_control_get() argument
648 struct en8811h_priv *priv = phydev->priv; in air_led_hw_control_get()
658 static int air_led_hw_control_set(struct phy_device *phydev, u8 index, in air_led_hw_control_set() argument
661 struct en8811h_priv *priv = phydev->priv; in air_led_hw_control_set()
709 ret = phy_modify_mmd(phydev, MDIO_MMD_VEND2, AIR_PHY_LED_ON(index), in air_led_hw_control_set()
715 return phy_write_mmd(phydev, MDIO_MMD_VEND2, AIR_PHY_LED_BLINK(index), in air_led_hw_control_set()
719 static int air_led_init(struct phy_device *phydev, u8 index, u8 state, u8 pol) in air_led_init() argument
737 err = phy_modify_mmd(phydev, MDIO_MMD_VEND2, AIR_PHY_LED_ON(index), in air_led_init()
747 static int air_leds_init(struct phy_device *phydev, int num, int dur, int mode) in air_leds_init() argument
749 struct en8811h_priv *priv = phydev->priv; in air_leds_init()
752 ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, AIR_PHY_LED_DUR_BLINK, in air_leds_init()
757 ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, AIR_PHY_LED_DUR_ON, in air_leds_init()
764 ret = phy_modify_mmd(phydev, MDIO_MMD_VEND2, AIR_PHY_LED_BCR, in air_leds_init()
771 ret = phy_modify_mmd(phydev, MDIO_MMD_VEND2, AIR_PHY_LED_BCR, in air_leds_init()
780 phydev_err(phydev, "LED mode %d is not supported\n", mode); in air_leds_init()
785 ret = air_led_init(phydev, i, AIR_LED_ENABLE, AIR_ACTIVE_HIGH); in air_leds_init()
787 phydev_err(phydev, "LED%d init failed: %d\n", i, ret); in air_leds_init()
790 air_led_hw_control_set(phydev, i, priv->led[i].rules); in air_leds_init()
796 static int en8811h_led_hw_is_supported(struct phy_device *phydev, u8 index, in en8811h_led_hw_is_supported() argument
809 static int en8811h_probe(struct phy_device *phydev) in en8811h_probe() argument
814 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(struct en8811h_priv), in en8811h_probe()
818 phydev->priv = priv; in en8811h_probe()
820 ret = en8811h_load_firmware(phydev); in en8811h_probe()
832 phydev->c45_ids.mmds_present |= MDIO_DEVS_PMAPMD | MDIO_DEVS_AN; in en8811h_probe()
834 ret = air_leds_init(phydev, EN8811H_LED_COUNT, AIR_PHY_LED_DUR, in en8811h_probe()
837 phydev_err(phydev, "Failed to disable leds: %d\n", ret); in en8811h_probe()
842 ret = air_buckpbus_reg_modify(phydev, EN8811H_GPIO_OUTPUT, in en8811h_probe()
851 static int en8811h_config_init(struct phy_device *phydev) in en8811h_config_init() argument
853 struct en8811h_priv *priv = phydev->priv; in en8811h_config_init()
854 struct device *dev = &phydev->mdio.dev; in en8811h_config_init()
860 ret = en8811h_restart_mcu(phydev); in en8811h_config_init()
871 ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, AIR_PHY_MCU_CMD_1, in en8811h_config_init()
875 ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, AIR_PHY_MCU_CMD_2, in en8811h_config_init()
879 ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, AIR_PHY_MCU_CMD_3, in en8811h_config_init()
883 ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, AIR_PHY_MCU_CMD_4, in en8811h_config_init()
898 ret = air_buckpbus_reg_modify(phydev, EN8811H_POLARITY, in en8811h_config_init()
904 ret = air_leds_init(phydev, EN8811H_LED_COUNT, AIR_PHY_LED_DUR, in en8811h_config_init()
907 phydev_err(phydev, "Failed to initialize leds: %d\n", ret); in en8811h_config_init()
914 static int en8811h_get_features(struct phy_device *phydev) in en8811h_get_features() argument
918 phydev->supported); in en8811h_get_features()
920 return genphy_c45_pma_read_abilities(phydev); in en8811h_get_features()
923 static int en8811h_get_rate_matching(struct phy_device *phydev, in en8811h_get_rate_matching() argument
929 static int en8811h_config_aneg(struct phy_device *phydev) in en8811h_config_aneg() argument
935 if (phydev->autoneg == AUTONEG_DISABLE) { in en8811h_config_aneg()
936 phydev_warn(phydev, "Disabling autoneg is not supported\n"); in en8811h_config_aneg()
940 adv = linkmode_adv_to_mii_10gbt_adv_t(phydev->advertising); in en8811h_config_aneg()
942 ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL, in en8811h_config_aneg()
949 return __genphy_config_aneg(phydev, changed); in en8811h_config_aneg()
952 static int en8811h_read_status(struct phy_device *phydev) in en8811h_read_status() argument
954 struct en8811h_priv *priv = phydev->priv; in en8811h_read_status()
958 ret = genphy_update_link(phydev); in en8811h_read_status()
962 phydev->master_slave_get = MASTER_SLAVE_CFG_UNSUPPORTED; in en8811h_read_status()
963 phydev->master_slave_state = MASTER_SLAVE_STATE_UNSUPPORTED; in en8811h_read_status()
964 phydev->speed = SPEED_UNKNOWN; in en8811h_read_status()
965 phydev->duplex = DUPLEX_UNKNOWN; in en8811h_read_status()
966 phydev->pause = 0; in en8811h_read_status()
967 phydev->asym_pause = 0; in en8811h_read_status()
968 phydev->rate_matching = RATE_MATCH_PAUSE; in en8811h_read_status()
970 ret = genphy_read_master_slave(phydev); in en8811h_read_status()
974 ret = genphy_read_lpa(phydev); in en8811h_read_status()
979 ret = air_buckpbus_reg_read(phydev, EN8811H_2P5G_LPA, &pbus_value); in en8811h_read_status()
983 phydev->lp_advertising, in en8811h_read_status()
986 if (phydev->autoneg_complete) in en8811h_read_status()
987 phy_resolve_aneg_pause(phydev); in en8811h_read_status()
989 if (!phydev->link) in en8811h_read_status()
993 val = phy_read(phydev, AIR_AUX_CTRL_STATUS); in en8811h_read_status()
998 phydev->speed = SPEED_2500; in en8811h_read_status()
1001 phydev->speed = SPEED_1000; in en8811h_read_status()
1004 phydev->speed = SPEED_100; in en8811h_read_status()
1013 phydev->lp_advertising, in en8811h_read_status()
1014 phydev->speed == SPEED_2500); in en8811h_read_status()
1018 phydev->duplex = DUPLEX_FULL; in en8811h_read_status()
1023 static int en8811h_clear_intr(struct phy_device *phydev) in en8811h_clear_intr() argument
1027 ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, AIR_PHY_MCU_CMD_3, in en8811h_clear_intr()
1032 ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, AIR_PHY_MCU_CMD_4, in en8811h_clear_intr()
1040 static irqreturn_t en8811h_handle_interrupt(struct phy_device *phydev) in en8811h_handle_interrupt() argument
1044 ret = en8811h_clear_intr(phydev); in en8811h_handle_interrupt()
1046 phy_error(phydev); in en8811h_handle_interrupt()
1050 phy_trigger_machine(phydev); in en8811h_handle_interrupt()