pm_bus.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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/pm_clock.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/mutex.h>
  19. #include <linux/clk.h>
  20. #include <linux/err.h>
  21. #include <plat/omap_device.h>
  22. #include <plat/omap-pm.h>
  23. #ifdef CONFIG_PM_RUNTIME
  24. static int omap1_pm_runtime_suspend(struct device *dev)
  25. {
  26. int ret;
  27. dev_dbg(dev, "%s\n", __func__);
  28. ret = pm_generic_runtime_suspend(dev);
  29. if (ret)
  30. return ret;
  31. ret = pm_clk_suspend(dev);
  32. if (ret) {
  33. pm_generic_runtime_resume(dev);
  34. return ret;
  35. }
  36. return 0;
  37. }
  38. static int omap1_pm_runtime_resume(struct device *dev)
  39. {
  40. dev_dbg(dev, "%s\n", __func__);
  41. pm_clk_resume(dev);
  42. return pm_generic_runtime_resume(dev);
  43. }
  44. static struct dev_pm_domain default_pm_domain = {
  45. .ops = {
  46. .runtime_suspend = omap1_pm_runtime_suspend,
  47. .runtime_resume = omap1_pm_runtime_resume,
  48. USE_PLATFORM_PM_SLEEP_OPS
  49. },
  50. };
  51. #define OMAP1_PM_DOMAIN (&default_pm_domain)
  52. #else
  53. #define OMAP1_PM_DOMAIN NULL
  54. #endif /* CONFIG_PM_RUNTIME */
  55. static struct pm_clk_notifier_block platform_bus_notifier = {
  56. .pm_domain = OMAP1_PM_DOMAIN,
  57. .con_ids = { "ick", "fck", NULL, },
  58. };
  59. static int __init omap1_pm_runtime_init(void)
  60. {
  61. if (!cpu_class_is_omap1())
  62. return -ENODEV;
  63. pm_clk_add_notifier(&platform_bus_type, &platform_bus_notifier);
  64. return 0;
  65. }
  66. core_initcall(omap1_pm_runtime_init);