Skip to content

Commit 073fffa

Browse files
stephanosioMani-Sadhasivam
authored andcommitted
scripts: dts: Support GIC interrupt type-specific IRQ number fix up.
The ARM Generic Interrupt Controller (GIC) supports multiple interrupt types whose linear IRQ numbers are offset by a type-specific base number. This commit adds a function to automatically fix up ARM GIC interrupts in order to output a linear IRQ number that is offset by the interrupt type-specific base number. For more details, refer to the issue zephyrproject-rtos#19860. Signed-off-by: Stephanos Ioannidis <[email protected]>
1 parent 00ac06a commit 073fffa

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

scripts/dts/gen_defines.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,20 @@ def irq_name_alias(irq, cell_name):
484484
alias += "_" + str2ident(cell_name)
485485
return alias
486486

487+
def map_arm_gic_irq_type(irq, irq_num):
488+
# Maps ARM GIC IRQ (type)+(index) combo to linear IRQ number
489+
if "type" not in irq.data:
490+
err("Expected binding for {!r} to have 'type' in interrupt-cells"
491+
.format(irq.controller))
492+
irq_type = irq.data["type"]
493+
494+
if irq_type == 0: # GIC_SPI
495+
return irq_num + 32
496+
if irq_type == 1: # GIC_PPI
497+
return irq_num + 16
498+
err("Invalid interrupt type specified for {!r}"
499+
.format(irq))
500+
487501
def encode_zephyr_multi_level_irq(irq, irq_num):
488502
# See doc/reference/kernel/other/interrupts.rst for details
489503
# on how this encoding works
@@ -493,7 +507,7 @@ def encode_zephyr_multi_level_irq(irq, irq_num):
493507
while irq_ctrl.interrupts:
494508
irq_num = (irq_num + 1) << 8
495509
if "irq" not in irq_ctrl.interrupts[0].data:
496-
err("Expected binding for {!r} to have 'irq' in *-cells"
510+
err("Expected binding for {!r} to have 'irq' in interrupt-cells"
497511
.format(irq_ctrl))
498512
irq_num |= irq_ctrl.interrupts[0].data["irq"]
499513
irq_ctrl = irq_ctrl.interrupts[0].controller
@@ -503,6 +517,8 @@ def encode_zephyr_multi_level_irq(irq, irq_num):
503517
for cell_name, cell_value in irq.data.items():
504518
ident = "IRQ_{}".format(irq_i)
505519
if cell_name == "irq":
520+
if "arm,gic" in irq.controller.compats:
521+
cell_value = map_arm_gic_irq_type(irq, cell_value)
506522
cell_value = encode_zephyr_multi_level_irq(irq, cell_value)
507523
else:
508524
ident += "_" + str2ident(cell_name)

0 commit comments

Comments
 (0)