Lines Matching +full:child +full:- +full:nodes
1 // SPDX-License-Identifier: GPL-2.0+
16 #include <linux/dma-mapping.h>
25 { .compatible = "simple-bus", },
26 { .compatible = "simple-mfd", },
29 { .compatible = "arm,amba-bus", },
35 { .compatible = "operating-points-v2", },
40 * of_find_device_by_node - Find the platform_device associated with a node
63 * mechanism for creating devices from device tree nodes.
67 * of_device_make_bus_id - Use the device node data to assign a unique name
72 * parent nodes until a unique name can be derived.
76 struct device_node *node = dev->of_node; in of_device_make_bus_id()
80 /* Construct the name, using parent nodes if necessary to ensure uniqueness */ in of_device_make_bus_id()
81 while (node->parent) { in of_device_make_bus_id()
95 kbasename(node->full_name), dev_name(dev)); in of_device_make_bus_id()
96 node = node->parent; in of_device_make_bus_id()
101 * of_device_alloc - Allocate and initialize an of_device
131 dev->num_resources = num_reg + num_irq; in of_device_alloc()
132 dev->resource = res; in of_device_alloc()
142 dev->dev.of_node = of_node_get(np); in of_device_alloc()
143 dev->dev.fwnode = &np->fwnode; in of_device_alloc()
144 dev->dev.parent = parent ? : &platform_bus; in of_device_alloc()
147 dev_set_name(&dev->dev, "%s", bus_id); in of_device_alloc()
149 of_device_make_bus_id(&dev->dev); in of_device_alloc()
156 * of_platform_device_create_pdata - Alloc, initialize and register an of_device
181 dev->dev.coherent_dma_mask = DMA_BIT_MASK(32); in of_platform_device_create_pdata()
182 if (!dev->dev.dma_mask) in of_platform_device_create_pdata()
183 dev->dev.dma_mask = &dev->dev.coherent_dma_mask; in of_platform_device_create_pdata()
184 dev->dev.bus = &platform_bus_type; in of_platform_device_create_pdata()
185 dev->dev.platform_data = platform_data; in of_platform_device_create_pdata()
186 of_msi_configure(&dev->dev, dev->dev.of_node); in of_platform_device_create_pdata()
201 * of_platform_device_create - Alloc, initialize and register an of_device
238 dev->dev.coherent_dma_mask = DMA_BIT_MASK(32); in of_amba_device_create()
239 dev->dev.dma_mask = &dev->dev.coherent_dma_mask; in of_amba_device_create()
242 dev->dev.of_node = of_node_get(node); in of_amba_device_create()
243 dev->dev.fwnode = &node->fwnode; in of_amba_device_create()
244 dev->dev.parent = parent ? : &platform_bus; in of_amba_device_create()
245 dev->dev.platform_data = platform_data; in of_amba_device_create()
247 dev_set_name(&dev->dev, "%s", bus_id); in of_amba_device_create()
249 of_device_make_bus_id(&dev->dev); in of_amba_device_create()
252 prop = of_get_property(node, "arm,primecell-periphid", NULL); in of_amba_device_create()
254 dev->periphid = of_read_ulong(prop, 1); in of_amba_device_create()
258 dev->irq[i] = irq_of_parse_and_map(node, i); in of_amba_device_create()
260 ret = of_address_to_resource(node, 0, &dev->res); in of_amba_device_create()
293 * of_dev_lookup() - Given a device node, lookup the preferred Linux name
306 for (; auxdata->compatible; auxdata++) { in of_dev_lookup()
307 if (!of_device_is_compatible(np, auxdata->compatible)) in of_dev_lookup()
311 if (res.start != auxdata->phys_addr) in of_dev_lookup()
313 pr_debug("%pOF: devname=%s\n", np, auxdata->name); in of_dev_lookup()
322 for (; auxdata->compatible; auxdata++) { in of_dev_lookup()
323 if (!of_device_is_compatible(np, auxdata->compatible)) in of_dev_lookup()
325 if (!auxdata->phys_addr && !auxdata->name) { in of_dev_lookup()
335 * of_platform_bus_create() - Create a device for a node and its children.
337 * @matches: match table for bus nodes
338 * @lookup: auxdata table for matching id and platform_data with device nodes
343 * recursively create devices for all the child nodes.
351 struct device_node *child; in of_platform_bus_create() local
359 pr_debug("%s() - skipping %pOF, no compatible prop\n", in of_platform_bus_create()
364 /* Skip nodes for which we don't want to create devices */ in of_platform_bus_create()
366 pr_debug("%s() - skipping %pOF node\n", __func__, bus); in of_platform_bus_create()
371 pr_debug("%s() - skipping %pOF, already populated\n", in of_platform_bus_create()
378 bus_id = auxdata->name; in of_platform_bus_create()
379 platform_data = auxdata->platform_data; in of_platform_bus_create()
395 for_each_child_of_node(bus, child) { in of_platform_bus_create()
396 pr_debug(" create child: %pOF\n", child); in of_platform_bus_create()
397 rc = of_platform_bus_create(child, matches, lookup, &dev->dev, strict); in of_platform_bus_create()
399 of_node_put(child); in of_platform_bus_create()
408 * of_platform_bus_probe() - Probe the device-tree for platform buses
410 * @matches: match table for bus nodes
420 struct device_node *child; in of_platform_bus_probe() local
425 return -EINVAL; in of_platform_bus_probe()
433 } else for_each_child_of_node(root, child) { in of_platform_bus_probe()
434 if (!of_match_node(matches, child)) in of_platform_bus_probe()
436 rc = of_platform_bus_create(child, matches, NULL, parent, false); in of_platform_bus_probe()
438 of_node_put(child); in of_platform_bus_probe()
449 * of_platform_populate() - Populate platform_devices from device tree data
452 * @lookup: auxdata table for matching id and platform_data with device nodes
456 * and creates devices from nodes. It differs in that it follows the modern
457 * convention of requiring all device nodes to have a 'compatible' property,
472 struct device_node *child; in of_platform_populate() local
477 return -EINVAL; in of_platform_populate()
483 for_each_child_of_node(root, child) { in of_platform_populate()
484 rc = of_platform_bus_create(child, matches, lookup, parent, true); in of_platform_populate()
486 of_node_put(child); in of_platform_populate()
510 { .compatible = "qcom,rmtfs-mem" },
511 { .compatible = "qcom,cmd-db" },
513 { .compatible = "nvmem-rmem" },
524 return -ENODEV; in of_platform_default_populate_init()
528 * platform_devices for every node in /reserved-memory with a in of_platform_default_populate_init()
558 if (!dev->of_node || !of_node_check_flag(dev->of_node, OF_POPULATED)) in of_platform_device_destroy()
561 /* Recurse for any nodes that were treated as busses */ in of_platform_device_destroy()
562 if (of_node_check_flag(dev->of_node, OF_POPULATED_BUS)) in of_platform_device_destroy()
565 of_node_clear_flag(dev->of_node, OF_POPULATED); in of_platform_device_destroy()
566 of_node_clear_flag(dev->of_node, OF_POPULATED_BUS); in of_platform_device_destroy()
568 if (dev->bus == &platform_bus_type) in of_platform_device_destroy()
571 else if (dev->bus == &amba_bustype) in of_platform_device_destroy()
580 * of_platform_depopulate() - Remove devices populated from device tree
585 * created from their respective device tree nodes (and only those,
586 * leaving others - eg. manually created - unharmed).
590 if (parent->of_node && of_node_check_flag(parent->of_node, OF_POPULATED_BUS)) { in of_platform_depopulate()
592 of_node_clear_flag(parent->of_node, OF_POPULATED_BUS); in of_platform_depopulate()
603 * devm_of_platform_populate() - Populate platform_devices from device tree data
617 return -EINVAL; in devm_of_platform_populate()
622 return -ENOMEM; in devm_of_platform_populate()
624 ret = of_platform_populate(dev->of_node, NULL, NULL, dev); in devm_of_platform_populate()
649 * devm_of_platform_depopulate() - Remove devices populated from device tree
654 * created from their respective device tree nodes (and only those,
655 * leaving others - eg. manually created - unharmed).
679 if (!of_node_check_flag(rd->dn->parent, OF_POPULATED_BUS)) in of_platform_notify()
683 if (of_node_check_flag(rd->dn, OF_POPULATED)) in of_platform_notify()
687 pdev_parent = of_find_device_by_node(rd->dn->parent); in of_platform_notify()
688 pdev = of_platform_device_create(rd->dn, NULL, in of_platform_notify()
689 pdev_parent ? &pdev_parent->dev : NULL); in of_platform_notify()
694 __func__, rd->dn); in of_platform_notify()
696 return notifier_from_errno(-EINVAL); in of_platform_notify()
703 if (!of_node_check_flag(rd->dn, OF_POPULATED)) in of_platform_notify()
707 pdev = of_find_device_by_node(rd->dn); in of_platform_notify()
712 of_platform_device_destroy(&pdev->dev, &children_left); in of_platform_notify()