aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-imx
diff options
context:
space:
mode:
authorAnson Huang <b20788@freescale.com>2014-09-16 23:11:45 -0400
committerShawn Guo <shawn.guo@linaro.org>2014-11-23 01:56:17 -0500
commitec336b284136610a43c9daac56d66b20d43ddf7b (patch)
tree83577860847dac802631c097be8aefdd8b28ac96 /arch/arm/mach-imx
parent035d0d7830b180215f0779d1b6dfb210f33a49fe (diff)
ARM: imx: replace cpu type check with ddr type check
As the DDR/IO and MMDC setting are different on LPDDR2 and DDR3, we used cpu type to decide how to do these settings in suspend before which is NOT flexible, take i.MX6SL for example, although it has LPDDR2 on EVK board, but users can also use DDR3 on other boards, so it is better to read the DDR type from MMDC then decide how to do related settings. Signed-off-by: Anson Huang <b20788@freescale.com> Signed-off-by: Shawn Guo <shawn.guo@freescale.com>
Diffstat (limited to 'arch/arm/mach-imx')
-rw-r--r--arch/arm/mach-imx/common.h1
-rw-r--r--arch/arm/mach-imx/mmdc.c17
-rw-r--r--arch/arm/mach-imx/mxc.h2
-rw-r--r--arch/arm/mach-imx/pm-imx6.c10
-rw-r--r--arch/arm/mach-imx/suspend-imx6.S14
5 files changed, 30 insertions, 14 deletions
diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h
index 1dabf435c592..23c84e67a56d 100644
--- a/arch/arm/mach-imx/common.h
+++ b/arch/arm/mach-imx/common.h
@@ -116,6 +116,7 @@ void imx_anatop_post_resume(void);
116int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode); 116int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode);
117void imx6q_set_int_mem_clk_lpm(bool enable); 117void imx6q_set_int_mem_clk_lpm(bool enable);
118void imx6sl_set_wait_clk(bool enter); 118void imx6sl_set_wait_clk(bool enter);
119int imx_mmdc_get_ddr_type(void);
119 120
120void imx_cpu_die(unsigned int cpu); 121void imx_cpu_die(unsigned int cpu);
121int imx_cpu_kill(unsigned int cpu); 122int imx_cpu_kill(unsigned int cpu);
diff --git a/arch/arm/mach-imx/mmdc.c b/arch/arm/mach-imx/mmdc.c
index 7a9686ad994c..3729d90cfa46 100644
--- a/arch/arm/mach-imx/mmdc.c
+++ b/arch/arm/mach-imx/mmdc.c
@@ -21,6 +21,12 @@
21#define BP_MMDC_MAPSR_PSD 0 21#define BP_MMDC_MAPSR_PSD 0
22#define BP_MMDC_MAPSR_PSS 4 22#define BP_MMDC_MAPSR_PSS 4
23 23
24#define MMDC_MDMISC 0x18
25#define BM_MMDC_MDMISC_DDR_TYPE 0x18
26#define BP_MMDC_MDMISC_DDR_TYPE 0x3
27
28static int ddr_type;
29
24static int imx_mmdc_probe(struct platform_device *pdev) 30static int imx_mmdc_probe(struct platform_device *pdev)
25{ 31{
26 struct device_node *np = pdev->dev.of_node; 32 struct device_node *np = pdev->dev.of_node;
@@ -31,6 +37,12 @@ static int imx_mmdc_probe(struct platform_device *pdev)
31 mmdc_base = of_iomap(np, 0); 37 mmdc_base = of_iomap(np, 0);
32 WARN_ON(!mmdc_base); 38 WARN_ON(!mmdc_base);
33 39
40 reg = mmdc_base + MMDC_MDMISC;
41 /* Get ddr type */
42 val = readl_relaxed(reg);
43 ddr_type = (val & BM_MMDC_MDMISC_DDR_TYPE) >>
44 BP_MMDC_MDMISC_DDR_TYPE;
45
34 reg = mmdc_base + MMDC_MAPSR; 46 reg = mmdc_base + MMDC_MAPSR;
35 47
36 /* Enable automatic power saving */ 48 /* Enable automatic power saving */
@@ -51,6 +63,11 @@ static int imx_mmdc_probe(struct platform_device *pdev)
51 return 0; 63 return 0;
52} 64}
53 65
66int imx_mmdc_get_ddr_type(void)
67{
68 return ddr_type;
69}
70
54static struct of_device_id imx_mmdc_dt_ids[] = { 71static struct of_device_id imx_mmdc_dt_ids[] = {
55 { .compatible = "fsl,imx6q-mmdc", }, 72 { .compatible = "fsl,imx6q-mmdc", },
56 { /* sentinel */ } 73 { /* sentinel */ }
diff --git a/arch/arm/mach-imx/mxc.h b/arch/arm/mach-imx/mxc.h
index 17a41ca65acf..4c1343df2ba4 100644
--- a/arch/arm/mach-imx/mxc.h
+++ b/arch/arm/mach-imx/mxc.h
@@ -55,6 +55,8 @@
55#define IMX_CHIP_REVISION_3_3 0x33 55#define IMX_CHIP_REVISION_3_3 0x33
56#define IMX_CHIP_REVISION_UNKNOWN 0xff 56#define IMX_CHIP_REVISION_UNKNOWN 0xff
57 57
58#define IMX_DDR_TYPE_LPDDR2 1
59
58#ifndef __ASSEMBLY__ 60#ifndef __ASSEMBLY__
59extern unsigned int __mxc_cpu_type; 61extern unsigned int __mxc_cpu_type;
60#endif 62#endif
diff --git a/arch/arm/mach-imx/pm-imx6.c b/arch/arm/mach-imx/pm-imx6.c
index 5c3af8f993d0..c653dd4c9103 100644
--- a/arch/arm/mach-imx/pm-imx6.c
+++ b/arch/arm/mach-imx/pm-imx6.c
@@ -88,7 +88,7 @@ struct imx6_pm_base {
88}; 88};
89 89
90struct imx6_pm_socdata { 90struct imx6_pm_socdata {
91 u32 cpu_type; 91 u32 ddr_type;
92 const char *mmdc_compat; 92 const char *mmdc_compat;
93 const char *src_compat; 93 const char *src_compat;
94 const char *iomuxc_compat; 94 const char *iomuxc_compat;
@@ -138,7 +138,6 @@ static const u32 imx6sx_mmdc_io_offset[] __initconst = {
138}; 138};
139 139
140static const struct imx6_pm_socdata imx6q_pm_data __initconst = { 140static const struct imx6_pm_socdata imx6q_pm_data __initconst = {
141 .cpu_type = MXC_CPU_IMX6Q,
142 .mmdc_compat = "fsl,imx6q-mmdc", 141 .mmdc_compat = "fsl,imx6q-mmdc",
143 .src_compat = "fsl,imx6q-src", 142 .src_compat = "fsl,imx6q-src",
144 .iomuxc_compat = "fsl,imx6q-iomuxc", 143 .iomuxc_compat = "fsl,imx6q-iomuxc",
@@ -148,7 +147,6 @@ static const struct imx6_pm_socdata imx6q_pm_data __initconst = {
148}; 147};
149 148
150static const struct imx6_pm_socdata imx6dl_pm_data __initconst = { 149static const struct imx6_pm_socdata imx6dl_pm_data __initconst = {
151 .cpu_type = MXC_CPU_IMX6DL,
152 .mmdc_compat = "fsl,imx6q-mmdc", 150 .mmdc_compat = "fsl,imx6q-mmdc",
153 .src_compat = "fsl,imx6q-src", 151 .src_compat = "fsl,imx6q-src",
154 .iomuxc_compat = "fsl,imx6dl-iomuxc", 152 .iomuxc_compat = "fsl,imx6dl-iomuxc",
@@ -158,7 +156,6 @@ static const struct imx6_pm_socdata imx6dl_pm_data __initconst = {
158}; 156};
159 157
160static const struct imx6_pm_socdata imx6sl_pm_data __initconst = { 158static const struct imx6_pm_socdata imx6sl_pm_data __initconst = {
161 .cpu_type = MXC_CPU_IMX6SL,
162 .mmdc_compat = "fsl,imx6sl-mmdc", 159 .mmdc_compat = "fsl,imx6sl-mmdc",
163 .src_compat = "fsl,imx6sl-src", 160 .src_compat = "fsl,imx6sl-src",
164 .iomuxc_compat = "fsl,imx6sl-iomuxc", 161 .iomuxc_compat = "fsl,imx6sl-iomuxc",
@@ -168,7 +165,6 @@ static const struct imx6_pm_socdata imx6sl_pm_data __initconst = {
168}; 165};
169 166
170static const struct imx6_pm_socdata imx6sx_pm_data __initconst = { 167static const struct imx6_pm_socdata imx6sx_pm_data __initconst = {
171 .cpu_type = MXC_CPU_IMX6SX,
172 .mmdc_compat = "fsl,imx6sx-mmdc", 168 .mmdc_compat = "fsl,imx6sx-mmdc",
173 .src_compat = "fsl,imx6sx-src", 169 .src_compat = "fsl,imx6sx-src",
174 .iomuxc_compat = "fsl,imx6sx-iomuxc", 170 .iomuxc_compat = "fsl,imx6sx-iomuxc",
@@ -187,7 +183,7 @@ static const struct imx6_pm_socdata imx6sx_pm_data __initconst = {
187struct imx6_cpu_pm_info { 183struct imx6_cpu_pm_info {
188 phys_addr_t pbase; /* The physical address of pm_info. */ 184 phys_addr_t pbase; /* The physical address of pm_info. */
189 phys_addr_t resume_addr; /* The physical resume address for asm code */ 185 phys_addr_t resume_addr; /* The physical resume address for asm code */
190 u32 cpu_type; 186 u32 ddr_type;
191 u32 pm_info_size; /* Size of pm_info. */ 187 u32 pm_info_size; /* Size of pm_info. */
192 struct imx6_pm_base mmdc_base; 188 struct imx6_pm_base mmdc_base;
193 struct imx6_pm_base src_base; 189 struct imx6_pm_base src_base;
@@ -522,7 +518,7 @@ static int __init imx6q_suspend_init(const struct imx6_pm_socdata *socdata)
522 goto pl310_cache_map_failed; 518 goto pl310_cache_map_failed;
523 } 519 }
524 520
525 pm_info->cpu_type = socdata->cpu_type; 521 pm_info->ddr_type = imx_mmdc_get_ddr_type();
526 pm_info->mmdc_io_num = socdata->mmdc_io_num; 522 pm_info->mmdc_io_num = socdata->mmdc_io_num;
527 mmdc_offset_array = socdata->mmdc_io_offset; 523 mmdc_offset_array = socdata->mmdc_io_offset;
528 524
diff --git a/arch/arm/mach-imx/suspend-imx6.S b/arch/arm/mach-imx/suspend-imx6.S
index ca4ea2daf25b..b99987b023fa 100644
--- a/arch/arm/mach-imx/suspend-imx6.S
+++ b/arch/arm/mach-imx/suspend-imx6.S
@@ -45,7 +45,7 @@
45 */ 45 */
46#define PM_INFO_PBASE_OFFSET 0x0 46#define PM_INFO_PBASE_OFFSET 0x0
47#define PM_INFO_RESUME_ADDR_OFFSET 0x4 47#define PM_INFO_RESUME_ADDR_OFFSET 0x4
48#define PM_INFO_CPU_TYPE_OFFSET 0x8 48#define PM_INFO_DDR_TYPE_OFFSET 0x8
49#define PM_INFO_PM_INFO_SIZE_OFFSET 0xC 49#define PM_INFO_PM_INFO_SIZE_OFFSET 0xC
50#define PM_INFO_MX6Q_MMDC_P_OFFSET 0x10 50#define PM_INFO_MX6Q_MMDC_P_OFFSET 0x10
51#define PM_INFO_MX6Q_MMDC_V_OFFSET 0x14 51#define PM_INFO_MX6Q_MMDC_V_OFFSET 0x14
@@ -110,7 +110,7 @@
110 ldreq r11, [r0, #PM_INFO_MX6Q_MMDC_V_OFFSET] 110 ldreq r11, [r0, #PM_INFO_MX6Q_MMDC_V_OFFSET]
111 ldrne r11, [r0, #PM_INFO_MX6Q_MMDC_P_OFFSET] 111 ldrne r11, [r0, #PM_INFO_MX6Q_MMDC_P_OFFSET]
112 112
113 cmp r3, #MXC_CPU_IMX6SL 113 cmp r3, #IMX_DDR_TYPE_LPDDR2
114 bne 4f 114 bne 4f
115 115
116 /* reset read FIFO, RST_RD_FIFO */ 116 /* reset read FIFO, RST_RD_FIFO */
@@ -151,7 +151,7 @@
151ENTRY(imx6_suspend) 151ENTRY(imx6_suspend)
152 ldr r1, [r0, #PM_INFO_PBASE_OFFSET] 152 ldr r1, [r0, #PM_INFO_PBASE_OFFSET]
153 ldr r2, [r0, #PM_INFO_RESUME_ADDR_OFFSET] 153 ldr r2, [r0, #PM_INFO_RESUME_ADDR_OFFSET]
154 ldr r3, [r0, #PM_INFO_CPU_TYPE_OFFSET] 154 ldr r3, [r0, #PM_INFO_DDR_TYPE_OFFSET]
155 ldr r4, [r0, #PM_INFO_PM_INFO_SIZE_OFFSET] 155 ldr r4, [r0, #PM_INFO_PM_INFO_SIZE_OFFSET]
156 156
157 /* 157 /*
@@ -209,8 +209,8 @@ poll_dvfs_set:
209 ldr r7, [r0, #PM_INFO_MMDC_IO_NUM_OFFSET] 209 ldr r7, [r0, #PM_INFO_MMDC_IO_NUM_OFFSET]
210 ldr r8, =PM_INFO_MMDC_IO_VAL_OFFSET 210 ldr r8, =PM_INFO_MMDC_IO_VAL_OFFSET
211 add r8, r8, r0 211 add r8, r8, r0
212 /* i.MX6SL's last 3 IOs need special setting */ 212 /* LPDDR2's last 3 IOs need special setting */
213 cmp r3, #MXC_CPU_IMX6SL 213 cmp r3, #IMX_DDR_TYPE_LPDDR2
214 subeq r7, r7, #0x3 214 subeq r7, r7, #0x3
215set_mmdc_io_lpm: 215set_mmdc_io_lpm:
216 ldr r9, [r8], #0x8 216 ldr r9, [r8], #0x8
@@ -218,7 +218,7 @@ set_mmdc_io_lpm:
218 subs r7, r7, #0x1 218 subs r7, r7, #0x1
219 bne set_mmdc_io_lpm 219 bne set_mmdc_io_lpm
220 220
221 cmp r3, #MXC_CPU_IMX6SL 221 cmp r3, #IMX_DDR_TYPE_LPDDR2
222 bne set_mmdc_io_lpm_done 222 bne set_mmdc_io_lpm_done
223 ldr r6, =0x1000 223 ldr r6, =0x1000
224 ldr r9, [r8], #0x8 224 ldr r9, [r8], #0x8
@@ -324,7 +324,7 @@ resume:
324 str r7, [r11, #MX6Q_SRC_GPR1] 324 str r7, [r11, #MX6Q_SRC_GPR1]
325 str r7, [r11, #MX6Q_SRC_GPR2] 325 str r7, [r11, #MX6Q_SRC_GPR2]
326 326
327 ldr r3, [r0, #PM_INFO_CPU_TYPE_OFFSET] 327 ldr r3, [r0, #PM_INFO_DDR_TYPE_OFFSET]
328 mov r5, #0x1 328 mov r5, #0x1
329 resume_mmdc 329 resume_mmdc
330 330