How to determine the IRQ number for a USB device?

Haleeq Usman picture Haleeq Usman · May 18, 2013 · Viewed 8.5k times · Source

I am new to driver development. However, I purchased an OSR USB FX2 Learning Kit, which comes with sample codes for Windows kernel/user mode driver. However, I am writing the driver in Linux (Ubuntu 12). I have successfully been able to send control commands and receive the return of control commands from the device. I also have been able to successfully send and read data over the BULK OUT/IN endpoints the device supports.

There is only one more experiment I have yet to complete. The device has the following endpoints:

1. BULK (OUT) --> Address 0x06
2. BULK (IN)  --> Address 0x88
3. INTERRUPT (IN) --> Address 0x81

I am unable to figure out how to find the IRQ number for the INTERRUPT (IN) endpoint. I understand how to install an IRQ handler using:

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

and write the handler with the correct function prototype. However, I am wondering how I would find what IRQ line (IRQ number) the device is interrupting on? That is, how do I determine what the value of the argument unsigned int irq in the request_irq function above should be? I read through the book "Linux Device Drivers, Third Edition" how the IRQ number is determined for parallel ports. However, how does this work for USB and how would I go about probing or finding out what this number should be for the USB device?

Answer

Ahmed Masud picture Ahmed Masud · May 18, 2013

You don't need to deal with interrupts for writing a USB device driver, if you would like a good tutorial on it have a look at

http://www.linuxforu.com/2011/10/usb-drivers-in-linux-1/

which is an excellent starting point to learn how to write USB drivers;

If you have specific issues as you go along; post them we'll see how it goes :)

EDIT

you can use platform_get_irq or platform_get_irq_byname to get the irq for the device.

EDIT 2:

I also point you to http://lwn.net/images/pdf/LDD3/ch10.pdf for your viewing pleasure :-) Shows you how to retrieve IRQs assigned to devices.