Skip to contentSkip to conversation

riscv: defconfig: enable "heartbeat" led trigger

PATCH In review FUKAUMI Naoki 2 participants 6 messages Jun 27, 2024 – Jul 2, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/4 riscv: defconfig: enable "heartbeat" led trigger

following JH7110 based boards have a LED for heartbeat.

- Milk-V Mars
- Pine64 Star64
- StarFive VisionFive 2

This patch adds and enables related configuration for it.

Changes in v2:
- reword commit message to include other JH7110 based boards

---
 arch/riscv/configs/defconfig | 6 ++++++
 1 file changed, 6 insertions(+)
arch/riscv/configs/defconfig +6 -0
index 3f1f055866af..5f5582d7d7fd 100644
@@ -147,6 +147,7 @@ CONFIG_MICREL_PHY=y
 CONFIG_MICROSEMI_PHY=y
 CONFIG_MOTORCOMM_PHY=y
 CONFIG_CAN_RCAR_CANFD=m
+# CONFIG_INPUT_LEDS is not set
 CONFIG_INPUT_MOUSEDEV=y
 CONFIG_KEYBOARD_SUN4I_LRADC=m
 CONFIG_SERIAL_8250=y
@@ -246,6 +247,11 @@ CONFIG_MMC_DW=y
 CONFIG_MMC_DW_STARFIVE=y
 CONFIG_MMC_SDHI=y
 CONFIG_MMC_SUNXI=y
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+CONFIG_LEDS_GPIO=y
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_TRIGGER_HEARTBEAT=y
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_DRV_SUN6I=y
 CONFIG_DMADEVICES=y
Signature · 1 line
2.43.0
#1 lore raw

PATCH v3 2/4 riscv: dts: starfive: enable heartbeat LED for Milk-V Mars

Milk-V Mars has a green LED to show system load[1]. This patch enables a green LED as a heartbeat LED.

[1] https://github.com/milkv-mars/mars-buildroot-sdk/blob/dev/linux/arch/riscv/boot/dts/starfive/jh7110-milkv-mars.dtsi#L79

Changes in v3:
- add default-state = "on" to turn LED on at U-Boot (not enabled yet) Changes in v2:
- reorder properties in led-0

---
 arch/riscv/boot/dts/starfive/jh7110-milkv-mars.dts | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/riscv/boot/dts/starfive/jh7110-milkv-mars.dts +14 -0
index 5cb9e99e1dac..5cae7a5d2f86 100644
@@ -4,11 +4,25 @@
  */
 
 /dts-v1/;
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/leds/common.h>
 #include "jh7110-common.dtsi"
 
 / {
 	model = "Milk-V Mars";
 	compatible = "milkv,mars", "starfive,jh7110";
+
+	leds {
+		compatible = "gpio-leds";
+
+		led-0 {
+			gpios = <&aongpio 3 GPIO_ACTIVE_HIGH>;
+			color = <LED_COLOR_ID_GREEN>;
+			default-state = "on";
+			function = LED_FUNCTION_HEARTBEAT;
+			linux,default-trigger = "heartbeat";
+		};
+	};
 };
 
 &gmac0 {
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH v3 2/4] riscv: dts: starfive: enable heartbeat LED for Milk-V Mars

Quoted 32 lines · FUKAUMI Naoki

Milk-V Mars has a green LED to show system load[1]. This patch enables a green LED as a heartbeat LED.

[1] https://github.com/milkv-mars/mars-buildroot-sdk/blob/dev/linux/arch/riscv/boot/dts/starfive/jh7110-milkv-mars.dtsi#L79

Changes in v3:
- add default-state = "on" to turn LED on at U-Boot (not enabled yet) Changes in v2:
- reorder properties in led-0

---
 arch/riscv/boot/dts/starfive/jh7110-milkv-mars.dts | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/riscv/boot/dts/starfive/jh7110-milkv-mars.dts +4 -0
