scripts: kconfig: Add dt_compat_any_has_prop

Add a kconfig preprocessor function to check if
any node of a certain compatible has a specific property in DT.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
This commit is contained in:
Declan Snyder 2024-06-04 09:25:34 -05:00 committed by Anas Nashif
commit ca6adbba61

View file

@ -749,6 +749,21 @@ def dt_compat_on_bus(kconf, _, compat, bus):
return "n"
def dt_compat_any_has_prop(kconf, _, compat, prop):
"""
This function takes a 'compat' and a 'prop' and returns "y" if any
node with compatible 'compat' also has a valid property 'prop'.
It returns "n" otherwise.
"""
if doc_mode or edt is None:
return "n"
if compat in edt.compat2okay:
for node in edt.compat2okay[compat]:
if prop in node.props:
return "y"
return "n"
def dt_nodelabel_has_compat(kconf, _, label, compat):
"""
@ -916,6 +931,7 @@ functions = {
"dt_has_compat": (dt_has_compat, 1, 1),
"dt_compat_enabled": (dt_compat_enabled, 1, 1),
"dt_compat_on_bus": (dt_compat_on_bus, 2, 2),
"dt_compat_any_has_prop": (dt_compat_any_has_prop, 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),