aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/hack-5.15
diff options
context:
space:
mode:
authorDavid Bauer <mail@david-bauer.net>2023-04-30 13:46:26 +0200
committerDavid Bauer <mail@david-bauer.net>2023-05-11 23:09:04 +0200
commit242fe8634eba4832877d42960ade58b60d739434 (patch)
treed70a58de154a4c4877ceca6a841895480e614e40 /target/linux/generic/hack-5.15
parent523c392fe675f83f7db8460e52f7f9b99bccae65 (diff)
downloadupstream-242fe8634eba4832877d42960ade58b60d739434.tar.gz
upstream-242fe8634eba4832877d42960ade58b60d739434.tar.bz2
upstream-242fe8634eba4832877d42960ade58b60d739434.zip
generic: add hack for MT753x LED configuration
This adds a small hack similar to the one used for ar8xxx switches to read a reg:value map for configuring the LED configuration registers. This allows OpenWrt to write device-specific LED action as well as blink configurations. It is unlikely to be accepted upstream, as upstream plans on integrating their own framework for handling these LEDs. Signed-off-by: David Bauer <mail@david-bauer.net>
Diffstat (limited to 'target/linux/generic/hack-5.15')
-rw-r--r--target/linux/generic/hack-5.15/766-net-phy-mediatek-ge-add-LED-configuration-interface.patch66
1 files changed, 66 insertions, 0 deletions
diff --git a/target/linux/generic/hack-5.15/766-net-phy-mediatek-ge-add-LED-configuration-interface.patch b/target/linux/generic/hack-5.15/766-net-phy-mediatek-ge-add-LED-configuration-interface.patch
new file mode 100644
index 0000000000..a69ec97ca3
--- /dev/null
+++ b/target/linux/generic/hack-5.15/766-net-phy-mediatek-ge-add-LED-configuration-interface.patch
@@ -0,0 +1,66 @@
+From cc225d163b5a4f7a0d1968298bf7927306646a47 Mon Sep 17 00:00:00 2001
+From: David Bauer <mail@david-bauer.net>
+Date: Fri, 28 Apr 2023 01:53:01 +0200
+Subject: [PATCH] net: phy: mediatek-ge: add LED configuration interface
+
+This adds a small hack similar to the one used for ar8xxx switches to
+read a reg:value map for configuring the LED configuration registers.
+
+This allows OpenWrt to write device-specific LED action as well as blink
+configurations. It is unlikely to be accepted upstream, as upstream
+plans on integrating their own framework for handling these LEDs.
+
+Signed-off-by: David Bauer <mail@david-bauer.net>
+---
+ drivers/net/phy/mediatek-ge.c | 33 +++++++++++++++++++++++++++++++++
+ 1 file changed, 33 insertions(+)
+
+--- a/drivers/net/phy/mediatek-ge.c
++++ b/drivers/net/phy/mediatek-ge.c
+@@ -53,6 +53,36 @@ static int mt7530_phy_config_init(struct
+ return 0;
+ }
+
++static int mt7530_led_config_of(struct phy_device *phydev)
++{
++ struct device_node *np = phydev->mdio.dev.of_node;
++ const __be32 *paddr;
++ int len;
++ int i;
++
++ paddr = of_get_property(np, "mediatek,led-config", &len);
++ if (!paddr)
++ return 0;
++
++ if (len < (2 * sizeof(*paddr)))
++ return -EINVAL;
++
++ len /= sizeof(*paddr);
++
++ phydev_warn(phydev, "Configure LED registers (num=%d)\n", len);
++ for (i = 0; i < len - 1; i += 2) {
++ u32 reg;
++ u32 val;
++
++ reg = be32_to_cpup(paddr + i);
++ val = be32_to_cpup(paddr + i + 1);
++
++ phy_write_mmd(phydev, MDIO_MMD_VEND2, reg, val);
++ }
++
++ return 0;
++}
++
+ static int mt7531_phy_config_init(struct phy_device *phydev)
+ {
+ mtk_gephy_config_init(phydev);
+@@ -65,6 +95,9 @@ static int mt7531_phy_config_init(struct
+ phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x13, 0x404);
+ phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x14, 0x404);
+
++ /* LED Config*/
++ mt7530_led_config_of(phydev);
++
+ return 0;
+ }
+