pm-imx6q.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright 2011 Freescale Semiconductor, Inc.
  3. * Copyright 2011 Linaro Ltd.
  4. *
  5. * The code contained herein is licensed under the GNU General Public
  6. * License. You may obtain a copy of the GNU General Public License
  7. * Version 2 or later at the following locations:
  8. *
  9. * http://www.opensource.org/licenses/gpl-license.html
  10. * http://www.gnu.org/copyleft/gpl.html
  11. */
  12. #include <linux/init.h>
  13. #include <linux/io.h>
  14. #include <linux/of.h>
  15. #include <linux/suspend.h>
  16. #include <asm/cacheflush.h>
  17. #include <asm/proc-fns.h>
  18. #include <asm/suspend.h>
  19. #include <asm/hardware/cache-l2x0.h>
  20. #include <mach/common.h>
  21. #include <mach/hardware.h>
  22. extern unsigned long phys_l2x0_saved_regs;
  23. static int imx6q_suspend_finish(unsigned long val)
  24. {
  25. cpu_do_idle();
  26. return 0;
  27. }
  28. static int imx6q_pm_enter(suspend_state_t state)
  29. {
  30. switch (state) {
  31. case PM_SUSPEND_MEM:
  32. imx6q_set_lpm(STOP_POWER_OFF);
  33. imx_gpc_pre_suspend();
  34. imx_set_cpu_jump(0, v7_cpu_resume);
  35. /* Zzz ... */
  36. cpu_suspend(0, imx6q_suspend_finish);
  37. imx_smp_prepare();
  38. imx_gpc_post_resume();
  39. break;
  40. default:
  41. return -EINVAL;
  42. }
  43. return 0;
  44. }
  45. static const struct platform_suspend_ops imx6q_pm_ops = {
  46. .enter = imx6q_pm_enter,
  47. .valid = suspend_valid_only_mem,
  48. };
  49. void __init imx6q_pm_init(void)
  50. {
  51. /*
  52. * The l2x0 core code provides an infrastucture to save and restore
  53. * l2x0 registers across suspend/resume cycle. But because imx6q
  54. * retains L2 content during suspend and needs to resume L2 before
  55. * MMU is enabled, it can only utilize register saving support and
  56. * have to take care of restoring on its own. So we save physical
  57. * address of the data structure used by l2x0 core to save registers,
  58. * and later restore the necessary ones in imx6q resume entry.
  59. */
  60. #ifdef CONFIG_CACHE_L2X0
  61. phys_l2x0_saved_regs = __pa(&l2x0_saved_regs);
  62. #endif
  63. suspend_set_ops(&imx6q_pm_ops);
  64. }