Skip to contentSkip to conversation

rockchip: Add support for leds and buttons on Radxa E20C

PATCH Applied Jonas Karlman 2 participants 6 messages Mar 4, 2025 – Mar 8, 2025

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

v2 cover rockchip: Add support for leds and buttons on Radxa E20C

The Radxa E20C has three GPIO leds, one SARADC maskrom button and one GPIO user button.

This series add leds, gpio-keys and adc-keys nodes to board DT to describe the leds and buttons found on Radxa E20C.

Changes in v2:
- Change gpio-leds node name to leds
- Drop patches already applied
- Merge saradc and gpio button series
- Reorder patches

Board schematics for Radxa E20C can be found at [1].

[1] https://dl.radxa.com/e/e20c/v1.10/radxa_e20c_v1100_schematic.pdf

Jonas Karlman (4):
arm64: dts: rockchip: Add leds node to Radxa E20C
arm64: dts: rockchip: Add user button to Radxa E20C
arm64: dts: rockchip: Add SARADC node for RK3528
arm64: dts: rockchip: Add maskrom button to Radxa E20C

 .../boot/dts/rockchip/rk3528-radxa-e20c.dts   | 116 ++++++++++++++++++
 arch/arm64/boot/dts/rockchip/rk3528.dtsi      |  13 ++
 2 files changed, 129 insertions(+)
Signature · 1 line
2.48.1
#1 lore raw

PATCH v2 1/4 arm64: dts: rockchip: Add leds node to Radxa E20C

Radxa E20C has three gpio controlled leds (sys, wan and lan).

Add led nodes and set default trigger to heartbeat for the sys led and netdev for the lan and wan leds.

---
v2: Rename gpio-leds node to leds

---
 .../boot/dts/rockchip/rk3528-radxa-e20c.dts   | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)
arch/arm64/boot/dts/rockchip/rk3528-radxa-e20c.dts +48 -0
index 5161d22330ab..7f0237206405 100644
@@ -6,6 +6,8 @@
  */
 
 /dts-v1/;
