Skip to content

Commit 02f513a

Browse files
peda-rNicolas Ferre
authored andcommitted
pm: at91: Workaround DDRSDRC self-refresh bug with LPDDR1 memories.
The DDRSDR controller fails miserably to put LPDDR1 memories in self-refresh. Force the controller to think it has DDR2 memories during the self-refresh period, as the DDR2 self-refresh spec is equivalent to LPDDR1, and is correctly implemented in the controller. Assume that the second controller has the same fault, but that is untested. Signed-off-by: Peter Rosin <peda@axentia.se> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
1 parent ad4a38d commit 02f513a

2 files changed

Lines changed: 39 additions & 6 deletions

File tree

‎arch/arm/mach-at91/pm_slowclock.S‎

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ ddr_sr_enable:
109109
cmp memctrl, #AT91_MEMCTRL_DDRSDR
110110
bne sdr_sr_enable
111111

112+
/* LPDDR1 --> force DDR2 mode during self-refresh */
113+
ldr tmp1, [sdramc, #AT91_DDRSDRC_MDR]
114+
str tmp1, .saved_sam9_mdr
115+
bic tmp1, tmp1, #~AT91_DDRSDRC_MD
116+
cmp tmp1, #AT91_DDRSDRC_MD_LOW_POWER_DDR
117+
ldreq tmp1, [sdramc, #AT91_DDRSDRC_MDR]
118+
biceq tmp1, tmp1, #AT91_DDRSDRC_MD
119+
orreq tmp1, tmp1, #AT91_DDRSDRC_MD_DDR2
120+
streq tmp1, [sdramc, #AT91_DDRSDRC_MDR]
121+
112122
/* prepare for DDRAM self-refresh mode */
113123
ldr tmp1, [sdramc, #AT91_DDRSDRC_LPR]
114124
str tmp1, .saved_sam9_lpr
@@ -117,14 +127,26 @@ ddr_sr_enable:
117127

118128
/* figure out if we use the second ram controller */
119129
cmp ramc1, #0
120-
ldrne tmp2, [ramc1, #AT91_DDRSDRC_LPR]
121-
strne tmp2, .saved_sam9_lpr1
122-
bicne tmp2, #AT91_DDRSDRC_LPCB
123-
orrne tmp2, #AT91_DDRSDRC_LPCB_SELF_REFRESH
130+
beq ddr_no_2nd_ctrl
131+
132+
ldr tmp2, [ramc1, #AT91_DDRSDRC_MDR]
133+
str tmp2, .saved_sam9_mdr1
134+
bic tmp2, tmp2, #~AT91_DDRSDRC_MD
135+
cmp tmp2, #AT91_DDRSDRC_MD_LOW_POWER_DDR
136+
ldreq tmp2, [ramc1, #AT91_DDRSDRC_MDR]
137+
biceq tmp2, tmp2, #AT91_DDRSDRC_MD
138+
orreq tmp2, tmp2, #AT91_DDRSDRC_MD_DDR2
139+
streq tmp2, [ramc1, #AT91_DDRSDRC_MDR]
140+
141+
ldr tmp2, [ramc1, #AT91_DDRSDRC_LPR]
142+
str tmp2, .saved_sam9_lpr1
143+
bic tmp2, #AT91_DDRSDRC_LPCB
144+
orr tmp2, #AT91_DDRSDRC_LPCB_SELF_REFRESH
124145

125146
/* Enable DDRAM self-refresh mode */
147+
str tmp2, [ramc1, #AT91_DDRSDRC_LPR]
148+
ddr_no_2nd_ctrl:
126149
str tmp1, [sdramc, #AT91_DDRSDRC_LPR]
127-
strne tmp2, [ramc1, #AT91_DDRSDRC_LPR]
128150

129151
b sdr_sr_done
130152

@@ -255,12 +277,17 @@ sdr_sr_done:
255277
*/
256278
cmp memctrl, #AT91_MEMCTRL_DDRSDR
257279
bne sdr_en_restore
280+
/* Restore MDR in case of LPDDR1 */
281+
ldr tmp1, .saved_sam9_mdr
282+
str tmp1, [sdramc, #AT91_DDRSDRC_MDR]
258283
/* Restore LPR on AT91 with DDRAM */
259284
ldr tmp1, .saved_sam9_lpr
260285
str tmp1, [sdramc, #AT91_DDRSDRC_LPR]
261286

262287
/* if we use the second ram controller */
263288
cmp ramc1, #0
289+
ldrne tmp2, .saved_sam9_mdr1
290+
strne tmp2, [ramc1, #AT91_DDRSDRC_MDR]
264291
ldrne tmp2, .saved_sam9_lpr1
265292
strne tmp2, [ramc1, #AT91_DDRSDRC_LPR]
266293

@@ -294,5 +321,11 @@ ram_restored:
294321
.saved_sam9_lpr1:
295322
.word 0
296323

324+
.saved_sam9_mdr:
325+
.word 0
326+
327+
.saved_sam9_mdr1:
328+
.word 0
329+
297330
ENTRY(at91_slow_clock_sz)
298331
.word .-at91_slow_clock

‎include/soc/at91/at91sam9_ddrsdr.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
#define AT91_DDRSDRC_UPD_MR (3 << 20) /* Update load mode register and extended mode register */
9393

9494
#define AT91_DDRSDRC_MDR 0x20 /* Memory Device Register */
95-
#define AT91_DDRSDRC_MD (3 << 0) /* Memory Device Type */
95+
#define AT91_DDRSDRC_MD (7 << 0) /* Memory Device Type */
9696
#define AT91_DDRSDRC_MD_SDR 0
9797
#define AT91_DDRSDRC_MD_LOW_POWER_SDR 1
9898
#define AT91_DDRSDRC_MD_LOW_POWER_DDR 3

0 commit comments

Comments
 (0)