pm_bus.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Runtime PM support code for OMAP1
  3. *
  4. * Author: Kevin Hilman, Deep Root Systems, LLC
  5. *
  6. * Copyright (C) 2010 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/kernel.h>
  14. #include <linux/io.h>
  15. #include <linux/pm_runtime.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/mutex.h>
  18. #include <linux/clk.h>
  19. #include <linux/err.h>
  20. #include <plat/omap_device.h>
  21. #include <plat/omap-pm.h>
  22. #ifdef CONFIG_PM_RUNTIME
  23. static int omap1_pm_runtime_suspend(struct device *dev)
  24. {
  25. int ret;
  26. dev_dbg(dev, "%s\n", __func__);
  27. ret = pm_generic_runtime_suspend(dev);
  28. if (ret)
  29. return ret;
  30. ret = pm_clk_suspend(dev);
  31. if (ret) {
  32. pm_generic_runtime_resume(dev);
  33. return ret;
  34. }
  35. return 0;
  36. }
  37. static int omap1_pm_runtime_resume(struct device *dev)
  38. {
  39. dev_dbg(dev, "%s\n", __func__);
  40. pm_clk_resume(dev);
  41. return pm_generic_runtime_resume(dev);
  42. }
  43. static struct dev_pm_domain default_pm_domain = {
  44. .ops = {
  45. .runtime_suspend = omap1_pm_runtime_suspend,
  46. .runtime_resume = omap1_pm_runtime_resume,
  47. USE_PLATFORM_PM_SLEEP_OPS
  48. },
  49. };
  50. #define OMAP1_PM_DOMAIN (&default_pm_domain)
  51. #else
  52. #define OMAP1_PM_DOMAIN NULL
  53. #endif /* CONFIG_PM_RUNTIME */
  54. static struct pm_clk_notifier_block platform_bus_notifier = {
  55. .pm_domain = OMAP1_PM_DOMAIN,
  56. .con_ids = { "ick", "fck", NULL, },
  57. };
  58. static int __init omap1_pm_runtime_init(void)
  59. {
  60. if (!cpu_class_is_omap1())
  61. return -ENODEV;
  62. pm_clk_add_notifier(&platform_bus_type, &platform_bus_notifier);
  63. return 0;
  64. }
  65. core_initcall(omap1_pm_runtime_init);