Lines Matching +full:a +full:- +full:child +full:- +full:node +full:- +full:property

1 // SPDX-License-Identifier: GPL-2.0
35 * of_fdt_limit_memory - limit the number of regions in the /memory node
39 * memory entries in the /memory node. This function may be called
59 "#address-cells", NULL); in of_fdt_limit_memory()
64 "#size-cells", NULL); in of_fdt_limit_memory()
82 static bool of_fdt_device_is_available(const void *blob, unsigned long node) in of_fdt_device_is_available() argument
84 const char *status = fdt_getprop(blob, node, "status", NULL); in of_fdt_device_is_available()
114 struct property *pp, **pprev = NULL; in populate_properties()
118 pprev = &np->properties; in populate_properties()
128 pr_warn("Cannot locate property at 0x%x\n", cur); in populate_properties()
133 pr_warn("Cannot find property name at 0x%x\n", cur); in populate_properties()
140 pp = unflatten_dt_alloc(mem, sizeof(struct property), in populate_properties()
141 __alignof__(struct property)); in populate_properties()
146 * ePAPR-style "phandle" properties, or the in populate_properties()
153 if (!np->phandle) in populate_properties()
154 np->phandle = be32_to_cpup(val); in populate_properties()
157 /* And we process the "ibm,phandle" property in populate_properties()
162 np->phandle = be32_to_cpup(val); in populate_properties()
164 pp->name = (char *)pname; in populate_properties()
165 pp->length = sz; in populate_properties()
166 pp->value = (__be32 *)val; in populate_properties()
168 pprev = &pp->next; in populate_properties()
171 /* With version 0x10 we may not have the name property, in populate_properties()
188 len = (pa - ps) + 1; in populate_properties()
189 pp = unflatten_dt_alloc(mem, sizeof(struct property) + len, in populate_properties()
190 __alignof__(struct property)); in populate_properties()
192 pp->name = "name"; in populate_properties()
193 pp->length = len; in populate_properties()
194 pp->value = pp + 1; in populate_properties()
196 pprev = &pp->next; in populate_properties()
197 memcpy(pp->value, ps, len - 1); in populate_properties()
198 ((char *)pp->value)[len - 1] = 0; in populate_properties()
199 pr_debug("fixed up name for %s -> %s\n", in populate_properties()
200 nodename, (char *)pp->value); in populate_properties()
232 np->full_name = fn = ((char *)np) + sizeof(*np); in populate_node()
237 np->parent = dad; in populate_node()
238 np->sibling = dad->child; in populate_node()
239 dad->child = np; in populate_node()
245 np->name = of_get_property(np, "name", NULL); in populate_node()
246 if (!np->name) in populate_node()
247 np->name = "<NULL>"; in populate_node()
256 struct device_node *child, *next; in reverse_nodes() local
258 /* In-depth first */ in reverse_nodes()
259 child = parent->child; in reverse_nodes()
260 while (child) { in reverse_nodes()
261 reverse_nodes(child); in reverse_nodes()
263 child = child->sibling; in reverse_nodes()
266 /* Reverse the nodes in the child list */ in reverse_nodes()
267 child = parent->child; in reverse_nodes()
268 parent->child = NULL; in reverse_nodes()
269 while (child) { in reverse_nodes()
270 next = child->sibling; in reverse_nodes()
272 child->sibling = parent->child; in reverse_nodes()
273 parent->child = child; in reverse_nodes()
274 child = next; in reverse_nodes()
279 * unflatten_dt_nodes - Alloc and populate a device_node from the flat tree
303 * We're unflattening device sub-tree if @dad is valid. There are in unflatten_dt_nodes()
327 return mem - base; in unflatten_dt_nodes()
335 if (offset < 0 && offset != -FDT_ERR_NOTFOUND) { in unflatten_dt_nodes()
337 return -EINVAL; in unflatten_dt_nodes()
341 * Reverse the child list. Some drivers assumes node order matches .dts in unflatten_dt_nodes()
342 * node order in unflatten_dt_nodes()
347 return mem - base; in unflatten_dt_nodes()
351 * __unflatten_device_tree - create tree of device_nodes from flat blob
353 * unflattens a device-tree, creating the
355 * pointers of the nodes so the normal device-tree walking functions
358 * @dad: Parent device node
360 * @dt_alloc: An allocator that provides a virtual address to memory
376 pr_debug(" -> unflatten_device_tree()\n"); in __unflatten_device_tree()
423 pr_debug(" <- unflatten_device_tree()\n"); in __unflatten_device_tree()
435 * of_fdt_unflatten_tree - create tree of device_nodes from flat blob
437 * @dad: Parent device node
440 * unflattens the device-tree passed by the firmware, creating the
442 * pointers of the nodes so the normal device-tree walking functions
474 * __reserved_mem_reserve_reg() - reserve all memory described in 'reg' property
476 static int __init __reserved_mem_reserve_reg(unsigned long node, in __reserved_mem_reserve_reg() argument
486 prop = of_get_flat_dt_prop(node, "reg", &len); in __reserved_mem_reserve_reg()
488 return -ENOENT; in __reserved_mem_reserve_reg()
491 pr_err("Reserved memory: invalid reg property in '%s', skipping node.\n", in __reserved_mem_reserve_reg()
493 return -EINVAL; in __reserved_mem_reserve_reg()
496 nomap = of_get_flat_dt_prop(node, "no-map", NULL) != NULL; in __reserved_mem_reserve_reg()
504 pr_debug("Reserved memory: reserved region for node '%s': base %pa, size %ld MiB\n", in __reserved_mem_reserve_reg()
507 pr_info("Reserved memory: failed to reserve memory for node '%s': base %pa, size %ld MiB\n", in __reserved_mem_reserve_reg()
510 len -= t_len; in __reserved_mem_reserve_reg()
512 fdt_reserved_mem_save_node(node, uname, base, size); in __reserved_mem_reserve_reg()
520 * __reserved_mem_check_root() - check if #size-cells, #address-cells provided
521 * in /reserved-memory matches the values supported by the current implementation,
522 * also check if ranges property has been provided
524 static int __init __reserved_mem_check_root(unsigned long node) in __reserved_mem_check_root() argument
528 prop = of_get_flat_dt_prop(node, "#size-cells", NULL); in __reserved_mem_check_root()
530 return -EINVAL; in __reserved_mem_check_root()
532 prop = of_get_flat_dt_prop(node, "#address-cells", NULL); in __reserved_mem_check_root()
534 return -EINVAL; in __reserved_mem_check_root()
536 prop = of_get_flat_dt_prop(node, "ranges", NULL); in __reserved_mem_check_root()
538 return -EINVAL; in __reserved_mem_check_root()
543 * fdt_scan_reserved_mem() - scan a single FDT node for reserved memory
545 static int __init __fdt_scan_reserved_mem(unsigned long node, const char *uname, in __fdt_scan_reserved_mem() argument
551 if (!found && depth == 1 && strcmp(uname, "reserved-memory") == 0) { in __fdt_scan_reserved_mem()
552 if (__reserved_mem_check_root(node) != 0) { in __fdt_scan_reserved_mem()
553 pr_err("Reserved memory: unsupported node format, ignoring\n"); in __fdt_scan_reserved_mem()
558 /* scan next node */ in __fdt_scan_reserved_mem()
561 /* scan next node */ in __fdt_scan_reserved_mem()
564 /* scanning of /reserved-memory has been finished */ in __fdt_scan_reserved_mem()
568 if (!of_fdt_device_is_available(initial_boot_params, node)) in __fdt_scan_reserved_mem()
571 err = __reserved_mem_reserve_reg(node, uname); in __fdt_scan_reserved_mem()
572 if (err == -ENOENT && of_get_flat_dt_prop(node, "size", NULL)) in __fdt_scan_reserved_mem()
573 fdt_reserved_mem_save_node(node, uname, 0, 0); in __fdt_scan_reserved_mem()
575 /* scan next node */ in __fdt_scan_reserved_mem()
580 * early_init_fdt_scan_reserved_mem() - create reserved memory regions
607 * early_init_fdt_reserve_self() - reserve the memory used by the FDT blob
621 * of_scan_flat_dt - scan flattened tree blob and call callback on each.
625 * This function is used to scan the flattened device-tree, it is
629 int __init of_scan_flat_dt(int (*it)(unsigned long node, in of_scan_flat_dt() argument
636 int offset, rc = 0, depth = -1; in of_scan_flat_dt()
641 for (offset = fdt_next_node(blob, -1, &depth); in of_scan_flat_dt()
652 * of_scan_flat_dt_subnodes - scan sub-nodes of a node call callback on each.
656 * This function is used to scan sub-nodes of a node.
659 int (*it)(unsigned long node, in of_scan_flat_dt_subnodes() argument
665 int node; in of_scan_flat_dt_subnodes() local
667 fdt_for_each_subnode(node, blob, parent) { in of_scan_flat_dt_subnodes()
671 pathp = fdt_get_name(blob, node, NULL); in of_scan_flat_dt_subnodes()
672 rc = it(node, pathp, data); in of_scan_flat_dt_subnodes()
680 * of_get_flat_dt_subnode_by_name - get the subnode by given name
682 * @node: the parent node
684 * @return offset of the subnode, or -FDT_ERR_NOTFOUND if there is none
687 int __init of_get_flat_dt_subnode_by_name(unsigned long node, const char *uname) in of_get_flat_dt_subnode_by_name() argument
689 return fdt_subnode_offset(initial_boot_params, node, uname); in of_get_flat_dt_subnode_by_name()
693 * of_get_flat_dt_root - find the root node in the flat blob
701 * of_get_flat_dt_prop - Given a node in the flat blob, return the property ptr
706 const void *__init of_get_flat_dt_prop(unsigned long node, const char *name, in of_get_flat_dt_prop() argument
709 return fdt_getprop(initial_boot_params, node, name, size); in of_get_flat_dt_prop()
713 * of_fdt_is_compatible - Return true if given node from the given blob has
715 * @blob: A device tree blob
716 * @node: node to test
719 * On match, returns a non-zero value with smaller values returned for more
723 unsigned long node, const char *compat) in of_fdt_is_compatible() argument
729 cp = fdt_getprop(blob, node, "compatible", &cplen); in of_fdt_is_compatible()
738 cplen -= l; in of_fdt_is_compatible()
745 * of_flat_dt_is_compatible - Return true if given node has compat in compatible list
746 * @node: node to test
749 int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) in of_flat_dt_is_compatible() argument
751 return of_fdt_is_compatible(initial_boot_params, node, compat); in of_flat_dt_is_compatible()
755 * of_flat_dt_match - Return true if node matches a list of compatible values
757 static int __init of_flat_dt_match(unsigned long node, const char *const *compat) in of_flat_dt_match() argument
765 tmp = of_fdt_is_compatible(initial_boot_params, node, *compat); in of_flat_dt_match()
775 * of_get_flat_dt_prop - Given a node in the flat blob, return the phandle
777 uint32_t __init of_get_flat_dt_phandle(unsigned long node) in of_get_flat_dt_phandle() argument
779 return fdt_get_phandle(initial_boot_params, node); in of_get_flat_dt_phandle()
787 int (*iterator)(unsigned long node, const char *uname, int depth, void *data);
803 * of_flat_dt_match_machine - Iterate match tables to find matching machine.
805 * @default_match: A machine specific ptr to return in case of no match.
838 size -= strlen(prop) + 1; in of_flat_dt_match_machine()
855 /* ARM64 would cause a BUG to occur here when CONFIG_DEBUG_VM is in __early_init_dt_declare_initrd()
868 * early_init_dt_check_for_initrd - Decode initrd location from flat tree
869 * @node: reference to node containing initrd location ('chosen')
871 static void __init early_init_dt_check_for_initrd(unsigned long node) in early_init_dt_check_for_initrd() argument
879 prop = of_get_flat_dt_prop(node, "linux,initrd-start", &len); in early_init_dt_check_for_initrd()
884 prop = of_get_flat_dt_prop(node, "linux,initrd-end", &len); in early_init_dt_check_for_initrd()
891 phys_initrd_size = end - start; in early_init_dt_check_for_initrd()
897 static inline void early_init_dt_check_for_initrd(unsigned long node) in early_init_dt_check_for_initrd() argument
916 return -ENOENT; in early_init_dt_scan_chosen_stdout()
918 p = fdt_getprop(fdt, offset, "stdout-path", &l); in early_init_dt_scan_chosen_stdout()
920 p = fdt_getprop(fdt, offset, "linux,stdout-path", &l); in early_init_dt_scan_chosen_stdout()
922 return -ENOENT; in early_init_dt_scan_chosen_stdout()
927 l = q - p; in early_init_dt_scan_chosen_stdout()
929 /* Get the node specified by stdout-path */ in early_init_dt_scan_chosen_stdout()
932 pr_warn("earlycon: stdout-path %.*s not found\n", l, p); in early_init_dt_scan_chosen_stdout()
940 if (!match->compatible[0]) in early_init_dt_scan_chosen_stdout()
943 if (fdt_node_check_compatible(fdt, offset, match->compatible)) in early_init_dt_scan_chosen_stdout()
949 return -ENODEV; in early_init_dt_scan_chosen_stdout()
954 * early_init_dt_scan_root - fetch the top level address and size cells
956 int __init early_init_dt_scan_root(unsigned long node, const char *uname, in early_init_dt_scan_root() argument
967 prop = of_get_flat_dt_prop(node, "#size-cells", NULL); in early_init_dt_scan_root()
972 prop = of_get_flat_dt_prop(node, "#address-cells", NULL); in early_init_dt_scan_root()
990 * early_init_dt_scan_memory - Look for and parse memory nodes
992 int __init early_init_dt_scan_memory(unsigned long node, const char *uname, in early_init_dt_scan_memory() argument
995 const char *type = of_get_flat_dt_prop(node, "device_type", NULL); in early_init_dt_scan_memory()
1004 reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l); in early_init_dt_scan_memory()
1006 reg = of_get_flat_dt_prop(node, "reg", &l); in early_init_dt_scan_memory()
1011 hotpluggable = of_get_flat_dt_prop(node, "hotpluggable", NULL); in early_init_dt_scan_memory()
1013 pr_debug("memory scan node %s, reg size %d,\n", uname, l); in early_init_dt_scan_memory()
1015 while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) { in early_init_dt_scan_memory()
1023 pr_debug(" - %llx , %llx\n", (unsigned long long)base, in early_init_dt_scan_memory()
1032 pr_warn("failed to mark hotplug range 0x%llx - 0x%llx\n", in early_init_dt_scan_memory()
1039 int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, in early_init_dt_scan_chosen() argument
1052 early_init_dt_check_for_initrd(node); in early_init_dt_scan_chosen()
1055 p = of_get_flat_dt_prop(node, "bootargs", &l); in early_init_dt_scan_chosen()
1060 * CONFIG_CMDLINE is meant to be a default in case nothing else in early_init_dt_scan_chosen()
1079 rng_seed = of_get_flat_dt_prop(node, "rng-seed", &l); in early_init_dt_scan_chosen()
1084 fdt_nop_property(initial_boot_params, node, "rng-seed"); in early_init_dt_scan_chosen()
1106 if (size < PAGE_SIZE - (base & ~PAGE_MASK)) { in early_init_dt_add_memory_arch()
1107 pr_warn("Ignoring memory block 0x%llx - 0x%llx\n", in early_init_dt_add_memory_arch()
1113 size -= PAGE_SIZE - (base & ~PAGE_MASK); in early_init_dt_add_memory_arch()
1119 pr_warn("Ignoring memory block 0x%llx - 0x%llx\n", in early_init_dt_add_memory_arch()
1124 if (base + size - 1 > MAX_MEMBLOCK_ADDR) { in early_init_dt_add_memory_arch()
1125 pr_warn("Ignoring memory range 0x%llx - 0x%llx\n", in early_init_dt_add_memory_arch()
1127 size = MAX_MEMBLOCK_ADDR - base + 1; in early_init_dt_add_memory_arch()
1131 pr_warn("Ignoring memory block 0x%llx - 0x%llx\n", in early_init_dt_add_memory_arch()
1136 pr_warn("Ignoring memory range 0x%llx - 0x%llx\n", in early_init_dt_add_memory_arch()
1138 size -= phys_offset - base; in early_init_dt_add_memory_arch()
1177 /* Setup flat device-tree pointer */ in early_init_dt_verify()
1189 /* Retrieve various information from the /chosen node */ in early_init_dt_scan_nodes()
1192 pr_warn("No chosen node found, continuing without\n"); in early_init_dt_scan_nodes()
1194 /* Initialize {size,address}-cells info */ in early_init_dt_scan_nodes()
1214 * unflatten_device_tree - create tree of device_nodes from flat blob
1216 * unflattens the device-tree passed by the firmware, creating the
1218 * pointers of the nodes so the normal device-tree walking functions
1233 * unflatten_and_copy_device_tree - copy and create tree of device_nodes from flat blob
1235 * Copies and unflattens the device-tree passed by the firmware, creating the
1237 * pointers of the nodes so the normal device-tree walking functions
1239 * reserved such is the case when the FDT is built-in to the kernel init