Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * File: arch/blackfin/mach-bf537/head.S |
| 3 | * Based on: arch/blackfin/mach-bf533/head.S |
| 4 | * Author: Jeff Dionne <jeff@uclinux.org> COPYRIGHT 1998 D. Jeff Dionne |
| 5 | * |
| 6 | * Created: 1998 |
| 7 | * Description: Startup code for Blackfin BF537 |
| 8 | * |
| 9 | * Modified: |
| 10 | * Copyright 2004-2006 Analog Devices Inc. |
| 11 | * |
| 12 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License as published by |
| 16 | * the Free Software Foundation; either version 2 of the License, or |
| 17 | * (at your option) any later version. |
| 18 | * |
| 19 | * This program is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with this program; if not, see the file COPYING, or write |
| 26 | * to the Free Software Foundation, Inc., |
| 27 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 28 | */ |
| 29 | |
| 30 | #include <linux/linkage.h> |
Mike Frysinger | 52a0781 | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 31 | #include <linux/init.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 32 | #include <asm/blackfin.h> |
Robin Getz | 669b792 | 2007-06-21 16:34:08 +0800 | [diff] [blame] | 33 | #include <asm/trace.h> |
| 34 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 35 | #if CONFIG_BFIN_KERNEL_CLOCK |
Robin Getz | f16295e | 2007-08-03 18:07:17 +0800 | [diff] [blame^] | 36 | #include <asm/mach-common/clocks.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 37 | #include <asm/mach/mem_init.h> |
| 38 | #endif |
| 39 | |
| 40 | .global __rambase |
| 41 | .global __ramstart |
| 42 | .global __ramend |
| 43 | .extern ___bss_stop |
| 44 | .extern ___bss_start |
| 45 | .extern _bf53x_relocate_l1_mem |
| 46 | |
Mike Frysinger | 83a5c3e | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 47 | #define INITIAL_STACK 0xFFB01000 |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 48 | |
Mike Frysinger | 52a0781 | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 49 | __INIT |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 50 | |
| 51 | ENTRY(__start) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 52 | /* R0: argument of command line string, passed from uboot, save it */ |
| 53 | R7 = R0; |
Mike Frysinger | 83a5c3e | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 54 | /* Set the SYSCFG register: |
| 55 | * Enable Cycle Counter and Nesting Of Interrupts (3rd Bit) |
| 56 | */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 57 | R0 = 0x36; |
Mike Frysinger | 83a5c3e | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 58 | SYSCFG = R0; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 59 | R0 = 0; |
| 60 | |
Mike Frysinger | 83a5c3e | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 61 | /* Clear Out All the data and pointer Registers */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 62 | R1 = R0; |
| 63 | R2 = R0; |
| 64 | R3 = R0; |
| 65 | R4 = R0; |
| 66 | R5 = R0; |
| 67 | R6 = R0; |
| 68 | |
| 69 | P0 = R0; |
| 70 | P1 = R0; |
| 71 | P2 = R0; |
| 72 | P3 = R0; |
| 73 | P4 = R0; |
| 74 | P5 = R0; |
| 75 | |
| 76 | LC0 = r0; |
| 77 | LC1 = r0; |
| 78 | L0 = r0; |
| 79 | L1 = r0; |
| 80 | L2 = r0; |
| 81 | L3 = r0; |
| 82 | |
Mike Frysinger | 83a5c3e | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 83 | /* Clear Out All the DAG Registers */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 84 | B0 = r0; |
| 85 | B1 = r0; |
| 86 | B2 = r0; |
| 87 | B3 = r0; |
| 88 | |
| 89 | I0 = r0; |
| 90 | I1 = r0; |
| 91 | I2 = r0; |
| 92 | I3 = r0; |
| 93 | |
| 94 | M0 = r0; |
| 95 | M1 = r0; |
| 96 | M2 = r0; |
| 97 | M3 = r0; |
| 98 | |
Robin Getz | 669b792 | 2007-06-21 16:34:08 +0800 | [diff] [blame] | 99 | trace_buffer_start(p0,r0); |
| 100 | P0 = R1; |
| 101 | R0 = R1; |
| 102 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 103 | /* Turn off the icache */ |
Mike Frysinger | e208f83 | 2007-07-25 10:11:42 +0800 | [diff] [blame] | 104 | p0.l = LO(IMEM_CONTROL); |
| 105 | p0.h = HI(IMEM_CONTROL); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 106 | R1 = [p0]; |
| 107 | R0 = ~ENICPLB; |
| 108 | R0 = R0 & R1; |
| 109 | |
| 110 | /* Anomaly 05000125 */ |
Mike Frysinger | 1aafd90 | 2007-07-25 11:19:14 +0800 | [diff] [blame] | 111 | #if ANOMALY_05000125 |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 112 | CLI R2; |
| 113 | SSYNC; |
| 114 | #endif |
| 115 | [p0] = R0; |
| 116 | SSYNC; |
Mike Frysinger | 1aafd90 | 2007-07-25 11:19:14 +0800 | [diff] [blame] | 117 | #if ANOMALY_05000125 |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 118 | STI R2; |
| 119 | #endif |
| 120 | |
| 121 | /* Turn off the dcache */ |
Mike Frysinger | e208f83 | 2007-07-25 10:11:42 +0800 | [diff] [blame] | 122 | p0.l = LO(DMEM_CONTROL); |
| 123 | p0.h = HI(DMEM_CONTROL); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 124 | R1 = [p0]; |
| 125 | R0 = ~ENDCPLB; |
| 126 | R0 = R0 & R1; |
| 127 | |
| 128 | /* Anomaly 05000125 */ |
Mike Frysinger | 1aafd90 | 2007-07-25 11:19:14 +0800 | [diff] [blame] | 129 | #if ANOMALY_05000125 |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 130 | CLI R2; |
| 131 | SSYNC; |
| 132 | #endif |
| 133 | [p0] = R0; |
| 134 | SSYNC; |
Mike Frysinger | 1aafd90 | 2007-07-25 11:19:14 +0800 | [diff] [blame] | 135 | #if ANOMALY_05000125 |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 136 | STI R2; |
| 137 | #endif |
| 138 | |
| 139 | /* Initialise General-Purpose I/O Modules on BF537 */ |
| 140 | /* Rev 0.0 Anomaly 05000212 - PORTx_FER, |
| 141 | * PORT_MUX Registers Do Not accept "writes" correctly: |
| 142 | */ |
| 143 | p0.h = hi(BFIN_PORT_MUX); |
| 144 | p0.l = lo(BFIN_PORT_MUX); |
Mike Frysinger | 1aafd90 | 2007-07-25 11:19:14 +0800 | [diff] [blame] | 145 | #if ANOMALY_05000212 |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 146 | R0.L = W[P0]; /* Read */ |
| 147 | SSYNC; |
| 148 | #endif |
| 149 | R0 = (PGDE_UART | PFTE_UART)(Z); |
Mike Frysinger | 1aafd90 | 2007-07-25 11:19:14 +0800 | [diff] [blame] | 150 | #if ANOMALY_05000212 |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 151 | W[P0] = R0.L; /* Write */ |
| 152 | SSYNC; |
| 153 | #endif |
| 154 | W[P0] = R0.L; /* Enable both UARTS */ |
| 155 | SSYNC; |
| 156 | |
| 157 | p0.h = hi(PORTF_FER); |
| 158 | p0.l = lo(PORTF_FER); |
Mike Frysinger | 1aafd90 | 2007-07-25 11:19:14 +0800 | [diff] [blame] | 159 | #if ANOMALY_05000212 |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 160 | R0.L = W[P0]; /* Read */ |
| 161 | SSYNC; |
| 162 | #endif |
| 163 | R0 = 0x000F(Z); |
Mike Frysinger | 1aafd90 | 2007-07-25 11:19:14 +0800 | [diff] [blame] | 164 | #if ANOMALY_05000212 |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 165 | W[P0] = R0.L; /* Write */ |
| 166 | SSYNC; |
| 167 | #endif |
| 168 | /* Enable peripheral function of PORTF for UART0 and UART1 */ |
| 169 | W[P0] = R0.L; |
| 170 | SSYNC; |
| 171 | |
| 172 | #if !defined(CONFIG_BF534) |
| 173 | p0.h = hi(EMAC_SYSTAT); |
| 174 | p0.l = lo(EMAC_SYSTAT); |
| 175 | R0.h = 0xFFFF; /* Clear EMAC Interrupt Status bits */ |
| 176 | R0.l = 0xFFFF; |
| 177 | [P0] = R0; |
| 178 | SSYNC; |
| 179 | #endif |
| 180 | |
| 181 | #ifdef CONFIG_BF537_PORT_H |
| 182 | p0.h = hi(PORTH_FER); |
| 183 | p0.l = lo(PORTH_FER); |
| 184 | R0.L = W[P0]; /* Read */ |
| 185 | SSYNC; |
| 186 | R0 = 0x0000; |
| 187 | W[P0] = R0.L; /* Write */ |
| 188 | SSYNC; |
| 189 | W[P0] = R0.L; /* Disable peripheral function of PORTH */ |
| 190 | SSYNC; |
| 191 | #endif |
| 192 | |
Mike Frysinger | 5079df9 | 2007-05-21 18:09:27 +0800 | [diff] [blame] | 193 | /* Initialise UART - when booting from u-boot, the UART is not disabled |
| 194 | * so if we dont initalize here, our serial console gets hosed */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 195 | p0.h = hi(UART_LCR); |
| 196 | p0.l = lo(UART_LCR); |
| 197 | r0 = 0x0(Z); |
| 198 | w[p0] = r0.L; /* To enable DLL writes */ |
| 199 | ssync; |
| 200 | |
| 201 | p0.h = hi(UART_DLL); |
| 202 | p0.l = lo(UART_DLL); |
Mike Frysinger | 83a5c3e | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 203 | r0 = 0x0(Z); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 204 | w[p0] = r0.L; |
| 205 | ssync; |
| 206 | |
| 207 | p0.h = hi(UART_DLH); |
| 208 | p0.l = lo(UART_DLH); |
| 209 | r0 = 0x00(Z); |
| 210 | w[p0] = r0.L; |
| 211 | ssync; |
| 212 | |
| 213 | p0.h = hi(UART_GCTL); |
| 214 | p0.l = lo(UART_GCTL); |
| 215 | r0 = 0x0(Z); |
| 216 | w[p0] = r0.L; /* To enable UART clock */ |
| 217 | ssync; |
| 218 | |
| 219 | /* Initialize stack pointer */ |
| 220 | sp.l = lo(INITIAL_STACK); |
| 221 | sp.h = hi(INITIAL_STACK); |
| 222 | fp = sp; |
| 223 | usp = sp; |
| 224 | |
| 225 | /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */ |
| 226 | call _bf53x_relocate_l1_mem; |
| 227 | #if CONFIG_BFIN_KERNEL_CLOCK |
| 228 | call _start_dma_code; |
| 229 | #endif |
Mike Frysinger | 83a5c3e | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 230 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 231 | /* Code for initializing Async memory banks */ |
| 232 | |
| 233 | p2.h = hi(EBIU_AMBCTL1); |
| 234 | p2.l = lo(EBIU_AMBCTL1); |
| 235 | r0.h = hi(AMBCTL1VAL); |
| 236 | r0.l = lo(AMBCTL1VAL); |
| 237 | [p2] = r0; |
| 238 | ssync; |
| 239 | |
| 240 | p2.h = hi(EBIU_AMBCTL0); |
| 241 | p2.l = lo(EBIU_AMBCTL0); |
| 242 | r0.h = hi(AMBCTL0VAL); |
| 243 | r0.l = lo(AMBCTL0VAL); |
| 244 | [p2] = r0; |
| 245 | ssync; |
| 246 | |
| 247 | p2.h = hi(EBIU_AMGCTL); |
| 248 | p2.l = lo(EBIU_AMGCTL); |
| 249 | r0 = AMGCTLVAL; |
| 250 | w[p2] = r0; |
| 251 | ssync; |
| 252 | |
| 253 | /* This section keeps the processor in supervisor mode |
| 254 | * during kernel boot. Switches to user mode at end of boot. |
| 255 | * See page 3-9 of Hardware Reference manual for documentation. |
| 256 | */ |
| 257 | |
| 258 | /* EVT15 = _real_start */ |
| 259 | |
| 260 | p0.l = lo(EVT15); |
| 261 | p0.h = hi(EVT15); |
| 262 | p1.l = _real_start; |
| 263 | p1.h = _real_start; |
| 264 | [p0] = p1; |
| 265 | csync; |
| 266 | |
| 267 | p0.l = lo(IMASK); |
| 268 | p0.h = hi(IMASK); |
| 269 | p1.l = IMASK_IVG15; |
| 270 | p1.h = 0x0; |
| 271 | [p0] = p1; |
| 272 | csync; |
| 273 | |
| 274 | raise 15; |
| 275 | p0.l = .LWAIT_HERE; |
| 276 | p0.h = .LWAIT_HERE; |
| 277 | reti = p0; |
Mike Frysinger | 1aafd90 | 2007-07-25 11:19:14 +0800 | [diff] [blame] | 278 | #if ANOMALY_05000281 |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 279 | nop; nop; nop; |
| 280 | #endif |
| 281 | rti; |
| 282 | |
| 283 | .LWAIT_HERE: |
| 284 | jump .LWAIT_HERE; |
Mike Frysinger | 52a0781 | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 285 | ENDPROC(__start) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 286 | |
| 287 | ENTRY(_real_start) |
| 288 | [ -- sp ] = reti; |
| 289 | p0.l = lo(WDOG_CTL); |
| 290 | p0.h = hi(WDOG_CTL); |
| 291 | r0 = 0xAD6(z); |
| 292 | w[p0] = r0; /* watchdog off for now */ |
| 293 | ssync; |
| 294 | |
| 295 | /* Code update for BSS size == 0 |
| 296 | * Zero out the bss region. |
| 297 | */ |
| 298 | |
| 299 | p1.l = ___bss_start; |
| 300 | p1.h = ___bss_start; |
| 301 | p2.l = ___bss_stop; |
| 302 | p2.h = ___bss_stop; |
| 303 | r0 = 0; |
| 304 | p2 -= p1; |
Mike Frysinger | 83a5c3e | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 305 | lsetup (.L_clear_bss, .L_clear_bss) lc0 = p2; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 306 | .L_clear_bss: |
| 307 | B[p1++] = r0; |
| 308 | |
| 309 | /* In case there is a NULL pointer reference |
| 310 | * Zero out region before stext |
| 311 | */ |
| 312 | |
| 313 | p1.l = 0x0; |
| 314 | p1.h = 0x0; |
| 315 | r0.l = __stext; |
| 316 | r0.h = __stext; |
| 317 | r0 = r0 >> 1; |
| 318 | p2 = r0; |
| 319 | r0 = 0; |
Mike Frysinger | 83a5c3e | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 320 | lsetup (.L_clear_zero, .L_clear_zero) lc0 = p2; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 321 | .L_clear_zero: |
| 322 | W[p1++] = r0; |
| 323 | |
| 324 | /* pass the uboot arguments to the global value command line */ |
| 325 | R0 = R7; |
| 326 | call _cmdline_init; |
| 327 | |
| 328 | p1.l = __rambase; |
| 329 | p1.h = __rambase; |
| 330 | r0.l = __sdata; |
| 331 | r0.h = __sdata; |
| 332 | [p1] = r0; |
| 333 | |
| 334 | p1.l = __ramstart; |
| 335 | p1.h = __ramstart; |
| 336 | p3.l = ___bss_stop; |
| 337 | p3.h = ___bss_stop; |
| 338 | |
| 339 | r1 = p3; |
| 340 | [p1] = r1; |
| 341 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 342 | /* |
Mike Frysinger | 83a5c3e | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 343 | * load the current thread pointer and stack |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 344 | */ |
| 345 | r1.l = _init_thread_union; |
| 346 | r1.h = _init_thread_union; |
| 347 | |
| 348 | r2.l = 0x2000; |
| 349 | r2.h = 0x0000; |
| 350 | r1 = r1 + r2; |
| 351 | sp = r1; |
| 352 | usp = sp; |
| 353 | fp = sp; |
Mike Frysinger | 52a0781 | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 354 | jump.l _start_kernel; |
| 355 | ENDPROC(_real_start) |
| 356 | |
| 357 | __FINIT |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 358 | |
| 359 | .section .l1.text |
| 360 | #if CONFIG_BFIN_KERNEL_CLOCK |
| 361 | ENTRY(_start_dma_code) |
| 362 | |
| 363 | /* Enable PHY CLK buffer output */ |
| 364 | p0.h = hi(VR_CTL); |
| 365 | p0.l = lo(VR_CTL); |
| 366 | r0.l = w[p0]; |
| 367 | bitset(r0, 14); |
| 368 | w[p0] = r0.l; |
| 369 | ssync; |
| 370 | |
| 371 | p0.h = hi(SIC_IWR); |
| 372 | p0.l = lo(SIC_IWR); |
| 373 | r0.l = 0x1; |
| 374 | r0.h = 0x0; |
| 375 | [p0] = r0; |
| 376 | SSYNC; |
| 377 | |
| 378 | /* |
| 379 | * Set PLL_CTL |
| 380 | * - [14:09] = MSEL[5:0] : CLKIN / VCO multiplication factors |
| 381 | * - [8] = BYPASS : BYPASS the PLL, run CLKIN into CCLK/SCLK |
| 382 | * - [7] = output delay (add 200ps of delay to mem signals) |
| 383 | * - [6] = input delay (add 200ps of input delay to mem signals) |
| 384 | * - [5] = PDWN : 1=All Clocks off |
| 385 | * - [3] = STOPCK : 1=Core Clock off |
| 386 | * - [1] = PLL_OFF : 1=Disable Power to PLL |
| 387 | * - [0] = DF : 1=Pass CLKIN/2 to PLL / 0=Pass CLKIN to PLL |
| 388 | * all other bits set to zero |
| 389 | */ |
| 390 | |
| 391 | p0.h = hi(PLL_LOCKCNT); |
| 392 | p0.l = lo(PLL_LOCKCNT); |
| 393 | r0 = 0x300(Z); |
| 394 | w[p0] = r0.l; |
| 395 | ssync; |
| 396 | |
| 397 | P2.H = hi(EBIU_SDGCTL); |
| 398 | P2.L = lo(EBIU_SDGCTL); |
| 399 | R0 = [P2]; |
| 400 | BITSET (R0, 24); |
| 401 | [P2] = R0; |
| 402 | SSYNC; |
| 403 | |
| 404 | r0 = CONFIG_VCO_MULT & 63; /* Load the VCO multiplier */ |
| 405 | r0 = r0 << 9; /* Shift it over, */ |
| 406 | r1 = CLKIN_HALF; /* Do we need to divide CLKIN by 2?*/ |
| 407 | r0 = r1 | r0; |
| 408 | r1 = PLL_BYPASS; /* Bypass the PLL? */ |
| 409 | r1 = r1 << 8; /* Shift it over */ |
| 410 | r0 = r1 | r0; /* add them all together */ |
| 411 | |
| 412 | p0.h = hi(PLL_CTL); |
| 413 | p0.l = lo(PLL_CTL); /* Load the address */ |
| 414 | cli r2; /* Disable interrupts */ |
| 415 | ssync; |
| 416 | w[p0] = r0.l; /* Set the value */ |
| 417 | idle; /* Wait for the PLL to stablize */ |
| 418 | sti r2; /* Enable interrupts */ |
| 419 | |
| 420 | .Lcheck_again: |
| 421 | p0.h = hi(PLL_STAT); |
| 422 | p0.l = lo(PLL_STAT); |
| 423 | R0 = W[P0](Z); |
| 424 | CC = BITTST(R0,5); |
| 425 | if ! CC jump .Lcheck_again; |
| 426 | |
| 427 | /* Configure SCLK & CCLK Dividers */ |
| 428 | r0 = (CONFIG_CCLK_ACT_DIV | CONFIG_SCLK_DIV); |
| 429 | p0.h = hi(PLL_DIV); |
| 430 | p0.l = lo(PLL_DIV); |
| 431 | w[p0] = r0.l; |
| 432 | ssync; |
| 433 | |
| 434 | p0.l = lo(EBIU_SDRRC); |
| 435 | p0.h = hi(EBIU_SDRRC); |
| 436 | r0 = mem_SDRRC; |
| 437 | w[p0] = r0.l; |
| 438 | ssync; |
| 439 | |
Mike Frysinger | e208f83 | 2007-07-25 10:11:42 +0800 | [diff] [blame] | 440 | p0.l = LO(EBIU_SDBCTL); |
| 441 | p0.h = HI(EBIU_SDBCTL); /* SDRAM Memory Bank Control Register */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 442 | r0 = mem_SDBCTL; |
| 443 | w[p0] = r0.l; |
| 444 | ssync; |
| 445 | |
| 446 | P2.H = hi(EBIU_SDGCTL); |
| 447 | P2.L = lo(EBIU_SDGCTL); |
| 448 | R0 = [P2]; |
| 449 | BITCLR (R0, 24); |
| 450 | p0.h = hi(EBIU_SDSTAT); |
| 451 | p0.l = lo(EBIU_SDSTAT); |
| 452 | r2.l = w[p0]; |
| 453 | cc = bittst(r2,3); |
| 454 | if !cc jump .Lskip; |
| 455 | NOP; |
| 456 | BITSET (R0, 23); |
| 457 | .Lskip: |
| 458 | [P2] = R0; |
| 459 | SSYNC; |
| 460 | |
| 461 | R0.L = lo(mem_SDGCTL); |
| 462 | R0.H = hi(mem_SDGCTL); |
| 463 | R1 = [p2]; |
| 464 | R1 = R1 | R0; |
| 465 | [P2] = R1; |
| 466 | SSYNC; |
| 467 | |
| 468 | p0.h = hi(SIC_IWR); |
| 469 | p0.l = lo(SIC_IWR); |
| 470 | r0.l = lo(IWR_ENABLE_ALL); |
| 471 | r0.h = hi(IWR_ENABLE_ALL); |
| 472 | [p0] = r0; |
| 473 | SSYNC; |
| 474 | |
| 475 | RTS; |
Mike Frysinger | 52a0781 | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 476 | ENDPROC(_start_dma_code) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 477 | #endif /* CONFIG_BFIN_KERNEL_CLOCK */ |
| 478 | |
| 479 | ENTRY(_bfin_reset) |
| 480 | /* No more interrupts to be handled*/ |
| 481 | CLI R6; |
| 482 | SSYNC; |
| 483 | |
| 484 | #if defined(CONFIG_MTD_M25P80) |
Mike Frysinger | c09c4e0 | 2007-05-21 18:09:30 +0800 | [diff] [blame] | 485 | /* |
| 486 | * The following code fix the SPI flash reboot issue, |
| 487 | * /CS signal of the chip which is using PF10 return to GPIO mode |
| 488 | */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 489 | p0.h = hi(PORTF_FER); |
| 490 | p0.l = lo(PORTF_FER); |
| 491 | r0.l = 0x0000; |
| 492 | w[p0] = r0.l; |
| 493 | SSYNC; |
| 494 | |
Mike Frysinger | c09c4e0 | 2007-05-21 18:09:30 +0800 | [diff] [blame] | 495 | /* /CS return to high */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 496 | p0.h = hi(PORTFIO); |
| 497 | p0.l = lo(PORTFIO); |
| 498 | r0.l = 0xFFFF; |
| 499 | w[p0] = r0.l; |
| 500 | SSYNC; |
| 501 | |
Mike Frysinger | c09c4e0 | 2007-05-21 18:09:30 +0800 | [diff] [blame] | 502 | /* Delay some time, This is necessary */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 503 | r1.h = 0; |
| 504 | r1.l = 0x400; |
| 505 | p1 = r1; |
Mike Frysinger | c09c4e0 | 2007-05-21 18:09:30 +0800 | [diff] [blame] | 506 | lsetup (.L_delay_lab1, .L_delay_lab1_end) lc1 = p1; |
| 507 | .L_delay_lab1: |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 508 | r0.h = 0; |
| 509 | r0.l = 0x8000; |
| 510 | p0 = r0; |
Mike Frysinger | c09c4e0 | 2007-05-21 18:09:30 +0800 | [diff] [blame] | 511 | lsetup (.L_delay_lab0, .L_delay_lab0_end) lc0 = p0; |
| 512 | .L_delay_lab0: |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 513 | nop; |
Mike Frysinger | c09c4e0 | 2007-05-21 18:09:30 +0800 | [diff] [blame] | 514 | .L_delay_lab0_end: |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 515 | nop; |
Mike Frysinger | c09c4e0 | 2007-05-21 18:09:30 +0800 | [diff] [blame] | 516 | .L_delay_lab1_end: |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 517 | nop; |
| 518 | #endif |
| 519 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 520 | /* Clear the IMASK register */ |
| 521 | p0.h = hi(IMASK); |
| 522 | p0.l = lo(IMASK); |
| 523 | r0 = 0x0; |
| 524 | [p0] = r0; |
| 525 | |
| 526 | /* Clear the ILAT register */ |
| 527 | p0.h = hi(ILAT); |
| 528 | p0.l = lo(ILAT); |
| 529 | r0 = [p0]; |
| 530 | [p0] = r0; |
| 531 | SSYNC; |
| 532 | |
Mike Frysinger | ef9256d | 2007-05-21 18:09:26 +0800 | [diff] [blame] | 533 | /* make sure SYSCR is set to use BMODE */ |
| 534 | P0.h = hi(SYSCR); |
| 535 | P0.l = lo(SYSCR); |
| 536 | R0.l = 0x0; |
| 537 | W[P0] = R0.l; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 538 | SSYNC; |
| 539 | |
Mike Frysinger | ef9256d | 2007-05-21 18:09:26 +0800 | [diff] [blame] | 540 | /* issue a system soft reset */ |
| 541 | P1.h = hi(SWRST); |
| 542 | P1.l = lo(SWRST); |
| 543 | R1.l = 0x0007; |
| 544 | W[P1] = R1; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 545 | SSYNC; |
| 546 | |
Mike Frysinger | ef9256d | 2007-05-21 18:09:26 +0800 | [diff] [blame] | 547 | /* clear system soft reset */ |
| 548 | R0.l = 0x0000; |
| 549 | W[P0] = R0; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 550 | SSYNC; |
| 551 | |
Mike Frysinger | ef9256d | 2007-05-21 18:09:26 +0800 | [diff] [blame] | 552 | /* issue core reset */ |
| 553 | raise 1; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 554 | |
| 555 | RTS; |
Mike Frysinger | ef9256d | 2007-05-21 18:09:26 +0800 | [diff] [blame] | 556 | ENDPROC(_bfin_reset) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 557 | |
| 558 | .data |
| 559 | |
| 560 | /* |
| 561 | * Set up the usable of RAM stuff. Size of RAM is determined then |
| 562 | * an initial stack set up at the end. |
| 563 | */ |
| 564 | |
| 565 | .align 4 |
| 566 | __rambase: |
| 567 | .long 0 |
| 568 | __ramstart: |
| 569 | .long 0 |
| 570 | __ramend: |
| 571 | .long 0 |