From 08d6ff059ef96a04acc3b8ab2c860eab0aedd193 Mon Sep 17 00:00:00 2001 From: Bjarki Arge Andreasen Date: Sun, 26 Nov 2023 11:34:06 +0100 Subject: [PATCH] scripts: dts: gen_defines: Generate interrupt-controller macro Extend the gen_defines.py write_interrupts(node) function to generate macros to get the interrupt controller for an interrupt specifier by idx and by name. The information is already generated by edtlib.py and stored in node.interrupts[].controller. This addition uses the node pointed to by the controller member to generate the following example output define DT_N_S_device1_IRQ_IDX_0_CONTROLLER \ DT_N_S_gpio_800 define DT_N_S_device1_IRQ_NAME_test4_CONTROLLER \ N_S_device1_IRQ_IDX_0_CONTROLLER Signed-off-by: Bjarki Arge Andreasen --- doc/build/dts/macros.bnf | 2 ++ scripts/dts/gen_defines.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/doc/build/dts/macros.bnf b/doc/build/dts/macros.bnf index 66e74bfbf5..c8c99db7ef 100644 --- a/doc/build/dts/macros.bnf +++ b/doc/build/dts/macros.bnf @@ -40,8 +40,10 @@ node-macro =/ %s"DT_N" path-id %s"_IRQ_NUM" node-macro =/ %s"DT_N" path-id %s"_IRQ_IDX_" DIGIT "_EXISTS" node-macro =/ %s"DT_N" path-id %s"_IRQ_IDX_" DIGIT %s"_VAL_" dt-name [ %s"_EXISTS" ] +node-macro =/ %s"DT_N" path-id %s"_CONTROLLER" node-macro =/ %s"DT_N" path-id %s"_IRQ_NAME_" dt-name %s"_VAL_" dt-name [ %s"_EXISTS" ] +node-macro =/ %s"DT_N" path-id %s"_IRQ_NAME_" dt-name "_CONTROLLER" ; The ranges property is also special. node-macro =/ %s"DT_N" path-id %s"_RANGES_NUM" node-macro =/ %s"DT_N" path-id %s"_RANGES_IDX_" DIGIT "_EXISTS" diff --git a/scripts/dts/gen_defines.py b/scripts/dts/gen_defines.py index 7721b5b4fe..0d84db4851 100755 --- a/scripts/dts/gen_defines.py +++ b/scripts/dts/gen_defines.py @@ -477,6 +477,13 @@ def write_interrupts(node): name_vals.append((name_macro, f"DT_{idx_macro}")) name_vals.append((name_macro + "_EXISTS", 1)) + idx_controller_macro = f"{path_id}_IRQ_IDX_{i}_CONTROLLER" + idx_controller_path = f"DT_{irq.controller.z_path_id}" + idx_vals.append((idx_controller_macro, idx_controller_path)) + if irq.name: + name_controller_macro = f"{path_id}_IRQ_NAME_{str2ident(irq.name)}_CONTROLLER" + name_vals.append((name_controller_macro, f"DT_{idx_controller_macro}")) + for macro, val in idx_vals: out_dt_define(macro, val) for macro, val in name_vals: