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