Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2008 Nobuhiro Iwamatsu |
| 4 | * Copyright (C) 2008 Renesas Solutions Corp. |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 5 | */ |
| 6 | #include <config.h> |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 7 | |
| 8 | #include <asm/processor.h> |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 9 | #include <asm/macro.h> |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 10 | |
| 11 | .global lowlevel_init |
| 12 | |
| 13 | .text |
| 14 | .align 2 |
| 15 | |
| 16 | lowlevel_init: |
| 17 | /* Cache setting */ |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 18 | write32 CCR1_A ,CCR1_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 19 | |
| 20 | /* ConfigurePortPins */ |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 21 | write16 PECRL3_A, PECRL3_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 22 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 23 | write16 PCCRL4_A, PCCRL4_D0 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 24 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 25 | write16 PECRL4_A, PECRL4_D0 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 26 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 27 | write16 PEIORL_A, PEIORL_D0 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 28 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 29 | write16 PCIORL_A, PCIORL_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 30 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 31 | write16 PFCRH2_A, PFCRH2_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 32 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 33 | write16 PFCRH3_A, PFCRH3_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 34 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 35 | write16 PFCRH1_A, PFCRH1_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 36 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 37 | write16 PFIORH_A, PFIORH_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 38 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 39 | write16 PECRL1_A, PECRL1_D0 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 40 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 41 | write16 PEIORL_A, PEIORL_D1 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 42 | |
| 43 | /* Configure Operating Frequency */ |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 44 | write16 WTCSR_A, WTCSR_D0 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 45 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 46 | write16 WTCSR_A, WTCSR_D1 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 47 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 48 | write16 WTCNT_A, WTCNT_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 49 | |
| 50 | /* Set clock mode*/ |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 51 | write16 FRQCR_A, FRQCR_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 52 | |
| 53 | /* Configure Bus And Memory */ |
| 54 | init_bsc_cs0: |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 55 | write16 PCCRL4_A, PCCRL4_D1 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 56 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 57 | write16 PECRL1_A, PECRL1_D1 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 58 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 59 | write32 CMNCR_A, CMNCR_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 60 | |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 61 | write32 CS0BCR_A, CS0BCR_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 62 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 63 | write32 CS0WCR_A, CS0WCR_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 64 | |
| 65 | init_bsc_cs1: |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 66 | write16 PECRL4_A, PECRL4_D1 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 67 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 68 | write32 CS1WCR_A, CS1WCR_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 69 | |
| 70 | init_sdram: |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 71 | write16 PCCRL2_A, PCCRL2_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 72 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 73 | write16 PCCRL4_A, PCCRL4_D2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 74 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 75 | write16 PCCRL1_A, PCCRL1_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 76 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 77 | write16 PCCRL3_A, PCCRL3_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 78 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 79 | write32 CS3BCR_A, CS3BCR_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 80 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 81 | write32 CS3WCR_A, CS3WCR_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 82 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 83 | write32 SDCR_A, SDCR_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 84 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 85 | write32 RTCOR_A, RTCOR_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 86 | |
Jean-Christophe PLAGNIOL-VILLARD | b9c2172 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 87 | write32 RTCSR_A, RTCSR_D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 88 | |
| 89 | /* wait 200us */ |
Jean-Christophe PLAGNIOL-VILLARD | bd96370 | 2008-12-20 19:29:48 +0100 | [diff] [blame] | 90 | mov.l REPEAT_D, r3 |
| 91 | mov #0, r2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 92 | repeat0: |
Jean-Christophe PLAGNIOL-VILLARD | bd96370 | 2008-12-20 19:29:48 +0100 | [diff] [blame] | 93 | add #1, r2 |
| 94 | cmp/hs r3, r2 |
| 95 | bf repeat0 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 96 | nop |
| 97 | |
Jean-Christophe PLAGNIOL-VILLARD | bd96370 | 2008-12-20 19:29:48 +0100 | [diff] [blame] | 98 | mov.l SDRAM_MODE, r1 |
| 99 | mov #0, r0 |
| 100 | mov.l r0, @r1 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 101 | |
| 102 | nop |
| 103 | rts |
| 104 | |
| 105 | .align 4 |
| 106 | |
| 107 | CCR1_A: .long CCR1 |
| 108 | CCR1_D: .long 0x0000090B |
| 109 | PCCRL4_A: .long 0xFFFE3910 |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 110 | PCCRL4_D0: .word 0x0000 |
| 111 | .align 2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 112 | PECRL4_A: .long 0xFFFE3A10 |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 113 | PECRL4_D0: .word 0x0000 |
| 114 | .align 2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 115 | PECRL3_A: .long 0xFFFE3A12 |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 116 | PECRL3_D: .word 0x0000 |
| 117 | .align 2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 118 | PEIORL_A: .long 0xFFFE3A06 |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 119 | PEIORL_D0: .word 0x1C00 |
| 120 | PEIORL_D1: .word 0x1C02 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 121 | PCIORL_A: .long 0xFFFE3906 |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 122 | PCIORL_D: .word 0x4000 |
| 123 | .align 2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 124 | PFCRH2_A: .long 0xFFFE3A8C |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 125 | PFCRH2_D: .word 0x0000 |
| 126 | .align 2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 127 | PFCRH3_A: .long 0xFFFE3A8A |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 128 | PFCRH3_D: .word 0x0000 |
| 129 | .align 2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 130 | PFCRH1_A: .long 0xFFFE3A8E |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 131 | PFCRH1_D: .word 0x0000 |
| 132 | .align 2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 133 | PFIORH_A: .long 0xFFFE3A84 |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 134 | PFIORH_D: .word 0x0729 |
| 135 | .align 2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 136 | PECRL1_A: .long 0xFFFE3A16 |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 137 | PECRL1_D0: .word 0x0033 |
| 138 | .align 2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 139 | |
| 140 | |
| 141 | WTCSR_A: .long 0xFFFE0000 |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 142 | WTCSR_D0: .word 0xA518 |
| 143 | WTCSR_D1: .word 0xA51D |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 144 | WTCNT_A: .long 0xFFFE0002 |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 145 | WTCNT_D: .word 0x5A84 |
| 146 | .align 2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 147 | FRQCR_A: .long 0xFFFE0010 |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 148 | FRQCR_D: .word 0x0104 |
| 149 | .align 2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 150 | |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 151 | PCCRL4_D1: .word 0x0010 |
| 152 | PECRL1_D1: .word 0x0133 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 153 | |
| 154 | CMNCR_A: .long 0xFFFC0000 |
| 155 | CMNCR_D: .long 0x00001810 |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 156 | CS0BCR_A: .long 0xFFFC0004 |
| 157 | CS0BCR_D: .long 0x10000400 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 158 | CS0WCR_A: .long 0xFFFC0028 |
| 159 | CS0WCR_D: .long 0x00000B41 |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 160 | PECRL4_D1: .word 0x0100 |
| 161 | .align 2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 162 | CS1WCR_A: .long 0xFFFC002C |
| 163 | CS1WCR_D: .long 0x00000B01 |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 164 | PCCRL4_D2: .word 0x0011 |
| 165 | .align 2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 166 | PCCRL3_A: .long 0xFFFE3912 |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 167 | PCCRL3_D: .word 0x0011 |
| 168 | .align 2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 169 | PCCRL2_A: .long 0xFFFE3914 |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 170 | PCCRL2_D: .word 0x1111 |
| 171 | .align 2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 172 | PCCRL1_A: .long 0xFFFE3916 |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 173 | PCCRL1_D: .word 0x1010 |
Phil Edworthy | 542f75c | 2011-05-31 01:51:42 -0700 | [diff] [blame] | 174 | .align 2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 175 | PDCRL4_A: .long 0xFFFE3990 |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 176 | PDCRL4_D: .word 0x0011 |
| 177 | .align 2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 178 | PDCRL3_A: .long 0xFFFE3992 |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 179 | PDCRL3_D: .word 0x00011 |
| 180 | .align 2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 181 | PDCRL2_A: .long 0xFFFE3994 |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 182 | PDCRL2_D: .word 0x1111 |
| 183 | .align 2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 184 | PDCRL1_A: .long 0xFFFE3996 |
Nobuhiro Iwamatsu | d398fca | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 185 | PDCRL1_D: .word 0x1000 |
| 186 | .align 2 |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 187 | CS3BCR_A: .long 0xFFFC0010 |
| 188 | CS3BCR_D: .long 0x00004400 |
| 189 | CS3WCR_A: .long 0xFFFC0034 |
| 190 | CS3WCR_D: .long 0x00002892 |
| 191 | SDCR_A: .long 0xFFFC004C |
| 192 | SDCR_D: .long 0x00000809 |
| 193 | RTCOR_A: .long 0xFFFC0058 |
| 194 | RTCOR_D: .long 0xA55A0041 |
| 195 | RTCSR_A: .long 0xFFFC0050 |
| 196 | RTCSR_D: .long 0xa55a0010 |
| 197 | |
Nobuhiro Iwamatsu | 6f7d436 | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 198 | SDRAM_MODE: .long 0xFFFC5040 |
| 199 | REPEAT_D: .long 0x00009C40 |