using IRQ1 in mpc5121ads
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>
**Note - this part's OK, I see the instance in /proc/interrupts after I load it**
On the hardware side the actual signal is a 1 Hz pulse (from GPS) routed to IRQ1 through the board's CPLD. This is the only interrupt on IRQ_1 so we can keep the logic simple i.e. on IRQ1 we can just jump to the service routine in a custom driver.
I understand 2 things have to be done:
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@0 { // there is no address so just make it 0
compatible = "gps_interrupt";
interrupts = <17 0x8>; // 17 is irq1, 8 is level low, seeinclude/linux/irq.h for others
interrupt-parent = < &ipic >;
};
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
A secondary question: where to properly add this function call in the file system?
Are we on the right track here? Is there sample/ tutorial code you could point us to?
Thanks in advance for any pointers - documentation on these mechanisms, sample code.
Sylvain Louchez
Quoted 1 line · sylvain louchez
Hello, I=92m a newbie looking for where the documentation and implementat=
ion
Quoted 3 lines
model can be found=85
My custom driver is looking for an interrupt notification from the kernel=
-
Quoted 4 lines
and it registers in the
/proc/interruptsfile as expected when installed, i.e.$insmod custom_driver.ko gps_irq=3D<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.
Quoted 2 lines
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
Quoted 5 lines
created in the dts file - something like:
gps@0 {=A0=A0=A0=A0=A0 // 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.
Quoted 2 lines
=A0=A0=A0 compatible =3D "
gps_interrupt";
Change this to: compatible =3D "<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?
Quoted 2 lines
=A0=A0=A0 interrupts =3D <17 0x8>;=A0=A0=A0=A0=A0=A0=A0=A0 // 17 is irq1,=
8 is level low, see
Quoted 3 lines
include/linux/irq.hfor others=A0=A0=A0 interrupt-parent =3D < &ipic >;
This looks correct
Quoted 1 line
2. but now we need to relate the actual interrupt to the virtual interrup=
t
Quoted 1 line
called in the driver... by invoking the function
irq_of_parse_and_map- b=
ut
Quoted 2 lines
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.
Quoted 1 line
A secondary question: where to properly add this function call in the fil=
e
Quoted 1 line
system?
Use of_register_platform_driver() to register your of_platform_driver in your module's init function.
Quoted 2 lines
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.
--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
Quoted 33 lines · sylvain louchez
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/interruptsfile as expected when installed, i.e.$insmod custom_driver.ko gps_irq=<n>
**Note - this part's OK, I see the instance in
/proc/interruptsafter I load it**On the hardware side the actual signal is a 1 Hz pulse (from GPS) routed to IRQ1 through the board's CPLD. This is the only interrupt on
IRQ_1so we can keep the logic simple i.e. on IRQ1 we can just jump to the service routine in a custom driver.I understand 2 things have to be done:
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:
Quoted 3 lines
gps@0 { // there is no address so just make it 0
compatible = "gps_interrupt";
Sorry, this is not relevant to your actual question, but this is not a good 'compatible' value. You should use the "vendor,model" convention here.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson