diff --git a/include/zephyr/devicetree/ordinals.h b/include/zephyr/devicetree/ordinals.h index c8b0302d1c..5dd9d00e30 100644 --- a/include/zephyr/devicetree/ordinals.h +++ b/include/zephyr/devicetree/ordinals.h @@ -24,6 +24,13 @@ */ #define DT_DEP_ORD(node_id) DT_CAT(node_id, _ORD) +/** + * @brief Get a node's dependency ordinal in string sortable form + * @param node_id Node identifier + * @return the node's dependency ordinal as a zero-padded integer literal + */ +#define DT_DEP_ORD_STR_SORTABLE(node_id) DT_CAT(node_id, _ORD_STR_SORTABLE) + /** * @brief Get a list of dependency ordinals of a node's direct dependencies * diff --git a/scripts/dts/gen_defines.py b/scripts/dts/gen_defines.py index ed47d3ae15..0c95557cda 100755 --- a/scripts/dts/gen_defines.py +++ b/scripts/dts/gen_defines.py @@ -747,6 +747,7 @@ def write_dep_info(node): out_comment("Node's dependency ordinal:") out_dt_define(f"{node.z_path_id}_ORD", node.dep_ordinal) + out_dt_define(f"{node.z_path_id}_ORD_STR_SORTABLE", f"{node.dep_ordinal:0>5}") out_comment("Ordinals for what this node depends on directly:") out_dt_define(f"{node.z_path_id}_REQUIRES_ORDS",