* [PATCH] ARM: boards: protonic-imx6: prtvt7: Use the input system for key detection
@ 2025-03-31 15:05 Robin van der Gracht
2025-04-01 5:52 ` Sascha Hauer
2025-04-01 5:58 ` Sascha Hauer
0 siblings, 2 replies; 4+ messages in thread
From: Robin van der Gracht @ 2025-03-31 15:05 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox, Robin van der Gracht
Static gpio mapping is deprecated. Instead query the gpio-keys driver for
pressed keys.
Signed-off-by: Robin van der Gracht <robin@protonic.nl>
---
arch/arm/boards/protonic-imx6/board.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/arch/arm/boards/protonic-imx6/board.c b/arch/arm/boards/protonic-imx6/board.c
index 9292052d30..4bfae3d608 100644
--- a/arch/arm/boards/protonic-imx6/board.c
+++ b/arch/arm/boards/protonic-imx6/board.c
@@ -13,6 +13,7 @@
#include <globalvar.h>
#include <gpio.h>
#include <i2c/i2c.h>
+#include <input/input.h>
#include <mach/imx/bbu.h>
#include <mach/imx/imx6.h>
#include <mach/imx/ocotp-fusemap.h>
@@ -740,19 +741,21 @@ static int prt_imx6_init_kvg_yaco(struct prt_imx6_priv *priv)
return prt_imx6_init_kvg_power(priv, PW_MODE_KVG_WITH_YACO);
}
-#define GPIO_KEY_F6 (0xe0 + 5)
-#define GPIO_KEY_CYCLE (0xe0 + 2)
-
static int prt_imx6_init_prtvt7(struct prt_imx6_priv *priv)
{
- /* This function relies heavely on the gpio-pca9539 driver */
+ unsigned long *keys;
- gpio_direction_input(GPIO_KEY_F6);
- gpio_direction_input(GPIO_KEY_CYCLE);
+ /*
+ * Prefer USB-boot and enable autoboot with timeout when CYCLE-F6 key
+ * combination is pressed.
+ */
+ keys = xzalloc((KEY_CYCLEWINDOWS / 8) + 1);
+ input_key_get_status(keys, KEY_CYCLEWINDOWS);
- if (gpio_get_value(GPIO_KEY_CYCLE) && gpio_get_value(GPIO_KEY_F6))
+ if (!(test_bit(KEY_CYCLEWINDOWS, keys) && test_bit(KEY_F6, keys)))
priv->no_usb_check = 1;
+ free(keys);
return 0;
}
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ARM: boards: protonic-imx6: prtvt7: Use the input system for key detection
2025-03-31 15:05 [PATCH] ARM: boards: protonic-imx6: prtvt7: Use the input system for key detection Robin van der Gracht
@ 2025-04-01 5:52 ` Sascha Hauer
2025-04-01 5:58 ` Sascha Hauer
1 sibling, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2025-04-01 5:52 UTC (permalink / raw)
To: Robin van der Gracht; +Cc: barebox
On Mon, 31 Mar 2025 17:05:28 +0200, Robin van der Gracht wrote:
> Static gpio mapping is deprecated. Instead query the gpio-keys driver for
> pressed keys.
>
>
Applied, thanks!
[1/1] ARM: boards: protonic-imx6: prtvt7: Use the input system for key detection
https://git.pengutronix.de/cgit/barebox/commit/?id=e44d472d128d (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ARM: boards: protonic-imx6: prtvt7: Use the input system for key detection
2025-03-31 15:05 [PATCH] ARM: boards: protonic-imx6: prtvt7: Use the input system for key detection Robin van der Gracht
2025-04-01 5:52 ` Sascha Hauer
@ 2025-04-01 5:58 ` Sascha Hauer
2025-04-01 6:27 ` Robin van der Gracht
1 sibling, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2025-04-01 5:58 UTC (permalink / raw)
To: Robin van der Gracht; +Cc: barebox
On Mon, Mar 31, 2025 at 05:05:28PM +0200, Robin van der Gracht wrote:
> Static gpio mapping is deprecated. Instead query the gpio-keys driver for
> pressed keys.
>
> Signed-off-by: Robin van der Gracht <robin@protonic.nl>
> ---
> arch/arm/boards/protonic-imx6/board.c | 17 ++++++++++-------
> 1 file changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/arch/arm/boards/protonic-imx6/board.c b/arch/arm/boards/protonic-imx6/board.c
> index 9292052d30..4bfae3d608 100644
> --- a/arch/arm/boards/protonic-imx6/board.c
> +++ b/arch/arm/boards/protonic-imx6/board.c
> @@ -13,6 +13,7 @@
> #include <globalvar.h>
> #include <gpio.h>
> #include <i2c/i2c.h>
> +#include <input/input.h>
> #include <mach/imx/bbu.h>
> #include <mach/imx/imx6.h>
> #include <mach/imx/ocotp-fusemap.h>
> @@ -740,19 +741,21 @@ static int prt_imx6_init_kvg_yaco(struct prt_imx6_priv *priv)
> return prt_imx6_init_kvg_power(priv, PW_MODE_KVG_WITH_YACO);
> }
>
> -#define GPIO_KEY_F6 (0xe0 + 5)
> -#define GPIO_KEY_CYCLE (0xe0 + 2)
> -
> static int prt_imx6_init_prtvt7(struct prt_imx6_priv *priv)
> {
> - /* This function relies heavely on the gpio-pca9539 driver */
> + unsigned long *keys;
>
> - gpio_direction_input(GPIO_KEY_F6);
> - gpio_direction_input(GPIO_KEY_CYCLE);
I added a
of_devices_ensure_probed_by_compatible("gpio-keys");
here to be sure you don't depend on probe order.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ARM: boards: protonic-imx6: prtvt7: Use the input system for key detection
2025-04-01 5:58 ` Sascha Hauer
@ 2025-04-01 6:27 ` Robin van der Gracht
0 siblings, 0 replies; 4+ messages in thread
From: Robin van der Gracht @ 2025-04-01 6:27 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
On 01-04-2025 07:58, Sascha Hauer wrote:
> On Mon, Mar 31, 2025 at 05:05:28PM +0200, Robin van der Gracht wrote:
>> Static gpio mapping is deprecated. Instead query the gpio-keys driver for
>> pressed keys.
>>
>> Signed-off-by: Robin van der Gracht <robin@protonic.nl>
>> ---
>> arch/arm/boards/protonic-imx6/board.c | 17 ++++++++++-------
>> 1 file changed, 10 insertions(+), 7 deletions(-)
>>
>> diff --git a/arch/arm/boards/protonic-imx6/board.c b/arch/arm/boards/protonic-imx6/board.c
>> index 9292052d30..4bfae3d608 100644
>> --- a/arch/arm/boards/protonic-imx6/board.c
>> +++ b/arch/arm/boards/protonic-imx6/board.c
>> @@ -13,6 +13,7 @@
>> #include <globalvar.h>
>> #include <gpio.h>
>> #include <i2c/i2c.h>
>> +#include <input/input.h>
>> #include <mach/imx/bbu.h>
>> #include <mach/imx/imx6.h>
>> #include <mach/imx/ocotp-fusemap.h>
>> @@ -740,19 +741,21 @@ static int prt_imx6_init_kvg_yaco(struct prt_imx6_priv *priv)
>> return prt_imx6_init_kvg_power(priv, PW_MODE_KVG_WITH_YACO);
>> }
>>
>> -#define GPIO_KEY_F6 (0xe0 + 5)
>> -#define GPIO_KEY_CYCLE (0xe0 + 2)
>> -
>> static int prt_imx6_init_prtvt7(struct prt_imx6_priv *priv)
>> {
>> - /* This function relies heavely on the gpio-pca9539 driver */
>> + unsigned long *keys;
>>
>> - gpio_direction_input(GPIO_KEY_F6);
>> - gpio_direction_input(GPIO_KEY_CYCLE);
> I added a
>
> of_devices_ensure_probed_by_compatible("gpio-keys");
>
> here to be sure you don't depend on probe order.
>
> Sascha
Ack. Thanks.
Robin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-01 6:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-31 15:05 [PATCH] ARM: boards: protonic-imx6: prtvt7: Use the input system for key detection Robin van der Gracht
2025-04-01 5:52 ` Sascha Hauer
2025-04-01 5:58 ` Sascha Hauer
2025-04-01 6:27 ` Robin van der Gracht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox