pm_bus.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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_runtime_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_runtime_clk_resume(dev);
  41. return pm_generic_runtime_resume(dev);
  42. }
  43. static struct dev_power_domain default_power_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. static struct pm_clk_notifier_block platform_bus_notifier = {
  51. .pwr_domain = &default_power_domain,
  52. .con_ids = { "ick", "fck", NULL, },
  53. };
  54. static int __init omap1_pm_runtime_init(void)
  55. {
  56. if (!cpu_class_is_omap1())
  57. return -ENODEV;
  58. pm_runtime_clk_add_notifier(&platform_bus_type, &platform_bus_notifier);
  59. return 0;
  60. }
  61. core_initcall(omap1_pm_runtime_init);
  62. #endif /* CONFIG_PM_RUNTIME */