[PATCH] ARM: boards: protonic-imx6: prtvt7: Use the input system for key detection

Robin van der Gracht robin at protonic.nl
Mon Mar 31 08:05:28 PDT 2025


Static gpio mapping is deprecated. Instead query the gpio-keys driver for
pressed keys.

Signed-off-by: Robin van der Gracht <robin at 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




More information about the barebox mailing list