Commit | Line | Data |
---|---|---|
97238b35 SAS |
1 | #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 | ||
7 | static 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; | |
18 | err: | |
19 | pm_runtime_disable(&pdev->dev); | |
20 | return ret; | |
21 | } | |
22 | ||
23 | static 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 | ||
31 | static 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 | ||
38 | static const struct of_device_id am335x_child_of_match[] = { | |
39 | { .compatible = "ti,am33xx-usb" }, | |
40 | { }, | |
41 | }; | |
42 | MODULE_DEVICE_TABLE(of, am335x_child_of_match); | |
43 | ||
44 | static 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 | ||
53 | module_platform_driver(am335x_child_driver); | |
54 | MODULE_DESCRIPTION("AM33xx child devices"); | |
55 | MODULE_LICENSE("GPL v2"); |