fuw
Posts: 1
Joined: Tue Dec 01, 2015 10:34 pm

How to enumerate interrupts?

Wed Dec 02, 2015 8:08 pm

By writing Linux kernel module one has possibility to handle interrupts. Usually using request_irq Linux function. However, it is necessary to know interrupt identifier. Is there any data that describe this correspondence between interrupts from different peripheral components and Linux identifiers?

GPIO has own helper function gpio_to_irq. With a simple loop

Code: Select all

unsigned u;
for (u = 0; u < 100; ++u)
{
  int n = gpio_to_irq(u);
  printk(KERN_INFO "gpio_to_irq(%u) = %d\n", u, n);
}
one can discover that there exist (at least at that particular raspi) 54 gpio pins and corresponding Linux interrupt identifiers are in range from 480 to 533. But how to find the rest?

findx
Posts: 29
Joined: Mon Jul 29, 2013 7:52 pm

Re: How to enumerate interrupts?

Sat Dec 05, 2015 10:20 pm

This is a bare metal forum, not a Linux forum. It would be best if you directed your questions to the Linux forum.

That said, to help point you in the right direction, please look at the datasheet, section 6. There are only 54 GPIO pins — the same 54 you found with your code. These pins are grouped into two banks, and GPIOs from only one bank are available on the normal Raspberry Pi headers. The compute module breaks out some additional GPIO pins from the other bank.

There's more to it (detailed in the datasheet), but basically the GPIO pins on a bank share an interrupt line. After it fires the kernel automagically maps the shared IRQ into unique kernel IRQ numbers. As you discovered, there is a gpio_to_irq(). There is also a platform specific irq_to_gpio() in mach/gpio.h. That should be all you need to know regarding the mapping of GPIOs to IRQs.

Return to “Bare metal, Assembly language”