Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to know the Interrupt/GPIO number for a specific pin in linux

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 ?

like image 334
Abd elrahman Diab Avatar asked Jun 26 '12 17:06

Abd elrahman Diab


People also ask

Where is GPIO number in Linux?

The Linux GPIO number for a certain GPIO pin can be determined by adding the GPIO pin index to the port base index. For instance: i. MX6 GPIO2_4 (port 2, pin 4) is: 32 + 4 = 36.

What is interrupt in GPIO?

GPIO interrupt handling is inherently a two-stage process. The interrupt from the general-purpose I/O (GPIO) controller, which causes the GPIO framework extension (GpioClx) interrupt service routine (ISR) to run, is called the primary interrupt.

What is GPIO base?

A general-purpose input/output (GPIO) is an uncommitted digital signal pin on an integrated circuit or electronic circuit board which may be used as an input or output, or both, and is controllable by software. GPIOs have no predefined purpose and are unused by default.


1 Answers

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

like image 189
embedded.kyle Avatar answered Sep 18 '22 15:09

embedded.kyle