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
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
|
/*
* Freescale MX23 low level RAM timings tables for Micron mDDR
*
* Author: Vitaly Wool <vital@embeddedalley.com>
*
* Copyright 2008-2010 Freescale Semiconductor, Inc.
* Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved.
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
__mx23_emi_set_values:
stmfd r9!, {r0 - r4, lr}
mov r1, #(HW_CLKCTRL_EMI_ADDR & 0x000000FF)
orr r1, r1, #(HW_CLKCTRL_EMI_ADDR & 0x0000FF00)
orr r1, r1, #(HW_CLKCTRL_EMI_ADDR & 0x00FF0000)
orr r1, r1, #(HW_CLKCTRL_EMI_ADDR & 0xFF000000)
@ DDC_RESNCY is deprecated at mx23
@ mov r3, #BM_CLKCTRL_EMI_DCC_RESYNC_ENABLE
mov r0, #(HW_CLKCTRL_FRAC_ADDR & 0x000000FF)
orr r0, r0, #(HW_CLKCTRL_FRAC_ADDR & 0x0000FF00)
orr r0, r0, #(HW_CLKCTRL_FRAC_ADDR & 0x00FF0000)
orr r0, r0, #(HW_CLKCTRL_FRAC_ADDR & 0xFF000000)
ldr r2, [r0]
and r4, r2, #BM_CLKCTRL_FRAC_EMIFRAC
lsr r4, r4, #8
/* new pll div > cur pll div? */
cmp r4, r8
bgt 1f
bic r4, r2, #BM_CLKCTRL_FRAC_EMIFRAC
orr r4, r4, r8, lsl #8
str r4, [r0]
nop
nop
nop
@ Change integer/fractional dividers.
@ The fractional divider and integer divider must be written in such
@ an order to guarantee that when going from a lower frequency to a
@ higher frequency that any intermediate frequencies do not exceed
@ the final frequency. For this reason, we must make sure to check
@ the current divider values with the new divider values and write
@ them in the correct order.
1: ldr r4, [r1]
and r4, r4, #BM_CLKCTRL_EMI_DIV_EMI
/* new emi div > cur emi div? */
cmp r4, r7
bgt 2f
mov r4, r7
orr r4, r4, #0x100
@ This was for DCC_RESYNC_ENABLE, which is deprecated in mx23
@ orr r4, r4, r3
str r4, [r1]
11: ldr r4, [r1]
tst r4, #BM_CLKCTRL_EMI_BUSY_REF_EMI
bne 11b
tst r4, #BM_CLKCTRL_EMI_BUSY_REF_XTAL
bne 11b
2: ldr r2, [r0]
and r4, r2, #BM_CLKCTRL_FRAC_EMIFRAC
lsr r4, r4, #8
/* new pll div != cur pll div? */
cmp r4, r8
beq 3f
bic r4, r2, #BM_CLKCTRL_FRAC_EMIFRAC
orr r4, r4, r8, lsl #8
str r4, [r0]
nop
nop
nop
3: ldr r4, [r1]
and r4, r4, #BM_CLKCTRL_EMI_DIV_EMI
/* new emi div != cur emi div? */
cmp r4, r7
beq 4f
mov r4, r7
orr r4, r4, #0x100
@ This was for DCC_RESYNC_ENABLE, which is deprecated in mx23
@ orr r4, r4, r3
str r4, [r1]
31: ldr r4, [r1]
tst r4, #BM_CLKCTRL_EMI_BUSY_REF_EMI
bne 31b
tst r4, #BM_CLKCTRL_EMI_BUSY_REF_XTAL
bne 31b
4: ldmfd r9!, {r0 - r4, lr}
mov pc, lr
mx23_ram_24M_set_timings:
ldr r0, __mx23_dram_ctl00
#ifdef CONFIG_MXS_RAM_MDDR
adr r1, __mx23_dram_24M_values
#else
// 96MHz is the lowest frequency supported for DDR1.
adr r1, __mx23_dram_96M_values
#endif
1: ldr r2, [r1]
ldr r3, [r1, #4]
mov r4, r2, lsl #2
str r3, [r0, r4]
add r1, r1, #8
cmp r2, #40
bne 1b
mov pc, lr
mx23_ram_48M_set_timings:
ldr r0, __mx23_dram_ctl00
#ifdef CONFIG_MXS_RAM_MDDR
adr r1, __mx23_dram_48M_values
#else
// 96MHz is the lowest frequency supported for DDR1.
adr r1, __mx23_dram_96M_values
#endif
1: ldr r2, [r1]
ldr r3, [r1, #4]
mov r4, r2, lsl #2
str r3, [r0, r4]
add r1, r1, #8
cmp r2, #40
bne 1b
mov pc, lr
mx23_ram_60M_set_timings:
ldr r0, __mx23_dram_ctl00
#ifdef CONFIG_MXS_RAM_MDDR
adr r1, __mx23_dram_60M_values
#else
// 96MHz is the lowest frequency supported for DDR1.
adr r1, __mx23_dram_96M_values
#endif
1: ldr r2, [r1]
ldr r3, [r1, #4]
mov r4, r2, lsl #2
str r3, [r0, r4]
add r1, r1, #8
cmp r2, #40
bne 1b
mov pc, lr
mx23_ram_80M_set_timings:
ldr r0, __mx23_dram_ctl00
#ifdef CONFIG_MXS_RAM_MDDR
adr r1, __mx23_dram_80M_values
#else
// 96MHz is the lowest frequency supported for DDR1.
adr r1, __mx23_dram_96M_values
#endif
1: ldr r2, [r1]
ldr r3, [r1, #4]
mov r4, r2, lsl #2
str r3, [r0, r4]
add r1, r1, #8
cmp r2, #40
bne 1b
mov pc, lr
mx23_ram_96M_set_timings:
ldr r0, __mx23_dram_ctl00
adr r1, __mx23_dram_96M_values
1: ldr r2, [r1]
ldr r3, [r1, #4]
mov r4, r2, lsl #2
str r3, [r0, r4]
add r1, r1, #8
cmp r2, #40
bne 1b
mov pc, lr
mx23_ram_120M_set_timings:
ldr r0, __mx23_dram_ctl00
adr r1, __mx23_dram_120M_values
1: ldr r2, [r1]
ldr r3, [r1, #4]
mov r4, r2, lsl #2
str r3, [r0, r4]
add r1, r1, #8
cmp r2, #40
bne 1b
mov pc, lr
mx23_ram_133M_set_timings:
ldr r0, __mx23_dram_ctl00
adr r1, __mx23_dram_133M_values
1: ldr r2, [r1]
ldr r3, [r1, #4]
str r3, [r0, r2, lsl #2]
add r1, r1, #8
cmp r2, #40
bne 1b
mov pc, lr
mx23_ram_150M_set_timings:
ldr r0, __mx23_dram_ctl00
adr r1, __mx23_dram_150M_values
1: ldr r2, [r1]
ldr r3, [r1, #4]
str r3, [r0, r2, lsl #2]
add r1, r1, #8
cmp r2, #40
bne 1b
mov pc, lr
__mx23_dram_ctl00:
.word MX23_SOC_IO_ADDRESS(REGS_DRAM_PHYS)
__mx23_dram_emi00:
.word MX23_SOC_IO_ADDRESS(REGS_EMI_PHYS)
__mx23_power_vdddctrl:
.word MX23_SOC_IO_ADDRESS(REGS_POWER_PHYS + HW_POWER_VDDDCTRL)
mx23_ram_save_timings:
ldr r0, __mx23_dram_ctl00
adr r1, __mx23_dram_saved_values
1: ldr r2, [r1]
mov r4, r2, lsl #2
ldr r3, [r0, r4]
str r3, [r1, #4]
add r1, r1, #8
cmp r2, #40
bne 1b
mov pc, lr
#ifdef CONFIG_MXS_RAM_MDDR
__mx23_dram_24M_values:
.word 4
.word 0x01000101
.word 7
.word 0x01000101
.word 12
.word 0x02010002
.word 13
.word 0x06060a02
.word 15
.word 0x01030000
.word 17
.word 0x2d000102
.word 18
.word 0x20200000
.word 19
.word 0x027f1414
.word 20
.word 0x01021608
.word 21
.word 0x00000002
.word 26
.word 0x000000b3
.word 32
.word 0x00030687
.word 33
.word 0x00000003
.word 34
.word 0x000012c1
.word 40
.word 0x00010000
__mx23_dram_48M_values:
.word 4
.word 0x01000101
.word 7
.word 0x01000101
.word 13
.word 0x06060a02
.word 12
.word 0x02010002
.word 15
.word 0x02040000
.word 17
.word 0x2d000104
.word 18
.word 0x1f1f0000
.word 19
.word 0x027f0a0a
.word 20
.word 0x02030a10
.word 21
.word 0x00000004
.word 26
.word 0x0000016f
.word 32
.word 0x00060d17
.word 33
.word 0x00000006
.word 34
.word 0x00002582
.word 40
.word 0x00020000
__mx23_dram_60M_values:
__mx23_dram_80M_values:
.word 4
.word 0x01000101
.word 7
.word 0x01000101
.word 12
.word 0x02020002
.word 13
.word 0x06060a02
.word 15
.word 0x02040000
.word 17
.word 0x2d000005
.word 18
.word 0x1f1f0000
.word 19
.word 0x027f0a0a
.word 20
.word 0x02040a10
.word 21
.word 0x00000006
.word 26
.word 0x000001cc
.word 32
.word 0x00081060
.word 33
.word 0x00000008
.word 34
.word 0x00002ee5
.word 40
.word 0x00020000
__mx23_dram_96M_values:
.word 4
.word 0x00000101
.word 7
.word 0x01000001
.word 12
.word 0x02020002
.word 13
.word 0x06070a02
.word 15
.word 0x03050000
.word 17
.word 0x2d000808
.word 18
.word 0x1f1f0000
.word 19
.word 0x020c1010
.word 20
.word 0x0305101c
.word 21
.word 0x00000007
.word 26
.word 0x000002e6
.word 32
.word 0x000c1a3b
.word 33
.word 0x0000000c
.word 34
.word 0x00004b0d
.word 40
.word 0x00030000
__mx23_dram_120M_values:
.word 4
.word 0x00000101
.word 7
.word 0x01000001
.word 12
.word 0x02020002
.word 13
.word 0x06070a02
.word 15
.word 0x03050000
.word 17
.word 0x2300080a
.word 18
.word 0x1f1f0000
.word 19
.word 0x020c1010
.word 20
.word 0x0306101c
.word 21
.word 0x00000009
.word 26
.word 0x000003a1
.word 32
.word 0x000f20ca
.word 33
.word 0x0000000f
.word 34
.word 0x00005dca
.word 40
.word 0x00040000
__mx23_dram_133M_values:
__mx23_dram_150M_values:
.word 4
.word 0x00000101
.word 7
.word 0x01000001
.word 12
.word 0x02020002
.word 13
.word 0x06070a02
.word 15
.word 0x03050000
.word 17
.word 0x2000080a
.word 18
.word 0x1f1f0000
.word 19
.word 0x020c1010
.word 20
.word 0x0306101c
.word 21
.word 0x0000000a
.word 26
.word 0x00000408
.word 32
.word 0x0010245f
.word 33
.word 0x00000010
.word 34
.word 0x00006808
.word 40
.word 0x00040000
#elif CONFIG_MXS_RAM_DDR
__mx23_dram_96M_values:
.word 4
.word 0x00000101
.word 7
.word 0x01000001
.word 11
.word 0x00070202
.word 12
.word 0x02020000 @ t_wr 2, t_rrd 2, t_cke 0
.word 13
.word 0x04040a01 @ t_wtr 1
.word 15
.word 0x02040000 @ t_rp 2, t_dal 4
.word 17
.word 0x2f001706 @ dll_start_point 0x2f, dll_increment 0x17, t_rc 6
.word 19
.word 0x027f1a1a
.word 20
.word 0x02051c21 @ t_rcd 2, t_rasmin 5, wr_dqs_shift 0x22
.word 21
.word 0x00000007 @ t_rfc 7
.word 26
.word 0x000002e6 /* 0x347b */ @ t_ref
.word 32
.word 0x00081a3e @ t_xsnr 8, t_rasmax 0x1a3e
.word 33
.word 0x000000c8 @ t_xsr 0xc8
.word 34
.word 0x00004b0d @ t_init
.word 40
.word 0x00010000
__mx23_dram_120M_values:
.word 4
.word 0x00000101
.word 7
.word 0x01000001
.word 11
.word 0x00070202
.word 12
.word 0x02020000 @ t_wr 2, t_rrd 2, t_cke 0
.word 13
.word 0x04040a01 @ t_wtr 1
.word 15
.word 0x02040000 @ t_rp 2, t_dal 4
.word 17
.word 0x26001308 @ dll_start_point 0x26, dll_increment 0x13, t_rc 8
.word 19
.word 0x027f1a1a
.word 20
.word 0x02061c23 @ t_rcd 2, t_rasmin 6
.word 21
.word 0x00000009 @ t_rfc 9
.word 26
.word 0x000003a1 /* 0x41a6 */ @ t_ref
.word 32
.word 0x000a20ca @ t_xsnr 9, t_rasmax 0x20ca
.word 33
.word 0x000000c8 @ t_xsr 0xc8
.word 34
.word 0x00005dca @ t_init
.word 40
.word 0x00010000
__mx23_dram_133M_values:
.word 4
.word 0x00000101
.word 7
.word 0x01000001
.word 11
.word 0x00070202
.word 12
.word 0x02020000
.word 13
.word 0x04040a01
.word 15
.word 0x02040000
.word 17
.word 0x19000f08 @ t_rc 0xa
.word 19
.word 0x02021313
.word 20
.word 0x02061521
.word 21
.word 0x0000000a
.word 26
.word 0x000003f7 /* 0x48b9 */
.word 32
.word 0x000a23cd
.word 33
.word 0x000000c8 @ t_xsr 0xc8
.word 34
.word 0x00006665
.word 40
.word 0x00010000
__mx23_dram_150M_values:
.word 4
.word 0x00000101
.word 7
.word 0x01000001
/*
Note that CASLAT of 0x06 means 2.5 cycles. This is needed to operate at this
frequency. HOWEVER, we would need to implement the setting of WRITEMODEREG
after setting CAS latency to assure that the new CAS latency is actually
being used in the EMI controller. Otherwise, the controller will still be
using whatever was set the first time the EMI controller was initialized.
Also, a CASLAT of 2.5 needs caslat_lin and caslat_lin_gate of 0x05
(also 2.5 cycles).
*/
.word 11
.word 0x00070206
.word 12
.word 0x02020000 @ t_wr 2, t_rrd 2, t_cke 0
/*
caslat_lin and caslat_lin_gate of 0x05 since CASLAT is 0x06 (2.5 cycles). See above note.
*/
.word 13
.word 0x05050a02 @ t_wtr 2
.word 15
.word 0x03060000 @ t_rp 3, t_dal 6
.word 17
.word 0x18000d0c @ dll_start_point 0x18, dll_increment 0xd, t_rc 0xc
.word 19
.word 0x027f0f0f
.word 20
.word 0x03071121 @ t_rcd 3, t_rasmin 7
.word 21
.word 0x0000000c @ t_rfc 0xc
.word 26
.word 0x000001cc /* 0x20cd */ @ t_ref
.word 32
.word 0x000c2860 @ t_xsnr 0xc, t_rasmax 0x2860
.word 33
.word 0x000000c8 @ t_xsr 0xc8
.word 34
.word 0x00007554 @ t_init
.word 40
.word 0x00010000
#else
#error RAM chip not defined
#endif
mx23_ram_restore_timings:
ldr r0, __mx23_dram_ctl00
adr r1, __mx23_dram_saved_values
1: ldr r2, [r1]
ldr r3, [r1, #4]
mov r4, r2, lsl #2
str r3, [r0, r4]
add r1, r1, #8
cmp r2, #40
bne 1b
mov pc, lr
__mx23_dram_saved_values:
.word 4
.word 0
.word 7
.word 0
.word 12
.word 0
.word 13
.word 0
.word 15
.word 0
.word 17
.word 0
.word 18
.word 0
.word 19
.word 0
.word 20
.word 0
.word 21
.word 0
.word 26
.word 0
.word 32
.word 0
.word 33
.word 0
.word 34
.word 0
.word 40
.word 0
|