|
435 | 435 | */ |
436 | 436 | #define DT_CHILD(node_id, child) UTIL_CAT(node_id, DT_S_PREFIX(child)) |
437 | 437 |
|
| 438 | +/** |
| 439 | + * @brief Get a node identifier for a child node by a reg address |
| 440 | + * |
| 441 | + * Example devicetree fragment: |
| 442 | + * |
| 443 | + * @code{.dts} |
| 444 | + * / { |
| 445 | + * soc-label: soc { |
| 446 | + * serial1: serial@40001000 { |
| 447 | + * status = "okay"; |
| 448 | + * current-speed = <115200>; |
| 449 | + * ... |
| 450 | + * }; |
| 451 | + * }; |
| 452 | + * }; |
| 453 | + * @endcode |
| 454 | + * |
| 455 | + * Example usage with DT_PROP() to get the status of the |
| 456 | + * `serial@40001000` node: |
| 457 | + * |
| 458 | + * @code{.c} |
| 459 | + * #define SOC_NODE DT_NODELABEL(soc_label) |
| 460 | + * DT_PROP(DT_CHILD_BY_REG_ADDR(SOC_NODE, 0, 40001000), status) // "okay" |
| 461 | + * @endcode |
| 462 | + * |
| 463 | + * |
| 464 | + * @param node_id node identifier |
| 465 | + * @param idx Register address index for the child node. |
| 466 | + * @param addr Register address for the child node. Can be hexadecimal (prefix with 0x) or decimal |
| 467 | + * |
| 468 | + * @return node identifier for the child node with the reg address at a specified index |
| 469 | + */ |
| 470 | +#define DT_CHILD_BY_REG_ADDR(node_id, idx, addr) \ |
| 471 | + DT_CAT5(node_id, _CHILD_REG_IDX_, idx, _ADDR_, addr) |
| 472 | + |
438 | 473 | /** |
439 | 474 | * @brief Get a node identifier for a status `okay` node with a compatible |
440 | 475 | * |
|
4066 | 4101 | #define DT_INST_CHILD(inst, child) \ |
4067 | 4102 | DT_CHILD(DT_DRV_INST(inst), child) |
4068 | 4103 |
|
| 4104 | +/** |
| 4105 | + * @brief Get a node identifier for a child node by a reg address of DT_DRV_INST(inst) |
| 4106 | + * |
| 4107 | + * @param inst instance number |
| 4108 | + * @param idx Register address index for the child node. |
| 4109 | + * @param addr Register address for the child node. Can be hexadecimal (prefix with 0x) or decimal |
| 4110 | + * |
| 4111 | + * @return node identifier for the child node with the reg address at a specified index |
| 4112 | + * |
| 4113 | + * @see DT_CHILD_BY_REG_ADDR |
| 4114 | + */ |
| 4115 | +#define DT_INST_CHILD_BY_REG_ADDR(inst, idx, addr) \ |
| 4116 | + DT_CHILD_BY_REG_ADDR(DT_DRV_INST(inst), idx, addr) |
| 4117 | + |
4069 | 4118 | /** |
4070 | 4119 | * @brief Get the number of child nodes of a given node |
4071 | 4120 | * |
|
0 commit comments