1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Function to read values from the device tree node attached to a udevice.
5 * Copyright (c) 2017 Google, Inc
6 * Written by Simon Glass <sjg@chromium.org>
12 #include <dm/fdtaddr.h>
13 #include <dm/ofnode.h>
14 #include <dm/uclass.h>
18 #if CONFIG_IS_ENABLED(OF_LIVE)
19 static inline const struct device_node *dev_np(const struct udevice *dev)
21 return ofnode_to_np(dev->node);
24 static inline const struct device_node *dev_np(const struct udevice *dev)
31 * dev_ofnode() - get the DT node reference associated with a udevice
33 * @dev: device to check
34 * @return reference of the the device's DT node
36 static inline ofnode dev_ofnode(const struct udevice *dev)
41 static inline bool dev_of_valid(const struct udevice *dev)
43 return ofnode_valid(dev_ofnode(dev));
46 #ifndef CONFIG_DM_DEV_READ_INLINE
49 * dev_read_u32() - read a 32-bit integer from a device's DT property
51 * @dev: device to read DT property from
52 * @propname: name of the property to read from
53 * @outp: place to put value (if found)
54 * @return 0 if OK, -ve on error
56 int dev_read_u32(const struct udevice *dev, const char *propname, u32 *outp);
59 * dev_read_u32_default() - read a 32-bit integer from a device's DT property
61 * @dev: device to read DT property from
62 * @propname: name of the property to read from
63 * @def: default value to return if the property has no value
64 * @return property value, or @def if not found
66 int dev_read_u32_default(const struct udevice *dev, const char *propname,
70 * dev_read_s32() - read a signed 32-bit integer from a device's DT property
72 * @dev: device to read DT property from
73 * @propname: name of the property to read from
74 * @outp: place to put value (if found)
75 * @return 0 if OK, -ve on error
77 int dev_read_s32(const struct udevice *dev, const char *propname, s32 *outp);
80 * dev_read_s32_default() - read a signed 32-bit int from a device's DT property
82 * @dev: device to read DT property from
83 * @propname: name of the property to read from
84 * @def: default value to return if the property has no value
85 * @return property value, or @def if not found
87 int dev_read_s32_default(const struct udevice *dev, const char *propname,
91 * dev_read_u32u() - read a 32-bit integer from a device's DT property
93 * This version uses a standard uint type.
95 * @dev: device to read DT property from
96 * @propname: name of the property to read from
97 * @outp: place to put value (if found)
98 * @return 0 if OK, -ve on error
100 int dev_read_u32u(const struct udevice *dev, const char *propname, uint *outp);
103 * dev_read_u64() - read a 64-bit integer from a device's DT property
105 * @dev: device to read DT property from
106 * @propname: name of the property to read from
107 * @outp: place to put value (if found)
108 * @return 0 if OK, -ve on error
110 int dev_read_u64(const struct udevice *dev, const char *propname, u64 *outp);
113 * dev_read_u64_default() - read a 64-bit integer from a device's DT property
115 * @dev: device to read DT property from
116 * @propname: name of the property to read from
117 * @def: default value to return if the property has no value
118 * @return property value, or @def if not found
120 u64 dev_read_u64_default(const struct udevice *dev, const char *propname,
124 * dev_read_string() - Read a string from a device's DT property
126 * @dev: device to read DT property from
127 * @propname: name of the property to read
128 * @return string from property value, or NULL if there is no such property
130 const char *dev_read_string(const struct udevice *dev, const char *propname);
133 * dev_read_bool() - read a boolean value from a device's DT property
135 * @dev: device to read DT property from
136 * @propname: name of property to read
137 * @return true if property is present (meaning true), false if not present
139 bool dev_read_bool(const struct udevice *dev, const char *propname);
142 * dev_read_subnode() - find a named subnode of a device
144 * @dev: device whose DT node contains the subnode
145 * @subnode_name: name of subnode to find
146 * @return reference to subnode (which can be invalid if there is no such
149 ofnode dev_read_subnode(const struct udevice *dev, const char *subbnode_name);
152 * dev_read_size() - read the size of a property
154 * @dev: device to check
155 * @propname: property to check
156 * @return size of property if present, or -EINVAL if not
158 int dev_read_size(const struct udevice *dev, const char *propname);
161 * dev_read_addr_index() - Get the indexed reg property of a device
163 * @dev: Device to read from
164 * @index: the 'reg' property can hold a list of <addr, size> pairs
165 * and @index is used to select which one is required
167 * @return address or FDT_ADDR_T_NONE if not found
169 fdt_addr_t dev_read_addr_index(const struct udevice *dev, int index);
172 * dev_read_addr_size_index() - Get the indexed reg property of a device
174 * @dev: Device to read from
175 * @index: the 'reg' property can hold a list of <addr, size> pairs
176 * and @index is used to select which one is required
177 * @size: place to put size value (on success)
179 * @return address or FDT_ADDR_T_NONE if not found
181 fdt_addr_t dev_read_addr_size_index(const struct udevice *dev, int index,
185 * dev_remap_addr_index() - Get the indexed reg property of a device
186 * as a memory-mapped I/O pointer
188 * @dev: Device to read from
189 * @index: the 'reg' property can hold a list of <addr, size> pairs
190 * and @index is used to select which one is required
192 * @return pointer or NULL if not found
194 void *dev_remap_addr_index(const struct udevice *dev, int index);
197 * dev_read_addr_name() - Get the reg property of a device, indexed by name
199 * @dev: Device to read from
200 * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
201 * 'reg-names' property providing named-based identification. @index
202 * indicates the value to search for in 'reg-names'.
204 * @return address or FDT_ADDR_T_NONE if not found
206 fdt_addr_t dev_read_addr_name(const struct udevice *dev, const char *name);
209 * dev_read_addr_size_name() - Get the reg property of a device, indexed by name
211 * @dev: Device to read from
212 * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
213 * 'reg-names' property providing named-based identification. @index
214 * indicates the value to search for in 'reg-names'.
215 * @size: place to put size value (on success)
217 * @return address or FDT_ADDR_T_NONE if not found
219 fdt_addr_t dev_read_addr_size_name(const struct udevice *dev, const char *name,
223 * dev_remap_addr_name() - Get the reg property of a device, indexed by name,
224 * as a memory-mapped I/O pointer
226 * @dev: Device to read from
227 * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
228 * 'reg-names' property providing named-based identification. @index
229 * indicates the value to search for in 'reg-names'.
231 * @return pointer or NULL if not found
233 void *dev_remap_addr_name(const struct udevice *dev, const char *name);
236 * dev_read_addr() - Get the reg property of a device
238 * @dev: Device to read from
240 * @return address or FDT_ADDR_T_NONE if not found
242 fdt_addr_t dev_read_addr(const struct udevice *dev);
245 * dev_read_addr_ptr() - Get the reg property of a device
248 * @dev: Device to read from
250 * @return pointer or NULL if not found
252 void *dev_read_addr_ptr(const struct udevice *dev);
255 * dev_read_addr_pci() - Read an address and handle PCI address translation
257 * At present U-Boot does not have address translation logic for PCI in the
258 * livetree implementation (of_addr.c). This special function supports this for
259 * the flat tree implementation.
261 * This function should be removed (and code should use dev_read() instead)
264 * 1. PCI address translation is added; and either
265 * 2. everything uses livetree where PCI translation is used (which is feasible
266 * in SPL and U-Boot proper) or PCI address translation is added to
267 * fdtdec_get_addr() and friends.
269 * @dev: Device to read from
270 * @return address or FDT_ADDR_T_NONE if not found
272 fdt_addr_t dev_read_addr_pci(const struct udevice *dev);
275 * dev_remap_addr() - Get the reg property of a device as a
276 * memory-mapped I/O pointer
278 * @dev: Device to read from
280 * @return pointer or NULL if not found
282 void *dev_remap_addr(const struct udevice *dev);
285 * dev_read_addr_size() - get address and size from a device property
287 * This does no address translation. It simply reads an property that contains
288 * an address and a size value, one after the other.
290 * @dev: Device to read from
291 * @propname: property to read
292 * @sizep: place to put size value (on success)
293 * @return address value, or FDT_ADDR_T_NONE on error
295 fdt_addr_t dev_read_addr_size(const struct udevice *dev, const char *propname,
299 * dev_read_name() - get the name of a device's node
301 * @dev: Device to read from
302 * @return name of node
304 const char *dev_read_name(const struct udevice *dev);
307 * dev_read_stringlist_search() - find string in a string list and return index
309 * Note that it is possible for this function to succeed on property values
310 * that are not NUL-terminated. That's because the function will stop after
311 * finding the first occurrence of @string. This can for example happen with
312 * small-valued cell properties, such as #address-cells, when searching for
315 * @dev: device to check
316 * @propname: name of the property containing the string list
317 * @string: string to look up in the string list
320 * the index of the string in the list of strings
321 * -ENODATA if the property is not found
322 * -EINVAL on some other error
324 int dev_read_stringlist_search(const struct udevice *dev, const char *property,
328 * dev_read_string_index() - obtain an indexed string from a string list
330 * @dev: device to examine
331 * @propname: name of the property containing the string list
332 * @index: index of the string to return
333 * @out: return location for the string
336 * length of string, if found or -ve error value if not found
338 int dev_read_string_index(const struct udevice *dev, const char *propname,
339 int index, const char **outp);
342 * dev_read_string_count() - find the number of strings in a string list
344 * @dev: device to examine
345 * @propname: name of the property containing the string list
347 * number of strings in the list, or -ve error value if not found
349 int dev_read_string_count(const struct udevice *dev, const char *propname);
351 * dev_read_phandle_with_args() - Find a node pointed by phandle in a list
353 * This function is useful to parse lists of phandles and their arguments.
354 * Returns 0 on success and fills out_args, on error returns appropriate
357 * Caller is responsible to call of_node_put() on the returned out_args->np
371 * list = <&phandle1 1 2 &phandle2 3>;
374 * To get a device_node of the `node2' node you may call this:
375 * dev_read_phandle_with_args(dev, "list", "#list-cells", 0, 1, &args);
377 * @dev: device whose node containing a list
378 * @list_name: property name that contains a list
379 * @cells_name: property name that specifies phandles' arguments count
380 * @cells_count: Cell count to use if @cells_name is NULL
381 * @index: index of a phandle to parse out
382 * @out_args: optional pointer to output arguments structure (will be filled)
383 * @return 0 on success (with @out_args filled out if not NULL), -ENOENT if
384 * @list_name does not exist, -EINVAL if a phandle was not found,
385 * @cells_name could not be found, the arguments were truncated or there
386 * were too many arguments.
388 int dev_read_phandle_with_args(const struct udevice *dev, const char *list_name,
389 const char *cells_name, int cell_count,
390 int index, struct ofnode_phandle_args *out_args);
393 * dev_count_phandle_with_args() - Return phandle number in a list
395 * This function is usefull to get phandle number contained in a property list.
396 * For example, this allows to allocate the right amount of memory to keep
397 * clock's reference contained into the "clocks" property.
400 * @dev: device whose node containing a list
401 * @list_name: property name that contains a list
402 * @cells_name: property name that specifies phandles' arguments count
403 * @Returns number of phandle found on success, on error returns appropriate
407 int dev_count_phandle_with_args(const struct udevice *dev,
408 const char *list_name, const char *cells_name);
411 * dev_read_addr_cells() - Get the number of address cells for a device's node
413 * This walks back up the tree to find the closest #address-cells property
414 * which controls the given node.
416 * @dev: device to check
417 * @return number of address cells this node uses
419 int dev_read_addr_cells(const struct udevice *dev);
422 * dev_read_size_cells() - Get the number of size cells for a device's node
424 * This walks back up the tree to find the closest #size-cells property
425 * which controls the given node.
427 * @dev: device to check
428 * @return number of size cells this node uses
430 int dev_read_size_cells(const struct udevice *dev);
433 * dev_read_addr_cells() - Get the address cells property in a node
435 * This function matches fdt_address_cells().
437 * @dev: device to check
438 * @return number of address cells this node uses
440 int dev_read_simple_addr_cells(const struct udevice *dev);
443 * dev_read_size_cells() - Get the size cells property in a node
445 * This function matches fdt_size_cells().
447 * @dev: device to check
448 * @return number of size cells this node uses
450 int dev_read_simple_size_cells(const struct udevice *dev);
453 * dev_read_phandle() - Get the phandle from a device
455 * @dev: device to check
456 * @return phandle (1 or greater), or 0 if no phandle or other error
458 int dev_read_phandle(const struct udevice *dev);
461 * dev_read_prop()- - read a property from a device's node
463 * @dev: device to check
464 * @propname: property to read
465 * @lenp: place to put length on success
466 * @return pointer to property, or NULL if not found
468 const void *dev_read_prop(const struct udevice *dev, const char *propname,
472 * dev_read_alias_seq() - Get the alias sequence number of a node
474 * This works out whether a node is pointed to by an alias, and if so, the
475 * sequence number of that alias. Aliases are of the form <base><num> where
476 * <num> is the sequence number. For example spi2 would be sequence number 2.
478 * @dev: device to look up
479 * @devnump: set to the sequence number if one is found
480 * @return 0 if a sequence was found, -ve if not
482 int dev_read_alias_seq(const struct udevice *dev, int *devnump);
485 * dev_read_u32_array() - Find and read an array of 32 bit integers
487 * Search for a property in a device node and read 32-bit value(s) from
490 * The out_values is modified only if a valid u32 value can be decoded.
492 * @dev: device to look up
493 * @propname: name of the property to read
494 * @out_values: pointer to return value, modified only if return value is 0
495 * @sz: number of array elements to read
496 * @return 0 on success, -EINVAL if the property does not exist, -ENODATA if
497 * property does not have a value, and -EOVERFLOW if the property data isn't
500 int dev_read_u32_array(const struct udevice *dev, const char *propname,
501 u32 *out_values, size_t sz);
504 * dev_read_first_subnode() - find the first subnode of a device's node
506 * @dev: device to look up
507 * @return reference to the first subnode (which can be invalid if the device's
508 * node has no subnodes)
510 ofnode dev_read_first_subnode(const struct udevice *dev);
513 * ofnode_next_subnode() - find the next sibling of a subnode
515 * @node: valid reference to previous node (sibling)
516 * @return reference to the next subnode (which can be invalid if the node
517 * has no more siblings)
519 ofnode dev_read_next_subnode(ofnode node);
522 * dev_read_u8_array_ptr() - find an 8-bit array
524 * Look up a device's node property and return a pointer to its contents as a
525 * byte array of given length. The property must have at least enough data
526 * for the array (count bytes). It may have more, but this will be ignored.
527 * The data is not copied.
529 * @dev: device to look up
530 * @propname: name of property to find
531 * @sz: number of array elements
532 * @return pointer to byte array if found, or NULL if the property is not
533 * found or there is not enough data
535 const uint8_t *dev_read_u8_array_ptr(const struct udevice *dev,
536 const char *propname, size_t sz);
539 * dev_read_enabled() - check whether a node is enabled
541 * This looks for a 'status' property. If this exists, then returns 1 if
542 * the status is 'ok' and 0 otherwise. If there is no status property,
543 * it returns 1 on the assumption that anything mentioned should be enabled
546 * @dev: device to examine
547 * @return integer value 0 (not enabled) or 1 (enabled)
549 int dev_read_enabled(const struct udevice *dev);
552 * dev_read_resource() - obtain an indexed resource from a device.
554 * @dev: device to examine
555 * @index index of the resource to retrieve (0 = first)
556 * @res returns the resource
557 * @return 0 if ok, negative on error
559 int dev_read_resource(const struct udevice *dev, uint index,
560 struct resource *res);
563 * dev_read_resource_byname() - obtain a named resource from a device.
565 * @dev: device to examine
566 * @name: name of the resource to retrieve
567 * @res: returns the resource
568 * @return 0 if ok, negative on error
570 int dev_read_resource_byname(const struct udevice *dev, const char *name,
571 struct resource *res);
574 * dev_translate_address() - Translate a device-tree address
576 * Translate an address from the device-tree into a CPU physical address. This
577 * function walks up the tree and applies the various bus mappings along the
580 * @dev: device giving the context in which to translate the address
581 * @in_addr: pointer to the address to translate
582 * @return the translated address; OF_BAD_ADDR on error
584 u64 dev_translate_address(const struct udevice *dev, const fdt32_t *in_addr);
587 * dev_translate_dma_address() - Translate a device-tree DMA address
589 * Translate a DMA address from the device-tree into a CPU physical address.
590 * This function walks up the tree and applies the various bus mappings along
593 * @dev: device giving the context in which to translate the DMA address
594 * @in_addr: pointer to the DMA address to translate
595 * @return the translated DMA address; OF_BAD_ADDR on error
597 u64 dev_translate_dma_address(const struct udevice *dev,
598 const fdt32_t *in_addr);
601 * dev_read_alias_highest_id - Get highest alias id for the given stem
602 * @stem: Alias stem to be examined
604 * The function travels the lookup table to get the highest alias id for the
606 * @return alias ID, if found, else -1
608 int dev_read_alias_highest_id(const char *stem);
610 #else /* CONFIG_DM_DEV_READ_INLINE is enabled */
612 static inline int dev_read_u32(const struct udevice *dev,
613 const char *propname, u32 *outp)
615 return ofnode_read_u32(dev_ofnode(dev), propname, outp);
618 static inline int dev_read_u32_default(const struct udevice *dev,
619 const char *propname, int def)
621 return ofnode_read_u32_default(dev_ofnode(dev), propname, def);
624 static inline int dev_read_s32(const struct udevice *dev,
625 const char *propname, s32 *outp)
627 return ofnode_read_s32(dev_ofnode(dev), propname, outp);
630 static inline int dev_read_s32_default(const struct udevice *dev,
631 const char *propname, int def)
633 return ofnode_read_s32_default(dev_ofnode(dev), propname, def);
636 static inline int dev_read_u32u(const struct udevice *dev,
637 const char *propname, uint *outp)
642 ret = ofnode_read_u32(dev_ofnode(dev), propname, &val);
650 static inline int dev_read_u64(const struct udevice *dev,
651 const char *propname, u64 *outp)
653 return ofnode_read_u64(dev_ofnode(dev), propname, outp);
656 static inline u64 dev_read_u64_default(const struct udevice *dev,
657 const char *propname, u64 def)
659 return ofnode_read_u64_default(dev_ofnode(dev), propname, def);
662 static inline const char *dev_read_string(const struct udevice *dev,
663 const char *propname)
665 return ofnode_read_string(dev_ofnode(dev), propname);
668 static inline bool dev_read_bool(const struct udevice *dev,
669 const char *propname)
671 return ofnode_read_bool(dev_ofnode(dev), propname);
674 static inline ofnode dev_read_subnode(const struct udevice *dev,
675 const char *subbnode_name)
677 return ofnode_find_subnode(dev_ofnode(dev), subbnode_name);
680 static inline int dev_read_size(const struct udevice *dev, const char *propname)
682 return ofnode_read_size(dev_ofnode(dev), propname);
685 static inline fdt_addr_t dev_read_addr_index(const struct udevice *dev,
688 return devfdt_get_addr_index(dev, index);
691 static inline fdt_addr_t dev_read_addr_size_index(const struct udevice *dev,
695 return devfdt_get_addr_size_index(dev, index, size);
698 static inline fdt_addr_t dev_read_addr_name(const struct udevice *dev,
701 return devfdt_get_addr_name(dev, name);
704 static inline fdt_addr_t dev_read_addr_size_name(const struct udevice *dev,
708 return devfdt_get_addr_size_name(dev, name, size);
711 static inline fdt_addr_t dev_read_addr(const struct udevice *dev)
713 return devfdt_get_addr(dev);
716 static inline void *dev_read_addr_ptr(const struct udevice *dev)
718 return devfdt_get_addr_ptr(dev);
721 static inline fdt_addr_t dev_read_addr_pci(const struct udevice *dev)
723 return devfdt_get_addr_pci(dev);
726 static inline void *dev_remap_addr(const struct udevice *dev)
728 return devfdt_remap_addr(dev);
731 static inline void *dev_remap_addr_index(const struct udevice *dev, int index)
733 return devfdt_remap_addr_index(dev, index);
736 static inline void *dev_remap_addr_name(const struct udevice *dev,
739 return devfdt_remap_addr_name(dev, name);
742 static inline fdt_addr_t dev_read_addr_size(const struct udevice *dev,
743 const char *propname,
746 return ofnode_get_addr_size(dev_ofnode(dev), propname, sizep);
749 static inline const char *dev_read_name(const struct udevice *dev)
751 return ofnode_get_name(dev_ofnode(dev));
754 static inline int dev_read_stringlist_search(const struct udevice *dev,
755 const char *propname,
758 return ofnode_stringlist_search(dev_ofnode(dev), propname, string);
761 static inline int dev_read_string_index(const struct udevice *dev,
762 const char *propname, int index,
765 return ofnode_read_string_index(dev_ofnode(dev), propname, index, outp);
768 static inline int dev_read_string_count(const struct udevice *dev,
769 const char *propname)
771 return ofnode_read_string_count(dev_ofnode(dev), propname);
774 static inline int dev_read_phandle_with_args(const struct udevice *dev,
775 const char *list_name, const char *cells_name, int cell_count,
776 int index, struct ofnode_phandle_args *out_args)
778 return ofnode_parse_phandle_with_args(dev_ofnode(dev), list_name,
779 cells_name, cell_count, index,
783 static inline int dev_count_phandle_with_args(const struct udevice *dev,
784 const char *list_name, const char *cells_name)
786 return ofnode_count_phandle_with_args(dev_ofnode(dev), list_name,
790 static inline int dev_read_addr_cells(const struct udevice *dev)
792 /* NOTE: this call should walk up the parent stack */
793 return fdt_address_cells(gd->fdt_blob, dev_of_offset(dev));
796 static inline int dev_read_size_cells(const struct udevice *dev)
798 /* NOTE: this call should walk up the parent stack */
799 return fdt_size_cells(gd->fdt_blob, dev_of_offset(dev));
802 static inline int dev_read_simple_addr_cells(const struct udevice *dev)
804 return fdt_address_cells(gd->fdt_blob, dev_of_offset(dev));
807 static inline int dev_read_simple_size_cells(const struct udevice *dev)
809 return fdt_size_cells(gd->fdt_blob, dev_of_offset(dev));
812 static inline int dev_read_phandle(const struct udevice *dev)
814 return fdt_get_phandle(gd->fdt_blob, dev_of_offset(dev));
817 static inline const void *dev_read_prop(const struct udevice *dev,
818 const char *propname, int *lenp)
820 return ofnode_get_property(dev_ofnode(dev), propname, lenp);
823 static inline int dev_read_alias_seq(const struct udevice *dev, int *devnump)
825 return fdtdec_get_alias_seq(gd->fdt_blob, dev->uclass->uc_drv->name,
826 dev_of_offset(dev), devnump);
829 static inline int dev_read_u32_array(const struct udevice *dev,
830 const char *propname, u32 *out_values,
833 return ofnode_read_u32_array(dev_ofnode(dev), propname, out_values, sz);
836 static inline ofnode dev_read_first_subnode(const struct udevice *dev)
838 return ofnode_first_subnode(dev_ofnode(dev));
841 static inline ofnode dev_read_next_subnode(ofnode node)
843 return ofnode_next_subnode(node);
846 static inline const uint8_t *dev_read_u8_array_ptr(const struct udevice *dev,
847 const char *propname,
850 return ofnode_read_u8_array_ptr(dev_ofnode(dev), propname, sz);
853 static inline int dev_read_enabled(const struct udevice *dev)
855 return fdtdec_get_is_enabled(gd->fdt_blob, dev_of_offset(dev));
858 static inline int dev_read_resource(const struct udevice *dev, uint index,
859 struct resource *res)
861 return ofnode_read_resource(dev_ofnode(dev), index, res);
864 static inline int dev_read_resource_byname(const struct udevice *dev,
866 struct resource *res)
868 return ofnode_read_resource_byname(dev_ofnode(dev), name, res);
871 static inline u64 dev_translate_address(const struct udevice *dev,
872 const fdt32_t *in_addr)
874 return ofnode_translate_address(dev_ofnode(dev), in_addr);
877 static inline u64 dev_translate_dma_address(const struct udevice *dev,
878 const fdt32_t *in_addr)
880 return ofnode_translate_dma_address(dev_ofnode(dev), in_addr);
883 static inline int dev_read_alias_highest_id(const char *stem)
885 return fdtdec_get_alias_highest_id(gd->fdt_blob, stem);
888 #endif /* CONFIG_DM_DEV_READ_INLINE */
891 * dev_for_each_subnode() - Helper function to iterate through subnodes
893 * This creates a for() loop which works through the subnodes in a device's
896 * @subnode: ofnode holding the current subnode
897 * @dev: device to use for interation (struct udevice *)
899 #define dev_for_each_subnode(subnode, dev) \
900 for (subnode = dev_read_first_subnode(dev); \
901 ofnode_valid(subnode); \
902 subnode = ofnode_next_subnode(subnode))