linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] Radxa NIO 12L: Add GPIO keys and LED support
@ 2025-08-26 14:01 Julien Massot
  2025-08-26 14:01 ` [PATCH v2 1/3] Input: mtk-pmic-keys - MT6359 has a specific release irq Julien Massot
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Julien Massot @ 2025-08-26 14:01 UTC (permalink / raw)
  To: kernel, Dmitry Torokhov, Matthias Brugger,
	AngeloGioacchino Del Regno, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Louis-Alexis Eyraud
  Cc: linux-input, linux-kernel, linux-arm-kernel, linux-mediatek,
	devicetree, Julien Massot

This patchset adds support for the GPIO-connected red and blue LEDs,
as well as the various hardware buttons present on the Radxa NIO 12L
board.

It also includes a fix for the missing release (key-up) interrupt
handling for PMIC-managed GPIO keys.

Signed-off-by: Julien Massot <julien.massot@collabora.com>
---
Changes in v2:
PATCH 1/3
- Add Fixes tag
- Drop Angelo's Reviewed-By since I'm now introducing the
'key_release_irq' member that was missing in v1.
- Link to v1: https://lore.kernel.org/r/20250801-radxa-nio-12-l-gpio-v1-0-d0840f85d2c8@collabora.com

---
Julien Massot (3):
      Input: mtk-pmic-keys - MT6359 has a specific release irq
      arm64: dts: mediatek: mt8395-nio-12l: add PMIC and GPIO keys support
      arm64: dts: mediatek: mt8395-nio-12l: add support for blue and red LEDs

 .../boot/dts/mediatek/mt8395-radxa-nio-12l.dts     | 67 ++++++++++++++++++++++
 drivers/input/keyboard/mtk-pmic-keys.c             |  5 +-
 2 files changed, 71 insertions(+), 1 deletion(-)
---
base-commit: 6c68f4c0a147c025ae0b25fab688c7c47964a02f
change-id: 20250801-radxa-nio-12-l-gpio-54f208c25333

Best regards,
-- 
Julien Massot <julien.massot@collabora.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/3] Input: mtk-pmic-keys - MT6359 has a specific release irq
  2025-08-26 14:01 [PATCH v2 0/3] Radxa NIO 12L: Add GPIO keys and LED support Julien Massot
@ 2025-08-26 14:01 ` Julien Massot
  2025-08-26 14:01 ` [PATCH v2 2/3] arm64: dts: mediatek: mt8395-nio-12l: add PMIC and GPIO keys support Julien Massot
  2025-08-26 14:01 ` [PATCH v2 3/3] arm64: dts: mediatek: mt8395-nio-12l: add support for blue and red LEDs Julien Massot
  2 siblings, 0 replies; 6+ messages in thread
From: Julien Massot @ 2025-08-26 14:01 UTC (permalink / raw)
  To: kernel, Dmitry Torokhov, Matthias Brugger,
	AngeloGioacchino Del Regno, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Louis-Alexis Eyraud
  Cc: linux-input, linux-kernel, linux-arm-kernel, linux-mediatek,
	devicetree, Julien Massot

A recent commit in linux-next added support for key events.
However, the key release event is not properly handled:
only key press events are generated, leaving key states
stuck in "pressed".

This patch ensures that both key press and key release events
are properly emitted by handling the release logic correctly.

Introduce a 'key_release_irq' member to the 'mtk_pmic_regs',
to identify the devices that have a separate irq for the
release event.

Fixes: bc25e6bf032e ("Input: mtk-pmic-keys - add support for MT6359 PMIC keys")
Signed-off-by: Julien Massot <julien.massot@collabora.com>
---
 drivers/input/keyboard/mtk-pmic-keys.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c
