scripts/dts: gen_defines: Generates _EXISTS for reg & irq macros

Add generation of the following macros:

DT_N_<node-id>_REG_IDX_<idx>_EXISTS 1
DT_N_<node-id>_IRQ_IDX_<idx>_EXISTS 1

This will allow us to use IS_ENABLED() in DT_REG_HAS_IDX and
DT_IRQ_HAS_IDX which matches behavior of other DT_*_HAS_* macros as
well as lets use these with COND_CODE_1.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2020-04-14 14:27:20 -05:00 committed by Kumar Gala
commit 4e2ad00496
2 changed files with 4 additions and 0 deletions

View file

@ -27,12 +27,14 @@ node-macro =/ %s"DT_N" path-id %s"_EXISTS"
node-macro =/ %s"DT_N" path-id %s"_BUS" ["_" dt-name] node-macro =/ %s"DT_N" path-id %s"_BUS" ["_" dt-name]
; The reg property is special and has its own macros. ; The reg property is special and has its own macros.
node-macro =/ %s"DT_N" path-id %s"_REG_NUM" node-macro =/ %s"DT_N" path-id %s"_REG_NUM"
node-macro =/ %s"DT_N" path-id %s"_REG_IDX_" DIGIT "_EXISTS"
node-macro =/ %s"DT_N" path-id %s"_REG_IDX_" DIGIT node-macro =/ %s"DT_N" path-id %s"_REG_IDX_" DIGIT
%s"_VAL_" ( %s"ADDRESS" / %s"SIZE") %s"_VAL_" ( %s"ADDRESS" / %s"SIZE")
node-macro =/ %s"DT_N" path-id %s"_REG_NAME_" dt-name node-macro =/ %s"DT_N" path-id %s"_REG_NAME_" dt-name
%s"_VAL_" ( %s"ADDRESS" / %s"SIZE") %s"_VAL_" ( %s"ADDRESS" / %s"SIZE")
; The interrupts property is also special. ; The interrupts property is also special.
node-macro =/ %s"DT_N" path-id %s"_IRQ_NUM" 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 node-macro =/ %s"DT_N" path-id %s"_IRQ_IDX_" DIGIT
%s"_VAL_" dt-name [ %s"_EXISTS" ] %s"_VAL_" dt-name [ %s"_EXISTS" ]
node-macro =/ %s"DT_N" path-id %s"_IRQ_NAME_" dt-name node-macro =/ %s"DT_N" path-id %s"_IRQ_NAME_" dt-name

View file

@ -239,6 +239,7 @@ def write_regs(node):
idx_vals.append((f"{path_id}_REG_NUM", len(node.regs))) idx_vals.append((f"{path_id}_REG_NUM", len(node.regs)))
for i, reg in enumerate(node.regs): for i, reg in enumerate(node.regs):
idx_vals.append((f"{path_id}_REG_IDX_{i}_EXISTS", 1))
if reg.addr is not None: if reg.addr is not None:
idx_macro = f"{path_id}_REG_IDX_{i}_VAL_ADDRESS" idx_macro = f"{path_id}_REG_IDX_{i}_VAL_ADDRESS"
idx_vals.append((idx_macro, idx_vals.append((idx_macro,
@ -312,6 +313,7 @@ def write_interrupts(node):
cell_value = map_arm_gic_irq_type(irq, cell_value) cell_value = map_arm_gic_irq_type(irq, cell_value)
cell_value = encode_zephyr_multi_level_irq(irq, cell_value) cell_value = encode_zephyr_multi_level_irq(irq, cell_value)
idx_vals.append((f"{path_id}_IRQ_IDX_{i}_EXISTS", 1))
idx_macro = f"{path_id}_IRQ_IDX_{i}_VAL_{name}" idx_macro = f"{path_id}_IRQ_IDX_{i}_VAL_{name}"
idx_vals.append((idx_macro, cell_value)) idx_vals.append((idx_macro, cell_value))
idx_vals.append((idx_macro + "_EXISTS", 1)) idx_vals.append((idx_macro + "_EXISTS", 1))