Lines Matching refs:fdt
13 static int fdt_nodename_eq_(const void *fdt, int offset, in fdt_nodename_eq_() argument
17 const char *p = fdt_get_name(fdt, offset, &olen); in fdt_nodename_eq_()
34 const char *fdt_get_string(const void *fdt, int stroffset, int *lenp) in fdt_get_string() argument
43 s = (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset; in fdt_get_string()
49 totalsize = fdt_ro_probe_(fdt); in fdt_get_string()
55 absoffset = stroffset + fdt_off_dt_strings(fdt); in fdt_get_string()
60 if (fdt_magic(fdt) == FDT_MAGIC) { in fdt_get_string()
63 if (can_assume(LATEST) || fdt_version(fdt) >= 17) { in fdt_get_string()
64 if ((unsigned)stroffset >= fdt_size_dt_strings(fdt)) in fdt_get_string()
66 if ((fdt_size_dt_strings(fdt) - stroffset) < len) in fdt_get_string()
67 len = fdt_size_dt_strings(fdt) - stroffset; in fdt_get_string()
69 } else if (fdt_magic(fdt) == FDT_SW_MAGIC) { in fdt_get_string()
73 (sw_stroffset > fdt_size_dt_strings(fdt))) in fdt_get_string()
82 s = (const char *)fdt + absoffset; in fdt_get_string()
100 const char *fdt_string(const void *fdt, int stroffset) in fdt_string() argument
102 return fdt_get_string(fdt, stroffset, NULL); in fdt_string()
105 static int fdt_string_eq_(const void *fdt, int stroffset, in fdt_string_eq_() argument
109 const char *p = fdt_get_string(fdt, stroffset, &slen); in fdt_string_eq_()
114 int fdt_find_max_phandle(const void *fdt, uint32_t *phandle) in fdt_find_max_phandle() argument
122 offset = fdt_next_node(fdt, offset, NULL); in fdt_find_max_phandle()
130 value = fdt_get_phandle(fdt, offset); in fdt_find_max_phandle()
142 int fdt_generate_phandle(const void *fdt, uint32_t *phandle) in fdt_generate_phandle() argument
147 err = fdt_find_max_phandle(fdt, &max); in fdt_generate_phandle()
160 static const struct fdt_reserve_entry *fdt_mem_rsv(const void *fdt, int n) in fdt_mem_rsv() argument
163 unsigned int absoffset = fdt_off_mem_rsvmap(fdt) + offset; in fdt_mem_rsv()
166 if (absoffset < fdt_off_mem_rsvmap(fdt)) in fdt_mem_rsv()
168 if (absoffset > fdt_totalsize(fdt) - in fdt_mem_rsv()
172 return fdt_mem_rsv_(fdt, n); in fdt_mem_rsv()
175 int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size) in fdt_get_mem_rsv() argument
179 FDT_RO_PROBE(fdt); in fdt_get_mem_rsv()
180 re = fdt_mem_rsv(fdt, n); in fdt_get_mem_rsv()
189 int fdt_num_mem_rsv(const void *fdt) in fdt_num_mem_rsv() argument
194 for (i = 0; (re = fdt_mem_rsv(fdt, i)) != NULL; i++) { in fdt_num_mem_rsv()
201 static int nextprop_(const void *fdt, int offset) in nextprop_() argument
207 tag = fdt_next_tag(fdt, offset, &nextoffset); in nextprop_()
225 int fdt_subnode_offset_namelen(const void *fdt, int offset, in fdt_subnode_offset_namelen() argument
230 FDT_RO_PROBE(fdt); in fdt_subnode_offset_namelen()
234 offset = fdt_next_node(fdt, offset, &depth)) in fdt_subnode_offset_namelen()
236 && fdt_nodename_eq_(fdt, offset, name, namelen)) in fdt_subnode_offset_namelen()
244 int fdt_subnode_offset(const void *fdt, int parentoffset, in fdt_subnode_offset() argument
247 return fdt_subnode_offset_namelen(fdt, parentoffset, name, strlen(name)); in fdt_subnode_offset()
250 int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen) in fdt_path_offset_namelen() argument
256 FDT_RO_PROBE(fdt); in fdt_path_offset_namelen()
265 p = fdt_get_alias_namelen(fdt, p, q - p); in fdt_path_offset_namelen()
268 offset = fdt_path_offset(fdt, p); in fdt_path_offset_namelen()
285 offset = fdt_subnode_offset_namelen(fdt, offset, p, q-p); in fdt_path_offset_namelen()
295 int fdt_path_offset(const void *fdt, const char *path) in fdt_path_offset() argument
297 return fdt_path_offset_namelen(fdt, path, strlen(path)); in fdt_path_offset()
300 const char *fdt_get_name(const void *fdt, int nodeoffset, int *len) in fdt_get_name() argument
302 const struct fdt_node_header *nh = fdt_offset_ptr_(fdt, nodeoffset); in fdt_get_name()
306 if (((err = fdt_ro_probe_(fdt)) < 0) in fdt_get_name()
307 || ((err = fdt_check_node_offset_(fdt, nodeoffset)) < 0)) in fdt_get_name()
312 if (!can_assume(LATEST) && fdt_version(fdt) < 0x10) { in fdt_get_name()
338 int fdt_first_property_offset(const void *fdt, int nodeoffset) in fdt_first_property_offset() argument
342 if ((offset = fdt_check_node_offset_(fdt, nodeoffset)) < 0) in fdt_first_property_offset()
345 return nextprop_(fdt, offset); in fdt_first_property_offset()
348 int fdt_next_property_offset(const void *fdt, int offset) in fdt_next_property_offset() argument
350 if ((offset = fdt_check_prop_offset_(fdt, offset)) < 0) in fdt_next_property_offset()
353 return nextprop_(fdt, offset); in fdt_next_property_offset()
356 static const struct fdt_property *fdt_get_property_by_offset_(const void *fdt, in fdt_get_property_by_offset_() argument
364 (err = fdt_check_prop_offset_(fdt, offset)) < 0) { in fdt_get_property_by_offset_()
370 prop = fdt_offset_ptr_(fdt, offset); in fdt_get_property_by_offset_()
378 const struct fdt_property *fdt_get_property_by_offset(const void *fdt, in fdt_get_property_by_offset() argument
385 if (!can_assume(LATEST) && fdt_version(fdt) < 0x10) { in fdt_get_property_by_offset()
391 return fdt_get_property_by_offset_(fdt, offset, lenp); in fdt_get_property_by_offset()
394 static const struct fdt_property *fdt_get_property_namelen_(const void *fdt, in fdt_get_property_namelen_() argument
401 for (offset = fdt_first_property_offset(fdt, offset); in fdt_get_property_namelen_()
403 (offset = fdt_next_property_offset(fdt, offset))) { in fdt_get_property_namelen_()
406 prop = fdt_get_property_by_offset_(fdt, offset, lenp); in fdt_get_property_namelen_()
411 if (fdt_string_eq_(fdt, fdt32_ld(&prop->nameoff), in fdt_get_property_namelen_()
425 const struct fdt_property *fdt_get_property_namelen(const void *fdt, in fdt_get_property_namelen() argument
432 if (!can_assume(LATEST) && fdt_version(fdt) < 0x10) { in fdt_get_property_namelen()
438 return fdt_get_property_namelen_(fdt, offset, name, namelen, lenp, in fdt_get_property_namelen()
443 const struct fdt_property *fdt_get_property(const void *fdt, in fdt_get_property() argument
447 return fdt_get_property_namelen(fdt, nodeoffset, name, in fdt_get_property()
451 const void *fdt_getprop_namelen(const void *fdt, int nodeoffset, in fdt_getprop_namelen() argument
457 prop = fdt_get_property_namelen_(fdt, nodeoffset, name, namelen, lenp, in fdt_getprop_namelen()
463 if (!can_assume(LATEST) && fdt_version(fdt) < 0x10 && in fdt_getprop_namelen()
469 const void *fdt_getprop_by_offset(const void *fdt, int offset, in fdt_getprop_by_offset() argument
474 prop = fdt_get_property_by_offset_(fdt, offset, lenp); in fdt_getprop_by_offset()
482 name = fdt_get_string(fdt, fdt32_ld(&prop->nameoff), in fdt_getprop_by_offset()
491 *namep = fdt_string(fdt, fdt32_ld(&prop->nameoff)); in fdt_getprop_by_offset()
496 if (!can_assume(LATEST) && fdt_version(fdt) < 0x10 && in fdt_getprop_by_offset()
502 const void *fdt_getprop(const void *fdt, int nodeoffset, in fdt_getprop() argument
505 return fdt_getprop_namelen(fdt, nodeoffset, name, strlen(name), lenp); in fdt_getprop()
508 uint32_t fdt_get_phandle(const void *fdt, int nodeoffset) in fdt_get_phandle() argument
515 php = fdt_getprop(fdt, nodeoffset, "phandle", &len); in fdt_get_phandle()
517 php = fdt_getprop(fdt, nodeoffset, "linux,phandle", &len); in fdt_get_phandle()
525 const char *fdt_get_alias_namelen(const void *fdt, in fdt_get_alias_namelen() argument
530 aliasoffset = fdt_path_offset(fdt, "/aliases"); in fdt_get_alias_namelen()
534 return fdt_getprop_namelen(fdt, aliasoffset, name, namelen, NULL); in fdt_get_alias_namelen()
537 const char *fdt_get_alias(const void *fdt, const char *name) in fdt_get_alias() argument
539 return fdt_get_alias_namelen(fdt, name, strlen(name)); in fdt_get_alias()
542 int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen) in fdt_get_path() argument
548 FDT_RO_PROBE(fdt); in fdt_get_path()
555 offset = fdt_next_node(fdt, offset, &depth)) { in fdt_get_path()
564 name = fdt_get_name(fdt, offset, &namelen); in fdt_get_path()
594 int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset, in fdt_supernode_atdepth_offset() argument
600 FDT_RO_PROBE(fdt); in fdt_supernode_atdepth_offset()
607 offset = fdt_next_node(fdt, offset, &depth)) { in fdt_supernode_atdepth_offset()
632 int fdt_node_depth(const void *fdt, int nodeoffset) in fdt_node_depth() argument
637 err = fdt_supernode_atdepth_offset(fdt, nodeoffset, 0, &nodedepth); in fdt_node_depth()
644 int fdt_parent_offset(const void *fdt, int nodeoffset) in fdt_parent_offset() argument
646 int nodedepth = fdt_node_depth(fdt, nodeoffset); in fdt_parent_offset()
650 return fdt_supernode_atdepth_offset(fdt, nodeoffset, in fdt_parent_offset()
654 int fdt_node_offset_by_prop_value(const void *fdt, int startoffset, in fdt_node_offset_by_prop_value() argument
662 FDT_RO_PROBE(fdt); in fdt_node_offset_by_prop_value()
669 for (offset = fdt_next_node(fdt, startoffset, NULL); in fdt_node_offset_by_prop_value()
671 offset = fdt_next_node(fdt, offset, NULL)) { in fdt_node_offset_by_prop_value()
672 val = fdt_getprop(fdt, offset, propname, &len); in fdt_node_offset_by_prop_value()
681 int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle) in fdt_node_offset_by_phandle() argument
688 FDT_RO_PROBE(fdt); in fdt_node_offset_by_phandle()
696 for (offset = fdt_next_node(fdt, -1, NULL); in fdt_node_offset_by_phandle()
698 offset = fdt_next_node(fdt, offset, NULL)) { in fdt_node_offset_by_phandle()
699 if (fdt_get_phandle(fdt, offset) == phandle) in fdt_node_offset_by_phandle()
723 int fdt_stringlist_count(const void *fdt, int nodeoffset, const char *property) in fdt_stringlist_count() argument
728 list = fdt_getprop(fdt, nodeoffset, property, &length); in fdt_stringlist_count()
748 int fdt_stringlist_search(const void *fdt, int nodeoffset, const char *property, in fdt_stringlist_search() argument
754 list = fdt_getprop(fdt, nodeoffset, property, &length); in fdt_stringlist_search()
778 const char *fdt_stringlist_get(const void *fdt, int nodeoffset, in fdt_stringlist_get() argument
785 list = fdt_getprop(fdt, nodeoffset, property, &length); in fdt_stringlist_get()
823 int fdt_node_check_compatible(const void *fdt, int nodeoffset, in fdt_node_check_compatible() argument
829 prop = fdt_getprop(fdt, nodeoffset, "compatible", &len); in fdt_node_check_compatible()
836 int fdt_node_offset_by_compatible(const void *fdt, int startoffset, in fdt_node_offset_by_compatible() argument
841 FDT_RO_PROBE(fdt); in fdt_node_offset_by_compatible()
848 for (offset = fdt_next_node(fdt, startoffset, NULL); in fdt_node_offset_by_compatible()
850 offset = fdt_next_node(fdt, offset, NULL)) { in fdt_node_offset_by_compatible()
851 err = fdt_node_check_compatible(fdt, offset, compatible); in fdt_node_offset_by_compatible()