Shawn Guo | a1f1c7e | 2011-09-06 15:08:40 +0800 | [diff] [blame] | 1 | /* |
Anson Huang | e95dddb | 2013-03-20 19:39:42 -0400 | [diff] [blame^] | 2 | * Copyright 2011-2013 Freescale Semiconductor, Inc. |
Shawn Guo | a1f1c7e | 2011-09-06 15:08:40 +0800 | [diff] [blame] | 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 | |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/io.h> |
| 15 | #include <linux/of.h> |
| 16 | #include <linux/suspend.h> |
| 17 | #include <asm/cacheflush.h> |
| 18 | #include <asm/proc-fns.h> |
| 19 | #include <asm/suspend.h> |
| 20 | #include <asm/hardware/cache-l2x0.h> |
Shawn Guo | a1f1c7e | 2011-09-06 15:08:40 +0800 | [diff] [blame] | 21 | |
Shawn Guo | e337247 | 2012-09-13 21:01:00 +0800 | [diff] [blame] | 22 | #include "common.h" |
Shawn Guo | 50f2de6 | 2012-09-14 14:14:45 +0800 | [diff] [blame] | 23 | #include "hardware.h" |
Shawn Guo | e337247 | 2012-09-13 21:01:00 +0800 | [diff] [blame] | 24 | |
Shawn Guo | a1f1c7e | 2011-09-06 15:08:40 +0800 | [diff] [blame] | 25 | static int imx6q_suspend_finish(unsigned long val) |
| 26 | { |
| 27 | cpu_do_idle(); |
| 28 | return 0; |
| 29 | } |
| 30 | |
| 31 | static int imx6q_pm_enter(suspend_state_t state) |
| 32 | { |
| 33 | switch (state) { |
| 34 | case PM_SUSPEND_MEM: |
| 35 | imx6q_set_lpm(STOP_POWER_OFF); |
| 36 | imx_gpc_pre_suspend(); |
Anson Huang | e95dddb | 2013-03-20 19:39:42 -0400 | [diff] [blame^] | 37 | imx_anatop_pre_suspend(); |
Shawn Guo | a1f1c7e | 2011-09-06 15:08:40 +0800 | [diff] [blame] | 38 | imx_set_cpu_jump(0, v7_cpu_resume); |
| 39 | /* Zzz ... */ |
| 40 | cpu_suspend(0, imx6q_suspend_finish); |
| 41 | imx_smp_prepare(); |
Anson Huang | e95dddb | 2013-03-20 19:39:42 -0400 | [diff] [blame^] | 42 | imx_anatop_post_resume(); |
Shawn Guo | a1f1c7e | 2011-09-06 15:08:40 +0800 | [diff] [blame] | 43 | imx_gpc_post_resume(); |
Shawn Guo | 83ae2098 | 2013-01-14 21:11:10 +0800 | [diff] [blame] | 44 | imx6q_set_lpm(WAIT_CLOCKED); |
Shawn Guo | a1f1c7e | 2011-09-06 15:08:40 +0800 | [diff] [blame] | 45 | break; |
| 46 | default: |
| 47 | return -EINVAL; |
| 48 | } |
| 49 | |
| 50 | return 0; |
| 51 | } |
| 52 | |
| 53 | static const struct platform_suspend_ops imx6q_pm_ops = { |
| 54 | .enter = imx6q_pm_enter, |
| 55 | .valid = suspend_valid_only_mem, |
| 56 | }; |
| 57 | |
| 58 | void __init imx6q_pm_init(void) |
| 59 | { |
Shawn Guo | a1f1c7e | 2011-09-06 15:08:40 +0800 | [diff] [blame] | 60 | suspend_set_ops(&imx6q_pm_ops); |
| 61 | } |