1a47a12beSStefan Roese/* 2a47a12beSStefan Roese * Copyright 2004, 2007-2010 Freescale Semiconductor, Inc. 3a47a12beSStefan Roese * Copyright (C) 2003 Motorola,Inc. 4a47a12beSStefan Roese * 5a47a12beSStefan Roese * See file CREDITS for list of people who contributed to this 6a47a12beSStefan Roese * project. 7a47a12beSStefan Roese * 8a47a12beSStefan Roese * This program is free software; you can redistribute it and/or 9a47a12beSStefan Roese * modify it under the terms of the GNU General Public License as 10a47a12beSStefan Roese * published by the Free Software Foundation; either version 2 of 11a47a12beSStefan Roese * the License, or (at your option) any later version. 12a47a12beSStefan Roese * 13a47a12beSStefan Roese * This program is distributed in the hope that it will be useful, 14a47a12beSStefan Roese * but WITHOUT ANY WARRANTY; without even the implied warranty of 15a47a12beSStefan Roese * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16a47a12beSStefan Roese * GNU General Public License for more details. 17a47a12beSStefan Roese * 18a47a12beSStefan Roese * You should have received a copy of the GNU General Public License 19a47a12beSStefan Roese * along with this program; if not, write to the Free Software 20a47a12beSStefan Roese * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21a47a12beSStefan Roese * MA 02111-1307 USA 22a47a12beSStefan Roese */ 23a47a12beSStefan Roese 24a47a12beSStefan Roese/* U-Boot Startup Code for Motorola 85xx PowerPC based Embedded Boards 25a47a12beSStefan Roese * 26a47a12beSStefan Roese * The processor starts at 0xfffffffc and the code is first executed in the 27a47a12beSStefan Roese * last 4K page(0xfffff000-0xffffffff) in flash/rom. 28a47a12beSStefan Roese * 29a47a12beSStefan Roese */ 30a47a12beSStefan Roese 31a47a12beSStefan Roese#include <config.h> 32a47a12beSStefan Roese#include <mpc85xx.h> 33a47a12beSStefan Roese#include <timestamp.h> 34a47a12beSStefan Roese#include <version.h> 35a47a12beSStefan Roese 36a47a12beSStefan Roese#define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */ 37a47a12beSStefan Roese 38a47a12beSStefan Roese#include <ppc_asm.tmpl> 39a47a12beSStefan Roese#include <ppc_defs.h> 40a47a12beSStefan Roese 41a47a12beSStefan Roese#include <asm/cache.h> 42a47a12beSStefan Roese#include <asm/mmu.h> 43a47a12beSStefan Roese 44a47a12beSStefan Roese#ifndef CONFIG_IDENT_STRING 45a47a12beSStefan Roese#define CONFIG_IDENT_STRING "" 46a47a12beSStefan Roese#endif 47a47a12beSStefan Roese 48a47a12beSStefan Roese#undef MSR_KERNEL 49a47a12beSStefan Roese#define MSR_KERNEL ( MSR_ME ) /* Machine Check */ 50a47a12beSStefan Roese 51a47a12beSStefan Roese/* 52a47a12beSStefan Roese * Set up GOT: Global Offset Table 53a47a12beSStefan Roese * 54a47a12beSStefan Roese * Use r12 to access the GOT 55a47a12beSStefan Roese */ 56a47a12beSStefan Roese START_GOT 57a47a12beSStefan Roese GOT_ENTRY(_GOT2_TABLE_) 58a47a12beSStefan Roese GOT_ENTRY(_FIXUP_TABLE_) 59a47a12beSStefan Roese 60a47a12beSStefan Roese#ifndef CONFIG_NAND_SPL 61a47a12beSStefan Roese GOT_ENTRY(_start) 62a47a12beSStefan Roese GOT_ENTRY(_start_of_vectors) 63a47a12beSStefan Roese GOT_ENTRY(_end_of_vectors) 64a47a12beSStefan Roese GOT_ENTRY(transfer_to_handler) 65a47a12beSStefan Roese#endif 66a47a12beSStefan Roese 67a47a12beSStefan Roese GOT_ENTRY(__init_end) 68a47a12beSStefan Roese GOT_ENTRY(_end) 69a47a12beSStefan Roese GOT_ENTRY(__bss_start) 70a47a12beSStefan Roese END_GOT 71a47a12beSStefan Roese 72a47a12beSStefan Roese/* 73a47a12beSStefan Roese * e500 Startup -- after reset only the last 4KB of the effective 74a47a12beSStefan Roese * address space is mapped in the MMU L2 TLB1 Entry0. The .bootpg 75a47a12beSStefan Roese * section is located at THIS LAST page and basically does three 76a47a12beSStefan Roese * things: clear some registers, set up exception tables and 77a47a12beSStefan Roese * add more TLB entries for 'larger spaces'(e.g. the boot rom) to 78a47a12beSStefan Roese * continue the boot procedure. 79a47a12beSStefan Roese 80a47a12beSStefan Roese * Once the boot rom is mapped by TLB entries we can proceed 81a47a12beSStefan Roese * with normal startup. 82a47a12beSStefan Roese * 83a47a12beSStefan Roese */ 84a47a12beSStefan Roese 85a47a12beSStefan Roese .section .bootpg,"ax" 86a47a12beSStefan Roese .globl _start_e500 87a47a12beSStefan Roese 88a47a12beSStefan Roese_start_e500: 89a47a12beSStefan Roese 90a47a12beSStefan Roese/* clear registers/arrays not reset by hardware */ 91a47a12beSStefan Roese 92a47a12beSStefan Roese /* L1 */ 93a47a12beSStefan Roese li r0,2 94a47a12beSStefan Roese mtspr L1CSR0,r0 /* invalidate d-cache */ 95a47a12beSStefan Roese mtspr L1CSR1,r0 /* invalidate i-cache */ 96a47a12beSStefan Roese 97a47a12beSStefan Roese mfspr r1,DBSR 98a47a12beSStefan Roese mtspr DBSR,r1 /* Clear all valid bits */ 99a47a12beSStefan Roese 100a47a12beSStefan Roese /* 101a47a12beSStefan Roese * Enable L1 Caches early 102a47a12beSStefan Roese * 103a47a12beSStefan Roese */ 104a47a12beSStefan Roese 105a47a12beSStefan Roese#if defined(CONFIG_E500MC) && defined(CONFIG_SYS_CACHE_STASHING) 106a47a12beSStefan Roese /* set stash id to (coreID) * 2 + 32 + L1 CT (0) */ 107a47a12beSStefan Roese li r2,(32 + 0) 108a47a12beSStefan Roese mtspr L1CSR2,r2 109a47a12beSStefan Roese#endif 110a47a12beSStefan Roese 111a47a12beSStefan Roese /* Enable/invalidate the I-Cache */ 112a47a12beSStefan Roese lis r2,(L1CSR1_ICFI|L1CSR1_ICLFR)@h 113a47a12beSStefan Roese ori r2,r2,(L1CSR1_ICFI|L1CSR1_ICLFR)@l 114a47a12beSStefan Roese mtspr SPRN_L1CSR1,r2 115a47a12beSStefan Roese1: 116a47a12beSStefan Roese mfspr r3,SPRN_L1CSR1 117a47a12beSStefan Roese and. r1,r3,r2 118a47a12beSStefan Roese bne 1b 119a47a12beSStefan Roese 120a47a12beSStefan Roese lis r3,(L1CSR1_CPE|L1CSR1_ICE)@h 121a47a12beSStefan Roese ori r3,r3,(L1CSR1_CPE|L1CSR1_ICE)@l 122a47a12beSStefan Roese mtspr SPRN_L1CSR1,r3 123a47a12beSStefan Roese isync 124a47a12beSStefan Roese2: 125a47a12beSStefan Roese mfspr r3,SPRN_L1CSR1 126a47a12beSStefan Roese andi. r1,r3,L1CSR1_ICE@l 127a47a12beSStefan Roese beq 2b 128a47a12beSStefan Roese 129a47a12beSStefan Roese /* Enable/invalidate the D-Cache */ 130a47a12beSStefan Roese lis r2,(L1CSR0_DCFI|L1CSR0_DCLFR)@h 131a47a12beSStefan Roese ori r2,r2,(L1CSR0_DCFI|L1CSR0_DCLFR)@l 132a47a12beSStefan Roese mtspr SPRN_L1CSR0,r2 133a47a12beSStefan Roese1: 134a47a12beSStefan Roese mfspr r3,SPRN_L1CSR0 135a47a12beSStefan Roese and. r1,r3,r2 136a47a12beSStefan Roese bne 1b 137a47a12beSStefan Roese 138a47a12beSStefan Roese lis r3,(L1CSR0_CPE|L1CSR0_DCE)@h 139a47a12beSStefan Roese ori r3,r3,(L1CSR0_CPE|L1CSR0_DCE)@l 140a47a12beSStefan Roese mtspr SPRN_L1CSR0,r3 141a47a12beSStefan Roese isync 142a47a12beSStefan Roese2: 143a47a12beSStefan Roese mfspr r3,SPRN_L1CSR0 144a47a12beSStefan Roese andi. r1,r3,L1CSR0_DCE@l 145a47a12beSStefan Roese beq 2b 146a47a12beSStefan Roese 147a47a12beSStefan Roese /* Setup interrupt vectors */ 148a47a12beSStefan Roese lis r1,TEXT_BASE@h 149a47a12beSStefan Roese mtspr IVPR,r1 150a47a12beSStefan Roese 151a47a12beSStefan Roese li r1,0x0100 152a47a12beSStefan Roese mtspr IVOR0,r1 /* 0: Critical input */ 153a47a12beSStefan Roese li r1,0x0200 154a47a12beSStefan Roese mtspr IVOR1,r1 /* 1: Machine check */ 155a47a12beSStefan Roese li r1,0x0300 156a47a12beSStefan Roese mtspr IVOR2,r1 /* 2: Data storage */ 157a47a12beSStefan Roese li r1,0x0400 158a47a12beSStefan Roese mtspr IVOR3,r1 /* 3: Instruction storage */ 159a47a12beSStefan Roese li r1,0x0500 160a47a12beSStefan Roese mtspr IVOR4,r1 /* 4: External interrupt */ 161a47a12beSStefan Roese li r1,0x0600 162a47a12beSStefan Roese mtspr IVOR5,r1 /* 5: Alignment */ 163a47a12beSStefan Roese li r1,0x0700 164a47a12beSStefan Roese mtspr IVOR6,r1 /* 6: Program check */ 165a47a12beSStefan Roese li r1,0x0800 166a47a12beSStefan Roese mtspr IVOR7,r1 /* 7: floating point unavailable */ 167a47a12beSStefan Roese li r1,0x0900 168a47a12beSStefan Roese mtspr IVOR8,r1 /* 8: System call */ 169a47a12beSStefan Roese /* 9: Auxiliary processor unavailable(unsupported) */ 170a47a12beSStefan Roese li r1,0x0a00 171a47a12beSStefan Roese mtspr IVOR10,r1 /* 10: Decrementer */ 172a47a12beSStefan Roese li r1,0x0b00 173a47a12beSStefan Roese mtspr IVOR11,r1 /* 11: Interval timer */ 174a47a12beSStefan Roese li r1,0x0c00 175a47a12beSStefan Roese mtspr IVOR12,r1 /* 12: Watchdog timer */ 176a47a12beSStefan Roese li r1,0x0d00 177a47a12beSStefan Roese mtspr IVOR13,r1 /* 13: Data TLB error */ 178a47a12beSStefan Roese li r1,0x0e00 179a47a12beSStefan Roese mtspr IVOR14,r1 /* 14: Instruction TLB error */ 180a47a12beSStefan Roese li r1,0x0f00 181a47a12beSStefan Roese mtspr IVOR15,r1 /* 15: Debug */ 182a47a12beSStefan Roese 183a47a12beSStefan Roese /* Clear and set up some registers. */ 184a47a12beSStefan Roese li r0,0x0000 185a47a12beSStefan Roese lis r1,0xffff 186a47a12beSStefan Roese mtspr DEC,r0 /* prevent dec exceptions */ 187a47a12beSStefan Roese mttbl r0 /* prevent fit & wdt exceptions */ 188a47a12beSStefan Roese mttbu r0 189a47a12beSStefan Roese mtspr TSR,r1 /* clear all timer exception status */ 190a47a12beSStefan Roese mtspr TCR,r0 /* disable all */ 191a47a12beSStefan Roese mtspr ESR,r0 /* clear exception syndrome register */ 192a47a12beSStefan Roese mtspr MCSR,r0 /* machine check syndrome register */ 193a47a12beSStefan Roese mtxer r0 /* clear integer exception register */ 194a47a12beSStefan Roese 195a47a12beSStefan Roese#ifdef CONFIG_SYS_BOOK3E_HV 196a47a12beSStefan Roese mtspr MAS8,r0 /* make sure MAS8 is clear */ 197a47a12beSStefan Roese#endif 198a47a12beSStefan Roese 199a47a12beSStefan Roese /* Enable Time Base and Select Time Base Clock */ 200a47a12beSStefan Roese lis r0,HID0_EMCP@h /* Enable machine check */ 201a47a12beSStefan Roese#if defined(CONFIG_ENABLE_36BIT_PHYS) 202a47a12beSStefan Roese ori r0,r0,HID0_ENMAS7@l /* Enable MAS7 */ 203a47a12beSStefan Roese#endif 204a47a12beSStefan Roese#ifndef CONFIG_E500MC 205a47a12beSStefan Roese ori r0,r0,HID0_TBEN@l /* Enable Timebase */ 206a47a12beSStefan Roese#endif 207a47a12beSStefan Roese mtspr HID0,r0 208a47a12beSStefan Roese 209a47a12beSStefan Roese#ifndef CONFIG_E500MC 210a47a12beSStefan Roese li r0,(HID1_ASTME|HID1_ABE)@l /* Addr streaming & broadcast */ 211a47a12beSStefan Roese mfspr r3,PVR 212a47a12beSStefan Roese andi. r3,r3, 0xff 213a47a12beSStefan Roese cmpwi r3,0x50@l /* if we are rev 5.0 or greater set MBDD */ 214a47a12beSStefan Roese blt 1f 215a47a12beSStefan Roese /* Set MBDD bit also */ 216a47a12beSStefan Roese ori r0, r0, HID1_MBDD@l 217a47a12beSStefan Roese1: 218a47a12beSStefan Roese mtspr HID1,r0 219a47a12beSStefan Roese#endif 220a47a12beSStefan Roese 221a47a12beSStefan Roese /* Enable Branch Prediction */ 222a47a12beSStefan Roese#if defined(CONFIG_BTB) 223a47a12beSStefan Roese lis r0,BUCSR_ENABLE@h 224a47a12beSStefan Roese ori r0,r0,BUCSR_ENABLE@l 225a47a12beSStefan Roese mtspr SPRN_BUCSR,r0 226a47a12beSStefan Roese#endif 227a47a12beSStefan Roese 228a47a12beSStefan Roese#if defined(CONFIG_SYS_INIT_DBCR) 229a47a12beSStefan Roese lis r1,0xffff 230a47a12beSStefan Roese ori r1,r1,0xffff 231a47a12beSStefan Roese mtspr DBSR,r1 /* Clear all status bits */ 232a47a12beSStefan Roese lis r0,CONFIG_SYS_INIT_DBCR@h /* DBCR0[IDM] must be set */ 233a47a12beSStefan Roese ori r0,r0,CONFIG_SYS_INIT_DBCR@l 234a47a12beSStefan Roese mtspr DBCR0,r0 235a47a12beSStefan Roese#endif 236a47a12beSStefan Roese 237a47a12beSStefan Roese#ifdef CONFIG_MPC8569 238a47a12beSStefan Roese#define CONFIG_SYS_LBC_ADDR (CONFIG_SYS_CCSRBAR_DEFAULT + 0x5000) 239a47a12beSStefan Roese#define CONFIG_SYS_LBCR_ADDR (CONFIG_SYS_LBC_ADDR + 0xd0) 240a47a12beSStefan Roese 241a47a12beSStefan Roese /* MPC8569 Rev.0 silcon needs to set bit 13 of LBCR to allow elBC to 242a47a12beSStefan Roese * use address space which is more than 12bits, and it must be done in 243a47a12beSStefan Roese * the 4K boot page. So we set this bit here. 244a47a12beSStefan Roese */ 245a47a12beSStefan Roese 246a47a12beSStefan Roese /* create a temp mapping TLB0[0] for LBCR */ 247a47a12beSStefan Roese lis r6,FSL_BOOKE_MAS0(0, 0, 0)@h 248a47a12beSStefan Roese ori r6,r6,FSL_BOOKE_MAS0(0, 0, 0)@l 249a47a12beSStefan Roese 250a47a12beSStefan Roese lis r7,FSL_BOOKE_MAS1(1, 0, 0, 0, BOOKE_PAGESZ_4K)@h 251a47a12beSStefan Roese ori r7,r7,FSL_BOOKE_MAS1(1, 0, 0, 0, BOOKE_PAGESZ_4K)@l 252a47a12beSStefan Roese 253a47a12beSStefan Roese lis r8,FSL_BOOKE_MAS2(CONFIG_SYS_LBC_ADDR, MAS2_I|MAS2_G)@h 254a47a12beSStefan Roese ori r8,r8,FSL_BOOKE_MAS2(CONFIG_SYS_LBC_ADDR, MAS2_I|MAS2_G)@l 255a47a12beSStefan Roese 256a47a12beSStefan Roese lis r9,FSL_BOOKE_MAS3(CONFIG_SYS_LBC_ADDR, 0, 257a47a12beSStefan Roese (MAS3_SX|MAS3_SW|MAS3_SR))@h 258a47a12beSStefan Roese ori r9,r9,FSL_BOOKE_MAS3(CONFIG_SYS_LBC_ADDR, 0, 259a47a12beSStefan Roese (MAS3_SX|MAS3_SW|MAS3_SR))@l 260a47a12beSStefan Roese 261a47a12beSStefan Roese mtspr MAS0,r6 262a47a12beSStefan Roese mtspr MAS1,r7 263a47a12beSStefan Roese mtspr MAS2,r8 264a47a12beSStefan Roese mtspr MAS3,r9 265a47a12beSStefan Roese isync 266a47a12beSStefan Roese msync 267a47a12beSStefan Roese tlbwe 268a47a12beSStefan Roese 269a47a12beSStefan Roese /* Set LBCR register */ 270a47a12beSStefan Roese lis r4,CONFIG_SYS_LBCR_ADDR@h 271a47a12beSStefan Roese ori r4,r4,CONFIG_SYS_LBCR_ADDR@l 272a47a12beSStefan Roese 273a47a12beSStefan Roese lis r5,CONFIG_SYS_LBC_LBCR@h 274a47a12beSStefan Roese ori r5,r5,CONFIG_SYS_LBC_LBCR@l 275a47a12beSStefan Roese stw r5,0(r4) 276a47a12beSStefan Roese isync 277a47a12beSStefan Roese 278a47a12beSStefan Roese /* invalidate this temp TLB */ 279a47a12beSStefan Roese lis r4,CONFIG_SYS_LBC_ADDR@h 280a47a12beSStefan Roese ori r4,r4,CONFIG_SYS_LBC_ADDR@l 281a47a12beSStefan Roese tlbivax 0,r4 282a47a12beSStefan Roese isync 283a47a12beSStefan Roese 284a47a12beSStefan Roese#endif /* CONFIG_MPC8569 */ 285a47a12beSStefan Roese 286a47a12beSStefan Roese lis r6,FSL_BOOKE_MAS0(1, 15, 0)@h 287a47a12beSStefan Roese ori r6,r6,FSL_BOOKE_MAS0(1, 15, 0)@l 288a47a12beSStefan Roese 289a47a12beSStefan Roese#ifndef CONFIG_SYS_RAMBOOT 290a47a12beSStefan Roese /* create a temp mapping in AS=1 to the 4M boot window */ 291a47a12beSStefan Roese lis r7,FSL_BOOKE_MAS1(1, 1, 0, 1, BOOKE_PAGESZ_4M)@h 292a47a12beSStefan Roese ori r7,r7,FSL_BOOKE_MAS1(1, 1, 0, 1, BOOKE_PAGESZ_4M)@l 293a47a12beSStefan Roese 294a47a12beSStefan Roese lis r8,FSL_BOOKE_MAS2(TEXT_BASE & 0xffc00000, (MAS2_I|MAS2_G))@h 295a47a12beSStefan Roese ori r8,r8,FSL_BOOKE_MAS2(TEXT_BASE & 0xffc00000, (MAS2_I|MAS2_G))@l 296a47a12beSStefan Roese 297a47a12beSStefan Roese /* The 85xx has the default boot window 0xff800000 - 0xffffffff */ 298a47a12beSStefan Roese lis r9,FSL_BOOKE_MAS3(0xffc00000, 0, (MAS3_SX|MAS3_SW|MAS3_SR))@h 299a47a12beSStefan Roese ori r9,r9,FSL_BOOKE_MAS3(0xffc00000, 0, (MAS3_SX|MAS3_SW|MAS3_SR))@l 300a47a12beSStefan Roese#else 301a47a12beSStefan Roese /* 302a47a12beSStefan Roese * create a temp mapping in AS=1 to the 1M TEXT_BASE space, the main 303a47a12beSStefan Roese * image has been relocated to TEXT_BASE on the second stage. 304a47a12beSStefan Roese */ 305a47a12beSStefan Roese lis r7,FSL_BOOKE_MAS1(1, 1, 0, 1, BOOKE_PAGESZ_1M)@h 306a47a12beSStefan Roese ori r7,r7,FSL_BOOKE_MAS1(1, 1, 0, 1, BOOKE_PAGESZ_1M)@l 307a47a12beSStefan Roese 308a47a12beSStefan Roese lis r8,FSL_BOOKE_MAS2(TEXT_BASE, (MAS2_I|MAS2_G))@h 309a47a12beSStefan Roese ori r8,r8,FSL_BOOKE_MAS2(TEXT_BASE, (MAS2_I|MAS2_G))@l 310a47a12beSStefan Roese 311a47a12beSStefan Roese lis r9,FSL_BOOKE_MAS3(TEXT_BASE, 0, (MAS3_SX|MAS3_SW|MAS3_SR))@h 312a47a12beSStefan Roese ori r9,r9,FSL_BOOKE_MAS3(TEXT_BASE, 0, (MAS3_SX|MAS3_SW|MAS3_SR))@l 313a47a12beSStefan Roese#endif 314a47a12beSStefan Roese 315a47a12beSStefan Roese mtspr MAS0,r6 316a47a12beSStefan Roese mtspr MAS1,r7 317a47a12beSStefan Roese mtspr MAS2,r8 318a47a12beSStefan Roese mtspr MAS3,r9 319a47a12beSStefan Roese isync 320a47a12beSStefan Roese msync 321a47a12beSStefan Roese tlbwe 322a47a12beSStefan Roese 323a47a12beSStefan Roese /* create a temp mapping in AS=1 to the stack */ 324a47a12beSStefan Roese lis r6,FSL_BOOKE_MAS0(1, 14, 0)@h 325a47a12beSStefan Roese ori r6,r6,FSL_BOOKE_MAS0(1, 14, 0)@l 326a47a12beSStefan Roese 327a47a12beSStefan Roese lis r7,FSL_BOOKE_MAS1(1, 1, 0, 1, BOOKE_PAGESZ_16K)@h 328a47a12beSStefan Roese ori r7,r7,FSL_BOOKE_MAS1(1, 1, 0, 1, BOOKE_PAGESZ_16K)@l 329a47a12beSStefan Roese 330a47a12beSStefan Roese lis r8,FSL_BOOKE_MAS2(CONFIG_SYS_INIT_RAM_ADDR, 0)@h 331a47a12beSStefan Roese ori r8,r8,FSL_BOOKE_MAS2(CONFIG_SYS_INIT_RAM_ADDR, 0)@l 332a47a12beSStefan Roese 333*a3f18529Syork#if defined(CONFIG_SYS_INIT_RAM_ADDR_PHYS_LOW) && \ 334*a3f18529Syork defined(CONFIG_SYS_INIT_RAM_ADDR_PHYS_HIGH) 335*a3f18529Syork lis r9,FSL_BOOKE_MAS3(CONFIG_SYS_INIT_RAM_ADDR_PHYS_LOW, 0, 336*a3f18529Syork (MAS3_SX|MAS3_SW|MAS3_SR))@h 337*a3f18529Syork ori r9,r9,FSL_BOOKE_MAS3(CONFIG_SYS_INIT_RAM_ADDR_PHYS_LOW, 0, 338*a3f18529Syork (MAS3_SX|MAS3_SW|MAS3_SR))@l 339*a3f18529Syork li r10,CONFIG_SYS_INIT_RAM_ADDR_PHYS_HIGH 340*a3f18529Syork mtspr MAS7,r10 341*a3f18529Syork#else 342a47a12beSStefan Roese lis r9,FSL_BOOKE_MAS3(CONFIG_SYS_INIT_RAM_ADDR, 0, (MAS3_SX|MAS3_SW|MAS3_SR))@h 343a47a12beSStefan Roese ori r9,r9,FSL_BOOKE_MAS3(CONFIG_SYS_INIT_RAM_ADDR, 0, (MAS3_SX|MAS3_SW|MAS3_SR))@l 344*a3f18529Syork#endif 345a47a12beSStefan Roese 346a47a12beSStefan Roese mtspr MAS0,r6 347a47a12beSStefan Roese mtspr MAS1,r7 348a47a12beSStefan Roese mtspr MAS2,r8 349a47a12beSStefan Roese mtspr MAS3,r9 350a47a12beSStefan Roese isync 351a47a12beSStefan Roese msync 352a47a12beSStefan Roese tlbwe 353a47a12beSStefan Roese 354a47a12beSStefan Roese lis r6,MSR_IS|MSR_DS@h 355a47a12beSStefan Roese ori r6,r6,MSR_IS|MSR_DS@l 356a47a12beSStefan Roese lis r7,switch_as@h 357a47a12beSStefan Roese ori r7,r7,switch_as@l 358a47a12beSStefan Roese 359a47a12beSStefan Roese mtspr SPRN_SRR0,r7 360a47a12beSStefan Roese mtspr SPRN_SRR1,r6 361a47a12beSStefan Roese rfi 362a47a12beSStefan Roese 363a47a12beSStefan Roeseswitch_as: 364a47a12beSStefan Roese/* L1 DCache is used for initial RAM */ 365a47a12beSStefan Roese 366a47a12beSStefan Roese /* Allocate Initial RAM in data cache. 367a47a12beSStefan Roese */ 368a47a12beSStefan Roese lis r3,CONFIG_SYS_INIT_RAM_ADDR@h 369a47a12beSStefan Roese ori r3,r3,CONFIG_SYS_INIT_RAM_ADDR@l 370a47a12beSStefan Roese mfspr r2, L1CFG0 371a47a12beSStefan Roese andi. r2, r2, 0x1ff 372a47a12beSStefan Roese /* cache size * 1024 / (2 * L1 line size) */ 373a47a12beSStefan Roese slwi r2, r2, (10 - 1 - L1_CACHE_SHIFT) 374a47a12beSStefan Roese mtctr r2 375a47a12beSStefan Roese li r0,0 376a47a12beSStefan Roese1: 377a47a12beSStefan Roese dcbz r0,r3 378a47a12beSStefan Roese dcbtls 0,r0,r3 379a47a12beSStefan Roese addi r3,r3,CONFIG_SYS_CACHELINE_SIZE 380a47a12beSStefan Roese bdnz 1b 381a47a12beSStefan Roese 382a47a12beSStefan Roese /* Jump out the last 4K page and continue to 'normal' start */ 383a47a12beSStefan Roese#ifdef CONFIG_SYS_RAMBOOT 384a47a12beSStefan Roese b _start_cont 385a47a12beSStefan Roese#else 386a47a12beSStefan Roese /* Calculate absolute address in FLASH and jump there */ 387a47a12beSStefan Roese /*--------------------------------------------------------------*/ 388a47a12beSStefan Roese lis r3,CONFIG_SYS_MONITOR_BASE@h 389a47a12beSStefan Roese ori r3,r3,CONFIG_SYS_MONITOR_BASE@l 390a47a12beSStefan Roese addi r3,r3,_start_cont - _start + _START_OFFSET 391a47a12beSStefan Roese mtlr r3 392a47a12beSStefan Roese blr 393a47a12beSStefan Roese#endif 394a47a12beSStefan Roese 395a47a12beSStefan Roese .text 396a47a12beSStefan Roese .globl _start 397a47a12beSStefan Roese_start: 398a47a12beSStefan Roese .long 0x27051956 /* U-BOOT Magic Number */ 399a47a12beSStefan Roese .globl version_string 400a47a12beSStefan Roeseversion_string: 401a47a12beSStefan Roese .ascii U_BOOT_VERSION 402a47a12beSStefan Roese .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")" 403a47a12beSStefan Roese .ascii CONFIG_IDENT_STRING, "\0" 404a47a12beSStefan Roese 405a47a12beSStefan Roese .align 4 406a47a12beSStefan Roese .globl _start_cont 407a47a12beSStefan Roese_start_cont: 408a47a12beSStefan Roese /* Setup the stack in initial RAM,could be L2-as-SRAM or L1 dcache*/ 409a47a12beSStefan Roese lis r1,CONFIG_SYS_INIT_RAM_ADDR@h 410a47a12beSStefan Roese ori r1,r1,CONFIG_SYS_INIT_SP_OFFSET@l 411a47a12beSStefan Roese 412a47a12beSStefan Roese li r0,0 413a47a12beSStefan Roese stwu r0,-4(r1) 414a47a12beSStefan Roese stwu r0,-4(r1) /* Terminate call chain */ 415a47a12beSStefan Roese 416a47a12beSStefan Roese stwu r1,-8(r1) /* Save back chain and move SP */ 417a47a12beSStefan Roese lis r0,RESET_VECTOR@h /* Address of reset vector */ 418a47a12beSStefan Roese ori r0,r0,RESET_VECTOR@l 419a47a12beSStefan Roese stwu r1,-8(r1) /* Save back chain and move SP */ 420a47a12beSStefan Roese stw r0,+12(r1) /* Save return addr (underflow vect) */ 421a47a12beSStefan Roese 422a47a12beSStefan Roese GET_GOT 423a47a12beSStefan Roese bl cpu_init_early_f 424a47a12beSStefan Roese 425a47a12beSStefan Roese /* switch back to AS = 0 */ 426a47a12beSStefan Roese lis r3,(MSR_CE|MSR_ME|MSR_DE)@h 427a47a12beSStefan Roese ori r3,r3,(MSR_CE|MSR_ME|MSR_DE)@l 428a47a12beSStefan Roese mtmsr r3 429a47a12beSStefan Roese isync 430a47a12beSStefan Roese 431a47a12beSStefan Roese bl cpu_init_f 432a47a12beSStefan Roese bl board_init_f 433a47a12beSStefan Roese isync 434a47a12beSStefan Roese 435a47a12beSStefan Roese#ifndef CONFIG_NAND_SPL 436a47a12beSStefan Roese . = EXC_OFF_SYS_RESET 437a47a12beSStefan Roese .globl _start_of_vectors 438a47a12beSStefan Roese_start_of_vectors: 439a47a12beSStefan Roese 440a47a12beSStefan Roese/* Critical input. */ 441a47a12beSStefan Roese CRIT_EXCEPTION(0x0100, CriticalInput, CritcalInputException) 442a47a12beSStefan Roese 443a47a12beSStefan Roese/* Machine check */ 444a47a12beSStefan Roese MCK_EXCEPTION(0x200, MachineCheck, MachineCheckException) 445a47a12beSStefan Roese 446a47a12beSStefan Roese/* Data Storage exception. */ 447a47a12beSStefan Roese STD_EXCEPTION(0x0300, DataStorage, UnknownException) 448a47a12beSStefan Roese 449a47a12beSStefan Roese/* Instruction Storage exception. */ 450a47a12beSStefan Roese STD_EXCEPTION(0x0400, InstStorage, UnknownException) 451a47a12beSStefan Roese 452a47a12beSStefan Roese/* External Interrupt exception. */ 453a47a12beSStefan Roese STD_EXCEPTION(0x0500, ExtInterrupt, ExtIntException) 454a47a12beSStefan Roese 455a47a12beSStefan Roese/* Alignment exception. */ 456a47a12beSStefan Roese . = 0x0600 457a47a12beSStefan RoeseAlignment: 458a47a12beSStefan Roese EXCEPTION_PROLOG(SRR0, SRR1) 459a47a12beSStefan Roese mfspr r4,DAR 460a47a12beSStefan Roese stw r4,_DAR(r21) 461a47a12beSStefan Roese mfspr r5,DSISR 462a47a12beSStefan Roese stw r5,_DSISR(r21) 463a47a12beSStefan Roese addi r3,r1,STACK_FRAME_OVERHEAD 464a47a12beSStefan Roese EXC_XFER_TEMPLATE(Alignment, AlignmentException, MSR_KERNEL, COPY_EE) 465a47a12beSStefan Roese 466a47a12beSStefan Roese/* Program check exception */ 467a47a12beSStefan Roese . = 0x0700 468a47a12beSStefan RoeseProgramCheck: 469a47a12beSStefan Roese EXCEPTION_PROLOG(SRR0, SRR1) 470a47a12beSStefan Roese addi r3,r1,STACK_FRAME_OVERHEAD 471a47a12beSStefan Roese EXC_XFER_TEMPLATE(ProgramCheck, ProgramCheckException, 472a47a12beSStefan Roese MSR_KERNEL, COPY_EE) 473a47a12beSStefan Roese 474a47a12beSStefan Roese /* No FPU on MPC85xx. This exception is not supposed to happen. 475a47a12beSStefan Roese */ 476a47a12beSStefan Roese STD_EXCEPTION(0x0800, FPUnavailable, UnknownException) 477a47a12beSStefan Roese 478a47a12beSStefan Roese . = 0x0900 479a47a12beSStefan Roese/* 480a47a12beSStefan Roese * r0 - SYSCALL number 481a47a12beSStefan Roese * r3-... arguments 482a47a12beSStefan Roese */ 483a47a12beSStefan RoeseSystemCall: 484a47a12beSStefan Roese addis r11,r0,0 /* get functions table addr */ 485a47a12beSStefan Roese ori r11,r11,0 /* Note: this code is patched in trap_init */ 486a47a12beSStefan Roese addis r12,r0,0 /* get number of functions */ 487a47a12beSStefan Roese ori r12,r12,0 488a47a12beSStefan Roese 489a47a12beSStefan Roese cmplw 0,r0,r12 490a47a12beSStefan Roese bge 1f 491a47a12beSStefan Roese 492a47a12beSStefan Roese rlwinm r0,r0,2,0,31 /* fn_addr = fn_tbl[r0] */ 493a47a12beSStefan Roese add r11,r11,r0 494a47a12beSStefan Roese lwz r11,0(r11) 495a47a12beSStefan Roese 496a47a12beSStefan Roese li r20,0xd00-4 /* Get stack pointer */ 497a47a12beSStefan Roese lwz r12,0(r20) 498a47a12beSStefan Roese subi r12,r12,12 /* Adjust stack pointer */ 499a47a12beSStefan Roese li r0,0xc00+_end_back-SystemCall 500a47a12beSStefan Roese cmplw 0,r0,r12 /* Check stack overflow */ 501a47a12beSStefan Roese bgt 1f 502a47a12beSStefan Roese stw r12,0(r20) 503a47a12beSStefan Roese 504a47a12beSStefan Roese mflr r0 505a47a12beSStefan Roese stw r0,0(r12) 506a47a12beSStefan Roese mfspr r0,SRR0 507a47a12beSStefan Roese stw r0,4(r12) 508a47a12beSStefan Roese mfspr r0,SRR1 509a47a12beSStefan Roese stw r0,8(r12) 510a47a12beSStefan Roese 511a47a12beSStefan Roese li r12,0xc00+_back-SystemCall 512a47a12beSStefan Roese mtlr r12 513a47a12beSStefan Roese mtspr SRR0,r11 514a47a12beSStefan Roese 515a47a12beSStefan Roese1: SYNC 516a47a12beSStefan Roese rfi 517a47a12beSStefan Roese_back: 518a47a12beSStefan Roese 519a47a12beSStefan Roese mfmsr r11 /* Disable interrupts */ 520a47a12beSStefan Roese li r12,0 521a47a12beSStefan Roese ori r12,r12,MSR_EE 522a47a12beSStefan Roese andc r11,r11,r12 523a47a12beSStefan Roese SYNC /* Some chip revs need this... */ 524a47a12beSStefan Roese mtmsr r11 525a47a12beSStefan Roese SYNC 526a47a12beSStefan Roese 527a47a12beSStefan Roese li r12,0xd00-4 /* restore regs */ 528a47a12beSStefan Roese lwz r12,0(r12) 529a47a12beSStefan Roese 530a47a12beSStefan Roese lwz r11,0(r12) 531a47a12beSStefan Roese mtlr r11 532a47a12beSStefan Roese lwz r11,4(r12) 533a47a12beSStefan Roese mtspr SRR0,r11 534a47a12beSStefan Roese lwz r11,8(r12) 535a47a12beSStefan Roese mtspr SRR1,r11 536a47a12beSStefan Roese 537a47a12beSStefan Roese addi r12,r12,12 /* Adjust stack pointer */ 538a47a12beSStefan Roese li r20,0xd00-4 539a47a12beSStefan Roese stw r12,0(r20) 540a47a12beSStefan Roese 541a47a12beSStefan Roese SYNC 542a47a12beSStefan Roese rfi 543a47a12beSStefan Roese_end_back: 544a47a12beSStefan Roese 545a47a12beSStefan Roese STD_EXCEPTION(0x0a00, Decrementer, timer_interrupt) 546a47a12beSStefan Roese STD_EXCEPTION(0x0b00, IntervalTimer, UnknownException) 547a47a12beSStefan Roese STD_EXCEPTION(0x0c00, WatchdogTimer, UnknownException) 548a47a12beSStefan Roese 549a47a12beSStefan Roese STD_EXCEPTION(0x0d00, DataTLBError, UnknownException) 550a47a12beSStefan Roese STD_EXCEPTION(0x0e00, InstructionTLBError, UnknownException) 551a47a12beSStefan Roese 552a47a12beSStefan Roese CRIT_EXCEPTION(0x0f00, DebugBreakpoint, DebugException ) 553a47a12beSStefan Roese 554a47a12beSStefan Roese .globl _end_of_vectors 555a47a12beSStefan Roese_end_of_vectors: 556a47a12beSStefan Roese 557a47a12beSStefan Roese 558a47a12beSStefan Roese . = . + (0x100 - ( . & 0xff )) /* align for debug */ 559a47a12beSStefan Roese 560a47a12beSStefan Roese/* 561a47a12beSStefan Roese * This code finishes saving the registers to the exception frame 562a47a12beSStefan Roese * and jumps to the appropriate handler for the exception. 563a47a12beSStefan Roese * Register r21 is pointer into trap frame, r1 has new stack pointer. 564a47a12beSStefan Roese */ 565a47a12beSStefan Roese .globl transfer_to_handler 566a47a12beSStefan Roesetransfer_to_handler: 567a47a12beSStefan Roese stw r22,_NIP(r21) 568a47a12beSStefan Roese lis r22,MSR_POW@h 569a47a12beSStefan Roese andc r23,r23,r22 570a47a12beSStefan Roese stw r23,_MSR(r21) 571a47a12beSStefan Roese SAVE_GPR(7, r21) 572a47a12beSStefan Roese SAVE_4GPRS(8, r21) 573a47a12beSStefan Roese SAVE_8GPRS(12, r21) 574a47a12beSStefan Roese SAVE_8GPRS(24, r21) 575a47a12beSStefan Roese 576a47a12beSStefan Roese mflr r23 577a47a12beSStefan Roese andi. r24,r23,0x3f00 /* get vector offset */ 578a47a12beSStefan Roese stw r24,TRAP(r21) 579a47a12beSStefan Roese li r22,0 580a47a12beSStefan Roese stw r22,RESULT(r21) 581a47a12beSStefan Roese mtspr SPRG2,r22 /* r1 is now kernel sp */ 582a47a12beSStefan Roese 583a47a12beSStefan Roese lwz r24,0(r23) /* virtual address of handler */ 584a47a12beSStefan Roese lwz r23,4(r23) /* where to go when done */ 585a47a12beSStefan Roese mtspr SRR0,r24 586a47a12beSStefan Roese mtspr SRR1,r20 587a47a12beSStefan Roese mtlr r23 588a47a12beSStefan Roese SYNC 589a47a12beSStefan Roese rfi /* jump to handler, enable MMU */ 590a47a12beSStefan Roese 591a47a12beSStefan Roeseint_return: 592a47a12beSStefan Roese mfmsr r28 /* Disable interrupts */ 593a47a12beSStefan Roese li r4,0 594a47a12beSStefan Roese ori r4,r4,MSR_EE 595a47a12beSStefan Roese andc r28,r28,r4 596a47a12beSStefan Roese SYNC /* Some chip revs need this... */ 597a47a12beSStefan Roese mtmsr r28 598a47a12beSStefan Roese SYNC 599a47a12beSStefan Roese lwz r2,_CTR(r1) 600a47a12beSStefan Roese lwz r0,_LINK(r1) 601a47a12beSStefan Roese mtctr r2 602a47a12beSStefan Roese mtlr r0 603a47a12beSStefan Roese lwz r2,_XER(r1) 604a47a12beSStefan Roese lwz r0,_CCR(r1) 605a47a12beSStefan Roese mtspr XER,r2 606a47a12beSStefan Roese mtcrf 0xFF,r0 607a47a12beSStefan Roese REST_10GPRS(3, r1) 608a47a12beSStefan Roese REST_10GPRS(13, r1) 609a47a12beSStefan Roese REST_8GPRS(23, r1) 610a47a12beSStefan Roese REST_GPR(31, r1) 611a47a12beSStefan Roese lwz r2,_NIP(r1) /* Restore environment */ 612a47a12beSStefan Roese lwz r0,_MSR(r1) 613a47a12beSStefan Roese mtspr SRR0,r2 614a47a12beSStefan Roese mtspr SRR1,r0 615a47a12beSStefan Roese lwz r0,GPR0(r1) 616a47a12beSStefan Roese lwz r2,GPR2(r1) 617a47a12beSStefan Roese lwz r1,GPR1(r1) 618a47a12beSStefan Roese SYNC 619a47a12beSStefan Roese rfi 620a47a12beSStefan Roese 621a47a12beSStefan Roesecrit_return: 622a47a12beSStefan Roese mfmsr r28 /* Disable interrupts */ 623a47a12beSStefan Roese li r4,0 624a47a12beSStefan Roese ori r4,r4,MSR_EE 625a47a12beSStefan Roese andc r28,r28,r4 626a47a12beSStefan Roese SYNC /* Some chip revs need this... */ 627a47a12beSStefan Roese mtmsr r28 628a47a12beSStefan Roese SYNC 629a47a12beSStefan Roese lwz r2,_CTR(r1) 630a47a12beSStefan Roese lwz r0,_LINK(r1) 631a47a12beSStefan Roese mtctr r2 632a47a12beSStefan Roese mtlr r0 633a47a12beSStefan Roese lwz r2,_XER(r1) 634a47a12beSStefan Roese lwz r0,_CCR(r1) 635a47a12beSStefan Roese mtspr XER,r2 636a47a12beSStefan Roese mtcrf 0xFF,r0 637a47a12beSStefan Roese REST_10GPRS(3, r1) 638a47a12beSStefan Roese REST_10GPRS(13, r1) 639a47a12beSStefan Roese REST_8GPRS(23, r1) 640a47a12beSStefan Roese REST_GPR(31, r1) 641a47a12beSStefan Roese lwz r2,_NIP(r1) /* Restore environment */ 642a47a12beSStefan Roese lwz r0,_MSR(r1) 643a47a12beSStefan Roese mtspr SPRN_CSRR0,r2 644a47a12beSStefan Roese mtspr SPRN_CSRR1,r0 645a47a12beSStefan Roese lwz r0,GPR0(r1) 646a47a12beSStefan Roese lwz r2,GPR2(r1) 647a47a12beSStefan Roese lwz r1,GPR1(r1) 648a47a12beSStefan Roese SYNC 649a47a12beSStefan Roese rfci 650a47a12beSStefan Roese 651a47a12beSStefan Roesemck_return: 652a47a12beSStefan Roese mfmsr r28 /* Disable interrupts */ 653a47a12beSStefan Roese li r4,0 654a47a12beSStefan Roese ori r4,r4,MSR_EE 655a47a12beSStefan Roese andc r28,r28,r4 656a47a12beSStefan Roese SYNC /* Some chip revs need this... */ 657a47a12beSStefan Roese mtmsr r28 658a47a12beSStefan Roese SYNC 659a47a12beSStefan Roese lwz r2,_CTR(r1) 660a47a12beSStefan Roese lwz r0,_LINK(r1) 661a47a12beSStefan Roese mtctr r2 662a47a12beSStefan Roese mtlr r0 663a47a12beSStefan Roese lwz r2,_XER(r1) 664a47a12beSStefan Roese lwz r0,_CCR(r1) 665a47a12beSStefan Roese mtspr XER,r2 666a47a12beSStefan Roese mtcrf 0xFF,r0 667a47a12beSStefan Roese REST_10GPRS(3, r1) 668a47a12beSStefan Roese REST_10GPRS(13, r1) 669a47a12beSStefan Roese REST_8GPRS(23, r1) 670a47a12beSStefan Roese REST_GPR(31, r1) 671a47a12beSStefan Roese lwz r2,_NIP(r1) /* Restore environment */ 672a47a12beSStefan Roese lwz r0,_MSR(r1) 673a47a12beSStefan Roese mtspr SPRN_MCSRR0,r2 674a47a12beSStefan Roese mtspr SPRN_MCSRR1,r0 675a47a12beSStefan Roese lwz r0,GPR0(r1) 676a47a12beSStefan Roese lwz r2,GPR2(r1) 677a47a12beSStefan Roese lwz r1,GPR1(r1) 678a47a12beSStefan Roese SYNC 679a47a12beSStefan Roese rfmci 680a47a12beSStefan Roese 681a47a12beSStefan Roese/* Cache functions. 682a47a12beSStefan Roese*/ 683a47a12beSStefan Roese.globl invalidate_icache 684a47a12beSStefan Roeseinvalidate_icache: 685a47a12beSStefan Roese mfspr r0,L1CSR1 686a47a12beSStefan Roese ori r0,r0,L1CSR1_ICFI 687a47a12beSStefan Roese msync 688a47a12beSStefan Roese isync 689a47a12beSStefan Roese mtspr L1CSR1,r0 690a47a12beSStefan Roese isync 691a47a12beSStefan Roese blr /* entire I cache */ 692a47a12beSStefan Roese 693a47a12beSStefan Roese.globl invalidate_dcache 694a47a12beSStefan Roeseinvalidate_dcache: 695a47a12beSStefan Roese mfspr r0,L1CSR0 696a47a12beSStefan Roese ori r0,r0,L1CSR0_DCFI 697a47a12beSStefan Roese msync 698a47a12beSStefan Roese isync 699a47a12beSStefan Roese mtspr L1CSR0,r0 700a47a12beSStefan Roese isync 701a47a12beSStefan Roese blr 702a47a12beSStefan Roese 703a47a12beSStefan Roese .globl icache_enable 704a47a12beSStefan Roeseicache_enable: 705a47a12beSStefan Roese mflr r8 706a47a12beSStefan Roese bl invalidate_icache 707a47a12beSStefan Roese mtlr r8 708a47a12beSStefan Roese isync 709a47a12beSStefan Roese mfspr r4,L1CSR1 710a47a12beSStefan Roese ori r4,r4,0x0001 711a47a12beSStefan Roese oris r4,r4,0x0001 712a47a12beSStefan Roese mtspr L1CSR1,r4 713a47a12beSStefan Roese isync 714a47a12beSStefan Roese blr 715a47a12beSStefan Roese 716a47a12beSStefan Roese .globl icache_disable 717a47a12beSStefan Roeseicache_disable: 718a47a12beSStefan Roese mfspr r0,L1CSR1 719a47a12beSStefan Roese lis r3,0 720a47a12beSStefan Roese ori r3,r3,L1CSR1_ICE 721a47a12beSStefan Roese andc r0,r0,r3 722a47a12beSStefan Roese mtspr L1CSR1,r0 723a47a12beSStefan Roese isync 724a47a12beSStefan Roese blr 725a47a12beSStefan Roese 726a47a12beSStefan Roese .globl icache_status 727a47a12beSStefan Roeseicache_status: 728a47a12beSStefan Roese mfspr r3,L1CSR1 729a47a12beSStefan Roese andi. r3,r3,L1CSR1_ICE 730a47a12beSStefan Roese blr 731a47a12beSStefan Roese 732a47a12beSStefan Roese .globl dcache_enable 733a47a12beSStefan Roesedcache_enable: 734a47a12beSStefan Roese mflr r8 735a47a12beSStefan Roese bl invalidate_dcache 736a47a12beSStefan Roese mtlr r8 737a47a12beSStefan Roese isync 738a47a12beSStefan Roese mfspr r0,L1CSR0 739a47a12beSStefan Roese ori r0,r0,0x0001 740a47a12beSStefan Roese oris r0,r0,0x0001 741a47a12beSStefan Roese msync 742a47a12beSStefan Roese isync 743a47a12beSStefan Roese mtspr L1CSR0,r0 744a47a12beSStefan Roese isync 745a47a12beSStefan Roese blr 746a47a12beSStefan Roese 747a47a12beSStefan Roese .globl dcache_disable 748a47a12beSStefan Roesedcache_disable: 749a47a12beSStefan Roese mfspr r3,L1CSR0 750a47a12beSStefan Roese lis r4,0 751a47a12beSStefan Roese ori r4,r4,L1CSR0_DCE 752a47a12beSStefan Roese andc r3,r3,r4 753a47a12beSStefan Roese mtspr L1CSR0,r0 754a47a12beSStefan Roese isync 755a47a12beSStefan Roese blr 756a47a12beSStefan Roese 757a47a12beSStefan Roese .globl dcache_status 758a47a12beSStefan Roesedcache_status: 759a47a12beSStefan Roese mfspr r3,L1CSR0 760a47a12beSStefan Roese andi. r3,r3,L1CSR0_DCE 761a47a12beSStefan Roese blr 762a47a12beSStefan Roese 763a47a12beSStefan Roese .globl get_pir 764a47a12beSStefan Roeseget_pir: 765a47a12beSStefan Roese mfspr r3,PIR 766a47a12beSStefan Roese blr 767a47a12beSStefan Roese 768a47a12beSStefan Roese .globl get_pvr 769a47a12beSStefan Roeseget_pvr: 770a47a12beSStefan Roese mfspr r3,PVR 771a47a12beSStefan Roese blr 772a47a12beSStefan Roese 773a47a12beSStefan Roese .globl get_svr 774a47a12beSStefan Roeseget_svr: 775a47a12beSStefan Roese mfspr r3,SVR 776a47a12beSStefan Roese blr 777a47a12beSStefan Roese 778a47a12beSStefan Roese .globl wr_tcr 779a47a12beSStefan Roesewr_tcr: 780a47a12beSStefan Roese mtspr TCR,r3 781a47a12beSStefan Roese blr 782a47a12beSStefan Roese 783a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 784a47a12beSStefan Roese/* Function: in8 */ 785a47a12beSStefan Roese/* Description: Input 8 bits */ 786a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 787a47a12beSStefan Roese .globl in8 788a47a12beSStefan Roesein8: 789a47a12beSStefan Roese lbz r3,0x0000(r3) 790a47a12beSStefan Roese blr 791a47a12beSStefan Roese 792a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 793a47a12beSStefan Roese/* Function: out8 */ 794a47a12beSStefan Roese/* Description: Output 8 bits */ 795a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 796a47a12beSStefan Roese .globl out8 797a47a12beSStefan Roeseout8: 798a47a12beSStefan Roese stb r4,0x0000(r3) 799a47a12beSStefan Roese sync 800a47a12beSStefan Roese blr 801a47a12beSStefan Roese 802a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 803a47a12beSStefan Roese/* Function: out16 */ 804a47a12beSStefan Roese/* Description: Output 16 bits */ 805a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 806a47a12beSStefan Roese .globl out16 807a47a12beSStefan Roeseout16: 808a47a12beSStefan Roese sth r4,0x0000(r3) 809a47a12beSStefan Roese sync 810a47a12beSStefan Roese blr 811a47a12beSStefan Roese 812a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 813a47a12beSStefan Roese/* Function: out16r */ 814a47a12beSStefan Roese/* Description: Byte reverse and output 16 bits */ 815a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 816a47a12beSStefan Roese .globl out16r 817a47a12beSStefan Roeseout16r: 818a47a12beSStefan Roese sthbrx r4,r0,r3 819a47a12beSStefan Roese sync 820a47a12beSStefan Roese blr 821a47a12beSStefan Roese 822a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 823a47a12beSStefan Roese/* Function: out32 */ 824a47a12beSStefan Roese/* Description: Output 32 bits */ 825a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 826a47a12beSStefan Roese .globl out32 827a47a12beSStefan Roeseout32: 828a47a12beSStefan Roese stw r4,0x0000(r3) 829a47a12beSStefan Roese sync 830a47a12beSStefan Roese blr 831a47a12beSStefan Roese 832a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 833a47a12beSStefan Roese/* Function: out32r */ 834a47a12beSStefan Roese/* Description: Byte reverse and output 32 bits */ 835a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 836a47a12beSStefan Roese .globl out32r 837a47a12beSStefan Roeseout32r: 838a47a12beSStefan Roese stwbrx r4,r0,r3 839a47a12beSStefan Roese sync 840a47a12beSStefan Roese blr 841a47a12beSStefan Roese 842a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 843a47a12beSStefan Roese/* Function: in16 */ 844a47a12beSStefan Roese/* Description: Input 16 bits */ 845a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 846a47a12beSStefan Roese .globl in16 847a47a12beSStefan Roesein16: 848a47a12beSStefan Roese lhz r3,0x0000(r3) 849a47a12beSStefan Roese blr 850a47a12beSStefan Roese 851a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 852a47a12beSStefan Roese/* Function: in16r */ 853a47a12beSStefan Roese/* Description: Input 16 bits and byte reverse */ 854a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 855a47a12beSStefan Roese .globl in16r 856a47a12beSStefan Roesein16r: 857a47a12beSStefan Roese lhbrx r3,r0,r3 858a47a12beSStefan Roese blr 859a47a12beSStefan Roese 860a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 861a47a12beSStefan Roese/* Function: in32 */ 862a47a12beSStefan Roese/* Description: Input 32 bits */ 863a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 864a47a12beSStefan Roese .globl in32 865a47a12beSStefan Roesein32: 866a47a12beSStefan Roese lwz 3,0x0000(3) 867a47a12beSStefan Roese blr 868a47a12beSStefan Roese 869a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 870a47a12beSStefan Roese/* Function: in32r */ 871a47a12beSStefan Roese/* Description: Input 32 bits and byte reverse */ 872a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 873a47a12beSStefan Roese .globl in32r 874a47a12beSStefan Roesein32r: 875a47a12beSStefan Roese lwbrx r3,r0,r3 876a47a12beSStefan Roese blr 877a47a12beSStefan Roese#endif /* !CONFIG_NAND_SPL */ 878a47a12beSStefan Roese 879a47a12beSStefan Roese/*------------------------------------------------------------------------------*/ 880a47a12beSStefan Roese 881a47a12beSStefan Roese/* 882a47a12beSStefan Roese * void write_tlb(mas0, mas1, mas2, mas3, mas7) 883a47a12beSStefan Roese */ 884a47a12beSStefan Roese .globl write_tlb 885a47a12beSStefan Roesewrite_tlb: 886a47a12beSStefan Roese mtspr MAS0,r3 887a47a12beSStefan Roese mtspr MAS1,r4 888a47a12beSStefan Roese mtspr MAS2,r5 889a47a12beSStefan Roese mtspr MAS3,r6 890a47a12beSStefan Roese#ifdef CONFIG_ENABLE_36BIT_PHYS 891a47a12beSStefan Roese mtspr MAS7,r7 892a47a12beSStefan Roese#endif 893a47a12beSStefan Roese li r3,0 894a47a12beSStefan Roese#ifdef CONFIG_SYS_BOOK3E_HV 895a47a12beSStefan Roese mtspr MAS8,r3 896a47a12beSStefan Roese#endif 897a47a12beSStefan Roese isync 898a47a12beSStefan Roese tlbwe 899a47a12beSStefan Roese msync 900a47a12beSStefan Roese isync 901a47a12beSStefan Roese blr 902a47a12beSStefan Roese 903a47a12beSStefan Roese/* 904a47a12beSStefan Roese * void relocate_code (addr_sp, gd, addr_moni) 905a47a12beSStefan Roese * 906a47a12beSStefan Roese * This "function" does not return, instead it continues in RAM 907a47a12beSStefan Roese * after relocating the monitor code. 908a47a12beSStefan Roese * 909a47a12beSStefan Roese * r3 = dest 910a47a12beSStefan Roese * r4 = src 911a47a12beSStefan Roese * r5 = length in bytes 912a47a12beSStefan Roese * r6 = cachelinesize 913a47a12beSStefan Roese */ 914a47a12beSStefan Roese .globl relocate_code 915a47a12beSStefan Roeserelocate_code: 916a47a12beSStefan Roese mr r1,r3 /* Set new stack pointer */ 917a47a12beSStefan Roese mr r9,r4 /* Save copy of Init Data pointer */ 918a47a12beSStefan Roese mr r10,r5 /* Save copy of Destination Address */ 919a47a12beSStefan Roese 920a47a12beSStefan Roese GET_GOT 921a47a12beSStefan Roese mr r3,r5 /* Destination Address */ 922a47a12beSStefan Roese lis r4,CONFIG_SYS_MONITOR_BASE@h /* Source Address */ 923a47a12beSStefan Roese ori r4,r4,CONFIG_SYS_MONITOR_BASE@l 924a47a12beSStefan Roese lwz r5,GOT(__init_end) 925a47a12beSStefan Roese sub r5,r5,r4 926a47a12beSStefan Roese li r6,CONFIG_SYS_CACHELINE_SIZE /* Cache Line Size */ 927a47a12beSStefan Roese 928a47a12beSStefan Roese /* 929a47a12beSStefan Roese * Fix GOT pointer: 930a47a12beSStefan Roese * 931a47a12beSStefan Roese * New GOT-PTR = (old GOT-PTR - CONFIG_SYS_MONITOR_BASE) + Destination Address 932a47a12beSStefan Roese * 933a47a12beSStefan Roese * Offset: 934a47a12beSStefan Roese */ 935a47a12beSStefan Roese sub r15,r10,r4 936a47a12beSStefan Roese 937a47a12beSStefan Roese /* First our own GOT */ 938a47a12beSStefan Roese add r12,r12,r15 939a47a12beSStefan Roese /* the the one used by the C code */ 940a47a12beSStefan Roese add r30,r30,r15 941a47a12beSStefan Roese 942a47a12beSStefan Roese /* 943a47a12beSStefan Roese * Now relocate code 944a47a12beSStefan Roese */ 945a47a12beSStefan Roese 946a47a12beSStefan Roese cmplw cr1,r3,r4 947a47a12beSStefan Roese addi r0,r5,3 948a47a12beSStefan Roese srwi. r0,r0,2 949a47a12beSStefan Roese beq cr1,4f /* In place copy is not necessary */ 950a47a12beSStefan Roese beq 7f /* Protect against 0 count */ 951a47a12beSStefan Roese mtctr r0 952a47a12beSStefan Roese bge cr1,2f 953a47a12beSStefan Roese 954a47a12beSStefan Roese la r8,-4(r4) 955a47a12beSStefan Roese la r7,-4(r3) 956a47a12beSStefan Roese1: lwzu r0,4(r8) 957a47a12beSStefan Roese stwu r0,4(r7) 958a47a12beSStefan Roese bdnz 1b 959a47a12beSStefan Roese b 4f 960a47a12beSStefan Roese 961a47a12beSStefan Roese2: slwi r0,r0,2 962a47a12beSStefan Roese add r8,r4,r0 963a47a12beSStefan Roese add r7,r3,r0 964a47a12beSStefan Roese3: lwzu r0,-4(r8) 965a47a12beSStefan Roese stwu r0,-4(r7) 966a47a12beSStefan Roese bdnz 3b 967a47a12beSStefan Roese 968a47a12beSStefan Roese/* 969a47a12beSStefan Roese * Now flush the cache: note that we must start from a cache aligned 970a47a12beSStefan Roese * address. Otherwise we might miss one cache line. 971a47a12beSStefan Roese */ 972a47a12beSStefan Roese4: cmpwi r6,0 973a47a12beSStefan Roese add r5,r3,r5 974a47a12beSStefan Roese beq 7f /* Always flush prefetch queue in any case */ 975a47a12beSStefan Roese subi r0,r6,1 976a47a12beSStefan Roese andc r3,r3,r0 977a47a12beSStefan Roese mr r4,r3 978a47a12beSStefan Roese5: dcbst 0,r4 979a47a12beSStefan Roese add r4,r4,r6 980a47a12beSStefan Roese cmplw r4,r5 981a47a12beSStefan Roese blt 5b 982a47a12beSStefan Roese sync /* Wait for all dcbst to complete on bus */ 983a47a12beSStefan Roese mr r4,r3 984a47a12beSStefan Roese6: icbi 0,r4 985a47a12beSStefan Roese add r4,r4,r6 986a47a12beSStefan Roese cmplw r4,r5 987a47a12beSStefan Roese blt 6b 988a47a12beSStefan Roese7: sync /* Wait for all icbi to complete on bus */ 989a47a12beSStefan Roese isync 990a47a12beSStefan Roese 991a47a12beSStefan Roese /* 992a47a12beSStefan Roese * Re-point the IVPR at RAM 993a47a12beSStefan Roese */ 994a47a12beSStefan Roese mtspr IVPR,r10 995a47a12beSStefan Roese 996a47a12beSStefan Roese/* 997a47a12beSStefan Roese * We are done. Do not return, instead branch to second part of board 998a47a12beSStefan Roese * initialization, now running from RAM. 999a47a12beSStefan Roese */ 1000a47a12beSStefan Roese 1001a47a12beSStefan Roese addi r0,r10,in_ram - _start + _START_OFFSET 1002a47a12beSStefan Roese mtlr r0 1003a47a12beSStefan Roese blr /* NEVER RETURNS! */ 1004a47a12beSStefan Roese .globl in_ram 1005a47a12beSStefan Roesein_ram: 1006a47a12beSStefan Roese 1007a47a12beSStefan Roese /* 1008a47a12beSStefan Roese * Relocation Function, r12 point to got2+0x8000 1009a47a12beSStefan Roese * 1010a47a12beSStefan Roese * Adjust got2 pointers, no need to check for 0, this code 1011a47a12beSStefan Roese * already puts a few entries in the table. 1012a47a12beSStefan Roese */ 1013a47a12beSStefan Roese li r0,__got2_entries@sectoff@l 1014a47a12beSStefan Roese la r3,GOT(_GOT2_TABLE_) 1015a47a12beSStefan Roese lwz r11,GOT(_GOT2_TABLE_) 1016a47a12beSStefan Roese mtctr r0 1017a47a12beSStefan Roese sub r11,r3,r11 1018a47a12beSStefan Roese addi r3,r3,-4 1019a47a12beSStefan Roese1: lwzu r0,4(r3) 1020a47a12beSStefan Roese cmpwi r0,0 1021a47a12beSStefan Roese beq- 2f 1022a47a12beSStefan Roese add r0,r0,r11 1023a47a12beSStefan Roese stw r0,0(r3) 1024a47a12beSStefan Roese2: bdnz 1b 1025a47a12beSStefan Roese 1026a47a12beSStefan Roese /* 1027a47a12beSStefan Roese * Now adjust the fixups and the pointers to the fixups 1028a47a12beSStefan Roese * in case we need to move ourselves again. 1029a47a12beSStefan Roese */ 1030a47a12beSStefan Roese li r0,__fixup_entries@sectoff@l 1031a47a12beSStefan Roese lwz r3,GOT(_FIXUP_TABLE_) 1032a47a12beSStefan Roese cmpwi r0,0 1033a47a12beSStefan Roese mtctr r0 1034a47a12beSStefan Roese addi r3,r3,-4 1035a47a12beSStefan Roese beq 4f 1036a47a12beSStefan Roese3: lwzu r4,4(r3) 1037a47a12beSStefan Roese lwzux r0,r4,r11 1038a47a12beSStefan Roese add r0,r0,r11 1039a47a12beSStefan Roese stw r10,0(r3) 1040a47a12beSStefan Roese stw r0,0(r4) 1041a47a12beSStefan Roese bdnz 3b 1042a47a12beSStefan Roese4: 1043a47a12beSStefan Roeseclear_bss: 1044a47a12beSStefan Roese /* 1045a47a12beSStefan Roese * Now clear BSS segment 1046a47a12beSStefan Roese */ 1047a47a12beSStefan Roese lwz r3,GOT(__bss_start) 1048a47a12beSStefan Roese lwz r4,GOT(_end) 1049a47a12beSStefan Roese 1050a47a12beSStefan Roese cmplw 0,r3,r4 1051a47a12beSStefan Roese beq 6f 1052a47a12beSStefan Roese 1053a47a12beSStefan Roese li r0,0 1054a47a12beSStefan Roese5: 1055a47a12beSStefan Roese stw r0,0(r3) 1056a47a12beSStefan Roese addi r3,r3,4 1057a47a12beSStefan Roese cmplw 0,r3,r4 1058a47a12beSStefan Roese bne 5b 1059a47a12beSStefan Roese6: 1060a47a12beSStefan Roese 1061a47a12beSStefan Roese mr r3,r9 /* Init Data pointer */ 1062a47a12beSStefan Roese mr r4,r10 /* Destination Address */ 1063a47a12beSStefan Roese bl board_init_r 1064a47a12beSStefan Roese 1065a47a12beSStefan Roese#ifndef CONFIG_NAND_SPL 1066a47a12beSStefan Roese /* 1067a47a12beSStefan Roese * Copy exception vector code to low memory 1068a47a12beSStefan Roese * 1069a47a12beSStefan Roese * r3: dest_addr 1070a47a12beSStefan Roese * r7: source address, r8: end address, r9: target address 1071a47a12beSStefan Roese */ 1072a47a12beSStefan Roese .globl trap_init 1073a47a12beSStefan Roesetrap_init: 1074a47a12beSStefan Roese mflr r4 /* save link register */ 1075a47a12beSStefan Roese GET_GOT 1076a47a12beSStefan Roese lwz r7,GOT(_start_of_vectors) 1077a47a12beSStefan Roese lwz r8,GOT(_end_of_vectors) 1078a47a12beSStefan Roese 1079a47a12beSStefan Roese li r9,0x100 /* reset vector always at 0x100 */ 1080a47a12beSStefan Roese 1081a47a12beSStefan Roese cmplw 0,r7,r8 1082a47a12beSStefan Roese bgelr /* return if r7>=r8 - just in case */ 1083a47a12beSStefan Roese1: 1084a47a12beSStefan Roese lwz r0,0(r7) 1085a47a12beSStefan Roese stw r0,0(r9) 1086a47a12beSStefan Roese addi r7,r7,4 1087a47a12beSStefan Roese addi r9,r9,4 1088a47a12beSStefan Roese cmplw 0,r7,r8 1089a47a12beSStefan Roese bne 1b 1090a47a12beSStefan Roese 1091a47a12beSStefan Roese /* 1092a47a12beSStefan Roese * relocate `hdlr' and `int_return' entries 1093a47a12beSStefan Roese */ 1094a47a12beSStefan Roese li r7,.L_CriticalInput - _start + _START_OFFSET 1095a47a12beSStefan Roese bl trap_reloc 1096a47a12beSStefan Roese li r7,.L_MachineCheck - _start + _START_OFFSET 1097a47a12beSStefan Roese bl trap_reloc 1098a47a12beSStefan Roese li r7,.L_DataStorage - _start + _START_OFFSET 1099a47a12beSStefan Roese bl trap_reloc 1100a47a12beSStefan Roese li r7,.L_InstStorage - _start + _START_OFFSET 1101a47a12beSStefan Roese bl trap_reloc 1102a47a12beSStefan Roese li r7,.L_ExtInterrupt - _start + _START_OFFSET 1103a47a12beSStefan Roese bl trap_reloc 1104a47a12beSStefan Roese li r7,.L_Alignment - _start + _START_OFFSET 1105a47a12beSStefan Roese bl trap_reloc 1106a47a12beSStefan Roese li r7,.L_ProgramCheck - _start + _START_OFFSET 1107a47a12beSStefan Roese bl trap_reloc 1108a47a12beSStefan Roese li r7,.L_FPUnavailable - _start + _START_OFFSET 1109a47a12beSStefan Roese bl trap_reloc 1110a47a12beSStefan Roese li r7,.L_Decrementer - _start + _START_OFFSET 1111a47a12beSStefan Roese bl trap_reloc 1112a47a12beSStefan Roese li r7,.L_IntervalTimer - _start + _START_OFFSET 1113a47a12beSStefan Roese li r8,_end_of_vectors - _start + _START_OFFSET 1114a47a12beSStefan Roese2: 1115a47a12beSStefan Roese bl trap_reloc 1116a47a12beSStefan Roese addi r7,r7,0x100 /* next exception vector */ 1117a47a12beSStefan Roese cmplw 0,r7,r8 1118a47a12beSStefan Roese blt 2b 1119a47a12beSStefan Roese 1120a47a12beSStefan Roese lis r7,0x0 1121a47a12beSStefan Roese mtspr IVPR,r7 1122a47a12beSStefan Roese 1123a47a12beSStefan Roese mtlr r4 /* restore link register */ 1124a47a12beSStefan Roese blr 1125a47a12beSStefan Roese 1126a47a12beSStefan Roese.globl unlock_ram_in_cache 1127a47a12beSStefan Roeseunlock_ram_in_cache: 1128a47a12beSStefan Roese /* invalidate the INIT_RAM section */ 1129a47a12beSStefan Roese lis r3,(CONFIG_SYS_INIT_RAM_ADDR & ~(CONFIG_SYS_CACHELINE_SIZE-1))@h 1130a47a12beSStefan Roese ori r3,r3,(CONFIG_SYS_INIT_RAM_ADDR & ~(CONFIG_SYS_CACHELINE_SIZE-1))@l 1131a47a12beSStefan Roese mfspr r4,L1CFG0 1132a47a12beSStefan Roese andi. r4,r4,0x1ff 1133a47a12beSStefan Roese slwi r4,r4,(10 - 1 - L1_CACHE_SHIFT) 1134a47a12beSStefan Roese mtctr r4 1135a47a12beSStefan Roese1: dcbi r0,r3 1136a47a12beSStefan Roese addi r3,r3,CONFIG_SYS_CACHELINE_SIZE 1137a47a12beSStefan Roese bdnz 1b 1138a47a12beSStefan Roese sync 1139a47a12beSStefan Roese 1140a47a12beSStefan Roese /* Invalidate the TLB entries for the cache */ 1141a47a12beSStefan Roese lis r3,CONFIG_SYS_INIT_RAM_ADDR@h 1142a47a12beSStefan Roese ori r3,r3,CONFIG_SYS_INIT_RAM_ADDR@l 1143a47a12beSStefan Roese tlbivax 0,r3 1144a47a12beSStefan Roese addi r3,r3,0x1000 1145a47a12beSStefan Roese tlbivax 0,r3 1146a47a12beSStefan Roese addi r3,r3,0x1000 1147a47a12beSStefan Roese tlbivax 0,r3 1148a47a12beSStefan Roese addi r3,r3,0x1000 1149a47a12beSStefan Roese tlbivax 0,r3 1150a47a12beSStefan Roese isync 1151a47a12beSStefan Roese blr 1152a47a12beSStefan Roese 1153a47a12beSStefan Roese.globl flush_dcache 1154a47a12beSStefan Roeseflush_dcache: 1155a47a12beSStefan Roese mfspr r3,SPRN_L1CFG0 1156a47a12beSStefan Roese 1157a47a12beSStefan Roese rlwinm r5,r3,9,3 /* Extract cache block size */ 1158a47a12beSStefan Roese twlgti r5,1 /* Only 32 and 64 byte cache blocks 1159a47a12beSStefan Roese * are currently defined. 1160a47a12beSStefan Roese */ 1161a47a12beSStefan Roese li r4,32 1162a47a12beSStefan Roese subfic r6,r5,2 /* r6 = log2(1KiB / cache block size) - 1163a47a12beSStefan Roese * log2(number of ways) 1164a47a12beSStefan Roese */ 1165a47a12beSStefan Roese slw r5,r4,r5 /* r5 = cache block size */ 1166a47a12beSStefan Roese 1167a47a12beSStefan Roese rlwinm r7,r3,0,0xff /* Extract number of KiB in the cache */ 1168a47a12beSStefan Roese mulli r7,r7,13 /* An 8-way cache will require 13 1169a47a12beSStefan Roese * loads per set. 1170a47a12beSStefan Roese */ 1171a47a12beSStefan Roese slw r7,r7,r6 1172a47a12beSStefan Roese 1173a47a12beSStefan Roese /* save off HID0 and set DCFA */ 1174a47a12beSStefan Roese mfspr r8,SPRN_HID0 1175a47a12beSStefan Roese ori r9,r8,HID0_DCFA@l 1176a47a12beSStefan Roese mtspr SPRN_HID0,r9 1177a47a12beSStefan Roese isync 1178a47a12beSStefan Roese 1179a47a12beSStefan Roese lis r4,0 1180a47a12beSStefan Roese mtctr r7 1181a47a12beSStefan Roese 1182a47a12beSStefan Roese1: lwz r3,0(r4) /* Load... */ 1183a47a12beSStefan Roese add r4,r4,r5 1184a47a12beSStefan Roese bdnz 1b 1185a47a12beSStefan Roese 1186a47a12beSStefan Roese msync 1187a47a12beSStefan Roese lis r4,0 1188a47a12beSStefan Roese mtctr r7 1189a47a12beSStefan Roese 1190a47a12beSStefan Roese1: dcbf 0,r4 /* ...and flush. */ 1191a47a12beSStefan Roese add r4,r4,r5 1192a47a12beSStefan Roese bdnz 1b 1193a47a12beSStefan Roese 1194a47a12beSStefan Roese /* restore HID0 */ 1195a47a12beSStefan Roese mtspr SPRN_HID0,r8 1196a47a12beSStefan Roese isync 1197a47a12beSStefan Roese 1198a47a12beSStefan Roese blr 1199a47a12beSStefan Roese 1200a47a12beSStefan Roese.globl setup_ivors 1201a47a12beSStefan Roesesetup_ivors: 1202a47a12beSStefan Roese 1203a47a12beSStefan Roese#include "fixed_ivor.S" 1204a47a12beSStefan Roese blr 1205a47a12beSStefan Roese#endif /* !CONFIG_NAND_SPL */ 1206