Hi everyone,
I come to this forum because I have a question to which I don't find any answer.
It concerns gpio keys buttons. More precisely, we use a GPIO to tell us when the micro USB is plugged.
the signal works as follow :
when the USB is plugged, the value coming to the GPIO is 0 and when the USB is unplugged the value coming to the GPIO is 1 (the electrical circuit is a NPN transistor).
Generally it works fine. For example when plugging the Micro USB the "hexdump /dev/input/event0 " prints :
0000010 7edf 4e30 3f28 0002 0001 0103 0001 0000
0000020 7edf 4e30 3f48 0002 0000 0000 0000 0000
However there is a particular case :
when the product is OFF and I plug the micro-USB (which starts the product). After that, the first Micro-USB unplug seems not to be detected as the "hexdump /dev/input/event0" prints only :
0000000 7edb 4e30 906d 0007 0000 0000 0000 0000
I have tried several changes in gpio keys parameters, but the problem is still there.
And when I try to set active_low=0, I get the opposite problem :
when starting the problem with no usb plugged, the first usb plug is not detected.
I pasted below my parameters for gpio-keys.
I am using an at91sam9260 board.
I would be very grateful, I someone could give me some piece of advice as I am really stuck right now.
Thanks a lot
Best regards,
François
Code:
/*
* GPIO Buttons
*/
#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
static struct gpio_keys_button ek_buttons[] = {
{
.gpio = AT91_PIN_PC12,
.code = BTN_0,
.desc = "SW_N",
.active_low = 1,
.wakeup = 1,
},
{
.gpio = AT91_PIN_PC11,
.code = BTN_1,
.desc = "SW_L",
.active_low = 1,
.wakeup = 1,
},
{
.gpio = AT91_PIN_PC8,
.code = BTN_2,
.desc = "SW_R",
.active_low = 1,
.wakeup = 1,
},
{
.gpio = AT91_PIN_PA31,
.code = BTN_3,
.desc = "USB",
.active_low = 1,
.wakeup = 1,
},
{
.gpio = AT91_PIN_PA20,
.code = BTN_4,
.desc = "DOCK",
.active_low = 1,
.wakeup = 1,
},
{
.gpio = AT91_PIN_PA8, /* battery door */
.code = BTN_5,
.desc = "JP1",
.active_low = 1,
.wakeup = 1,
},
};
static struct gpio_keys_platform_data ek_button_data = {
.buttons = ek_buttons,
.nbuttons = ARRAY_SIZE(ek_buttons),
};
static struct platform_device ek_button_device = {
.name = "gpio-keys",
.id = -1,
.num_resources = 0,
.dev = {
.platform_data = &ek_button_data,
}
};
static void __init ek_add_device_buttons(void)
{
at91_set_gpio_input(AT91_PIN_PC12, 1); /* SW_N */
at91_set_deglitch(AT91_PIN_PC12, 1);
at91_set_gpio_input(AT91_PIN_PC11, 1); /* SW_L */
at91_set_deglitch(AT91_PIN_PC11, 1);
at91_set_gpio_input(AT91_PIN_PC8, 1); /* SW_R */
at91_set_deglitch(AT91_PIN_PC8, 1);
at91_set_gpio_input(AT91_PIN_PA31, 1); /* USB_#INT */
at91_set_deglitch(AT91_PIN_PA31, 1);
at91_set_gpio_input(AT91_PIN_PA20, 1); /* DOCK_#INT */
at91_set_deglitch(AT91_PIN_PA20, 1);
platform_device_register(&ek_button_device);
}