musb_am335x.c 1.2 KB

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