1 /* 2 * Copyright (c) 2020 Nordic Semiconductor ASA 3 * SPDX-License-Identifier: Apache-2.0 4 */ 5 6 #ifndef ZEPHYR_INCLUDE_DEVICETREE_ORDINALS_H_ 7 #define ZEPHYR_INCLUDE_DEVICETREE_ORDINALS_H_ 8 9 /** 10 * @file 11 * @brief Devicetree node dependency ordinals 12 */ 13 14 /** 15 * @defgroup devicetree-dep-ord Dependency tracking 16 * @ingroup devicetree 17 * @{ 18 */ 19 20 /** 21 * @brief Get a node's dependency ordinal 22 * @param node_id Node identifier 23 * @return the node's dependency ordinal as an integer literal 24 */ 25 #define DT_DEP_ORD(node_id) DT_CAT(node_id, _ORD) 26 27 /** 28 * @brief Get a list of dependency ordinals of a node's direct dependencies 29 * 30 * There is a comma after each ordinal in the expansion, **including** 31 * the last one: 32 * 33 * DT_REQUIRES_DEP_ORDS(my_node) // required_ord_1, ..., required_ord_n, 34 * 35 * The one case DT_REQUIRES_DEP_ORDS() expands to nothing is when 36 * given the root node identifier @p DT_ROOT as argument. The root has 37 * no direct dependencies; every other node at least depends on its 38 * parent. 39 * 40 * @param node_id Node identifier 41 * @return a list of dependency ordinals, with each ordinal followed 42 * by a comma (<tt>,</tt>), or an empty expansion 43 */ 44 #define DT_REQUIRES_DEP_ORDS(node_id) DT_CAT(node_id, _REQUIRES_ORDS) 45 46 /** 47 * @brief Get a list of dependency ordinals of what depends directly on a node 48 * 49 * There is a comma after each ordinal in the expansion, **including** 50 * the last one: 51 * 52 * DT_SUPPORTS_DEP_ORDS(my_node) // supported_ord_1, ..., supported_ord_n, 53 * 54 * DT_SUPPORTS_DEP_ORDS() may expand to nothing. This happens when @p node_id 55 * refers to a leaf node that nothing else depends on. 56 * 57 * @param node_id Node identifier 58 * @return a list of dependency ordinals, with each ordinal followed 59 * by a comma (<tt>,</tt>), or an empty expansion 60 */ 61 #define DT_SUPPORTS_DEP_ORDS(node_id) DT_CAT(node_id, _SUPPORTS_ORDS) 62 63 /** 64 * @brief Get a DT_DRV_COMPAT instance's dependency ordinal 65 * 66 * Equivalent to DT_DEP_ORD(DT_DRV_INST(inst)). 67 * 68 * @param inst instance number 69 * @return The instance's dependency ordinal 70 */ 71 #define DT_INST_DEP_ORD(inst) DT_DEP_ORD(DT_DRV_INST(inst)) 72 73 /** 74 * @brief Get a list of dependency ordinals of a DT_DRV_COMPAT instance's 75 * direct dependencies 76 * 77 * Equivalent to DT_REQUIRES_DEP_ORDS(DT_DRV_INST(inst)). 78 * 79 * @param inst instance number 80 * @return a list of dependency ordinals for the nodes the instance depends 81 * on directly 82 */ 83 #define DT_INST_REQUIRES_DEP_ORDS(inst) DT_REQUIRES_DEP_ORDS(DT_DRV_INST(inst)) 84 85 /** 86 * @brief Get a list of dependency ordinals of what depends directly on a 87 * DT_DRV_COMPAT instance 88 * 89 * Equivalent to DT_SUPPORTS_DEP_ORDS(DT_DRV_INST(inst)). 90 * 91 * @param inst instance number 92 * @return a list of node identifiers for the nodes that depend directly 93 * on the instance 94 */ 95 #define DT_INST_SUPPORTS_DEP_ORDS(inst) DT_SUPPORTS_DEP_ORDS(DT_DRV_INST(inst)) 96 97 /** 98 * @} 99 */ 100 101 #endif /* ZEPHYR_INCLUDE_DEVICETREE_ORDINALS_H_ */ 102