using IRQ1 in mpc5121ads

Grant Likely grant.likely at secretlab.ca
Tue Mar 31 03:42:30 EST 2009


On Mon, Mar 30, 2009 at 8:33 AM, sylvain louchez
<sylvain.louchez at gmail.com> wrote:
> Hello, I’m a newbie looking for where the documentation and implementation
> model can be found…
>
> My custom driver is looking for an interrupt notification from the kernel -
> and it registers in the /proc/interrupts file as expected when installed,
> i.e.
>
> $insmod custom_driver.ko gps_irq=<n>

You don't want to do this with PowerPC.  There is no reliable way to
know what the IRQ number is at module load time.  Note that the IRQ
numbers listed in /proc/interrupts are *not* the same as the hardware
interrupt number.  /proc/interrupts on powerpc shows 'virtual IRQ'
numbers which are assigned dynamically as needed.  This is so that the
kernel can handle multiple cascaded IRQ controllers, each with
different hardware IRQ numbering schemes.

> 1. create an entry in the dts file; I think we've got this understood
> through advice already received - for example the new interrupt entry can be
> created in the dts file - something like:
>
>
>
> gps at 0 {      // there is no address so just make it 0

There is no address so just make it "gps {", unless you have more than
one of them.

>
>     compatible = "gps_interrupt";

Change this to: compatible = "<vendor>,<name-of-gps-device>";

Note that this node should describe the whole GPS device, not just IRQ
line for the GPS device.  Is this device addressable in any way?  Does
it have any memory mapped registers?  SPI?  I2C?

>
>     interrupts = <17 0x8>;         // 17 is irq1, 8 is level low, see
> include/linux/irq.h for others
>
>     interrupt-parent = < &ipic >;

This looks correct

> 2. but now we need to relate the actual interrupt to the virtual interrupt
> called in the driver... by invoking the function irq_of_parse_and_map - but
> we don't know how to do it - nor have we found how to do it in browsing
> through the open source documentation

You need to write an of_platform_driver which will bind against the
'compatible' property in your GPS node.

> A secondary question: where to properly add this function call in the file
> system?

Use of_register_platform_driver() to register your of_platform_driver
in your module's init function.

> Are we on the right track here? Is there sample/ tutorial code you could
> point us to?

Search for of_register_platform_driver() in the kernel source.

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.



More information about the Linuxppc-dev mailing list