wdenk | fabd46a | 2004-07-10 23:11:10 +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 | fabd46a | 2004-07-10 23:11:10 +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 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 32 | DRAM_SIZE: .long CONFIG_SYS_DRAM_SIZE |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 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 | |
| 42 | /* |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 43 | * Memory setup |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 44 | */ |
| 45 | |
wdenk | 400558b | 2005-04-02 23:52:25 +0000 | [diff] [blame] | 46 | .globl lowlevel_init |
| 47 | lowlevel_init: |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 48 | |
| 49 | /* Set up GPIO pins first ----------------------------------------- */ |
| 50 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 51 | ldr r0, =GPSR0 |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 52 | ldr r1, =CONFIG_SYS_GPSR0_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 53 | str r1, [r0] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 54 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 55 | ldr r0, =GPSR1 |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 56 | ldr r1, =CONFIG_SYS_GPSR1_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 57 | str r1, [r0] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 58 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 59 | ldr r0, =GPSR2 |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 60 | ldr r1, =CONFIG_SYS_GPSR2_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 61 | str r1, [r0] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 62 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 63 | ldr r0, =GPCR0 |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 64 | ldr r1, =CONFIG_SYS_GPCR0_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 65 | str r1, [r0] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 66 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 67 | ldr r0, =GPCR1 |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 68 | ldr r1, =CONFIG_SYS_GPCR1_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 69 | str r1, [r0] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 70 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 71 | ldr r0, =GPCR2 |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 72 | ldr r1, =CONFIG_SYS_GPCR2_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 73 | str r1, [r0] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 74 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 75 | ldr r0, =GPDR0 |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 76 | ldr r1, =CONFIG_SYS_GPDR0_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 77 | str r1, [r0] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 78 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 79 | ldr r0, =GPDR1 |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 80 | ldr r1, =CONFIG_SYS_GPDR1_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 81 | str r1, [r0] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 82 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 83 | ldr r0, =GPDR2 |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 84 | ldr r1, =CONFIG_SYS_GPDR2_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 85 | str r1, [r0] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 86 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 87 | ldr r0, =GAFR0_L |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 88 | ldr r1, =CONFIG_SYS_GAFR0_L_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 89 | str r1, [r0] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 90 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 91 | ldr r0, =GAFR0_U |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 92 | ldr r1, =CONFIG_SYS_GAFR0_U_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 93 | str r1, [r0] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 94 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 95 | ldr r0, =GAFR1_L |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 96 | ldr r1, =CONFIG_SYS_GAFR1_L_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 97 | str r1, [r0] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 98 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 99 | ldr r0, =GAFR1_U |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 100 | ldr r1, =CONFIG_SYS_GAFR1_U_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 101 | str r1, [r0] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 102 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 103 | ldr r0, =GAFR2_L |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 104 | ldr r1, =CONFIG_SYS_GAFR2_L_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 105 | str r1, [r0] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 106 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 107 | ldr r0, =GAFR2_U |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 108 | ldr r1, =CONFIG_SYS_GAFR2_U_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 109 | str r1, [r0] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 110 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 111 | ldr r0, =PSSR /* enable GPIO pins */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 112 | ldr r1, =CONFIG_SYS_PSSR_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 113 | str r1, [r0] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 114 | |
| 115 | /* ---------------------------------------------------------------- */ |
| 116 | /* Enable memory interface */ |
| 117 | /* */ |
| 118 | /* The sequence below is based on the recommended init steps */ |
| 119 | /* detailed in the Intel PXA250 Operating Systems Developers Guide, */ |
| 120 | /* Chapter 10. */ |
| 121 | /* ---------------------------------------------------------------- */ |
| 122 | |
| 123 | /* ---------------------------------------------------------------- */ |
| 124 | /* Step 1: Wait for at least 200 microsedonds to allow internal */ |
| 125 | /* clocks to settle. Only necessary after hard reset... */ |
| 126 | /* FIXME: can be optimized later */ |
| 127 | /* ---------------------------------------------------------------- */ |
| 128 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 129 | ldr r3, =OSCR /* reset the OS Timer Count to zero */ |
| 130 | mov r2, #0 |
| 131 | str r2, [r3] |
| 132 | ldr r4, =0x300 /* really 0x2E1 is about 200usec, */ |
| 133 | /* so 0x300 should be plenty */ |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 134 | 1: |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 135 | ldr r2, [r3] |
| 136 | cmp r4, r2 |
| 137 | bgt 1b |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 138 | |
| 139 | mem_init: |
| 140 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 141 | ldr r1, =MEMC_BASE /* get memory controller base addr. */ |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 142 | |
| 143 | /* ---------------------------------------------------------------- */ |
| 144 | /* Step 2a: Initialize Asynchronous static memory controller */ |
| 145 | /* ---------------------------------------------------------------- */ |
| 146 | |
| 147 | /* MSC registers: timing, bus width, mem type */ |
| 148 | |
| 149 | /* MSC0: nCS(0,1) */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 150 | ldr r2, =CONFIG_SYS_MSC0_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 151 | str r2, [r1, #MSC0_OFFSET] |
| 152 | ldr r2, [r1, #MSC0_OFFSET] /* read back to ensure */ |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 153 | /* that data latches */ |
| 154 | /* MSC1: nCS(2,3) */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 155 | ldr r2, =CONFIG_SYS_MSC1_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 156 | str r2, [r1, #MSC1_OFFSET] |
| 157 | ldr r2, [r1, #MSC1_OFFSET] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 158 | |
| 159 | /* MSC2: nCS(4,5) */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 160 | ldr r2, =CONFIG_SYS_MSC2_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 161 | str r2, [r1, #MSC2_OFFSET] |
| 162 | ldr r2, [r1, #MSC2_OFFSET] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 163 | |
| 164 | /* ---------------------------------------------------------------- */ |
| 165 | /* Step 2b: Initialize Card Interface */ |
| 166 | /* ---------------------------------------------------------------- */ |
| 167 | |
| 168 | /* MECR: Memory Expansion Card Register */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 169 | ldr r2, =CONFIG_SYS_MECR_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 170 | str r2, [r1, #MECR_OFFSET] |
| 171 | ldr r2, [r1, #MECR_OFFSET] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 172 | |
| 173 | /* MCMEM0: Card Interface slot 0 timing */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 174 | ldr r2, =CONFIG_SYS_MCMEM0_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 175 | str r2, [r1, #MCMEM0_OFFSET] |
| 176 | ldr r2, [r1, #MCMEM0_OFFSET] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 177 | |
| 178 | /* MCMEM1: Card Interface slot 1 timing */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 179 | ldr r2, =CONFIG_SYS_MCMEM1_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 180 | str r2, [r1, #MCMEM1_OFFSET] |
| 181 | ldr r2, [r1, #MCMEM1_OFFSET] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 182 | |
| 183 | /* MCATT0: Card Interface Attribute Space Timing, slot 0 */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 184 | ldr r2, =CONFIG_SYS_MCATT0_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 185 | str r2, [r1, #MCATT0_OFFSET] |
| 186 | ldr r2, [r1, #MCATT0_OFFSET] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 187 | |
| 188 | /* MCATT1: Card Interface Attribute Space Timing, slot 1 */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 189 | ldr r2, =CONFIG_SYS_MCATT1_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 190 | str r2, [r1, #MCATT1_OFFSET] |
| 191 | ldr r2, [r1, #MCATT1_OFFSET] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 192 | |
| 193 | /* MCIO0: Card Interface I/O Space Timing, slot 0 */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 194 | ldr r2, =CONFIG_SYS_MCIO0_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 195 | str r2, [r1, #MCIO0_OFFSET] |
| 196 | ldr r2, [r1, #MCIO0_OFFSET] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 197 | |
| 198 | /* MCIO1: Card Interface I/O Space Timing, slot 1 */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 199 | ldr r2, =CONFIG_SYS_MCIO1_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 200 | str r2, [r1, #MCIO1_OFFSET] |
| 201 | ldr r2, [r1, #MCIO1_OFFSET] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 202 | |
| 203 | /* ---------------------------------------------------------------- */ |
| 204 | /* Step 2c: Write FLYCNFG FIXME: what's that??? */ |
| 205 | /* ---------------------------------------------------------------- */ |
| 206 | |
| 207 | |
| 208 | /* ---------------------------------------------------------------- */ |
| 209 | /* Step 2d: Initialize Timing for Sync Memory (SDCLK0) */ |
| 210 | /* ---------------------------------------------------------------- */ |
| 211 | |
| 212 | /* Before accessing MDREFR we need a valid DRI field, so we set */ |
| 213 | /* this to power on defaults + DRI field, set SDRAM clocks free running */ |
| 214 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 215 | ldr r3, =CONFIG_SYS_MDREFR_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 216 | ldr r2, =0xFFF |
| 217 | and r3, r3, r2 |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 218 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 219 | ldr r0, [r1, #MDREFR_OFFSET] |
| 220 | bic r0, r0, r2 |
| 221 | bic r0, r0, #(MDREFR_K0FREE|MDREFR_K1FREE|MDREFR_K2FREE) |
| 222 | orr r0, r0, r3 |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 223 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 224 | str r0, [r1, #MDREFR_OFFSET] /* write back MDREFR */ |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 225 | |
| 226 | |
| 227 | /* ---------------------------------------------------------------- */ |
| 228 | /* Step 3: Initialize Synchronous Static Memory (Flash/Peripherals) */ |
| 229 | /* ---------------------------------------------------------------- */ |
| 230 | |
| 231 | /* Initialize SXCNFG register. Assert the enable bits */ |
| 232 | |
| 233 | /* Write SXMRS to cause an MRS command to all enabled banks of */ |
| 234 | /* synchronous static memory. Note that SXLCR need not be written */ |
| 235 | /* at this time. */ |
| 236 | |
| 237 | /* FIXME: we use async mode for now */ |
| 238 | |
| 239 | |
| 240 | /* ---------------------------------------------------------------- */ |
| 241 | /* Step 4: Initialize SDRAM */ |
| 242 | /* ---------------------------------------------------------------- */ |
| 243 | |
| 244 | /* set MDREFR according to user define with exception of a few bits */ |
| 245 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 246 | ldr r4, =CONFIG_SYS_MDREFR_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 247 | ldr r2, =(MDREFR_K0RUN|MDREFR_K0DB2|MDREFR_K1RUN|MDREFR_K1DB2|\ |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 248 | MDREFR_K2RUN |MDREFR_K2DB2) |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 249 | and r4, r4, r2 |
| 250 | bic r0, r0, r2 |
| 251 | orr r0, r0, r4 |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 252 | |
| 253 | str r0, [r1, #MDREFR_OFFSET] /* write back MDREFR */ |
| 254 | ldr r0, [r1, #MDREFR_OFFSET] |
| 255 | |
| 256 | /* Step 4b: de-assert MDREFR:SLFRSH. */ |
| 257 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 258 | bic r0, r0, #(MDREFR_SLFRSH) |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 259 | str r0, [r1, #MDREFR_OFFSET] /* write back MDREFR */ |
| 260 | ldr r0, [r1, #MDREFR_OFFSET] |
| 261 | |
| 262 | |
| 263 | /* Step 4c: assert MDREFR:E1PIN and E0PIO as desired, set KXFREE */ |
| 264 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 265 | ldr r4, =CONFIG_SYS_MDREFR_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 266 | ldr r2, =(MDREFR_E0PIN|MDREFR_E1PIN|MDREFR_K0FREE| \ |
| 267 | MDREFR_K1FREE | MDREFR_K2FREE) |
| 268 | and r4, r4, r2 |
| 269 | orr r0, r0, r4 |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 270 | str r0, [r1, #MDREFR_OFFSET] /* write back MDREFR */ |
| 271 | ldr r0, [r1, #MDREFR_OFFSET] |
| 272 | |
| 273 | |
| 274 | /* Step 4d: write MDCNFG with MDCNFG:DEx deasserted (set to 0), to */ |
| 275 | /* configure but not enable each SDRAM partition pair. */ |
| 276 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 277 | ldr r4, =CONFIG_SYS_MDCNFG_VAL |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 278 | bic r4, r4, #(MDCNFG_DE0|MDCNFG_DE1) |
| 279 | bic r4, r4, #(MDCNFG_DE2|MDCNFG_DE3) |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 280 | str r4, [r1, #MDCNFG_OFFSET] /* write back MDCNFG */ |
| 281 | ldr r4, [r1, #MDCNFG_OFFSET] |
| 282 | |
| 283 | |
| 284 | /* Step 4e: Wait for the clock to the SDRAMs to stabilize, */ |
| 285 | /* 100..200 µsec. */ |
| 286 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 287 | ldr r3, =OSCR /* reset the OS Timer Count to zero */ |
| 288 | mov r2, #0 |
| 289 | str r2, [r3] |
| 290 | ldr r4, =0x300 /* really 0x2E1 is about 200usec, */ |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 291 | /* so 0x300 should be plenty */ |
| 292 | 1: |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 293 | ldr r2, [r3] |
| 294 | cmp r4, r2 |
| 295 | bgt 1b |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 296 | |
| 297 | |
| 298 | /* Step 4f: Trigger a number (usually 8) refresh cycles by */ |
| 299 | /* attempting non-burst read or write accesses to disabled */ |
| 300 | /* SDRAM, as commonly specified in the power up sequence */ |
| 301 | /* documented in SDRAM data sheets. The address(es) used */ |
| 302 | /* for this purpose must not be cacheable. */ |
| 303 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 304 | ldr r3, =CONFIG_SYS_DRAM_BASE |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 305 | .rept 8 |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 306 | str r2, [r3] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 307 | .endr |
| 308 | |
| 309 | /* Step 4g: Write MDCNFG with enable bits asserted */ |
| 310 | /* (MDCNFG:DEx set to 1). */ |
| 311 | |
| 312 | ldr r3, [r1, #MDCNFG_OFFSET] |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 313 | orr r3, r3, #(MDCNFG_DE0|MDCNFG_DE1) |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 314 | str r3, [r1, #MDCNFG_OFFSET] |
| 315 | |
| 316 | /* Step 4h: Write MDMRS. */ |
| 317 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 318 | ldr r2, =CONFIG_SYS_MDMRS_VAL |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 319 | str r2, [r1, #MDMRS_OFFSET] |
| 320 | |
| 321 | |
| 322 | /* We are finished with Intel's memory controller initialisation */ |
| 323 | |
| 324 | |
| 325 | /* ---------------------------------------------------------------- */ |
| 326 | /* Disable (mask) all interrupts at interrupt controller */ |
| 327 | /* ---------------------------------------------------------------- */ |
| 328 | |
| 329 | initirqs: |
| 330 | |
| 331 | mov r1, #0 /* clear int. level register (IRQ, not FIQ) */ |
| 332 | ldr r2, =ICLR |
| 333 | str r1, [r2] |
| 334 | |
| 335 | ldr r2, =ICMR /* mask all interrupts at the controller */ |
| 336 | str r1, [r2] |
| 337 | |
| 338 | |
| 339 | /* ---------------------------------------------------------------- */ |
| 340 | /* Clock initialisation */ |
| 341 | /* ---------------------------------------------------------------- */ |
| 342 | |
| 343 | initclks: |
| 344 | |
| 345 | /* Disable the peripheral clocks, and set the core clock frequency */ |
| 346 | |
| 347 | /* Turn Off ALL on-chip peripheral clocks for re-configuration */ |
| 348 | /* Note: See label 'ENABLECLKS' for the re-enabling */ |
| 349 | ldr r1, =CKEN |
| 350 | mov r2, #0 |
| 351 | str r2, [r1] |
| 352 | |
| 353 | |
| 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} */ |
| 356 | |
| 357 | /* ... and write the core clock config register */ |
| 358 | ldr r1, =CCCR |
| 359 | str r2, [r1] |
| 360 | |
| 361 | #ifdef RTC |
| 362 | /* enable the 32Khz oscillator for RTC and PowerManager */ |
| 363 | |
| 364 | ldr r1, =OSCC |
| 365 | mov r2, #OSCC_OON |
| 366 | str r2, [r1] |
| 367 | |
| 368 | /* NOTE: spin here until OSCC.OOK get set, meaning the PLL */ |
| 369 | /* has settled. */ |
| 370 | 60: |
| 371 | ldr r2, [r1] |
| 372 | ands r2, r2, #1 |
| 373 | beq 60b |
| 374 | #endif |
| 375 | |
| 376 | /* ---------------------------------------------------------------- */ |
| 377 | /* */ |
| 378 | /* ---------------------------------------------------------------- */ |
| 379 | |
| 380 | /* Save SDRAM size */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 381 | ldr r1, =DRAM_SIZE |
| 382 | str r8, [r1] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 383 | |
| 384 | /* Interrupt init: Mask all interrupts */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 385 | ldr r0, =ICMR /* enable no sources */ |
| 386 | mov r1, #0 |
| 387 | str r1, [r0] |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 388 | |
| 389 | /* FIXME */ |
| 390 | |
| 391 | #define NODEBUG |
| 392 | #ifdef NODEBUG |
| 393 | /*Disable software and data breakpoints */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 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 */ |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 398 | |
| 399 | /*Enable all debug functionality */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 400 | mov r0,#0x80000000 |
| 401 | mcr p14,0,r0,c10,c0,0 /* dcsr */ |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 402 | |
| 403 | #endif |
| 404 | |
| 405 | /* ---------------------------------------------------------------- */ |
wdenk | 400558b | 2005-04-02 23:52:25 +0000 | [diff] [blame] | 406 | /* End lowlevel_init */ |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 407 | /* ---------------------------------------------------------------- */ |
| 408 | |
wdenk | 400558b | 2005-04-02 23:52:25 +0000 | [diff] [blame] | 409 | endlowlevel_init: |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 410 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 411 | mov pc, lr |