Hi
I’ve been adding a GPIO expander chip to my marvell pxa310 development board. The CPU core is an ARM processor and the kernel I’ve got is 2.6.28. The driver I’ve been trying to use is the
/drivers/gpio/pca359x.c
The driver has a lot of code related to interrupts which I mostly understand now, but I’m stuck on a basic problem – what should I define the “.irq” value in the i2c_board_info structure? The GPIO expander chip has an interrupt signal which I’ve connected to GPIO125.
On the Marvell PXA310, GPIOs 2 through 127 share a common IRQ – number 10, or GPIO_IRQ_2_x. It seems logical that I should assign the irq value to GPIO_IRQ_2_x. There is a confusing bit of code in the pca953x.c driver where it sets up interrupts:
Quote:
for (irq = irq_start; irq < irq_start + chip->gpio_chip.ngpio; irq++) {
set_irq_chip(irq, ic);
set_irq_chip_data(irq, chip);
set_irq_handler(irq, handle_edge_irq);
set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
}
set_irq_type(chip->irq, IRQT_FALLING);
set_irq_data(chip->irq, chip);
set_irq_chained_handler(chip->irq, pca953x_irq_demux);
|
This for loop goes on to install a handler, etc. for each of the GPIO lines in this chip (total of 8). The control variable of the for loop is the irq number itself. If it starts at number 10 and loops 8 times, it will install irq_handler functions overtop of irq’s 10 through 17. That’s my confusion – IRQs 11 through 17 have nothing to do with GPIOs. I wonder how this works, whether installing handlers on these IRQs will clobber any IRQs that may already be set there by other device drivers, etc.
Documentation/IRQ.txt wasn’t very helpful. I need more detail. If anyone can point me at a book, website, article, etc. that serves as a good programmer’s reference to Linux’s kernel/irq/chip.c mechanisms, I’d be grateful. If anyone has a quick answer or two that can shed some light on my confusion I’d welcome that too.
Thanks for reading my long post.
Peat