wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 1998 Dan Malek <dmalek@jlc.net> |
| 3 | * Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se> |
| 4 | * Copyright (C) 2000,2001,2002 Wolfgang Denk <wd@denx.de> |
Stefan Roese | f6c7b76 | 2007-03-24 15:45:34 +0100 | [diff] [blame] | 5 | * Copyright (C) 2007 Stefan Roese <sr@denx.de>, DENX Software Engineering |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 6 | * Copyright (c) 2008 Nuovation System Designs, LLC |
| 7 | * Grant Erickson <gerickson@nuovations.com> |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 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 | */ |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 27 | /*------------------------------------------------------------------------------+ |
| 28 | * |
| 29 | * This source code has been made available to you by IBM on an AS-IS |
| 30 | * basis. Anyone receiving this source is licensed under IBM |
| 31 | * copyrights to use it in any way he or she deems fit, including |
| 32 | * copying it, modifying it, compiling it, and redistributing it either |
| 33 | * with or without modifications. No license under IBM patents or |
| 34 | * patent applications is to be implied by the copyright license. |
| 35 | * |
| 36 | * Any user of this software should understand that IBM cannot provide |
| 37 | * technical support for this software and will not be responsible for |
| 38 | * any consequences resulting from the use of this software. |
| 39 | * |
| 40 | * Any person who transfers this source code or any derivative work |
| 41 | * must include the IBM copyright notice, this paragraph, and the |
| 42 | * preceding two paragraphs in the transferred software. |
| 43 | * |
| 44 | * COPYRIGHT I B M CORPORATION 1995 |
| 45 | * LICENSED MATERIAL - PROGRAM PROPERTY OF I B M |
| 46 | *------------------------------------------------------------------------------- |
| 47 | */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 48 | |
Wolfgang Denk | 0ee7077 | 2005-09-23 11:05:55 +0200 | [diff] [blame] | 49 | /* U-Boot - Startup Code for AMCC 4xx PowerPC based Embedded Boards |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 50 | * |
| 51 | * |
| 52 | * The processor starts at 0xfffffffc and the code is executed |
| 53 | * from flash/rom. |
| 54 | * in memory, but as long we don't jump around before relocating. |
| 55 | * board_init lies at a quite high address and when the cpu has |
| 56 | * jumped there, everything is ok. |
| 57 | * This works because the cpu gives the FLASH (CS0) the whole |
| 58 | * address space at startup, and board_init lies as a echo of |
| 59 | * the flash somewhere up there in the memorymap. |
| 60 | * |
| 61 | * board_init will change CS0 to be positioned at the correct |
| 62 | * address and (s)dram will be positioned at address 0 |
| 63 | */ |
| 64 | #include <config.h> |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 65 | #include <ppc4xx.h> |
| 66 | #include <version.h> |
| 67 | |
| 68 | #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */ |
| 69 | |
| 70 | #include <ppc_asm.tmpl> |
| 71 | #include <ppc_defs.h> |
| 72 | |
| 73 | #include <asm/cache.h> |
| 74 | #include <asm/mmu.h> |
| 75 | |
| 76 | #ifndef CONFIG_IDENT_STRING |
| 77 | #define CONFIG_IDENT_STRING "" |
| 78 | #endif |
| 79 | |
| 80 | #ifdef CFG_INIT_DCACHE_CS |
| 81 | # if (CFG_INIT_DCACHE_CS == 0) |
| 82 | # define PBxAP pb0ap |
| 83 | # define PBxCR pb0cr |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 84 | # if (defined(CFG_EBC_PB0AP) && defined(CFG_EBC_PB0CR)) |
| 85 | # define PBxAP_VAL CFG_EBC_PB0AP |
| 86 | # define PBxCR_VAL CFG_EBC_PB0CR |
| 87 | # endif |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 88 | # endif |
| 89 | # if (CFG_INIT_DCACHE_CS == 1) |
| 90 | # define PBxAP pb1ap |
| 91 | # define PBxCR pb1cr |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 92 | # if (defined(CFG_EBC_PB1AP) && defined(CFG_EBC_PB1CR)) |
| 93 | # define PBxAP_VAL CFG_EBC_PB1AP |
| 94 | # define PBxCR_VAL CFG_EBC_PB1CR |
| 95 | # endif |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 96 | # endif |
| 97 | # if (CFG_INIT_DCACHE_CS == 2) |
| 98 | # define PBxAP pb2ap |
| 99 | # define PBxCR pb2cr |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 100 | # if (defined(CFG_EBC_PB2AP) && defined(CFG_EBC_PB2CR)) |
| 101 | # define PBxAP_VAL CFG_EBC_PB2AP |
| 102 | # define PBxCR_VAL CFG_EBC_PB2CR |
| 103 | # endif |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 104 | # endif |
| 105 | # if (CFG_INIT_DCACHE_CS == 3) |
| 106 | # define PBxAP pb3ap |
| 107 | # define PBxCR pb3cr |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 108 | # if (defined(CFG_EBC_PB3AP) && defined(CFG_EBC_PB3CR)) |
| 109 | # define PBxAP_VAL CFG_EBC_PB3AP |
| 110 | # define PBxCR_VAL CFG_EBC_PB3CR |
| 111 | # endif |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 112 | # endif |
| 113 | # if (CFG_INIT_DCACHE_CS == 4) |
| 114 | # define PBxAP pb4ap |
| 115 | # define PBxCR pb4cr |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 116 | # if (defined(CFG_EBC_PB4AP) && defined(CFG_EBC_PB4CR)) |
| 117 | # define PBxAP_VAL CFG_EBC_PB4AP |
| 118 | # define PBxCR_VAL CFG_EBC_PB4CR |
| 119 | # endif |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 120 | # endif |
| 121 | # if (CFG_INIT_DCACHE_CS == 5) |
| 122 | # define PBxAP pb5ap |
| 123 | # define PBxCR pb5cr |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 124 | # if (defined(CFG_EBC_PB5AP) && defined(CFG_EBC_PB5CR)) |
| 125 | # define PBxAP_VAL CFG_EBC_PB5AP |
| 126 | # define PBxCR_VAL CFG_EBC_PB5CR |
| 127 | # endif |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 128 | # endif |
| 129 | # if (CFG_INIT_DCACHE_CS == 6) |
| 130 | # define PBxAP pb6ap |
| 131 | # define PBxCR pb6cr |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 132 | # if (defined(CFG_EBC_PB6AP) && defined(CFG_EBC_PB6CR)) |
| 133 | # define PBxAP_VAL CFG_EBC_PB6AP |
| 134 | # define PBxCR_VAL CFG_EBC_PB6CR |
| 135 | # endif |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 136 | # endif |
| 137 | # if (CFG_INIT_DCACHE_CS == 7) |
| 138 | # define PBxAP pb7ap |
| 139 | # define PBxCR pb7cr |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 140 | # if (defined(CFG_EBC_PB7AP) && defined(CFG_EBC_PB7CR)) |
| 141 | # define PBxAP_VAL CFG_EBC_PB7AP |
| 142 | # define PBxCR_VAL CFG_EBC_PB7CR |
| 143 | # endif |
| 144 | # endif |
| 145 | # ifndef PBxAP_VAL |
| 146 | # define PBxAP_VAL 0 |
| 147 | # endif |
| 148 | # ifndef PBxCR_VAL |
| 149 | # define PBxCR_VAL 0 |
| 150 | # endif |
| 151 | /* |
| 152 | * Memory Bank x (nothingness) initialization CFG_INIT_RAM_ADDR + 64 MiB |
| 153 | * used as temporary stack pointer for the primordial stack |
| 154 | */ |
| 155 | # ifndef CFG_INIT_DCACHE_PBxAR |
| 156 | # define CFG_INIT_DCACHE_PBxAR (EBC_BXAP_BME_DISABLED | \ |
| 157 | EBC_BXAP_TWT_ENCODE(7) | \ |
| 158 | EBC_BXAP_BCE_DISABLE | \ |
| 159 | EBC_BXAP_BCT_2TRANS | \ |
| 160 | EBC_BXAP_CSN_ENCODE(0) | \ |
| 161 | EBC_BXAP_OEN_ENCODE(0) | \ |
| 162 | EBC_BXAP_WBN_ENCODE(0) | \ |
| 163 | EBC_BXAP_WBF_ENCODE(0) | \ |
| 164 | EBC_BXAP_TH_ENCODE(2) | \ |
| 165 | EBC_BXAP_RE_DISABLED | \ |
| 166 | EBC_BXAP_SOR_NONDELAYED | \ |
| 167 | EBC_BXAP_BEM_WRITEONLY | \ |
| 168 | EBC_BXAP_PEN_DISABLED) |
| 169 | # endif /* CFG_INIT_DCACHE_PBxAR */ |
| 170 | # ifndef CFG_INIT_DCACHE_PBxCR |
| 171 | # define CFG_INIT_DCACHE_PBxCR (EBC_BXCR_BAS_ENCODE(CFG_INIT_RAM_ADDR) | \ |
| 172 | EBC_BXCR_BS_64MB | \ |
| 173 | EBC_BXCR_BU_RW | \ |
| 174 | EBC_BXCR_BW_16BIT) |
| 175 | # endif /* CFG_INIT_DCACHE_PBxCR */ |
| 176 | # ifndef CFG_INIT_RAM_PATTERN |
| 177 | # define CFG_INIT_RAM_PATTERN 0xDEADDEAD |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 178 | # endif |
| 179 | #endif /* CFG_INIT_DCACHE_CS */ |
| 180 | |
Stefan Roese | 0fb8ab9 | 2008-01-30 14:48:28 +0100 | [diff] [blame] | 181 | #if (defined(CFG_INIT_RAM_DCACHE) && (CFG_INIT_RAM_END > (4 << 10))) |
| 182 | #error Only 4k of init-ram is supported - please adjust CFG_INIT_RAM_END! |
| 183 | #endif |
| 184 | |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 185 | /* |
| 186 | * Unless otherwise overriden, enable two 128MB cachable instruction regions |
| 187 | * at CFG_SDRAM_BASE and another 128MB cacheable instruction region covering |
| 188 | * NOR flash at CFG_FLASH_BASE. Disable all cacheable data regions. |
| 189 | */ |
Stefan Roese | 7d72e02 | 2008-06-02 14:35:44 +0200 | [diff] [blame^] | 190 | #if !defined(CFG_FLASH_BASE) |
| 191 | /* If not already defined, set it to the "last" 128MByte region */ |
| 192 | # define CFG_FLASH_BASE 0xf8000000 |
| 193 | #endif |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 194 | #if !defined(CFG_ICACHE_SACR_VALUE) |
| 195 | # define CFG_ICACHE_SACR_VALUE \ |
| 196 | (PPC_128MB_SACR_VALUE(CFG_SDRAM_BASE + ( 0 << 20)) | \ |
| 197 | PPC_128MB_SACR_VALUE(CFG_SDRAM_BASE + (128 << 20)) | \ |
| 198 | PPC_128MB_SACR_VALUE(CFG_FLASH_BASE)) |
| 199 | #endif /* !defined(CFG_ICACHE_SACR_VALUE) */ |
| 200 | |
| 201 | #if !defined(CFG_DCACHE_SACR_VALUE) |
| 202 | # define CFG_DCACHE_SACR_VALUE \ |
| 203 | (0x00000000) |
| 204 | #endif /* !defined(CFG_DCACHE_SACR_VALUE) */ |
| 205 | |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 206 | #define function_prolog(func_name) .text; \ |
Stefan Roese | 4274351 | 2007-06-01 15:27:11 +0200 | [diff] [blame] | 207 | .align 2; \ |
| 208 | .globl func_name; \ |
| 209 | func_name: |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 210 | #define function_epilog(func_name) .type func_name,@function; \ |
Stefan Roese | 4274351 | 2007-06-01 15:27:11 +0200 | [diff] [blame] | 211 | .size func_name,.-func_name |
| 212 | |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 213 | /* We don't want the MMU yet. |
| 214 | */ |
| 215 | #undef MSR_KERNEL |
| 216 | #define MSR_KERNEL ( MSR_ME ) /* Machine Check */ |
| 217 | |
| 218 | |
| 219 | .extern ext_bus_cntlr_init |
| 220 | .extern sdram_init |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 221 | #ifdef CONFIG_NAND_U_BOOT |
| 222 | .extern reconfig_tlb0 |
| 223 | #endif |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 224 | |
| 225 | /* |
| 226 | * Set up GOT: Global Offset Table |
| 227 | * |
| 228 | * Use r14 to access the GOT |
| 229 | */ |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 230 | #if !defined(CONFIG_NAND_SPL) |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 231 | START_GOT |
| 232 | GOT_ENTRY(_GOT2_TABLE_) |
| 233 | GOT_ENTRY(_FIXUP_TABLE_) |
| 234 | |
| 235 | GOT_ENTRY(_start) |
| 236 | GOT_ENTRY(_start_of_vectors) |
| 237 | GOT_ENTRY(_end_of_vectors) |
| 238 | GOT_ENTRY(transfer_to_handler) |
| 239 | |
wdenk | b9a83a9 | 2003-05-30 12:48:29 +0000 | [diff] [blame] | 240 | GOT_ENTRY(__init_end) |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 241 | GOT_ENTRY(_end) |
wdenk | bf2f8c9 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 242 | GOT_ENTRY(__bss_start) |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 243 | END_GOT |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 244 | #endif /* CONFIG_NAND_SPL */ |
| 245 | |
| 246 | #if defined(CONFIG_NAND_U_BOOT) && !defined(CONFIG_NAND_SPL) |
| 247 | /* |
| 248 | * NAND U-Boot image is started from offset 0 |
| 249 | */ |
| 250 | .text |
Stefan Roese | 23d8d34 | 2007-06-06 11:42:13 +0200 | [diff] [blame] | 251 | #if defined(CONFIG_440) |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 252 | bl reconfig_tlb0 |
Stefan Roese | 23d8d34 | 2007-06-06 11:42:13 +0200 | [diff] [blame] | 253 | #endif |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 254 | GET_GOT |
| 255 | bl cpu_init_f /* run low-level CPU init code (from Flash) */ |
| 256 | bl board_init_f |
| 257 | #endif |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 258 | |
| 259 | /* |
| 260 | * 440 Startup -- on reset only the top 4k of the effective |
| 261 | * address space is mapped in by an entry in the instruction |
| 262 | * and data shadow TLB. The .bootpg section is located in the |
| 263 | * top 4k & does only what's necessary to map in the the rest |
| 264 | * of the boot rom. Once the boot rom is mapped in we can |
| 265 | * proceed with normal startup. |
| 266 | * |
| 267 | * NOTE: CS0 only covers the top 2MB of the effective address |
| 268 | * space after reset. |
| 269 | */ |
| 270 | |
| 271 | #if defined(CONFIG_440) |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 272 | #if !defined(CONFIG_NAND_SPL) |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 273 | .section .bootpg,"ax" |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 274 | #endif |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 275 | .globl _start_440 |
| 276 | |
| 277 | /**************************************************************************/ |
| 278 | _start_440: |
Wolfgang Denk | 4df0da5 | 2006-10-09 00:42:01 +0200 | [diff] [blame] | 279 | /*--------------------------------------------------------------------+ |
| 280 | | 440EPX BUP Change - Hardware team request |
| 281 | +--------------------------------------------------------------------*/ |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 282 | #if defined(CONFIG_440EPX) || defined(CONFIG_440GRX) |
| 283 | sync |
| 284 | nop |
| 285 | nop |
| 286 | #endif |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 287 | /*----------------------------------------------------------------+ |
| 288 | | Core bug fix. Clear the esr |
| 289 | +-----------------------------------------------------------------*/ |
Marian Balakowicz | be9463b | 2006-07-06 21:17:24 +0200 | [diff] [blame] | 290 | li r0,0 |
Wolfgang Denk | ba94093 | 2006-07-19 13:50:38 +0200 | [diff] [blame] | 291 | mtspr esr,r0 |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 292 | /*----------------------------------------------------------------*/ |
| 293 | /* Clear and set up some registers. */ |
| 294 | /*----------------------------------------------------------------*/ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 295 | iccci r0,r0 /* NOTE: operands not used for 440 */ |
| 296 | dccci r0,r0 /* NOTE: operands not used for 440 */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 297 | sync |
| 298 | li r0,0 |
| 299 | mtspr srr0,r0 |
| 300 | mtspr srr1,r0 |
| 301 | mtspr csrr0,r0 |
| 302 | mtspr csrr1,r0 |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 303 | /* NOTE: 440GX adds machine check status regs */ |
| 304 | #if defined(CONFIG_440) && !defined(CONFIG_440GP) |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 305 | mtspr mcsrr0,r0 |
| 306 | mtspr mcsrr1,r0 |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 307 | mfspr r1,mcsr |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 308 | mtspr mcsr,r1 |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 309 | #endif |
Stefan Roese | 0100cc1 | 2006-11-22 13:20:50 +0100 | [diff] [blame] | 310 | |
| 311 | /*----------------------------------------------------------------*/ |
| 312 | /* CCR0 init */ |
| 313 | /*----------------------------------------------------------------*/ |
| 314 | /* Disable store gathering & broadcast, guarantee inst/data |
| 315 | * cache block touch, force load/store alignment |
| 316 | * (see errata 1.12: 440_33) |
| 317 | */ |
| 318 | lis r1,0x0030 /* store gathering & broadcast disable */ |
| 319 | ori r1,r1,0x6000 /* cache touch */ |
| 320 | mtspr ccr0,r1 |
| 321 | |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 322 | /*----------------------------------------------------------------*/ |
| 323 | /* Initialize debug */ |
| 324 | /*----------------------------------------------------------------*/ |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 325 | mfspr r1,dbcr0 |
| 326 | andis. r1, r1, 0x8000 /* test DBCR0[EDM] bit */ |
| 327 | bne skip_debug_init /* if set, don't clear debug register */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 328 | mtspr dbcr0,r0 |
| 329 | mtspr dbcr1,r0 |
| 330 | mtspr dbcr2,r0 |
| 331 | mtspr iac1,r0 |
| 332 | mtspr iac2,r0 |
| 333 | mtspr iac3,r0 |
| 334 | mtspr dac1,r0 |
| 335 | mtspr dac2,r0 |
| 336 | mtspr dvc1,r0 |
| 337 | mtspr dvc2,r0 |
| 338 | |
| 339 | mfspr r1,dbsr |
| 340 | mtspr dbsr,r1 /* Clear all valid bits */ |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 341 | skip_debug_init: |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 342 | |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 343 | #if defined (CONFIG_440SPE) |
| 344 | /*----------------------------------------------------------------+ |
| 345 | | Initialize Core Configuration Reg1. |
| 346 | | a. ICDPEI: Record even parity. Normal operation. |
| 347 | | b. ICTPEI: Record even parity. Normal operation. |
| 348 | | c. DCTPEI: Record even parity. Normal operation. |
| 349 | | d. DCDPEI: Record even parity. Normal operation. |
| 350 | | e. DCUPEI: Record even parity. Normal operation. |
| 351 | | f. DCMPEI: Record even parity. Normal operation. |
| 352 | | g. FCOM: Normal operation |
| 353 | | h. MMUPEI: Record even parity. Normal operation. |
| 354 | | i. FFF: Flush only as much data as necessary. |
Marian Balakowicz | be9463b | 2006-07-06 21:17:24 +0200 | [diff] [blame] | 355 | | j. TCS: Timebase increments from CPU clock. |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 356 | +-----------------------------------------------------------------*/ |
Marian Balakowicz | be9463b | 2006-07-06 21:17:24 +0200 | [diff] [blame] | 357 | li r0,0 |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 358 | mtspr ccr1, r0 |
| 359 | |
| 360 | /*----------------------------------------------------------------+ |
| 361 | | Reset the timebase. |
| 362 | | The previous write to CCR1 sets the timebase source. |
| 363 | +-----------------------------------------------------------------*/ |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 364 | mtspr tbl, r0 |
| 365 | mtspr tbu, r0 |
| 366 | #endif |
| 367 | |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 368 | /*----------------------------------------------------------------*/ |
| 369 | /* Setup interrupt vectors */ |
| 370 | /*----------------------------------------------------------------*/ |
| 371 | mtspr ivpr,r0 /* Vectors start at 0x0000_0000 */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 372 | li r1,0x0100 |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 373 | mtspr ivor0,r1 /* Critical input */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 374 | li r1,0x0200 |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 375 | mtspr ivor1,r1 /* Machine check */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 376 | li r1,0x0300 |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 377 | mtspr ivor2,r1 /* Data storage */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 378 | li r1,0x0400 |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 379 | mtspr ivor3,r1 /* Instruction storage */ |
| 380 | li r1,0x0500 |
| 381 | mtspr ivor4,r1 /* External interrupt */ |
| 382 | li r1,0x0600 |
| 383 | mtspr ivor5,r1 /* Alignment */ |
| 384 | li r1,0x0700 |
| 385 | mtspr ivor6,r1 /* Program check */ |
| 386 | li r1,0x0800 |
| 387 | mtspr ivor7,r1 /* Floating point unavailable */ |
| 388 | li r1,0x0c00 |
| 389 | mtspr ivor8,r1 /* System call */ |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 390 | li r1,0x0a00 |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 391 | mtspr ivor9,r1 /* Auxiliary Processor unavailable */ |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 392 | li r1,0x0900 |
| 393 | mtspr ivor10,r1 /* Decrementer */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 394 | li r1,0x1300 |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 395 | mtspr ivor13,r1 /* Data TLB error */ |
| 396 | li r1,0x1400 |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 397 | mtspr ivor14,r1 /* Instr TLB error */ |
| 398 | li r1,0x2000 |
| 399 | mtspr ivor15,r1 /* Debug */ |
| 400 | |
| 401 | /*----------------------------------------------------------------*/ |
| 402 | /* Configure cache regions */ |
| 403 | /*----------------------------------------------------------------*/ |
| 404 | mtspr inv0,r0 |
| 405 | mtspr inv1,r0 |
| 406 | mtspr inv2,r0 |
| 407 | mtspr inv3,r0 |
| 408 | mtspr dnv0,r0 |
| 409 | mtspr dnv1,r0 |
| 410 | mtspr dnv2,r0 |
| 411 | mtspr dnv3,r0 |
| 412 | mtspr itv0,r0 |
| 413 | mtspr itv1,r0 |
| 414 | mtspr itv2,r0 |
| 415 | mtspr itv3,r0 |
| 416 | mtspr dtv0,r0 |
| 417 | mtspr dtv1,r0 |
| 418 | mtspr dtv2,r0 |
| 419 | mtspr dtv3,r0 |
| 420 | |
| 421 | /*----------------------------------------------------------------*/ |
| 422 | /* Cache victim limits */ |
| 423 | /*----------------------------------------------------------------*/ |
| 424 | /* floors 0, ceiling max to use the entire cache -- nothing locked |
| 425 | */ |
| 426 | lis r1,0x0001 |
| 427 | ori r1,r1,0xf800 |
| 428 | mtspr ivlim,r1 |
| 429 | mtspr dvlim,r1 |
| 430 | |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 431 | /*----------------------------------------------------------------+ |
| 432 | |Initialize MMUCR[STID] = 0. |
| 433 | +-----------------------------------------------------------------*/ |
| 434 | mfspr r0,mmucr |
| 435 | addis r1,0,0xFFFF |
| 436 | ori r1,r1,0xFF00 |
| 437 | and r0,r0,r1 |
| 438 | mtspr mmucr,r0 |
| 439 | |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 440 | /*----------------------------------------------------------------*/ |
| 441 | /* Clear all TLB entries -- TID = 0, TS = 0 */ |
| 442 | /*----------------------------------------------------------------*/ |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 443 | addis r0,0,0x0000 |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 444 | li r1,0x003f /* 64 TLB entries */ |
| 445 | mtctr r1 |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 446 | rsttlb: tlbwe r0,r1,0x0000 /* Invalidate all entries (V=0)*/ |
| 447 | tlbwe r0,r1,0x0001 |
| 448 | tlbwe r0,r1,0x0002 |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 449 | subi r1,r1,0x0001 |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 450 | bdnz rsttlb |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 451 | |
| 452 | /*----------------------------------------------------------------*/ |
| 453 | /* TLB entry setup -- step thru tlbtab */ |
| 454 | /*----------------------------------------------------------------*/ |
Rafal Jaworowski | a2e7ef0 | 2006-08-10 12:43:17 +0200 | [diff] [blame] | 455 | #if defined(CONFIG_440SPE) |
| 456 | /*----------------------------------------------------------------*/ |
| 457 | /* We have different TLB tables for revA and rev B of 440SPe */ |
| 458 | /*----------------------------------------------------------------*/ |
| 459 | mfspr r1, PVR |
| 460 | lis r0,0x5342 |
| 461 | ori r0,r0,0x1891 |
| 462 | cmpw r7,r1,r0 |
| 463 | bne r7,..revA |
| 464 | bl tlbtabB |
| 465 | b ..goon |
| 466 | ..revA: |
| 467 | bl tlbtabA |
| 468 | ..goon: |
| 469 | #else |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 470 | bl tlbtab /* Get tlbtab pointer */ |
Rafal Jaworowski | a2e7ef0 | 2006-08-10 12:43:17 +0200 | [diff] [blame] | 471 | #endif |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 472 | mr r5,r0 |
| 473 | li r1,0x003f /* 64 TLB entries max */ |
| 474 | mtctr r1 |
| 475 | li r4,0 /* TLB # */ |
| 476 | |
| 477 | addi r5,r5,-4 |
| 478 | 1: lwzu r0,4(r5) |
| 479 | cmpwi r0,0 |
| 480 | beq 2f /* 0 marks end */ |
| 481 | lwzu r1,4(r5) |
| 482 | lwzu r2,4(r5) |
| 483 | tlbwe r0,r4,0 /* TLB Word 0 */ |
| 484 | tlbwe r1,r4,1 /* TLB Word 1 */ |
| 485 | tlbwe r2,r4,2 /* TLB Word 2 */ |
| 486 | addi r4,r4,1 /* Next TLB */ |
| 487 | bdnz 1b |
| 488 | |
| 489 | /*----------------------------------------------------------------*/ |
| 490 | /* Continue from 'normal' start */ |
| 491 | /*----------------------------------------------------------------*/ |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 492 | 2: |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 493 | bl 3f |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 494 | b _start |
| 495 | |
| 496 | 3: li r0,0 |
| 497 | mtspr srr1,r0 /* Keep things disabled for now */ |
| 498 | mflr r1 |
| 499 | mtspr srr0,r1 |
| 500 | rfi |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 501 | #endif /* CONFIG_440 */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 502 | |
| 503 | /* |
| 504 | * r3 - 1st arg to board_init(): IMMP pointer |
| 505 | * r4 - 2nd arg to board_init(): boot flag |
| 506 | */ |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 507 | #ifndef CONFIG_NAND_SPL |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 508 | .text |
| 509 | .long 0x27051956 /* U-Boot Magic Number */ |
| 510 | .globl version_string |
| 511 | version_string: |
| 512 | .ascii U_BOOT_VERSION |
| 513 | .ascii " (", __DATE__, " - ", __TIME__, ")" |
| 514 | .ascii CONFIG_IDENT_STRING, "\0" |
| 515 | |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 516 | . = EXC_OFF_SYS_RESET |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 517 | .globl _start_of_vectors |
| 518 | _start_of_vectors: |
| 519 | |
| 520 | /* Critical input. */ |
| 521 | CRIT_EXCEPTION(0x100, CritcalInput, UnknownException) |
| 522 | |
| 523 | #ifdef CONFIG_440 |
| 524 | /* Machine check */ |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 525 | MCK_EXCEPTION(0x200, MachineCheck, MachineCheckException) |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 526 | #else |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 527 | CRIT_EXCEPTION(0x200, MachineCheck, MachineCheckException) |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 528 | #endif /* CONFIG_440 */ |
| 529 | |
| 530 | /* Data Storage exception. */ |
| 531 | STD_EXCEPTION(0x300, DataStorage, UnknownException) |
| 532 | |
| 533 | /* Instruction Storage exception. */ |
| 534 | STD_EXCEPTION(0x400, InstStorage, UnknownException) |
| 535 | |
| 536 | /* External Interrupt exception. */ |
| 537 | STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt) |
| 538 | |
| 539 | /* Alignment exception. */ |
| 540 | . = 0x600 |
| 541 | Alignment: |
| 542 | EXCEPTION_PROLOG(SRR0, SRR1) |
| 543 | mfspr r4,DAR |
| 544 | stw r4,_DAR(r21) |
| 545 | mfspr r5,DSISR |
| 546 | stw r5,_DSISR(r21) |
| 547 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 548 | li r20,MSR_KERNEL |
| 549 | rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */ |
| 550 | lwz r6,GOT(transfer_to_handler) |
| 551 | mtlr r6 |
| 552 | blrl |
| 553 | .L_Alignment: |
| 554 | .long AlignmentException - _start + _START_OFFSET |
| 555 | .long int_return - _start + _START_OFFSET |
| 556 | |
| 557 | /* Program check exception */ |
| 558 | . = 0x700 |
| 559 | ProgramCheck: |
| 560 | EXCEPTION_PROLOG(SRR0, SRR1) |
| 561 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 562 | li r20,MSR_KERNEL |
| 563 | rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */ |
| 564 | lwz r6,GOT(transfer_to_handler) |
| 565 | mtlr r6 |
| 566 | blrl |
| 567 | .L_ProgramCheck: |
| 568 | .long ProgramCheckException - _start + _START_OFFSET |
| 569 | .long int_return - _start + _START_OFFSET |
| 570 | |
| 571 | #ifdef CONFIG_440 |
| 572 | STD_EXCEPTION(0x800, FPUnavailable, UnknownException) |
| 573 | STD_EXCEPTION(0x900, Decrementer, DecrementerPITException) |
| 574 | STD_EXCEPTION(0xa00, APU, UnknownException) |
Stefan Roese | 80d99a4 | 2007-06-19 16:42:31 +0200 | [diff] [blame] | 575 | #endif |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 576 | STD_EXCEPTION(0xc00, SystemCall, UnknownException) |
| 577 | |
| 578 | #ifdef CONFIG_440 |
| 579 | STD_EXCEPTION(0x1300, DataTLBError, UnknownException) |
| 580 | STD_EXCEPTION(0x1400, InstructionTLBError, UnknownException) |
| 581 | #else |
| 582 | STD_EXCEPTION(0x1000, PIT, DecrementerPITException) |
| 583 | STD_EXCEPTION(0x1100, InstructionTLBMiss, UnknownException) |
| 584 | STD_EXCEPTION(0x1200, DataTLBMiss, UnknownException) |
| 585 | #endif |
| 586 | CRIT_EXCEPTION(0x2000, DebugBreakpoint, DebugException ) |
| 587 | |
| 588 | .globl _end_of_vectors |
| 589 | _end_of_vectors: |
| 590 | . = _START_OFFSET |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 591 | #endif |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 592 | .globl _start |
| 593 | _start: |
| 594 | |
| 595 | /*****************************************************************************/ |
| 596 | #if defined(CONFIG_440) |
| 597 | |
| 598 | /*----------------------------------------------------------------*/ |
| 599 | /* Clear and set up some registers. */ |
| 600 | /*----------------------------------------------------------------*/ |
| 601 | li r0,0x0000 |
| 602 | lis r1,0xffff |
| 603 | mtspr dec,r0 /* prevent dec exceptions */ |
| 604 | mtspr tbl,r0 /* prevent fit & wdt exceptions */ |
| 605 | mtspr tbu,r0 |
| 606 | mtspr tsr,r1 /* clear all timer exception status */ |
| 607 | mtspr tcr,r0 /* disable all */ |
| 608 | mtspr esr,r0 /* clear exception syndrome register */ |
| 609 | mtxer r0 /* clear integer exception register */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 610 | |
| 611 | /*----------------------------------------------------------------*/ |
| 612 | /* Debug setup -- some (not very good) ice's need an event*/ |
| 613 | /* to establish control :-( Define CFG_INIT_DBCR to the dbsr */ |
| 614 | /* value you need in this case 0x8cff 0000 should do the trick */ |
| 615 | /*----------------------------------------------------------------*/ |
| 616 | #if defined(CFG_INIT_DBCR) |
| 617 | lis r1,0xffff |
| 618 | ori r1,r1,0xffff |
| 619 | mtspr dbsr,r1 /* Clear all status bits */ |
| 620 | lis r0,CFG_INIT_DBCR@h |
| 621 | ori r0,r0,CFG_INIT_DBCR@l |
| 622 | mtspr dbcr0,r0 |
| 623 | isync |
| 624 | #endif |
| 625 | |
| 626 | /*----------------------------------------------------------------*/ |
| 627 | /* Setup the internal SRAM */ |
| 628 | /*----------------------------------------------------------------*/ |
| 629 | li r0,0 |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 630 | |
| 631 | #ifdef CFG_INIT_RAM_DCACHE |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 632 | /* Clear Dcache to use as RAM */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 633 | addis r3,r0,CFG_INIT_RAM_ADDR@h |
| 634 | ori r3,r3,CFG_INIT_RAM_ADDR@l |
| 635 | addis r4,r0,CFG_INIT_RAM_END@h |
| 636 | ori r4,r4,CFG_INIT_RAM_END@l |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 637 | rlwinm. r5,r4,0,27,31 |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 638 | rlwinm r5,r4,27,5,31 |
| 639 | beq ..d_ran |
| 640 | addi r5,r5,0x0001 |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 641 | ..d_ran: |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 642 | mtctr r5 |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 643 | ..d_ag: |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 644 | dcbz r0,r3 |
| 645 | addi r3,r3,32 |
| 646 | bdnz ..d_ag |
Stefan Roese | a86bde3 | 2008-01-09 10:23:16 +0100 | [diff] [blame] | 647 | |
| 648 | /* |
| 649 | * Lock the init-ram/stack in d-cache, so that other regions |
| 650 | * may use d-cache as well |
| 651 | * Note, that this current implementation locks exactly 4k |
| 652 | * of d-cache, so please make sure that you don't define a |
| 653 | * bigger init-ram area. Take a look at the lwmon5 440EPx |
| 654 | * implementation as a reference. |
| 655 | */ |
| 656 | msync |
| 657 | isync |
| 658 | /* 8. set TFLOOR/NFLOOR to 8 (-> 8*16*32 bytes locked -> 4k) */ |
| 659 | lis r1,0x0201 |
| 660 | ori r1,r1,0xf808 |
| 661 | mtspr dvlim,r1 |
| 662 | lis r1,0x0808 |
| 663 | ori r1,r1,0x0808 |
| 664 | mtspr dnv0,r1 |
| 665 | mtspr dnv1,r1 |
| 666 | mtspr dnv2,r1 |
| 667 | mtspr dnv3,r1 |
| 668 | mtspr dtv0,r1 |
| 669 | mtspr dtv1,r1 |
| 670 | mtspr dtv2,r1 |
| 671 | mtspr dtv3,r1 |
| 672 | msync |
| 673 | isync |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 674 | #endif /* CFG_INIT_RAM_DCACHE */ |
| 675 | |
| 676 | /* 440EP & 440GR are only 440er PPC's without internal SRAM */ |
| 677 | #if !defined(CONFIG_440EP) && !defined(CONFIG_440GR) |
| 678 | /* not all PPC's have internal SRAM usable as L2-cache */ |
Stefan Roese | cc019d1 | 2008-03-11 15:05:50 +0100 | [diff] [blame] | 679 | #if defined(CONFIG_440GX) || \ |
| 680 | defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \ |
| 681 | defined(CONFIG_460EX) || defined(CONFIG_460GT) |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 682 | mtdcr l2_cache_cfg,r0 /* Ensure L2 Cache is off */ |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 683 | #endif |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 684 | |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 685 | lis r2,0x7fff |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 686 | ori r2,r2,0xffff |
| 687 | mfdcr r1,isram0_dpc |
| 688 | and r1,r1,r2 /* Disable parity check */ |
| 689 | mtdcr isram0_dpc,r1 |
| 690 | mfdcr r1,isram0_pmeg |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 691 | and r1,r1,r2 /* Disable pwr mgmt */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 692 | mtdcr isram0_pmeg,r1 |
| 693 | |
| 694 | lis r1,0x8000 /* BAS = 8000_0000 */ |
Stefan Roese | 9964474 | 2005-11-29 18:18:21 +0100 | [diff] [blame] | 695 | #if defined(CONFIG_440GX) || defined(CONFIG_440SP) |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 696 | ori r1,r1,0x0980 /* first 64k */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 697 | mtdcr isram0_sb0cr,r1 |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 698 | lis r1,0x8001 |
| 699 | ori r1,r1,0x0980 /* second 64k */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 700 | mtdcr isram0_sb1cr,r1 |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 701 | lis r1, 0x8002 |
| 702 | ori r1,r1, 0x0980 /* third 64k */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 703 | mtdcr isram0_sb2cr,r1 |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 704 | lis r1, 0x8003 |
| 705 | ori r1,r1, 0x0980 /* fourth 64k */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 706 | mtdcr isram0_sb3cr,r1 |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 707 | #elif defined(CONFIG_440SPE) |
| 708 | lis r1,0x0000 /* BAS = 0000_0000 */ |
| 709 | ori r1,r1,0x0984 /* first 64k */ |
| 710 | mtdcr isram0_sb0cr,r1 |
| 711 | lis r1,0x0001 |
| 712 | ori r1,r1,0x0984 /* second 64k */ |
| 713 | mtdcr isram0_sb1cr,r1 |
| 714 | lis r1, 0x0002 |
| 715 | ori r1,r1, 0x0984 /* third 64k */ |
| 716 | mtdcr isram0_sb2cr,r1 |
| 717 | lis r1, 0x0003 |
| 718 | ori r1,r1, 0x0984 /* fourth 64k */ |
| 719 | mtdcr isram0_sb3cr,r1 |
Stefan Roese | cc019d1 | 2008-03-11 15:05:50 +0100 | [diff] [blame] | 720 | #elif defined(CONFIG_460EX) || defined(CONFIG_460GT) |
| 721 | lis r1,0x4000 /* BAS = 8000_0000 */ |
| 722 | ori r1,r1,0x4580 /* 16k */ |
| 723 | mtdcr isram0_sb0cr,r1 |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 724 | #elif defined(CONFIG_440GP) |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 725 | ori r1,r1,0x0380 /* 8k rw */ |
| 726 | mtdcr isram0_sb0cr,r1 |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 727 | mtdcr isram0_sb1cr,r0 /* Disable bank 1 */ |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 728 | #endif |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 729 | #endif /* #if !defined(CONFIG_440EP) && !defined(CONFIG_440GR) */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 730 | |
| 731 | /*----------------------------------------------------------------*/ |
| 732 | /* Setup the stack in internal SRAM */ |
| 733 | /*----------------------------------------------------------------*/ |
| 734 | lis r1,CFG_INIT_RAM_ADDR@h |
| 735 | ori r1,r1,CFG_INIT_SP_OFFSET@l |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 736 | li r0,0 |
| 737 | stwu r0,-4(r1) |
| 738 | stwu r0,-4(r1) /* Terminate call chain */ |
| 739 | |
| 740 | stwu r1,-8(r1) /* Save back chain and move SP */ |
| 741 | lis r0,RESET_VECTOR@h /* Address of reset vector */ |
| 742 | ori r0,r0, RESET_VECTOR@l |
| 743 | stwu r1,-8(r1) /* Save back chain and move SP */ |
| 744 | stw r0,+12(r1) /* Save return addr (underflow vect) */ |
| 745 | |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 746 | #ifdef CONFIG_NAND_SPL |
Stefan Roese | 7d72e02 | 2008-06-02 14:35:44 +0200 | [diff] [blame^] | 747 | bl nand_boot_common /* will not return */ |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 748 | #else |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 749 | GET_GOT |
Stefan Roese | c443fe9 | 2005-11-22 13:20:42 +0100 | [diff] [blame] | 750 | |
| 751 | bl cpu_init_f /* run low-level CPU init code (from Flash) */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 752 | bl board_init_f |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 753 | #endif |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 754 | |
| 755 | #endif /* CONFIG_440 */ |
| 756 | |
| 757 | /*****************************************************************************/ |
| 758 | #ifdef CONFIG_IOP480 |
| 759 | /*----------------------------------------------------------------------- */ |
| 760 | /* Set up some machine state registers. */ |
| 761 | /*----------------------------------------------------------------------- */ |
| 762 | addi r0,r0,0x0000 /* initialize r0 to zero */ |
| 763 | mtspr esr,r0 /* clear Exception Syndrome Reg */ |
| 764 | mttcr r0 /* timer control register */ |
| 765 | mtexier r0 /* disable all interrupts */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 766 | addis r4,r0,0xFFFF /* set r4 to 0xFFFFFFFF (status in the */ |
| 767 | ori r4,r4,0xFFFF /* dbsr is cleared by setting bits to 1) */ |
| 768 | mtdbsr r4 /* clear/reset the dbsr */ |
| 769 | mtexisr r4 /* clear all pending interrupts */ |
| 770 | addis r4,r0,0x8000 |
| 771 | mtexier r4 /* enable critical exceptions */ |
| 772 | addis r4,r0,0x0000 /* assume 403GCX - enable core clk */ |
| 773 | ori r4,r4,0x4020 /* dbling (no harm done on GA and GC */ |
| 774 | mtiocr r4 /* since bit not used) & DRC to latch */ |
| 775 | /* data bus on rising edge of CAS */ |
| 776 | /*----------------------------------------------------------------------- */ |
| 777 | /* Clear XER. */ |
| 778 | /*----------------------------------------------------------------------- */ |
| 779 | mtxer r0 |
| 780 | /*----------------------------------------------------------------------- */ |
| 781 | /* Invalidate i-cache and d-cache TAG arrays. */ |
| 782 | /*----------------------------------------------------------------------- */ |
| 783 | addi r3,0,1024 /* 1/4 of I-cache size, half of D-cache */ |
| 784 | addi r4,0,1024 /* 1/4 of I-cache */ |
| 785 | ..cloop: |
| 786 | iccci 0,r3 |
| 787 | iccci r4,r3 |
| 788 | dccci 0,r3 |
| 789 | addic. r3,r3,-16 /* move back one cache line */ |
| 790 | bne ..cloop /* loop back to do rest until r3 = 0 */ |
| 791 | |
| 792 | /* */ |
| 793 | /* initialize IOP480 so it can read 1 MB code area for SRAM spaces */ |
| 794 | /* this requires enabling MA[17..0], by default only MA[12..0] are enabled. */ |
| 795 | /* */ |
| 796 | |
| 797 | /* first copy IOP480 register base address into r3 */ |
| 798 | addis r3,0,0x5000 /* IOP480 register base address hi */ |
| 799 | /* ori r3,r3,0x0000 / IOP480 register base address lo */ |
| 800 | |
| 801 | #ifdef CONFIG_ADCIOP |
| 802 | /* use r4 as the working variable */ |
| 803 | /* turn on CS3 (LOCCTL.7) */ |
| 804 | lwz r4,0x84(r3) /* LOCTL is at offset 0x84 */ |
| 805 | andi. r4,r4,0xff7f /* make bit 7 = 0 -- CS3 mode */ |
| 806 | stw r4,0x84(r3) /* LOCTL is at offset 0x84 */ |
| 807 | #endif |
| 808 | |
| 809 | #ifdef CONFIG_DASA_SIM |
| 810 | /* use r4 as the working variable */ |
| 811 | /* turn on MA17 (LOCCTL.7) */ |
| 812 | lwz r4,0x84(r3) /* LOCTL is at offset 0x84 */ |
| 813 | ori r4,r4,0x80 /* make bit 7 = 1 -- MA17 mode */ |
| 814 | stw r4,0x84(r3) /* LOCTL is at offset 0x84 */ |
| 815 | #endif |
| 816 | |
| 817 | /* turn on MA16..13 (LCS0BRD.12 = 0) */ |
| 818 | lwz r4,0x100(r3) /* LCS0BRD is at offset 0x100 */ |
| 819 | andi. r4,r4,0xefff /* make bit 12 = 0 */ |
| 820 | stw r4,0x100(r3) /* LCS0BRD is at offset 0x100 */ |
| 821 | |
| 822 | /* make sure above stores all comlete before going on */ |
| 823 | sync |
| 824 | |
| 825 | /* last thing, set local init status done bit (DEVINIT.31) */ |
| 826 | lwz r4,0x80(r3) /* DEVINIT is at offset 0x80 */ |
| 827 | oris r4,r4,0x8000 /* make bit 31 = 1 */ |
| 828 | stw r4,0x80(r3) /* DEVINIT is at offset 0x80 */ |
| 829 | |
| 830 | /* clear all pending interrupts and disable all interrupts */ |
| 831 | li r4,-1 /* set p1 to 0xffffffff */ |
| 832 | stw r4,0x1b0(r3) /* clear all pending interrupts */ |
| 833 | stw r4,0x1b8(r3) /* clear all pending interrupts */ |
| 834 | li r4,0 /* set r4 to 0 */ |
| 835 | stw r4,0x1b4(r3) /* disable all interrupts */ |
| 836 | stw r4,0x1bc(r3) /* disable all interrupts */ |
| 837 | |
| 838 | /* make sure above stores all comlete before going on */ |
| 839 | sync |
| 840 | |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 841 | /* Set-up icache cacheability. */ |
| 842 | lis r1, CFG_ICACHE_SACR_VALUE@h |
| 843 | ori r1, r1, CFG_ICACHE_SACR_VALUE@l |
| 844 | mticcr r1 |
| 845 | isync |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 846 | |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 847 | /* Set-up dcache cacheability. */ |
| 848 | lis r1, CFG_DCACHE_SACR_VALUE@h |
| 849 | ori r1, r1, CFG_DCACHE_SACR_VALUE@l |
| 850 | mtdccr r1 |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 851 | |
| 852 | addis r1,r0,CFG_INIT_RAM_ADDR@h |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 853 | ori r1,r1,CFG_INIT_SP_OFFSET /* set up the stack to SDRAM */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 854 | li r0, 0 /* Make room for stack frame header and */ |
| 855 | stwu r0, -4(r1) /* clear final stack frame so that */ |
| 856 | stwu r0, -4(r1) /* stack backtraces terminate cleanly */ |
| 857 | |
| 858 | GET_GOT /* initialize GOT access */ |
| 859 | |
| 860 | bl board_init_f /* run first part of init code (from Flash) */ |
| 861 | |
| 862 | #endif /* CONFIG_IOP480 */ |
| 863 | |
| 864 | /*****************************************************************************/ |
Stefan Roese | 17ffbc8 | 2007-03-21 13:38:59 +0100 | [diff] [blame] | 865 | #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \ |
| 866 | defined(CONFIG_405EP) || defined(CONFIG_405EZ) || \ |
Stefan Roese | 153b3e2 | 2007-10-05 17:10:59 +0200 | [diff] [blame] | 867 | defined(CONFIG_405EX) || defined(CONFIG_405) |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 868 | /*----------------------------------------------------------------------- */ |
| 869 | /* Clear and set up some registers. */ |
| 870 | /*----------------------------------------------------------------------- */ |
| 871 | addi r4,r0,0x0000 |
Stefan Roese | 153b3e2 | 2007-10-05 17:10:59 +0200 | [diff] [blame] | 872 | #if !defined(CONFIG_405EX) |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 873 | mtspr sgr,r4 |
Stefan Roese | 153b3e2 | 2007-10-05 17:10:59 +0200 | [diff] [blame] | 874 | #else |
| 875 | /* |
| 876 | * On 405EX, completely clearing the SGR leads to PPC hangup |
| 877 | * upon PCIe configuration access. The PCIe memory regions |
| 878 | * need to be guarded! |
| 879 | */ |
| 880 | lis r3,0x0000 |
| 881 | ori r3,r3,0x7FFC |
| 882 | mtspr sgr,r3 |
| 883 | #endif |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 884 | mtspr dcwr,r4 |
| 885 | mtesr r4 /* clear Exception Syndrome Reg */ |
| 886 | mttcr r4 /* clear Timer Control Reg */ |
| 887 | mtxer r4 /* clear Fixed-Point Exception Reg */ |
| 888 | mtevpr r4 /* clear Exception Vector Prefix Reg */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 889 | addi r4,r0,(0xFFFF-0x10000) /* set r4 to 0xFFFFFFFF (status in the */ |
| 890 | /* dbsr is cleared by setting bits to 1) */ |
| 891 | mtdbsr r4 /* clear/reset the dbsr */ |
| 892 | |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 893 | /* Invalidate the i- and d-caches. */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 894 | bl invalidate_icache |
| 895 | bl invalidate_dcache |
| 896 | |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 897 | /* Set-up icache cacheability. */ |
| 898 | lis r4, CFG_ICACHE_SACR_VALUE@h |
| 899 | ori r4, r4, CFG_ICACHE_SACR_VALUE@l |
| 900 | mticcr r4 |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 901 | isync |
| 902 | |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 903 | /* Set-up dcache cacheability. */ |
| 904 | lis r4, CFG_DCACHE_SACR_VALUE@h |
| 905 | ori r4, r4, CFG_DCACHE_SACR_VALUE@l |
| 906 | mtdccr r4 |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 907 | |
Stefan Roese | 7d72e02 | 2008-06-02 14:35:44 +0200 | [diff] [blame^] | 908 | #if !(defined(CFG_EBC_PB0AP) && defined(CFG_EBC_PB0CR)) |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 909 | /*----------------------------------------------------------------------- */ |
| 910 | /* Tune the speed and size for flash CS0 */ |
| 911 | /*----------------------------------------------------------------------- */ |
| 912 | bl ext_bus_cntlr_init |
| 913 | #endif |
Stefan Roese | 7d72e02 | 2008-06-02 14:35:44 +0200 | [diff] [blame^] | 914 | |
Stefan Roese | 153b3e2 | 2007-10-05 17:10:59 +0200 | [diff] [blame] | 915 | #if !(defined(CFG_INIT_DCACHE_CS) || defined(CFG_TEMP_STACK_OCM)) |
| 916 | /* |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 917 | * For boards that don't have OCM and can't use the data cache |
| 918 | * for their primordial stack, setup stack here directly after the |
| 919 | * SDRAM is initialized in ext_bus_cntlr_init. |
Stefan Roese | 153b3e2 | 2007-10-05 17:10:59 +0200 | [diff] [blame] | 920 | */ |
| 921 | lis r1, CFG_INIT_RAM_ADDR@h |
| 922 | ori r1,r1,CFG_INIT_SP_OFFSET /* set up the stack in SDRAM */ |
| 923 | |
| 924 | li r0, 0 /* Make room for stack frame header and */ |
| 925 | stwu r0, -4(r1) /* clear final stack frame so that */ |
| 926 | stwu r0, -4(r1) /* stack backtraces terminate cleanly */ |
| 927 | /* |
| 928 | * Set up a dummy frame to store reset vector as return address. |
| 929 | * this causes stack underflow to reset board. |
| 930 | */ |
| 931 | stwu r1, -8(r1) /* Save back chain and move SP */ |
| 932 | lis r0, RESET_VECTOR@h /* Address of reset vector */ |
| 933 | ori r0, r0, RESET_VECTOR@l |
| 934 | stwu r1, -8(r1) /* Save back chain and move SP */ |
| 935 | stw r0, +12(r1) /* Save return addr (underflow vect) */ |
| 936 | #endif /* !(CFG_INIT_DCACHE_CS || !CFG_TEM_STACK_OCM) */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 937 | |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 938 | #if defined(CONFIG_405EP) |
| 939 | /*----------------------------------------------------------------------- */ |
| 940 | /* DMA Status, clear to come up clean */ |
| 941 | /*----------------------------------------------------------------------- */ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 942 | addis r3,r0, 0xFFFF /* Clear all existing DMA status */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 943 | ori r3,r3, 0xFFFF |
| 944 | mtdcr dmasr, r3 |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 945 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 946 | bl ppc405ep_init /* do ppc405ep specific init */ |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 947 | #endif /* CONFIG_405EP */ |
| 948 | |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 949 | #if defined(CFG_OCM_DATA_ADDR) && defined(CFG_OCM_DATA_SIZE) |
Stefan Roese | 17ffbc8 | 2007-03-21 13:38:59 +0100 | [diff] [blame] | 950 | #if defined(CONFIG_405EZ) |
| 951 | /******************************************************************** |
| 952 | * Setup OCM - On Chip Memory - PPC405EZ uses OCM Controller V2 |
| 953 | *******************************************************************/ |
| 954 | /* |
| 955 | * We can map the OCM on the PLB3, so map it at |
| 956 | * CFG_OCM_DATA_ADDR + 0x8000 |
| 957 | */ |
| 958 | lis r3,CFG_OCM_DATA_ADDR@h /* OCM location */ |
| 959 | ori r3,r3,CFG_OCM_DATA_ADDR@l |
Stefan Roese | 80d99a4 | 2007-06-19 16:42:31 +0200 | [diff] [blame] | 960 | ori r3,r3,0x0270 /* 16K for Bank 1, R/W/Enable */ |
Stefan Roese | 17ffbc8 | 2007-03-21 13:38:59 +0100 | [diff] [blame] | 961 | mtdcr ocmplb3cr1,r3 /* Set PLB Access */ |
| 962 | ori r3,r3,0x4000 /* Add 0x4000 for bank 2 */ |
| 963 | mtdcr ocmplb3cr2,r3 /* Set PLB Access */ |
| 964 | isync |
| 965 | |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 966 | lis r3,CFG_OCM_DATA_ADDR@h /* OCM location */ |
Stefan Roese | 17ffbc8 | 2007-03-21 13:38:59 +0100 | [diff] [blame] | 967 | ori r3,r3,CFG_OCM_DATA_ADDR@l |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 968 | ori r3,r3,0x0270 /* 16K for Bank 1, R/W/Enable */ |
| 969 | mtdcr ocmdscr1, r3 /* Set Data Side */ |
| 970 | mtdcr ocmiscr1, r3 /* Set Instruction Side */ |
Stefan Roese | 17ffbc8 | 2007-03-21 13:38:59 +0100 | [diff] [blame] | 971 | ori r3,r3,0x4000 /* Add 0x4000 for bank 2 */ |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 972 | mtdcr ocmdscr2, r3 /* Set Data Side */ |
| 973 | mtdcr ocmiscr2, r3 /* Set Instruction Side */ |
| 974 | addis r3,0,0x0800 /* OCM Data Parity Disable - 1 Wait State */ |
Stefan Roese | d85f5d7 | 2007-05-24 09:49:00 +0200 | [diff] [blame] | 975 | mtdcr ocmdsisdpc,r3 |
Stefan Roese | 17ffbc8 | 2007-03-21 13:38:59 +0100 | [diff] [blame] | 976 | |
| 977 | isync |
Stefan Roese | f6c7b76 | 2007-03-24 15:45:34 +0100 | [diff] [blame] | 978 | #else /* CONFIG_405EZ */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 979 | /******************************************************************** |
| 980 | * Setup OCM - On Chip Memory |
| 981 | *******************************************************************/ |
| 982 | /* Setup OCM */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 983 | lis r0, 0x7FFF |
| 984 | ori r0, r0, 0xFFFF |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 985 | mfdcr r3, ocmiscntl /* get instr-side IRAM config */ |
Stefan Roese | f6c7b76 | 2007-03-24 15:45:34 +0100 | [diff] [blame] | 986 | mfdcr r4, ocmdscntl /* get data-side IRAM config */ |
| 987 | and r3, r3, r0 /* disable data-side IRAM */ |
| 988 | and r4, r4, r0 /* disable data-side IRAM */ |
| 989 | mtdcr ocmiscntl, r3 /* set instr-side IRAM config */ |
| 990 | mtdcr ocmdscntl, r4 /* set data-side IRAM config */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 991 | isync |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 992 | |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 993 | lis r3,CFG_OCM_DATA_ADDR@h /* OCM location */ |
Stefan Roese | f6c7b76 | 2007-03-24 15:45:34 +0100 | [diff] [blame] | 994 | ori r3,r3,CFG_OCM_DATA_ADDR@l |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 995 | mtdcr ocmdsarc, r3 |
| 996 | addis r4, 0, 0xC000 /* OCM data area enabled */ |
| 997 | mtdcr ocmdscntl, r4 |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 998 | isync |
Stefan Roese | 17ffbc8 | 2007-03-21 13:38:59 +0100 | [diff] [blame] | 999 | #endif /* CONFIG_405EZ */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1000 | #endif |
| 1001 | |
| 1002 | /*----------------------------------------------------------------------- */ |
| 1003 | /* Setup temporary stack in DCACHE or OCM if needed for SDRAM SPD. */ |
| 1004 | /*----------------------------------------------------------------------- */ |
| 1005 | #ifdef CFG_INIT_DCACHE_CS |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 1006 | li r4, PBxAP |
| 1007 | mtdcr ebccfga, r4 |
| 1008 | lis r4, CFG_INIT_DCACHE_PBxAR@h |
| 1009 | ori r4, r4, CFG_INIT_DCACHE_PBxAR@l |
| 1010 | mtdcr ebccfgd, r4 |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1011 | |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 1012 | addi r4, 0, PBxCR |
| 1013 | mtdcr ebccfga, r4 |
| 1014 | lis r4, CFG_INIT_DCACHE_PBxCR@h |
| 1015 | ori r4, r4, CFG_INIT_DCACHE_PBxCR@l |
| 1016 | mtdcr ebccfgd, r4 |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1017 | |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 1018 | /* |
| 1019 | * Enable the data cache for the 128MB storage access control region |
| 1020 | * at CFG_INIT_RAM_ADDR. |
| 1021 | */ |
| 1022 | mfdccr r4 |
| 1023 | oris r4, r4, PPC_128MB_SACR_VALUE(CFG_INIT_RAM_ADDR)@h |
| 1024 | ori r4, r4, PPC_128MB_SACR_VALUE(CFG_INIT_RAM_ADDR)@l |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1025 | mtdccr r4 |
| 1026 | |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 1027 | /* |
| 1028 | * Preallocate data cache lines to be used to avoid a subsequent |
| 1029 | * cache miss and an ensuing machine check exception when exceptions |
| 1030 | * are enabled. |
| 1031 | */ |
| 1032 | li r0, 0 |
| 1033 | |
| 1034 | lis r3, CFG_INIT_RAM_ADDR@h |
| 1035 | ori r3, r3, CFG_INIT_RAM_ADDR@l |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1036 | |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 1037 | lis r4, CFG_INIT_RAM_END@h |
| 1038 | ori r4, r4, CFG_INIT_RAM_END@l |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1039 | |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 1040 | /* |
| 1041 | * Convert the size, in bytes, to the number of cache lines/blocks |
| 1042 | * to preallocate. |
| 1043 | */ |
| 1044 | clrlwi. r5, r4, (32 - L1_CACHE_SHIFT) |
| 1045 | srwi r5, r4, L1_CACHE_SHIFT |
| 1046 | beq ..load_counter |
| 1047 | addi r5, r5, 0x0001 |
| 1048 | ..load_counter: |
| 1049 | mtctr r5 |
| 1050 | |
| 1051 | /* Preallocate the computed number of cache blocks. */ |
| 1052 | ..alloc_dcache_block: |
| 1053 | dcba r0, r3 |
| 1054 | addi r3, r3, L1_CACHE_BYTES |
| 1055 | bdnz ..alloc_dcache_block |
| 1056 | sync |
| 1057 | |
| 1058 | /* |
| 1059 | * Load the initial stack pointer and data area and convert the size, |
| 1060 | * in bytes, to the number of words to initialize to a known value. |
| 1061 | */ |
| 1062 | lis r1, CFG_INIT_RAM_ADDR@h |
| 1063 | ori r1, r1, CFG_INIT_SP_OFFSET@l |
| 1064 | |
| 1065 | lis r4, (CFG_INIT_RAM_END >> 2)@h |
| 1066 | ori r4, r4, (CFG_INIT_RAM_END >> 2)@l |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1067 | mtctr r4 |
| 1068 | |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 1069 | lis r2, CFG_INIT_RAM_ADDR@h |
| 1070 | ori r2, r2, CFG_INIT_RAM_END@l |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1071 | |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 1072 | lis r4, CFG_INIT_RAM_PATTERN@h |
| 1073 | ori r4, r4, CFG_INIT_RAM_PATTERN@l |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1074 | |
| 1075 | ..stackloop: |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 1076 | stwu r4, -4(r2) |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1077 | bdnz ..stackloop |
| 1078 | |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 1079 | /* |
| 1080 | * Make room for stack frame header and clear final stack frame so |
| 1081 | * that stack backtraces terminate cleanly. |
| 1082 | */ |
| 1083 | stwu r0, -4(r1) |
| 1084 | stwu r0, -4(r1) |
| 1085 | |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1086 | /* |
| 1087 | * Set up a dummy frame to store reset vector as return address. |
| 1088 | * this causes stack underflow to reset board. |
| 1089 | */ |
| 1090 | stwu r1, -8(r1) /* Save back chain and move SP */ |
| 1091 | addis r0, 0, RESET_VECTOR@h /* Address of reset vector */ |
| 1092 | ori r0, r0, RESET_VECTOR@l |
| 1093 | stwu r1, -8(r1) /* Save back chain and move SP */ |
| 1094 | stw r0, +12(r1) /* Save return addr (underflow vect) */ |
| 1095 | |
| 1096 | #elif defined(CFG_TEMP_STACK_OCM) && \ |
| 1097 | (defined(CFG_OCM_DATA_ADDR) && defined(CFG_OCM_DATA_SIZE)) |
| 1098 | /* |
| 1099 | * Stack in OCM. |
| 1100 | */ |
| 1101 | |
| 1102 | /* Set up Stack at top of OCM */ |
| 1103 | lis r1, (CFG_INIT_RAM_ADDR + CFG_INIT_SP_OFFSET)@h |
| 1104 | ori r1, r1, (CFG_INIT_RAM_ADDR + CFG_INIT_SP_OFFSET)@l |
| 1105 | |
| 1106 | /* Set up a zeroized stack frame so that backtrace works right */ |
| 1107 | li r0, 0 |
| 1108 | stwu r0, -4(r1) |
| 1109 | stwu r0, -4(r1) |
| 1110 | |
| 1111 | /* |
| 1112 | * Set up a dummy frame to store reset vector as return address. |
| 1113 | * this causes stack underflow to reset board. |
| 1114 | */ |
| 1115 | stwu r1, -8(r1) /* Save back chain and move SP */ |
| 1116 | lis r0, RESET_VECTOR@h /* Address of reset vector */ |
| 1117 | ori r0, r0, RESET_VECTOR@l |
| 1118 | stwu r1, -8(r1) /* Save back chain and move SP */ |
| 1119 | stw r0, +12(r1) /* Save return addr (underflow vect) */ |
| 1120 | #endif /* CFG_INIT_DCACHE_CS */ |
| 1121 | |
| 1122 | /*----------------------------------------------------------------------- */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1123 | /* Initialize SDRAM Controller */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1124 | /*----------------------------------------------------------------------- */ |
| 1125 | bl sdram_init |
| 1126 | |
Stefan Roese | 23d8d34 | 2007-06-06 11:42:13 +0200 | [diff] [blame] | 1127 | #ifdef CONFIG_NAND_SPL |
Stefan Roese | 7d72e02 | 2008-06-02 14:35:44 +0200 | [diff] [blame^] | 1128 | bl nand_boot_common /* will not return */ |
Stefan Roese | 23d8d34 | 2007-06-06 11:42:13 +0200 | [diff] [blame] | 1129 | #else |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1130 | GET_GOT /* initialize GOT access */ |
| 1131 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1132 | bl cpu_init_f /* run low-level CPU init code (from Flash) */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1133 | |
| 1134 | /* NEVER RETURNS! */ |
| 1135 | bl board_init_f /* run first part of init code (from Flash) */ |
Stefan Roese | 23d8d34 | 2007-06-06 11:42:13 +0200 | [diff] [blame] | 1136 | #endif /* CONFIG_NAND_SPL */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1137 | |
wdenk | 232fe0b | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 1138 | #endif /* CONFIG_405GP || CONFIG_405CR || CONFIG_405 || CONFIG_405EP */ |
| 1139 | /*----------------------------------------------------------------------- */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1140 | |
| 1141 | |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 1142 | #ifndef CONFIG_NAND_SPL |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1143 | /* |
| 1144 | * This code finishes saving the registers to the exception frame |
| 1145 | * and jumps to the appropriate handler for the exception. |
| 1146 | * Register r21 is pointer into trap frame, r1 has new stack pointer. |
| 1147 | */ |
| 1148 | .globl transfer_to_handler |
| 1149 | transfer_to_handler: |
| 1150 | stw r22,_NIP(r21) |
| 1151 | lis r22,MSR_POW@h |
| 1152 | andc r23,r23,r22 |
| 1153 | stw r23,_MSR(r21) |
| 1154 | SAVE_GPR(7, r21) |
| 1155 | SAVE_4GPRS(8, r21) |
| 1156 | SAVE_8GPRS(12, r21) |
| 1157 | SAVE_8GPRS(24, r21) |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1158 | mflr r23 |
| 1159 | andi. r24,r23,0x3f00 /* get vector offset */ |
| 1160 | stw r24,TRAP(r21) |
| 1161 | li r22,0 |
| 1162 | stw r22,RESULT(r21) |
| 1163 | mtspr SPRG2,r22 /* r1 is now kernel sp */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1164 | lwz r24,0(r23) /* virtual address of handler */ |
| 1165 | lwz r23,4(r23) /* where to go when done */ |
| 1166 | mtspr SRR0,r24 |
| 1167 | mtspr SRR1,r20 |
| 1168 | mtlr r23 |
| 1169 | SYNC |
| 1170 | rfi /* jump to handler, enable MMU */ |
| 1171 | |
| 1172 | int_return: |
| 1173 | mfmsr r28 /* Disable interrupts */ |
| 1174 | li r4,0 |
| 1175 | ori r4,r4,MSR_EE |
| 1176 | andc r28,r28,r4 |
| 1177 | SYNC /* Some chip revs need this... */ |
| 1178 | mtmsr r28 |
| 1179 | SYNC |
| 1180 | lwz r2,_CTR(r1) |
| 1181 | lwz r0,_LINK(r1) |
| 1182 | mtctr r2 |
| 1183 | mtlr r0 |
| 1184 | lwz r2,_XER(r1) |
| 1185 | lwz r0,_CCR(r1) |
| 1186 | mtspr XER,r2 |
| 1187 | mtcrf 0xFF,r0 |
| 1188 | REST_10GPRS(3, r1) |
| 1189 | REST_10GPRS(13, r1) |
| 1190 | REST_8GPRS(23, r1) |
| 1191 | REST_GPR(31, r1) |
| 1192 | lwz r2,_NIP(r1) /* Restore environment */ |
| 1193 | lwz r0,_MSR(r1) |
| 1194 | mtspr SRR0,r2 |
| 1195 | mtspr SRR1,r0 |
| 1196 | lwz r0,GPR0(r1) |
| 1197 | lwz r2,GPR2(r1) |
| 1198 | lwz r1,GPR1(r1) |
| 1199 | SYNC |
| 1200 | rfi |
| 1201 | |
| 1202 | crit_return: |
| 1203 | mfmsr r28 /* Disable interrupts */ |
| 1204 | li r4,0 |
| 1205 | ori r4,r4,MSR_EE |
| 1206 | andc r28,r28,r4 |
| 1207 | SYNC /* Some chip revs need this... */ |
| 1208 | mtmsr r28 |
| 1209 | SYNC |
| 1210 | lwz r2,_CTR(r1) |
| 1211 | lwz r0,_LINK(r1) |
| 1212 | mtctr r2 |
| 1213 | mtlr r0 |
| 1214 | lwz r2,_XER(r1) |
| 1215 | lwz r0,_CCR(r1) |
| 1216 | mtspr XER,r2 |
| 1217 | mtcrf 0xFF,r0 |
| 1218 | REST_10GPRS(3, r1) |
| 1219 | REST_10GPRS(13, r1) |
| 1220 | REST_8GPRS(23, r1) |
| 1221 | REST_GPR(31, r1) |
| 1222 | lwz r2,_NIP(r1) /* Restore environment */ |
| 1223 | lwz r0,_MSR(r1) |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 1224 | mtspr csrr0,r2 |
| 1225 | mtspr csrr1,r0 |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1226 | lwz r0,GPR0(r1) |
| 1227 | lwz r2,GPR2(r1) |
| 1228 | lwz r1,GPR1(r1) |
| 1229 | SYNC |
| 1230 | rfci |
| 1231 | |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 1232 | #ifdef CONFIG_440 |
| 1233 | mck_return: |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 1234 | mfmsr r28 /* Disable interrupts */ |
| 1235 | li r4,0 |
| 1236 | ori r4,r4,MSR_EE |
| 1237 | andc r28,r28,r4 |
| 1238 | SYNC /* Some chip revs need this... */ |
| 1239 | mtmsr r28 |
| 1240 | SYNC |
| 1241 | lwz r2,_CTR(r1) |
| 1242 | lwz r0,_LINK(r1) |
| 1243 | mtctr r2 |
| 1244 | mtlr r0 |
| 1245 | lwz r2,_XER(r1) |
| 1246 | lwz r0,_CCR(r1) |
| 1247 | mtspr XER,r2 |
| 1248 | mtcrf 0xFF,r0 |
| 1249 | REST_10GPRS(3, r1) |
| 1250 | REST_10GPRS(13, r1) |
| 1251 | REST_8GPRS(23, r1) |
| 1252 | REST_GPR(31, r1) |
| 1253 | lwz r2,_NIP(r1) /* Restore environment */ |
| 1254 | lwz r0,_MSR(r1) |
| 1255 | mtspr mcsrr0,r2 |
| 1256 | mtspr mcsrr1,r0 |
| 1257 | lwz r0,GPR0(r1) |
| 1258 | lwz r2,GPR2(r1) |
| 1259 | lwz r1,GPR1(r1) |
| 1260 | SYNC |
| 1261 | rfmci |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 1262 | #endif /* CONFIG_440 */ |
| 1263 | |
| 1264 | |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1265 | .globl get_pvr |
| 1266 | get_pvr: |
| 1267 | mfspr r3, PVR |
| 1268 | blr |
| 1269 | |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1270 | /*------------------------------------------------------------------------------- */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1271 | /* Function: out16 */ |
| 1272 | /* Description: Output 16 bits */ |
| 1273 | /*------------------------------------------------------------------------------- */ |
| 1274 | .globl out16 |
| 1275 | out16: |
| 1276 | sth r4,0x0000(r3) |
| 1277 | blr |
| 1278 | |
| 1279 | /*------------------------------------------------------------------------------- */ |
| 1280 | /* Function: out16r */ |
| 1281 | /* Description: Byte reverse and output 16 bits */ |
| 1282 | /*------------------------------------------------------------------------------- */ |
| 1283 | .globl out16r |
| 1284 | out16r: |
| 1285 | sthbrx r4,r0,r3 |
| 1286 | blr |
| 1287 | |
| 1288 | /*------------------------------------------------------------------------------- */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1289 | /* Function: out32r */ |
| 1290 | /* Description: Byte reverse and output 32 bits */ |
| 1291 | /*------------------------------------------------------------------------------- */ |
| 1292 | .globl out32r |
| 1293 | out32r: |
| 1294 | stwbrx r4,r0,r3 |
| 1295 | blr |
| 1296 | |
| 1297 | /*------------------------------------------------------------------------------- */ |
| 1298 | /* Function: in16 */ |
| 1299 | /* Description: Input 16 bits */ |
| 1300 | /*------------------------------------------------------------------------------- */ |
| 1301 | .globl in16 |
| 1302 | in16: |
| 1303 | lhz r3,0x0000(r3) |
| 1304 | blr |
| 1305 | |
| 1306 | /*------------------------------------------------------------------------------- */ |
| 1307 | /* Function: in16r */ |
| 1308 | /* Description: Input 16 bits and byte reverse */ |
| 1309 | /*------------------------------------------------------------------------------- */ |
| 1310 | .globl in16r |
| 1311 | in16r: |
| 1312 | lhbrx r3,r0,r3 |
| 1313 | blr |
| 1314 | |
| 1315 | /*------------------------------------------------------------------------------- */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1316 | /* Function: in32r */ |
| 1317 | /* Description: Input 32 bits and byte reverse */ |
| 1318 | /*------------------------------------------------------------------------------- */ |
| 1319 | .globl in32r |
| 1320 | in32r: |
| 1321 | lwbrx r3,r0,r3 |
| 1322 | blr |
| 1323 | |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1324 | /* |
| 1325 | * void relocate_code (addr_sp, gd, addr_moni) |
| 1326 | * |
| 1327 | * This "function" does not return, instead it continues in RAM |
| 1328 | * after relocating the monitor code. |
| 1329 | * |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 1330 | * r3 = Relocated stack pointer |
| 1331 | * r4 = Relocated global data pointer |
| 1332 | * r5 = Relocated text pointer |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1333 | */ |
| 1334 | .globl relocate_code |
| 1335 | relocate_code: |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 1336 | #if defined(CONFIG_4xx_DCACHE) || defined(CFG_INIT_DCACHE_CS) |
Stefan Roese | eff3a0a | 2007-10-31 17:55:58 +0100 | [diff] [blame] | 1337 | /* |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 1338 | * We need to flush the initial global data (gd_t) before the dcache |
| 1339 | * will be invalidated. |
Stefan Roese | eff3a0a | 2007-10-31 17:55:58 +0100 | [diff] [blame] | 1340 | */ |
| 1341 | |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 1342 | /* Save registers */ |
| 1343 | mr r9, r3 |
| 1344 | mr r10, r4 |
| 1345 | mr r11, r5 |
Stefan Roese | eff3a0a | 2007-10-31 17:55:58 +0100 | [diff] [blame] | 1346 | |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 1347 | /* Flush initial global data range */ |
| 1348 | mr r3, r4 |
| 1349 | addi r4, r4, CFG_GBL_DATA_SIZE@l |
Stefan Roese | eff3a0a | 2007-10-31 17:55:58 +0100 | [diff] [blame] | 1350 | bl flush_dcache_range |
| 1351 | |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 1352 | #if defined(CFG_INIT_DCACHE_CS) |
| 1353 | /* |
| 1354 | * Undo the earlier data cache set-up for the primordial stack and |
| 1355 | * data area. First, invalidate the data cache and then disable data |
| 1356 | * cacheability for that area. Finally, restore the EBC values, if |
| 1357 | * any. |
| 1358 | */ |
| 1359 | |
| 1360 | /* Invalidate the primordial stack and data area in cache */ |
| 1361 | lis r3, CFG_INIT_RAM_ADDR@h |
| 1362 | ori r3, r3, CFG_INIT_RAM_ADDR@l |
| 1363 | |
| 1364 | lis r4, CFG_INIT_RAM_END@h |
| 1365 | ori r4, r4, CFG_INIT_RAM_END@l |
| 1366 | add r4, r4, r3 |
| 1367 | |
| 1368 | bl invalidate_dcache_range |
| 1369 | |
| 1370 | /* Disable cacheability for the region */ |
| 1371 | mfdccr r3 |
| 1372 | lis r4, ~PPC_128MB_SACR_VALUE(CFG_INIT_RAM_ADDR)@h |
| 1373 | ori r4, r4, ~PPC_128MB_SACR_VALUE(CFG_INIT_RAM_ADDR)@l |
| 1374 | and r3, r3, r4 |
| 1375 | mtdccr r3 |
| 1376 | |
| 1377 | /* Restore the EBC parameters */ |
| 1378 | li r3, PBxAP |
| 1379 | mtdcr ebccfga, r3 |
| 1380 | lis r3, PBxAP_VAL@h |
| 1381 | ori r3, r3, PBxAP_VAL@l |
| 1382 | mtdcr ebccfgd, r3 |
| 1383 | |
| 1384 | li r3, PBxCR |
| 1385 | mtdcr ebccfga, r3 |
| 1386 | lis r3, PBxCR_VAL@h |
| 1387 | ori r3, r3, PBxCR_VAL@l |
| 1388 | mtdcr ebccfgd, r3 |
| 1389 | #endif /* defined(CFG_INIT_DCACHE_CS) */ |
| 1390 | |
| 1391 | /* Restore registers */ |
| 1392 | mr r3, r9 |
| 1393 | mr r4, r10 |
| 1394 | mr r5, r11 |
| 1395 | #endif /* defined(CONFIG_4xx_DCACHE) || defined(CFG_INIT_DCACHE_CS) */ |
Stefan Roese | a86bde3 | 2008-01-09 10:23:16 +0100 | [diff] [blame] | 1396 | |
| 1397 | #ifdef CFG_INIT_RAM_DCACHE |
| 1398 | /* |
| 1399 | * Unlock the previously locked d-cache |
| 1400 | */ |
| 1401 | msync |
| 1402 | isync |
| 1403 | /* set TFLOOR/NFLOOR to 0 again */ |
| 1404 | lis r6,0x0001 |
| 1405 | ori r6,r6,0xf800 |
| 1406 | mtspr dvlim,r6 |
| 1407 | lis r6,0x0000 |
| 1408 | ori r6,r6,0x0000 |
| 1409 | mtspr dnv0,r6 |
| 1410 | mtspr dnv1,r6 |
| 1411 | mtspr dnv2,r6 |
| 1412 | mtspr dnv3,r6 |
| 1413 | mtspr dtv0,r6 |
| 1414 | mtspr dtv1,r6 |
| 1415 | mtspr dtv2,r6 |
| 1416 | mtspr dtv3,r6 |
| 1417 | msync |
| 1418 | isync |
| 1419 | #endif /* CFG_INIT_RAM_DCACHE */ |
| 1420 | |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 1421 | #if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \ |
| 1422 | defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \ |
Stefan Roese | cc019d1 | 2008-03-11 15:05:50 +0100 | [diff] [blame] | 1423 | defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \ |
| 1424 | defined(CONFIG_460EX) || defined(CONFIG_460GT) |
Stefan Roese | 9eba0c8 | 2006-06-02 16:18:04 +0200 | [diff] [blame] | 1425 | /* |
| 1426 | * On some 440er platforms the cache is enabled in the first TLB (Boot-CS) |
| 1427 | * to speed up the boot process. Now this cache needs to be disabled. |
| 1428 | */ |
| 1429 | iccci 0,0 /* Invalidate inst cache */ |
| 1430 | dccci 0,0 /* Invalidate data cache, now no longer our stack */ |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1431 | sync |
Stefan Roese | 9eba0c8 | 2006-06-02 16:18:04 +0200 | [diff] [blame] | 1432 | isync |
Niklaus Giger | 86cb27b | 2007-11-30 18:35:11 +0100 | [diff] [blame] | 1433 | #ifdef CFG_TLB_FOR_BOOT_FLASH |
| 1434 | addi r1,r0,CFG_TLB_FOR_BOOT_FLASH /* Use defined TLB */ |
| 1435 | #else |
| 1436 | addi r1,r0,0x0000 /* Default TLB entry is #0 */ |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 1437 | #endif /* CFG_TLB_FOR_BOOT_FLASH */ |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1438 | tlbre r0,r1,0x0002 /* Read contents */ |
Stefan Roese | 9964474 | 2005-11-29 18:18:21 +0100 | [diff] [blame] | 1439 | ori r0,r0,0x0c00 /* Or in the inhibit, write through bit */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1440 | tlbwe r0,r1,0x0002 /* Save it out */ |
Stefan Roese | 9eba0c8 | 2006-06-02 16:18:04 +0200 | [diff] [blame] | 1441 | sync |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1442 | isync |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 1443 | #endif /* defined(CONFIG_440EP) || ... || defined(CONFIG_460GT) */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1444 | mr r1, r3 /* Set new stack pointer */ |
| 1445 | mr r9, r4 /* Save copy of Init Data pointer */ |
| 1446 | mr r10, r5 /* Save copy of Destination Address */ |
| 1447 | |
| 1448 | mr r3, r5 /* Destination Address */ |
| 1449 | lis r4, CFG_MONITOR_BASE@h /* Source Address */ |
| 1450 | ori r4, r4, CFG_MONITOR_BASE@l |
wdenk | b9a83a9 | 2003-05-30 12:48:29 +0000 | [diff] [blame] | 1451 | lwz r5, GOT(__init_end) |
| 1452 | sub r5, r5, r4 |
Stefan Roese | eff3a0a | 2007-10-31 17:55:58 +0100 | [diff] [blame] | 1453 | li r6, L1_CACHE_BYTES /* Cache Line Size */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1454 | |
| 1455 | /* |
| 1456 | * Fix GOT pointer: |
| 1457 | * |
| 1458 | * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address |
| 1459 | * |
| 1460 | * Offset: |
| 1461 | */ |
| 1462 | sub r15, r10, r4 |
| 1463 | |
| 1464 | /* First our own GOT */ |
| 1465 | add r14, r14, r15 |
Grant Erickson | b693341 | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 1466 | /* then the one used by the C code */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1467 | add r30, r30, r15 |
| 1468 | |
| 1469 | /* |
| 1470 | * Now relocate code |
| 1471 | */ |
| 1472 | |
| 1473 | cmplw cr1,r3,r4 |
| 1474 | addi r0,r5,3 |
| 1475 | srwi. r0,r0,2 |
| 1476 | beq cr1,4f /* In place copy is not necessary */ |
| 1477 | beq 7f /* Protect against 0 count */ |
| 1478 | mtctr r0 |
| 1479 | bge cr1,2f |
| 1480 | |
| 1481 | la r8,-4(r4) |
| 1482 | la r7,-4(r3) |
| 1483 | 1: lwzu r0,4(r8) |
| 1484 | stwu r0,4(r7) |
| 1485 | bdnz 1b |
| 1486 | b 4f |
| 1487 | |
| 1488 | 2: slwi r0,r0,2 |
| 1489 | add r8,r4,r0 |
| 1490 | add r7,r3,r0 |
| 1491 | 3: lwzu r0,-4(r8) |
| 1492 | stwu r0,-4(r7) |
| 1493 | bdnz 3b |
| 1494 | |
| 1495 | /* |
| 1496 | * Now flush the cache: note that we must start from a cache aligned |
| 1497 | * address. Otherwise we might miss one cache line. |
| 1498 | */ |
| 1499 | 4: cmpwi r6,0 |
| 1500 | add r5,r3,r5 |
| 1501 | beq 7f /* Always flush prefetch queue in any case */ |
| 1502 | subi r0,r6,1 |
| 1503 | andc r3,r3,r0 |
| 1504 | mr r4,r3 |
| 1505 | 5: dcbst 0,r4 |
| 1506 | add r4,r4,r6 |
| 1507 | cmplw r4,r5 |
| 1508 | blt 5b |
| 1509 | sync /* Wait for all dcbst to complete on bus */ |
| 1510 | mr r4,r3 |
| 1511 | 6: icbi 0,r4 |
| 1512 | add r4,r4,r6 |
| 1513 | cmplw r4,r5 |
| 1514 | blt 6b |
| 1515 | 7: sync /* Wait for all icbi to complete on bus */ |
| 1516 | isync |
| 1517 | |
| 1518 | /* |
| 1519 | * We are done. Do not return, instead branch to second part of board |
| 1520 | * initialization, now running from RAM. |
| 1521 | */ |
| 1522 | |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 1523 | addi r0, r10, in_ram - _start + _START_OFFSET |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1524 | mtlr r0 |
| 1525 | blr /* NEVER RETURNS! */ |
| 1526 | |
| 1527 | in_ram: |
| 1528 | |
| 1529 | /* |
| 1530 | * Relocation Function, r14 point to got2+0x8000 |
| 1531 | * |
| 1532 | * Adjust got2 pointers, no need to check for 0, this code |
| 1533 | * already puts a few entries in the table. |
| 1534 | */ |
| 1535 | li r0,__got2_entries@sectoff@l |
| 1536 | la r3,GOT(_GOT2_TABLE_) |
| 1537 | lwz r11,GOT(_GOT2_TABLE_) |
| 1538 | mtctr r0 |
| 1539 | sub r11,r3,r11 |
| 1540 | addi r3,r3,-4 |
| 1541 | 1: lwzu r0,4(r3) |
| 1542 | add r0,r0,r11 |
| 1543 | stw r0,0(r3) |
| 1544 | bdnz 1b |
| 1545 | |
| 1546 | /* |
| 1547 | * Now adjust the fixups and the pointers to the fixups |
| 1548 | * in case we need to move ourselves again. |
| 1549 | */ |
| 1550 | 2: li r0,__fixup_entries@sectoff@l |
| 1551 | lwz r3,GOT(_FIXUP_TABLE_) |
| 1552 | cmpwi r0,0 |
| 1553 | mtctr r0 |
| 1554 | addi r3,r3,-4 |
| 1555 | beq 4f |
| 1556 | 3: lwzu r4,4(r3) |
| 1557 | lwzux r0,r4,r11 |
| 1558 | add r0,r0,r11 |
| 1559 | stw r10,0(r3) |
| 1560 | stw r0,0(r4) |
| 1561 | bdnz 3b |
| 1562 | 4: |
| 1563 | clear_bss: |
| 1564 | /* |
| 1565 | * Now clear BSS segment |
| 1566 | */ |
wdenk | bf2f8c9 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 1567 | lwz r3,GOT(__bss_start) |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1568 | lwz r4,GOT(_end) |
| 1569 | |
| 1570 | cmplw 0, r3, r4 |
Anatolij Gustschin | 720025b | 2007-12-05 17:43:20 +0100 | [diff] [blame] | 1571 | beq 7f |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1572 | |
| 1573 | li r0, 0 |
Anatolij Gustschin | 720025b | 2007-12-05 17:43:20 +0100 | [diff] [blame] | 1574 | |
| 1575 | andi. r5, r4, 3 |
| 1576 | beq 6f |
| 1577 | sub r4, r4, r5 |
| 1578 | mtctr r5 |
| 1579 | mr r5, r4 |
| 1580 | 5: stb r0, 0(r5) |
| 1581 | addi r5, r5, 1 |
| 1582 | bdnz 5b |
| 1583 | 6: |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1584 | stw r0, 0(r3) |
| 1585 | addi r3, r3, 4 |
| 1586 | cmplw 0, r3, r4 |
Anatolij Gustschin | 720025b | 2007-12-05 17:43:20 +0100 | [diff] [blame] | 1587 | bne 6b |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1588 | |
Anatolij Gustschin | 720025b | 2007-12-05 17:43:20 +0100 | [diff] [blame] | 1589 | 7: |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1590 | mr r3, r9 /* Init Data pointer */ |
| 1591 | mr r4, r10 /* Destination Address */ |
| 1592 | bl board_init_r |
| 1593 | |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1594 | /* |
| 1595 | * Copy exception vector code to low memory |
| 1596 | * |
| 1597 | * r3: dest_addr |
| 1598 | * r7: source address, r8: end address, r9: target address |
| 1599 | */ |
| 1600 | .globl trap_init |
| 1601 | trap_init: |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 1602 | lwz r7, GOT(_start_of_vectors) |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1603 | lwz r8, GOT(_end_of_vectors) |
| 1604 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 1605 | li r9, 0x100 /* reset vector always at 0x100 */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1606 | |
| 1607 | cmplw 0, r7, r8 |
| 1608 | bgelr /* return if r7>=r8 - just in case */ |
| 1609 | |
| 1610 | mflr r4 /* save link register */ |
| 1611 | 1: |
| 1612 | lwz r0, 0(r7) |
| 1613 | stw r0, 0(r9) |
| 1614 | addi r7, r7, 4 |
| 1615 | addi r9, r9, 4 |
| 1616 | cmplw 0, r7, r8 |
| 1617 | bne 1b |
| 1618 | |
| 1619 | /* |
| 1620 | * relocate `hdlr' and `int_return' entries |
| 1621 | */ |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 1622 | li r7, .L_MachineCheck - _start + _START_OFFSET |
| 1623 | li r8, Alignment - _start + _START_OFFSET |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1624 | 2: |
| 1625 | bl trap_reloc |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 1626 | addi r7, r7, 0x100 /* next exception vector */ |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1627 | cmplw 0, r7, r8 |
| 1628 | blt 2b |
| 1629 | |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 1630 | li r7, .L_Alignment - _start + _START_OFFSET |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1631 | bl trap_reloc |
| 1632 | |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 1633 | li r7, .L_ProgramCheck - _start + _START_OFFSET |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1634 | bl trap_reloc |
| 1635 | |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 1636 | #ifdef CONFIG_440 |
| 1637 | li r7, .L_FPUnavailable - _start + _START_OFFSET |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 1638 | bl trap_reloc |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1639 | |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 1640 | li r7, .L_Decrementer - _start + _START_OFFSET |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 1641 | bl trap_reloc |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 1642 | |
| 1643 | li r7, .L_APU - _start + _START_OFFSET |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 1644 | bl trap_reloc |
Stefan Roese | 80d99a4 | 2007-06-19 16:42:31 +0200 | [diff] [blame] | 1645 | |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 1646 | li r7, .L_InstructionTLBError - _start + _START_OFFSET |
| 1647 | bl trap_reloc |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 1648 | |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 1649 | li r7, .L_DataTLBError - _start + _START_OFFSET |
| 1650 | bl trap_reloc |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 1651 | #else /* CONFIG_440 */ |
| 1652 | li r7, .L_PIT - _start + _START_OFFSET |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 1653 | bl trap_reloc |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 1654 | |
| 1655 | li r7, .L_InstructionTLBMiss - _start + _START_OFFSET |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 1656 | bl trap_reloc |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 1657 | |
| 1658 | li r7, .L_DataTLBMiss - _start + _START_OFFSET |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 1659 | bl trap_reloc |
Grzegorz Bernacki | 837bc5b | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 1660 | #endif /* CONFIG_440 */ |
| 1661 | |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 1662 | li r7, .L_DebugBreakpoint - _start + _START_OFFSET |
| 1663 | bl trap_reloc |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1664 | |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 1665 | #if !defined(CONFIG_440) |
Stefan Roese | 7b12aa8 | 2006-03-13 09:42:28 +0100 | [diff] [blame] | 1666 | addi r7,r0,0x1000 /* set ME bit (Machine Exceptions) */ |
| 1667 | oris r7,r7,0x0002 /* set CE bit (Critical Exceptions) */ |
| 1668 | mtmsr r7 /* change MSR */ |
| 1669 | #else |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 1670 | bl __440_msr_set |
| 1671 | b __440_msr_continue |
Stefan Roese | 7b12aa8 | 2006-03-13 09:42:28 +0100 | [diff] [blame] | 1672 | |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 1673 | __440_msr_set: |
Stefan Roese | 7b12aa8 | 2006-03-13 09:42:28 +0100 | [diff] [blame] | 1674 | addi r7,r0,0x1000 /* set ME bit (Machine Exceptions) */ |
| 1675 | oris r7,r7,0x0002 /* set CE bit (Critical Exceptions) */ |
| 1676 | mtspr srr1,r7 |
| 1677 | mflr r7 |
| 1678 | mtspr srr0,r7 |
| 1679 | rfi |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 1680 | __440_msr_continue: |
Stefan Roese | 7b12aa8 | 2006-03-13 09:42:28 +0100 | [diff] [blame] | 1681 | #endif |
| 1682 | |
wdenk | 0442ed8 | 2002-11-03 10:24:00 +0000 | [diff] [blame] | 1683 | mtlr r4 /* restore link register */ |
| 1684 | blr |
| 1685 | |
| 1686 | /* |
| 1687 | * Function: relocate entries for one exception vector |
| 1688 | */ |
| 1689 | trap_reloc: |
| 1690 | lwz r0, 0(r7) /* hdlr ... */ |
| 1691 | add r0, r0, r3 /* ... += dest_addr */ |
| 1692 | stw r0, 0(r7) |
| 1693 | |
| 1694 | lwz r0, 4(r7) /* int_return ... */ |
| 1695 | add r0, r0, r3 /* ... += dest_addr */ |
| 1696 | stw r0, 4(r7) |
| 1697 | |
| 1698 | blr |
Stefan Roese | 4274351 | 2007-06-01 15:27:11 +0200 | [diff] [blame] | 1699 | |
| 1700 | #if defined(CONFIG_440) |
| 1701 | /*----------------------------------------------------------------------------+ |
| 1702 | | dcbz_area. |
| 1703 | +----------------------------------------------------------------------------*/ |
| 1704 | function_prolog(dcbz_area) |
| 1705 | rlwinm. r5,r4,0,27,31 |
Wolfgang Denk | 09675ef | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 1706 | rlwinm r5,r4,27,5,31 |
| 1707 | beq ..d_ra2 |
| 1708 | addi r5,r5,0x0001 |
| 1709 | ..d_ra2:mtctr r5 |
| 1710 | ..d_ag2:dcbz r0,r3 |
| 1711 | addi r3,r3,32 |
| 1712 | bdnz ..d_ag2 |
Stefan Roese | 4274351 | 2007-06-01 15:27:11 +0200 | [diff] [blame] | 1713 | sync |
| 1714 | blr |
| 1715 | function_epilog(dcbz_area) |
Stefan Roese | 4274351 | 2007-06-01 15:27:11 +0200 | [diff] [blame] | 1716 | #endif /* CONFIG_440 */ |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 1717 | #endif /* CONFIG_NAND_SPL */ |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1718 | |
Stefan Roese | 4274351 | 2007-06-01 15:27:11 +0200 | [diff] [blame] | 1719 | /*------------------------------------------------------------------------------- */ |
| 1720 | /* Function: in8 */ |
| 1721 | /* Description: Input 8 bits */ |
| 1722 | /*------------------------------------------------------------------------------- */ |
| 1723 | .globl in8 |
| 1724 | in8: |
| 1725 | lbz r3,0x0000(r3) |
| 1726 | blr |
| 1727 | |
| 1728 | /*------------------------------------------------------------------------------- */ |
| 1729 | /* Function: out8 */ |
| 1730 | /* Description: Output 8 bits */ |
| 1731 | /*------------------------------------------------------------------------------- */ |
| 1732 | .globl out8 |
| 1733 | out8: |
| 1734 | stb r4,0x0000(r3) |
| 1735 | blr |
| 1736 | |
| 1737 | /*------------------------------------------------------------------------------- */ |
| 1738 | /* Function: out32 */ |
| 1739 | /* Description: Output 32 bits */ |
| 1740 | /*------------------------------------------------------------------------------- */ |
| 1741 | .globl out32 |
| 1742 | out32: |
| 1743 | stw r4,0x0000(r3) |
| 1744 | blr |
| 1745 | |
| 1746 | /*------------------------------------------------------------------------------- */ |
| 1747 | /* Function: in32 */ |
| 1748 | /* Description: Input 32 bits */ |
| 1749 | /*------------------------------------------------------------------------------- */ |
| 1750 | .globl in32 |
| 1751 | in32: |
| 1752 | lwz 3,0x0000(3) |
| 1753 | blr |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1754 | |
| 1755 | /**************************************************************************/ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1756 | /* PPC405EP specific stuff */ |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1757 | /**************************************************************************/ |
| 1758 | #ifdef CONFIG_405EP |
| 1759 | ppc405ep_init: |
stroese | 5ad6d4d | 2003-12-09 14:54:43 +0000 | [diff] [blame] | 1760 | |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1761 | #ifdef CONFIG_BUBINGA |
stroese | 5ad6d4d | 2003-12-09 14:54:43 +0000 | [diff] [blame] | 1762 | /* |
| 1763 | * Initialize EBC chip selects 1 & 4 and GPIO pins (for alternate |
| 1764 | * function) to support FPGA and NVRAM accesses below. |
| 1765 | */ |
| 1766 | |
| 1767 | lis r3,GPIO0_OSRH@h /* config GPIO output select */ |
| 1768 | ori r3,r3,GPIO0_OSRH@l |
| 1769 | lis r4,CFG_GPIO0_OSRH@h |
| 1770 | ori r4,r4,CFG_GPIO0_OSRH@l |
| 1771 | stw r4,0(r3) |
| 1772 | lis r3,GPIO0_OSRL@h |
| 1773 | ori r3,r3,GPIO0_OSRL@l |
| 1774 | lis r4,CFG_GPIO0_OSRL@h |
| 1775 | ori r4,r4,CFG_GPIO0_OSRL@l |
| 1776 | stw r4,0(r3) |
| 1777 | |
| 1778 | lis r3,GPIO0_ISR1H@h /* config GPIO input select */ |
| 1779 | ori r3,r3,GPIO0_ISR1H@l |
| 1780 | lis r4,CFG_GPIO0_ISR1H@h |
| 1781 | ori r4,r4,CFG_GPIO0_ISR1H@l |
| 1782 | stw r4,0(r3) |
| 1783 | lis r3,GPIO0_ISR1L@h |
| 1784 | ori r3,r3,GPIO0_ISR1L@l |
| 1785 | lis r4,CFG_GPIO0_ISR1L@h |
| 1786 | ori r4,r4,CFG_GPIO0_ISR1L@l |
| 1787 | stw r4,0(r3) |
| 1788 | |
| 1789 | lis r3,GPIO0_TSRH@h /* config GPIO three-state select */ |
| 1790 | ori r3,r3,GPIO0_TSRH@l |
| 1791 | lis r4,CFG_GPIO0_TSRH@h |
| 1792 | ori r4,r4,CFG_GPIO0_TSRH@l |
| 1793 | stw r4,0(r3) |
| 1794 | lis r3,GPIO0_TSRL@h |
| 1795 | ori r3,r3,GPIO0_TSRL@l |
| 1796 | lis r4,CFG_GPIO0_TSRL@h |
| 1797 | ori r4,r4,CFG_GPIO0_TSRL@l |
| 1798 | stw r4,0(r3) |
| 1799 | |
| 1800 | lis r3,GPIO0_TCR@h /* config GPIO driver output enables */ |
| 1801 | ori r3,r3,GPIO0_TCR@l |
| 1802 | lis r4,CFG_GPIO0_TCR@h |
| 1803 | ori r4,r4,CFG_GPIO0_TCR@l |
| 1804 | stw r4,0(r3) |
| 1805 | |
| 1806 | li r3,pb1ap /* program EBC bank 1 for RTC access */ |
| 1807 | mtdcr ebccfga,r3 |
| 1808 | lis r3,CFG_EBC_PB1AP@h |
| 1809 | ori r3,r3,CFG_EBC_PB1AP@l |
| 1810 | mtdcr ebccfgd,r3 |
| 1811 | li r3,pb1cr |
| 1812 | mtdcr ebccfga,r3 |
| 1813 | lis r3,CFG_EBC_PB1CR@h |
| 1814 | ori r3,r3,CFG_EBC_PB1CR@l |
| 1815 | mtdcr ebccfgd,r3 |
| 1816 | |
| 1817 | li r3,pb1ap /* program EBC bank 1 for RTC access */ |
| 1818 | mtdcr ebccfga,r3 |
| 1819 | lis r3,CFG_EBC_PB1AP@h |
| 1820 | ori r3,r3,CFG_EBC_PB1AP@l |
| 1821 | mtdcr ebccfgd,r3 |
| 1822 | li r3,pb1cr |
| 1823 | mtdcr ebccfga,r3 |
| 1824 | lis r3,CFG_EBC_PB1CR@h |
| 1825 | ori r3,r3,CFG_EBC_PB1CR@l |
| 1826 | mtdcr ebccfgd,r3 |
| 1827 | |
| 1828 | li r3,pb4ap /* program EBC bank 4 for FPGA access */ |
| 1829 | mtdcr ebccfga,r3 |
| 1830 | lis r3,CFG_EBC_PB4AP@h |
| 1831 | ori r3,r3,CFG_EBC_PB4AP@l |
| 1832 | mtdcr ebccfgd,r3 |
| 1833 | li r3,pb4cr |
| 1834 | mtdcr ebccfga,r3 |
| 1835 | lis r3,CFG_EBC_PB4CR@h |
| 1836 | ori r3,r3,CFG_EBC_PB4CR@l |
| 1837 | mtdcr ebccfgd,r3 |
| 1838 | #endif |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1839 | |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1840 | /* |
| 1841 | !----------------------------------------------------------------------- |
| 1842 | ! Check to see if chip is in bypass mode. |
| 1843 | ! If so, write stored CPC0_PLLMR0 and CPC0_PLLMR1 values and perform a |
| 1844 | ! CPU reset Otherwise, skip this step and keep going. |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1845 | ! Note: Running BIOS in bypass mode is not supported since PLB speed |
| 1846 | ! will not be fast enough for the SDRAM (min 66MHz) |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1847 | !----------------------------------------------------------------------- |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1848 | */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1849 | mfdcr r5, CPC0_PLLMR1 |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1850 | rlwinm r4,r5,1,0x1 /* get system clock source (SSCS) */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1851 | cmpi cr0,0,r4,0x1 |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1852 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1853 | beq pll_done /* if SSCS =b'1' then PLL has */ |
| 1854 | /* already been set */ |
| 1855 | /* and CPU has been reset */ |
| 1856 | /* so skip to next section */ |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1857 | |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1858 | #ifdef CONFIG_BUBINGA |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1859 | /* |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1860 | !----------------------------------------------------------------------- |
| 1861 | ! Read NVRAM to get value to write in PLLMR. |
| 1862 | ! If value has not been correctly saved, write default value |
| 1863 | ! Default config values (assuming on-board 33MHz SYS_CLK) are above. |
| 1864 | ! See CPU_DEFAULT_200 and CPU_DEFAULT_266 above. |
| 1865 | ! |
| 1866 | ! WARNING: This code assumes the first three words in the nvram_t |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1867 | ! structure in openbios.h. Changing the beginning of |
| 1868 | ! the structure will break this code. |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1869 | ! |
| 1870 | !----------------------------------------------------------------------- |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1871 | */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1872 | addis r3,0,NVRAM_BASE@h |
| 1873 | addi r3,r3,NVRAM_BASE@l |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1874 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1875 | lwz r4, 0(r3) |
| 1876 | addis r5,0,NVRVFY1@h |
| 1877 | addi r5,r5,NVRVFY1@l |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1878 | cmp cr0,0,r4,r5 /* Compare 1st NVRAM Magic number*/ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1879 | bne ..no_pllset |
| 1880 | addi r3,r3,4 |
| 1881 | lwz r4, 0(r3) |
| 1882 | addis r5,0,NVRVFY2@h |
| 1883 | addi r5,r5,NVRVFY2@l |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1884 | cmp cr0,0,r4,r5 /* Compare 2 NVRAM Magic number */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1885 | bne ..no_pllset |
| 1886 | addi r3,r3,8 /* Skip over conf_size */ |
| 1887 | lwz r4, 4(r3) /* Load PLLMR1 value from NVRAM */ |
| 1888 | lwz r3, 0(r3) /* Load PLLMR0 value from NVRAM */ |
| 1889 | rlwinm r5,r4,1,0x1 /* get system clock source (SSCS) */ |
| 1890 | cmpi cr0,0,r5,1 /* See if PLL is locked */ |
| 1891 | beq pll_write |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1892 | ..no_pllset: |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1893 | #endif /* CONFIG_BUBINGA */ |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1894 | |
John Otken | 9aa3677 | 2007-07-26 17:49:11 +0200 | [diff] [blame] | 1895 | #ifdef CONFIG_TAIHU |
| 1896 | mfdcr r4, CPC0_BOOT |
| 1897 | andi. r5, r4, CPC0_BOOT_SEP@l |
| 1898 | bne strap_1 /* serial eeprom present */ |
| 1899 | addis r5,0,CPLD_REG0_ADDR@h |
| 1900 | ori r5,r5,CPLD_REG0_ADDR@l |
| 1901 | andi. r5, r5, 0x10 |
| 1902 | bne _pci_66mhz |
| 1903 | #endif /* CONFIG_TAIHU */ |
| 1904 | |
Stefan Roese | a5d182e | 2007-08-14 14:44:41 +0200 | [diff] [blame] | 1905 | #if defined(CONFIG_ZEUS) |
| 1906 | mfdcr r4, CPC0_BOOT |
| 1907 | andi. r5, r4, CPC0_BOOT_SEP@l |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1908 | bne strap_1 /* serial eeprom present */ |
Stefan Roese | a5d182e | 2007-08-14 14:44:41 +0200 | [diff] [blame] | 1909 | lis r3,0x0000 |
| 1910 | addi r3,r3,0x3030 |
| 1911 | lis r4,0x8042 |
| 1912 | addi r4,r4,0x223e |
| 1913 | b 1f |
| 1914 | strap_1: |
| 1915 | mfdcr r3, CPC0_PLLMR0 |
| 1916 | mfdcr r4, CPC0_PLLMR1 |
| 1917 | b 1f |
| 1918 | #endif |
| 1919 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1920 | addis r3,0,PLLMR0_DEFAULT@h /* PLLMR0 default value */ |
| 1921 | ori r3,r3,PLLMR0_DEFAULT@l /* */ |
| 1922 | addis r4,0,PLLMR1_DEFAULT@h /* PLLMR1 default value */ |
| 1923 | ori r4,r4,PLLMR1_DEFAULT@l /* */ |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1924 | |
John Otken | 9aa3677 | 2007-07-26 17:49:11 +0200 | [diff] [blame] | 1925 | #ifdef CONFIG_TAIHU |
| 1926 | b 1f |
| 1927 | _pci_66mhz: |
| 1928 | addis r3,0,PLLMR0_DEFAULT_PCI66@h |
| 1929 | ori r3,r3,PLLMR0_DEFAULT_PCI66@l |
| 1930 | addis r4,0,PLLMR1_DEFAULT_PCI66@h |
| 1931 | ori r4,r4,PLLMR1_DEFAULT_PCI66@l |
| 1932 | b 1f |
| 1933 | strap_1: |
| 1934 | mfdcr r3, CPC0_PLLMR0 |
| 1935 | mfdcr r4, CPC0_PLLMR1 |
John Otken | 9aa3677 | 2007-07-26 17:49:11 +0200 | [diff] [blame] | 1936 | #endif /* CONFIG_TAIHU */ |
| 1937 | |
Stefan Roese | a5d182e | 2007-08-14 14:44:41 +0200 | [diff] [blame] | 1938 | 1: |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1939 | b pll_write /* Write the CPC0_PLLMR with new value */ |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1940 | |
| 1941 | pll_done: |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1942 | /* |
| 1943 | !----------------------------------------------------------------------- |
| 1944 | ! Clear Soft Reset Register |
| 1945 | ! This is needed to enable PCI if not booting from serial EPROM |
| 1946 | !----------------------------------------------------------------------- |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1947 | */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1948 | addi r3, 0, 0x0 |
| 1949 | mtdcr CPC0_SRR, r3 |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1950 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1951 | addis r3,0,0x0010 |
| 1952 | mtctr r3 |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1953 | pci_wait: |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1954 | bdnz pci_wait |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1955 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1956 | blr /* return to main code */ |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1957 | |
| 1958 | /* |
| 1959 | !----------------------------------------------------------------------------- |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1960 | ! Function: pll_write |
| 1961 | ! Description: Updates the value of the CPC0_PLLMR according to CMOS27E documentation |
| 1962 | ! That is: |
| 1963 | ! 1. Pll is first disabled (de-activated by putting in bypass mode) |
| 1964 | ! 2. PLL is reset |
| 1965 | ! 3. Clock dividers are set while PLL is held in reset and bypassed |
| 1966 | ! 4. PLL Reset is cleared |
| 1967 | ! 5. Wait 100us for PLL to lock |
| 1968 | ! 6. A core reset is performed |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1969 | ! Input: r3 = Value to write to CPC0_PLLMR0 |
| 1970 | ! Input: r4 = Value to write to CPC0_PLLMR1 |
| 1971 | ! Output r3 = none |
| 1972 | !----------------------------------------------------------------------------- |
| 1973 | */ |
| 1974 | pll_write: |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1975 | mfdcr r5, CPC0_UCR |
| 1976 | andis. r5,r5,0xFFFF |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1977 | ori r5,r5,0x0101 /* Stop the UART clocks */ |
| 1978 | mtdcr CPC0_UCR,r5 /* Before changing PLL */ |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1979 | |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1980 | mfdcr r5, CPC0_PLLMR1 |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1981 | rlwinm r5,r5,0,0x7FFFFFFF /* Disable PLL */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1982 | mtdcr CPC0_PLLMR1,r5 |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1983 | oris r5,r5,0x4000 /* Set PLL Reset */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1984 | mtdcr CPC0_PLLMR1,r5 |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1985 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1986 | mtdcr CPC0_PLLMR0,r3 /* Set clock dividers */ |
| 1987 | rlwinm r5,r4,0,0x3FFFFFFF /* Reset & Bypass new PLL dividers */ |
| 1988 | oris r5,r5,0x4000 /* Set PLL Reset */ |
| 1989 | mtdcr CPC0_PLLMR1,r5 /* Set clock dividers */ |
| 1990 | rlwinm r5,r5,0,0xBFFFFFFF /* Clear PLL Reset */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1991 | mtdcr CPC0_PLLMR1,r5 |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1992 | |
| 1993 | /* |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1994 | ! Wait min of 100us for PLL to lock. |
| 1995 | ! See CMOS 27E databook for more info. |
| 1996 | ! At 200MHz, that means waiting 20,000 instructions |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 1997 | */ |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 1998 | addi r3,0,20000 /* 2000 = 0x4e20 */ |
| 1999 | mtctr r3 |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 2000 | pll_wait: |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 2001 | bdnz pll_wait |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 2002 | |
Wolfgang Denk | 8dd4d33 | 2005-08-06 01:42:58 +0200 | [diff] [blame] | 2003 | oris r5,r5,0x8000 /* Enable PLL */ |
| 2004 | mtdcr CPC0_PLLMR1,r5 /* Engage */ |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 2005 | |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 2006 | /* |
| 2007 | * Reset CPU to guarantee timings are OK |
| 2008 | * Not sure if this is needed... |
| 2009 | */ |
| 2010 | addis r3,0,0x1000 |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 2011 | mtspr dbcr0,r3 /* This will cause a CPU core reset, and */ |
| 2012 | /* execution will continue from the poweron */ |
| 2013 | /* vector of 0xfffffffc */ |
stroese | 434979e | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 2014 | #endif /* CONFIG_405EP */ |
Stefan Roese | a8856e3 | 2007-02-20 10:57:08 +0100 | [diff] [blame] | 2015 | |
| 2016 | #if defined(CONFIG_440) |
Stefan Roese | a8856e3 | 2007-02-20 10:57:08 +0100 | [diff] [blame] | 2017 | /*----------------------------------------------------------------------------+ |
| 2018 | | mttlb3. |
| 2019 | +----------------------------------------------------------------------------*/ |
| 2020 | function_prolog(mttlb3) |
| 2021 | TLBWE(4,3,2) |
| 2022 | blr |
| 2023 | function_epilog(mttlb3) |
| 2024 | |
| 2025 | /*----------------------------------------------------------------------------+ |
| 2026 | | mftlb3. |
| 2027 | +----------------------------------------------------------------------------*/ |
| 2028 | function_prolog(mftlb3) |
Wolfgang Denk | 52232fd | 2007-02-27 14:26:04 +0100 | [diff] [blame] | 2029 | TLBRE(3,3,2) |
Stefan Roese | a8856e3 | 2007-02-20 10:57:08 +0100 | [diff] [blame] | 2030 | blr |
| 2031 | function_epilog(mftlb3) |
| 2032 | |
| 2033 | /*----------------------------------------------------------------------------+ |
| 2034 | | mttlb2. |
| 2035 | +----------------------------------------------------------------------------*/ |
| 2036 | function_prolog(mttlb2) |
| 2037 | TLBWE(4,3,1) |
| 2038 | blr |
| 2039 | function_epilog(mttlb2) |
| 2040 | |
| 2041 | /*----------------------------------------------------------------------------+ |
| 2042 | | mftlb2. |
| 2043 | +----------------------------------------------------------------------------*/ |
| 2044 | function_prolog(mftlb2) |
Wolfgang Denk | 52232fd | 2007-02-27 14:26:04 +0100 | [diff] [blame] | 2045 | TLBRE(3,3,1) |
Stefan Roese | a8856e3 | 2007-02-20 10:57:08 +0100 | [diff] [blame] | 2046 | blr |
| 2047 | function_epilog(mftlb2) |
| 2048 | |
| 2049 | /*----------------------------------------------------------------------------+ |
| 2050 | | mttlb1. |
| 2051 | +----------------------------------------------------------------------------*/ |
| 2052 | function_prolog(mttlb1) |
| 2053 | TLBWE(4,3,0) |
| 2054 | blr |
| 2055 | function_epilog(mttlb1) |
| 2056 | |
| 2057 | /*----------------------------------------------------------------------------+ |
| 2058 | | mftlb1. |
| 2059 | +----------------------------------------------------------------------------*/ |
| 2060 | function_prolog(mftlb1) |
Wolfgang Denk | 52232fd | 2007-02-27 14:26:04 +0100 | [diff] [blame] | 2061 | TLBRE(3,3,0) |
Stefan Roese | a8856e3 | 2007-02-20 10:57:08 +0100 | [diff] [blame] | 2062 | blr |
| 2063 | function_epilog(mftlb1) |
| 2064 | #endif /* CONFIG_440 */ |
Stefan Roese | 7d72e02 | 2008-06-02 14:35:44 +0200 | [diff] [blame^] | 2065 | |
| 2066 | #if defined(CONFIG_NAND_SPL) |
| 2067 | /* |
| 2068 | * void nand_boot_relocate(dst, src, bytes) |
| 2069 | * |
| 2070 | * r3 = Destination address to copy code to (in SDRAM) |
| 2071 | * r4 = Source address to copy code from |
| 2072 | * r5 = size to copy in bytes |
| 2073 | */ |
| 2074 | nand_boot_relocate: |
| 2075 | mr r6,r3 |
| 2076 | mr r7,r4 |
| 2077 | mflr r8 |
| 2078 | |
| 2079 | /* |
| 2080 | * Copy SPL from icache into SDRAM |
| 2081 | */ |
| 2082 | subi r3,r3,4 |
| 2083 | subi r4,r4,4 |
| 2084 | srwi r5,r5,2 |
| 2085 | mtctr r5 |
| 2086 | ..spl_loop: |
| 2087 | lwzu r0,4(r4) |
| 2088 | stwu r0,4(r3) |
| 2089 | bdnz ..spl_loop |
| 2090 | |
| 2091 | /* |
| 2092 | * Calculate "corrected" link register, so that we "continue" |
| 2093 | * in execution in destination range |
| 2094 | */ |
| 2095 | sub r3,r7,r6 /* r3 = src - dst */ |
| 2096 | sub r8,r8,r3 /* r8 = link-reg - (src - dst) */ |
| 2097 | mtlr r8 |
| 2098 | blr |
| 2099 | |
| 2100 | nand_boot_common: |
| 2101 | /* |
| 2102 | * First initialize SDRAM. It has to be available *before* calling |
| 2103 | * nand_boot(). |
| 2104 | */ |
| 2105 | lis r3,CFG_SDRAM_BASE@h |
| 2106 | ori r3,r3,CFG_SDRAM_BASE@l |
| 2107 | bl initdram |
| 2108 | |
| 2109 | /* |
| 2110 | * Now copy the 4k SPL code into SDRAM and continue execution |
| 2111 | * from there. |
| 2112 | */ |
| 2113 | lis r3,CFG_NAND_BOOT_SPL_DST@h |
| 2114 | ori r3,r3,CFG_NAND_BOOT_SPL_DST@l |
| 2115 | lis r4,CFG_NAND_BOOT_SPL_SRC@h |
| 2116 | ori r4,r4,CFG_NAND_BOOT_SPL_SRC@l |
| 2117 | lis r5,CFG_NAND_BOOT_SPL_SIZE@h |
| 2118 | ori r5,r5,CFG_NAND_BOOT_SPL_SIZE@l |
| 2119 | bl nand_boot_relocate |
| 2120 | |
| 2121 | /* |
| 2122 | * We're running from SDRAM now!!! |
| 2123 | * |
| 2124 | * It is necessary for 4xx systems to relocate from running at |
| 2125 | * the original location (0xfffffxxx) to somewhere else (SDRAM |
| 2126 | * preferably). This is because CS0 needs to be reconfigured for |
| 2127 | * NAND access. And we can't reconfigure this CS when currently |
| 2128 | * "running" from it. |
| 2129 | */ |
| 2130 | |
| 2131 | /* |
| 2132 | * Finally call nand_boot() to load main NAND U-Boot image from |
| 2133 | * NAND and jump to it. |
| 2134 | */ |
| 2135 | bl nand_boot /* will not return */ |
| 2136 | #endif /* CONFIG_NAND_SPL */ |