diff --git a/drivers/net/phy/mediatek/Kconfig b/drivers/net/phy/mediatek/Kconfig index bb7dc876271e..b6d41bbbbc27 100644 --- a/drivers/net/phy/mediatek/Kconfig +++ b/drivers/net/phy/mediatek/Kconfig @@ -23,9 +23,9 @@ config MEDIATEK_GE_PHY config MEDIATEK_GE_SOC_PHY tristate "MediaTek SoC Ethernet PHYs" - depends on ARM64 || COMPILE_TEST + depends on ARM64 || ECONET || COMPILE_TEST depends on ARCH_AIROHA || (ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || \ - COMPILE_TEST + ECONET || COMPILE_TEST select MTK_NET_PHYLIB select PHY_PACKAGE help @@ -36,5 +36,9 @@ config MEDIATEK_GE_SOC_PHY present in the SoCs efuse and will dynamically calibrate VCM (common-mode voltage) during startup. + Also include support for the built-in Gigabit Ethernet PHYs of + the Airoha AN7581 and AN7583 SoCs and of the EcoNet EN7528 SoC, + which need no efuse calibration data. + config MTK_NET_PHYLIB tristate diff --git a/drivers/net/phy/mediatek/mtk-ge-soc.c b/drivers/net/phy/mediatek/mtk-ge-soc.c index 9a54949644d5..0041300d4f10 100644 --- a/drivers/net/phy/mediatek/mtk-ge-soc.c +++ b/drivers/net/phy/mediatek/mtk-ge-soc.c @@ -16,6 +16,7 @@ #define MTK_GPHY_ID_MT7981 0x03a29461 #define MTK_GPHY_ID_MT7988 0x03a29481 +#define MTK_GPHY_ID_EN7528 0x03a29491 #define MTK_GPHY_ID_AN7581 0x03a294c1 #define MTK_GPHY_ID_AN7583 0xc0ff0420 @@ -320,6 +321,14 @@ /* Registers on MDIO_MMD_VEND2 */ #define MTK_PHY_LED1_DEFAULT_POLARITIES BIT(1) +/* LED basic control register, part of the same LED block as the LED0/LED1 + * control registers above. The air_en8811h driver describes the same + * register as AIR_PHY_LED_BCR. + */ +#define MTK_PHY_LED_BCR 0x21 +#define MTK_PHY_LED_BCR_CLK_EN BIT(3) +#define MTK_PHY_LED_BCR_EXT_CTRL BIT(15) + #define MTK_PHY_RG_BG_RASEL 0x115 #define MTK_PHY_RG_BG_RASEL_MASK GENMASK(2, 0) @@ -1470,6 +1479,19 @@ static int an7583_phy_config_init(struct phy_device *phydev) return phy_clear_bits(phydev, MII_BMCR, BMCR_PDOWN); } +static int en7528_phy_config_init(struct phy_device *phydev) +{ + /* The LED controller of the EN7528 powers up with its external + * control disabled, leaving the LED pins dark regardless of what is + * programmed into the LED control registers. Hand the pins over to + * the LED control registers the same way the air_en8811h driver + * does; the mode field of this register is already set out of reset. + */ + return phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, MTK_PHY_LED_BCR, + MTK_PHY_LED_BCR_CLK_EN | + MTK_PHY_LED_BCR_EXT_CTRL); +} + static struct phy_driver mtk_socphy_driver[] = { { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7981), @@ -1505,6 +1527,18 @@ static struct phy_driver mtk_socphy_driver[] = { .led_hw_control_set = mt798x_phy_led_hw_control_set, .led_hw_control_get = mt798x_phy_led_hw_control_get, }, + { + PHY_ID_MATCH_EXACT(MTK_GPHY_ID_EN7528), + .name = "EcoNet EN7528 PHY", + .config_init = en7528_phy_config_init, + .probe = an7581_phy_probe, + .led_blink_set = mt798x_phy_led_blink_set, + .led_brightness_set = mt798x_phy_led_brightness_set, + .led_hw_is_supported = mt798x_phy_led_hw_is_supported, + .led_hw_control_set = mt798x_phy_led_hw_control_set, + .led_hw_control_get = mt798x_phy_led_hw_control_get, + .led_polarity_set = an7581_phy_led_polarity_set, + }, { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_AN7581), .name = "Airoha AN7581 PHY", @@ -1537,6 +1571,7 @@ module_phy_driver(mtk_socphy_driver); static const struct mdio_device_id __maybe_unused mtk_socphy_tbl[] = { { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7981) }, { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7988) }, + { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_EN7528) }, { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_AN7581) }, { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_AN7583) }, { }