]> git.ipfire.org Git - thirdparty/openwrt.git/blob
e51d94d60e8ca85d62324f7dd26dd975d0cc9941
[thirdparty/openwrt.git] /
1 From 6a325aed130bb68790e765f923e76ec5669d2da7 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Thu, 10 Apr 2025 12:04:04 +0200
4 Subject: [PATCH 2/2] net: phy: mediatek: add Airoha PHY ID to SoC driver
5
6 Airoha AN7581 SoC ship with a Switch based on the MT753x Switch embedded
7 in other SoC like the MT7581 and the MT7988. Similar to these they
8 require configuring some pin to enable LED PHYs.
9
10 Add support for the PHY ID for the Airoha embedded Switch and define a
11 simple probe function to toggle these pins. Also fill the LED functions
12 and add dedicated function to define LED polarity.
13
14 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
15 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
16 Link: https://patch.msgid.link/20250410100410.348-2-ansuelsmth@gmail.com
17 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
18 ---
19 drivers/net/phy/mediatek/mtk-ge-soc.c | 62 +++++++++++++++++++++++++++
20 2 files changed, 65 insertions(+), 1 deletion(-)
21
22 --- a/drivers/net/phy/mediatek/mtk-ge-soc.c
23 +++ b/drivers/net/phy/mediatek/mtk-ge-soc.c
24 @@ -1405,6 +1408,53 @@ static int mt7981_phy_probe(struct phy_d
25 return mt798x_phy_calibration(phydev);
26 }
27
28 +static int an7581_phy_probe(struct phy_device *phydev)
29 +{
30 + struct mtk_socphy_priv *priv;
31 + struct pinctrl *pinctrl;
32 +
33 + /* Toggle pinctrl to enable PHY LED */
34 + pinctrl = devm_pinctrl_get_select(&phydev->mdio.dev, "gbe-led");
35 + if (IS_ERR(pinctrl))
36 + dev_err(&phydev->mdio.bus->dev,
37 + "Failed to setup PHY LED pinctrl\n");
38 +
39 + priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
40 + if (!priv)
41 + return -ENOMEM;
42 +
43 + phydev->priv = priv;
44 +
45 + return 0;
46 +}
47 +
48 +static int an7581_phy_led_polarity_set(struct phy_device *phydev, int index,
49 + unsigned long modes)
50 +{
51 + u32 mode;
52 + u16 val;
53 +
54 + if (index >= MTK_PHY_MAX_LEDS)
55 + return -EINVAL;
56 +
57 + for_each_set_bit(mode, &modes, __PHY_LED_MODES_NUM) {
58 + switch (mode) {
59 + case PHY_LED_ACTIVE_LOW:
60 + val = MTK_PHY_LED_ON_POLARITY;
61 + break;
62 + case PHY_LED_ACTIVE_HIGH:
63 + val = 0;
64 + break;
65 + default:
66 + return -EINVAL;
67 + }
68 + }
69 +
70 + return phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ?
71 + MTK_PHY_LED1_ON_CTRL : MTK_PHY_LED0_ON_CTRL,
72 + MTK_PHY_LED_ON_POLARITY, val);
73 +}
74 +
75 static struct phy_driver mtk_socphy_driver[] = {
76 {
77 PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7981),
78 @@ -1440,6 +1490,17 @@ static struct phy_driver mtk_socphy_driv
79 .led_hw_control_set = mt798x_phy_led_hw_control_set,
80 .led_hw_control_get = mt798x_phy_led_hw_control_get,
81 },
82 + {
83 + PHY_ID_MATCH_EXACT(MTK_GPHY_ID_AN7581),
84 + .name = "Airoha AN7581 PHY",
85 + .probe = an7581_phy_probe,
86 + .led_blink_set = mt798x_phy_led_blink_set,
87 + .led_brightness_set = mt798x_phy_led_brightness_set,
88 + .led_hw_is_supported = mt798x_phy_led_hw_is_supported,
89 + .led_hw_control_set = mt798x_phy_led_hw_control_set,
90 + .led_hw_control_get = mt798x_phy_led_hw_control_get,
91 + .led_polarity_set = an7581_phy_led_polarity_set,
92 + },
93 };
94
95 module_phy_driver(mtk_socphy_driver);