pm_bus.c 1.6 KB

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