Lines Matching full:phydev
315 static int mtk_socphy_read_page(struct phy_device *phydev) in mtk_socphy_read_page() argument
317 return __phy_read(phydev, MTK_EXT_PAGE_ACCESS); in mtk_socphy_read_page()
320 static int mtk_socphy_write_page(struct phy_device *phydev, int page) in mtk_socphy_write_page() argument
322 return __phy_write(phydev, MTK_EXT_PAGE_ACCESS, page); in mtk_socphy_write_page()
331 static int cal_cycle(struct phy_device *phydev, int devad, in cal_cycle() argument
337 phy_modify_mmd(phydev, devad, regnum, in cal_cycle()
339 phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CALIN, in cal_cycle()
342 ret = phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1, in cal_cycle()
347 phydev_err(phydev, "Calibration cycle timeout\n"); in cal_cycle()
351 phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CALIN, in cal_cycle()
353 ret = phy_read_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CAL_COMP) >> in cal_cycle()
355 phydev_dbg(phydev, "cal_val: 0x%x, ret: %d\n", cal_val, ret); in cal_cycle()
360 static int rext_fill_result(struct phy_device *phydev, u16 *buf) in rext_fill_result() argument
362 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG5, in rext_fill_result()
364 phy_modify_mmd(phydev, MDIO_MMD_VEND2, MTK_PHY_RG_BG_RASEL, in rext_fill_result()
370 static int rext_cal_efuse(struct phy_device *phydev, u32 *buf) in rext_cal_efuse() argument
376 rext_fill_result(phydev, rext_cal_val); in rext_cal_efuse()
381 static int tx_offset_fill_result(struct phy_device *phydev, u16 *buf) in tx_offset_fill_result() argument
383 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B, in tx_offset_fill_result()
385 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B, in tx_offset_fill_result()
387 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D, in tx_offset_fill_result()
389 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D, in tx_offset_fill_result()
395 static int tx_offset_cal_efuse(struct phy_device *phydev, u32 *buf) in tx_offset_cal_efuse() argument
404 tx_offset_fill_result(phydev, tx_offset_cal_val); in tx_offset_cal_efuse()
409 static int tx_amp_fill_result(struct phy_device *phydev, u16 *buf) in tx_amp_fill_result() argument
421 switch (phydev->drv->phy_id) { in tx_amp_fill_result()
442 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TXVLD_DA_RG, in tx_amp_fill_result()
444 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TXVLD_DA_RG, in tx_amp_fill_result()
446 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_A2, in tx_amp_fill_result()
448 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_A2, in tx_amp_fill_result()
451 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_B1, in tx_amp_fill_result()
453 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_B1, in tx_amp_fill_result()
455 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_B2, in tx_amp_fill_result()
457 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_B2, in tx_amp_fill_result()
460 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_C1, in tx_amp_fill_result()
462 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_C1, in tx_amp_fill_result()
464 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_C2, in tx_amp_fill_result()
466 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_C2, in tx_amp_fill_result()
469 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D1, in tx_amp_fill_result()
471 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D1, in tx_amp_fill_result()
473 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D2, in tx_amp_fill_result()
475 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D2, in tx_amp_fill_result()
481 static int tx_amp_cal_efuse(struct phy_device *phydev, u32 *buf) in tx_amp_cal_efuse() argument
489 tx_amp_fill_result(phydev, tx_amp_cal_val); in tx_amp_cal_efuse()
494 static int tx_r50_fill_result(struct phy_device *phydev, u16 tx_r50_cal_val, in tx_r50_fill_result() argument
500 if (phydev->drv->phy_id == MTK_GPHY_ID_MT7988) in tx_r50_fill_result()
522 phy_write_mmd(phydev, MDIO_MMD_VEND1, reg, val | val << 8); in tx_r50_fill_result()
527 static int tx_r50_cal_efuse(struct phy_device *phydev, u32 *buf, in tx_r50_cal_efuse() argument
548 tx_r50_fill_result(phydev, tx_r50_cal_val, txg_calen_x); in tx_r50_cal_efuse()
553 static int tx_vcm_cal_sw(struct phy_device *phydev, u8 rg_txreserve_x) in tx_vcm_cal_sw() argument
559 phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, in tx_vcm_cal_sw()
561 phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, in tx_vcm_cal_sw()
563 phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, in tx_vcm_cal_sw()
568 phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, in tx_vcm_cal_sw()
571 phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, in tx_vcm_cal_sw()
574 phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, in tx_vcm_cal_sw()
579 phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, in tx_vcm_cal_sw()
582 phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, in tx_vcm_cal_sw()
585 phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, in tx_vcm_cal_sw()
590 phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, in tx_vcm_cal_sw()
593 phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, in tx_vcm_cal_sw()
596 phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, in tx_vcm_cal_sw()
601 phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, in tx_vcm_cal_sw()
604 phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, in tx_vcm_cal_sw()
607 phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, in tx_vcm_cal_sw()
619 phydev_dbg(phydev, "Start TX-VCM SW cal.\n"); in tx_vcm_cal_sw()
622 ret = cal_cycle(phydev, MDIO_MMD_VEND1, MTK_PHY_RXADC_CTRL_RG9, in tx_vcm_cal_sw()
641 lower_ret = cal_cycle(phydev, MDIO_MMD_VEND1, in tx_vcm_cal_sw()
651 upper_ret = cal_cycle(phydev, MDIO_MMD_VEND1, in tx_vcm_cal_sw()
671 cal_cycle(phydev, MDIO_MMD_VEND1, MTK_PHY_RXADC_CTRL_RG9, in tx_vcm_cal_sw()
678 phydev_dbg(phydev, "TX-VCM SW cal result: 0x%x\n", upper_idx); in tx_vcm_cal_sw()
682 cal_cycle(phydev, MDIO_MMD_VEND1, MTK_PHY_RXADC_CTRL_RG9, in tx_vcm_cal_sw()
689 phydev_warn(phydev, "TX-VCM SW cal result at low margin 0x%x\n", in tx_vcm_cal_sw()
694 phydev_warn(phydev, "TX-VCM SW cal result at high margin 0x%x\n", in tx_vcm_cal_sw()
701 phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, in tx_vcm_cal_sw()
703 phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, in tx_vcm_cal_sw()
705 phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, in tx_vcm_cal_sw()
707 phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, in tx_vcm_cal_sw()
714 static void mt798x_phy_common_finetune(struct phy_device *phydev) in mt798x_phy_common_finetune() argument
716 phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); in mt798x_phy_common_finetune()
718 __phy_write(phydev, 0x11, 0xc71); in mt798x_phy_common_finetune()
719 __phy_write(phydev, 0x12, 0xc); in mt798x_phy_common_finetune()
720 __phy_write(phydev, 0x10, 0x8fae); in mt798x_phy_common_finetune()
723 __phy_write(phydev, 0x11, 0x2f00); in mt798x_phy_common_finetune()
724 __phy_write(phydev, 0x12, 0xe); in mt798x_phy_common_finetune()
725 __phy_write(phydev, 0x10, 0x8fb0); in mt798x_phy_common_finetune()
728 __phy_write(phydev, 0x11, 0x55a0); in mt798x_phy_common_finetune()
729 __phy_write(phydev, 0x12, 0x0); in mt798x_phy_common_finetune()
730 __phy_write(phydev, 0x10, 0x83aa); in mt798x_phy_common_finetune()
733 __phy_write(phydev, 0x11, 0x240); in mt798x_phy_common_finetune()
734 __phy_write(phydev, 0x12, 0x0); in mt798x_phy_common_finetune()
735 __phy_write(phydev, 0x10, 0x9680); in mt798x_phy_common_finetune()
738 __phy_write(phydev, 0x11, 0x0); in mt798x_phy_common_finetune()
739 __phy_write(phydev, 0x12, 0x0); in mt798x_phy_common_finetune()
740 __phy_write(phydev, 0x10, 0x9686); in mt798x_phy_common_finetune()
748 __phy_write(phydev, 0x11, 0xbaef); in mt798x_phy_common_finetune()
749 __phy_write(phydev, 0x12, 0x2e); in mt798x_phy_common_finetune()
750 __phy_write(phydev, 0x10, 0x968c); in mt798x_phy_common_finetune()
751 phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); in mt798x_phy_common_finetune()
754 static void mt7981_phy_finetune(struct phy_device *phydev) in mt7981_phy_finetune() argument
769 phy_write_mmd(phydev, MDIO_MMD_VEND1, i, val[k++]); in mt7981_phy_finetune()
772 phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); in mt7981_phy_finetune()
774 __phy_write(phydev, 0x11, 0x600); in mt7981_phy_finetune()
775 __phy_write(phydev, 0x12, 0x0); in mt7981_phy_finetune()
776 __phy_write(phydev, 0x10, 0x8fc0); in mt7981_phy_finetune()
779 __phy_write(phydev, 0x11, 0x4c2a); in mt7981_phy_finetune()
780 __phy_write(phydev, 0x12, 0x3e); in mt7981_phy_finetune()
781 __phy_write(phydev, 0x10, 0x8fa4); in mt7981_phy_finetune()
786 __phy_write(phydev, 0x11, 0xd10a); in mt7981_phy_finetune()
787 __phy_write(phydev, 0x12, 0x34); in mt7981_phy_finetune()
788 __phy_write(phydev, 0x10, 0x8f82); in mt7981_phy_finetune()
791 __phy_write(phydev, 0x11, 0x5555); in mt7981_phy_finetune()
792 __phy_write(phydev, 0x12, 0x55); in mt7981_phy_finetune()
793 __phy_write(phydev, 0x10, 0x8ec0); in mt7981_phy_finetune()
794 phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); in mt7981_phy_finetune()
797 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG234, in mt7981_phy_finetune()
802 phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LPF_CNT_VAL, 0x200); in mt7981_phy_finetune()
805 phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K1_L, 0x82); in mt7981_phy_finetune()
806 phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K1_U, 0x0); in mt7981_phy_finetune()
807 phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K2_L, 0x103); in mt7981_phy_finetune()
808 phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K2_U, 0x0); in mt7981_phy_finetune()
809 phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K3_L, 0x82); in mt7981_phy_finetune()
810 phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K3_U, 0x0); in mt7981_phy_finetune()
811 phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K4_L, 0xd177); in mt7981_phy_finetune()
812 phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K4_U, 0x3); in mt7981_phy_finetune()
813 phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K5_L, 0x2c82); in mt7981_phy_finetune()
814 phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K5_U, 0xe); in mt7981_phy_finetune()
817 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG27C, in mt7981_phy_finetune()
819 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG27D, in mt7981_phy_finetune()
823 phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_LDO_PUMP_EN_PAIRAB, 0x0); in mt7981_phy_finetune()
824 phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_LDO_PUMP_EN_PAIRCD, 0x0); in mt7981_phy_finetune()
826 phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_LDO_OUTPUT_V, 0x2222); in mt7981_phy_finetune()
829 static void mt7988_phy_finetune(struct phy_device *phydev) in mt7988_phy_finetune() argument
838 phy_write_mmd(phydev, MDIO_MMD_VEND1, i, val[i]); in mt7988_phy_finetune()
841 phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_TX_FILTER, 0x5); in mt7988_phy_finetune()
843 phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); in mt7988_phy_finetune()
845 __phy_write(phydev, 0x11, 0x500); in mt7988_phy_finetune()
846 __phy_write(phydev, 0x12, 0x0); in mt7988_phy_finetune()
847 __phy_write(phydev, 0x10, 0x8fc0); in mt7988_phy_finetune()
854 __phy_write(phydev, 0x11, 0xb90a); in mt7988_phy_finetune()
855 __phy_write(phydev, 0x12, 0x6f); in mt7988_phy_finetune()
856 __phy_write(phydev, 0x10, 0x8f82); in mt7988_phy_finetune()
859 __phy_write(phydev, 0x11, 0xfbba); in mt7988_phy_finetune()
860 __phy_write(phydev, 0x12, 0xc3); in mt7988_phy_finetune()
861 __phy_write(phydev, 0x10, 0x87f8); in mt7988_phy_finetune()
863 phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); in mt7988_phy_finetune()
866 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG234, in mt7988_phy_finetune()
871 phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LPF_CNT_VAL, 0x3ff); in mt7988_phy_finetune()
874 static void mt798x_phy_eee(struct phy_device *phydev) in mt798x_phy_eee() argument
876 phy_modify_mmd(phydev, MDIO_MMD_VEND1, in mt798x_phy_eee()
883 phy_modify_mmd(phydev, MDIO_MMD_VEND1, in mt798x_phy_eee()
889 phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, in mt798x_phy_eee()
893 phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, in mt798x_phy_eee()
896 phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, in mt798x_phy_eee()
899 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG238, in mt798x_phy_eee()
905 phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG239, in mt798x_phy_eee()
909 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG2C7, in mt798x_phy_eee()
914 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG2D1, in mt798x_phy_eee()
921 phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG323, in mt798x_phy_eee()
925 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG324, in mt798x_phy_eee()
930 phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG326, in mt798x_phy_eee()
936 phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); in mt798x_phy_eee()
938 __phy_write(phydev, 0x11, 0xb); in mt798x_phy_eee()
939 __phy_write(phydev, 0x12, 0x0); in mt798x_phy_eee()
940 __phy_write(phydev, 0x10, 0x9690); in mt798x_phy_eee()
943 __phy_write(phydev, 0x11, 0x114f); in mt798x_phy_eee()
944 __phy_write(phydev, 0x12, 0x2); in mt798x_phy_eee()
945 __phy_write(phydev, 0x10, 0x969a); in mt798x_phy_eee()
948 __phy_write(phydev, 0x11, 0x3028); in mt798x_phy_eee()
949 __phy_write(phydev, 0x12, 0x0); in mt798x_phy_eee()
950 __phy_write(phydev, 0x10, 0x969e); in mt798x_phy_eee()
953 __phy_write(phydev, 0x11, 0x5010); in mt798x_phy_eee()
954 __phy_write(phydev, 0x12, 0x0); in mt798x_phy_eee()
955 __phy_write(phydev, 0x10, 0x96a0); in mt798x_phy_eee()
958 __phy_write(phydev, 0x11, 0x24a); in mt798x_phy_eee()
959 __phy_write(phydev, 0x12, 0x0); in mt798x_phy_eee()
960 __phy_write(phydev, 0x10, 0x96a8); in mt798x_phy_eee()
963 __phy_write(phydev, 0x11, 0x3210); in mt798x_phy_eee()
964 __phy_write(phydev, 0x12, 0x0); in mt798x_phy_eee()
965 __phy_write(phydev, 0x10, 0x96b8); in mt798x_phy_eee()
968 __phy_write(phydev, 0x11, 0x1463); in mt798x_phy_eee()
969 __phy_write(phydev, 0x12, 0x0); in mt798x_phy_eee()
970 __phy_write(phydev, 0x10, 0x96ca); in mt798x_phy_eee()
973 __phy_write(phydev, 0x11, 0x36); in mt798x_phy_eee()
974 __phy_write(phydev, 0x12, 0x0); in mt798x_phy_eee()
975 __phy_write(phydev, 0x10, 0x8f80); in mt798x_phy_eee()
976 phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); in mt798x_phy_eee()
978 phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_3); in mt798x_phy_eee()
979 __phy_modify(phydev, MTK_PHY_LPI_REG_14, MTK_PHY_LPI_WAKE_TIMER_1000_MASK, in mt798x_phy_eee()
982 __phy_modify(phydev, MTK_PHY_LPI_REG_1c, MTK_PHY_SMI_DET_ON_THRESH_MASK, in mt798x_phy_eee()
984 phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); in mt798x_phy_eee()
986 phy_modify_mmd(phydev, MDIO_MMD_VEND1, in mt798x_phy_eee()
992 static int cal_sw(struct phy_device *phydev, enum CAL_ITEM cal_item, in cal_sw() argument
1002 ret = tx_vcm_cal_sw(phydev, pair_n); in cal_sw()
1013 static int cal_efuse(struct phy_device *phydev, enum CAL_ITEM cal_item, in cal_efuse() argument
1023 ret = rext_cal_efuse(phydev, buf); in cal_efuse()
1026 ret = tx_offset_cal_efuse(phydev, buf); in cal_efuse()
1029 ret = tx_amp_cal_efuse(phydev, buf); in cal_efuse()
1032 ret = tx_r50_cal_efuse(phydev, buf, pair_n); in cal_efuse()
1044 static int start_cal(struct phy_device *phydev, enum CAL_ITEM cal_item, in start_cal() argument
1052 ret = cal_efuse(phydev, cal_item, start_pair, in start_cal()
1056 ret = cal_sw(phydev, cal_item, start_pair, end_pair); in start_cal()
1063 phydev_err(phydev, "cal %d failed\n", cal_item); in start_cal()
1070 static int mt798x_phy_calibration(struct phy_device *phydev) in mt798x_phy_calibration() argument
1077 cell = nvmem_cell_get(&phydev->mdio.dev, "phy-cal-data"); in mt798x_phy_calibration()
1090 phydev_err(phydev, "invalid efuse data\n"); in mt798x_phy_calibration()
1095 ret = start_cal(phydev, REXT, EFUSE_M, NO_PAIR, NO_PAIR, buf); in mt798x_phy_calibration()
1098 ret = start_cal(phydev, TX_OFFSET, EFUSE_M, NO_PAIR, NO_PAIR, buf); in mt798x_phy_calibration()
1101 ret = start_cal(phydev, TX_AMP, EFUSE_M, NO_PAIR, NO_PAIR, buf); in mt798x_phy_calibration()
1104 ret = start_cal(phydev, TX_R50, EFUSE_M, PAIR_A, PAIR_D, buf); in mt798x_phy_calibration()
1107 ret = start_cal(phydev, TX_VCM, SW_M, PAIR_A, PAIR_A, buf); in mt798x_phy_calibration()
1116 static int mt798x_phy_config_init(struct phy_device *phydev) in mt798x_phy_config_init() argument
1118 switch (phydev->drv->phy_id) { in mt798x_phy_config_init()
1120 mt7981_phy_finetune(phydev); in mt798x_phy_config_init()
1123 mt7988_phy_finetune(phydev); in mt798x_phy_config_init()
1127 mt798x_phy_common_finetune(phydev); in mt798x_phy_config_init()
1128 mt798x_phy_eee(phydev); in mt798x_phy_config_init()
1130 return mt798x_phy_calibration(phydev); in mt798x_phy_config_init()
1133 static int mt798x_phy_hw_led_on_set(struct phy_device *phydev, u8 index, in mt798x_phy_hw_led_on_set() argument
1137 struct mtk_socphy_priv *priv = phydev->priv; in mt798x_phy_hw_led_on_set()
1148 return phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ? in mt798x_phy_hw_led_on_set()
1156 static int mt798x_phy_hw_led_blink_set(struct phy_device *phydev, u8 index, in mt798x_phy_hw_led_blink_set() argument
1160 struct mtk_socphy_priv *priv = phydev->priv; in mt798x_phy_hw_led_blink_set()
1171 return phy_write_mmd(phydev, MDIO_MMD_VEND2, index ? in mt798x_phy_hw_led_blink_set()
1178 static int mt798x_phy_led_blink_set(struct phy_device *phydev, u8 index, in mt798x_phy_led_blink_set() argument
1194 err = mt798x_phy_hw_led_blink_set(phydev, index, blinking); in mt798x_phy_led_blink_set()
1198 return mt798x_phy_hw_led_on_set(phydev, index, false); in mt798x_phy_led_blink_set()
1201 static int mt798x_phy_led_brightness_set(struct phy_device *phydev, in mt798x_phy_led_brightness_set() argument
1206 err = mt798x_phy_hw_led_blink_set(phydev, index, false); in mt798x_phy_led_brightness_set()
1210 return mt798x_phy_hw_led_on_set(phydev, index, (value != LED_OFF)); in mt798x_phy_led_brightness_set()
1222 static int mt798x_phy_led_hw_is_supported(struct phy_device *phydev, u8 index, in mt798x_phy_led_hw_is_supported() argument
1235 static int mt798x_phy_led_hw_control_get(struct phy_device *phydev, u8 index, in mt798x_phy_led_hw_control_get() argument
1241 struct mtk_socphy_priv *priv = phydev->priv; in mt798x_phy_led_hw_control_get()
1247 on = phy_read_mmd(phydev, MDIO_MMD_VEND2, in mt798x_phy_led_hw_control_get()
1253 blink = phy_read_mmd(phydev, MDIO_MMD_VEND2, in mt798x_phy_led_hw_control_get()
1306 static int mt798x_phy_led_hw_control_set(struct phy_device *phydev, u8 index, in mt798x_phy_led_hw_control_set() argument
1310 struct mtk_socphy_priv *priv = phydev->priv; in mt798x_phy_led_hw_control_set()
1353 ret = phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ? in mt798x_phy_led_hw_control_set()
1364 return phy_write_mmd(phydev, MDIO_MMD_VEND2, index ? in mt798x_phy_led_hw_control_set()
1369 static bool mt7988_phy_led_get_polarity(struct phy_device *phydev, int led_num) in mt7988_phy_led_get_polarity() argument
1371 struct mtk_socphy_shared *priv = phydev->shared->priv; in mt7988_phy_led_get_polarity()
1379 if (polarities & BIT(phydev->mdio.addr)) in mt7988_phy_led_get_polarity()
1385 static int mt7988_phy_fix_leds_polarities(struct phy_device *phydev) in mt7988_phy_fix_leds_polarities() argument
1392 phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ? in mt7988_phy_fix_leds_polarities()
1395 mt7988_phy_led_get_polarity(phydev, index) ? in mt7988_phy_fix_leds_polarities()
1399 pinctrl = devm_pinctrl_get_select(&phydev->mdio.dev, "gbe-led"); in mt7988_phy_fix_leds_polarities()
1401 dev_err(&phydev->mdio.bus->dev, "Failed to setup PHY LED pinctrl\n"); in mt7988_phy_fix_leds_polarities()
1406 static int mt7988_phy_probe_shared(struct phy_device *phydev) in mt7988_phy_probe_shared() argument
1408 struct device_node *np = dev_of_node(&phydev->mdio.bus->dev); in mt7988_phy_probe_shared()
1409 struct mtk_socphy_shared *shared = phydev->shared->priv; in mt7988_phy_probe_shared()
1440 static void mt798x_phy_leds_state_init(struct phy_device *phydev) in mt798x_phy_leds_state_init() argument
1445 mt798x_phy_led_hw_control_get(phydev, i, NULL); in mt798x_phy_leds_state_init()
1448 static int mt7988_phy_probe(struct phy_device *phydev) in mt7988_phy_probe() argument
1454 if (phydev->mdio.addr > 3) in mt7988_phy_probe()
1457 err = devm_phy_package_join(&phydev->mdio.dev, phydev, 0, in mt7988_phy_probe()
1462 if (phy_package_probe_once(phydev)) { in mt7988_phy_probe()
1463 err = mt7988_phy_probe_shared(phydev); in mt7988_phy_probe()
1468 shared = phydev->shared->priv; in mt7988_phy_probe()
1469 priv = &shared->priv[phydev->mdio.addr]; in mt7988_phy_probe()
1471 phydev->priv = priv; in mt7988_phy_probe()
1473 mt798x_phy_leds_state_init(phydev); in mt7988_phy_probe()
1475 err = mt7988_phy_fix_leds_polarities(phydev); in mt7988_phy_probe()
1483 phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RXADC_CTRL_RG7, in mt7988_phy_probe()
1486 return mt798x_phy_calibration(phydev); in mt7988_phy_probe()
1489 static int mt7981_phy_probe(struct phy_device *phydev) in mt7981_phy_probe() argument
1493 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(struct mtk_socphy_priv), in mt7981_phy_probe()
1498 phydev->priv = priv; in mt7981_phy_probe()
1500 mt798x_phy_leds_state_init(phydev); in mt7981_phy_probe()
1502 return mt798x_phy_calibration(phydev); in mt7981_phy_probe()