scripts/dts: Generate IRQ values for multi-level IRQs
When we have multi-level (ie chained interrupt controllers) Zephyr has a schemee to encode the multi-level and IRQ values along the level's into a single 32-bit value. This is the "IRQ" value expected by Zephyr APIs. The encoding scheme is documented here: doc/reference/kernel/other/interrupts.rst Update the device tree generation to walk the interrupt levels and generate the expected encoded value for the IRQ. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
2bed6759a4
commit
c16537fbde
1 changed files with 18 additions and 2 deletions
|
@ -446,11 +446,27 @@ def write_irqs(dev):
|
|||
alias += "_" + str2ident(cell_name)
|
||||
return alias
|
||||
|
||||
def encode_zephyr_multi_level_irq(irq, irq_num):
|
||||
# See doc/reference/kernel/other/interrupts.rst for details
|
||||
# on how this encoding works
|
||||
|
||||
irq_ctrl = irq.controller
|
||||
# Look for interrupt controller parent until we have none
|
||||
while irq_ctrl.interrupts:
|
||||
irq_num = (irq_num + 1) << 8
|
||||
if "irq" not in irq_ctrl.interrupts[0].specifier:
|
||||
err("Expected binding for {!r} to have 'irq' "
|
||||
"in '#cells'".format(irq_ctrl))
|
||||
irq_num |= irq_ctrl.interrupts[0].specifier["irq"]
|
||||
irq_ctrl = irq_ctrl.interrupts[0].controller
|
||||
return irq_num
|
||||
|
||||
for irq_i, irq in enumerate(dev.interrupts):
|
||||
# We ignore the controller for now
|
||||
for cell_name, cell_value in irq.specifier.items():
|
||||
ident = "IRQ_{}".format(irq_i)
|
||||
if cell_name != "irq":
|
||||
if cell_name == "irq":
|
||||
cell_value = encode_zephyr_multi_level_irq(irq, cell_value)
|
||||
else:
|
||||
ident += "_" + str2ident(cell_name)
|
||||
|
||||
out_dev(dev, ident, cell_value,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue