domlao
domlao

Reputation: 16029

Where can I find the IRQ number in request_irq function?

I'm learning device driver programming in Linux. I am wondering where I could find the IRQ number to be used as the "irq" parameter in the request_irq function?

int request_irq (unsigned int irq,
                 void (*handler) (int, void *, struct pt_regs *),
                 unsigned long irqflags,
                 const char *devname,
                 void *dev_id);  

Thanks

Upvotes: 1

Views: 2914

Answers (2)

gby
gby

Reputation: 15218

If you have only a single interrupt controller the irq number is simply the hardware IRQ number.

If you have more then one PIC you need to look in the board specific initialization include files to see which offset was given to the specific PIC your device is connected to and add that to the hardware IRQ number.

It is usually an include file named irqs.h in the include/ directory of of the board specific files. E.g. for an Arm based Bcmring board, the file is in linux/arch/arm/mach-bcmring/include/mach/irqs.h

Upvotes: 1

Dummy00001
Dummy00001

Reputation: 17430

You seem learning the device programming from the wrong side - without a device.

If you have e.g. device on PCI but, then its IRQ is negotiated by the PCI and is available via Linux PCI subsystem.

If you have some custom wired device, quite often its IRQ line is hardwired and you should ask the people who made the custom device where it was wired to and what IRQ it is.

Otherwise buy yourself a copy of LDD3 - it's worth it and describes all that in details.

Upvotes: 2

Related Questions