kconfig: add dt_chosen_path() helper
This helper allows setting default Kconfig values based on devicetree
node properties without giving the full path to the node.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
diff --git a/scripts/kconfig/kconfigfunctions.py b/scripts/kconfig/kconfigfunctions.py
index 345da16..c41bf31 100644
--- a/scripts/kconfig/kconfigfunctions.py
+++ b/scripts/kconfig/kconfigfunctions.py
@@ -81,6 +81,19 @@
return "y" if node and node.enabled else "n"
+def dt_chosen_path(kconf, _, chosen):
+ """
+ This function takes a /chosen node property and returns the path
+ to the node in the property value, or the empty string.
+ """
+ if doc_mode or edt is None:
+ return "n"
+
+ node = edt.chosen_node(chosen)
+
+ return node.path if node else ""
+
+
def dt_nodelabel_enabled(kconf, _, label):
"""
This function takes a 'label' and returns "y" if we find an "enabled"
@@ -382,6 +395,7 @@
"dt_compat_on_bus": (dt_compat_on_bus, 2, 2),
"dt_chosen_label": (dt_chosen_label, 1, 1),
"dt_chosen_enabled": (dt_chosen_enabled, 1, 1),
+ "dt_chosen_path": (dt_chosen_path, 1, 1),
"dt_nodelabel_enabled": (dt_nodelabel_enabled, 1, 1),
"dt_chosen_reg_addr_int": (dt_chosen_reg, 1, 3),
"dt_chosen_reg_addr_hex": (dt_chosen_reg, 1, 3),