Search code examples
linux-kernelkernellinux-device-driverplatformdevice-tree

Getting information from the device tree and requesting irq


Context

In the device tree I am using, in one of its node, the filed interrupts is:

interrupts = <0x0 0x1d 0x4>;

(from a device tree of a Pynq board, equipaged with a ZYnq device with a dual-core ARM A9 )

Now, in the device tree .probe function, I use the Linux kernel API:

irq_line = platform_get_irq(pdev, 0);

in order to get the irq to use for the function request_irq (described in ldd3 chapter 10).

Ones the irq_line = platform_get_irq(pdev, 0); is executed, I get the value 0x2e that DOESN'T match with the fields of the interrupts of the device tree.

Questions

  1. What are exactly the <0x0 0x1d 0x4> numbers? I know that, in according to elinux.org,:

interrupts - A property of a device node containing a list of interrupt specifiers, one for each interrupt output signal on the device.

  1. How can I get the irq line to use (maybe starting from these numbers)? Is the irq line related to the device tree?

  2. Why am I getting a value that doesn't match with no one of the fields of interrupts?

I am sure I am misunderstanding some important topics, I am sorry. And thank you for reading the question and sharing your knowledge.


Solution

  • What are exactly the <0x0 0x1d 0x4> numbers? I know that, in according to elinux.org, (interrupts = <0x0 0x1d 0x4>;)

    Firstly you need to look at the interrupt-parent of the device node, this parent will #interrupt-cells property which specifies number of bits needed to encode a interrupt source, so from your entry interrupts = <0x0 0x1d 0x4>; means the following:

    0x0  = shared processor interrupts
    0x1d = interrupt number
    0x4  = active high level-sensitive/[IRQ_TYPE_LEVEL_HIGH][2] 
    

    How can I get the irq line to use (maybe starting from these numbers)? Is the irq line related to the device tree?

    Why am I getting a value that doesn't match with no one of the fields of interrupts?

    Its well answered here also refer this.