target/generic: airoha phy: add a device_property to disable HW LEDs
authorJohn Crispin <[email protected]>
Sat, 6 Apr 2024 10:10:48 +0000 (12:10 +0200)
committerDaniel Golle <[email protected]>
Wed, 8 May 2024 01:01:10 +0000 (02:01 +0100)
Add a new device property "airoha,led-hw-disable" that will disable the LED
HW control when set. This allows the "netdev" trigger to control the LEDs.

Signed-off-by: John Crispin <[email protected]>
target/linux/generic/pending-6.1/751-net-phy-airoha-make-hw-leds-optional.patch [new file with mode: 0644]
target/linux/generic/pending-6.6/751-net-phy-airoha-make-hw-leds-optional.patch [new file with mode: 0644]

diff --git a/target/linux/generic/pending-6.1/751-net-phy-airoha-make-hw-leds-optional.patch b/target/linux/generic/pending-6.1/751-net-phy-airoha-make-hw-leds-optional.patch
new file mode 100644 (file)
index 0000000..9dbe644
--- /dev/null
@@ -0,0 +1,31 @@
+Index: linux-6.6.23/drivers/net/phy/air_en8811h.c
+===================================================================
+--- linux-6.6.23.orig/drivers/net/phy/air_en8811h.c
++++ linux-6.6.23/drivers/net/phy/air_en8811h.c
+@@ -157,6 +157,7 @@ struct led {
+ struct en8811h_priv {
+       u32             firmware_version;
+       struct led      led[EN8811H_LED_COUNT];
++      bool            led_hw_control;
+ };
+ enum {
+@@ -540,6 +541,9 @@ static int air_led_hw_control_get(struct
+ {
+       struct en8811h_priv *priv = phydev->priv;
++      if (!priv->led_hw_control)
++              return -EINVAL;
++
+       if (index >= EN8811H_LED_COUNT)
+               return -EINVAL;
+@@ -814,6 +818,8 @@ static int en8811h_config_init(struct ph
+       if (ret < 0)
+               return ret;
++      priv->led_hw_control = !device_property_read_bool(dev, "airoha,led-hw-disable");
++      
+       ret = air_leds_init(phydev, EN8811H_LED_COUNT, AIR_PHY_LED_DUR,
+                           AIR_LED_MODE_USER_DEFINE);
+       if (ret < 0) {
diff --git a/target/linux/generic/pending-6.6/751-net-phy-airoha-make-hw-leds-optional.patch b/target/linux/generic/pending-6.6/751-net-phy-airoha-make-hw-leds-optional.patch
new file mode 100644 (file)
index 0000000..9dbe644
--- /dev/null
@@ -0,0 +1,31 @@
+Index: linux-6.6.23/drivers/net/phy/air_en8811h.c
+===================================================================
+--- linux-6.6.23.orig/drivers/net/phy/air_en8811h.c
++++ linux-6.6.23/drivers/net/phy/air_en8811h.c
+@@ -157,6 +157,7 @@ struct led {
+ struct en8811h_priv {
+       u32             firmware_version;
+       struct led      led[EN8811H_LED_COUNT];
++      bool            led_hw_control;
+ };
+ enum {
+@@ -540,6 +541,9 @@ static int air_led_hw_control_get(struct
+ {
+       struct en8811h_priv *priv = phydev->priv;
++      if (!priv->led_hw_control)
++              return -EINVAL;
++
+       if (index >= EN8811H_LED_COUNT)
+               return -EINVAL;
+@@ -814,6 +818,8 @@ static int en8811h_config_init(struct ph
+       if (ret < 0)
+               return ret;
++      priv->led_hw_control = !device_property_read_bool(dev, "airoha,led-hw-disable");
++      
+       ret = air_leds_init(phydev, EN8811H_LED_COUNT, AIR_PHY_LED_DUR,
+                           AIR_LED_MODE_USER_DEFINE);
+       if (ret < 0) {