Lines Matching +full:child +full:- +full:nodes
1 // SPDX-License-Identifier: GPL-2.0+
16 #include <linux/dma-mapping.h>
27 { .compatible = "simple-bus", },
28 { .compatible = "simple-mfd", },
31 { .compatible = "arm,amba-bus", },
37 * of_find_device_by_node - Find the platform_device associated with a node
56 BUG_ON(ofdev->dev.of_node == NULL); in of_device_add()
60 ofdev->name = dev_name(&ofdev->dev); in of_device_add()
61 ofdev->id = PLATFORM_DEVID_NONE; in of_device_add()
68 set_dev_node(&ofdev->dev, of_node_to_nid(ofdev->dev.of_node)); in of_device_add()
70 return device_add(&ofdev->dev); in of_device_add()
75 device_initialize(&pdev->dev); in of_device_register()
82 device_unregister(&ofdev->dev); in of_device_unregister()
88 { .compatible = "operating-points-v2", },
97 * mechanism for creating devices from device tree nodes.
101 * of_device_make_bus_id - Use the device node data to assign a unique name
106 * parent nodes until a unique name can be derived.
110 struct device_node *node = dev->of_node; in of_device_make_bus_id()
115 /* Construct the name, using parent nodes if necessary to ensure uniqueness */ in of_device_make_bus_id()
116 while (node->parent) { in of_device_make_bus_id()
125 addr, ffs(mask) - 1, node, dev_name(dev)); in of_device_make_bus_id()
135 kbasename(node->full_name), dev_name(dev)); in of_device_make_bus_id()
136 node = node->parent; in of_device_make_bus_id()
141 * of_device_alloc - Allocate and initialize an of_device
169 dev->num_resources = num_reg; in of_device_alloc()
170 dev->resource = res; in of_device_alloc()
178 device_set_node(&dev->dev, of_fwnode_handle(of_node_get(np))); in of_device_alloc()
179 dev->dev.parent = parent ? : &platform_bus; in of_device_alloc()
182 dev_set_name(&dev->dev, "%s", bus_id); in of_device_alloc()
184 of_device_make_bus_id(&dev->dev); in of_device_alloc()
191 * of_platform_device_create_pdata - Alloc, initialize and register an of_device
216 dev->dev.coherent_dma_mask = DMA_BIT_MASK(32); in of_platform_device_create_pdata()
217 if (!dev->dev.dma_mask) in of_platform_device_create_pdata()
218 dev->dev.dma_mask = &dev->dev.coherent_dma_mask; in of_platform_device_create_pdata()
219 dev->dev.bus = &platform_bus_type; in of_platform_device_create_pdata()
220 dev->dev.platform_data = platform_data; in of_platform_device_create_pdata()
221 of_msi_configure(&dev->dev, dev->dev.of_node); in of_platform_device_create_pdata()
236 * of_platform_device_create - Alloc, initialize and register an of_device
272 dev->dev.coherent_dma_mask = DMA_BIT_MASK(32); in of_amba_device_create()
273 dev->dev.dma_mask = &dev->dev.coherent_dma_mask; in of_amba_device_create()
276 device_set_node(&dev->dev, of_fwnode_handle(of_node_get(node))); in of_amba_device_create()
277 dev->dev.parent = parent ? : &platform_bus; in of_amba_device_create()
278 dev->dev.platform_data = platform_data; in of_amba_device_create()
280 dev_set_name(&dev->dev, "%s", bus_id); in of_amba_device_create()
282 of_device_make_bus_id(&dev->dev); in of_amba_device_create()
285 of_property_read_u32(node, "arm,primecell-periphid", &dev->periphid); in of_amba_device_create()
287 ret = of_address_to_resource(node, 0, &dev->res); in of_amba_device_create()
320 * of_dev_lookup() - Given a device node, lookup the preferred Linux name
333 for (; auxdata->compatible; auxdata++) { in of_dev_lookup()
334 if (!of_device_is_compatible(np, auxdata->compatible)) in of_dev_lookup()
338 if (res.start != auxdata->phys_addr) in of_dev_lookup()
340 pr_debug("%pOF: devname=%s\n", np, auxdata->name); in of_dev_lookup()
349 for (; auxdata->compatible; auxdata++) { in of_dev_lookup()
350 if (!of_device_is_compatible(np, auxdata->compatible)) in of_dev_lookup()
352 if (!auxdata->phys_addr && !auxdata->name) { in of_dev_lookup()
362 * of_platform_bus_create() - Create a device for a node and its children.
364 * @matches: match table for bus nodes
365 * @lookup: auxdata table for matching id and platform_data with device nodes
370 * recursively create devices for all the child nodes.
378 struct device_node *child; in of_platform_bus_create() local
386 pr_debug("%s() - skipping %pOF, no compatible prop\n", in of_platform_bus_create()
391 /* Skip nodes for which we don't want to create devices */ in of_platform_bus_create()
393 pr_debug("%s() - skipping %pOF node\n", __func__, bus); in of_platform_bus_create()
398 pr_debug("%s() - skipping %pOF, already populated\n", in of_platform_bus_create()
405 bus_id = auxdata->name; in of_platform_bus_create()
406 platform_data = auxdata->platform_data; in of_platform_bus_create()
422 for_each_child_of_node(bus, child) { in of_platform_bus_create()
423 pr_debug(" create child: %pOF\n", child); in of_platform_bus_create()
424 rc = of_platform_bus_create(child, matches, lookup, &dev->dev, strict); in of_platform_bus_create()
426 of_node_put(child); in of_platform_bus_create()
435 * of_platform_bus_probe() - Probe the device-tree for platform buses
437 * @matches: match table for bus nodes
447 struct device_node *child; in of_platform_bus_probe() local
452 return -EINVAL; in of_platform_bus_probe()
460 } else for_each_child_of_node(root, child) { in of_platform_bus_probe()
461 if (!of_match_node(matches, child)) in of_platform_bus_probe()
463 rc = of_platform_bus_create(child, matches, NULL, parent, false); in of_platform_bus_probe()
465 of_node_put(child); in of_platform_bus_probe()
476 * of_platform_populate() - Populate platform_devices from device tree data
479 * @lookup: auxdata table for matching id and platform_data with device nodes
483 * and creates devices from nodes. It differs in that it follows the modern
484 * convention of requiring all device nodes to have a 'compatible' property,
499 struct device_node *child; in of_platform_populate() local
504 return -EINVAL; in of_platform_populate()
510 for_each_child_of_node(root, child) { in of_platform_populate()
511 rc = of_platform_bus_create(child, matches, lookup, parent, true); in of_platform_populate()
513 of_node_put(child); in of_platform_populate()
537 { .compatible = "qcom,rmtfs-mem" },
538 { .compatible = "qcom,cmd-db" },
541 { .compatible = "nvmem-rmem" },
542 { .compatible = "google,open-dice" },
553 return -ENODEV; in of_platform_default_populate_init()
562 if (of_property_present(of_chosen, "linux,bootx-noscreen")) { in of_platform_default_populate_init()
570 dev = platform_device_alloc("bootx-noscreen", 0); in of_platform_default_populate_init()
572 return -ENOMEM; in of_platform_default_populate_init()
587 !of_get_property(node, "linux,boot-display", NULL)) in of_platform_default_populate_init()
589 dev = of_platform_device_create(node, "of-display", NULL); in of_platform_default_populate_init()
592 return -ENOMEM; in of_platform_default_populate_init()
599 const char *of_display_format = "of-display.%d"; in of_platform_default_populate_init()
611 * platform_devices for every node in /reserved-memory with a in of_platform_default_populate_init()
623 node = of_get_compatible_child(of_chosen, "simple-framebuffer"); in of_platform_default_populate_init()
645 if (!dev->of_node || !of_node_check_flag(dev->of_node, OF_POPULATED)) in of_platform_device_destroy()
648 /* Recurse for any nodes that were treated as busses */ in of_platform_device_destroy()
649 if (of_node_check_flag(dev->of_node, OF_POPULATED_BUS)) in of_platform_device_destroy()
652 of_node_clear_flag(dev->of_node, OF_POPULATED); in of_platform_device_destroy()
653 of_node_clear_flag(dev->of_node, OF_POPULATED_BUS); in of_platform_device_destroy()
655 if (dev->bus == &platform_bus_type) in of_platform_device_destroy()
658 else if (dev->bus == &amba_bustype) in of_platform_device_destroy()
667 * of_platform_depopulate() - Remove devices populated from device tree
672 * created from their respective device tree nodes (and only those,
673 * leaving others - eg. manually created - unharmed).
677 if (parent->of_node && of_node_check_flag(parent->of_node, OF_POPULATED_BUS)) { in of_platform_depopulate()
679 of_node_clear_flag(parent->of_node, OF_POPULATED_BUS); in of_platform_depopulate()
690 * devm_of_platform_populate() - Populate platform_devices from device tree data
704 return -EINVAL; in devm_of_platform_populate()
709 return -ENOMEM; in devm_of_platform_populate()
711 ret = of_platform_populate(dev->of_node, NULL, NULL, dev); in devm_of_platform_populate()
736 * devm_of_platform_depopulate() - Remove devices populated from device tree
741 * created from their respective device tree nodes (and only those,
742 * leaving others - eg. manually created - unharmed).
766 if (!of_node_check_flag(rd->dn->parent, OF_POPULATED_BUS)) in of_platform_notify()
770 if (of_node_check_flag(rd->dn, OF_POPULATED)) in of_platform_notify()
777 rd->dn->fwnode.flags &= ~FWNODE_FLAG_NOT_DEVICE; in of_platform_notify()
779 pdev_parent = of_find_device_by_node(rd->dn->parent); in of_platform_notify()
780 pdev = of_platform_device_create(rd->dn, NULL, in of_platform_notify()
781 pdev_parent ? &pdev_parent->dev : NULL); in of_platform_notify()
786 __func__, rd->dn); in of_platform_notify()
788 return notifier_from_errno(-EINVAL); in of_platform_notify()
795 if (!of_node_check_flag(rd->dn, OF_POPULATED)) in of_platform_notify()
799 pdev = of_find_device_by_node(rd->dn); in of_platform_notify()
804 of_platform_device_destroy(&pdev->dev, &children_left); in of_platform_notify()