pm-imx5.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
  3. *
  4. * The code contained herein is licensed under the GNU General Public
  5. * License. You may obtain a copy of the GNU General Public License
  6. * Version 2 or later at the following locations:
  7. *
  8. * http://www.opensource.org/licenses/gpl-license.html
  9. * http://www.gnu.org/copyleft/gpl.html
  10. */
  11. #include <linux/suspend.h>
  12. #include <linux/clk.h>
  13. #include <linux/io.h>
  14. #include <linux/err.h>
  15. #include <asm/cacheflush.h>
  16. #include <asm/tlbflush.h>
  17. #include <mach/system.h>
  18. #include "crm_regs.h"
  19. static struct clk *gpc_dvfs_clk;
  20. static int mx5_suspend_enter(suspend_state_t state)
  21. {
  22. clk_enable(gpc_dvfs_clk);
  23. switch (state) {
  24. case PM_SUSPEND_MEM:
  25. mx5_cpu_lp_set(STOP_POWER_OFF);
  26. break;
  27. case PM_SUSPEND_STANDBY:
  28. mx5_cpu_lp_set(WAIT_UNCLOCKED_POWER_OFF);
  29. break;
  30. default:
  31. return -EINVAL;
  32. }
  33. if (state == PM_SUSPEND_MEM) {
  34. local_flush_tlb_all();
  35. flush_cache_all();
  36. /*clear the EMPGC0/1 bits */
  37. __raw_writel(0, MXC_SRPG_EMPGC0_SRPGCR);
  38. __raw_writel(0, MXC_SRPG_EMPGC1_SRPGCR);
  39. }
  40. cpu_do_idle();
  41. clk_disable(gpc_dvfs_clk);
  42. return 0;
  43. }
  44. static int mx5_pm_valid(suspend_state_t state)
  45. {
  46. return (state > PM_SUSPEND_ON && state <= PM_SUSPEND_MAX);
  47. }
  48. static const struct platform_suspend_ops mx5_suspend_ops = {
  49. .valid = mx5_pm_valid,
  50. .enter = mx5_suspend_enter,
  51. };
  52. static int __init mx5_pm_init(void)
  53. {
  54. if (gpc_dvfs_clk == NULL)
  55. gpc_dvfs_clk = clk_get(NULL, "gpc_dvfs");
  56. if (!IS_ERR(gpc_dvfs_clk)) {
  57. if (cpu_is_mx51())
  58. suspend_set_ops(&mx5_suspend_ops);
  59. } else
  60. return -EPERM;
  61. return 0;
  62. }
  63. device_initcall(mx5_pm_init);