pm-imx5.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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/common.h>
  18. #include <mach/hardware.h>
  19. #include "crm_regs.h"
  20. static struct clk *gpc_dvfs_clk;
  21. static int mx5_suspend_enter(suspend_state_t state)
  22. {
  23. clk_enable(gpc_dvfs_clk);
  24. switch (state) {
  25. case PM_SUSPEND_MEM:
  26. mx5_cpu_lp_set(STOP_POWER_OFF);
  27. break;
  28. case PM_SUSPEND_STANDBY:
  29. mx5_cpu_lp_set(WAIT_UNCLOCKED_POWER_OFF);
  30. break;
  31. default:
  32. return -EINVAL;
  33. }
  34. if (state == PM_SUSPEND_MEM) {
  35. local_flush_tlb_all();
  36. flush_cache_all();
  37. /*clear the EMPGC0/1 bits */
  38. __raw_writel(0, MXC_SRPG_EMPGC0_SRPGCR);
  39. __raw_writel(0, MXC_SRPG_EMPGC1_SRPGCR);
  40. }
  41. cpu_do_idle();
  42. clk_disable(gpc_dvfs_clk);
  43. return 0;
  44. }
  45. static int mx5_pm_valid(suspend_state_t state)
  46. {
  47. return (state > PM_SUSPEND_ON && state <= PM_SUSPEND_MAX);
  48. }
  49. static const struct platform_suspend_ops mx5_suspend_ops = {
  50. .valid = mx5_pm_valid,
  51. .enter = mx5_suspend_enter,
  52. };
  53. static int __init mx5_pm_init(void)
  54. {
  55. if (gpc_dvfs_clk == NULL)
  56. gpc_dvfs_clk = clk_get(NULL, "gpc_dvfs");
  57. if (!IS_ERR(gpc_dvfs_clk)) {
  58. if (cpu_is_mx51())
  59. suspend_set_ops(&mx5_suspend_ops);
  60. } else
  61. return -EPERM;
  62. return 0;
  63. }
  64. device_initcall(mx5_pm_init);