simple-pm-bus.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Simple Power-Managed Bus Driver
  3. *
  4. * Copyright (C) 2014-2015 Glider bvba
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/module.h>
  11. #include <linux/of_platform.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/pm_runtime.h>
  14. static int simple_pm_bus_probe(struct platform_device *pdev)
  15. {
  16. struct device_node *np = pdev->dev.of_node;
  17. dev_dbg(&pdev->dev, "%s\n", __func__);
  18. pm_runtime_enable(&pdev->dev);
  19. if (np)
  20. of_platform_populate(np, NULL, NULL, &pdev->dev);
  21. return 0;
  22. }
  23. static int simple_pm_bus_remove(struct platform_device *pdev)
  24. {
  25. dev_dbg(&pdev->dev, "%s\n", __func__);
  26. pm_runtime_disable(&pdev->dev);
  27. return 0;
  28. }
  29. static const struct of_device_id simple_pm_bus_of_match[] = {
  30. { .compatible = "simple-pm-bus", },
  31. { /* sentinel */ }
  32. };
  33. MODULE_DEVICE_TABLE(of, simple_pm_bus_of_match);
  34. static struct platform_driver simple_pm_bus_driver = {
  35. .probe = simple_pm_bus_probe,
  36. .remove = simple_pm_bus_remove,
  37. .driver = {
  38. .name = "simple-pm-bus",
  39. .of_match_table = simple_pm_bus_of_match,
  40. },
  41. };
  42. module_platform_driver(simple_pm_bus_driver);
  43. MODULE_DESCRIPTION("Simple Power-Managed Bus Driver");
  44. MODULE_AUTHOR("Geert Uytterhoeven <geert+renesas@glider.be>");
  45. MODULE_LICENSE("GPL v2");