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