10

i'm doing a project in which i need to handle an interrupt in Linux.

the board i'm using is an ARM9Board based on the s3c6410 MCU by Samsung (arm 11 processor) and it has the following I/O interface :

enter image description here

as the image shows i have EINTx pins for external interrupts and GPxx pins as GPIO pins and i don't mind using any of them but i don't have their numbers !

For EINTx pins :

when i call

int request_irq(unsigned int irq, void (*handler)(int, struct pt_regs *), 
unsigned long flags, const char *device); 

i need the interrupt number to pass it as the first paramter of the function , so how can i get the irq number for example the EINT16 pin ?

For GPxx pins : the same story as i need the GPIO pin nuumber to pass it to those functions

int gpio_request(unsigned gpio, const char *label);
int gpio_direction_input(unsigned gpio);
int gpio_to_irq(unsigned gpio);

i.e how do i know the GPIO number for the GPP8 pin ?

i searched the board documents and datasheet but it doesn't contain anything about how to get those numbers , any idea or help on where to look ?

embedded.kyle
  • 10,976
  • 5
  • 37
  • 56
Abd elrahman Diab
  • 135
  • 1
  • 2
  • 7

2 Answers2

9

The Embedded Linux you are using should have a GPIO driver that has #define statements for the GPIO pins. You can then get the IRQ number of the specific GPIO using something like:

irq_num = gpio_to_irq(S3C64XX_GPP(8));

The Linux GPIO lib support for that particular chip is available in the following file:

linux/arch/arm/mach-s3c6400/include/mach/gpio.h

There you will find all the #define statements for the various GPIO.

See the section on GPIO Conventions in their documentation:

http://www.kernel.org/doc/Documentation/gpio/gpio.txt

HoldOffHunger
  • 18,769
  • 10
  • 104
  • 133
embedded.kyle
  • 10,976
  • 5
  • 37
  • 56
  • the kernel supplied with the board have a GPIO driver at /drivers/gpio but non of the c files there have a #define for the pins , and i found /include/linux/gpio.g but it contains only the declaration for functions like gpio_request and gpio_to_irq but no #define either – Abd elrahman Diab Jun 26 '12 at 18:06
  • 1
    I've updated my answer with specific information regarding the distro supplied with that board. – embedded.kyle Jun 26 '12 at 19:22
  • wow, thank u very much sir .. i don't know what was their idea of burying this information that much deep in the kernel but i think i should do a much harder search next time :) – Abd elrahman Diab Jun 26 '12 at 19:27
  • @embedded.kyle: How do I know the function similar to S3C64XX_GPP() for the board http://in.mouser.com/new/pandaboardorg/pandaboardES/ ? – Sagar Jain Jul 07 '14 at 04:46
  • 1
    @mps It really depends on which Linux distro you are using so you should refer to that distro's documentation. But in general, you should find the `gpio.h` file and that should tell you everything you need to know. I've also updated the link to `gpio.txt` since it was broken. That should also be of some use to you. – embedded.kyle Jul 07 '14 at 18:08
  • Thanks for the updated link. That's really helpful. I don't see any function similar to S3C64XX_GPP() in linux/gpio.h – Sagar Jain Jul 08 '14 at 03:55
0

I was doing some work on the GPIO pin as well but it's on a different board, AM335x. Just to let you know, there's quite few of way to do it. One of the method we are using is using memory board to access (write or read) the GPIO pin.

This is a really good article to help me to get things working. Register access to the GPIOs of the Beaglebone via memory mapping

jen1982
  • 67
  • 2
  • 11