Lines Matching +full:int +full:- +full:property

1 /* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */
5 * libfdt - Flat Device Tree manipulation
22 /* FDT_ERR_NOTFOUND: The requested node or property does not exist */
24 /* FDT_ERR_EXISTS: Attempted to create a node or property which
35 * offset which is out-of-bounds, or which points to an
43 * This can be caused either by an invalid phandle property
44 * length, or the phandle value was either 0 or -1, which are
48 * tree created by the sequential-write functions, which is
53 /* FDT_ERR_TRUNCATED: FDT or a sub-block is improperly
58 * device tree at all - it is missing the flattened device
63 * read-write functions, this may mean that fdt_open_into() is
70 /* FDT_ERR_BADLAYOUT: For read-write functions, the given
71 * device tree has it's sub-blocks in an order that the
74 * into a form suitable for the read-write operations. */
84 /* FDT_ERR_BADNCELLS: Device tree has a #address-cells, #size-cells
85 * or similar property with a bad format or value */
88 /* FDT_ERR_BADVALUE: Device tree has a property with an unexpected
89 * value. For example: a property expected to contain a string list
90 * is not NUL-terminated within the length of its value. */
95 * unexpected or missing value, property or node. */
106 /* FDT_ERR_ALIGNMENT: The device tree base address is not 8-byte
113 /* Valid values for phandles range from 1 to 2^32-2. */
116 /* Low-level functions (you probably don't need these) */
120 const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen);
122 static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen) in fdt_offset_ptr_w()
127 uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset);
151 static inline void fdt32_st(void *property, uint32_t value) in fdt32_st() argument
153 uint8_t *bp = (uint8_t *)property; in fdt32_st()
175 static inline void fdt64_st(void *property, uint64_t value) in fdt64_st() argument
177 uint8_t *bp = (uint8_t *)property; in fdt64_st()
193 int fdt_next_node(const void *fdt, int offset, int *depth);
196 * fdt_first_subnode() - get offset of first direct subnode
200 * Return: offset of first subnode, or -FDT_ERR_NOTFOUND if there is none
202 int fdt_first_subnode(const void *fdt, int offset);
205 * fdt_next_subnode() - get offset of next direct subnode
212 * Return: offset of next subnode, or -FDT_ERR_NOTFOUND if there are no more
215 int fdt_next_subnode(const void *fdt, int offset);
218 * fdt_for_each_subnode - iterate over all subnodes of a parent
220 * @node: child node (int, lvalue)
222 * @parent: parent node (int)
231 * if ((node < 0) && (node != -FDT_ERR_NOTFOUND)) {
248 (fdt32_ld(&((const struct fdt_header *)(fdt))->field))
264 fdth->name = cpu_to_fdt32(val); \
279 * fdt_header_size - return the size of the tree's header
287 * fdt_header_size_ - internal function to get header size from a version number
295 * fdt_check_header - sanity check a device tree header
305 * -FDT_ERR_BADMAGIC,
306 * -FDT_ERR_BADVERSION,
307 * -FDT_ERR_BADSTATE,
308 * -FDT_ERR_TRUNCATED, standard meanings, as above
310 int fdt_check_header(const void *fdt);
313 * fdt_move - move a device tree around in memory
326 * -FDT_ERR_NOSPACE, bufsize is insufficient to contain the device tree
327 * -FDT_ERR_BADMAGIC,
328 * -FDT_ERR_BADVERSION,
329 * -FDT_ERR_BADSTATE, standard meanings
331 int fdt_move(const void *fdt, void *buf, int bufsize);
334 /* Read-only functions */
337 int fdt_check_full(const void *fdt, size_t bufsize);
340 * fdt_get_string - retrieve a string from the strings block of a device tree
353 const char *fdt_get_string(const void *fdt, int stroffset, int *lenp);
356 * fdt_string - retrieve a string from the strings block of a device tree
367 const char *fdt_string(const void *fdt, int stroffset);
370 * fdt_find_max_phandle - find and return the highest phandle in a tree
381 int fdt_find_max_phandle(const void *fdt, uint32_t *phandle);
384 * fdt_get_max_phandle - retrieves the highest phandle in a tree
389 * with a value of 0 or -1.
396 * -1, if an error occurred
401 int err; in fdt_get_max_phandle()
405 return (uint32_t)-1; in fdt_get_max_phandle()
411 * fdt_generate_phandle - return a new, unused phandle for a device tree blob
420 * Return: 0 on success or a negative error-code on failure
422 int fdt_generate_phandle(const void *fdt, uint32_t *phandle);
425 * fdt_num_mem_rsv - retrieve the number of memory reserve map entries
435 int fdt_num_mem_rsv(const void *fdt);
438 * fdt_get_mem_rsv - retrieve one memory reserve map entry
441 * @address: pointer to 64-bit variable to hold the start address
442 * @size: pointer to 64-bit variable to hold the size of the entry
445 * the n-th reserve map entry from the device tree blob, in
446 * native-endian format.
450 * -FDT_ERR_BADMAGIC,
451 * -FDT_ERR_BADVERSION,
452 * -FDT_ERR_BADSTATE, standard meanings
454 int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size);
457 * fdt_subnode_offset_namelen - find a subnode based on substring
468 * Return: offset of the subnode or -FDT_ERR_NOTFOUND if name not found.
471 int fdt_subnode_offset_namelen(const void *fdt, int parentoffset,
472 const char *name, int namelen);
475 * fdt_subnode_offset - find a subnode of a given node
489 * -FDT_ERR_NOTFOUND, if the requested subnode does not exist
490 * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE
492 * -FDT_ERR_BADMAGIC,
493 * -FDT_ERR_BADVERSION,
494 * -FDT_ERR_BADSTATE,
495 * -FDT_ERR_BADSTRUCTURE,
496 * -FDT_ERR_TRUNCATED, standard meanings.
498 int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
501 * fdt_path_offset_namelen - find a tree node by its full path
512 int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen);
516 * fdt_path_offset - find a tree node by its full path
530 * -FDT_ERR_BADPATH, given path does not begin with '/' or is invalid
531 * -FDT_ERR_NOTFOUND, if the requested node does not exist
532 * -FDT_ERR_BADMAGIC,
533 * -FDT_ERR_BADVERSION,
534 * -FDT_ERR_BADSTATE,
535 * -FDT_ERR_BADSTRUCTURE,
536 * -FDT_ERR_TRUNCATED, standard meanings.
538 int fdt_path_offset(const void *fdt, const char *path);
541 * fdt_get_name - retrieve the name of a given node
548 * non-NULL, the length of this name is also returned, in the integer
553 * If lenp is non-NULL, *lenp contains the length of that name
556 * if lenp is non-NULL *lenp contains an error code (<0):
557 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE
559 * -FDT_ERR_BADMAGIC,
560 * -FDT_ERR_BADVERSION,
561 * -FDT_ERR_BADSTATE, standard meanings
563 const char *fdt_get_name(const void *fdt, int nodeoffset, int *lenp);
566 * fdt_first_property_offset - find the offset of a node's first property
570 * fdt_first_property_offset() finds the first property of the node at
574 * structure block offset of the property (>=0), on success
575 * -FDT_ERR_NOTFOUND, if the requested node has no properties
576 * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_BEGIN_NODE tag
577 * -FDT_ERR_BADMAGIC,
578 * -FDT_ERR_BADVERSION,
579 * -FDT_ERR_BADSTATE,
580 * -FDT_ERR_BADSTRUCTURE,
581 * -FDT_ERR_TRUNCATED, standard meanings.
583 int fdt_first_property_offset(const void *fdt, int nodeoffset);
586 * fdt_next_property_offset - step through a node's properties
588 * @offset: structure block offset of a property
590 * fdt_next_property_offset() finds the property immediately after the
591 * one at the given structure block offset. This will be a property
592 * of the same node as the given property.
595 * structure block offset of the next property (>=0), on success
596 * -FDT_ERR_NOTFOUND, if the given property is the last in its node
597 * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_PROP tag
598 * -FDT_ERR_BADMAGIC,
599 * -FDT_ERR_BADVERSION,
600 * -FDT_ERR_BADSTATE,
601 * -FDT_ERR_BADSTRUCTURE,
602 * -FDT_ERR_TRUNCATED, standard meanings.
604 int fdt_next_property_offset(const void *fdt, int offset);
607 * fdt_for_each_property_offset - iterate over all properties of a node
609 * @property: property offset (int, lvalue)
611 * @node: node offset (int)
615 * fdt_for_each_property_offset(property, fdt, node) {
616 * Use property
620 * if ((property < 0) && (property != -FDT_ERR_NOTFOUND)) {
624 * Note that this is implemented as a macro and property is used as
628 #define fdt_for_each_property_offset(property, fdt, node) \ argument
629 for (property = fdt_first_property_offset(fdt, node); \
630 property >= 0; \
631 property = fdt_next_property_offset(fdt, property))
634 * fdt_get_property_by_offset - retrieve the property at a given offset
636 * @offset: offset of the property to retrieve
641 * offset. If lenp is non-NULL, the length of the property value is
648 * pointer to the structure representing the property
649 * if lenp is non-NULL, *lenp contains the length of the property
652 * if lenp is non-NULL, *lenp contains an error code (<0):
653 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag
654 * -FDT_ERR_BADMAGIC,
655 * -FDT_ERR_BADVERSION,
656 * -FDT_ERR_BADSTATE,
657 * -FDT_ERR_BADSTRUCTURE,
658 * -FDT_ERR_TRUNCATED, standard meanings
661 int offset,
662 int *lenp);
665 * fdt_get_property_namelen - find a property based on substring
667 * @nodeoffset: offset of the node whose property to find
668 * @name: name of the property to find
673 * characters of name for matching the property name.
675 * Return: pointer to the structure representing the property, or NULL
680 int nodeoffset,
682 int namelen, int *lenp);
686 * fdt_get_property - find a given property in a given node
688 * @nodeoffset: offset of the node whose property to find
689 * @name: name of the property to find
693 * structure within the device tree blob corresponding to the property
695 * non-NULL, the length of the property value is also returned, in the
699 * pointer to the structure representing the property
700 * if lenp is non-NULL, *lenp contains the length of the property
703 * if lenp is non-NULL, *lenp contains an error code (<0):
704 * -FDT_ERR_NOTFOUND, node does not have named property
705 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE
707 * -FDT_ERR_BADMAGIC,
708 * -FDT_ERR_BADVERSION,
709 * -FDT_ERR_BADSTATE,
710 * -FDT_ERR_BADSTRUCTURE,
711 * -FDT_ERR_TRUNCATED, standard meanings
713 const struct fdt_property *fdt_get_property(const void *fdt, int nodeoffset,
714 const char *name, int *lenp);
715 static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset, in fdt_get_property_w()
717 int *lenp) in fdt_get_property_w()
724 * fdt_getprop_by_offset - retrieve the value of a property at a given offset
726 * @offset: offset of the property to read
731 * property at structure block offset 'offset' (this will be a pointer
733 * lenp is non-NULL, the length of the property value is also
734 * returned, in the integer pointed to by lenp. If namep is non-NULL,
735 * the property's namne will also be returned in the char * pointed to
740 * pointer to the property's value
741 * if lenp is non-NULL, *lenp contains the length of the property
743 * if namep is non-NULL *namep contiains a pointer to the property
746 * if lenp is non-NULL, *lenp contains an error code (<0):
747 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag
748 * -FDT_ERR_BADMAGIC,
749 * -FDT_ERR_BADVERSION,
750 * -FDT_ERR_BADSTATE,
751 * -FDT_ERR_BADSTRUCTURE,
752 * -FDT_ERR_TRUNCATED, standard meanings
755 const void *fdt_getprop_by_offset(const void *fdt, int offset,
756 const char **namep, int *lenp);
760 * fdt_getprop_namelen - get property value based on substring
762 * @nodeoffset: offset of the node whose property to find
763 * @name: name of the property to find
768 * characters of name for matching the property name.
770 * Return: pointer to the property's value or NULL on error
773 const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
774 const char *name, int namelen, int *lenp);
775 static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset, in fdt_getprop_namelen_w()
776 const char *name, int namelen, in fdt_getprop_namelen_w()
777 int *lenp) in fdt_getprop_namelen_w()
785 * fdt_getprop - retrieve the value of a given property
787 * @nodeoffset: offset of the node whose property to find
788 * @name: name of the property to find
791 * fdt_getprop() retrieves a pointer to the value of the property
794 * If @lenp is non-NULL, the length of the property value is also
798 * pointer to the property's value
799 * if lenp is non-NULL, *lenp contains the length of the property
802 * if lenp is non-NULL, *lenp contains an error code (<0):
803 * -FDT_ERR_NOTFOUND, node does not have named property
804 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE
806 * -FDT_ERR_BADMAGIC,
807 * -FDT_ERR_BADVERSION,
808 * -FDT_ERR_BADSTATE,
809 * -FDT_ERR_BADSTRUCTURE,
810 * -FDT_ERR_TRUNCATED, standard meanings
812 const void *fdt_getprop(const void *fdt, int nodeoffset,
813 const char *name, int *lenp);
814 static inline void *fdt_getprop_w(void *fdt, int nodeoffset, in fdt_getprop_w()
815 const char *name, int *lenp) in fdt_getprop_w()
821 * fdt_get_phandle - retrieve the phandle of a given node
829 * the phandle of the node at nodeoffset, on success (!= 0, != -1)
832 uint32_t fdt_get_phandle(const void *fdt, int nodeoffset);
835 * fdt_get_alias_namelen - get alias based on substring
848 const char *name, int namelen);
852 * fdt_get_alias - retrieve the path referenced by a given alias
857 * value of the property named @name in the node /aliases.
866 * fdt_get_path - determine the full path of a node
881 * nodeoffset, as a NUL-terminated string.
882 * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
883 * -FDT_ERR_NOSPACE, the path of the given node is longer than (bufsize-1)
885 * -FDT_ERR_BADMAGIC,
886 * -FDT_ERR_BADVERSION,
887 * -FDT_ERR_BADSTATE,
888 * -FDT_ERR_BADSTRUCTURE, standard meanings
890 int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen);
893 * fdt_supernode_atdepth_offset - find a specific ancestor of a node
914 * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
915 * -FDT_ERR_NOTFOUND, supernodedepth was greater than the depth of
917 * -FDT_ERR_BADMAGIC,
918 * -FDT_ERR_BADVERSION,
919 * -FDT_ERR_BADSTATE,
920 * -FDT_ERR_BADSTRUCTURE, standard meanings
922 int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset,
923 int supernodedepth, int *nodedepth);
926 * fdt_node_depth - find the depth of a given node
938 * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
939 * -FDT_ERR_BADMAGIC,
940 * -FDT_ERR_BADVERSION,
941 * -FDT_ERR_BADSTATE,
942 * -FDT_ERR_BADSTRUCTURE, standard meanings
944 int fdt_node_depth(const void *fdt, int nodeoffset);
947 * fdt_parent_offset - find the parent of a given node
961 * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
962 * -FDT_ERR_BADMAGIC,
963 * -FDT_ERR_BADVERSION,
964 * -FDT_ERR_BADSTATE,
965 * -FDT_ERR_BADSTRUCTURE, standard meanings
967 int fdt_parent_offset(const void *fdt, int nodeoffset);
970 * fdt_node_offset_by_prop_value - find nodes with a given property value
973 * @propname: property name to check
974 * @propval: property value to search for
978 * node after startoffset, which has a property named propname whose
980 * startoffset is -1, the very first such node in the tree.
984 * offset = fdt_node_offset_by_prop_value(fdt, -1, propname,
986 * while (offset != -FDT_ERR_NOTFOUND) {
992 * Note the -1 in the first call to the function, if 0 is used here
999 * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the
1001 * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
1002 * -FDT_ERR_BADMAGIC,
1003 * -FDT_ERR_BADVERSION,
1004 * -FDT_ERR_BADSTATE,
1005 * -FDT_ERR_BADSTRUCTURE, standard meanings
1007 int fdt_node_offset_by_prop_value(const void *fdt, int startoffset,
1009 const void *propval, int proplen);
1012 * fdt_node_offset_by_phandle - find the node with a given phandle
1023 * -FDT_ERR_NOTFOUND, no node with that phandle exists
1024 * -FDT_ERR_BADPHANDLE, given phandle value was invalid (0 or -1)
1025 * -FDT_ERR_BADMAGIC,
1026 * -FDT_ERR_BADVERSION,
1027 * -FDT_ERR_BADSTATE,
1028 * -FDT_ERR_BADSTRUCTURE, standard meanings
1030 int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle);
1033 * fdt_node_check_compatible - check a node's compatible property
1039 * @compatible property with the given string as one of its elements,
1040 * it returns non-zero otherwise, or on error.
1043 * 0, if the node has a 'compatible' property listing the given string
1044 * 1, if the node has a 'compatible' property, but it does not list
1046 * -FDT_ERR_NOTFOUND, if the given node has no 'compatible' property
1047 * -FDT_ERR_BADOFFSET, if nodeoffset does not refer to a BEGIN_NODE tag
1048 * -FDT_ERR_BADMAGIC,
1049 * -FDT_ERR_BADVERSION,
1050 * -FDT_ERR_BADSTATE,
1051 * -FDT_ERR_BADSTRUCTURE, standard meanings
1053 int fdt_node_check_compatible(const void *fdt, int nodeoffset,
1057 * fdt_node_offset_by_compatible - find nodes with a given 'compatible' value
1063 * node after startoffset, which has a 'compatible' property which
1064 * lists the given compatible string; or if startoffset is -1, the
1069 * offset = fdt_node_offset_by_compatible(fdt, -1, compatible);
1070 * while (offset != -FDT_ERR_NOTFOUND) {
1075 * Note the -1 in the first call to the function, if 0 is used here
1082 * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the
1084 * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
1085 * -FDT_ERR_BADMAGIC,
1086 * -FDT_ERR_BADVERSION,
1087 * -FDT_ERR_BADSTATE,
1088 * -FDT_ERR_BADSTRUCTURE, standard meanings
1090 int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
1094 * fdt_stringlist_contains - check a string list property for a string
1095 * @strlist: Property containing a list of strings to check
1096 * @listlen: Length of property
1101 * "compatible" property.
1105 int fdt_stringlist_contains(const char *strlist, int listlen, const char *str);
1108 * fdt_stringlist_count - count the number of strings in a string list
1111 * @property: name of the property containing the string list
1114 * the number of strings in the given property
1115 * -FDT_ERR_BADVALUE if the property value is not NUL-terminated
1116 * -FDT_ERR_NOTFOUND if the property does not exist
1118 int fdt_stringlist_count(const void *fdt, int nodeoffset, const char *property);
1121 * fdt_stringlist_search - find a string in a string list and return its index
1124 * @property: name of the property containing the string list
1127 * Note that it is possible for this function to succeed on property values
1128 * that are not NUL-terminated. That's because the function will stop after
1130 * small-valued cell properties, such as #address-cells, when searching for
1135 * -FDT_ERR_BADVALUE if the property value is not NUL-terminated
1136 * -FDT_ERR_NOTFOUND if the property does not exist or does not contain
1139 int fdt_stringlist_search(const void *fdt, int nodeoffset, const char *property,
1143 * fdt_stringlist_get() - obtain the string at a given index in a string list
1146 * @property: name of the property containing the string list
1151 * non-NUL-terminated values. For example on small-valued cell properties
1154 * If non-NULL, the length of the string (on success) or a negative error-code
1160 * location pointed to by the lenp parameter, if non-NULL. On failure one of
1162 * (if non-NULL):
1163 * -FDT_ERR_BADVALUE if the property value is not NUL-terminated
1164 * -FDT_ERR_NOTFOUND if the property does not exist
1166 const char *fdt_stringlist_get(const void *fdt, int nodeoffset,
1167 const char *property, int index,
1168 int *lenp);
1171 /* Read-only functions (addressing related) */
1175 * FDT_MAX_NCELLS - maximum value for #address-cells and #size-cells
1177 * This is the maximum value for #address-cells, #size-cells and
1186 * fdt_address_cells - retrieve address size for a bus represented in the tree
1190 * When the node has a valid #address-cells property, returns its value.
1194 * 2, if the node has no #address-cells property
1195 * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid
1196 * #address-cells property
1197 * -FDT_ERR_BADMAGIC,
1198 * -FDT_ERR_BADVERSION,
1199 * -FDT_ERR_BADSTATE,
1200 * -FDT_ERR_BADSTRUCTURE,
1201 * -FDT_ERR_TRUNCATED, standard meanings
1203 int fdt_address_cells(const void *fdt, int nodeoffset);
1206 * fdt_size_cells - retrieve address range size for a bus represented in the
1211 * When the node has a valid #size-cells property, returns its value.
1215 * 1, if the node has no #size-cells property
1216 * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid
1217 * #size-cells property
1218 * -FDT_ERR_BADMAGIC,
1219 * -FDT_ERR_BADVERSION,
1220 * -FDT_ERR_BADSTATE,
1221 * -FDT_ERR_BADSTRUCTURE,
1222 * -FDT_ERR_TRUNCATED, standard meanings
1224 int fdt_size_cells(const void *fdt, int nodeoffset);
1228 /* Write-in-place functions */
1232 * fdt_setprop_inplace_namelen_partial - change a property's value,
1235 * @nodeoffset: offset of the node whose property to change
1236 * @name: name of the property to change
1238 * @idx: index of the property to change in the array
1239 * @val: pointer to data to replace the property value with
1240 * @len: length of the property value
1242 * Identical to fdt_setprop_inplace(), but modifies the given property
1250 int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
1251 const char *name, int namelen,
1253 int len);
1257 * fdt_setprop_inplace - change a property's value, but not its size
1259 * @nodeoffset: offset of the node whose property to change
1260 * @name: name of the property to change
1261 * @val: pointer to data to replace the property value with
1262 * @len: length of the property value
1264 * fdt_setprop_inplace() replaces the value of a given property with
1266 * size of a property, and so will only work if len is equal to the
1267 * current length of the property.
1270 * the given property value, and will not alter or move any other part
1275 * -FDT_ERR_NOSPACE, if len is not equal to the property's current length
1276 * -FDT_ERR_NOTFOUND, node does not have the named property
1277 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1278 * -FDT_ERR_BADMAGIC,
1279 * -FDT_ERR_BADVERSION,
1280 * -FDT_ERR_BADSTATE,
1281 * -FDT_ERR_BADSTRUCTURE,
1282 * -FDT_ERR_TRUNCATED, standard meanings
1285 int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
1286 const void *val, int len);
1290 * fdt_setprop_inplace_u32 - change the value of a 32-bit integer property
1292 * @nodeoffset: offset of the node whose property to change
1293 * @name: name of the property to change
1294 * @val: 32-bit integer value to replace the property with
1296 * fdt_setprop_inplace_u32() replaces the value of a given property
1297 * with the 32-bit integer value in val, converting val to big-endian
1298 * if necessary. This function cannot change the size of a property,
1299 * and so will only work if the property already exists and has length
1303 * the given property value, and will not alter or move any other part
1308 * -FDT_ERR_NOSPACE, if the property's length is not equal to 4
1309 * -FDT_ERR_NOTFOUND, node does not have the named property
1310 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1311 * -FDT_ERR_BADMAGIC,
1312 * -FDT_ERR_BADVERSION,
1313 * -FDT_ERR_BADSTATE,
1314 * -FDT_ERR_BADSTRUCTURE,
1315 * -FDT_ERR_TRUNCATED, standard meanings
1317 static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset, in fdt_setprop_inplace_u32()
1325 * fdt_setprop_inplace_u64 - change the value of a 64-bit integer property
1327 * @nodeoffset: offset of the node whose property to change
1328 * @name: name of the property to change
1329 * @val: 64-bit integer value to replace the property with
1331 * fdt_setprop_inplace_u64() replaces the value of a given property
1332 * with the 64-bit integer value in val, converting val to big-endian
1333 * if necessary. This function cannot change the size of a property,
1334 * and so will only work if the property already exists and has length
1338 * the given property value, and will not alter or move any other part
1343 * -FDT_ERR_NOSPACE, if the property's length is not equal to 8
1344 * -FDT_ERR_NOTFOUND, node does not have the named property
1345 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1346 * -FDT_ERR_BADMAGIC,
1347 * -FDT_ERR_BADVERSION,
1348 * -FDT_ERR_BADSTATE,
1349 * -FDT_ERR_BADSTRUCTURE,
1350 * -FDT_ERR_TRUNCATED, standard meanings
1352 static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset, in fdt_setprop_inplace_u64()
1360 * fdt_setprop_inplace_cell - change the value of a single-cell property
1362 * @nodeoffset: offset of the node containing the property
1363 * @name: name of the property to change the value of
1364 * @val: new value of the 32-bit cell
1369 static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset, in fdt_setprop_inplace_cell()
1376 * fdt_nop_property - replace a property with nop tags
1378 * @nodeoffset: offset of the node whose property to nop
1379 * @name: name of the property to nop
1381 * fdt_nop_property() will replace a given property's representation
1386 * the property, and will not alter or move any other part of the
1391 * -FDT_ERR_NOTFOUND, node does not have the named property
1392 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1393 * -FDT_ERR_BADMAGIC,
1394 * -FDT_ERR_BADVERSION,
1395 * -FDT_ERR_BADSTATE,
1396 * -FDT_ERR_BADSTRUCTURE,
1397 * -FDT_ERR_TRUNCATED, standard meanings
1399 int fdt_nop_property(void *fdt, int nodeoffset, const char *name);
1402 * fdt_nop_node - replace a node (subtree) with nop tags
1416 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1417 * -FDT_ERR_BADMAGIC,
1418 * -FDT_ERR_BADVERSION,
1419 * -FDT_ERR_BADSTATE,
1420 * -FDT_ERR_BADSTRUCTURE,
1421 * -FDT_ERR_TRUNCATED, standard meanings
1423 int fdt_nop_node(void *fdt, int nodeoffset);
1431 /* FDT_CREATE_FLAG_NO_NAME_DEDUP: Do not try to de-duplicate property
1438 * fdt_create_with_flags - begin creation of a new fdt
1450 * -FDT_ERR_NOSPACE, bufsize is insufficient for a minimal fdt
1451 * -FDT_ERR_BADFLAGS, flags is not valid
1453 int fdt_create_with_flags(void *buf, int bufsize, uint32_t flags);
1456 * fdt_create - begin creation of a new fdt
1464 * -FDT_ERR_NOSPACE, bufsize is insufficient for a minimal fdt
1466 int fdt_create(void *buf, int bufsize);
1468 int fdt_resize(void *fdt, void *buf, int bufsize);
1469 int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size);
1470 int fdt_finish_reservemap(void *fdt);
1471 int fdt_begin_node(void *fdt, const char *name);
1472 int fdt_property(void *fdt, const char *name, const void *val, int len);
1473 static inline int fdt_property_u32(void *fdt, const char *name, uint32_t val) in fdt_property_u32()
1478 static inline int fdt_property_u64(void *fdt, const char *name, uint64_t val) in fdt_property_u64()
1485 static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val) in fdt_property_cell()
1492 * fdt_property_placeholder - add a new property and return a ptr to its value
1495 * @name: name of property to add
1496 * @len: length of property value in bytes
1501 * -FDT_ERR_BADMAGIC,
1502 * -FDT_ERR_NOSPACE, standard meanings
1504 int fdt_property_placeholder(void *fdt, const char *name, int len, void **valp);
1508 int fdt_end_node(void *fdt);
1509 int fdt_finish(void *fdt);
1512 /* Read-write functions */
1515 int fdt_create_empty_tree(void *buf, int bufsize);
1516 int fdt_open_into(const void *fdt, void *buf, int bufsize);
1517 int fdt_pack(void *fdt);
1520 * fdt_add_mem_rsv - add one memory reserve map entry
1522 * @address: 64-bit start address of the reserve map entry
1523 * @size: 64-bit size of the reserved region
1533 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
1535 * -FDT_ERR_BADMAGIC,
1536 * -FDT_ERR_BADVERSION,
1537 * -FDT_ERR_BADSTATE,
1538 * -FDT_ERR_BADSTRUCTURE,
1539 * -FDT_ERR_BADLAYOUT,
1540 * -FDT_ERR_TRUNCATED, standard meanings
1542 int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size);
1545 * fdt_del_mem_rsv - remove a memory reserve map entry
1549 * fdt_del_mem_rsv() removes the n-th memory reserve map entry from
1557 * -FDT_ERR_NOTFOUND, there is no entry of the given index (i.e. there
1559 * -FDT_ERR_BADMAGIC,
1560 * -FDT_ERR_BADVERSION,
1561 * -FDT_ERR_BADSTATE,
1562 * -FDT_ERR_BADSTRUCTURE,
1563 * -FDT_ERR_BADLAYOUT,
1564 * -FDT_ERR_TRUNCATED, standard meanings
1566 int fdt_del_mem_rsv(void *fdt, int n);
1569 * fdt_set_name - change the name of a given node
1585 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob
1587 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1588 * -FDT_ERR_BADMAGIC,
1589 * -FDT_ERR_BADVERSION,
1590 * -FDT_ERR_BADSTATE, standard meanings
1592 int fdt_set_name(void *fdt, int nodeoffset, const char *name);
1595 * fdt_setprop - create or change a property
1597 * @nodeoffset: offset of the node whose property to change
1598 * @name: name of the property to change
1599 * @val: pointer to data to set the property value to
1600 * @len: length of the property value
1602 * fdt_setprop() sets the value of the named property in the given
1603 * node to the given value and length, creating the property if it
1611 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
1612 * contain the new property value
1613 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1614 * -FDT_ERR_BADLAYOUT,
1615 * -FDT_ERR_BADMAGIC,
1616 * -FDT_ERR_BADVERSION,
1617 * -FDT_ERR_BADSTATE,
1618 * -FDT_ERR_BADSTRUCTURE,
1619 * -FDT_ERR_BADLAYOUT,
1620 * -FDT_ERR_TRUNCATED, standard meanings
1622 int fdt_setprop(void *fdt, int nodeoffset, const char *name,
1623 const void *val, int len);
1626 * fdt_setprop_placeholder - allocate space for a property
1628 * @nodeoffset: offset of the node whose property to change
1629 * @name: name of the property to change
1630 * @len: length of the property value
1631 * @prop_data: return pointer to property data
1633 * fdt_setprop_placeholer() allocates the named property in the given node.
1634 * If the property exists it is resized. In either case a pointer to the
1635 * property data is returned.
1642 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
1643 * contain the new property value
1644 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1645 * -FDT_ERR_BADLAYOUT,
1646 * -FDT_ERR_BADMAGIC,
1647 * -FDT_ERR_BADVERSION,
1648 * -FDT_ERR_BADSTATE,
1649 * -FDT_ERR_BADSTRUCTURE,
1650 * -FDT_ERR_BADLAYOUT,
1651 * -FDT_ERR_TRUNCATED, standard meanings
1653 int fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name,
1654 int len, void **prop_data);
1657 * fdt_setprop_u32 - set a property to a 32-bit integer
1659 * @nodeoffset: offset of the node whose property to change
1660 * @name: name of the property to change
1661 * @val: 32-bit integer value for the property (native endian)
1663 * fdt_setprop_u32() sets the value of the named property in the given
1664 * node to the given 32-bit integer value (converting to big-endian if
1665 * necessary), or creates a new property with that value if it does
1673 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
1674 * contain the new property value
1675 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1676 * -FDT_ERR_BADLAYOUT,
1677 * -FDT_ERR_BADMAGIC,
1678 * -FDT_ERR_BADVERSION,
1679 * -FDT_ERR_BADSTATE,
1680 * -FDT_ERR_BADSTRUCTURE,
1681 * -FDT_ERR_BADLAYOUT,
1682 * -FDT_ERR_TRUNCATED, standard meanings
1684 static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name, in fdt_setprop_u32()
1692 * fdt_setprop_u64 - set a property to a 64-bit integer
1694 * @nodeoffset: offset of the node whose property to change
1695 * @name: name of the property to change
1696 * @val: 64-bit integer value for the property (native endian)
1698 * fdt_setprop_u64() sets the value of the named property in the given
1699 * node to the given 64-bit integer value (converting to big-endian if
1700 * necessary), or creates a new property with that value if it does
1708 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
1709 * contain the new property value
1710 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1711 * -FDT_ERR_BADLAYOUT,
1712 * -FDT_ERR_BADMAGIC,
1713 * -FDT_ERR_BADVERSION,
1714 * -FDT_ERR_BADSTATE,
1715 * -FDT_ERR_BADSTRUCTURE,
1716 * -FDT_ERR_BADLAYOUT,
1717 * -FDT_ERR_TRUNCATED, standard meanings
1719 static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name, in fdt_setprop_u64()
1727 * fdt_setprop_cell - set a property to a single cell value
1729 * @nodeoffset: offset of the node whose property to change
1730 * @name: name of the property to change
1731 * @val: 32-bit integer value for the property (native endian)
1737 static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name, in fdt_setprop_cell()
1744 * fdt_setprop_string - set a property to a string value
1746 * @nodeoffset: offset of the node whose property to change
1747 * @name: name of the property to change
1748 * @str: string value for the property
1750 * fdt_setprop_string() sets the value of the named property in the
1752 * string to determine the new length of the property), or creates a
1753 * new property with that value if it does not already exist.
1760 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
1761 * contain the new property value
1762 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1763 * -FDT_ERR_BADLAYOUT,
1764 * -FDT_ERR_BADMAGIC,
1765 * -FDT_ERR_BADVERSION,
1766 * -FDT_ERR_BADSTATE,
1767 * -FDT_ERR_BADSTRUCTURE,
1768 * -FDT_ERR_BADLAYOUT,
1769 * -FDT_ERR_TRUNCATED, standard meanings
1776 * fdt_setprop_empty - set a property to an empty value
1778 * @nodeoffset: offset of the node whose property to change
1779 * @name: name of the property to change
1781 * fdt_setprop_empty() sets the value of the named property in the
1783 * property if it does not already exist.
1790 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
1791 * contain the new property value
1792 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1793 * -FDT_ERR_BADLAYOUT,
1794 * -FDT_ERR_BADMAGIC,
1795 * -FDT_ERR_BADVERSION,
1796 * -FDT_ERR_BADSTATE,
1797 * -FDT_ERR_BADSTRUCTURE,
1798 * -FDT_ERR_BADLAYOUT,
1799 * -FDT_ERR_TRUNCATED, standard meanings
1805 * fdt_appendprop - append to or create a property
1807 * @nodeoffset: offset of the node whose property to change
1808 * @name: name of the property to append to
1809 * @val: pointer to data to append to the property value
1810 * @len: length of the data to append to the property value
1812 * fdt_appendprop() appends the value to the named property in the
1813 * given node, creating the property if it does not already exist.
1820 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
1821 * contain the new property value
1822 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1823 * -FDT_ERR_BADLAYOUT,
1824 * -FDT_ERR_BADMAGIC,
1825 * -FDT_ERR_BADVERSION,
1826 * -FDT_ERR_BADSTATE,
1827 * -FDT_ERR_BADSTRUCTURE,
1828 * -FDT_ERR_BADLAYOUT,
1829 * -FDT_ERR_TRUNCATED, standard meanings
1831 int fdt_appendprop(void *fdt, int nodeoffset, const char *name,
1832 const void *val, int len);
1835 * fdt_appendprop_u32 - append a 32-bit integer value to a property
1837 * @nodeoffset: offset of the node whose property to change
1838 * @name: name of the property to change
1839 * @val: 32-bit integer value to append to the property (native endian)
1841 * fdt_appendprop_u32() appends the given 32-bit integer value
1842 * (converting to big-endian if necessary) to the value of the named
1843 * property in the given node, or creates a new property with that
1851 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
1852 * contain the new property value
1853 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1854 * -FDT_ERR_BADLAYOUT,
1855 * -FDT_ERR_BADMAGIC,
1856 * -FDT_ERR_BADVERSION,
1857 * -FDT_ERR_BADSTATE,
1858 * -FDT_ERR_BADSTRUCTURE,
1859 * -FDT_ERR_BADLAYOUT,
1860 * -FDT_ERR_TRUNCATED, standard meanings
1862 static inline int fdt_appendprop_u32(void *fdt, int nodeoffset, in fdt_appendprop_u32()
1870 * fdt_appendprop_u64 - append a 64-bit integer value to a property
1872 * @nodeoffset: offset of the node whose property to change
1873 * @name: name of the property to change
1874 * @val: 64-bit integer value to append to the property (native endian)
1876 * fdt_appendprop_u64() appends the given 64-bit integer value
1877 * (converting to big-endian if necessary) to the value of the named
1878 * property in the given node, or creates a new property with that
1886 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
1887 * contain the new property value
1888 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1889 * -FDT_ERR_BADLAYOUT,
1890 * -FDT_ERR_BADMAGIC,
1891 * -FDT_ERR_BADVERSION,
1892 * -FDT_ERR_BADSTATE,
1893 * -FDT_ERR_BADSTRUCTURE,
1894 * -FDT_ERR_BADLAYOUT,
1895 * -FDT_ERR_TRUNCATED, standard meanings
1897 static inline int fdt_appendprop_u64(void *fdt, int nodeoffset, in fdt_appendprop_u64()
1905 * fdt_appendprop_cell - append a single cell value to a property
1907 * @nodeoffset: offset of the node whose property to change
1908 * @name: name of the property to change
1909 * @val: 32-bit integer value to append to the property (native endian)
1915 static inline int fdt_appendprop_cell(void *fdt, int nodeoffset, in fdt_appendprop_cell()
1922 * fdt_appendprop_string - append a string to a property
1924 * @nodeoffset: offset of the node whose property to change
1925 * @name: name of the property to change
1926 * @str: string value to append to the property
1929 * the named property in the given node, or creates a new property
1937 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
1938 * contain the new property value
1939 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1940 * -FDT_ERR_BADLAYOUT,
1941 * -FDT_ERR_BADMAGIC,
1942 * -FDT_ERR_BADVERSION,
1943 * -FDT_ERR_BADSTATE,
1944 * -FDT_ERR_BADSTRUCTURE,
1945 * -FDT_ERR_BADLAYOUT,
1946 * -FDT_ERR_TRUNCATED, standard meanings
1952 * fdt_appendprop_addrrange - append a address range property
1955 * @nodeoffset: offset of the node to add a property at
1956 * @name: name of property
1961 * address and size) to the value of the named property in the given
1962 * node, or creates a new property with that value if it does not
1965 * Cell sizes are determined by parent's #address-cells and #size-cells.
1972 * -FDT_ERR_BADLAYOUT,
1973 * -FDT_ERR_BADMAGIC,
1974 * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid
1975 * #address-cells property
1976 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1977 * -FDT_ERR_BADSTATE,
1978 * -FDT_ERR_BADSTRUCTURE,
1979 * -FDT_ERR_BADVERSION,
1980 * -FDT_ERR_BADVALUE, addr or size doesn't fit to respective cells size
1981 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
1982 * contain a new property
1983 * -FDT_ERR_TRUNCATED, standard meanings
1985 int fdt_appendprop_addrrange(void *fdt, int parent, int nodeoffset,
1989 * fdt_delprop - delete a property
1991 * @nodeoffset: offset of the node whose property to nop
1992 * @name: name of the property to nop
1994 * fdt_del_property() will delete the given property.
2001 * -FDT_ERR_NOTFOUND, node does not have the named property
2002 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
2003 * -FDT_ERR_BADLAYOUT,
2004 * -FDT_ERR_BADMAGIC,
2005 * -FDT_ERR_BADVERSION,
2006 * -FDT_ERR_BADSTATE,
2007 * -FDT_ERR_BADSTRUCTURE,
2008 * -FDT_ERR_TRUNCATED, standard meanings
2010 int fdt_delprop(void *fdt, int nodeoffset, const char *name);
2013 * fdt_add_subnode_namelen - creates a new node based on substring
2028 int fdt_add_subnode_namelen(void *fdt, int parentoffset,
2029 const char *name, int namelen);
2033 * fdt_add_subnode - creates a new node
2048 * -FDT_ERR_NOTFOUND, if the requested subnode does not exist
2049 * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE
2051 * -FDT_ERR_EXISTS, if the node at parentoffset already has a subnode of
2053 * -FDT_ERR_NOSPACE, if there is insufficient free space in the
2055 * -FDT_ERR_NOSPACE
2056 * -FDT_ERR_BADLAYOUT
2057 * -FDT_ERR_BADMAGIC,
2058 * -FDT_ERR_BADVERSION,
2059 * -FDT_ERR_BADSTATE,
2060 * -FDT_ERR_BADSTRUCTURE,
2061 * -FDT_ERR_TRUNCATED, standard meanings.
2063 int fdt_add_subnode(void *fdt, int parentoffset, const char *name);
2066 * fdt_del_node - delete a node (subtree)
2078 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
2079 * -FDT_ERR_BADLAYOUT,
2080 * -FDT_ERR_BADMAGIC,
2081 * -FDT_ERR_BADVERSION,
2082 * -FDT_ERR_BADSTATE,
2083 * -FDT_ERR_BADSTRUCTURE,
2084 * -FDT_ERR_TRUNCATED, standard meanings
2086 int fdt_del_node(void *fdt, int nodeoffset);
2089 * fdt_overlay_apply - Applies a DT overlay on a base DT
2101 * -FDT_ERR_NOSPACE, there's not enough space in the base device tree
2102 * -FDT_ERR_NOTFOUND, the overlay points to some inexistant nodes or
2104 * -FDT_ERR_BADPHANDLE,
2105 * -FDT_ERR_BADOVERLAY,
2106 * -FDT_ERR_NOPHANDLES,
2107 * -FDT_ERR_INTERNAL,
2108 * -FDT_ERR_BADLAYOUT,
2109 * -FDT_ERR_BADMAGIC,
2110 * -FDT_ERR_BADOFFSET,
2111 * -FDT_ERR_BADPATH,
2112 * -FDT_ERR_BADVERSION,
2113 * -FDT_ERR_BADSTRUCTURE,
2114 * -FDT_ERR_BADSTATE,
2115 * -FDT_ERR_TRUNCATED, standard meanings
2117 int fdt_overlay_apply(void *fdt, void *fdto);
2123 const char *fdt_strerror(int errval);