Hello Ahmad,
On 2022-06-20 09:51, Ahmad Fatoum wrote:
Hello,
On 17.06.22 10:44, Marco Felsch wrote:
On 22-06-17, Sascha Hauer wrote:
Or, it is active low and your patch is correct :D
If they are, can we add a comment or _N suffix to the names?
Does barebox not have gpiod? The board code just should check if it is
active or not. Whatever active means in this case.
There is gpiod_get(), but there's also gpio-keys support. See
drivers/input/specialkeys.c for an example on how to register an input
notifier.
I'm interested in two keys pressed at the same time. When I implement a
notifyer like in specialkeys.c I'll have to check if the other key is pressed
at that time as well.
I noticed that the input subsystem is already maintaining a bitmask with keys
pressed. If I tap into that, I can implement it like so:
diff --git a/arch/arm/boards/protonic-imx6/board.c
b/arch/arm/boards/protonic-imx6/board.c
index 8436903fd8..1e1a22ae8e 100644
--- a/arch/arm/boards/protonic-imx6/board.c
+++ b/arch/arm/boards/protonic-imx6/board.c
@@ -8,11 +8,13 @@
#include <bootm.h>
#include <common.h>
#include <deep-probe.h>
+#include <dt-bindings/input/linux-event-codes.h>
#include <environment.h>
#include <fcntl.h>
#include <globalvar.h>
#include <gpio.h>
#include <i2c/i2c.h>
+#include <input/input.h>
#include <mach/bbu.h>
#include <mach/imx6.h>
#include <mach/ocotp-fusemap.h>
@@ -742,17 +744,13 @@ 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[BITS_TO_LONGS(KEY_CYCLEWINDOWS)];
- gpio_direction_input(GPIO_KEY_F6);
- gpio_direction_input(GPIO_KEY_CYCLE);
+ 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;
return 0;
- Robin