Lines Matching defs:fdt

31 #include <fdt.h>
37 static int _fdt_nodename_eq(const void *fdt, int offset,
40 const char *p = fdt_offset_ptr(fdt, offset + FDT_TAGSIZE, len+1);
57 const char *fdt_string(const void *fdt, int stroffset)
59 return (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset;
62 static int _fdt_string_eq(const void *fdt, int stroffset,
65 const char *p = fdt_string(fdt, stroffset);
70 int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
72 FDT_CHECK_HEADER(fdt);
73 *address = fdt64_to_cpu(_fdt_mem_rsv(fdt, n)->address);
74 *size = fdt64_to_cpu(_fdt_mem_rsv(fdt, n)->size);
78 int fdt_num_mem_rsv(const void *fdt)
82 while (fdt64_to_cpu(_fdt_mem_rsv(fdt, i)->size) != 0)
87 static int _nextprop(const void *fdt, int offset)
93 tag = fdt_next_tag(fdt, offset, &nextoffset);
111 int fdt_subnode_offset_namelen(const void *fdt, int offset,
116 FDT_CHECK_HEADER(fdt);
120 offset = fdt_next_node(fdt, offset, &depth))
122 && _fdt_nodename_eq(fdt, offset, name, namelen))
130 int fdt_subnode_offset(const void *fdt, int parentoffset,
133 return fdt_subnode_offset_namelen(fdt, parentoffset, name, strlen(name));
136 int fdt_path_offset(const void *fdt, const char *path)
142 FDT_CHECK_HEADER(fdt);
151 p = fdt_get_alias_namelen(fdt, p, q - p);
154 offset = fdt_path_offset(fdt, p);
170 offset = fdt_subnode_offset_namelen(fdt, offset, p, q-p);
180 const char *fdt_get_name(const void *fdt, int nodeoffset, int *len)
182 const struct fdt_node_header *nh = _fdt_offset_ptr(fdt, nodeoffset);
185 if (((err = fdt_check_header(fdt)) != 0)
186 || ((err = _fdt_check_node_offset(fdt, nodeoffset)) < 0))
200 int fdt_first_property_offset(const void *fdt, int nodeoffset)
204 if ((offset = _fdt_check_node_offset(fdt, nodeoffset)) < 0)
207 return _nextprop(fdt, offset);
210 int fdt_next_property_offset(const void *fdt, int offset)
212 if ((offset = _fdt_check_prop_offset(fdt, offset)) < 0)
215 return _nextprop(fdt, offset);
218 const struct fdt_property *fdt_get_property_by_offset(const void *fdt,
225 if ((err = _fdt_check_prop_offset(fdt, offset)) < 0) {
231 prop = _fdt_offset_ptr(fdt, offset);
239 const struct fdt_property *fdt_get_property_namelen(const void *fdt,
244 for (offset = fdt_first_property_offset(fdt, offset);
246 (offset = fdt_next_property_offset(fdt, offset))) {
249 if (!(prop = fdt_get_property_by_offset(fdt, offset, lenp))) {
253 if (_fdt_string_eq(fdt, fdt32_to_cpu(prop->nameoff),
263 const struct fdt_property *fdt_get_property(const void *fdt,
267 return fdt_get_property_namelen(fdt, nodeoffset, name,
271 const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
276 prop = fdt_get_property_namelen(fdt, nodeoffset, name, namelen, lenp);
283 const void *fdt_getprop_by_offset(const void *fdt, int offset,
288 prop = fdt_get_property_by_offset(fdt, offset, lenp);
292 *namep = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
296 const void *fdt_getprop(const void *fdt, int nodeoffset,
299 return fdt_getprop_namelen(fdt, nodeoffset, name, strlen(name), lenp);
302 uint32_t fdt_get_phandle(const void *fdt, int nodeoffset)
309 php = fdt_getprop(fdt, nodeoffset, "phandle", &len);
311 php = fdt_getprop(fdt, nodeoffset, "linux,phandle", &len);
319 const char *fdt_get_alias_namelen(const void *fdt,
324 aliasoffset = fdt_path_offset(fdt, "/aliases");
328 return fdt_getprop_namelen(fdt, aliasoffset, name, namelen, NULL);
331 const char *fdt_get_alias(const void *fdt, const char *name)
333 return fdt_get_alias_namelen(fdt, name, strlen(name));
336 int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen)
342 FDT_CHECK_HEADER(fdt);
349 offset = fdt_next_node(fdt, offset, &depth)) {
358 name = fdt_get_name(fdt, offset, &namelen);
388 int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset,
394 FDT_CHECK_HEADER(fdt);
401 offset = fdt_next_node(fdt, offset, &depth)) {
424 int fdt_node_depth(const void *fdt, int nodeoffset)
429 err = fdt_supernode_atdepth_offset(fdt, nodeoffset, 0, &nodedepth);
435 int fdt_parent_offset(const void *fdt, int nodeoffset)
437 int nodedepth = fdt_node_depth(fdt, nodeoffset);
441 return fdt_supernode_atdepth_offset(fdt, nodeoffset,
445 int fdt_node_offset_by_prop_value(const void *fdt, int startoffset,
453 FDT_CHECK_HEADER(fdt);
460 for (offset = fdt_next_node(fdt, startoffset, NULL);
462 offset = fdt_next_node(fdt, offset, NULL)) {
463 val = fdt_getprop(fdt, offset, propname, &len);
472 int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle)
479 FDT_CHECK_HEADER(fdt);
487 for (offset = fdt_next_node(fdt, -1, NULL);
489 offset = fdt_next_node(fdt, offset, NULL)) {
490 if (fdt_get_phandle(fdt, offset) == phandle)
515 int fdt_node_check_compatible(const void *fdt, int nodeoffset,
521 prop = fdt_getprop(fdt, nodeoffset, "compatible", &len);
530 int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
535 FDT_CHECK_HEADER(fdt);
542 for (offset = fdt_next_node(fdt, startoffset, NULL);
544 offset = fdt_next_node(fdt, offset, NULL)) {
545 err = fdt_node_check_compatible(fdt, offset, compatible);