index 50e2e792c91d2626d3f282d04a1db60845827ef2..c78d9f6d97c4f7a77b4c44cee3b93e4712a19aec 100644
--- a/drivers/input/keyboard/mtk-pmic-keys.c
+++ b/drivers/input/keyboard/mtk-pmic-keys.c
@@ -55,6 +55,7 @@ struct mtk_pmic_regs {
 	const struct mtk_pmic_keys_regs keys_regs[MTK_PMIC_MAX_KEY_COUNT];
 	u32 pmic_rst_reg;
 	u32 rst_lprst_mask; /* Long-press reset timeout bitmask */
+	bool key_release_irq;
 };
 
 static const struct mtk_pmic_regs mt6397_regs = {
@@ -116,6 +117,7 @@ static const struct mtk_pmic_regs mt6358_regs = {
 				   MTK_PMIC_HOMEKEY_RST),
 	.pmic_rst_reg = MT6358_TOP_RST_MISC,
 	.rst_lprst_mask = MTK_PMIC_RST_DU_MASK,
+	.key_release_irq = true,
 };
 
 static const struct mtk_pmic_regs mt6359_regs = {
@@ -129,6 +131,7 @@ static const struct mtk_pmic_regs mt6359_regs = {
 				   MTK_PMIC_HOMEKEY_RST),
 	.pmic_rst_reg = MT6359_TOP_RST_MISC,
 	.rst_lprst_mask = MTK_PMIC_RST_DU_MASK,
+	.key_release_irq = true,
 };
 
 struct mtk_pmic_keys_info {
@@ -368,7 +371,7 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)
 		if (keys->keys[index].irq < 0)
 			return keys->keys[index].irq;
 
