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
|
/*
* Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <config.h>
/* DDR script */
.macro imx7d_ddrphy_latency_setting
ldr r2, =ANATOP_BASE_ADDR
ldr r3, [r2, #0x800]
and r3, r3, #0xFF
cmp r3, #0x11
bne TUNE_END
/*TO 1.1*/
ldr r1, =0x1c1c1c1c
str r1, [r0, #0x7c]
ldr r1, =0x1c1c1c1c
str r1, [r0, #0x80]
ldr r1, =0x30301c1c
str r1, [r0, #0x84]
ldr r1, =0x00000030
str r1, [r0, #0x88]
ldr r1, =0x30303030
str r1, [r0, #0x6c]
TUNE_END:
.endm
.macro imx7d_12x12_lpddr3_arm2_setting
/* check whether it is a LPSR resume */
ldr r1, =0x30270000
ldr r7, [r1]
cmp r7, #0
beq 16f
/* disable wdog powerdown counter */
ldr r0, =0x30280000
ldrh r1, =0x0
strh r1, [r0, #0x8]
/* initialize AIPs 1-3 port */
ldr r0, =0x301f0000
ldr r1, =0x77777777
str r1, [r0]
str r1, [r0, #0x4]
ldr r1, =0x0
str r1, [r0, #0x40]
str r1, [r0, #0x44]
str r1, [r0, #0x48]
str r1, [r0, #0x4c]
str r1, [r0, #0x50]
ldr r0, =0x305f0000
ldr r1, =0x77777777
str r1, [r0]
str r1, [r0, #0x4]
ldr r1, =0x0
str r1, [r0, #0x40]
str r1, [r0, #0x44]
str r1, [r0, #0x48]
str r1, [r0, #0x4c]
str r1, [r0, #0x50]
ldr r0, =0x309f0000
ldr r1, =0x77777777
str r1, [r0]
str r1, [r0, #0x4]
ldr r1, =0x0
str r1, [r0, #0x40]
str r1, [r0, #0x44]
str r1, [r0, #0x48]
str r1, [r0, #0x4c]
str r1, [r0, #0x50]
ldr r1, =0x30360000
ldr r2, =0x30390000
ldr r3, =0x307a0000
ldr r4, =0x30790000
ldr r10, =0x30380000
ldr r11, =0x30340000
/* turn on ddr power */
ldr r7, =(0x1 << 29)
str r7, [r1, #0x388]
ldr r6, =50
1:
subs r6, r6, #0x1
bne 1b
/* clear ddr_phy reset */
ldr r6, =0x1000
ldr r7, [r2, r6]
orr r7, r7, #0x3
str r7, [r2, r6]
ldr r7, [r2, r6]
bic r7, r7, #0x1
str r7, [r2, r6]
/* restore DDRC */
ldr r6, =0x0
ldr r7, =0x03040008
str r7, [r3, r6]
ldr r6, =0x1a0
ldr r7, =0x80400003
str r7, [r3, r6]
ldr r6, =0x1a4
ldr r7, =0x00100020
str r7, [r3, r6]
ldr r6, =0x1a8
ldr r7, =0x80100004
str r7, [r3, r6]
ldr r6, =0x64
ldr r7, =0x00200038
str r7, [r3, r6]
ldr r6, =0xd0
ldr r7, =0xc0350001
str r7, [r3, r6]
ldr r6, =0xdc
ldr r7, =0x00C3000A
str r7, [r3, r6]
ldr r6, =0xe0
ldr r7, =0x00010000
str r7, [r3, r6]
ldr r6, =0xe4
ldr r7, =0x00110006
str r7, [r3, r6]
ldr r6, =0xf4
ldr r7, =0x0000033F
str r7, [r3, r6]
ldr r6, =0x100
ldr r7, =0x0A0E110B
str r7, [r3, r6]
ldr r6, =0x104
ldr r7, =0x00020211
str r7, [r3, r6]
ldr r6, =0x108
ldr r7, =0x03060707
str r7, [r3, r6]
ldr r6, =0x10c
ldr r7, =0x00A0500C
str r7, [r3, r6]
ldr r6, =0x110
ldr r7, =0x05020307
str r7, [r3, r6]
ldr r6, =0x114
ldr r7, =0x02020404
str r7, [r3, r6]
ldr r6, =0x118
ldr r7, =0x02020003
str r7, [r3, r6]
ldr r6, =0x11c
ldr r7, =0x00000202
str r7, [r3, r6]
ldr r6, =0x180
ldr r7, =0x00600018
str r7, [r3, r6]
ldr r6, =0x184
ldr r7, =0x00e00100
str r7, [r3, r6]
ldr r6, =0x190
ldr r7, =0x02098205
str r7, [r3, r6]
ldr r6, =0x194
ldr r7, =0x00060303
str r7, [r3, r6]
ldr r6, =0x200
ldr r7, =0x00000016
str r7, [r3, r6]
ldr r6, =0x204
ldr r7, =0x00171717
str r7, [r3, r6]
ldr r6, =0x214
ldr r7, =0x05050505
str r7, [r3, r6]
ldr r6, =0x218
ldr r7, =0x0F0F0505
str r7, [r3, r6]
ldr r6, =0x240
ldr r7, =0x06000601
str r7, [r3, r6]
ldr r6, =0x244
ldr r7, =0x00000000
str r7, [r3, r6]
ldr r7, =0x20
str r7, [r3, #0x30]
ldr r7, =0x0
str r7, [r3, #0x1b0]
/* do PHY, clear ddr_phy reset */
ldr r6, =0x1000
ldr r7, [r2, r6]
bic r7, r7, #0x2
str r7, [r2, r6]
ldr r7, [r1, #0x800]
and r7, r7, #0xFF
cmp r7, #0x10
beq 2f
/* TO1.1 */
ldr r7, [r11]
bic r7, r7, #(1 << 27)
str r7, [r11]
ldr r7, [r11]
bic r7, r7, #(1 << 29)
str r7, [r11]
2:
/* clear/set bit30 of SNVS_MISC_CTRL to ensure exit from ddr retention */
ldr r7, =(0x1 << 30)
str r7, [r1, #0x388]
ldr r7, =(0x1 << 30)
str r7, [r1, #0x384]
/* need to delay ~5mS */
ldr r6, =0x100000
3:
subs r6, r6, #0x1
bne 3b
/* restore DDR PHY */
ldr r6, =0x0
ldr r7, =0x17421E40
str r7, [r4, r6]
ldr r6, =0x4
ldr r7, =0x10210100
str r7, [r4, r6]
ldr r6, =0x8
ldr r7, =0x00010000
str r7, [r4, r6]
ldr r6, =0x10
ldr r7, =0x0007080C
str r7, [r4, r6]
ldr r7, [r1, #0x800]
and r7, r7, #0xFF
cmp r7, #0x10
beq 4f
ldr r6, =0x7c
ldr r7, =0x1c1c1c1c
str r7, [r4, r6]
ldr r6, =0x80
ldr r7, =0x1c1c1c1c
str r7, [r4, r6]
ldr r6, =0x84
ldr r7, =0x30301c1c
str r7, [r4, r6]
ldr r6, =0x88
ldr r7, =0x00000030
str r7, [r4, r6]
ldr r6, =0x6c
ldr r7, =0x30303030
str r7, [r4, r6]
4:
ldr r6, =0x1c
ldr r7, =0x01010000
str r7, [r4, r6]
ldr r6, =0x9c
ldr r7, =0x0DB60D6E
str r7, [r4, r6]
ldr r6, =0x20
ldr r7, =0x0a0a0a0a
str r7, [r4, r6]
ldr r6, =0x30
ldr r7, =0x06060606
str r7, [r4, r6]
ldr r6, =0x50
ldr r7, =0x01000008
str r7, [r4, r6]
ldr r6, =0x50
ldr r7, =0x00000008
str r7, [r4, r6]
ldr r6, =0xc0
ldr r7, =0x0e407304
str r7, [r4, r6]
ldr r6, =0xc0
ldr r7, =0x0e447304
str r7, [r4, r6]
ldr r6, =0xc0
ldr r7, =0x0e447306
str r7, [r4, r6]
ldr r6, =0xc0
ldr r7, =0x0e4c7304
str r7, [r4, r6]
ldr r6, =0xc0
ldr r7, =0x0e487306
str r7, [r4, r6]
ldr r7, =0x0
add r9, r10, #0x4000
str r7, [r9, #0x130]
ldr r7, =0x170
orr r7, r7, #0x8
str r7, [r11, #0x20]
ldr r7, =0x2
add r9, r10, #0x4000
str r7, [r9, #0x130]
ldr r7, =0xf
str r7, [r4, #0x18]
/* wait until self-refresh mode entered */
11:
ldr r7, [r3, #0x4]
and r7, r7, #0x3
cmp r7, #0x3
bne 11b
ldr r7, =0x0
str r7, [r3, #0x320]
ldr r7, =0x1
str r7, [r3, #0x1b0]
ldr r7, =0x1
str r7, [r3, #0x320]
12:
ldr r7, [r3, #0x324]
and r7, r7, #0x1
cmp r7, #0x1
bne 12b
13:
ldr r7, [r3, #0x4]
and r7, r7, #0x20
cmp r7, #0x20
bne 13b
/* let DDR out of self-refresh */
ldr r7, =0x0
str r7, [r3, #0x30]
14:
ldr r7, [r3, #0x4]
and r7, r7, #0x30
cmp r7, #0x0
bne 14b
15:
ldr r7, [r3, #0x4]
and r7, r7, #0x3
cmp r7, #0x1
bne 15b
/* enable port */
ldr r7, =0x1
str r7, [r3, #0x490]
/* jump to kernel resume */
ldr r1, =0x30270000
ldr r7, [r1]
mov pc, r7
16:
/* Configure ocram_epdc */
ldr r0, =IOMUXC_GPR_BASE_ADDR
ldr r1, =0x4f400005
str r1, [r0, #0x4]
/* clear/set bit30 of SNVS_MISC_CTRL to ensure exit from ddr retention */
ldr r0, =ANATOP_BASE_ADDR
ldr r1, =(0x1 << 30)
str r1, [r0, #0x388]
str r1, [r0, #0x384]
ldr r0, =SRC_BASE_ADDR
ldr r1, =0x2
ldr r2, =0x1000
str r1, [r0, r2]
ldr r0, =DDRC_IPS_BASE_ADDR
ldr r1, =0x03040008
str r1, [r0]
ldr r1, =0x00200038
str r1, [r0, #0x64]
ldr r1, =0x1
str r1, [r0, #0x490]
ldr r1, =0x00350001
str r1, [r0, #0xd0]
ldr r1, =0x00c3000a
str r1, [r0, #0xdc]
ldr r1, =0x00010000
str r1, [r0, #0xe0]
ldr r1, =0x00110006
str r1, [r0, #0xe4]
ldr r1, =0x33f
str r1, [r0, #0xf4]
ldr r1, =0x0a0e110b
str r1, [r0, #0x100]
ldr r1, =0x00020211
str r1, [r0, #0x104]
ldr r1, =0x03060708
str r1, [r0, #0x108]
ldr r1, =0x00a0500c
str r1, [r0, #0x10c]
ldr r1, =0x05020307
str r1, [r0, #0x110]
ldr r1, =0x02020404
str r1, [r0, #0x114]
ldr r1, =0x02020003
str r1, [r0, #0x118]
ldr r1, =0x00000202
str r1, [r0, #0x11c]
ldr r1, =0x00000202
str r1, [r0, #0x120]
ldr r1, =0x00600018
str r1, [r0, #0x180]
ldr r1, =0x00e00100
str r1, [r0, #0x184]
ldr r1, =0x02098205
str r1, [r0, #0x190]
ldr r1, =0x00060303
str r1, [r0, #0x194]
ldr r1, =0x80400003
str r1, [r0, #0x1a0]
ldr r1, =0x00100020
str r1, [r0, #0x1a4]
ldr r1, =0x80100004
str r1, [r0, #0x1a8]
ldr r1, =0x00000016
str r1, [r0, #0x200]
ldr r1, =0x00171717
str r1, [r0, #0x204]
ldr r1, =0x00000f00
str r1, [r0, #0x210]
ldr r1, =0x05050505
str r1, [r0, #0x214]
ldr r1, =0x0f0f0505
str r1, [r0, #0x218]
ldr r1, =0x06000601
str r1, [r0, #0x240]
mov r1, #0x0
str r1, [r0, #0x244]
ldr r0, =SRC_BASE_ADDR
mov r1, #0x0
ldr r2, =0x1000
str r1, [r0, r2]
ldr r0, =DDRPHY_IPS_BASE_ADDR
ldr r1, =0x17421e40
str r1, [r0]
ldr r1, =0x10210100
str r1, [r0, #0x4]
ldr r1, =0x00010000
str r1, [r0, #0x8]
ldr r1, =0x0007080c
str r1, [r0, #0x10]
imx7d_ddrphy_latency_setting
ldr r1, =0x1010007e
str r1, [r0, #0xb0]
ldr r1, =0x01010000
str r1, [r0, #0x1c]
ldr r1, =0x0db60d6e
str r1, [r0, #0x9c]
ldr r1, =0x06060606
str r1, [r0, #0x30]
ldr r1, =0x0a0a0a0a
str r1, [r0, #0x20]
ldr r1, =0x01000008
str r1, [r0, #0x50]
ldr r1, =0x00000008
str r1, [r0, #0x50]
ldr r1, =0x0000000f
str r1, [r0, #0x18]
ldr r1, =0x1e487304
str r1, [r0, #0xc0]
ldr r1, =0x1e487304
str r1, [r0, #0xc0]
ldr r1, =0x1e487306
str r1, [r0, #0xc0]
ldr r1, =0x1e4c7304
str r1, [r0, #0xc0]
wait_zq:
ldr r1, [r0, #0xc4]
tst r1, #0x1
beq wait_zq
ldr r1, =0x1e487304
str r1, [r0, #0xc0]
ldr r0, =CCM_BASE_ADDR
mov r1, #0x0
ldr r2, =0x4130
str r1, [r0, r2]
ldr r0, =IOMUXC_GPR_BASE_ADDR
mov r1, #0x178
str r1, [r0, #0x20]
ldr r0, =CCM_BASE_ADDR
mov r1, #0x2
ldr r2, =0x4130
str r1, [r0, r2]
ldr r0, =DDRC_IPS_BASE_ADDR
wait_stat:
ldr r1, [r0, #0x4]
tst r1, #0x1
beq wait_stat
.endm
.macro imx7_clock_gating
.endm
.macro imx7_qos_setting
.endm
.macro imx7_ddr_setting
imx7d_12x12_lpddr3_arm2_setting
.endm
/* include the common plugin code here */
#include <asm/arch/mx7_plugin.S>
|