wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Most of this taken from Redboot hal_platform_setup.h with cleanup |
| 3 | * |
| 4 | * NOTE: I haven't clean this up considerably, just enough to get it |
| 5 | * running. See hal_platform_setup.h for the source. See |
wdenk | 400558b | 2005-04-02 23:52:25 +0000 | [diff] [blame] | 6 | * board/cradle/lowlevel_init.S for another PXA250 setup that is |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 7 | * much cleaner. |
| 8 | * |
| 9 | * See file CREDITS for list of people who contributed to this |
| 10 | * project. |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License as |
| 14 | * published by the Free Software Foundation; either version 2 of |
| 15 | * the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 25 | * MA 02111-1307 USA |
| 26 | */ |
| 27 | |
| 28 | #include <config.h> |
| 29 | #include <version.h> |
| 30 | #include <asm/arch/pxa-regs.h> |
| 31 | |
| 32 | DRAM_SIZE: .long CFG_DRAM_SIZE |
| 33 | |
| 34 | /* wait for coprocessor write complete */ |
| 35 | .macro CPWAIT reg |
| 36 | mrc p15,0,\reg,c2,c0,0 |
| 37 | mov \reg,\reg |
| 38 | sub pc,pc,#4 |
| 39 | .endm |
| 40 | |
| 41 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 42 | /* |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 43 | * Memory setup |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 44 | */ |
| 45 | |
wdenk | 400558b | 2005-04-02 23:52:25 +0000 | [diff] [blame] | 46 | .globl lowlevel_init |
| 47 | lowlevel_init: |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 48 | |
| 49 | mov r10, lr |
| 50 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 51 | /* Set up GPIO pins first ----------------------------------------- */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 52 | |
| 53 | ldr r0, =GPSR0 |
| 54 | ldr r1, =CFG_GPSR0_VAL |
| 55 | str r1, [r0] |
| 56 | |
| 57 | ldr r0, =GPSR1 |
| 58 | ldr r1, =CFG_GPSR1_VAL |
| 59 | str r1, [r0] |
| 60 | |
| 61 | ldr r0, =GPSR2 |
| 62 | ldr r1, =CFG_GPSR2_VAL |
| 63 | str r1, [r0] |
| 64 | |
| 65 | ldr r0, =GPCR0 |
| 66 | ldr r1, =CFG_GPCR0_VAL |
| 67 | str r1, [r0] |
| 68 | |
| 69 | ldr r0, =GPCR1 |
| 70 | ldr r1, =CFG_GPCR1_VAL |
| 71 | str r1, [r0] |
| 72 | |
| 73 | ldr r0, =GPCR2 |
| 74 | ldr r1, =CFG_GPCR2_VAL |
| 75 | str r1, [r0] |
| 76 | |
| 77 | ldr r0, =GPDR0 |
| 78 | ldr r1, =CFG_GPDR0_VAL |
| 79 | str r1, [r0] |
| 80 | |
| 81 | ldr r0, =GPDR1 |
| 82 | ldr r1, =CFG_GPDR1_VAL |
| 83 | str r1, [r0] |
| 84 | |
| 85 | ldr r0, =GPDR2 |
| 86 | ldr r1, =CFG_GPDR2_VAL |
| 87 | str r1, [r0] |
| 88 | |
| 89 | ldr r0, =GAFR0_L |
| 90 | ldr r1, =CFG_GAFR0_L_VAL |
| 91 | str r1, [r0] |
| 92 | |
| 93 | ldr r0, =GAFR0_U |
| 94 | ldr r1, =CFG_GAFR0_U_VAL |
| 95 | str r1, [r0] |
| 96 | |
| 97 | ldr r0, =GAFR1_L |
| 98 | ldr r1, =CFG_GAFR1_L_VAL |
| 99 | str r1, [r0] |
| 100 | |
| 101 | ldr r0, =GAFR1_U |
| 102 | ldr r1, =CFG_GAFR1_U_VAL |
| 103 | str r1, [r0] |
| 104 | |
| 105 | ldr r0, =GAFR2_L |
| 106 | ldr r1, =CFG_GAFR2_L_VAL |
| 107 | str r1, [r0] |
| 108 | |
| 109 | ldr r0, =GAFR2_U |
| 110 | ldr r1, =CFG_GAFR2_U_VAL |
| 111 | str r1, [r0] |
| 112 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 113 | ldr r0, =PSSR /* enable GPIO pins */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 114 | ldr r1, =CFG_PSSR_VAL |
| 115 | str r1, [r0] |
| 116 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 117 | /* ---------------------------------------------------------------- */ |
| 118 | /* Enable memory interface */ |
| 119 | /* */ |
| 120 | /* The sequence below is based on the recommended init steps */ |
| 121 | /* detailed in the Intel PXA250 Operating Systems Developers Guide, */ |
| 122 | /* Chapter 10. */ |
| 123 | /* ---------------------------------------------------------------- */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 124 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 125 | /* ---------------------------------------------------------------- */ |
| 126 | /* Step 1: Wait for at least 200 microsedonds to allow internal */ |
| 127 | /* clocks to settle. Only necessary after hard reset... */ |
| 128 | /* FIXME: can be optimized later */ |
| 129 | /* ---------------------------------------------------------------- */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 130 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 131 | ldr r3, =OSCR /* reset the OS Timer Count to zero */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 132 | mov r2, #0 |
| 133 | str r2, [r3] |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 134 | ldr r4, =0x300 /* really 0x2E1 is about 200usec, */ |
| 135 | /* so 0x300 should be plenty */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 136 | 1: |
| 137 | ldr r2, [r3] |
| 138 | cmp r4, r2 |
| 139 | bgt 1b |
| 140 | |
| 141 | mem_init: |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 142 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 143 | ldr r1, =MEMC_BASE /* get memory controller base addr. */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 144 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 145 | /* ---------------------------------------------------------------- */ |
| 146 | /* Step 2a: Initialize Asynchronous static memory controller */ |
| 147 | /* ---------------------------------------------------------------- */ |
| 148 | |
| 149 | /* MSC registers: timing, bus width, mem type */ |
| 150 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 151 | /* MSC0: nCS(0,1) */ |
| 152 | ldr r2, =CFG_MSC0_VAL |
| 153 | str r2, [r1, #MSC0_OFFSET] |
| 154 | ldr r2, [r1, #MSC0_OFFSET] /* read back to ensure */ |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 155 | /* that data latches */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 156 | /* MSC1: nCS(2,3) */ |
| 157 | ldr r2, =CFG_MSC1_VAL |
| 158 | str r2, [r1, #MSC1_OFFSET] |
| 159 | ldr r2, [r1, #MSC1_OFFSET] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 160 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 161 | /* MSC2: nCS(4,5) */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 162 | ldr r2, =CFG_MSC2_VAL |
| 163 | str r2, [r1, #MSC2_OFFSET] |
| 164 | ldr r2, [r1, #MSC2_OFFSET] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 165 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 166 | /* ---------------------------------------------------------------- */ |
| 167 | /* Step 2b: Initialize Card Interface */ |
| 168 | /* ---------------------------------------------------------------- */ |
| 169 | |
| 170 | /* MECR: Memory Expansion Card Register */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 171 | ldr r2, =CFG_MECR_VAL |
| 172 | str r2, [r1, #MECR_OFFSET] |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 173 | ldr r2, [r1, #MECR_OFFSET] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 174 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 175 | /* MCMEM0: Card Interface slot 0 timing */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 176 | ldr r2, =CFG_MCMEM0_VAL |
| 177 | str r2, [r1, #MCMEM0_OFFSET] |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 178 | ldr r2, [r1, #MCMEM0_OFFSET] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 179 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 180 | /* MCMEM1: Card Interface slot 1 timing */ |
| 181 | ldr r2, =CFG_MCMEM1_VAL |
| 182 | str r2, [r1, #MCMEM1_OFFSET] |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 183 | ldr r2, [r1, #MCMEM1_OFFSET] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 184 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 185 | /* MCATT0: Card Interface Attribute Space Timing, slot 0 */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 186 | ldr r2, =CFG_MCATT0_VAL |
| 187 | str r2, [r1, #MCATT0_OFFSET] |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 188 | ldr r2, [r1, #MCATT0_OFFSET] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 189 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 190 | /* MCATT1: Card Interface Attribute Space Timing, slot 1 */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 191 | ldr r2, =CFG_MCATT1_VAL |
| 192 | str r2, [r1, #MCATT1_OFFSET] |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 193 | ldr r2, [r1, #MCATT1_OFFSET] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 194 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 195 | /* MCIO0: Card Interface I/O Space Timing, slot 0 */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 196 | ldr r2, =CFG_MCIO0_VAL |
| 197 | str r2, [r1, #MCIO0_OFFSET] |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 198 | ldr r2, [r1, #MCIO0_OFFSET] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 199 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 200 | /* MCIO1: Card Interface I/O Space Timing, slot 1 */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 201 | ldr r2, =CFG_MCIO1_VAL |
| 202 | str r2, [r1, #MCIO1_OFFSET] |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 203 | ldr r2, [r1, #MCIO1_OFFSET] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 204 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 205 | /* ---------------------------------------------------------------- */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 206 | /* Step 2c: Write FLYCNFG FIXME: what's that??? */ |
| 207 | /* ---------------------------------------------------------------- */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 208 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 209 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 210 | /* ---------------------------------------------------------------- */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 211 | /* Step 2d: Initialize Timing for Sync Memory (SDCLK0) */ |
| 212 | /* ---------------------------------------------------------------- */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 213 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 214 | /* Before accessing MDREFR we need a valid DRI field, so we set */ |
| 215 | /* this to power on defaults + DRI field. */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 216 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 217 | ldr r3, =CFG_MDREFR_VAL |
| 218 | ldr r2, =0xFFF |
| 219 | and r3, r3, r2 |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 220 | ldr r4, =0x03ca4000 |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 221 | orr r4, r4, r3 |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 222 | str r4, [r1, #MDREFR_OFFSET] /* write back MDREFR */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 223 | ldr r4, [r1, #MDREFR_OFFSET] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 224 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 225 | /* Note: preserve the mdrefr value in r4 */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 226 | |
| 227 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 228 | /* ---------------------------------------------------------------- */ |
| 229 | /* Step 3: Initialize Synchronous Static Memory (Flash/Peripherals) */ |
| 230 | /* ---------------------------------------------------------------- */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 231 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 232 | /* Initialize SXCNFG register. Assert the enable bits */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 233 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 234 | /* Write SXMRS to cause an MRS command to all enabled banks of */ |
| 235 | /* synchronous static memory. Note that SXLCR need not be written */ |
| 236 | /* at this time. */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 237 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 238 | /* FIXME: we use async mode for now */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 239 | |
| 240 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 241 | /* ---------------------------------------------------------------- */ |
| 242 | /* Step 4: Initialize SDRAM */ |
| 243 | /* ---------------------------------------------------------------- */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 244 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 245 | /* set MDREFR according to user define with exception of a few bits */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 246 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 247 | ldr r4, =CFG_MDREFR_VAL |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 248 | orr r4, r4, #(MDREFR_SLFRSH) |
| 249 | bic r4, r4, #(MDREFR_E1PIN|MDREFR_E0PIN) |
| 250 | str r4, [r1, #MDREFR_OFFSET] /* write back MDREFR */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 251 | ldr r4, [r1, #MDREFR_OFFSET] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 252 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 253 | /* Step 4b: de-assert MDREFR:SLFRSH. */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 254 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 255 | bic r4, r4, #(MDREFR_SLFRSH) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 256 | str r4, [r1, #MDREFR_OFFSET] /* write back MDREFR */ |
| 257 | ldr r4, [r1, #MDREFR_OFFSET] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 258 | |
| 259 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 260 | /* Step 4c: assert MDREFR:E1PIN and E0PIO as desired */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 261 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 262 | ldr r4, =CFG_MDREFR_VAL |
| 263 | str r4, [r1, #MDREFR_OFFSET] /* write back MDREFR */ |
| 264 | ldr r4, [r1, #MDREFR_OFFSET] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 265 | |
| 266 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 267 | /* Step 4d: write MDCNFG with MDCNFG:DEx deasserted (set to 0), to */ |
| 268 | /* configure but not enable each SDRAM partition pair. */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 269 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 270 | ldr r4, =CFG_MDCNFG_VAL |
| 271 | bic r4, r4, #(MDCNFG_DE0|MDCNFG_DE1) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 272 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 273 | str r4, [r1, #MDCNFG_OFFSET] /* write back MDCNFG */ |
| 274 | ldr r4, [r1, #MDCNFG_OFFSET] |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 275 | |
| 276 | |
| 277 | /* Step 4e: Wait for the clock to the SDRAMs to stabilize, */ |
| 278 | /* 100..200 µsec. */ |
| 279 | |
| 280 | ldr r3, =OSCR /* reset the OS Timer Count to zero */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 281 | mov r2, #0 |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 282 | str r2, [r3] |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 283 | ldr r4, =0x300 /* really 0x2E1 is about 200usec, */ |
| 284 | /* so 0x300 should be plenty */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 285 | 1: |
| 286 | ldr r2, [r3] |
| 287 | cmp r4, r2 |
| 288 | bgt 1b |
| 289 | |
| 290 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 291 | /* Step 4f: Trigger a number (usually 8) refresh cycles by */ |
| 292 | /* attempting non-burst read or write accesses to disabled */ |
| 293 | /* SDRAM, as commonly specified in the power up sequence */ |
| 294 | /* documented in SDRAM data sheets. The address(es) used */ |
| 295 | /* for this purpose must not be cacheable. */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 296 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 297 | ldr r3, =CFG_DRAM_BASE |
| 298 | str r2, [r3] |
| 299 | str r2, [r3] |
| 300 | str r2, [r3] |
| 301 | str r2, [r3] |
| 302 | str r2, [r3] |
| 303 | str r2, [r3] |
| 304 | str r2, [r3] |
| 305 | str r2, [r3] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 306 | |
| 307 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 308 | /* Step 4g: Write MDCNFG with enable bits asserted */ |
| 309 | /* (MDCNFG:DEx set to 1). */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 310 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 311 | ldr r3, [r1, #MDCNFG_OFFSET] |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 312 | orr r3, r3, #(MDCNFG_DE0|MDCNFG_DE1) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 313 | str r3, [r1, #MDCNFG_OFFSET] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 314 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 315 | /* Step 4h: Write MDMRS. */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 316 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 317 | ldr r2, =CFG_MDMRS_VAL |
| 318 | str r2, [r1, #MDMRS_OFFSET] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 319 | |
| 320 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 321 | /* We are finished with Intel's memory controller initialisation */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 322 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 323 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 324 | /* ---------------------------------------------------------------- */ |
| 325 | /* Disable (mask) all interrupts at interrupt controller */ |
| 326 | /* ---------------------------------------------------------------- */ |
| 327 | |
| 328 | initirqs: |
| 329 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 330 | mov r1, #0 /* clear int. level register (IRQ, not FIQ) */ |
| 331 | ldr r2, =ICLR |
| 332 | str r1, [r2] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 333 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 334 | ldr r2, =ICMR /* mask all interrupts at the controller */ |
| 335 | str r1, [r2] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 336 | |
| 337 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 338 | /* ---------------------------------------------------------------- */ |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 339 | /* Clock initialisation */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 340 | /* ---------------------------------------------------------------- */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 341 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 342 | initclks: |
| 343 | |
| 344 | /* Disable the peripheral clocks, and set the core clock frequency */ |
| 345 | /* (hard-coding at 398.12MHz for now). */ |
| 346 | |
| 347 | /* Turn Off ALL on-chip peripheral clocks for re-configuration */ |
| 348 | /* Note: See label 'ENABLECLKS' for the re-enabling */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 349 | ldr r1, =CKEN |
| 350 | mov r2, #0 |
| 351 | str r2, [r1] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 352 | |
| 353 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 354 | /* default value in case no valid rotary switch setting is found */ |
| 355 | ldr r2, =(CCCR_L27|CCCR_M2|CCCR_N10) /* DEFAULT: {200/200/100} */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 356 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 357 | /* ... and write the core clock config register */ |
| 358 | ldr r1, =CCCR |
| 359 | str r2, [r1] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 360 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 361 | #ifdef RTC |
| 362 | /* enable the 32Khz oscillator for RTC and PowerManager */ |
| 363 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 364 | ldr r1, =OSCC |
| 365 | mov r2, #OSCC_OON |
| 366 | str r2, [r1] |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 367 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 368 | /* NOTE: spin here until OSCC.OOK get set, meaning the PLL */ |
| 369 | /* has settled. */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 370 | 60: |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 371 | ldr r2, [r1] |
| 372 | ands r2, r2, #1 |
| 373 | beq 60b |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 374 | #endif |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 375 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 376 | /* ---------------------------------------------------------------- */ |
| 377 | /* */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 378 | /* ---------------------------------------------------------------- */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 379 | |
| 380 | /* Save SDRAM size */ |
| 381 | ldr r1, =DRAM_SIZE |
| 382 | str r8, [r1] |
| 383 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 384 | /* Interrupt init: Mask all interrupts */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 385 | ldr r0, =ICMR /* enable no sources */ |
| 386 | mov r1, #0 |
| 387 | str r1, [r0] |
| 388 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame] | 389 | /* FIXME */ |
| 390 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 391 | #define NODEBUG |
| 392 | #ifdef NODEBUG |
| 393 | /*Disable software and data breakpoints */ |
| 394 | mov r0,#0 |
| 395 | mcr p15,0,r0,c14,c8,0 /* ibcr0 */ |
| 396 | mcr p15,0,r0,c14,c9,0 /* ibcr1 */ |
| 397 | mcr p15,0,r0,c14,c4,0 /* dbcon */ |
| 398 | |
| 399 | /*Enable all debug functionality */ |
| 400 | mov r0,#0x80000000 |
| 401 | mcr p14,0,r0,c10,c0,0 /* dcsr */ |
| 402 | |
| 403 | #endif |
| 404 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 405 | /* ---------------------------------------------------------------- */ |
wdenk | 400558b | 2005-04-02 23:52:25 +0000 | [diff] [blame] | 406 | /* End lowlevel_init */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 407 | /* ---------------------------------------------------------------- */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 408 | |
wdenk | 400558b | 2005-04-02 23:52:25 +0000 | [diff] [blame] | 409 | endlowlevel_init: |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 410 | |
| 411 | mov pc, lr |