blob: 41ac5b5b57ceadfdfa5a796c51c4eed445f0f9f1 [file] [log] [blame]
Sebastian Andrzej Siewior97238b32013-07-05 14:51:33 +02001#include <linux/init.h>
2#include <linux/platform_device.h>
3#include <linux/pm_runtime.h>
4#include <linux/module.h>
5#include <linux/of_platform.h>
6
7static int am335x_child_probe(struct platform_device *pdev)
8{
9 int ret;
10
11 pm_runtime_enable(&pdev->dev);
12
13 ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
14 if (ret)
15 goto err;
16
17 return 0;
18err:
19 pm_runtime_disable(&pdev->dev);
20 return ret;
21}
22
23static int of_remove_populated_child(struct device *dev, void *d)
24{
25 struct platform_device *pdev = to_platform_device(dev);
26
27 of_device_unregister(pdev);
28 return 0;
29}
30
31static int am335x_child_remove(struct platform_device *pdev)
32{
33 device_for_each_child(&pdev->dev, NULL, of_remove_populated_child);
34 pm_runtime_disable(&pdev->dev);
35 return 0;
36}
37
38static const struct of_device_id am335x_child_of_match[] = {
39 { .compatible = "ti,am33xx-usb" },
40 { },
41};
42MODULE_DEVICE_TABLE(of, am335x_child_of_match);
43
44static struct platform_driver am335x_child_driver = {
45 .probe = am335x_child_probe,
46 .remove = am335x_child_remove,
47 .driver = {
48 .name = "am335x-usb-childs",
49 .of_match_table = of_match_ptr(am335x_child_of_match),
50 },
51};
52
53module_platform_driver(am335x_child_driver);
54MODULE_DESCRIPTION("AM33xx child devices");
55MODULE_LICENSE("GPL v2");