[PATCH 2/2] riscv: dts: sifive: add pwm leds for HiFive Unleashed

Icenowy Zheng icenowy at aosc.io
Mon Feb 28 09:48:37 PST 2022


The PWM0 controller of HiFive Unleashed's FU540-C000 chip is connected
to 4 LEDs.

Add them to the device tree, with function and default trigger set from
the triggers used in old kernels done by SiFive.

Signed-off-by: Icenowy Zheng <icenowy at aosc.io>
---
 .../boot/dts/sifive/hifive-unleashed-a00.dts  | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts b/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts
index 44824d7e50ac7..2935719ca169e 100644
--- a/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts
+++ b/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts
@@ -3,6 +3,8 @@
 
 #include "fu540-c000.dtsi"
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/leds/common.h>
+#include <dt-bindings/pwm/pwm.h>
 
 /* Clock frequency (in Hz) of the PCB crystal for rtcclk */
 #define RTCCLK_FREQ		1000000
@@ -32,6 +34,46 @@ hfclk: hfclk {
 		clock-output-names = "hfclk";
 	};
 
+	led-controller {
+		compatible = "pwm-leds";
+
+		led-0 {
+			color = <LED_COLOR_ID_GREEN>;
+			pwms = <&pwm0 0 10000000 PWM_POLARITY_INVERTED>;
+			active-low;
+			max-brightness = <255>;
+			function = LED_FUNCTION_HEARTBEAT;
+			linux,default-trigger = "heartbeat";
+		};
+
+		led-1 {
+			color = <LED_COLOR_ID_GREEN>;
+			pwms = <&pwm0 1 10000000 PWM_POLARITY_INVERTED>;
+			active-low;
+			max-brightness = <255>;
+			function = LED_FUNCTION_MTD;
+			linux,default-trigger = "mtd";
+		};
+
+		led-2 {
+			color = <LED_COLOR_ID_GREEN>;
+			pwms = <&pwm0 2 10000000 PWM_POLARITY_INVERTED>;
+			active-low;
+			max-brightness = <255>;
+			function = LED_FUNCTION_LAN;
+			linux,default-trigger = "netdev";
+		};
+
+		led-3 {
+			color = <LED_COLOR_ID_GREEN>;
+			pwms = <&pwm0 3 10000000 PWM_POLARITY_INVERTED>;
+			active-low;
+			max-brightness = <255>;
+			function = LED_FUNCTION_PANIC;
+			linux,default-trigger = "panic";
+		};
+	};
+
 	memory at 80000000 {
 		device_type = "memory";
 		reg = <0x0 0x80000000 0x2 0x00000000>;
-- 
2.30.2




More information about the linux-riscv mailing list