scripts: dts: add special tooling for handling GPIO hog nodes
GPIO hog nodes contain a "gpios" property, but unlike other "*-gpios"
properties, these are not phandle-arrays as they only carry the data part
(e.g. pin, flags) but lack the phandles to the (parent) GPIO controller.
Add special devicetree tooling to handle the "gpios" property of GPIO hog
nodes and generate special devicetree helper macros as if they were phandle
arrays.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
diff --git a/scripts/dts/gen_defines.py b/scripts/dts/gen_defines.py
index 5f97320..bede6b4 100755
--- a/scripts/dts/gen_defines.py
+++ b/scripts/dts/gen_defines.py
@@ -358,6 +358,7 @@
# we can't capture with the current bindings language.
write_pinctrls(node)
write_fixed_partitions(node)
+ write_gpio_hogs(node)
def write_ranges(node):
# ranges property: edtlib knows the right #address-cells and
@@ -608,6 +609,21 @@
flash_area_num += 1
+def write_gpio_hogs(node):
+ # Write special macros for gpio-hog node properties.
+
+ macro = f"{node.z_path_id}_GPIO_HOGS"
+ macro2val = {}
+ for i, entry in enumerate(node.gpio_hogs):
+ macro2val.update(controller_and_data_macros(entry, i, macro))
+
+ if macro2val:
+ out_comment("GPIO hog properties:")
+ out_dt_define(f"{macro}_EXISTS", 1)
+ out_dt_define(f"{macro}_NUM", len(node.gpio_hogs))
+ for macro, val in macro2val.items():
+ out_dt_define(macro, val)
+
def write_vanilla_props(node):
# Writes macros for any and all properties defined in the
# "properties" section of the binding for the node.