Lines Matching +full:a +full:- +full:child +full:- +full:node +full:- +full:property
1 // SPDX-License-Identifier: GPL-2.0
43 * of_fdt_limit_memory - limit the number of regions in the /memory node
47 * memory entries in the /memory node. This function may be called
69 bool of_fdt_device_is_available(const void *blob, unsigned long node) in of_fdt_device_is_available() argument
71 const char *status = fdt_getprop(blob, node, "status", NULL); in of_fdt_device_is_available()
101 struct property *pp, **pprev = NULL; in populate_properties()
105 pprev = &np->properties; in populate_properties()
115 pr_warn("Cannot locate property at 0x%x\n", cur); in populate_properties()
120 pr_warn("Cannot find property name at 0x%x\n", cur); in populate_properties()
127 pp = unflatten_dt_alloc(mem, sizeof(struct property), in populate_properties()
128 __alignof__(struct property)); 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()
144 /* And we process the "ibm,phandle" property 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()
158 /* With version 0x10 we may not have the name property, in populate_properties()
175 len = (pa - ps) + 1; in populate_properties()
176 pp = unflatten_dt_alloc(mem, sizeof(struct property) + len, in populate_properties()
177 __alignof__(struct property)); 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()
239 struct device_node *child, *next; in reverse_nodes() local
241 /* In-depth first */ in reverse_nodes()
242 child = parent->child; in reverse_nodes()
243 while (child) { in reverse_nodes()
244 reverse_nodes(child); in reverse_nodes()
246 child = child->sibling; in reverse_nodes()
249 /* Reverse the nodes in the child list */ in reverse_nodes()
250 child = parent->child; in reverse_nodes()
251 parent->child = NULL; in reverse_nodes()
252 while (child) { 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()
257 child = next; in reverse_nodes()
262 * unflatten_dt_nodes - Alloc and populate a device_node from the flat tree
287 * We're unflattening device sub-tree if @dad is valid. There are 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()
326 * Reverse the child list. Some drivers assumes node order matches .dts in unflatten_dt_nodes()
327 * node order 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
340 * @dt_alloc: An allocator that provides a virtual address to memory
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
364 pr_debug(" -> unflatten_device_tree()\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
429 * @dad: Parent device node
432 * unflattens the device-tree passed by the firmware, creating the
434 * pointers of the nodes so the normal device-tree walking functions
467 * fdt_reserve_elfcorehdr() - reserves memory for elf core header
471 * information about primary kernel's core image and is used by a dump
491 * early_init_fdt_scan_reserved_mem() - create reserved memory regions
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
544 int __init of_scan_flat_dt(int (*it)(unsigned long node, in of_scan_flat_dt() argument
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.
568 * @parent: parent node
572 * This function is used to scan sub-nodes of a node.
575 int (*it)(unsigned long node, in of_scan_flat_dt_subnodes() argument
581 int node; in of_scan_flat_dt_subnodes() local
583 fdt_for_each_subnode(node, blob, parent) { in of_scan_flat_dt_subnodes()
587 pathp = fdt_get_name(blob, node, NULL); in of_scan_flat_dt_subnodes()
588 rc = it(node, pathp, data); in of_scan_flat_dt_subnodes()
596 * of_get_flat_dt_subnode_by_name - get the subnode by given name
598 * @node: the parent node
600 * @return offset of the subnode, or -FDT_ERR_NOTFOUND if there is none
603 int __init of_get_flat_dt_subnode_by_name(unsigned long node, const char *uname) in of_get_flat_dt_subnode_by_name() argument
605 return fdt_subnode_offset(initial_boot_params, node, uname); in of_get_flat_dt_subnode_by_name()
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
622 const void *__init of_get_flat_dt_prop(unsigned long node, const char *name, in of_get_flat_dt_prop() argument
625 return fdt_getprop(initial_boot_params, node, name, size); in of_get_flat_dt_prop()
629 * of_fdt_is_compatible - Return true if given node from the given blob has
631 * @blob: A device tree blob
632 * @node: node to test
635 * Return: a non-zero value on match with smaller values returned for more
639 unsigned long node, const char *compat) in of_fdt_is_compatible() argument
645 cp = fdt_getprop(blob, node, "compatible", &cplen); in of_fdt_is_compatible()
654 cplen -= l; in of_fdt_is_compatible()
661 * of_flat_dt_is_compatible - Return true if given node has compat in compatible list
662 * @node: node to test
665 int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) in of_flat_dt_is_compatible() argument
667 return of_fdt_is_compatible(initial_boot_params, node, compat); in of_flat_dt_is_compatible()
671 * of_flat_dt_match - Return true if node matches a list of compatible values
673 static int __init of_flat_dt_match(unsigned long node, const char *const *compat) in of_flat_dt_match() argument
681 tmp = of_fdt_is_compatible(initial_boot_params, node, *compat); in of_flat_dt_match()
691 * of_get_flat_dt_phandle - Given a node in the flat blob, return the phandle
693 uint32_t __init of_get_flat_dt_phandle(unsigned long node) in of_get_flat_dt_phandle() argument
695 return fdt_get_phandle(initial_boot_params, node); in of_get_flat_dt_phandle()
710 * of_flat_dt_match_machine - Iterate match tables to find matching machine.
712 * @default_match: A machine specific ptr to return in case of no match.
745 size -= strlen(prop) + 1; in of_flat_dt_match_machine()
775 * early_init_dt_check_for_initrd - Decode initrd location from flat tree
776 * @node: reference to node containing initrd location ('chosen')
778 static void __init early_init_dt_check_for_initrd(unsigned long node) in early_init_dt_check_for_initrd() argument
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
811 * @node: reference to node containing elfcorehdr location ('chosen')
813 static void __init early_init_dt_check_for_elfcorehdr(unsigned long node) in early_init_dt_check_for_elfcorehdr() argument
821 pr_debug("Looking for elfcorehdr property... "); in early_init_dt_check_for_elfcorehdr()
823 prop = of_get_flat_dt_prop(node, "linux,elfcorehdr", &len); in early_init_dt_check_for_elfcorehdr()
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
854 unsigned long node = chosen_node_offset; in early_init_dt_check_for_usable_mem_range() local
856 if ((long)node < 0) in early_init_dt_check_for_usable_mem_range()
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
884 unsigned long node = chosen_node_offset; in early_init_dt_check_kho() local
889 if (!IS_ENABLED(CONFIG_KEXEC_HANDOVER) || (long)node < 0) in early_init_dt_check_kho()
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
966 int node = fdt_path_offset(fdt, "/"); in early_init_dt_scan_root() local
968 if (node < 0) in early_init_dt_scan_root()
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
1000 int node, found_memory = 0; in early_init_dt_scan_memory() local
1003 fdt_for_each_subnode(node, fdt, 0) { in early_init_dt_scan_memory()
1004 const char *type = of_get_flat_dt_prop(node, "device_type", NULL); in early_init_dt_scan_memory()
1013 if (!of_fdt_device_is_available(fdt, node)) in early_init_dt_scan_memory()
1016 reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l); in early_init_dt_scan_memory()
1018 reg = of_get_flat_dt_prop(node, "reg", &l); in early_init_dt_scan_memory()
1023 hotpluggable = of_get_flat_dt_prop(node, "hotpluggable", NULL); in early_init_dt_scan_memory()
1025 pr_debug("memory scan node %s, reg size %d,\n", in early_init_dt_scan_memory()
1026 fdt_get_name(fdt, node, NULL), 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()
1055 int l, node; in early_init_dt_scan_chosen() local
1060 node = fdt_path_offset(fdt, "/chosen"); in early_init_dt_scan_chosen()
1061 if (node < 0) in early_init_dt_scan_chosen()
1062 node = fdt_path_offset(fdt, "/chosen@0"); in early_init_dt_scan_chosen()
1063 if (node < 0) in early_init_dt_scan_chosen()
1064 /* Handle the cmdline config options even if no /chosen node */ in early_init_dt_scan_chosen()
1067 chosen_node_offset = node; in early_init_dt_scan_chosen()
1069 early_init_dt_check_for_initrd(node); in early_init_dt_scan_chosen()
1070 early_init_dt_check_for_elfcorehdr(node); in early_init_dt_scan_chosen()
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()
1085 p = of_get_flat_dt_prop(node, "bootargs", &l); in early_init_dt_scan_chosen()
1091 * CONFIG_CMDLINE is meant to be a default in case nothing else 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()
1176 /* Setup flat device-tree pointer */ in early_init_dt_verify()
1182 /* Initialize {size,address}-cells info */ in early_init_dt_verify()
1193 /* Retrieve various information from the /chosen node */ in early_init_dt_scan_nodes()
1196 pr_warn("No chosen node found, continuing without\n"); in early_init_dt_scan_nodes()
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
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()
1250 /* Populate an empty root node when bootloader doesn't provide one */ 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
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