summaryrefslogtreecommitdiff
path: root/board/samsung/smdkv310/mem_setup.S
blob: 73aebe3c60956a598b4b7e411310bc5d696aeaab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
/*
 * Memory setup for SMDKV310 board based on S5PC210
 *
 * Copyright (C) 2011 Samsung Electronics
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

#include <config.h>

#define SET_MIU

#define MEM_DLL

#ifdef CONFIG_CLK_800_330_165
#define DRAM_CLK_330
#endif
#ifdef CONFIG_CLK_1000_200_200
#define DRAM_CLK_200
#endif
#ifdef CONFIG_CLK_1000_330_165
#define DRAM_CLK_330
#endif
#ifdef CONFIG_CLK_1000_400_200
#define DRAM_CLK_400
#endif

	.globl mem_ctrl_asm_init
mem_ctrl_asm_init:

	/*
	* Async bridge configuration at CPU_core:
	* 1: half_sync
	* 0: full_sync
	*/
	ldr r0, =0x10010350
	mov r1, #1
	str r1, [r0]

#ifdef SET_MIU
	ldr	r0, =S5PC210_MIU_BASE	@0x10600000
#ifdef CONFIG_MIU_1BIT_INTERLEAVED
	ldr	r1, =0x0000000c
	str	r1, [r0, #0x400]	@MIU_INTLV_CONFIG
	ldr	r1, =0x40000000
	str	r1, [r0, #0x808]	@MIU_INTLV_START_ADDR
	ldr	r1, =0xbfffffff
	str	r1, [r0, #0x810]	@MIU_INTLV_END_ADDR
	ldr	r1, =0x00000001
	str	r1, [r0, #0x800]	@MIU_MAPPING_UPDATE
#endif
#ifdef CONFIG_MIU_2BIT_INTERLEAVED
	ldr	r1, =0x2000150c
	str	r1, [r0, #0x400]	@MIU_INTLV_CONFIG
	ldr	r1, =0x40000000
	str	r1, [r0, #0x808]	@MIU_INTLV_START_ADDR
	ldr	r1, =0xbfffffff
	str	r1, [r0, #0x810]	@MIU_INTLV_END_ADDR
	ldr	r1, =0x00000001
	str	r1, [r0, #0x800]	@MIU_MAPPING_UPDATE
#endif
#ifdef CONFIG_MIU_LINEAR
	ldr	r1, =0x40000000
	str	r1, [r0, #0x818]	@MIU_SINGLE_MAPPING0_START_ADDR
	ldr	r1, =0x7fffffff
	str	r1, [r0, #0x820]	@MIU_SINGLE_MAPPING0_END_ADDR
	ldr	r1, =0x80000000
	str	r1, [r0, #0x828]	@MIU_SINGLE_MAPPING1_START_ADDR
	ldr	r1, =0xbfffffff
	str	r1, [r0, #0x830]	@MIU_SINGLE_MAPPING1_END_ADDR]
	ldr	r1, =0x00000006
	str	r1, [r0, #0x800]	@MIU_MAPPING_UPDATE
#endif
#endif
	/* DREX0 */
	ldr	r0, =S5PC210_DMC0_BASE	@0x10400000

	ldr	r1, =0xe0000086
	str	r1, [r0, #0x1C]		@DMC_PHYCONTROL1

	ldr	r1, =0xE3855703
	str	r1, [r0, #0x44]		@DMC_PHYZQCONTROL

	mov	r2, #0x100000
1:	subs	r2, r2, #1
	bne	1b

	ldr	r1, =0xe000008e
	str	r1, [r0, #0x1C]		@DMC_PHYCONTROL1
	ldr	r1, =0xe0000086
	str	r1, [r0, #0x1C]		@DMC_PHYCONTROL1

	ldr	r1, =0x71101008
	str	r1, [r0, #0x18]		@DMC_PHYCONTROL0
	ldr	r1, =0x7110100A
	str	r1, [r0, #0x18]		@DMC_PHYCONTROL0
	ldr	r1, =0xe0000086
	str	r1, [r0, #0x1C]		@DMC_PHYCONTROL1
	ldr	r1, =0x7110100B
	str	r1, [r0, #0x18]		@DMC_PHYCONTROL0

	ldr	r1, =0x00000000
	str	r1, [r0, #0x20]		@DMC_PHYCONTROL2

	ldr	r1, =0x0FFF301a
	str	r1, [r0, #0x00]		@DMC_CONCONTROL
	ldr	r1, =0x00312640
	str	r1, [r0, #0x04]		@DMC_MEMCONTROL]

#ifdef CONFIG_MIU_LINEAR
	ldr	r1, =0x40e01323
	str	r1, [r0, #0x08]		@DMC_MEMCONFIG0
	ldr	r1, =0x60e01323
	str	r1, [r0, #0x0C]		@DMC_MEMCONFIG1
#else	/* @MIU_1BIT_INTERLEAVED | MIU_2BIT_INTERLEAVED */
	ldr	r1, =0x20e01323
	str	r1, [r0, #0x08]		@DMC_MEMCONFIG0
	ldr	r1, =0x40e01323
	str	r1, [r0, #0x0C]		@DMC_MEMCONFIG1
#endif

	ldr	r1, =0xff000000
	str	r1, [r0, #0x14]		@DMC_PRECHCONFIG

	ldr	r1, =0x000000BC
	str	r1, [r0, #0x30]		@DMC_TIMINGAREF

#ifdef DRAM_CLK_330
	ldr	r1, =0x3545548d
	str	r1, [r0, #0x34]		@DMC_TIMINGROW
	ldr	r1, =0x45430506
	str	r1, [r0, #0x38]		@DMC_TIMINGDATA
	ldr	r1, =0x4439033c
	str	r1, [r0, #0x3C]		@DMC_TIMINGPOWER
#endif
#ifdef DRAM_CLK_400
	ldr	r1, =0x4046654f
	str	r1, [r0, #0x34]		@DMC_TIMINGROW
	ldr	r1, =0x56500506
	str	r1, [r0, #0x38]		@DMC_TIMINGDATA
	ldr	r1, =0x5444033d
	str	r1, [r0, #0x3C]		@DMC_TIMINGPOWER
#endif
	ldr	r1, =0x07000000
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD

	mov	r2, #0x100000
2:	subs	r2, r2, #1
	bne	2b

	ldr	r1, =0x00020000
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD
	ldr	r1, =0x00030000
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD
	ldr	r1, =0x00010002
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD
	ldr	r1, =0x00000328
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD

	mov	r2, #0x100000
3:	subs	r2, r2, #1
	bne	3b

	ldr	r1, =0x0a000000
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD

	mov	r2, #0x100000
4:	subs	r2, r2, #1
	bne	4b

	ldr	r1, =0x07100000
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD

	mov	r2, #0x100000
5:	subs	r2, r2, #1
	bne	5b

	ldr	r1, =0x00120000
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD
	ldr	r1, =0x00130000
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD
	ldr	r1, =0x00110002
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD
	ldr	r1, =0x00100328
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD

	mov	r2, #0x100000
6:	subs	r2, r2, #1
	bne	6b

	ldr	r1, =0x0a100000
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD

	mov	r2, #0x100000
7:	subs	r2, r2, #1
	bne	7b

	ldr	r1, =0xe000008e
	str	r1, [r0, #0x1C]		@DMC_PHYCONTROL1
	ldr	r1, =0xe0000086
	str	r1, [r0, #0x1C]		@DMC_PHYCONTROL1

	mov	r2, #0x100000
8:	subs	r2, r2, #1
	bne	8b

	/* DREX1 */
	ldr	r0, =S5PC210_DMC1_BASE	@0x10410000

	ldr	r1, =0xe0000086
	str	r1, [r0, #0x1C]		@DMC_PHYCONTROL1

	ldr	r1, =0xE3855703
	str	r1, [r0, #0x44]		@DMC_PHYZQCONTROL

	mov	r2, #0x100000
1:	subs	r2, r2, #1
	bne	1b

	ldr	r1, =0xe000008e
	str	r1, [r0, #0x1C]		@DMC_PHYCONTROL1
	ldr	r1, =0xe0000086
	str	r1, [r0, #0x1C]		@DMC_PHYCONTROL1

	ldr	r1, =0x71101008
	str	r1, [r0, #0x18]		@DMC_PHYCONTROL0
	ldr	r1, =0x7110100A
	str	r1, [r0, #0x18]		@DMC_PHYCONTROL0
	ldr	r1, =0xe0000086
	str	r1, [r0, #0x1C]		@DMC_PHYCONTROL1
	ldr	r1, =0x7110100B
	str	r1, [r0, #0x18]		@DMC_PHYCONTROL0

	ldr	r1, =0x00000000
	str	r1, [r0, #0x20]		@DMC_PHYCONTROL2

	ldr	r1, =0x0FFF301a
	str	r1, [r0, #0x00]		@DMC_CONCONTROL
	ldr	r1, =0x00312640
	str	r1, [r0, #0x04]		@DMC_MEMCONTROL]

#ifdef CONFIG_MIU_LINEAR
	ldr	r1, =0x40e01323
	str	r1, [r0, #0x08]		@DMC_MEMCONFIG0
	ldr	r1, =0x60e01323
	str	r1, [r0, #0x0C]		@DMC_MEMCONFIG1
#else	/* @MIU_1BIT_INTERLEAVED | MIU_2BIT_INTERLEAVED */
	ldr	r1, =0x20e01323
	str	r1, [r0, #0x08]		@DMC_MEMCONFIG0
	ldr	r1, =0x40e01323
	str	r1, [r0, #0x0C]		@DMC_MEMCONFIG1
#endif

	ldr	r1, =0xff000000
	str	r1, [r0, #0x14]		@DMC_PRECHCONFIG

	ldr	r1, =0x000000BC
	str	r1, [r0, #0x30]		@DMC_TIMINGAREF

#ifdef DRAM_CLK_330
	ldr	r1, =0x3545548d
	str	r1, [r0, #0x34]		@DMC_TIMINGROW
	ldr	r1, =0x45430506
	str	r1, [r0, #0x38]		@DMC_TIMINGDATA
	ldr	r1, =0x4439033c
	str	r1, [r0, #0x3C]		@DMC_TIMINGPOWER
#endif
#ifdef DRAM_CLK_400
	ldr	r1, =0x4046654f
	str	r1, [r0, #0x34]		@DMC_TIMINGROW
	ldr	r1, =0x56500506
	str	r1, [r0, #0x38]		@DMC_TIMINGDATA
	ldr	r1, =0x5444033d
	str	r1, [r0, #0x3C]		@DMC_TIMINGPOWER
#endif

	ldr	r1, =0x07000000
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD

	mov	r2, #0x100000
2:	subs	r2, r2, #1
	bne	2b

	ldr	r1, =0x00020000
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD
	ldr	r1, =0x00030000
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD
	ldr	r1, =0x00010002
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD
	ldr	r1, =0x00000328
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD

	mov	r2, #0x100000
3:	subs	r2, r2, #1
	bne	3b

	ldr	r1, =0x0a000000
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD

	mov	r2, #0x100000
4:	subs	r2, r2, #1
	bne	4b

	ldr	r1, =0x07100000
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD

	mov	r2, #0x100000
5:	subs	r2, r2, #1
	bne	5b

	ldr	r1, =0x00120000
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD
	ldr	r1, =0x00130000
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD
	ldr	r1, =0x00110002
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD
	ldr	r1, =0x00100328
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD

	mov	r2, #0x100000
6:	subs	r2, r2, #1
	bne	6b

	ldr	r1, =0x0a100000
	str	r1, [r0, #0x10]		@DMC_DIRECTCMD

	mov	r2, #0x100000
7:	subs	r2, r2, #1
	bne	7b

	ldr	r1, =0xe000008e
	str	r1, [r0, #0x1C]		@DMC_PHYCONTROL1
	ldr	r1, =0xe0000086
	str	r1, [r0, #0x1C]		@DMC_PHYCONTROL1

	mov	r2, #0x100000
8:	subs	r2, r2, #1
	bne	8b

	/* turn on DREX0, DREX1 */
	ldr	r0, =0x10400000		@APB_DMC_0_BASE
	ldr	r1, =0x0FFF303a
	str	r1, [r0, #0x00]		@DMC_CONCONTROL

	ldr	r0, =0x10410000		@APB_DMC_1_BASE
	ldr	r1, =0x0FFF303a
	str	r1, [r0, #0x00]		@DMC_CONCONTROL

	mov	pc, lr