Search code examples
clinuxarminterruptdevice-tree

In an ARM device tree file, what do the three interrupt values mean


A device tree source for a typical ARM device would have the interrupt-controller section:

interrupt-controller@f8f01000 {
    compatible = "arm,cortex-a9-gic";
    #interrupt-cells = <0x3>;
    interrupt-controller;
    reg = <0xf8f01000 0x1000 0xf8f00100 0x100>;
    num_cpus = <0x2>;
    num_interrupts = <0x60>;
    linux,phandle = <0x3>;
    phandle = <0x3>;
};

The property #interrupt-cells defines the size of the tuple for registering an interrupt. Therefore, when defining a device, three integers have to be defined to specify an interrupt and its properties.

ocmc@f800c000 {
    compatible = "xlnx,zynq-ocmc-1.0";
    interrupt-parent = <0x3>;
    interrupts = <0x0 0x3 0x4>;
    reg = <0xf800c000 0x1000>;
};

The question is, what do each of the three values stand for? So, what does the line interrupts = <0x0 0x3 0x4>; mean? And what offset has to be added when registering an interrupt handler for it (via signal.h/csignal with signal(<signal id>, <function name>);)


Solution

  • Parsing from the linked websites:

    The first number is a flag indicating if the interrupt is an SPI (shared peripheral interrupt). A nonzero value means it is an SPI. This impacts offsets added to translate the interrupt number (16 for SPI, 32 for non-SPI).

    The second number is the interrupt number.

    The third number is the type of interrupt: 0 = Leave it as it was (power-up default or what the bootloader set it to, if it did). 1 = Rising edge. 4 = Level sensitive, active high.