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

1 // SPDX-License-Identifier: GPL-2.0
42 * of_fdt_limit_memory - limit the number of regions in the /memory node
46 * memory entries in the /memory node. This function may be called
68 bool of_fdt_device_is_available(const void *blob, unsigned long node) in of_fdt_device_is_available() argument
70 const char *status = fdt_getprop(blob, node, "status", NULL); in of_fdt_device_is_available()
100 struct property *pp, **pprev = NULL; in populate_properties()
104 pprev = &np->properties; in populate_properties()
114 pr_warn("Cannot locate property at 0x%x\n", cur); in populate_properties()
119 pr_warn("Cannot find property name at 0x%x\n", cur); in populate_properties()
126 pp = unflatten_dt_alloc(mem, sizeof(struct property), in populate_properties()
127 __alignof__(struct property)); in populate_properties()
132 * ePAPR-style "phandle" properties, or the in populate_properties()
139 if (!np->phandle) in populate_properties()
140 np->phandle = be32_to_cpup(val); in populate_properties()
143 /* And we process the "ibm,phandle" property in populate_properties()
148 np->phandle = be32_to_cpup(val); in populate_properties()
150 pp->name = (char *)pname; in populate_properties()
151 pp->length = sz; in populate_properties()
152 pp->value = (__be32 *)val; in populate_properties()
154 pprev = &pp->next; in populate_properties()
157 /* With version 0x10 we may not have the name property, in populate_properties()
174 len = (pa - ps) + 1; in populate_properties()
175 pp = unflatten_dt_alloc(mem, sizeof(struct property) + len, in populate_properties()
176 __alignof__(struct property)); in populate_properties()
178 pp->name = "name"; in populate_properties()
179 pp->length = len; in populate_properties()
180 pp->value = pp + 1; in populate_properties()
182 memcpy(pp->value, ps, len - 1); in populate_properties()
183 ((char *)pp->value)[len - 1] = 0; in populate_properties()
184 pr_debug("fixed up name for %s -> %s\n", in populate_properties()
185 nodename, (char *)pp->value); in populate_properties()
214 np->full_name = fn = ((char *)np) + sizeof(*np); in populate_node()
219 np->parent = dad; in populate_node()
220 np->sibling = dad->child; in populate_node()
221 dad->child = np; in populate_node()
227 np->name = of_get_property(np, "name", NULL); in populate_node()
228 if (!np->name) in populate_node()
229 np->name = "<NULL>"; in populate_node()
238 struct device_node *child, *next; in reverse_nodes() local
240 /* In-depth first */ in reverse_nodes()
241 child = parent->child; in reverse_nodes()
242 while (child) { in reverse_nodes()
243 reverse_nodes(child); in reverse_nodes()
245 child = child->sibling; in reverse_nodes()
248 /* Reverse the nodes in the child list */ in reverse_nodes()
249 child = parent->child; in reverse_nodes()
250 parent->child = NULL; in reverse_nodes()
251 while (child) { in reverse_nodes()
252 next = child->sibling; in reverse_nodes()
254 child->sibling = parent->child; in reverse_nodes()
255 parent->child = child; in reverse_nodes()
256 child = next; in reverse_nodes()
261 * unflatten_dt_nodes - Alloc and populate a device_node from the flat tree
286 * We're unflattening device sub-tree if @dad is valid. There are in unflatten_dt_nodes()
301 if (WARN_ON_ONCE(depth >= FDT_MAX_DEPTH - 1)) in unflatten_dt_nodes()
319 if (offset < 0 && offset != -FDT_ERR_NOTFOUND) { in unflatten_dt_nodes()
321 return -EINVAL; in unflatten_dt_nodes()
325 * Reverse the child list. Some drivers assumes node order matches .dts in unflatten_dt_nodes()
326 * node order in unflatten_dt_nodes()
331 return mem - base; in unflatten_dt_nodes()
335 * __unflatten_device_tree - create tree of device_nodes from flat blob
337 * @dad: Parent device node
339 * @dt_alloc: An allocator that provides a virtual address to memory
343 * unflattens a device-tree, creating the tree of struct device_node. It also
344 * fills the "name" and "type" pointers of the nodes so the normal device-tree
363 pr_debug(" -> unflatten_device_tree()\n"); in __unflatten_device_tree()
414 pr_debug(" <- unflatten_device_tree()\n"); in __unflatten_device_tree()
426 * of_fdt_unflatten_tree - create tree of device_nodes from flat blob
428 * @dad: Parent device node
431 * unflattens the device-tree passed by the firmware, creating the
433 * pointers of the nodes so the normal device-tree walking functions
466 * fdt_reserve_elfcorehdr() - reserves memory for elf core header
470 * information about primary kernel's core image and is used by a dump
490 * early_init_fdt_scan_reserved_mem() - create reserved memory regions
522 * early_init_fdt_reserve_self() - reserve the memory used by the FDT blob
535 * of_scan_flat_dt - scan flattened tree blob and call callback on each.
539 * This function is used to scan the flattened device-tree, it is
543 int __init of_scan_flat_dt(int (*it)(unsigned long node, in of_scan_flat_dt() argument
550 int offset, rc = 0, depth = -1; in of_scan_flat_dt()
555 for (offset = fdt_next_node(blob, -1, &depth); in of_scan_flat_dt()
566 * of_scan_flat_dt_subnodes - scan sub-nodes of a node call callback on each.
567 * @parent: parent node
571 * This function is used to scan sub-nodes of a node.
574 int (*it)(unsigned long node, in of_scan_flat_dt_subnodes() argument
580 int node; in of_scan_flat_dt_subnodes() local
582 fdt_for_each_subnode(node, blob, parent) { in of_scan_flat_dt_subnodes()
586 pathp = fdt_get_name(blob, node, NULL); in of_scan_flat_dt_subnodes()
587 rc = it(node, pathp, data); in of_scan_flat_dt_subnodes()
595 * of_get_flat_dt_subnode_by_name - get the subnode by given name
597 * @node: the parent node
599 * @return offset of the subnode, or -FDT_ERR_NOTFOUND if there is none
602 int __init of_get_flat_dt_subnode_by_name(unsigned long node, const char *uname) in of_get_flat_dt_subnode_by_name() argument
604 return fdt_subnode_offset(initial_boot_params, node, uname); in of_get_flat_dt_subnode_by_name()
608 * of_get_flat_dt_root - find the root node in the flat blob
616 * of_get_flat_dt_prop - Given a node in the flat blob, return the property ptr
621 const void *__init of_get_flat_dt_prop(unsigned long node, const char *name, in of_get_flat_dt_prop() argument
624 return fdt_getprop(initial_boot_params, node, name, size); in of_get_flat_dt_prop()
628 * of_fdt_is_compatible - Return true if given node from the given blob has
630 * @blob: A device tree blob
631 * @node: node to test
634 * Return: a non-zero value on match with smaller values returned for more
638 unsigned long node, const char *compat) in of_fdt_is_compatible() argument
644 cp = fdt_getprop(blob, node, "compatible", &cplen); in of_fdt_is_compatible()
653 cplen -= l; in of_fdt_is_compatible()
660 * of_flat_dt_is_compatible - Return true if given node has compat in compatible list
661 * @node: node to test
664 int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) in of_flat_dt_is_compatible() argument
666 return of_fdt_is_compatible(initial_boot_params, node, compat); in of_flat_dt_is_compatible()
670 * of_flat_dt_match - Return true if node matches a list of compatible values
672 static int __init of_flat_dt_match(unsigned long node, const char *const *compat) in of_flat_dt_match() argument
680 tmp = of_fdt_is_compatible(initial_boot_params, node, *compat); in of_flat_dt_match()
690 * of_get_flat_dt_phandle - Given a node in the flat blob, return the phandle
692 uint32_t __init of_get_flat_dt_phandle(unsigned long node) in of_get_flat_dt_phandle() argument
694 return fdt_get_phandle(initial_boot_params, node); in of_get_flat_dt_phandle()
709 * of_flat_dt_match_machine - Iterate match tables to find matching machine.
711 * @default_match: A machine specific ptr to return in case of no match.
744 size -= strlen(prop) + 1; in of_flat_dt_match_machine()
774 * early_init_dt_check_for_initrd - Decode initrd location from flat tree
775 * @node: reference to node containing initrd location ('chosen')
777 static void __init early_init_dt_check_for_initrd(unsigned long node) in early_init_dt_check_for_initrd() argument
788 prop = of_get_flat_dt_prop(node, "linux,initrd-start", &len); in early_init_dt_check_for_initrd()
793 prop = of_get_flat_dt_prop(node, "linux,initrd-end", &len); in early_init_dt_check_for_initrd()
802 phys_initrd_size = end - start; in early_init_dt_check_for_initrd()
808 * early_init_dt_check_for_elfcorehdr - Decode elfcorehdr location from flat
810 * @node: reference to node containing elfcorehdr location ('chosen')
812 static void __init early_init_dt_check_for_elfcorehdr(unsigned long node) in early_init_dt_check_for_elfcorehdr() argument
820 pr_debug("Looking for elfcorehdr property... "); in early_init_dt_check_for_elfcorehdr()
822 prop = of_get_flat_dt_prop(node, "linux,elfcorehdr", &len); in early_init_dt_check_for_elfcorehdr()
833 static unsigned long chosen_node_offset = -FDT_ERR_NOTFOUND;
836 * The main usage of linux,usable-memory-range is for crash dump kernel.
837 * Originally, the number of usable-memory regions is one. Now there may
839 * To make compatibility with existing user-space and older kdump, the low
840 * region is always the last range of linux,usable-memory-range if exist.
845 * early_init_dt_check_for_usable_mem_range - Decode usable memory range
853 unsigned long node = chosen_node_offset; in early_init_dt_check_for_usable_mem_range() local
855 if ((long)node < 0) in early_init_dt_check_for_usable_mem_range()
858 pr_debug("Looking for usable-memory-range property... "); in early_init_dt_check_for_usable_mem_range()
860 prop = of_get_flat_dt_prop(node, "linux,usable-memory-range", &len); in early_init_dt_check_for_usable_mem_range()
893 return -ENOENT; in early_init_dt_scan_chosen_stdout()
895 p = fdt_getprop(fdt, offset, "stdout-path", &l); in early_init_dt_scan_chosen_stdout()
897 p = fdt_getprop(fdt, offset, "linux,stdout-path", &l); in early_init_dt_scan_chosen_stdout()
899 return -ENOENT; in early_init_dt_scan_chosen_stdout()
904 l = q - p; in early_init_dt_scan_chosen_stdout()
906 /* Get the node specified by stdout-path */ in early_init_dt_scan_chosen_stdout()
909 pr_warn("earlycon: stdout-path %.*s not found\n", l, p); in early_init_dt_scan_chosen_stdout()
914 if (!match->compatible[0]) in early_init_dt_scan_chosen_stdout()
917 if (fdt_node_check_compatible(fdt, offset, match->compatible)) in early_init_dt_scan_chosen_stdout()
921 if (!ret || ret == -EALREADY) in early_init_dt_scan_chosen_stdout()
924 return -ENODEV; in early_init_dt_scan_chosen_stdout()
929 * early_init_dt_scan_root - fetch the top level address and size cells
935 int node = fdt_path_offset(fdt, "/"); in early_init_dt_scan_root() local
937 if (node < 0) in early_init_dt_scan_root()
938 return -ENODEV; in early_init_dt_scan_root()
943 prop = of_get_flat_dt_prop(node, "#size-cells", NULL); in early_init_dt_scan_root()
944 if (!WARN(!prop, "No '#size-cells' in root node\n")) in early_init_dt_scan_root()
948 prop = of_get_flat_dt_prop(node, "#address-cells", NULL); in early_init_dt_scan_root()
949 if (!WARN(!prop, "No '#address-cells' in root node\n")) in early_init_dt_scan_root()
965 * early_init_dt_scan_memory - Look for and parse memory nodes
969 int node, found_memory = 0; in early_init_dt_scan_memory() local
972 fdt_for_each_subnode(node, fdt, 0) { in early_init_dt_scan_memory()
973 const char *type = of_get_flat_dt_prop(node, "device_type", NULL); in early_init_dt_scan_memory()
982 if (!of_fdt_device_is_available(fdt, node)) in early_init_dt_scan_memory()
985 reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l); in early_init_dt_scan_memory()
987 reg = of_get_flat_dt_prop(node, "reg", &l); in early_init_dt_scan_memory()
992 hotpluggable = of_get_flat_dt_prop(node, "hotpluggable", NULL); in early_init_dt_scan_memory()
994 pr_debug("memory scan node %s, reg size %d,\n", in early_init_dt_scan_memory()
995 fdt_get_name(fdt, node, NULL), l); in early_init_dt_scan_memory()
997 while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) { in early_init_dt_scan_memory()
1005 pr_debug(" - %llx, %llx\n", base, size); in early_init_dt_scan_memory()
1015 pr_warn("failed to mark hotplug range 0x%llx - 0x%llx\n", in early_init_dt_scan_memory()
1024 int l, node; in early_init_dt_scan_chosen() local
1029 node = fdt_path_offset(fdt, "/chosen"); in early_init_dt_scan_chosen()
1030 if (node < 0) in early_init_dt_scan_chosen()
1031 node = fdt_path_offset(fdt, "/chosen@0"); in early_init_dt_scan_chosen()
1032 if (node < 0) in early_init_dt_scan_chosen()
1033 /* Handle the cmdline config options even if no /chosen node */ in early_init_dt_scan_chosen()
1036 chosen_node_offset = node; in early_init_dt_scan_chosen()
1038 early_init_dt_check_for_initrd(node); in early_init_dt_scan_chosen()
1039 early_init_dt_check_for_elfcorehdr(node); in early_init_dt_scan_chosen()
1041 rng_seed = of_get_flat_dt_prop(node, "rng-seed", &l); in early_init_dt_scan_chosen()
1046 fdt_nop_property(initial_boot_params, node, "rng-seed"); in early_init_dt_scan_chosen()
1054 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()
1093 if (size < PAGE_SIZE - (base & ~PAGE_MASK)) { in early_init_dt_add_memory_arch()
1094 pr_warn("Ignoring memory block 0x%llx - 0x%llx\n", in early_init_dt_add_memory_arch()
1100 size -= PAGE_SIZE - (base & ~PAGE_MASK); in early_init_dt_add_memory_arch()
1106 pr_warn("Ignoring memory block 0x%llx - 0x%llx\n", in early_init_dt_add_memory_arch()
1111 if (base + size - 1 > MAX_MEMBLOCK_ADDR) { in early_init_dt_add_memory_arch()
1112 pr_warn("Ignoring memory range 0x%llx - 0x%llx\n", in early_init_dt_add_memory_arch()
1114 size = MAX_MEMBLOCK_ADDR - base + 1; in early_init_dt_add_memory_arch()
1118 pr_warn("Ignoring memory block 0x%llx - 0x%llx\n", in early_init_dt_add_memory_arch()
1123 pr_warn("Ignoring memory range 0x%llx - 0x%llx\n", in early_init_dt_add_memory_arch()
1125 size -= phys_offset - base; in early_init_dt_add_memory_arch()
1145 /* Setup flat device-tree pointer */ in early_init_dt_verify()
1151 /* Initialize {size,address}-cells info */ in early_init_dt_verify()
1162 /* Retrieve various information from the /chosen node */ in early_init_dt_scan_nodes()
1165 pr_warn("No chosen node found, continuing without\n"); in early_init_dt_scan_nodes()
1170 /* Handle linux,usable-memory-range property */ in early_init_dt_scan_nodes()
1202 * unflatten_device_tree - create tree of device_nodes from flat blob
1204 * unflattens the device-tree passed by the firmware, creating the
1206 * pointers of the nodes so the normal device-tree walking functions
1213 /* Save the statically-placed regions in the reserved_mem array */ in unflatten_device_tree()
1216 /* Populate an empty root node when bootloader doesn't provide one */ in unflatten_device_tree()
1221 __dtb_empty_root_end - __dtb_empty_root_begin) { in unflatten_device_tree()
1239 * unflatten_and_copy_device_tree - copy and create tree of device_nodes from flat blob
1241 * Copies and unflattens the device-tree passed by the firmware, creating the
1243 * pointers of the nodes so the normal device-tree walking functions
1245 * reserved such is the case when the FDT is built-in to the kernel init