2 * Copyright (C) 2011 Renesas Solutions Corp.
4 * SPDX-License-Identifier: GPL-2.0+
8 #include <asm/processor.h>
11 .macro or32, addr, data
25 .section .spiboot1.text
30 /*------- GPIO -------*/
31 write8 PGDR_A, PGDR_D /* eMMC power off */
33 write16 PACR_A, PACR_D
34 write16 PBCR_A, PBCR_D
35 write16 PCCR_A, PCCR_D
36 write16 PDCR_A, PDCR_D
37 write16 PECR_A, PECR_D
38 write16 PFCR_A, PFCR_D
39 write16 PGCR_A, PGCR_D
40 write16 PHCR_A, PHCR_D
41 write16 PICR_A, PICR_D
42 write16 PJCR_A, PJCR_D
43 write16 PKCR_A, PKCR_D
44 write16 PLCR_A, PLCR_D
45 write16 PMCR_A, PMCR_D
46 write16 PNCR_A, PNCR_D
47 write16 POCR_A, POCR_D
48 write16 PQCR_A, PQCR_D
49 write16 PRCR_A, PRCR_D
50 write16 PSCR_A, PSCR_D
51 write16 PTCR_A, PTCR_D
52 write16 PUCR_A, PUCR_D
53 write16 PVCR_A, PVCR_D
54 write16 PWCR_A, PWCR_D
55 write16 PXCR_A, PXCR_D
56 write16 PYCR_A, PYCR_D
57 write16 PZCR_A, PZCR_D
58 write16 PSEL0_A, PSEL0_D
59 write16 PSEL1_A, PSEL1_D
60 write16 PSEL2_A, PSEL2_D
61 write16 PSEL3_A, PSEL3_D
62 write16 PSEL4_A, PSEL4_D
63 write16 PSEL5_A, PSEL5_D
64 write16 PSEL6_A, PSEL6_D
65 write16 PSEL7_A, PSEL7_D
66 write16 PSEL8_A, PSEL8_D
73 /*------- GPIO -------*/
74 PGDR_A: .long 0xffec0040
75 PACR_A: .long 0xffec0000
76 PBCR_A: .long 0xffec0002
77 PCCR_A: .long 0xffec0004
78 PDCR_A: .long 0xffec0006
79 PECR_A: .long 0xffec0008
80 PFCR_A: .long 0xffec000a
81 PGCR_A: .long 0xffec000c
82 PHCR_A: .long 0xffec000e
83 PICR_A: .long 0xffec0010
84 PJCR_A: .long 0xffec0012
85 PKCR_A: .long 0xffec0014
86 PLCR_A: .long 0xffec0016
87 PMCR_A: .long 0xffec0018
88 PNCR_A: .long 0xffec001a
89 POCR_A: .long 0xffec001c
90 PQCR_A: .long 0xffec0020
91 PRCR_A: .long 0xffec0022
92 PSCR_A: .long 0xffec0024
93 PTCR_A: .long 0xffec0026
94 PUCR_A: .long 0xffec0028
95 PVCR_A: .long 0xffec002a
96 PWCR_A: .long 0xffec002c
97 PXCR_A: .long 0xffec002e
98 PYCR_A: .long 0xffec0030
99 PZCR_A: .long 0xffec0032
100 PSEL0_A: .long 0xffec0070
101 PSEL1_A: .long 0xffec0072
102 PSEL2_A: .long 0xffec0074
103 PSEL3_A: .long 0xffec0076
104 PSEL4_A: .long 0xffec0078
105 PSEL5_A: .long 0xffec007a
106 PSEL6_A: .long 0xffec007c
107 PSEL7_A: .long 0xffec0082
108 PSEL8_A: .long 0xffec0084
130 #if defined(CONFIG_SH7757_OFFSET_SPI)
140 PSEL0_D: .long 0xfe00
141 PSEL1_D: .long 0x0000
142 PSEL2_D: .long 0x3000
143 PSEL3_D: .long 0xff00
144 PSEL4_D: .long 0x771f
145 PSEL5_D: .long 0x0ffc
146 PSEL6_D: .long 0x00ff
147 PSEL7_D: .long 0xfc00
148 PSEL8_D: .long 0x0000
164 /* If CPU runs on SDRAM, PC is 0x8???????. */
165 PC_MASK: .long 0x20000000
172 mov.l EXPEVT_POWER_ON_RESET, r1
177 * If EXPEVT value is manual reset or tlb multipul-hit,
178 * initialization of DDR3IF is not necessary.
191 * If DBACEN == 1(DBSC was already enabled), we have to avoid the
192 * initialization of DDR3-SDRAM.
198 /*------- DDR3IF -------*/
199 /* oscillation stabilization time */
200 wait_timer WAIT_OSC_TIME
203 write32 DBCMD_A, DBCMD_RSTL_VAL
207 write32 DBCMD_A, DBCMD_PDEN_VAL
210 write32 DBKIND_A, DBKIND_D
213 write32 DBCONF_A, DBCONF_D
214 write32 DBTR0_A, DBTR0_D
215 write32 DBTR1_A, DBTR1_D
216 write32 DBTR2_A, DBTR2_D
217 write32 DBTR3_A, DBTR3_D
218 write32 DBTR4_A, DBTR4_D
219 write32 DBTR5_A, DBTR5_D
220 write32 DBTR6_A, DBTR6_D
221 write32 DBTR7_A, DBTR7_D
222 write32 DBTR8_A, DBTR8_D
223 write32 DBTR9_A, DBTR9_D
224 write32 DBTR10_A, DBTR10_D
225 write32 DBTR11_A, DBTR11_D
226 write32 DBTR12_A, DBTR12_D
227 write32 DBTR13_A, DBTR13_D
228 write32 DBTR14_A, DBTR14_D
229 write32 DBTR15_A, DBTR15_D
230 write32 DBTR16_A, DBTR16_D
231 write32 DBTR17_A, DBTR17_D
232 write32 DBTR18_A, DBTR18_D
233 write32 DBTR19_A, DBTR19_D
234 write32 DBRNK0_A, DBRNK0_D
237 write32 DBPDCNT3_A, DBPDCNT3_D
240 write32 DBPDCNT1_A, DBPDCNT1_D
241 write32 DBPDCNT2_A, DBPDCNT2_D
242 write32 DBPDLCK_A, DBPDLCK_D
243 write32 DBPDRGA_A, DBPDRGA_D
244 write32 DBPDRGD_A, DBPDRGD_D
250 write32 DBPDCNT0_A, DBPDCNT0_D
257 write32 DBCMD_A, DBCMD_WAIT_VAL
261 write32 DBCMD_A, DBCMD_RSTH_VAL
265 write32 DBCMD_A, DBCMD_WAIT_VAL
266 write32 DBCMD_A, DBCMD_WAIT_VAL
267 write32 DBCMD_A, DBCMD_WAIT_VAL
268 write32 DBCMD_A, DBCMD_WAIT_VAL
271 write32 DBCMD_A, DBCMD_PDXT_VAL
274 write32 DBCMD_A, DBCMD_MRS2_VAL
277 write32 DBCMD_A, DBCMD_MRS3_VAL
280 write32 DBCMD_A, DBCMD_MRS1_VAL
283 write32 DBCMD_A, DBCMD_MRS0_VAL
286 write32 DBCMD_A, DBCMD_ZQCL_VAL
288 write32 DBCMD_A, DBCMD_REF_VAL
289 write32 DBCMD_A, DBCMD_REF_VAL
293 write32 DBADJ0_A, DBADJ0_D
294 write32 DBADJ1_A, DBADJ1_D
295 write32 DBADJ2_A, DBADJ2_D
298 write32 DBRFCNF0_A, DBRFCNF0_D
299 write32 DBRFCNF1_A, DBRFCNF1_D
300 write32 DBRFCNF2_A, DBRFCNF2_D
303 write32 DBCALCNF_A, DBCALCNF_D
306 write32 DBRFEN_A, DBRFEN_D
307 write32 DBCMD_A, DBCMD_SRXT_VAL
310 write32 DBACEN_A, DBACEN_D
315 #if defined(CONFIG_SH7757LCR_DDR_ECC)
317 write32 ECD_ECDEN_A, ECD_ECDEN_D
318 write32 ECD_INTSR_A, ECD_INTSR_D
319 write32 ECD_SPACER_A, ECD_SPACER_D
320 write32 ECD_MCR_A, ECD_MCR_D
327 EXPEVT_A: .long 0xff000024
328 EXPEVT_POWER_ON_RESET: .long 0x00000000
330 /*------- DDR3IF -------*/
331 DBCMD_A: .long 0xfe800018
332 DBKIND_A: .long 0xfe800020
333 DBCONF_A: .long 0xfe800024
334 DBTR0_A: .long 0xfe800040
335 DBTR1_A: .long 0xfe800044
336 DBTR2_A: .long 0xfe800048
337 DBTR3_A: .long 0xfe800050
338 DBTR4_A: .long 0xfe800054
339 DBTR5_A: .long 0xfe800058
340 DBTR6_A: .long 0xfe80005c
341 DBTR7_A: .long 0xfe800060
342 DBTR8_A: .long 0xfe800064
343 DBTR9_A: .long 0xfe800068
344 DBTR10_A: .long 0xfe80006c
345 DBTR11_A: .long 0xfe800070
346 DBTR12_A: .long 0xfe800074
347 DBTR13_A: .long 0xfe800078
348 DBTR14_A: .long 0xfe80007c
349 DBTR15_A: .long 0xfe800080
350 DBTR16_A: .long 0xfe800084
351 DBTR17_A: .long 0xfe800088
352 DBTR18_A: .long 0xfe80008c
353 DBTR19_A: .long 0xfe800090
354 DBRNK0_A: .long 0xfe800100
355 DBPDCNT0_A: .long 0xfe800200
356 DBPDCNT1_A: .long 0xfe800204
357 DBPDCNT2_A: .long 0xfe800208
358 DBPDCNT3_A: .long 0xfe80020c
359 DBPDLCK_A: .long 0xfe800280
360 DBPDRGA_A: .long 0xfe800290
361 DBPDRGD_A: .long 0xfe8002a0
362 DBADJ0_A: .long 0xfe8000c0
363 DBADJ1_A: .long 0xfe8000c4
364 DBADJ2_A: .long 0xfe8000c8
365 DBRFCNF0_A: .long 0xfe8000e0
366 DBRFCNF1_A: .long 0xfe8000e4
367 DBRFCNF2_A: .long 0xfe8000e8
368 DBCALCNF_A: .long 0xfe8000f4
369 DBRFEN_A: .long 0xfe800014
370 DBACEN_A: .long 0xfe800010
371 DBWAIT_A: .long 0xfe80001c
373 WAIT_OSC_TIME: .long 6000
374 WAIT_30US: .long 13333
376 DBCMD_RSTL_VAL: .long 0x20000000
377 DBCMD_PDEN_VAL: .long 0x1000d73c
378 DBCMD_WAIT_VAL: .long 0x0000d73c
379 DBCMD_RSTH_VAL: .long 0x2100d73c
380 DBCMD_PDXT_VAL: .long 0x110000c8
381 DBCMD_MRS0_VAL: .long 0x28000930
382 DBCMD_MRS1_VAL: .long 0x29000004
383 DBCMD_MRS2_VAL: .long 0x2a000008
384 DBCMD_MRS3_VAL: .long 0x2b000000
385 DBCMD_ZQCL_VAL: .long 0x03000200
386 DBCMD_REF_VAL: .long 0x0c000000
387 DBCMD_SRXT_VAL: .long 0x19000000
388 DBKIND_D: .long 0x00000007
389 DBCONF_D: .long 0x0f030a01
390 DBTR0_D: .long 0x00000007
391 DBTR1_D: .long 0x00000006
392 DBTR2_D: .long 0x00000000
393 DBTR3_D: .long 0x00000007
394 DBTR4_D: .long 0x00070007
395 DBTR5_D: .long 0x0000001b
396 DBTR6_D: .long 0x00000014
397 DBTR7_D: .long 0x00000005
398 DBTR8_D: .long 0x00000015
399 DBTR9_D: .long 0x00000006
400 DBTR10_D: .long 0x00000008
401 DBTR11_D: .long 0x00000007
402 DBTR12_D: .long 0x0000000e
403 DBTR13_D: .long 0x00000056
404 DBTR14_D: .long 0x00000006
405 DBTR15_D: .long 0x00000004
406 DBTR16_D: .long 0x00150002
407 DBTR17_D: .long 0x000c0017
408 DBTR18_D: .long 0x00000200
409 DBTR19_D: .long 0x00000040
410 DBRNK0_D: .long 0x00000001
411 DBPDCNT0_D: .long 0x00000001
412 DBPDCNT1_D: .long 0x00000001
413 DBPDCNT2_D: .long 0x00000000
414 DBPDCNT3_D: .long 0x00004010
415 DBPDLCK_D: .long 0x0000a55a
416 DBPDRGA_D: .long 0x00000028
417 DBPDRGD_D: .long 0x00017100
419 DBADJ0_D: .long 0x00000000
420 DBADJ1_D: .long 0x00000000
421 DBADJ2_D: .long 0x18061806
422 DBRFCNF0_D: .long 0x000001ff
423 DBRFCNF1_D: .long 0x08001000
424 DBRFCNF2_D: .long 0x00000000
425 DBCALCNF_D: .long 0x0000ffff
426 DBRFEN_D: .long 0x00000001
427 DBACEN_D: .long 0x00000001
429 /*------- DDR-ECC -------*/
430 ECD_ECDEN_A: .long 0xffc1012c
431 ECD_ECDEN_D: .long 0x00000001
432 ECD_INTSR_A: .long 0xfe900024
433 ECD_INTSR_D: .long 0xffffffff
434 ECD_SPACER_A: .long 0xfe900018
435 ECD_SPACER_D: .long SH7757LCR_SDRAM_ECC_SETTING
436 ECD_MCR_A: .long 0xfe900010
437 ECD_MCR_D: .long 0x00000001
442 #if defined(CONFIG_SH_32BIT)
443 /*------- set PMB -------*/
444 write32 PASCR_A, PASCR_29BIT_D
445 write32 MMUCR_A, MMUCR_D
447 /*****************************************************************
448 * ent virt phys v sz c wt
449 * 0 0xa0000000 0x00000000 1 128M 0 1
450 * 1 0xa8000000 0x48000000 1 128M 0 1
451 * 5 0x88000000 0x48000000 1 128M 1 1
453 write32 PMB_ADDR_SPIBOOT_A, PMB_ADDR_SPIBOOT_D
454 write32 PMB_DATA_SPIBOOT_A, PMB_DATA_SPIBOOT_D
455 write32 PMB_ADDR_DDR_C1_A, PMB_ADDR_DDR_C1_D
456 write32 PMB_DATA_DDR_C1_A, PMB_DATA_DDR_C1_D
457 write32 PMB_ADDR_DDR_N1_A, PMB_ADDR_DDR_N1_D
458 write32 PMB_DATA_DDR_N1_A, PMB_DATA_DDR_N1_D
460 write32 PMB_ADDR_ENTRY2, PMB_ADDR_NOT_USE_D
461 write32 PMB_ADDR_ENTRY3, PMB_ADDR_NOT_USE_D
462 write32 PMB_ADDR_ENTRY4, PMB_ADDR_NOT_USE_D
463 write32 PMB_ADDR_ENTRY6, PMB_ADDR_NOT_USE_D
464 write32 PMB_ADDR_ENTRY7, PMB_ADDR_NOT_USE_D
465 write32 PMB_ADDR_ENTRY8, PMB_ADDR_NOT_USE_D
466 write32 PMB_ADDR_ENTRY9, PMB_ADDR_NOT_USE_D
467 write32 PMB_ADDR_ENTRY10, PMB_ADDR_NOT_USE_D
468 write32 PMB_ADDR_ENTRY11, PMB_ADDR_NOT_USE_D
469 write32 PMB_ADDR_ENTRY12, PMB_ADDR_NOT_USE_D
470 write32 PMB_ADDR_ENTRY13, PMB_ADDR_NOT_USE_D
471 write32 PMB_ADDR_ENTRY14, PMB_ADDR_NOT_USE_D
472 write32 PMB_ADDR_ENTRY15, PMB_ADDR_NOT_USE_D
474 write32 PASCR_A, PASCR_INIT
477 #endif /* if defined(CONFIG_SH_32BIT) */
480 /* CPU is running on ILRAM? */
485 mov.l _bss_start, r15
486 mov.l _spiboot_main, r0
491 _spiboot_main: .long (spiboot_main - (100b + 4))
492 _bss_start: .long bss_start
503 #if defined(CONFIG_SH_32BIT)
504 /*------- set PMB -------*/
505 PMB_ADDR_SPIBOOT_A: .long PMB_ADDR_BASE(0)
506 PMB_ADDR_DDR_N1_A: .long PMB_ADDR_BASE(1)
507 PMB_ADDR_DDR_C1_A: .long PMB_ADDR_BASE(5)
508 PMB_ADDR_ENTRY2: .long PMB_ADDR_BASE(2)
509 PMB_ADDR_ENTRY3: .long PMB_ADDR_BASE(3)
510 PMB_ADDR_ENTRY4: .long PMB_ADDR_BASE(4)
511 PMB_ADDR_ENTRY6: .long PMB_ADDR_BASE(6)
512 PMB_ADDR_ENTRY7: .long PMB_ADDR_BASE(7)
513 PMB_ADDR_ENTRY8: .long PMB_ADDR_BASE(8)
514 PMB_ADDR_ENTRY9: .long PMB_ADDR_BASE(9)
515 PMB_ADDR_ENTRY10: .long PMB_ADDR_BASE(10)
516 PMB_ADDR_ENTRY11: .long PMB_ADDR_BASE(11)
517 PMB_ADDR_ENTRY12: .long PMB_ADDR_BASE(12)
518 PMB_ADDR_ENTRY13: .long PMB_ADDR_BASE(13)
519 PMB_ADDR_ENTRY14: .long PMB_ADDR_BASE(14)
520 PMB_ADDR_ENTRY15: .long PMB_ADDR_BASE(15)
522 PMB_ADDR_SPIBOOT_D: .long mk_pmb_addr_val(0xa0)
523 PMB_ADDR_DDR_C1_D: .long mk_pmb_addr_val(0x88)
524 PMB_ADDR_DDR_N1_D: .long mk_pmb_addr_val(0xa8)
525 PMB_ADDR_NOT_USE_D: .long 0x00000000
527 PMB_DATA_SPIBOOT_A: .long PMB_DATA_BASE(0)
528 PMB_DATA_DDR_N1_A: .long PMB_DATA_BASE(1)
529 PMB_DATA_DDR_C1_A: .long PMB_DATA_BASE(5)
531 /* ppn ub v s1 s0 c wt */
532 PMB_DATA_SPIBOOT_D: .long mk_pmb_data_val(0x00, 0, 1, 1, 0, 0, 1)
533 PMB_DATA_DDR_C1_D: .long mk_pmb_data_val(0x48, 0, 1, 1, 0, 1, 1)
534 PMB_DATA_DDR_N1_D: .long mk_pmb_data_val(0x48, 1, 1, 1, 0, 0, 1)
536 PASCR_A: .long 0xff000070
537 DUMMY_ADDR: .long 0xa0000000
538 PASCR_29BIT_D: .long 0x00000000
539 PASCR_INIT: .long 0x80000080
540 MMUCR_A: .long 0xff000010
541 MMUCR_D: .long 0x00000004 /* clear ITLB */
542 #endif /* CONFIG_SH_32BIT */
545 CCR_D: .long CCR_CACHE_INIT