This adds the 4 PWM controlled green LEDs to the HiFive Unleashed device
tree. The schematic doesn't specify any special function for the LEDs,
so they're added here without any default triggers and named d1, d2, d3
and d4 just like in the schematic.
Signed-off-by: Emil Renner Berthing <[email protected]>
---
Yes this board is old, but I'm trying to get rid of custom riscv patches in
the Ubuntu kernel.
.../boot/dts/sifive/hifive-unleashed-a00.dts | 38 +++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts b/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts
index ced0d4e47938..900a50526d77 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
@@ -42,6 +44,42 @@ gpio-restart {
compatible = "gpio-restart";
gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
};
+
+ led-controller {
+ compatible = "pwm-leds";
+
+ led-d1 {
+ pwms = <&pwm0 0 7812500 PWM_POLARITY_INVERTED>;
+ active-low;
+ color = <LED_COLOR_ID_GREEN>;
+ max-brightness = <255>;
+ label = "d1";
+ };
+
+ led-d2 {
+ pwms = <&pwm0 1 7812500 PWM_POLARITY_INVERTED>;
+ active-low;
+ color = <LED_COLOR_ID_GREEN>;
+ max-brightness = <255>;
+ label = "d2";
+ };
+
+ led-d3 {
+ pwms = <&pwm0 2 7812500 PWM_POLARITY_INVERTED>;
+ active-low;
+ color = <LED_COLOR_ID_GREEN>;
+ max-brightness = <255>;
+ label = "d3";
+ };
+
+ led-d4 {
+ pwms = <&pwm0 3 7812500 PWM_POLARITY_INVERTED>;
+ active-low;
+ color = <LED_COLOR_ID_GREEN>;
+ max-brightness = <255>;
+ label = "d4";
+ };
+ };
};
&uart0 {
--
2.37.2
On Wed, Oct 12, 2022 at 01:09:28PM +0200, Emil Renner Berthing wrote:
> This adds the 4 PWM controlled green LEDs to the HiFive Unleashed device
> tree. The schematic doesn't specify any special function for the LEDs,
> so they're added here without any default triggers and named d1, d2, d3
> and d4 just like in the schematic.
>
> Signed-off-by: Emil Renner Berthing <[email protected]>
> ---
>
> Yes this board is old, but I'm trying to get rid of custom riscv patches in
> the Ubuntu kernel.
Old maybe, but some of us still have them ;)
Reviewed-by: Conor Dooley <[email protected]>
Twiddled the sysfs knobs a bit too so:
Tested-by: Conor Dooley <[email protected]>
>
> .../boot/dts/sifive/hifive-unleashed-a00.dts | 38 +++++++++++++++++++
> 1 file changed, 38 insertions(+)
>
> diff --git a/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts b/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts
> index ced0d4e47938..900a50526d77 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
> @@ -42,6 +44,42 @@ gpio-restart {
> compatible = "gpio-restart";
> gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
> };
> +
> + led-controller {
> + compatible = "pwm-leds";
> +
> + led-d1 {
> + pwms = <&pwm0 0 7812500 PWM_POLARITY_INVERTED>;
> + active-low;
> + color = <LED_COLOR_ID_GREEN>;
> + max-brightness = <255>;
> + label = "d1";
> + };
> +
> + led-d2 {
> + pwms = <&pwm0 1 7812500 PWM_POLARITY_INVERTED>;
> + active-low;
> + color = <LED_COLOR_ID_GREEN>;
> + max-brightness = <255>;
> + label = "d2";
> + };
> +
> + led-d3 {
> + pwms = <&pwm0 2 7812500 PWM_POLARITY_INVERTED>;
> + active-low;
> + color = <LED_COLOR_ID_GREEN>;
> + max-brightness = <255>;
> + label = "d3";
> + };
> +
> + led-d4 {
> + pwms = <&pwm0 3 7812500 PWM_POLARITY_INVERTED>;
> + active-low;
> + color = <LED_COLOR_ID_GREEN>;
> + max-brightness = <255>;
> + label = "d4";
> + };
> + };
> };
>
> &uart0 {
> --
> 2.37.2
>
On Wed, 12 Oct 2022 04:09:28 PDT (-0700), [email protected] wrote:
> This adds the 4 PWM controlled green LEDs to the HiFive Unleashed device
> tree. The schematic doesn't specify any special function for the LEDs,
> so they're added here without any default triggers and named d1, d2, d3
> and d4 just like in the schematic.
>
> Signed-off-by: Emil Renner Berthing <[email protected]>
> ---
>
> Yes this board is old, but I'm trying to get rid of custom riscv patches in
> the Ubuntu kernel.
IMO fixing stuff for old boards is great, particularly if they're broken
upstream but supported by distro kernels -- that's kind of a messy spot
to be in.
> .../boot/dts/sifive/hifive-unleashed-a00.dts | 38 +++++++++++++++++++
> 1 file changed, 38 insertions(+)
>
> diff --git a/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts b/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts
> index ced0d4e47938..900a50526d77 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
> @@ -42,6 +44,42 @@ gpio-restart {
> compatible = "gpio-restart";
> gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
> };
> +
> + led-controller {
> + compatible = "pwm-leds";
> +
> + led-d1 {
> + pwms = <&pwm0 0 7812500 PWM_POLARITY_INVERTED>;
> + active-low;
> + color = <LED_COLOR_ID_GREEN>;
> + max-brightness = <255>;
> + label = "d1";
> + };
> +
> + led-d2 {
> + pwms = <&pwm0 1 7812500 PWM_POLARITY_INVERTED>;
> + active-low;
> + color = <LED_COLOR_ID_GREEN>;
> + max-brightness = <255>;
> + label = "d2";
> + };
> +
> + led-d3 {
> + pwms = <&pwm0 2 7812500 PWM_POLARITY_INVERTED>;
> + active-low;
> + color = <LED_COLOR_ID_GREEN>;
> + max-brightness = <255>;
> + label = "d3";
> + };
> +
> + led-d4 {
> + pwms = <&pwm0 3 7812500 PWM_POLARITY_INVERTED>;
> + active-low;
> + color = <LED_COLOR_ID_GREEN>;
> + max-brightness = <255>;
> + label = "d4";
> + };
> + };
> };
>
> &uart0 {
On Wed, 12 Oct 2022 13:09:28 +0200, Emil Renner Berthing wrote:
> This adds the 4 PWM controlled green LEDs to the HiFive Unleashed device
> tree. The schematic doesn't specify any special function for the LEDs,
> so they're added here without any default triggers and named d1, d2, d3
> and d4 just like in the schematic.
>
>
Applied, thanks!
[1/1] riscv: dts: sifive unleashed: Add PWM controlled LEDs
https://git.kernel.org/palmer/c/8bc8824d3019
Best regards,
--
Palmer Dabbelt <[email protected]>