diff options
author | Anson Huang <b20788@freescale.com> | 2013-03-20 19:39:42 -0400 |
---|---|---|
committer | Shawn Guo <shawn.guo@linaro.org> | 2013-04-12 07:01:42 -0400 |
commit | e95dddb34c896f33e89f97365491e7932f89a0c0 (patch) | |
tree | 1c8a95766fb00b1120882836ea6e8822b6101c77 /arch/arm/mach-imx | |
parent | cb872cacb2ef57ade6bb0ff41e18b9508a0e073e (diff) |
ARM: imx: enable anatop suspend/resume
Anatop module have sereval configurations for user
to reduce the power consumption in suspend, provide
suspend/resume interface for further use and enable
fet_odrive to reduce CORE LDO leakage during suspend.
As we have a common anatop file, remove all the operations
of anatop module in other files, use anatop interfaces to
do that.
Signed-off-by: Anson Huang <b20788@freescale.com>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Diffstat (limited to 'arch/arm/mach-imx')
-rw-r--r-- | arch/arm/mach-imx/Kconfig | 4 | ||||
-rw-r--r-- | arch/arm/mach-imx/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/mach-imx/anatop.c | 74 | ||||
-rw-r--r-- | arch/arm/mach-imx/common.h | 7 | ||||
-rw-r--r-- | arch/arm/mach-imx/mach-imx6q.c | 48 | ||||
-rw-r--r-- | arch/arm/mach-imx/pm-imx6q.c | 4 |
6 files changed, 94 insertions, 44 deletions
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig index 6575e4ebe26e..f694074f2302 100644 --- a/arch/arm/mach-imx/Kconfig +++ b/arch/arm/mach-imx/Kconfig | |||
@@ -65,6 +65,9 @@ config IRAM_ALLOC | |||
65 | bool | 65 | bool |
66 | select GENERIC_ALLOCATOR | 66 | select GENERIC_ALLOCATOR |
67 | 67 | ||
68 | config HAVE_IMX_ANATOP | ||
69 | bool | ||
70 | |||
68 | config HAVE_IMX_GPC | 71 | config HAVE_IMX_GPC |
69 | bool | 72 | bool |
70 | 73 | ||
@@ -795,6 +798,7 @@ config SOC_IMX6Q | |||
795 | select CPU_V7 | 798 | select CPU_V7 |
796 | select HAVE_ARM_SCU | 799 | select HAVE_ARM_SCU |
797 | select HAVE_CAN_FLEXCAN if CAN | 800 | select HAVE_CAN_FLEXCAN if CAN |
801 | select HAVE_IMX_ANATOP | ||
798 | select HAVE_IMX_GPC | 802 | select HAVE_IMX_GPC |
799 | select HAVE_IMX_MMDC | 803 | select HAVE_IMX_MMDC |
800 | select HAVE_IMX_SRC | 804 | select HAVE_IMX_SRC |
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile index 23555b0c08a9..b16eb39b9f5d 100644 --- a/arch/arm/mach-imx/Makefile +++ b/arch/arm/mach-imx/Makefile | |||
@@ -91,6 +91,7 @@ obj-$(CONFIG_MACH_EUKREA_CPUIMX35SD) += mach-cpuimx35.o | |||
91 | obj-$(CONFIG_MACH_EUKREA_MBIMXSD35_BASEBOARD) += eukrea_mbimxsd35-baseboard.o | 91 | obj-$(CONFIG_MACH_EUKREA_MBIMXSD35_BASEBOARD) += eukrea_mbimxsd35-baseboard.o |
92 | obj-$(CONFIG_MACH_VPR200) += mach-vpr200.o | 92 | obj-$(CONFIG_MACH_VPR200) += mach-vpr200.o |
93 | 93 | ||
94 | obj-$(CONFIG_HAVE_IMX_ANATOP) += anatop.o | ||
94 | obj-$(CONFIG_HAVE_IMX_GPC) += gpc.o | 95 | obj-$(CONFIG_HAVE_IMX_GPC) += gpc.o |
95 | obj-$(CONFIG_HAVE_IMX_MMDC) += mmdc.o | 96 | obj-$(CONFIG_HAVE_IMX_MMDC) += mmdc.o |
96 | obj-$(CONFIG_HAVE_IMX_SRC) += src.o | 97 | obj-$(CONFIG_HAVE_IMX_SRC) += src.o |
diff --git a/arch/arm/mach-imx/anatop.c b/arch/arm/mach-imx/anatop.c new file mode 100644 index 000000000000..b396b92526d3 --- /dev/null +++ b/arch/arm/mach-imx/anatop.c | |||
@@ -0,0 +1,74 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2013 Freescale Semiconductor, Inc. | ||
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 | |||
12 | #include <linux/err.h> | ||
13 | #include <linux/io.h> | ||
14 | #include <linux/of.h> | ||
15 | #include <linux/of_address.h> | ||
16 | #include <linux/mfd/syscon.h> | ||
17 | #include <linux/regmap.h> | ||
18 | |||
19 | #define REG_SET 0x4 | ||
20 | #define REG_CLR 0x8 | ||
21 | |||
22 | #define ANADIG_REG_CORE 0x140 | ||
23 | #define ANADIG_USB1_CHRG_DETECT 0x1b0 | ||
24 | #define ANADIG_USB2_CHRG_DETECT 0x210 | ||
25 | #define ANADIG_DIGPROG 0x260 | ||
26 | |||
27 | #define BM_ANADIG_REG_CORE_FET_ODRIVE 0x20000000 | ||
28 | #define BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B 0x80000 | ||
29 | #define BM_ANADIG_USB_CHRG_DETECT_EN_B 0x100000 | ||
30 | |||
31 | static struct regmap *anatop; | ||
32 | |||
33 | static void imx_anatop_enable_fet_odrive(bool enable) | ||
34 | { | ||
35 | regmap_write(anatop, ANADIG_REG_CORE + (enable ? REG_SET : REG_CLR), | ||
36 | BM_ANADIG_REG_CORE_FET_ODRIVE); | ||
37 | } | ||
38 | |||
39 | void imx_anatop_pre_suspend(void) | ||
40 | { | ||
41 | imx_anatop_enable_fet_odrive(true); | ||
42 | } | ||
43 | |||
44 | void imx_anatop_post_resume(void) | ||
45 | { | ||
46 | imx_anatop_enable_fet_odrive(false); | ||
47 | } | ||
48 | |||
49 | void imx_anatop_usb_chrg_detect_disable(void) | ||
50 | { | ||
51 | regmap_write(anatop, ANADIG_USB1_CHRG_DETECT, | ||
52 | BM_ANADIG_USB_CHRG_DETECT_EN_B | ||
53 | | BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B); | ||
54 | regmap_write(anatop, ANADIG_USB2_CHRG_DETECT, | ||
55 | BM_ANADIG_USB_CHRG_DETECT_EN_B | | ||
56 | BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B); | ||
57 | } | ||
58 | |||
59 | u32 imx_anatop_get_digprog(void) | ||
60 | { | ||
61 | u32 val; | ||
62 | |||
63 | regmap_read(anatop, ANADIG_DIGPROG, &val); | ||
64 | return val; | ||
65 | } | ||
66 | |||
67 | void __init imx_anatop_init(void) | ||
68 | { | ||
69 | anatop = syscon_regmap_lookup_by_compatible("fsl,imx6q-anatop"); | ||
70 | if (IS_ERR(anatop)) { | ||
71 | pr_err("%s: failed to find imx6q-anatop regmap!\n", __func__); | ||
72 | return; | ||
73 | } | ||
74 | } | ||
diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h index 9fea2522d7a3..d557bf383289 100644 --- a/arch/arm/mach-imx/common.h +++ b/arch/arm/mach-imx/common.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. | 2 | * Copyright 2004-2013 Freescale Semiconductor, Inc. All Rights Reserved. |
3 | */ | 3 | */ |
4 | 4 | ||
5 | /* | 5 | /* |
@@ -128,6 +128,11 @@ extern void imx_src_prepare_restart(void); | |||
128 | extern void imx_gpc_init(void); | 128 | extern void imx_gpc_init(void); |
129 | extern void imx_gpc_pre_suspend(void); | 129 | extern void imx_gpc_pre_suspend(void); |
130 | extern void imx_gpc_post_resume(void); | 130 | extern void imx_gpc_post_resume(void); |
131 | extern void imx_anatop_init(void); | ||
132 | extern void imx_anatop_pre_suspend(void); | ||
133 | extern void imx_anatop_post_resume(void); | ||
134 | extern void imx_anatop_usb_chrg_detect_disable(void); | ||
135 | extern u32 imx_anatop_get_digprog(void); | ||
131 | extern int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode); | 136 | extern int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode); |
132 | extern void imx6q_set_chicken_bit(void); | 137 | extern void imx6q_set_chicken_bit(void); |
133 | 138 | ||
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c index 9ffd103b27e4..31aee4d5fcdd 100644 --- a/arch/arm/mach-imx/mach-imx6q.c +++ b/arch/arm/mach-imx/mach-imx6q.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright 2011 Freescale Semiconductor, Inc. | 2 | * Copyright 2011-2013 Freescale Semiconductor, Inc. |
3 | * Copyright 2011 Linaro Ltd. | 3 | * Copyright 2011 Linaro Ltd. |
4 | * | 4 | * |
5 | * The code contained herein is licensed under the GNU General Public | 5 | * The code contained herein is licensed under the GNU General Public |
@@ -39,27 +39,12 @@ | |||
39 | #include "cpuidle.h" | 39 | #include "cpuidle.h" |
40 | #include "hardware.h" | 40 | #include "hardware.h" |
41 | 41 | ||
42 | #define IMX6Q_ANALOG_DIGPROG 0x260 | ||
43 | |||
44 | static int imx6q_revision(void) | 42 | static int imx6q_revision(void) |
45 | { | 43 | { |
46 | struct device_node *np; | ||
47 | void __iomem *base; | ||
48 | static u32 rev; | 44 | static u32 rev; |
49 | 45 | ||
50 | if (!rev) { | 46 | if (!rev) |
51 | np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-anatop"); | 47 | rev = imx_anatop_get_digprog(); |
52 | if (!np) | ||
53 | return IMX_CHIP_REVISION_UNKNOWN; | ||
54 | base = of_iomap(np, 0); | ||
55 | if (!base) { | ||
56 | of_node_put(np); | ||
57 | return IMX_CHIP_REVISION_UNKNOWN; | ||
58 | } | ||
59 | rev = readl_relaxed(base + IMX6Q_ANALOG_DIGPROG); | ||
60 | iounmap(base); | ||
61 | of_node_put(np); | ||
62 | } | ||
63 | 48 | ||
64 | switch (rev & 0xff) { | 49 | switch (rev & 0xff) { |
65 | case 0: | 50 | case 0: |
@@ -165,29 +150,7 @@ static void __init imx6q_1588_init(void) | |||
165 | } | 150 | } |
166 | static void __init imx6q_usb_init(void) | 151 | static void __init imx6q_usb_init(void) |
167 | { | 152 | { |
168 | struct regmap *anatop; | 153 | imx_anatop_usb_chrg_detect_disable(); |
169 | |||
170 | #define HW_ANADIG_USB1_CHRG_DETECT 0x000001b0 | ||
171 | #define HW_ANADIG_USB2_CHRG_DETECT 0x00000210 | ||
172 | |||
173 | #define BM_ANADIG_USB_CHRG_DETECT_EN_B 0x00100000 | ||
174 | #define BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B 0x00080000 | ||
175 | |||
176 | anatop = syscon_regmap_lookup_by_compatible("fsl,imx6q-anatop"); | ||
177 | if (!IS_ERR(anatop)) { | ||
178 | /* | ||
179 | * The external charger detector needs to be disabled, | ||
180 | * or the signal at DP will be poor | ||
181 | */ | ||
182 | regmap_write(anatop, HW_ANADIG_USB1_CHRG_DETECT, | ||
183 | BM_ANADIG_USB_CHRG_DETECT_EN_B | ||
184 | | BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B); | ||
185 | regmap_write(anatop, HW_ANADIG_USB2_CHRG_DETECT, | ||
186 | BM_ANADIG_USB_CHRG_DETECT_EN_B | | ||
187 | BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B); | ||
188 | } else { | ||
189 | pr_warn("failed to find fsl,imx6q-anatop regmap\n"); | ||
190 | } | ||
191 | } | 154 | } |
192 | 155 | ||
193 | static void __init imx6q_init_machine(void) | 156 | static void __init imx6q_init_machine(void) |
@@ -197,9 +160,11 @@ static void __init imx6q_init_machine(void) | |||
197 | 160 | ||
198 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); | 161 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); |
199 | 162 | ||
163 | imx_anatop_init(); | ||
200 | imx6q_pm_init(); | 164 | imx6q_pm_init(); |
201 | imx6q_usb_init(); | 165 | imx6q_usb_init(); |
202 | imx6q_1588_init(); | 166 | imx6q_1588_init(); |
167 | imx_print_silicon_rev("i.MX6Q", imx6q_revision()); | ||
203 | } | 168 | } |
204 | 169 | ||
205 | #define OCOTP_CFG3 0x440 | 170 | #define OCOTP_CFG3 0x440 |
@@ -293,7 +258,6 @@ static void __init imx6q_timer_init(void) | |||
293 | { | 258 | { |
294 | mx6q_clocks_init(); | 259 | mx6q_clocks_init(); |
295 | twd_local_timer_of_register(); | 260 | twd_local_timer_of_register(); |
296 | imx_print_silicon_rev("i.MX6Q", imx6q_revision()); | ||
297 | } | 261 | } |
298 | 262 | ||
299 | static const char *imx6q_dt_compat[] __initdata = { | 263 | static const char *imx6q_dt_compat[] __initdata = { |
diff --git a/arch/arm/mach-imx/pm-imx6q.c b/arch/arm/mach-imx/pm-imx6q.c index 5faba7a3c95f..204942749e21 100644 --- a/arch/arm/mach-imx/pm-imx6q.c +++ b/arch/arm/mach-imx/pm-imx6q.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright 2011 Freescale Semiconductor, Inc. | 2 | * Copyright 2011-2013 Freescale Semiconductor, Inc. |
3 | * Copyright 2011 Linaro Ltd. | 3 | * Copyright 2011 Linaro Ltd. |
4 | * | 4 | * |
5 | * The code contained herein is licensed under the GNU General Public | 5 | * The code contained herein is licensed under the GNU General Public |
@@ -34,10 +34,12 @@ static int imx6q_pm_enter(suspend_state_t state) | |||
34 | case PM_SUSPEND_MEM: | 34 | case PM_SUSPEND_MEM: |
35 | imx6q_set_lpm(STOP_POWER_OFF); | 35 | imx6q_set_lpm(STOP_POWER_OFF); |
36 | imx_gpc_pre_suspend(); | 36 | imx_gpc_pre_suspend(); |
37 | imx_anatop_pre_suspend(); | ||
37 | imx_set_cpu_jump(0, v7_cpu_resume); | 38 | imx_set_cpu_jump(0, v7_cpu_resume); |
38 | /* Zzz ... */ | 39 | /* Zzz ... */ |
39 | cpu_suspend(0, imx6q_suspend_finish); | 40 | cpu_suspend(0, imx6q_suspend_finish); |
40 | imx_smp_prepare(); | 41 | imx_smp_prepare(); |
42 | imx_anatop_post_resume(); | ||
41 | imx_gpc_post_resume(); | 43 | imx_gpc_post_resume(); |
42 | imx6q_set_lpm(WAIT_CLOCKED); | 44 | imx6q_set_lpm(WAIT_CLOCKED); |
43 | break; | 45 | break; |