scripts: kconfigfunctions: Redefine dt_nodelabel_has_compat()

The function in its current form is confusing because unlike other
similarly named functions (dt_nodelabel_has_prop(), dt_node_has_prop())
or devicetree macros (DT_NODE_HAS_COMPAT(), DT_NODE_HAS_PROP()), this
function takes into account the status of the checked node and returns
"y" only when the node is enabled.
This commit redefines dt_nodelabel_has_compat() so that it no longer
checks the node status, and for cases where the previous functionality
is needed, a new function named dt_nodelabel_enabled_with_compat()
is introduced as a replacement.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
diff --git a/scripts/kconfig/kconfigfunctions.py b/scripts/kconfig/kconfigfunctions.py
index 6b2e237..fc54fc9 100644
--- a/scripts/kconfig/kconfigfunctions.py
+++ b/scripts/kconfig/kconfigfunctions.py
@@ -498,6 +498,23 @@
 
 def dt_nodelabel_has_compat(kconf, _, label, compat):
     """
+    This function takes a 'label' and looks for an EDT node with that label.
+    If it finds such node, it returns "y" if this node is compatible with
+    the provided 'compat'. Otherwise, it return "n" .
+    """
+    if doc_mode or edt is None:
+        return "n"
+
+    node = edt.label2node.get(label)
+
+    if node and compat in node.compats:
+        return "y"
+
+    return "n"
+
+
+def dt_nodelabel_enabled_with_compat(kconf, _, label, compat):
+    """
     This function takes a 'label' and returns "y" if an "enabled" node with
     such label can be found in the EDT and that node is compatible with the
     provided 'compat', otherwise it returns "n".
@@ -560,6 +577,7 @@
         "dt_path_enabled": (dt_node_enabled, 1, 1),
         "dt_alias_enabled": (dt_node_enabled, 1, 1),
         "dt_nodelabel_enabled": (dt_nodelabel_enabled, 1, 1),
+        "dt_nodelabel_enabled_with_compat": (dt_nodelabel_enabled_with_compat, 2, 2),
         "dt_chosen_reg_addr_int": (dt_chosen_reg, 1, 3),
         "dt_chosen_reg_addr_hex": (dt_chosen_reg, 1, 3),
         "dt_chosen_reg_size_int": (dt_chosen_reg, 1, 3),