* [PATCH v4 1/2] dt-bindings: input: gpio-keys: add pinctrl states
2026-10-05 20:47 [PATCH v4 0/2] Input: gpio-keys - support wakeup pinctrl state Kendall Willis
@ 2026-10-05 20:47 ` Kendall Willis
2026-10-05 20:47 ` [PATCH v4 2/2] Input: gpio-keys - support wakeup pinctrl state on suspend Kendall Willis
2026-10-19 12:59 ` [PATCH v4 0/2] Input: gpio-keys - support wakeup pinctrl state Francesco Dolcini
2 siblings, 0 replies; 4+ messages in thread
From: Kendall Willis @ 2026-10-05 20:47 UTC (permalink / raw)
To: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: msp, s-kochidanadu, a-kaur, s-tripathi1, vishalm, k-willis,
linux-input, linux-kernel, devicetree
Document pinctrl properties on the gpio-keys device node. The default
pinctrl state describes the default pin configuration. The wakeup state
configures pins to be able to wakeup the system from suspend if GPIO is a
wakeup source.
The pinctrl sleep state is not defined here despite being used to configure
pins for system suspend to save power. It is not defined since no
gpio-key device tree nodes utilize it. If the sleep state was added, a
device could use both the wakeup state and sleep state. The sleep state
would be entered upon suspend when wakeup is disabled for the device,
whereas the wakeup state would be entered upon suspend if wakeup is enabled
for the device. For now only the wakeup state is defined since it is
used specifically to enable pin configurations that can wakeup the
system from suspend.
Signed-off-by: Kendall Willis <k-willis@ti.com>
---
Documentation/devicetree/bindings/input/gpio-keys.yaml | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/Documentation/devicetree/bindings/input/gpio-keys.yaml b/Documentation/devicetree/bindings/input/gpio-keys.yaml
index cc78c2152921308fe0cad3e29ca78a5fad08f066..a0712fba45845e42ca63489354e0cae87de2143f 100644
--- a/Documentation/devicetree/bindings/input/gpio-keys.yaml
+++ b/Documentation/devicetree/bindings/input/gpio-keys.yaml
@@ -22,6 +22,22 @@ properties:
poll-interval: true
+ pinctrl-0:
+ description: Default pinctrl state
+
+ pinctrl-1:
+ description: Wakeup pinctrl state
+
+ pinctrl-names:
+ description:
+ When present should contain at least "default" describing the default pin
+ states. The "wakeup" state describes the pin state used to wakeup the system
+ when wakeup is enabled and the system is suspended.
+ minItems: 1
+ items:
+ - const: default
+ - const: wakeup
+
patternProperties:
"^(button|event|key|switch|(button|event|key|switch)-[a-z0-9-]+|[a-z0-9-]+-(button|event|key|switch))$":
$ref: input.yaml#
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v4 2/2] Input: gpio-keys - support wakeup pinctrl state on suspend
2026-10-05 20:47 [PATCH v4 0/2] Input: gpio-keys - support wakeup pinctrl state Kendall Willis
2026-10-05 20:47 ` [PATCH v4 1/2] dt-bindings: input: gpio-keys: add pinctrl states Kendall Willis
@ 2026-10-05 20:47 ` Kendall Willis
2026-10-19 12:59 ` [PATCH v4 0/2] Input: gpio-keys - support wakeup pinctrl state Francesco Dolcini
2 siblings, 0 replies; 4+ messages in thread
From: Kendall Willis @ 2026-10-05 20:47 UTC (permalink / raw)
To: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: msp, s-kochidanadu, a-kaur, s-tripathi1, vishalm, k-willis,
linux-input, linux-kernel, devicetree
GPIO can be used as a wakeup source for TI K3 AM62 devices during
suspend to RAM states. The GPIO controller is powered off in these
states, so a wakeup enable flag must be set on the GPIO pin in the
pinctrl in order to allow wakeup.
If the device is wakeup enabled, select the wakeup pinctrl state on
suspend and restore the default pinctrl state on resume.
Signed-off-by: Kendall Willis <k-willis@ti.com>
---
drivers/input/keyboard/gpio_keys.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 129fc4212a5ed126496b331ce626682d441c53bf..8d3409c6de1ea87ccc118b2d6ba9ffc313caa027 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -28,6 +28,7 @@
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/spinlock.h>
+#include <linux/pinctrl/consumer.h>
#include <dt-bindings/input/gpio-keys.h>
struct gpio_button_data {
@@ -60,6 +61,8 @@ struct gpio_keys_drvdata {
struct input_dev *input;
struct mutex disable_lock;
unsigned short *keymap;
+ struct pinctrl *pinctrl;
+ struct pinctrl_state *pinctrl_wakeup;
struct gpio_button_data data[];
};
@@ -884,6 +887,17 @@ static int gpio_keys_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, ddata);
input_set_drvdata(input, ddata);
+ ddata->pinctrl = devm_pinctrl_get(dev);
+ if (IS_ERR(ddata->pinctrl)) {
+ error = PTR_ERR(ddata->pinctrl);
+ ddata->pinctrl = NULL;
+
+ if (error != -ENODEV)
+ return dev_err_probe(dev, error, "Failed to get pinctrl\n");
+ } else if (ddata->pinctrl) {
+ ddata->pinctrl_wakeup = pinctrl_lookup_state(ddata->pinctrl, "wakeup");
+ }
+
input->name = pdata->name ? : pdev->name;
input->phys = "gpio-keys/input0";
input->dev.parent = dev;
@@ -1010,6 +1024,12 @@ gpio_keys_enable_wakeup(struct gpio_keys_drvdata *ddata)
int error;
int i;
+ if (!IS_ERR_OR_NULL(ddata->pinctrl_wakeup)) {
+ error = pinctrl_select_state(ddata->pinctrl, ddata->pinctrl_wakeup);
+ if (error)
+ return error;
+ }
+
for (i = 0; i < ddata->pdata->nbuttons; i++) {
bdata = &ddata->data[i];
if (bdata->button->wakeup) {
@@ -1023,6 +1043,9 @@ gpio_keys_enable_wakeup(struct gpio_keys_drvdata *ddata)
return 0;
err_out:
+ if (!IS_ERR_OR_NULL(ddata->pinctrl_wakeup))
+ pinctrl_pm_select_default_state(ddata->input->dev.parent);
+
while (i--) {
bdata = &ddata->data[i];
if (bdata->button->wakeup)
@@ -1039,6 +1062,9 @@ gpio_keys_disable_wakeup(struct gpio_keys_drvdata *ddata)
struct gpio_button_data *bdata;
int i;
+ if (!IS_ERR_OR_NULL(ddata->pinctrl_wakeup))
+ pinctrl_pm_select_default_state(ddata->input->dev.parent);
+
for (i = 0; i < ddata->pdata->nbuttons; i++) {
bdata = &ddata->data[i];
bdata->suspended = false;
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v4 0/2] Input: gpio-keys - support wakeup pinctrl state
2026-10-05 20:47 [PATCH v4 0/2] Input: gpio-keys - support wakeup pinctrl state Kendall Willis
2026-10-05 20:47 ` [PATCH v4 1/2] dt-bindings: input: gpio-keys: add pinctrl states Kendall Willis
2026-10-05 20:47 ` [PATCH v4 2/2] Input: gpio-keys - support wakeup pinctrl state on suspend Kendall Willis
@ 2026-10-19 12:59 ` Francesco Dolcini
2 siblings, 0 replies; 4+ messages in thread
From: Francesco Dolcini @ 2026-10-19 12:59 UTC (permalink / raw)
To: Kendall Willis
Cc: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
msp, s-kochidanadu, a-kaur, s-tripathi1, vishalm, linux-input,
linux-kernel, devicetree
Hello Kendall,
On Mon, Oct 05, 2026 at 03:47:03PM -0500, Kendall Willis wrote:
> Add 'wakeup' pinctrl state to support separate pin wakeup
> configurations for GPIO. Upon suspend the 'wakeup' pinctrl state is
> chosen if it exists. On resume the 'default' pinctrl state is selected.
> The 'wakeup' pinctrl state allows wakeup from low-power states if a
> specific pin configuration is needed.
>
> On TI K3 AM62 family of devices, the GPIO controller is turned off in
> suspend to RAM states, so no interrupt can be received by the
> controller. This prevents system wakeup from low-power states.
> Alternatively, the pins can wakeup the system if a wakeup flag is set on
> the pin by using pinctrl.
>
> A corresponding device tree patch using the 'wakeup' pinctrl state can
> be found under "arm64: dts: ti: k3-am62l3-evm: add wakeup-source for GPIO
> button" [1].
>
> Tested GPIO wakeup from suspend on AM62L EVM and AM62P EVM.
>
> [1] https://lore.kernel.org/all/20260912-upstream-gpio-wakeup-dts-v1-1-2057d76c63aa@ti.com/
>
> Signed-off-by: Kendall Willis <k-willis@ti.com>
What's the plan/status on this? I see rob reviewed the bindings patch
(in v3), but the tag is lost here.
We would benefit for having this merged, Toradex Verdin AM62 needs this
feature.
Francesco
^ permalink raw reply [flat|nested] 4+ messages in thread