user button from driver

Hello to all,
I'm writing a device driver for beagle, and I want to control the
on-board user button (GPIO_7) in order to register an interrupt from
this button. In other words, I simply want the button to be associated
with an interrupt handler I wrote.
I'm trying to use the kernel GPIO API, but the gpio_request() call
returns with -EBUSY. Then, while gpio_to_irq() correctly returns the
irq number (as I can see it in /proc/interrupts), request_irq()
returns -EBUSY again.
The call sequence is

...
gpio_request(GPIO_7, "gpio");
irq = gpio_to_irq(GPIO_7);
request_irq(irq, my_handler, IRQF_SHARED, name, NULL);
...

How can I free such irq in order to manage it?

Thanks

Daniele

I’m purely guessing here, but the fact that the normal kernel configuration sets up that button with an internal interrupt handler and then enables a keyboard like event would seem to mean that you need to modify your kernel build to disable the default operation of that button.

Wim.

Googling i'm finding many drivers that use omap-specific functions,
such as omap_request_gpio() or something like that. I found
declarations of such functions in the arch/arm/plat-omap/include/*
directory.
But i'm new to kernel development, and i can't figure out how to
include files from that dir...
Maybe calling omap functions is needed in order to request gpio lines,
is it correct?
Sorry for the newbie questions...

Daniele

I’m pretty sure that USER-button is already acquired by kernel. Just find the place in kernel and disable it.

2010/11/22 Daniele Capuano <el.einad@gmail.com>

Daniele - sorry I don’t have any direct advice, but here is an excellent resource for Linux device drivers:

http://lwn.net/Kernel/LDD3/

Do you think that I have to disable ALL the GPIO support in kernel
configuration? It seems to be quite a dramatic solution...but i can't
find where is any gpio-specific driver in kernel...
please help...!

Daniele

p.s. @Jeff Yes, that is my reference book for deleloping my
driver...but gpio is not taken into account...

You need to learn how to find necessary code in the kernel source, because the kernel itself is the perfect book about linux device drivers :slight_smile:

Try to use “grep” utility to search for text. For instance something like:

grep GPIO * -r | grep omap

2010/11/23 Daniele Capuano <el.einad@gmail.com>

Daniele,

Take a look at this gentleman's page, he does almost exactly what
you're looking to do, and provides ample code examples to accomplish
the task.

http://wh1t3s.com/tag/beagleboard/

Good luck!

Have a look into the kernel source:

Documentation/gpio.txt explains the way GPIO are managed by the kernel. Note the user interface through sysfs.

arch/arm/plat-omap/gpio.c is the platform code used by the generic gpio framework.

Have fun !

I found the kernel configuration at
"Device Drivers -> Input Device Support-> Keyboards - > GPIO Buttons"
that seems to perfectly match the case. Now, since this is a built-in
configuration and cannot be disabled without recompiling, i'm going to
recompile and retry...
Thanks a lot!

Daniele

Can’t we configure the gpio_keys driver to call my custom ISR for user button? If not, then as discussed in this thread we need to disable GPIO buttons from menu config and write a module where we can request for user button and register it with custom handler?

Thanks
Sanket