pm_bus.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. struct clk *iclk, *fclk;
  26. int ret = 0;
  27. dev_dbg(dev, "%s\n", __func__);
  28. ret = pm_generic_runtime_suspend(dev);
  29. fclk = clk_get(dev, "fck");
  30. if (!IS_ERR(fclk)) {
  31. clk_disable(fclk);
  32. clk_put(fclk);
  33. }
  34. iclk = clk_get(dev, "ick");
  35. if (!IS_ERR(iclk)) {
  36. clk_disable(iclk);
  37. clk_put(iclk);
  38. }
  39. return 0;
  40. };
  41. static int omap1_pm_runtime_resume(struct device *dev)
  42. {
  43. int ret = 0;
  44. struct clk *iclk, *fclk;
  45. dev_dbg(dev, "%s\n", __func__);
  46. iclk = clk_get(dev, "ick");
  47. if (!IS_ERR(iclk)) {
  48. clk_enable(iclk);
  49. clk_put(iclk);
  50. }
  51. fclk = clk_get(dev, "fck");
  52. if (!IS_ERR(fclk)) {
  53. clk_enable(fclk);
  54. clk_put(fclk);
  55. }
  56. return pm_generic_runtime_resume(dev);
  57. };
  58. static int __init omap1_pm_runtime_init(void)
  59. {
  60. const struct dev_pm_ops *pm;
  61. struct dev_pm_ops *omap_pm;
  62. pm = platform_bus_get_pm_ops();
  63. if (!pm) {
  64. pr_err("%s: unable to get dev_pm_ops from platform_bus\n",
  65. __func__);
  66. return -ENODEV;
  67. }
  68. omap_pm = kmemdup(pm, sizeof(struct dev_pm_ops), GFP_KERNEL);
  69. if (!omap_pm) {
  70. pr_err("%s: unable to alloc memory for new dev_pm_ops\n",
  71. __func__);
  72. return -ENOMEM;
  73. }
  74. omap_pm->runtime_suspend = omap1_pm_runtime_suspend;
  75. omap_pm->runtime_resume = omap1_pm_runtime_resume;
  76. platform_bus_set_pm_ops(omap_pm);
  77. return 0;
  78. }
  79. core_initcall(omap1_pm_runtime_init);
  80. #endif /* CONFIG_PM_RUNTIME */