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>
This commit is contained in:
Martí Bolívar 2020-04-23 12:28:06 -07:00 committed by Kumar Gala
commit 7ff3ebcbb9

View file

@ -81,6 +81,19 @@ def dt_chosen_enabled(kconf, _, chosen):
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 @@ functions = {
"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),