-		if (of_device_is_compatible(node, "mediatek,mt6358-keys")) {
+		if (mtk_pmic_regs->key_release_irq) {
 			keys->keys[index].irq_r = platform_get_irq_byname(pdev,
 									  irqnames_r[index]);
 

-- 
2.50.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/3] arm64: dts: mediatek: mt8395-nio-12l: add PMIC and GPIO keys support
  2025-08-26 14:01 [PATCH v2 0/3] Radxa NIO 12L: Add GPIO keys and LED support Julien Massot
  2025-08-26 14:01 ` [PATCH v2 1/3] Input: mtk-pmic-keys - MT6359 has a specific release irq Julien Massot
@ 2025-08-26 14:01 ` Julien Massot
  2025-08-26 14:01 ` [PATCH v2 3/3] arm64: dts: mediatek: mt8395-nio-12l: add support for blue and red LEDs Julien Massot
  2 siblings, 0 replies; 6+ messages in thread
From: Julien Massot @ 2025-08-26 14:01 UTC (permalink / raw)
  To: kernel, Dmitry Torokhov, Matthias Brugger,
	AngeloGioacchino Del Regno, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Louis-Alexis Eyraud
  Cc: linux-input, linux-kernel, linux-arm-kernel, linux-mediatek,
	devicetree, Julien Massot

Add support for PMIC and GPIO keys on the Radxa NIO 12L board:
Declare a gpio-keys node for the Volume Up button using GPIO106.
Add the corresponding pin configuration in the pinctrl node.
Add a mediatek,mt6359-keys subnode under the PMIC to handle the
power and home buttons exposed by the MT6359.

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Julien Massot <julien.massot@collabora.com>
---
 .../boot/dts/mediatek/mt8395-radxa-nio-12l.dts     | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8395-radxa-nio-12l.dts b/arch/arm64/boot/dts/mediatek/mt8395-radxa-nio-12l.dts
index 329c60cc6a6be0b4be8c0b8bb033b32d35302804..fd596e2298285361ad7c2fb828feec598d75a73e 100644
--- a/arch/arm64/boot/dts/mediatek/mt8395-radxa-nio-12l.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8395-radxa-nio-12l.dts
@@ -8,6 +8,7 @@
 #include "mt8195.dtsi"
 #include "mt6359.dtsi"
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/pinctrl/mt8195-pinfunc.h>
 #include <dt-bindings/regulator/mediatek,mt6360-regulator.h>
@@ -60,6 +61,18 @@ backlight: backlight {
 		status = "disabled";
 	};
 
+	keys: gpio-keys {
+		compatible = "gpio-keys";
+
+		button-volume-up {
+			wakeup-source;
+			debounce-interval = <100>;
+			gpios = <&pio 106 GPIO_ACTIVE_LOW>;
+			label = "volume_up";
+			linux,code = <KEY_VOLUMEUP>;
+		};
+	};
+
 	wifi_vreg: regulator-wifi-3v3-en {
 		compatible = "regulator-fixed";
 		regulator-name = "wifi_3v3_en";
@@ -626,6 +639,14 @@ pins-txd {
 		};
 	};
 
+	gpio_key_pins: gpio-keys-pins {
+		pins {
+			pinmux = <PINMUX_GPIO106__FUNC_GPIO106>;
+			bias-pull-up;
+			input-enable;
+		};
+	};
+
 	i2c2_pins: i2c2-pins {
 		pins-bus {
 			pinmux = <PINMUX_GPIO12__FUNC_SDA2>,
@@ -880,6 +901,21 @@ &pciephy {
 
 &pmic {
 	interrupts-extended = <&pio 222 IRQ_TYPE_LEVEL_HIGH>;
+
+	mt6359keys: keys {
+		compatible = "mediatek,mt6359-keys";
+		mediatek,long-press-mode = <1>;
+		power-off-time-sec = <0>;
+
+		power-key {
+			linux,keycodes = <KEY_POWER>;
+			wakeup-source;
+		};
+
+		home {
+			linux,keycodes = <KEY_HOME>;
+		};
+	};
 };
 
 &scp {

-- 
2.50.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/3] arm64: dts: mediatek: mt8395-nio-12l: add support for blue and red LEDs
  2025-08-26 14:01 [PATCH v2 0/3] Radxa NIO 12L: Add GPIO keys and LED support Julien Massot
  2025-08-26 14:01 ` [PATCH v2 1/3] Input: mtk-pmic-keys - MT6359 has a specific release irq Julien Massot
  2025-08-26 14:01 ` [PATCH v2 2/3] arm64: dts: mediatek: mt8395-nio-12l: add PMIC and GPIO keys support Julien Massot
@ 2025-08-26 14:01 ` Julien Massot
  2025-08-27  7:40   ` Alexander Dahl
  2 siblings, 1 reply; 6+ messages in thread
From: Julien Massot @ 2025-08-26 14:01 UTC (permalink / raw)
  To: kernel, Dmitry Torokhov, Matthias Brugger,
	AngeloGioacchino Del Regno, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Louis-Alexis Eyraud
  Cc: linux-input, linux-kernel, linux-arm-kernel, linux-mediatek,
	devicetree, Julien Massot

The Radxa NIO 12L board has an RGB LED, of which only red and blue
are controllable.

Red and blue LEDs: no need to choose, both are enabled.

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Julien Massot <julien.massot@collabora.com>
---
 .../boot/dts/mediatek/mt8395-radxa-nio-12l.dts     | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8395-radxa-nio-12l.dts b/arch/arm64/boot/dts/mediatek/mt8395-radxa-nio-12l.dts
index fd596e2298285361ad7c2fb828feec598d75a73e..12288ad4d2932b7f78c96c0efe366a046721f919 100644
--- a/arch/arm64/boot/dts/mediatek/mt8395-radxa-nio-12l.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8395-radxa-nio-12l.dts
@@ -10,6 +10,7 @@
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
 #include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/leds/common.h>
 #include <dt-bindings/pinctrl/mt8195-pinfunc.h>
 #include <dt-bindings/regulator/mediatek,mt6360-regulator.h>
 #include <dt-bindings/spmi/spmi.h>
@@ -73,6 +74,28 @@ button-volume-up {
 		};
 	};
 
+	gpio-leds {
+		compatible = "gpio-leds";
+		pinctrl-0 = <&gpio_leds_pins>;
+		pinctrl-names = "default";
+
+		/*
+		 * This board has a RGB LED, of which only R and B
+		 * are controllable.
+		 */
+		led-0 {
+			label = "rgb-blue";
+			color = <LED_COLOR_ID_BLUE>;
+			gpios = <&pio 6 GPIO_ACTIVE_HIGH>;
+		};
+
+		led-1 {
+			label = "rgb-red";
+			color = <LED_COLOR_ID_RED>;
+			gpios = <&pio 7 GPIO_ACTIVE_HIGH>;
+		};
+	};
+
 	wifi_vreg: regulator-wifi-3v3-en {
 		compatible = "regulator-fixed";
 		regulator-name = "wifi_3v3_en";
@@ -647,6 +670,14 @@ pins {
 		};
 	};
 
+	gpio_leds_pins: gpio-leds-pins {
+		pins {
+			pinmux = <PINMUX_GPIO6__FUNC_GPIO6>,
+				 <PINMUX_GPIO7__FUNC_GPIO7>;
+			output-low;
+		};
+	};
+
 	i2c2_pins: i2c2-pins {
 		pins-bus {
 			pinmux = <PINMUX_GPIO12__FUNC_SDA2>,

-- 
2.50.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 3/3] arm64: dts: mediatek: mt8395-nio-12l: add support for blue and red LEDs
  2025-08-26 14:01 ` [PATCH v2 3/3] arm64: dts: mediatek: mt8395-nio-12l: add support for blue and red LEDs Julien Massot
@ 2025-08-27  7:40   ` Alexander Dahl
  2025-08-27  9:04     ` Julien Massot
  0 siblings, 1 reply; 6+ messages in thread
From: Alexander Dahl @ 2025-08-27  7:40 UTC (permalink / raw)
  To: Julien Massot
  Cc: kernel, Dmitry Torokhov, Matthias Brugger,
	AngeloGioacchino Del Regno, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Louis-Alexis Eyraud, linux-input, linux-kernel,
	linux-arm-kernel, linux-mediatek, devicetree

Hello Julien,

Am Tue, Aug 26, 2025 at 04:01:54PM +0200 schrieb Julien Massot:
> The Radxa NIO 12L board has an RGB LED, of which only red and blue
> are controllable.
> 
> Red and blue LEDs: no need to choose, both are enabled.
> 
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Julien Massot <julien.massot@collabora.com>
> ---
>  .../boot/dts/mediatek/mt8395-radxa-nio-12l.dts     | 31 ++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/mediatek/mt8395-radxa-nio-12l.dts b/arch/arm64/boot/dts/mediatek/mt8395-radxa-nio-12l.dts
> index fd596e2298285361ad7c2fb828feec598d75a73e..12288ad4d2932b7f78c96c0efe366a046721f919 100644
> --- a/arch/arm64/boot/dts/mediatek/mt8395-radxa-nio-12l.dts
> +++ b/arch/arm64/boot/dts/mediatek/mt8395-radxa-nio-12l.dts
> @@ -10,6 +10,7 @@
>  #include <dt-bindings/gpio/gpio.h>
>  #include <dt-bindings/input/input.h>
>  #include <dt-bindings/interrupt-controller/irq.h>
> +#include <dt-bindings/leds/common.h>
>  #include <dt-bindings/pinctrl/mt8195-pinfunc.h>
>  #include <dt-bindings/regulator/mediatek,mt6360-regulator.h>
>  #include <dt-bindings/spmi/spmi.h>
> @@ -73,6 +74,28 @@ button-volume-up {
>  		};
>  	};
>  
> +	gpio-leds {
> +		compatible = "gpio-leds";
> +		pinctrl-0 = <&gpio_leds_pins>;
> +		pinctrl-names = "default";
> +
> +		/*
> +		 * This board has a RGB LED, of which only R and B
> +		 * are controllable.
> +		 */
> +		led-0 {
> +			label = "rgb-blue";
> +			color = <LED_COLOR_ID_BLUE>;
> +			gpios = <&pio 6 GPIO_ACTIVE_HIGH>;
> +		};
> +
> +		led-1 {
> +			label = "rgb-red";
> +			color = <LED_COLOR_ID_RED>;
> +			gpios = <&pio 7 GPIO_ACTIVE_HIGH>;
> +		};

The label property is deprecated, and if I'm not mistaken not
recommended for new boards.  Do you have a reason to set it?
If so, it might be worth adding in the commit message.

Greets
Alex

> +	};
> +
>  	wifi_vreg: regulator-wifi-3v3-en {
>  		compatible = "regulator-fixed";
>  		regulator-name = "wifi_3v3_en";
> @@ -647,6 +670,14 @@ pins {
>  		};
>  	};
>  
> +	gpio_leds_pins: gpio-leds-pins {
> +		pins {
> +			pinmux = <PINMUX_GPIO6__FUNC_GPIO6>,
> +				 <PINMUX_GPIO7__FUNC_GPIO7>;
> +			output-low;
> +		};
> +	};
> +
>  	i2c2_pins: i2c2-pins {
>  		pins-bus {
>  			pinmux = <PINMUX_GPIO12__FUNC_SDA2>,
> 
> -- 
> 2.50.1
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 3/3] arm64: dts: mediatek: mt8395-nio-12l: add support for blue and red LEDs
  2025-08-27  7:40   ` Alexander Dahl
@ 2025-08-27  9:04     ` Julien Massot
  0 siblings, 0 replies; 6+ messages in thread
From: Julien Massot @ 2025-08-27  9:04 UTC (permalink / raw)
  To: kernel, Dmitry Torokhov, Matthias Brugger,
	AngeloGioacchino Del Regno, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Louis-Alexis Eyraud, linux-input, linux-kernel,
	linux-arm-kernel, linux-mediatek, devicetree

Hi Alexander,

On Wed, 2025-08-27 at 09:40 +0200, Alexander Dahl wrote:
> Hello Julien,
> 
> Am Tue, Aug 26, 2025 at 04:01:54PM +0200 schrieb Julien Massot:
> > The Radxa NIO 12L board has an RGB LED, of which only red and blue
> > are controllable.
> > 
> > Red and blue LEDs: no need to choose, both are enabled.
> > 
> > Reviewed-by: AngeloGioacchino Del Regno
> > <angelogioacchino.delregno@collabora.com>
> > Signed-off-by: Julien Massot <julien.massot@collabora.com>
> > ---
> >  .../boot/dts/mediatek/mt8395-radxa-nio-12l.dts     | 31
> > ++++++++++++++++++++++
> >  1 file changed, 31 insertions(+)
> > 
> > diff --git a/arch/arm64/boot/dts/mediatek/mt8395-radxa-nio-12l.dts
> > b/arch/arm64/boot/dts/mediatek/mt8395-radxa-nio-12l.dts
> > index
> > fd596e2298285361ad7c2fb828feec598d75a73e..12288ad4d2932b7f78c96c0efe36
> > 6a046721f919 100644
> > --- a/arch/arm64/boot/dts/mediatek/mt8395-radxa-nio-12l.dts
> > +++ b/arch/arm64/boot/dts/mediatek/mt8395-radxa-nio-12l.dts
> > @@ -10,6 +10,7 @@
> >  #include <dt-bindings/gpio/gpio.h>
> >  #include <dt-bindings/input/input.h>
> >  #include <dt-bindings/interrupt-controller/irq.h>
> > +#include <dt-bindings/leds/common.h>
> >  #include <dt-bindings/pinctrl/mt8195-pinfunc.h>
> >  #include <dt-bindings/regulator/mediatek,mt6360-regulator.h>
> >  #include <dt-bindings/spmi/spmi.h>
> > @@ -73,6 +74,28 @@ button-volume-up {
> >  		};
> >  	};
> >  
> > +	gpio-leds {
> > +		compatible = "gpio-leds";
> > +		pinctrl-0 = <&gpio_leds_pins>;
> > +		pinctrl-names = "default";
> > +
> > +		/*
> > +		 * This board has a RGB LED, of which only R and B
> > +		 * are controllable.
> > +		 */
> > +		led-0 {
> > +			label = "rgb-blue";
> > +			color = <LED_COLOR_ID_BLUE>;
> > +			gpios = <&pio 6 GPIO_ACTIVE_HIGH>;
> > +		};
> > +
> > +		led-1 {
> > +			label = "rgb-red";
> > +			color = <LED_COLOR_ID_RED>;
> > +			gpios = <&pio 7 GPIO_ACTIVE_HIGH>;
> > +		};
> 
> The label property is deprecated, and if I'm not mistaken not
> recommended for new boards.  Do you have a reason to set it?
> If so, it might be worth adding in the commit message.

No, I just wasn’t aware of the deprecation, but I can now see
it in the common LED binding.
I’ll wait a bit for any other potential reviews and then resend
the patch without the label. The LED will then appear as 'blue'
instead of 'rgb-blue' in sysfs.

Regards,
Julien

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-08-27  9:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-26 14:01 [PATCH v2 0/3] Radxa NIO 12L: Add GPIO keys and LED support Julien Massot
2025-08-26 14:01 ` [PATCH v2 1/3] Input: mtk-pmic-keys - MT6359 has a specific release irq Julien Massot
2025-08-26 14:01 ` [PATCH v2 2/3] arm64: dts: mediatek: mt8395-nio-12l: add PMIC and GPIO keys support Julien Massot
2025-08-26 14:01 ` [PATCH v2 3/3] arm64: dts: mediatek: mt8395-nio-12l: add support for blue and red LEDs Julien Massot
2025-08-27  7:40   ` Alexander Dahl
2025-08-27  9:04     ` Julien Massot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).