pm_domain.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Runtime PM support code for DaVinci
  3. *
  4. * Author: Kevin Hilman
  5. *
  6. * Copyright (C) 2012 Texas Instruments, Inc.
  7. *
  8. * This file is licensed under the terms of the GNU General Public
  9. * License version 2. This program is licensed "as is" without any
  10. * warranty of any kind, whether express or implied.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/pm_runtime.h>
  14. #include <linux/pm_clock.h>
  15. #include <linux/platform_device.h>
  16. #ifdef CONFIG_PM_RUNTIME
  17. static int davinci_pm_runtime_suspend(struct device *dev)
  18. {
  19. int ret;
  20. dev_dbg(dev, "%s\n", __func__);
  21. ret = pm_generic_runtime_suspend(dev);
  22. if (ret)
  23. return ret;
  24. ret = pm_clk_suspend(dev);
  25. if (ret) {
  26. pm_generic_runtime_resume(dev);
  27. return ret;
  28. }
  29. return 0;
  30. }
  31. static int davinci_pm_runtime_resume(struct device *dev)
  32. {
  33. dev_dbg(dev, "%s\n", __func__);
  34. pm_clk_resume(dev);
  35. return pm_generic_runtime_resume(dev);
  36. }
  37. #endif
  38. static struct dev_pm_domain davinci_pm_domain = {
  39. .ops = {
  40. SET_RUNTIME_PM_OPS(davinci_pm_runtime_suspend,
  41. davinci_pm_runtime_resume, NULL)
  42. USE_PLATFORM_PM_SLEEP_OPS
  43. },
  44. };
  45. static struct pm_clk_notifier_block platform_bus_notifier = {
  46. .pm_domain = &davinci_pm_domain,
  47. };
  48. static int __init davinci_pm_runtime_init(void)
  49. {
  50. pm_clk_add_notifier(&platform_bus_type, &platform_bus_notifier);
  51. return 0;
  52. }
  53. core_initcall(davinci_pm_runtime_init);