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