musb_am335x.c 1.2 KB

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