|How to Define an IRQ Handler in a Custom Linux Device Driver|
This note explains how to add an IRQ handler to a custom device driver in the uClinux kernel running on the SmartFusion2.
The specific example below was developed on the Emcraft Systems M2S-FG484 System-On-Module plugged into the SOM-BSB-EXT development baseboard. The example defines an IRQ handler for the user push button on the SOM-BSB-EXT.
The push button input is tied to MSS GPIO_0 in the default Libero design used with the M2S-FG484 SOM. This is IRQ 50 in the NVIC space.
Here is the code that registers the IRQ and enables the interrupt at the GPIO level:
Here is the interrupt handler. For the level sensitive interrupts, no explicit clearing is needed, for edge sensitive you would have to add code to explicitly clear the interrupt by writing into the GPIO_IRQ register:
static irqreturn_t sample_irq(int irq, void *dev_id)
Here is how the code was tested on the target.
/mnt # insmod sample.ko
/mnt # irq 50