Lines Matching +full:device +full:- +full:tree

1 // SPDX-License-Identifier: GPL-2.0
3 * Functions for working with the Flattened Device Tree data format
43 * of_fdt_limit_memory - limit the number of regions in the /memory node
46 * Adjust the flattened device tree to have at most 'limit' number of
105 pprev = &np->properties; in populate_properties()
132 /* We accept flattened tree phandles either in in populate_properties()
133 * ePAPR-style "phandle" properties, or the in populate_properties()
140 if (!np->phandle) in populate_properties()
141 np->phandle = be32_to_cpup(val); in populate_properties()
145 * used in pSeries dynamic device tree in populate_properties()
149 np->phandle = be32_to_cpup(val); in populate_properties()
151 pp->name = (char *)pname; in populate_properties()
152 pp->length = sz; in populate_properties()
153 pp->value = (__be32 *)val; in populate_properties()
155 pprev = &pp->next; in populate_properties()
175 len = (pa - ps) + 1; in populate_properties()
179 pp->name = "name"; in populate_properties()
180 pp->length = len; in populate_properties()
181 pp->value = pp + 1; in populate_properties()
183 memcpy(pp->value, ps, len - 1); in populate_properties()
184 ((char *)pp->value)[len - 1] = 0; in populate_properties()
185 pr_debug("fixed up name for %s -> %s\n", in populate_properties()
186 nodename, (char *)pp->value); in populate_properties()
215 np->full_name = fn = ((char *)np) + sizeof(*np); in populate_node()
220 np->parent = dad; in populate_node()
221 np->sibling = dad->child; in populate_node()
222 dad->child = np; in populate_node()
228 np->name = of_get_property(np, "name", NULL); in populate_node()
229 if (!np->name) in populate_node()
230 np->name = "<NULL>"; in populate_node()
241 /* In-depth first */ in reverse_nodes()
242 child = parent->child; in reverse_nodes()
246 child = child->sibling; in reverse_nodes()
250 child = parent->child; in reverse_nodes()
251 parent->child = NULL; in reverse_nodes()
253 next = child->sibling; in reverse_nodes()
255 child->sibling = parent->child; in reverse_nodes()
256 parent->child = child; in reverse_nodes()
262 * unflatten_dt_nodes - Alloc and populate a device_node from the flat tree
263 * @blob: The parent device tree blob
264 * @mem: Memory chunk to use for allocating device nodes and properties
266 * @nodepp: The device_node tree created by the call
268 * Return: The size of unflattened device tree or error code
287 * We're unflattening device sub-tree if @dad is valid. There are in unflatten_dt_nodes()
290 * immediately when negative @depth is found. Otherwise, the device in unflatten_dt_nodes()
302 if (WARN_ON_ONCE(depth >= FDT_MAX_DEPTH - 1)) in unflatten_dt_nodes()
320 if (offset < 0 && offset != -FDT_ERR_NOTFOUND) { in unflatten_dt_nodes()
322 return -EINVAL; in unflatten_dt_nodes()
332 return mem - base; in unflatten_dt_nodes()
336 * __unflatten_device_tree - create tree of device_nodes from flat blob
338 * @dad: Parent device node
339 * @mynodes: The device_node tree created by the call
341 * for the resulting tree
344 * unflattens a device-tree, creating the tree of struct device_node. It also
345 * fills the "name" and "type" pointers of the nodes so the normal device-tree
349 * device tree on success.
364 pr_debug(" -> unflatten_device_tree()\n"); in __unflatten_device_tree()
367 pr_debug("No device tree pointer\n"); in __unflatten_device_tree()
371 pr_debug("Unflattening device tree:\n"); in __unflatten_device_tree()
377 pr_err("Invalid device tree blob header\n"); in __unflatten_device_tree()
389 /* Allocate memory for the expanded device tree */ in __unflatten_device_tree()
404 pr_warn("End of tree marker overwritten: %08x\n", in __unflatten_device_tree()
412 pr_debug("unflattened tree is detached\n"); in __unflatten_device_tree()
415 pr_debug(" <- unflatten_device_tree()\n"); in __unflatten_device_tree()
427 * of_fdt_unflatten_tree - create tree of device_nodes from flat blob
428 * @blob: Flat device tree blob
429 * @dad: Parent device node
430 * @mynodes: The device tree created by the call
432 * unflattens the device-tree passed by the firmware, creating the
433 * tree of struct device_node. It also fills the "name" and "type"
434 * pointers of the nodes so the normal device-tree walking functions
438 * device tree on success.
467 * fdt_reserve_elfcorehdr() - reserves memory for elf core header
470 * described in the device tree. This region contains all the
491 * early_init_fdt_scan_reserved_mem() - create reserved memory regions
493 * This function grabs memory from early allocator for device exclusive use
494 * defined in device tree structures. It should be called by arch specific code
523 * early_init_fdt_reserve_self() - reserve the memory used by the FDT blob
536 * of_scan_flat_dt - scan flattened tree blob and call callback on each.
540 * This function is used to scan the flattened device-tree, it is
542 * unflatten the tree
551 int offset, rc = 0, depth = -1; in of_scan_flat_dt()
556 for (offset = fdt_next_node(blob, -1, &depth); in of_scan_flat_dt()
567 * of_scan_flat_dt_subnodes - scan sub-nodes of a node call callback on each.
572 * This function is used to scan sub-nodes of a node.
596 * of_get_flat_dt_subnode_by_name - get the subnode by given name
600 * @return offset of the subnode, or -FDT_ERR_NOTFOUND if there is none
609 * of_get_flat_dt_root - find the root node in the flat blob
617 * of_get_flat_dt_prop - Given a node in the flat blob, return the property ptr
629 * of_fdt_is_compatible - Return true if given node from the given blob has
631 * @blob: A device tree blob
635 * Return: a non-zero value on match with smaller values returned for more
654 cplen -= l; in of_fdt_is_compatible()
661 * of_flat_dt_is_compatible - Return true if given node has compat in compatible list
671 * of_flat_dt_match - Return true if node matches a list of compatible values
691 * of_get_flat_dt_phandle - Given a node in the flat blob, return the phandle
710 * of_flat_dt_match_machine - Iterate match tables to find matching machine.
739 pr_err("\n unrecognized device tree list:\n[ "); in of_flat_dt_match_machine()
745 size -= strlen(prop) + 1; in of_flat_dt_match_machine()
775 * early_init_dt_check_for_initrd - Decode initrd location from flat tree
789 prop = of_get_flat_dt_prop(node, "linux,initrd-start", &len); in early_init_dt_check_for_initrd()
794 prop = of_get_flat_dt_prop(node, "linux,initrd-end", &len); in early_init_dt_check_for_initrd()
803 phys_initrd_size = end - start; in early_init_dt_check_for_initrd()
809 * early_init_dt_check_for_elfcorehdr - Decode elfcorehdr location from flat
810 * tree
834 static unsigned long chosen_node_offset = -FDT_ERR_NOTFOUND;
837 * The main usage of linux,usable-memory-range is for crash dump kernel.
838 * Originally, the number of usable-memory regions is one. Now there may
840 * To make compatibility with existing user-space and older kdump, the low
841 * region is always the last range of linux,usable-memory-range if exist.
846 * early_init_dt_check_for_usable_mem_range - Decode usable memory range
847 * location from flat tree
859 pr_debug("Looking for usable-memory-range property... "); in early_init_dt_check_for_usable_mem_range()
861 prop = of_get_flat_dt_prop(node, "linux,usable-memory-range", &len); in early_init_dt_check_for_usable_mem_range()
880 * early_init_dt_check_kho - Decode info required for kexec handover from DT
892 p = of_get_flat_dt_prop(node, "linux,kho-fdt", &l); in early_init_dt_check_kho()
899 p = of_get_flat_dt_prop(node, "linux,kho-scratch", &l); in early_init_dt_check_kho()
924 return -ENOENT; in early_init_dt_scan_chosen_stdout()
926 p = fdt_getprop(fdt, offset, "stdout-path", &l); in early_init_dt_scan_chosen_stdout()
928 p = fdt_getprop(fdt, offset, "linux,stdout-path", &l); in early_init_dt_scan_chosen_stdout()
930 return -ENOENT; in early_init_dt_scan_chosen_stdout()
935 l = q - p; in early_init_dt_scan_chosen_stdout()
937 /* Get the node specified by stdout-path */ in early_init_dt_scan_chosen_stdout()
940 pr_warn("earlycon: stdout-path %.*s not found\n", l, p); in early_init_dt_scan_chosen_stdout()
945 if (!match->compatible[0]) in early_init_dt_scan_chosen_stdout()
948 if (fdt_node_check_compatible(fdt, offset, match->compatible)) in early_init_dt_scan_chosen_stdout()
952 if (!ret || ret == -EALREADY) in early_init_dt_scan_chosen_stdout()
955 return -ENODEV; in early_init_dt_scan_chosen_stdout()
960 * early_init_dt_scan_root - fetch the top level address and size cells
969 return -ENODEV; in early_init_dt_scan_root()
974 prop = of_get_flat_dt_prop(node, "#size-cells", NULL); in early_init_dt_scan_root()
975 if (!WARN(!prop, "No '#size-cells' in root node\n")) in early_init_dt_scan_root()
979 prop = of_get_flat_dt_prop(node, "#address-cells", NULL); in early_init_dt_scan_root()
980 if (!WARN(!prop, "No '#address-cells' in root node\n")) in early_init_dt_scan_root()
996 * early_init_dt_scan_memory - Look for and parse memory nodes
1016 reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l); in early_init_dt_scan_memory()
1028 while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) { in early_init_dt_scan_memory()
1036 pr_debug(" - %llx, %llx\n", base, size); in early_init_dt_scan_memory()
1046 pr_warn("failed to mark hotplug range 0x%llx - 0x%llx\n", in early_init_dt_scan_memory()
1072 rng_seed = of_get_flat_dt_prop(node, "rng-seed", &l); in early_init_dt_scan_chosen()
1077 fdt_nop_property(initial_boot_params, node, "rng-seed"); in early_init_dt_scan_chosen()
1124 if (size < PAGE_SIZE - (base & ~PAGE_MASK)) { in early_init_dt_add_memory_arch()
1125 pr_warn("Ignoring memory block 0x%llx - 0x%llx\n", in early_init_dt_add_memory_arch()
1131 size -= PAGE_SIZE - (base & ~PAGE_MASK); in early_init_dt_add_memory_arch()
1137 pr_warn("Ignoring memory block 0x%llx - 0x%llx\n", in early_init_dt_add_memory_arch()
1142 if (base + size - 1 > MAX_MEMBLOCK_ADDR) { in early_init_dt_add_memory_arch()
1143 pr_warn("Ignoring memory range 0x%llx - 0x%llx\n", in early_init_dt_add_memory_arch()
1145 size = MAX_MEMBLOCK_ADDR - base + 1; in early_init_dt_add_memory_arch()
1149 pr_warn("Ignoring memory block 0x%llx - 0x%llx\n", in early_init_dt_add_memory_arch()
1154 pr_warn("Ignoring memory range 0x%llx - 0x%llx\n", in early_init_dt_add_memory_arch()
1156 size -= phys_offset - base; in early_init_dt_add_memory_arch()
1172 /* check device tree validity */ in early_init_dt_verify()
1176 /* Setup flat device-tree pointer */ in early_init_dt_verify()
1182 /* Initialize {size,address}-cells info */ in early_init_dt_verify()
1201 /* Handle linux,usable-memory-range property */ in early_init_dt_scan_nodes()
1236 * unflatten_device_tree - create tree of device_nodes from flat blob
1238 * unflattens the device-tree passed by the firmware, creating the
1239 * tree of struct device_node. It also fills the "name" and "type"
1240 * pointers of the nodes so the normal device-tree walking functions
1247 /* Save the statically-placed regions in the reserved_mem array */ in unflatten_device_tree()
1255 __dtb_empty_root_end - __dtb_empty_root_begin) { in unflatten_device_tree()
1273 * unflatten_and_copy_device_tree - copy and create tree of device_nodes from flat blob
1275 * Copies and unflattens the device-tree passed by the firmware, creating the
1276 * tree of struct device_node. It also fills the "name" and "type"
1277 * pointers of the nodes so the normal device-tree walking functions
1279 * reserved such is the case when the FDT is built-in to the kernel init