From: Christian Lamparter <chunkeey@gmail.com>
Date: Sun, 13 Feb 2022 10:18:04 +0000 (+0100)
Subject: mpc85xx: update lp5521 led-controller node for 5.10
X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=583ac0e11df7e29142837410a320db4654e4ff96;p=openwrt%2Fstaging%2Fxback.git

mpc85xx: update lp5521 led-controller node for 5.10

The tricolor LED which is controlled by a lp5521 needed
some maintenance as the driver failed to load in the
current v5.10 image:
| lp5521: probe of 0-0032 failed with error -22

This is because the device-tree needed to be updated
to match the latest led coloring and function trends.

 - removed the device name from the label
 - added color/function properties
 - added required reg and cells properties

For reference a disabled multicolor/RGB is added since this
reflects the real hardware. Unfortunately, the multicolor
sysfs interface isn't supported by yet.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
---

diff --git a/target/linux/mpc85xx/files/arch/powerpc/boot/dts/hiveap-330.dts b/target/linux/mpc85xx/files/arch/powerpc/boot/dts/hiveap-330.dts
index 359b123bc6..67b93707c7 100644
--- a/target/linux/mpc85xx/files/arch/powerpc/boot/dts/hiveap-330.dts
+++ b/target/linux/mpc85xx/files/arch/powerpc/boot/dts/hiveap-330.dts
@@ -9,16 +9,18 @@
  * option) any later version.
  */
 
+#include <dt-bindings/leds/common.h>
+
 /include/ "fsl/p1020si-pre.dtsi"
 / {
 	model = "Aerohive HiveAP-330";
 	compatible = "aerohive,hiveap-330";
 
 	aliases {
-		led-boot = &tricolor_green;
-		led-failsafe = &tricolor_red;
-		led-running = &tricolor_green;
-		led-upgrade = &tricolor_red;
+		led-boot = &led_power_green;
+		led-failsafe = &led_fault_red;
+		led-running = &led_power_green;
+		led-upgrade = &led_fault_red;
 		label-mac-device = &enet0;
 	};
 
@@ -119,21 +121,66 @@
 				compatible = "national,lp5521";
 				reg = <0x32>;
 				clock-mode = /bits/ 8 <2>;
-				tricolor_red: chan0 {
-					chan-name = "hiveap-330:red:tricolor0";
+#if 1
+				led_fault_red: led@0 {
+					reg = <0>;
+					chan-name = "fault:red";
 					led-cur = /bits/ 8 <0x2f>;
 					max-cur = /bits/ 8 <0x5f>;
+					color = <LED_COLOR_ID_RED>;
+					function = LED_FUNCTION_FAULT;
 				};
-				tricolor_green:chan1 {
-					chan-name = "hiveap-330:green:tricolor0";
+				led_power_green: led@1 {
+					reg = <1>;
+					chan-name = "power:green";
 					led-cur = /bits/ 8 <0x2f>;
 					max-cur = /bits/ 8 <0x5f>;
+					color = <LED_COLOR_ID_GREEN>;
+					function = LED_FUNCTION_POWER;
 				};
-				chan2 {
-					chan-name = "hiveap-330:blue:tricolor0";
+				led@2{
+					reg = <2>;
+					chan-name = "blue";
 					led-cur = /bits/ 8 <0x2f>;
 					max-cur = /bits/ 8 <0x5f>;
+					color = <LED_COLOR_ID_BLUE>;
+				};
+#else
+				/*
+				 * openwrt isn't ready to handle multi-intensity leds yet
+				 * # echo 255 255 255 > /sys/class/leds/tricolor/multi_intensity
+				 * # echo 255 > /sys/class/leds/tricolor/brightness
+				 */
+
+				rgbled-0 {
+					function = LED_FUNCTION_POWER;
+					color = <LED_COLOR_ID_RGB>;
+					#address-cells = <1>;
+					#size-cells = <0>;
+
+					led@0 {
+						reg = <0>;
+						chan-name = "tricolor";
+						led-cur = /bits/ 8 <0x2f>;
+						max-cur = /bits/ 8 <0x5f>;
+						color = <LED_COLOR_ID_RED>;
+					};
+					led@1 {
+						reg = <1>;
+						chan-name = "tricolor";
+						led-cur = /bits/ 8 <0x2f>;
+						max-cur = /bits/ 8 <0x5f>;
+						color = <LED_COLOR_ID_GREEN>;
+					};
+					led@2{
+						reg = <2>;
+						chan-name = "tricolor";
+						led-cur = /bits/ 8 <0x2f>;
+						max-cur = /bits/ 8 <0x5f>;
+						color = <LED_COLOR_ID_BLUE>;
+					};
 				};
+#endif
 			};
 
 			/* Most likely SoC boot config */