LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices

Reply
 
Search this Thread
Old 07-27-2011, 08:37 AM   #1
nomoney29
LQ Newbie
 
Registered: May 2011
Posts: 8

Rep: Reputation: 0
gpio keys buttons weird behaviour - first unplug not detected


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);
}
 
Old 08-23-2011, 09:30 AM   #2
nomoney29
LQ Newbie
 
Registered: May 2011
Posts: 8

Original Poster
Rep: Reputation: 0
Little update : I still did not find the solution of this behaviour.
If someone already this type of issue, please advice me !

Thanks !
 
  


Reply

Tags
detection, gpio, kernel, keys


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using GPIO (from kernel GPIO support) in MY application DannyGilbert Linux - Kernel 2 03-16-2009 07:52 AM
USB keyboard not detected until I unplug it ??? glenn69 Linux - Hardware 0 11-08-2005 11:13 AM
9.3 weird behaviour ????? bigjohn Suse/Novell 9 07-06-2005 05:44 AM
Check name of keys and buttons Ephracis Linux - Software 1 03-20-2005 07:50 PM
Multimedia keys/mouse buttons Narooze Linux - Hardware 7 04-20-2004 01:01 AM


All times are GMT -5. The time now is 09:29 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration