Zephyr API Documentation
2.7.0-rc2
A Scalable Open Source RTOS
|
Macros | |
#define | DT_NODE_EXISTS(node_id) IS_ENABLED(DT_CAT(node_id, _EXISTS)) |
Does a node identifier refer to a node? More... | |
#define | DT_NODE_HAS_STATUS(node_id, status) DT_NODE_HAS_STATUS_INTERNAL(node_id, status) |
Does a node identifier refer to a node with a status? More... | |
#define | DT_HAS_COMPAT_STATUS_OKAY(compat) IS_ENABLED(DT_CAT(DT_COMPAT_HAS_OKAY_, compat)) |
Does the devicetree have a status "okay" node with a compatible? More... | |
#define | DT_NUM_INST_STATUS_OKAY(compat) |
Get the number of instances of a given compatible with status "okay". More... | |
#define | DT_NODE_HAS_COMPAT(node_id, compat) IS_ENABLED(DT_CAT(node_id, _COMPAT_MATCHES_##compat)) |
Does a devicetree node match a compatible? More... | |
#define | DT_NODE_HAS_COMPAT_STATUS(node_id, compat, status) DT_NODE_HAS_COMPAT(node_id, compat) && DT_NODE_HAS_STATUS(node_id, status) |
Does a devicetree node have a compatible and status? More... | |
#define | DT_NODE_HAS_PROP(node_id, prop) IS_ENABLED(DT_CAT(node_id, _P_##prop##_EXISTS)) |
Does a devicetree node have a property? More... | |
#define | DT_PHA_HAS_CELL_AT_IDX(node_id, pha, idx, cell) |
Does a phandle array have a named cell specifier at an index? More... | |
#define | DT_PHA_HAS_CELL(node_id, pha, cell) DT_PHA_HAS_CELL_AT_IDX(node_id, pha, 0, cell) |
Equivalent to DT_PHA_HAS_CELL_AT_IDX(node_id, pha, 0, cell) More... | |
#define DT_HAS_COMPAT_STATUS_OKAY | ( | compat | ) | IS_ENABLED(DT_CAT(DT_COMPAT_HAS_OKAY_, compat)) |
#include <include/devicetree.h>
Does the devicetree have a status "okay" node with a compatible?
Test for whether the devicetree has any nodes with status "okay" and the given compatible. That is, this returns 1 if and only if there is at least one "node_id" for which both of these expressions return 1:
DT_NODE_HAS_STATUS(node_id, okay) DT_NODE_HAS_COMPAT(node_id, compat)
As usual, both a missing status and an "ok" status are treated as "okay".
compat | lowercase-and-underscores compatible, without quotes |
#define DT_NODE_EXISTS | ( | node_id | ) | IS_ENABLED(DT_CAT(node_id, _EXISTS)) |
#include <include/devicetree.h>
Does a node identifier refer to a node?
Tests whether a node identifier refers to a node which exists, i.e. is defined in the devicetree.
It doesn't matter whether or not the node has a matching binding, or what the node's status value is. This is purely a check of whether the node exists at all.
node_id | a node identifier |
#define DT_NODE_HAS_COMPAT | ( | node_id, | |
compat | |||
) | IS_ENABLED(DT_CAT(node_id, _COMPAT_MATCHES_##compat)) |
#include <include/devicetree.h>
Does a devicetree node match a compatible?
Example devicetree fragment:
n: node { compatible = "vnd,specific-device", "generic-device"; }
Example usages which evaluate to 1:
DT_NODE_HAS_COMPAT(DT_NODELABEL(n), vnd_specific_device) DT_NODE_HAS_COMPAT(DT_NODELABEL(n), generic_device)
This macro only uses the value of the compatible property. Whether or not a particular compatible has a matching binding has no effect on its value, nor does the node's status.
node_id | node identifier |
compat | lowercase-and-underscores compatible, without quotes |
#define DT_NODE_HAS_COMPAT_STATUS | ( | node_id, | |
compat, | |||
status | |||
) | DT_NODE_HAS_COMPAT(node_id, compat) && DT_NODE_HAS_STATUS(node_id, status) |
#include <include/devicetree.h>
Does a devicetree node have a compatible and status?
This is equivalent to:
(DT_NODE_HAS_COMPAT(node_id, compat) && DT_NODE_HAS_STATUS(node_id, status))
node_id | node identifier |
compat | lowercase-and-underscores compatible, without quotes |
status | okay or disabled as a token, not a string |
#define DT_NODE_HAS_PROP | ( | node_id, | |
prop | |||
) | IS_ENABLED(DT_CAT(node_id, _P_##prop##_EXISTS)) |
#include <include/devicetree.h>
Does a devicetree node have a property?
Tests whether a devicetree node has a property defined.
This tests whether the property is defined at all, not whether a boolean property is true or false. To get a boolean property's truth value, use DT_PROP(node_id, prop) instead.
node_id | node identifier |
prop | lowercase-and-underscores property name |
#define DT_NODE_HAS_STATUS | ( | node_id, | |
status | |||
) | DT_NODE_HAS_STATUS_INTERNAL(node_id, status) |
#include <include/devicetree.h>
Does a node identifier refer to a node with a status?
Example uses:
DT_NODE_HAS_STATUS(DT_PATH(soc, i2c_12340000), okay) DT_NODE_HAS_STATUS(DT_PATH(soc, i2c_12340000), disabled)
Tests whether a node identifier refers to a node which:
node_id | a node identifier |
status | a status as one of the tokens okay or disabled, not a string |
#define DT_NUM_INST_STATUS_OKAY | ( | compat | ) |
#include <include/devicetree.h>
Get the number of instances of a given compatible with status "okay".
compat | lowercase-and-underscores compatible, without quotes |
#define DT_PHA_HAS_CELL | ( | node_id, | |
pha, | |||
cell | |||
) | DT_PHA_HAS_CELL_AT_IDX(node_id, pha, 0, cell) |
#include <include/devicetree.h>
Equivalent to DT_PHA_HAS_CELL_AT_IDX(node_id, pha, 0, cell)
node_id | node identifier |
pha | lowercase-and-underscores property with type "phandle-array" |
cell | lowercase-and-underscores cell name whose existence to check at index "idx" |
#define DT_PHA_HAS_CELL_AT_IDX | ( | node_id, | |
pha, | |||
idx, | |||
cell | |||
) |
#include <include/devicetree.h>
Does a phandle array have a named cell specifier at an index?
If this returns 1, then the phandle-array property "pha" has a cell named "cell" at index "idx", and therefore DT_PHA_BY_IDX(node_id, pha, idx, cell) is valid. If it returns 0, it's an error to use DT_PHA_BY_IDX() with the same arguments.
node_id | node identifier |
pha | lowercase-and-underscores property with type "phandle-array" |
idx | index to check within "pha" |
cell | lowercase-and-underscores cell name whose existence to check at index "idx" |