+
+#include <dt-bindings/leds/common.h>
 #include "rk3528.dtsi"
 
 / {
@@ -15,6 +17,52 @@ / {
 	chosen {
 		stdout-path = "serial0:1500000n8";
 	};
+
+	leds {
+		compatible = "gpio-leds";
+		pinctrl-names = "default";
+		pinctrl-0 = <&lan_led_g>, <&sys_led_g>, <&wan_led_g>;
+
+		led-lan {
+			color = <LED_COLOR_ID_GREEN>;
+			default-state = "off";
+			function = LED_FUNCTION_LAN;
+			gpios = <&gpio4 RK_PB5 GPIO_ACTIVE_HIGH>;
+			linux,default-trigger = "netdev";
+		};
+
+		led-sys {
+			color = <LED_COLOR_ID_GREEN>;
+			default-state = "on";
+			function = LED_FUNCTION_HEARTBEAT;
+			gpios = <&gpio4 RK_PC1 GPIO_ACTIVE_LOW>;
+			linux,default-trigger = "heartbeat";
+		};
+
+		led-wan {
+			color = <LED_COLOR_ID_GREEN>;
+			default-state = "off";
+			function = LED_FUNCTION_WAN;
+			gpios = <&gpio4 RK_PC0 GPIO_ACTIVE_HIGH>;
+			linux,default-trigger = "netdev";
+		};
+	};
+};
+
+&pinctrl {
+	leds {
+		lan_led_g: lan-led-g {
+			rockchip,pins = <4 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>;
+		};
+
+		sys_led_g: sys-led-g {
+			rockchip,pins = <4 RK_PC1 RK_FUNC_GPIO &pcfg_pull_none>;
+		};
+
+		wan_led_g: wan-led-g {
+			rockchip,pins = <4 RK_PC0 RK_FUNC_GPIO &pcfg_pull_none>;
+		};
+	};
 };
 
 &uart0 {
Signature · 1 line
2.48.1
#2 lore raw

PATCH v2 2/4 arm64: dts: rockchip: Add user button to Radxa E20C

In reply to Jonas Karlman

Radxa E20C has two buttons, one SARADC maskrom button and one GPIO user button.

Add support for the user button using a gpio-keys node.

---
v2: No change

---
 .../boot/dts/rockchip/rk3528-radxa-e20c.dts   | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)
arch/arm64/boot/dts/rockchip/rk3528-radxa-e20c.dts +20 -0
index 7f0237206405..b378774d2a4e 100644
@@ -7,6 +7,7 @@
 
 /dts-v1/;
 
+#include <dt-bindings/input/input.h>
 #include <dt-bindings/leds/common.h>
 #include "rk3528.dtsi"
 
@@ -18,6 +19,19 @@ chosen {
 		stdout-path = "serial0:1500000n8";
 	};
 
+	gpio-keys {
+		compatible = "gpio-keys";
+		pinctrl-names = "default";
+		pinctrl-0 = <&user_key>;
+
+		button-user {
+			gpios = <&gpio0 RK_PA0 GPIO_ACTIVE_LOW>;
+			label = "USER";
+			linux,code = <BTN_1>;
+			wakeup-source;
+		};
+	};
+
 	leds {
 		compatible = "gpio-leds";
 		pinctrl-names = "default";
@@ -50,6 +64,12 @@ led-wan {
 };
 
 &pinctrl {
+	gpio-keys {
+		user_key: user-key {
+			rockchip,pins = <0 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>;
+		};
+	};
+
 	leds {
 		lan_led_g: lan-led-g {
 			rockchip,pins = <4 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>;
Signature · 1 line
2.48.1
#3 lore raw

PATCH v2 3/4 arm64: dts: rockchip: Add SARADC node for RK3528

In reply to Jonas Karlman

Add a device tree node for the SARADC controller used by RK3528.

---
v2: No change

---
 arch/arm64/boot/dts/rockchip/rk3528.dtsi | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm64/boot/dts/rockchip/rk3528.dtsi +13 -0
index b1713ed4d7e2..d3e2a64ff2d5 100644
@@ -9,6 +9,7 @@
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/pinctrl/rockchip.h>
 #include <dt-bindings/clock/rockchip,rk3528-cru.h>
+#include <dt-bindings/reset/rockchip,rk3528-cru.h>
 
 / {
 	compatible = "rockchip,rk3528";
@@ -264,6 +265,18 @@ uart7: serial@ffa28000 {
 			status = "disabled";
 		};
 
+		saradc: adc@ffae0000 {
+			compatible = "rockchip,rk3528-saradc";
+			reg = <0x0 0xffae0000 0x0 0x10000>;
+			clocks = <&cru CLK_SARADC>, <&cru PCLK_SARADC>;
+			clock-names = "saradc", "apb_pclk";
+			interrupts = <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>;
+			resets = <&cru SRST_P_SARADC>;
+			reset-names = "saradc-apb";
+			#io-channel-cells = <1>;
+			status = "disabled";
+		};
+
 		pinctrl: pinctrl {
 			compatible = "rockchip,rk3528-pinctrl";
 			rockchip,grf = <&ioc_grf>;
Signature · 1 line
2.48.1
#4 lore raw

PATCH v2 4/4 arm64: dts: rockchip: Add maskrom button to Radxa E20C

In reply to Jonas Karlman

Radxa E20C has two buttons, one SARADC maskrom button and one GPIO user button.

Add support for the maskrom button using a adc-keys node, also add the regulators used by SARADC controller.

---
v2: No change

---
 .../boot/dts/rockchip/rk3528-radxa-e20c.dts   | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)
arch/arm64/boot/dts/rockchip/rk3528-radxa-e20c.dts +48 -0
index b378774d2a4e..5346ef457c2a 100644
@@ -19,6 +19,20 @@ chosen {
 		stdout-path = "serial0:1500000n8";
 	};
 
+	adc-keys {
+		compatible = "adc-keys";
+		io-channels = <&saradc 0>;
+		io-channel-names = "buttons";
+		keyup-threshold-microvolt = <1800000>;
+		poll-interval = <100>;
+
+		button-maskrom {
+			label = "MASKROM";
+			linux,code = <KEY_SETUP>;
+			press-threshold-microvolt = <0>;
+		};
+	};
+
 	gpio-keys {
 		compatible = "gpio-keys";
 		pinctrl-names = "default";
@@ -61,6 +75,35 @@ led-wan {
 			linux,default-trigger = "netdev";
 		};
 	};
+
+	vcc_1v8: regulator-1v8-vcc {
+		compatible = "regulator-fixed";
+		regulator-name = "vcc_1v8";
+		regulator-always-on;
+		regulator-boot-on;
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+		vin-supply = <&vcc_3v3>;
+	};
+
+	vcc_3v3: regulator-3v3-vcc {
+		compatible = "regulator-fixed";
+		regulator-name = "vcc_3v3";
+		regulator-always-on;
+		regulator-boot-on;
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		vin-supply = <&vcc5v0_sys>;
+	};
+
+	vcc5v0_sys: regulator-5v0-vcc-sys {
+		compatible = "regulator-fixed";
+		regulator-name = "vcc5v0_sys";
+		regulator-always-on;
+		regulator-boot-on;
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+	};
 };
 
 &pinctrl {
@@ -85,6 +128,11 @@ wan_led_g: wan-led-g {
 	};
 };
 
+&saradc {
+	vref-supply = <&vcc_1v8>;
+	status = "okay";
+};
+
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0m0_xfer>;
Signature · 1 line
2.48.1
maintainer Applied
#5 lore raw
In reply to Jonas Karlman
Quoted 6 lines · Jonas Karlman

The Radxa E20C has three GPIO leds, one SARADC maskrom button and one GPIO user button.

This series add leds, gpio-keys and adc-keys nodes to board DT to describe the leds and buttons found on Radxa E20C.

Quoted 7 lines

Changes in v2:
- Change gpio-leds node name to leds
- Drop patches already applied
- Merge saradc and gpio button series
- Reorder patches

[...]

Applied, thanks!

[1/4] arm64: dts: rockchip: Add leds node to Radxa E20C

      commit: 6a709e003492e9878d5f1357be0b2e1162e1e6a6
[2/4] arm64: dts: rockchip: Add user button to Radxa E20C
      commit: ad8afc8813567994164f2720189c819da8c22b99
[3/4] arm64: dts: rockchip: Add SARADC node for RK3528
      commit: 6e58302c84ce90aadbecd41efe1f69098a6f91e5
[4/4] arm64: dts: rockchip: Add maskrom button to Radxa E20C
      commit: 3a2819ee9c71d1c6388e456cc4eb042914d15d7e

Best regards,

Signature · 1 line
Heiko Stuebner <[email protected]>