index 5cb9e99e1dac..5cae7a5d2f86 100644
@@ -4,11 +4,25 @@
  */
 
 /dts-v1/;
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/leds/common.h>
 #include "jh7110-common.dtsi"
 
 / {
 	model = "Milk-V Mars";
 	compatible = "milkv,mars", "starfive,jh7110";
+
+	leds {

arch/riscv/boot/dts/starfive/jh7110-milkv-mars.dts line 25

Quoted 10 lines
arch/riscv/boot/dts/starfive/jh7110-milkv-mars.dts +10 -0
+		compatible = "gpio-leds";
+
+		led-0 {
+			gpios = <&aongpio 3 GPIO_ACTIVE_HIGH>;
+			color = <LED_COLOR_ID_GREEN>;
+			default-state = "on";
+			function = LED_FUNCTION_HEARTBEAT;
+			linux,default-trigger = "heartbeat";
+		};
+	};

Hi Naoki

Thanks for adding the other boards too. As mentioned previously [1] boards should not add functions to LEDs unless the hardware clearly defines a function for them, and nothing on these boards mention that it should be a heartbeeat. As you said on IRC userland can easily add whatever function they want.

Also please add a cover letter when you're sending multiple patches. Eg. use git format-patch --cover-letter

/Emil

[1]: https://lore.kernel.org/linux-riscv/CAJM55Z_j8gWFyKvsiu-oGDV7Hacr4Amt5FdkHdjKnhZwZgxncA@mail.gmail.com/

Quoted 6 lines
arch/riscv/boot/dts/starfive/jh7110-milkv-mars.dts +0 -1
 };
 
 &gmac0 {
--

2.43.0

#3 lore raw

Re: [PATCH v3 2/4] riscv: dts: starfive: enable heartbeat LED for Milk-V Mars

Hi

On 7/1/24 21:28, Emil Renner Berthing wrote:
(snip)

Quoted 6 lines

Hi Naoki

Thanks for adding the other boards too. As mentioned previously [1] boards should not add functions to LEDs unless the hardware clearly defines a function for them, and nothing on these boards mention that it should be a heartbeeat. As you said on IRC userland can easily add whatever function they want.

on behalf of MilkV Technology, what should we do to add function to LED?

I think even if hardware clearly defines a function, you'll say userland can easily do it. any objections?

--
FUKAUMI Naoki
Shenzhen MilkV Technology Co., Ltd.

Quoted 15 lines

Also please add a cover letter when you're sending multiple patches. Eg. use git format-patch --cover-letter

/Emil

[1]: https://lore.kernel.org/linux-riscv/CAJM55Z_j8gWFyKvsiu-oGDV7Hacr4Amt5FdkHdjKnhZwZgxncA@mail.gmail.com/

Quoted 6 lines
  };

&gmac0 {
--
2.43.0

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#4 lore raw

PATCH v3 3/4 riscv: dts: starfive: enable heartbeat LED for Pine64 Star64

In reply to FUKAUMI Naoki

Pine64 Star64 has a blue LED to show system load[1]. This patch enables a blue LED as a heartbeat LED.

[1] https://github.com/Fishwaldo/Star64_linux/blob/Star64_devel/arch/riscv/boot/dts/starfive/jh7110-pine64-star64.dtsi#L79

Changes in v3:
- add default-state = "on" to turn LED on at U-Boot (not enabled yet) Changes in v2:
- new

---
 .../boot/dts/starfive/jh7110-pine64-star64.dts     | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/riscv/boot/dts/starfive/jh7110-pine64-star64.dts +14 -0
index 2d41f18e0359..b9962b4e8eca 100644
@@ -4,6 +4,8 @@
  */
 
 /dts-v1/;
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/leds/common.h>
 #include "jh7110-common.dtsi"
 
 / {
@@ -12,6 +14,18 @@ / {
 	aliases {
 		ethernet1 = &gmac1;
 	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		led-0 {
+			gpios = <&aongpio 3 GPIO_ACTIVE_HIGH>;
+			color = <LED_COLOR_ID_BLUE>;
+			default-state = "on";
+			function = LED_FUNCTION_HEARTBEAT;
+			linux,default-trigger = "heartbeat";
+		};
+	};
 };
 
 &gmac0 {
Signature · 1 line
2.43.0
#5 lore raw

PATCH v3 4/4 riscv: dts: starfive: enable heartbeat LED for StarFive VisionFive 2

In reply to FUKAUMI Naoki

StarFive VisionFive 2 has a green LED to show system load[1]. This patch enables a green LED as a heartbeat LED.

[1] https://github.com/starfive-tech/linux/blob/a61d1d826ca3060fd76ab31d37c691fc09b52fc0/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi#L79

Changes in v3:
- add default-state = "on" to turn LED on at U-Boot (not enabled yet) Changes in v2:
- new

---
 .../dts/starfive/jh7110-starfive-visionfive-2.dtsi | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi +14 -0
index 18f38fc790a4..06efbed53cc7 100644
@@ -5,12 +5,26 @@
  */
 
 /dts-v1/;
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/leds/common.h>
 #include "jh7110-common.dtsi"
 
 / {
 	aliases {
 		ethernet1 = &gmac1;
 	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		led-0 {
+			gpios = <&aongpio 3 GPIO_ACTIVE_HIGH>;
+			color = <LED_COLOR_ID_GREEN>;
+			default-state = "on";
+			function = LED_FUNCTION_HEARTBEAT;
+			linux,default-trigger = "heartbeat";
+		};
+	};
 };
 
 &gmac1 {
Signature · 1 line
2.43.0