Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Board specific setup info |
| 3 | * |
| 4 | * (C) Copyright 2005-2007 |
| 5 | * Samsung Electronics, |
| 6 | * Kyungmin Park <kyungmin.park@samsung.com> |
| 7 | * |
| 8 | * See file CREDITS for list of people who contributed to this |
| 9 | * project. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU General Public License as |
| 13 | * published by the Free Software Foundation; either version 2 of |
| 14 | * the License, or (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 24 | * MA 02111-1307 USA |
| 25 | */ |
| 26 | |
| 27 | #include <config.h> |
| 28 | #include <version.h> |
| 29 | #include <asm/arch/omap2420.h> |
| 30 | #include <asm/arch/mem.h> |
| 31 | #include <asm/arch/clocks.h> |
| 32 | #include "mem.h" |
| 33 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 34 | #define APOLLON_CS0_BASE 0x00000000 |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 35 | |
| 36 | #ifdef PRCM_CONFIG_I |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 37 | #define SDRC_ACTIM_CTRLA_0_VAL 0x7BA35907 |
| 38 | #define SDRC_ACTIM_CTRLB_0_VAL 0x00000013 |
| 39 | #define SDRC_RFR_CTRL_0_VAL 0x00044C01 |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 40 | #elif defined(PRCM_CONFIG_II) |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 41 | #define SDRC_ACTIM_CTRLA_0_VAL 0x4A59B485 |
| 42 | #define SDRC_ACTIM_CTRLB_0_VAL 0x0000000C |
| 43 | #define SDRC_RFR_CTRL_0_VAL 0x00030001 |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 44 | #endif |
| 45 | |
| 46 | #define SDRAM_BASE_ADDRESS 0x80008000 |
| 47 | |
| 48 | _TEXT_BASE: |
| 49 | .word TEXT_BASE /* sdram load addr from config.mk */ |
| 50 | |
| 51 | .globl lowlevel_init |
| 52 | lowlevel_init: |
| 53 | |
| 54 | #ifdef CFG_NOR_BOOT |
| 55 | /* Check running in SDRAM */ |
| 56 | mov r0, pc, lsr #28 |
| 57 | cmp r0, #8 |
| 58 | beq prcm_setup |
Peter Pearse | d82a83f | 2007-11-15 08:45:13 +0000 | [diff] [blame] | 59 | |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 60 | flash_setup: |
| 61 | /* In Flash */ |
| 62 | ldr r0, =WD2_BASE |
| 63 | ldr r1, =WD_UNLOCK1 |
| 64 | str r1, [r0, #WSPR] |
| 65 | |
| 66 | ldr r1, =WD_UNLOCK2 |
| 67 | str r1, [r0, #WSPR] |
| 68 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 69 | /* Pin muxing for SDRC */ |
| 70 | mov r1, #0x00 |
| 71 | ldr r0, =0x480000A1 /* ball C12, mode 0 */ |
| 72 | strb r1, [r0] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 73 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 74 | ldr r0, =0x48000032 /* ball D11, mode 0 */ |
| 75 | strb r1, [r0] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 76 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 77 | ldr r0, =0x480000A3 /* ball B13, mode 0 */ |
| 78 | strb r1, [r0] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 79 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 80 | /* SDRC setting */ |
| 81 | ldr r0, =OMAP2420_SDRC_BASE |
| 82 | ldr r1, =0x00000010 |
| 83 | str r1, [r0, #0x10] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 84 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 85 | ldr r1, =0x00000100 |
| 86 | str r1, [r0, #0x44] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 87 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 88 | /* SDRC CS0 configuration */ |
| 89 | ldr r1, =0x00d04011 |
| 90 | str r1, [r0, #0x80] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 91 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 92 | ldr r1, =SDRC_ACTIM_CTRLA_0_VAL |
| 93 | str r1, [r0, #0x9C] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 94 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 95 | ldr r1, =SDRC_ACTIM_CTRLB_0_VAL |
| 96 | str r1, [r0, #0xA0] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 97 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 98 | ldr r1, =SDRC_RFR_CTRL_0_VAL |
| 99 | str r1, [r0, #0xA4] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 100 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 101 | ldr r1, =0x00000041 |
| 102 | str r1, [r0, #0x70] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 103 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 104 | /* Manual command sequence */ |
| 105 | ldr r1, =0x00000007 |
| 106 | str r1, [r0, #0xA8] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 107 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 108 | ldr r1, =0x00000000 |
| 109 | str r1, [r0, #0xA8] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 110 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 111 | ldr r1, =0x00000001 |
| 112 | str r1, [r0, #0xA8] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 113 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 114 | ldr r1, =0x00000002 |
| 115 | str r1, [r0, #0xA8] |
| 116 | str r1, [r0, #0xA8] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 117 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 118 | /* |
| 119 | * CS0 SDRC Mode register |
| 120 | * Burst length = 4 - DDR memory |
| 121 | * Serial mode |
| 122 | * CAS latency = 3 |
| 123 | */ |
| 124 | ldr r1, =0x00000032 |
| 125 | str r1, [r0, #0x84] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 126 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 127 | /* Note: You MUST set EMR values */ |
| 128 | /* EMR1 & EMR2 */ |
| 129 | ldr r1, =0x00000000 |
| 130 | str r1, [r0, #0x88] |
| 131 | str r1, [r0, #0x8C] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 132 | |
| 133 | #ifdef OLD_SDRC_DLLA_CTRL |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 134 | /* SDRC_DLLA_CTRL */ |
| 135 | ldr r1, =0x00007306 |
| 136 | str r1, [r0, #0x60] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 137 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 138 | ldr r1, =0x00007303 |
| 139 | str r1, [r0, #0x60] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 140 | #else |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 141 | /* SDRC_DLLA_CTRL */ |
| 142 | ldr r1, =0x00000506 |
| 143 | str r1, [r0, #0x60] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 144 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 145 | ldr r1, =0x00000503 |
| 146 | str r1, [r0, #0x60] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 147 | #endif |
| 148 | |
| 149 | #ifdef __BROKEN_FEATURE__ |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 150 | /* SDRC_DLLB_CTRL */ |
| 151 | ldr r1, =0x00000506 |
| 152 | str r1, [r0, #0x68] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 153 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 154 | ldr r1, =0x00000503 |
| 155 | str r1, [r0, #0x68] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 156 | #endif |
| 157 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 158 | /* little delay after init */ |
| 159 | mov r2, #0x1800 |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 160 | 1: |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 161 | subs r2, r2, #0x1 |
| 162 | bne 1b |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 163 | |
| 164 | /* Setup base address */ |
| 165 | ldr r0, =0x00000000 /* NOR address */ |
| 166 | ldr r1, =SDRAM_BASE_ADDRESS /* SDRAM address */ |
| 167 | ldr r2, =0x20000 /* Size: 128KB */ |
| 168 | |
| 169 | copy_loop: |
| 170 | ldmia r0!, {r3-r10} |
| 171 | stmia r1!, {r3-r10} |
| 172 | cmp r0, r2 |
| 173 | ble copy_loop |
| 174 | |
| 175 | ldr r1, =SDRAM_BASE_ADDRESS |
| 176 | mov lr, pc |
| 177 | mov pc, r1 |
| 178 | #endif |
| 179 | |
| 180 | prcm_setup: |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 181 | ldr r0, =OMAP2420_CM_BASE |
| 182 | ldr r1, [r0, #0x544] /* CLKSEL2_PLL */ |
| 183 | bic r1, r1, #0x03 |
| 184 | orr r1, r1, #0x02 |
| 185 | str r1, [r0, #0x544] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 186 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 187 | ldr r1, [r0, #0x500] |
| 188 | bic r1, r1, #0x03 |
| 189 | orr r1, r1, #0x01 |
| 190 | str r1, [r0, #0x500] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 191 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 192 | ldr r1, [r0, #0x140] |
| 193 | bic r1, r1, #0x1f |
| 194 | orr r1, r1, #0x02 |
| 195 | str r1, [r0, #0x140] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 196 | |
| 197 | #ifdef PRCM_CONFIG_I |
| 198 | ldr r1, =0x000003C3 |
| 199 | #else |
| 200 | ldr r1, =0x00000343 |
| 201 | #endif |
| 202 | str r1, [r0, #0x840] |
| 203 | |
| 204 | ldr r1, =0x00000002 |
| 205 | str r1, [r0, #0x340] |
Peter Pearse | d82a83f | 2007-11-15 08:45:13 +0000 | [diff] [blame] | 206 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 207 | ldr r1, =CM_CLKSEL1_CORE |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 208 | #ifdef PRCM_CONFIG_I |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 209 | ldr r2, =0x08300C44 |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 210 | #else |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 211 | ldr r2, =0x04600C26 |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 212 | #endif |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 213 | str r2, [r1] |
Peter Pearse | d82a83f | 2007-11-15 08:45:13 +0000 | [diff] [blame] | 214 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 215 | ldr r0, =OMAP2420_CM_BASE |
| 216 | ldr r1, [r0, #0x084] |
| 217 | and r1, r1, #0x01 |
| 218 | cmp r1, #0x01 |
| 219 | bne clkvalid |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 220 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 221 | b . |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 222 | |
| 223 | clkvalid: |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 224 | mov r1, #0x01 |
| 225 | str r1, [r0, #0x080] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 226 | |
| 227 | waitvalid: |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 228 | ldr r1, [r0, #0x084] |
| 229 | and r1, r1, #0x01 |
| 230 | cmp r1, #0x00 |
| 231 | bne waitvalid |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 232 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 233 | ldr r0, =CM_CLKSEL1_PLL |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 234 | #ifdef PRCM_CONFIG_I |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 235 | ldr r1, =0x01837100 |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 236 | #else |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 237 | ldr r1, =0x01832100 |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 238 | #endif |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 239 | str r1, [r0] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 240 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 241 | ldr r0, =PRCM_CLKCFG_CTRL |
| 242 | mov r1, #0x01 |
| 243 | str r1, [r0] |
| 244 | mov r6, #0x50 |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 245 | loop1: |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 246 | subs r6, r6, #0x01 |
| 247 | cmp r6, #0x01 |
| 248 | bne loop1 |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 249 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 250 | ldr r0, =CM_CLKEN_PLL |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 251 | mov r1, #0x0f |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 252 | str r1, [r0] |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 253 | |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 254 | mov r6, #0x100 |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 255 | loop2: |
Wolfgang Denk | c93939f | 2008-01-09 11:36:21 +0100 | [diff] [blame] | 256 | subs r6, r6, #0x01 |
| 257 | cmp r6, #0x01 |
| 258 | bne loop2 |
Peter Pearse | ba348b5 | 2007-11-09 15:24:26 +0000 | [diff] [blame] | 259 | |
| 260 | ldr r0, =0x48008200 |
| 261 | ldr r1, =0xbfffffff |
| 262 | str r1, [r0] |
| 263 | |
| 264 | ldr r0, =0x48008210 |
| 265 | ldr r1, =0xfffffff9 |
| 266 | str r1, [r0] |
| 267 | |
| 268 | ldr r0, =0x4806a004 |
| 269 | ldr r1, =0x00 |
| 270 | strb r1, [r0] |
| 271 | |
| 272 | ldr r0, =0x4806a020 |
| 273 | ldr r1, =0x07 |
| 274 | strb r1, [r0] |
| 275 | |
| 276 | ldr r0, =0x4806a00c |
| 277 | ldr r1, =0x83 |
| 278 | strb r1, [r0] |
| 279 | |
| 280 | ldr r0, =0x4806a000 |
| 281 | ldr r1, =0x1a |
| 282 | strb r1, [r0] |
| 283 | |
| 284 | ldr r0, =0x4806a004 |
| 285 | ldr r1, =0x00 |
| 286 | strb r1, [r0] |
| 287 | |
| 288 | ldr r0, =0x4806a00c |
| 289 | ldr r1, =0x03 |
| 290 | strb r1, [r0] |
| 291 | |
| 292 | ldr r0, =0x4806a010 |
| 293 | ldr r1, =0x03 |
| 294 | strb r1, [r0] |
| 295 | |
| 296 | ldr r0, =0x4806a008 |
| 297 | ldr r1, =0x04 |
| 298 | strb r1, [r0] |
| 299 | |
| 300 | ldr r0, =0x4806a020 |
| 301 | ldr r1, =0x00 |
| 302 | strb r1, [r0] |
| 303 | |
| 304 | #if 0 |
| 305 | ldr r0, =0x4806a000 |
| 306 | mov r1, #'u' |
| 307 | strb r1, [r0] |
| 308 | #endif |
| 309 | |
| 310 | #if 0 |
| 311 | /* LED0 OFF */ |
| 312 | ldr r3, =0x480000E5 |
| 313 | mov r4, #0x0b |
| 314 | strb r4, [r3] |
| 315 | #endif |
| 316 | |
| 317 | ldr sp, SRAM_STACK |
| 318 | str ip, [sp] /* stash old link register */ |
| 319 | mov ip, lr /* save link reg across call */ |
| 320 | bl s_init /* go setup pll,mux,memory */ |
| 321 | ldr ip, [sp] /* restore save ip */ |
| 322 | mov lr, ip /* restore link reg */ |
| 323 | |
| 324 | /* map interrupt controller */ |
| 325 | ldr r0, VAL_INTH_SETUP |
| 326 | mcr p15, 0, r0, c15, c2, 4 |
| 327 | |
| 328 | /* back to arch calling code */ |
| 329 | mov pc, lr |
| 330 | |
| 331 | /* the literal pools origin */ |
| 332 | .ltorg |
| 333 | |
| 334 | VAL_INTH_SETUP: |
| 335 | .word PERIFERAL_PORT_BASE |
| 336 | SRAM_STACK: |
| 337 | .word LOW_LEVEL_SRAM_STACK |