1a47a12beSStefan Roese/* 2a4107f86SPrabhakar Kushwaha * Copyright 2004, 2007-2012 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 3125ddd1fbSWolfgang Denk#include <asm-offsets.h> 32a47a12beSStefan Roese#include <config.h> 33a47a12beSStefan Roese#include <mpc85xx.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#undef MSR_KERNEL 45a47a12beSStefan Roese#define MSR_KERNEL ( MSR_ME ) /* Machine Check */ 46a47a12beSStefan Roese 47a47a12beSStefan Roese/* 48a47a12beSStefan Roese * Set up GOT: Global Offset Table 49a47a12beSStefan Roese * 50a47a12beSStefan Roese * Use r12 to access the GOT 51a47a12beSStefan Roese */ 52a47a12beSStefan Roese START_GOT 53a47a12beSStefan Roese GOT_ENTRY(_GOT2_TABLE_) 54a47a12beSStefan Roese GOT_ENTRY(_FIXUP_TABLE_) 55a47a12beSStefan Roese 56a47a12beSStefan Roese#ifndef CONFIG_NAND_SPL 57a47a12beSStefan Roese GOT_ENTRY(_start) 58a47a12beSStefan Roese GOT_ENTRY(_start_of_vectors) 59a47a12beSStefan Roese GOT_ENTRY(_end_of_vectors) 60a47a12beSStefan Roese GOT_ENTRY(transfer_to_handler) 61a47a12beSStefan Roese#endif 62a47a12beSStefan Roese 63a47a12beSStefan Roese GOT_ENTRY(__init_end) 6444c6e659SPo-Yu Chuang GOT_ENTRY(__bss_end__) 65a47a12beSStefan Roese GOT_ENTRY(__bss_start) 66a47a12beSStefan Roese END_GOT 67a47a12beSStefan Roese 68a47a12beSStefan Roese/* 69a47a12beSStefan Roese * e500 Startup -- after reset only the last 4KB of the effective 70a47a12beSStefan Roese * address space is mapped in the MMU L2 TLB1 Entry0. The .bootpg 71a47a12beSStefan Roese * section is located at THIS LAST page and basically does three 72a47a12beSStefan Roese * things: clear some registers, set up exception tables and 73a47a12beSStefan Roese * add more TLB entries for 'larger spaces'(e.g. the boot rom) to 74a47a12beSStefan Roese * continue the boot procedure. 75a47a12beSStefan Roese 76a47a12beSStefan Roese * Once the boot rom is mapped by TLB entries we can proceed 77a47a12beSStefan Roese * with normal startup. 78a47a12beSStefan Roese * 79a47a12beSStefan Roese */ 80a47a12beSStefan Roese 81a47a12beSStefan Roese .section .bootpg,"ax" 82a47a12beSStefan Roese .globl _start_e500 83a47a12beSStefan Roese 84a47a12beSStefan Roese_start_e500: 855344f7a2SPrabhakar Kushwaha/* Enable debug exception */ 865344f7a2SPrabhakar Kushwaha li r1,MSR_DE 875344f7a2SPrabhakar Kushwaha mtmsr r1 88a47a12beSStefan Roese 8933eee330SScott Wood#ifdef CONFIG_SYS_FSL_ERRATUM_A004510 9033eee330SScott Wood mfspr r3,SPRN_SVR 9133eee330SScott Wood rlwinm r3,r3,0,0xff 9233eee330SScott Wood li r4,CONFIG_SYS_FSL_ERRATUM_A004510_SVR_REV 9333eee330SScott Wood cmpw r3,r4 9433eee330SScott Wood beq 1f 9533eee330SScott Wood 9633eee330SScott Wood#ifdef CONFIG_SYS_FSL_ERRATUM_A004510_SVR_REV2 9733eee330SScott Wood li r4,CONFIG_SYS_FSL_ERRATUM_A004510_SVR_REV2 9833eee330SScott Wood cmpw r3,r4 9933eee330SScott Wood beq 1f 10033eee330SScott Wood#endif 10133eee330SScott Wood 10233eee330SScott Wood /* Not a supported revision affected by erratum */ 10333eee330SScott Wood li r27,0 10433eee330SScott Wood b 2f 10533eee330SScott Wood 10633eee330SScott Wood1: li r27,1 /* Remember for later that we have the erratum */ 10733eee330SScott Wood /* Erratum says set bits 55:60 to 001001 */ 10833eee330SScott Wood msync 10933eee330SScott Wood isync 11033eee330SScott Wood mfspr r3,976 11133eee330SScott Wood li r4,0x48 11233eee330SScott Wood rlwimi r3,r4,0,0x1f8 11333eee330SScott Wood mtspr 976,r3 11433eee330SScott Wood isync 11533eee330SScott Wood2: 11633eee330SScott Wood#endif 11733eee330SScott Wood 1187065b7d4SRuchika Gupta#if defined(CONFIG_SECURE_BOOT) && defined(CONFIG_E500MC) 1197065b7d4SRuchika Gupta /* ISBC uses L2 as stack. 1207065b7d4SRuchika Gupta * Disable L2 cache here so that u-boot can enable it later 1217065b7d4SRuchika Gupta * as part of it's normal flow 1227065b7d4SRuchika Gupta */ 1237065b7d4SRuchika Gupta 1247065b7d4SRuchika Gupta /* Check if L2 is enabled */ 1257065b7d4SRuchika Gupta mfspr r3, SPRN_L2CSR0 1267065b7d4SRuchika Gupta lis r2, L2CSR0_L2E@h 1277065b7d4SRuchika Gupta ori r2, r2, L2CSR0_L2E@l 1287065b7d4SRuchika Gupta and. r4, r3, r2 1297065b7d4SRuchika Gupta beq l2_disabled 1307065b7d4SRuchika Gupta 1317065b7d4SRuchika Gupta mfspr r3, SPRN_L2CSR0 1327065b7d4SRuchika Gupta /* Flush L2 cache */ 1337065b7d4SRuchika Gupta lis r2,(L2CSR0_L2FL)@h 1347065b7d4SRuchika Gupta ori r2, r2, (L2CSR0_L2FL)@l 1357065b7d4SRuchika Gupta or r3, r2, r3 1367065b7d4SRuchika Gupta sync 1377065b7d4SRuchika Gupta isync 1387065b7d4SRuchika Gupta mtspr SPRN_L2CSR0,r3 1397065b7d4SRuchika Gupta isync 1407065b7d4SRuchika Gupta1: 1417065b7d4SRuchika Gupta mfspr r3, SPRN_L2CSR0 1427065b7d4SRuchika Gupta and. r1, r3, r2 1437065b7d4SRuchika Gupta bne 1b 1447065b7d4SRuchika Gupta 1457065b7d4SRuchika Gupta mfspr r3, SPRN_L2CSR0 1467065b7d4SRuchika Gupta lis r2, L2CSR0_L2E@h 1477065b7d4SRuchika Gupta ori r2, r2, L2CSR0_L2E@l 1487065b7d4SRuchika Gupta andc r4, r3, r2 1497065b7d4SRuchika Gupta sync 1507065b7d4SRuchika Gupta isync 1517065b7d4SRuchika Gupta mtspr SPRN_L2CSR0,r4 1527065b7d4SRuchika Gupta isync 1537065b7d4SRuchika Gupta 1547065b7d4SRuchika Guptal2_disabled: 1557065b7d4SRuchika Gupta#endif 1567065b7d4SRuchika Gupta 157a47a12beSStefan Roese/* clear registers/arrays not reset by hardware */ 158a47a12beSStefan Roese 159a47a12beSStefan Roese /* L1 */ 160a47a12beSStefan Roese li r0,2 161a47a12beSStefan Roese mtspr L1CSR0,r0 /* invalidate d-cache */ 162a47a12beSStefan Roese mtspr L1CSR1,r0 /* invalidate i-cache */ 163a47a12beSStefan Roese 164a47a12beSStefan Roese mfspr r1,DBSR 165a47a12beSStefan Roese mtspr DBSR,r1 /* Clear all valid bits */ 166a47a12beSStefan Roese 167a47a12beSStefan Roese /* 168a47a12beSStefan Roese * Enable L1 Caches early 169a47a12beSStefan Roese * 170a47a12beSStefan Roese */ 171a47a12beSStefan Roese 172*6d2b9da1SYork Sun#ifdef CONFIG_SYS_CACHE_STASHING 173a47a12beSStefan Roese /* set stash id to (coreID) * 2 + 32 + L1 CT (0) */ 174a47a12beSStefan Roese li r2,(32 + 0) 175a47a12beSStefan Roese mtspr L1CSR2,r2 176a47a12beSStefan Roese#endif 177a47a12beSStefan Roese 178a47a12beSStefan Roese /* Enable/invalidate the I-Cache */ 179a47a12beSStefan Roese lis r2,(L1CSR1_ICFI|L1CSR1_ICLFR)@h 180a47a12beSStefan Roese ori r2,r2,(L1CSR1_ICFI|L1CSR1_ICLFR)@l 181a47a12beSStefan Roese mtspr SPRN_L1CSR1,r2 182a47a12beSStefan Roese1: 183a47a12beSStefan Roese mfspr r3,SPRN_L1CSR1 184a47a12beSStefan Roese and. r1,r3,r2 185a47a12beSStefan Roese bne 1b 186a47a12beSStefan Roese 187a47a12beSStefan Roese lis r3,(L1CSR1_CPE|L1CSR1_ICE)@h 188a47a12beSStefan Roese ori r3,r3,(L1CSR1_CPE|L1CSR1_ICE)@l 189a47a12beSStefan Roese mtspr SPRN_L1CSR1,r3 190a47a12beSStefan Roese isync 191a47a12beSStefan Roese2: 192a47a12beSStefan Roese mfspr r3,SPRN_L1CSR1 193a47a12beSStefan Roese andi. r1,r3,L1CSR1_ICE@l 194a47a12beSStefan Roese beq 2b 195a47a12beSStefan Roese 196a47a12beSStefan Roese /* Enable/invalidate the D-Cache */ 197a47a12beSStefan Roese lis r2,(L1CSR0_DCFI|L1CSR0_DCLFR)@h 198a47a12beSStefan Roese ori r2,r2,(L1CSR0_DCFI|L1CSR0_DCLFR)@l 199a47a12beSStefan Roese mtspr SPRN_L1CSR0,r2 200a47a12beSStefan Roese1: 201a47a12beSStefan Roese mfspr r3,SPRN_L1CSR0 202a47a12beSStefan Roese and. r1,r3,r2 203a47a12beSStefan Roese bne 1b 204a47a12beSStefan Roese 205a47a12beSStefan Roese lis r3,(L1CSR0_CPE|L1CSR0_DCE)@h 206a47a12beSStefan Roese ori r3,r3,(L1CSR0_CPE|L1CSR0_DCE)@l 207a47a12beSStefan Roese mtspr SPRN_L1CSR0,r3 208a47a12beSStefan Roese isync 209a47a12beSStefan Roese2: 210a47a12beSStefan Roese mfspr r3,SPRN_L1CSR0 211a47a12beSStefan Roese andi. r1,r3,L1CSR0_DCE@l 212a47a12beSStefan Roese beq 2b 213a47a12beSStefan Roese 21469c78267SYork Sun .macro create_tlb1_entry esel ts tsize epn wimg rpn perm phy_high scratch 21569c78267SYork Sun lis \scratch, FSL_BOOKE_MAS0(1, \esel, 0)@h 21669c78267SYork Sun ori \scratch, \scratch, FSL_BOOKE_MAS0(1, \esel, 0)@l 21769c78267SYork Sun mtspr MAS0, \scratch 21869c78267SYork Sun lis \scratch, FSL_BOOKE_MAS1(1, 1, 0, \ts, \tsize)@h 21969c78267SYork Sun ori \scratch, \scratch, FSL_BOOKE_MAS1(1, 1, 0, \ts, \tsize)@l 22069c78267SYork Sun mtspr MAS1, \scratch 22169c78267SYork Sun lis \scratch, FSL_BOOKE_MAS2(\epn, \wimg)@h 22269c78267SYork Sun ori \scratch, \scratch, FSL_BOOKE_MAS2(\epn, \wimg)@l 22369c78267SYork Sun mtspr MAS2, \scratch 22469c78267SYork Sun lis \scratch, FSL_BOOKE_MAS3(\rpn, 0, \perm)@h 22569c78267SYork Sun ori \scratch, \scratch, FSL_BOOKE_MAS3(\rpn, 0, \perm)@l 22669c78267SYork Sun mtspr MAS3, \scratch 22769c78267SYork Sun lis \scratch, \phy_high@h 22869c78267SYork Sun ori \scratch, \scratch, \phy_high@l 22969c78267SYork Sun mtspr MAS7, \scratch 23069c78267SYork Sun isync 23169c78267SYork Sun msync 23269c78267SYork Sun tlbwe 23369c78267SYork Sun isync 23469c78267SYork Sun .endm 23569c78267SYork Sun 23669c78267SYork Sun .macro create_tlb0_entry esel ts tsize epn wimg rpn perm phy_high scratch 23769c78267SYork Sun lis \scratch, FSL_BOOKE_MAS0(0, \esel, 0)@h 23869c78267SYork Sun ori \scratch, \scratch, FSL_BOOKE_MAS0(0, \esel, 0)@l 23969c78267SYork Sun mtspr MAS0, \scratch 24069c78267SYork Sun lis \scratch, FSL_BOOKE_MAS1(1, 0, 0, \ts, \tsize)@h 24169c78267SYork Sun ori \scratch, \scratch, FSL_BOOKE_MAS1(1, 0, 0, \ts, \tsize)@l 24269c78267SYork Sun mtspr MAS1, \scratch 24369c78267SYork Sun lis \scratch, FSL_BOOKE_MAS2(\epn, \wimg)@h 24469c78267SYork Sun ori \scratch, \scratch, FSL_BOOKE_MAS2(\epn, \wimg)@l 24569c78267SYork Sun mtspr MAS2, \scratch 24669c78267SYork Sun lis \scratch, FSL_BOOKE_MAS3(\rpn, 0, \perm)@h 24769c78267SYork Sun ori \scratch, \scratch, FSL_BOOKE_MAS3(\rpn, 0, \perm)@l 24869c78267SYork Sun mtspr MAS3, \scratch 24969c78267SYork Sun lis \scratch, \phy_high@h 25069c78267SYork Sun ori \scratch, \scratch, \phy_high@l 25169c78267SYork Sun mtspr MAS7, \scratch 25269c78267SYork Sun isync 25369c78267SYork Sun msync 25469c78267SYork Sun tlbwe 25569c78267SYork Sun isync 25669c78267SYork Sun .endm 25769c78267SYork Sun 25869c78267SYork Sun .macro delete_tlb1_entry esel scratch 25969c78267SYork Sun lis \scratch, FSL_BOOKE_MAS0(1, \esel, 0)@h 26069c78267SYork Sun ori \scratch, \scratch, FSL_BOOKE_MAS0(1, \esel, 0)@l 26169c78267SYork Sun mtspr MAS0, \scratch 26269c78267SYork Sun li \scratch, 0 26369c78267SYork Sun mtspr MAS1, \scratch 26469c78267SYork Sun isync 26569c78267SYork Sun msync 26669c78267SYork Sun tlbwe 26769c78267SYork Sun isync 26869c78267SYork Sun .endm 26969c78267SYork Sun 27069c78267SYork Sun .macro delete_tlb0_entry esel epn wimg scratch 27169c78267SYork Sun lis \scratch, FSL_BOOKE_MAS0(0, \esel, 0)@h 27269c78267SYork Sun ori \scratch, \scratch, FSL_BOOKE_MAS0(0, \esel, 0)@l 27369c78267SYork Sun mtspr MAS0, \scratch 27469c78267SYork Sun li \scratch, 0 27569c78267SYork Sun mtspr MAS1, \scratch 27669c78267SYork Sun lis \scratch, FSL_BOOKE_MAS2(\epn, \wimg)@h 27769c78267SYork Sun ori \scratch, \scratch, FSL_BOOKE_MAS2(\epn, \wimg)@l 27869c78267SYork Sun mtspr MAS2, \scratch 27969c78267SYork Sun isync 28069c78267SYork Sun msync 28169c78267SYork Sun tlbwe 28269c78267SYork Sun isync 28369c78267SYork Sun .endm 28469c78267SYork Sun 285d16a37b8SPrabhakar Kushwaha#if defined(CONFIG_SYS_PPC_E500_DEBUG_TLB) && !defined(CONFIG_NAND_SPL) 286689f00fcSPrabhakar Kushwaha/* 287689f00fcSPrabhakar Kushwaha * TLB entry for debuggging in AS1 288689f00fcSPrabhakar Kushwaha * Create temporary TLB entry in AS0 to handle debug exception 289689f00fcSPrabhakar Kushwaha * As on debug exception MSR is cleared i.e. Address space is changed 290689f00fcSPrabhakar Kushwaha * to 0. A TLB entry (in AS0) is required to handle debug exception generated 291689f00fcSPrabhakar Kushwaha * in AS1. 292689f00fcSPrabhakar Kushwaha */ 293689f00fcSPrabhakar Kushwaha 294689f00fcSPrabhakar Kushwaha#if !defined(CONFIG_SYS_RAMBOOT) && !defined(CONFIG_SECURE_BOOT) 295689f00fcSPrabhakar Kushwaha/* 296689f00fcSPrabhakar Kushwaha * TLB entry is created for IVPR + IVOR15 to map on valid OP code address 297689f00fcSPrabhakar Kushwaha * bacause flash's virtual address maps to 0xff800000 - 0xffffffff. 298689f00fcSPrabhakar Kushwaha * and this window is outside of 4K boot window. 299689f00fcSPrabhakar Kushwaha */ 30069c78267SYork Sun create_tlb1_entry CONFIG_SYS_PPC_E500_DEBUG_TLB, \ 30169c78267SYork Sun 0, BOOKE_PAGESZ_4M, \ 30269c78267SYork Sun CONFIG_SYS_MONITOR_BASE & 0xffc00000, MAS2_I|MAS2_G, \ 30369c78267SYork Sun 0xffc00000, MAS3_SX|MAS3_SW|MAS3_SR, \ 30469c78267SYork Sun 0, r6 305689f00fcSPrabhakar Kushwaha 306689f00fcSPrabhakar Kushwaha#elif !defined(CONFIG_SYS_RAMBOOT) && defined(CONFIG_SECURE_BOOT) 30769c78267SYork Sun create_tlb1_entry CONFIG_SYS_PPC_E500_DEBUG_TLB, \ 30869c78267SYork Sun 0, BOOKE_PAGESZ_1M, \ 30969c78267SYork Sun CONFIG_SYS_MONITOR_BASE, MAS2_I|MAS2_G, \ 31069c78267SYork Sun CONFIG_SYS_PBI_FLASH_WINDOW, MAS3_SX|MAS3_SW|MAS3_SR, \ 31169c78267SYork Sun 0, r6 312689f00fcSPrabhakar Kushwaha#else 313689f00fcSPrabhakar Kushwaha/* 314689f00fcSPrabhakar Kushwaha * TLB entry is created for IVPR + IVOR15 to map on valid OP code address 315689f00fcSPrabhakar Kushwaha * because "nexti" will resize TLB to 4K 316689f00fcSPrabhakar Kushwaha */ 31769c78267SYork Sun create_tlb1_entry CONFIG_SYS_PPC_E500_DEBUG_TLB, \ 31869c78267SYork Sun 0, BOOKE_PAGESZ_256K, \ 31969c78267SYork Sun CONFIG_SYS_MONITOR_BASE, MAS2_I, \ 32069c78267SYork Sun CONFIG_SYS_MONITOR_BASE, MAS3_SX|MAS3_SW|MAS3_SR, \ 32169c78267SYork Sun 0, r6 322689f00fcSPrabhakar Kushwaha#endif 323689f00fcSPrabhakar Kushwaha#endif 324689f00fcSPrabhakar Kushwaha 325119a55f9SPrabhakar Kushwaha/* 326119a55f9SPrabhakar Kushwaha * Ne need to setup interrupt vector for NAND SPL 327119a55f9SPrabhakar Kushwaha * because NAND SPL never compiles it. 328119a55f9SPrabhakar Kushwaha */ 329119a55f9SPrabhakar Kushwaha#if !defined(CONFIG_NAND_SPL) 330a47a12beSStefan Roese /* Setup interrupt vectors */ 3310635b09cSHaiying Wang lis r1,CONFIG_SYS_MONITOR_BASE@h 332a47a12beSStefan Roese mtspr IVPR,r1 333a47a12beSStefan Roese 334a4107f86SPrabhakar Kushwaha lis r3,(CONFIG_SYS_MONITOR_BASE & 0xffff)@h 335a4107f86SPrabhakar Kushwaha ori r3,r3,(CONFIG_SYS_MONITOR_BASE & 0xffff)@l 336a4107f86SPrabhakar Kushwaha 337a4107f86SPrabhakar Kushwaha addi r4,r3,CriticalInput - _start + _START_OFFSET 338a4107f86SPrabhakar Kushwaha mtspr IVOR0,r4 /* 0: Critical input */ 339a4107f86SPrabhakar Kushwaha addi r4,r3,MachineCheck - _start + _START_OFFSET 340a4107f86SPrabhakar Kushwaha mtspr IVOR1,r4 /* 1: Machine check */ 341a4107f86SPrabhakar Kushwaha addi r4,r3,DataStorage - _start + _START_OFFSET 342a4107f86SPrabhakar Kushwaha mtspr IVOR2,r4 /* 2: Data storage */ 343a4107f86SPrabhakar Kushwaha addi r4,r3,InstStorage - _start + _START_OFFSET 344a4107f86SPrabhakar Kushwaha mtspr IVOR3,r4 /* 3: Instruction storage */ 345a4107f86SPrabhakar Kushwaha addi r4,r3,ExtInterrupt - _start + _START_OFFSET 346a4107f86SPrabhakar Kushwaha mtspr IVOR4,r4 /* 4: External interrupt */ 347a4107f86SPrabhakar Kushwaha addi r4,r3,Alignment - _start + _START_OFFSET 348a4107f86SPrabhakar Kushwaha mtspr IVOR5,r4 /* 5: Alignment */ 349a4107f86SPrabhakar Kushwaha addi r4,r3,ProgramCheck - _start + _START_OFFSET 350a4107f86SPrabhakar Kushwaha mtspr IVOR6,r4 /* 6: Program check */ 351a4107f86SPrabhakar Kushwaha addi r4,r3,FPUnavailable - _start + _START_OFFSET 352a4107f86SPrabhakar Kushwaha mtspr IVOR7,r4 /* 7: floating point unavailable */ 353a4107f86SPrabhakar Kushwaha addi r4,r3,SystemCall - _start + _START_OFFSET 354a4107f86SPrabhakar Kushwaha mtspr IVOR8,r4 /* 8: System call */ 355a47a12beSStefan Roese /* 9: Auxiliary processor unavailable(unsupported) */ 356a4107f86SPrabhakar Kushwaha addi r4,r3,Decrementer - _start + _START_OFFSET 357a4107f86SPrabhakar Kushwaha mtspr IVOR10,r4 /* 10: Decrementer */ 358a4107f86SPrabhakar Kushwaha addi r4,r3,IntervalTimer - _start + _START_OFFSET 359a4107f86SPrabhakar Kushwaha mtspr IVOR11,r4 /* 11: Interval timer */ 360a4107f86SPrabhakar Kushwaha addi r4,r3,WatchdogTimer - _start + _START_OFFSET 361a4107f86SPrabhakar Kushwaha mtspr IVOR12,r4 /* 12: Watchdog timer */ 362a4107f86SPrabhakar Kushwaha addi r4,r3,DataTLBError - _start + _START_OFFSET 363a4107f86SPrabhakar Kushwaha mtspr IVOR13,r4 /* 13: Data TLB error */ 364a4107f86SPrabhakar Kushwaha addi r4,r3,InstructionTLBError - _start + _START_OFFSET 365a4107f86SPrabhakar Kushwaha mtspr IVOR14,r4 /* 14: Instruction TLB error */ 366a4107f86SPrabhakar Kushwaha addi r4,r3,DebugBreakpoint - _start + _START_OFFSET 367a4107f86SPrabhakar Kushwaha mtspr IVOR15,r4 /* 15: Debug */ 368119a55f9SPrabhakar Kushwaha#endif 369a47a12beSStefan Roese 370a47a12beSStefan Roese /* Clear and set up some registers. */ 371a47a12beSStefan Roese li r0,0x0000 372a47a12beSStefan Roese lis r1,0xffff 373a47a12beSStefan Roese mtspr DEC,r0 /* prevent dec exceptions */ 374a47a12beSStefan Roese mttbl r0 /* prevent fit & wdt exceptions */ 375a47a12beSStefan Roese mttbu r0 376a47a12beSStefan Roese mtspr TSR,r1 /* clear all timer exception status */ 377a47a12beSStefan Roese mtspr TCR,r0 /* disable all */ 378a47a12beSStefan Roese mtspr ESR,r0 /* clear exception syndrome register */ 379a47a12beSStefan Roese mtspr MCSR,r0 /* machine check syndrome register */ 380a47a12beSStefan Roese mtxer r0 /* clear integer exception register */ 381a47a12beSStefan Roese 382a47a12beSStefan Roese#ifdef CONFIG_SYS_BOOK3E_HV 383a47a12beSStefan Roese mtspr MAS8,r0 /* make sure MAS8 is clear */ 384a47a12beSStefan Roese#endif 385a47a12beSStefan Roese 386a47a12beSStefan Roese /* Enable Time Base and Select Time Base Clock */ 387a47a12beSStefan Roese lis r0,HID0_EMCP@h /* Enable machine check */ 388a47a12beSStefan Roese#if defined(CONFIG_ENABLE_36BIT_PHYS) 389a47a12beSStefan Roese ori r0,r0,HID0_ENMAS7@l /* Enable MAS7 */ 390a47a12beSStefan Roese#endif 391a47a12beSStefan Roese#ifndef CONFIG_E500MC 392a47a12beSStefan Roese ori r0,r0,HID0_TBEN@l /* Enable Timebase */ 393a47a12beSStefan Roese#endif 394a47a12beSStefan Roese mtspr HID0,r0 395a47a12beSStefan Roese 396a47a12beSStefan Roese#ifndef CONFIG_E500MC 397a47a12beSStefan Roese li r0,(HID1_ASTME|HID1_ABE)@l /* Addr streaming & broadcast */ 398a47a12beSStefan Roese mfspr r3,PVR 399a47a12beSStefan Roese andi. r3,r3, 0xff 400a47a12beSStefan Roese cmpwi r3,0x50@l /* if we are rev 5.0 or greater set MBDD */ 401a47a12beSStefan Roese blt 1f 402a47a12beSStefan Roese /* Set MBDD bit also */ 403a47a12beSStefan Roese ori r0, r0, HID1_MBDD@l 404a47a12beSStefan Roese1: 405a47a12beSStefan Roese mtspr HID1,r0 406a47a12beSStefan Roese#endif 407a47a12beSStefan Roese 40843f082bbSKumar Gala#ifdef CONFIG_SYS_FSL_ERRATUM_CPU_A003999 40943f082bbSKumar Gala mfspr r3,977 41043f082bbSKumar Gala oris r3,r3,0x0100 41143f082bbSKumar Gala mtspr 977,r3 41243f082bbSKumar Gala#endif 41343f082bbSKumar Gala 414a47a12beSStefan Roese /* Enable Branch Prediction */ 415a47a12beSStefan Roese#if defined(CONFIG_BTB) 416a47a12beSStefan Roese lis r0,BUCSR_ENABLE@h 417a47a12beSStefan Roese ori r0,r0,BUCSR_ENABLE@l 418a47a12beSStefan Roese mtspr SPRN_BUCSR,r0 419a47a12beSStefan Roese#endif 420a47a12beSStefan Roese 421a47a12beSStefan Roese#if defined(CONFIG_SYS_INIT_DBCR) 422a47a12beSStefan Roese lis r1,0xffff 423a47a12beSStefan Roese ori r1,r1,0xffff 424a47a12beSStefan Roese mtspr DBSR,r1 /* Clear all status bits */ 425a47a12beSStefan Roese lis r0,CONFIG_SYS_INIT_DBCR@h /* DBCR0[IDM] must be set */ 426a47a12beSStefan Roese ori r0,r0,CONFIG_SYS_INIT_DBCR@l 427a47a12beSStefan Roese mtspr DBCR0,r0 428a47a12beSStefan Roese#endif 429a47a12beSStefan Roese 430a47a12beSStefan Roese#ifdef CONFIG_MPC8569 431a47a12beSStefan Roese#define CONFIG_SYS_LBC_ADDR (CONFIG_SYS_CCSRBAR_DEFAULT + 0x5000) 432a47a12beSStefan Roese#define CONFIG_SYS_LBCR_ADDR (CONFIG_SYS_LBC_ADDR + 0xd0) 433a47a12beSStefan Roese 434a47a12beSStefan Roese /* MPC8569 Rev.0 silcon needs to set bit 13 of LBCR to allow elBC to 435a47a12beSStefan Roese * use address space which is more than 12bits, and it must be done in 436a47a12beSStefan Roese * the 4K boot page. So we set this bit here. 437a47a12beSStefan Roese */ 438a47a12beSStefan Roese 439a47a12beSStefan Roese /* create a temp mapping TLB0[0] for LBCR */ 44069c78267SYork Sun create_tlb0_entry 0, \ 44169c78267SYork Sun 0, BOOKE_PAGESZ_4K, \ 44269c78267SYork Sun CONFIG_SYS_LBC_ADDR, MAS2_I|MAS2_G, \ 44369c78267SYork Sun CONFIG_SYS_LBC_ADDR, MAS3_SW|MAS3_SR, \ 44469c78267SYork Sun 0, r6 445a47a12beSStefan Roese 446a47a12beSStefan Roese /* Set LBCR register */ 447a47a12beSStefan Roese lis r4,CONFIG_SYS_LBCR_ADDR@h 448a47a12beSStefan Roese ori r4,r4,CONFIG_SYS_LBCR_ADDR@l 449a47a12beSStefan Roese 450a47a12beSStefan Roese lis r5,CONFIG_SYS_LBC_LBCR@h 451a47a12beSStefan Roese ori r5,r5,CONFIG_SYS_LBC_LBCR@l 452a47a12beSStefan Roese stw r5,0(r4) 453a47a12beSStefan Roese isync 454a47a12beSStefan Roese 455a47a12beSStefan Roese /* invalidate this temp TLB */ 456a47a12beSStefan Roese lis r4,CONFIG_SYS_LBC_ADDR@h 457a47a12beSStefan Roese ori r4,r4,CONFIG_SYS_LBC_ADDR@l 458a47a12beSStefan Roese tlbivax 0,r4 459a47a12beSStefan Roese isync 460a47a12beSStefan Roese 461a47a12beSStefan Roese#endif /* CONFIG_MPC8569 */ 462a47a12beSStefan Roese 4636ca88b09STimur Tabi/* 46472243c01STimur Tabi * Search for the TLB that covers the code we're executing, and shrink it 46572243c01STimur Tabi * so that it covers only this 4K page. That will ensure that any other 46672243c01STimur Tabi * TLB we create won't interfere with it. We assume that the TLB exists, 4673ea21536SScott Wood * which is why we don't check the Valid bit of MAS1. We also assume 4683ea21536SScott Wood * it is in TLB1. 46972243c01STimur Tabi * 47072243c01STimur Tabi * This is necessary, for example, when booting from the on-chip ROM, 47172243c01STimur Tabi * which (oddly) creates a single 4GB TLB that covers CCSR and DDR. 47272243c01STimur Tabi */ 47372243c01STimur Tabi bl nexti /* Find our address */ 47472243c01STimur Tabinexti: mflr r1 /* R1 = our PC */ 47572243c01STimur Tabi li r2, 0 47672243c01STimur Tabi mtspr MAS6, r2 /* Assume the current PID and AS are 0 */ 47772243c01STimur Tabi isync 47872243c01STimur Tabi msync 47972243c01STimur Tabi tlbsx 0, r1 /* This must succeed */ 48072243c01STimur Tabi 4813ea21536SScott Wood mfspr r14, MAS0 /* Save ESEL for later */ 4823ea21536SScott Wood rlwinm r14, r14, 16, 0xfff 4833ea21536SScott Wood 48472243c01STimur Tabi /* Set the size of the TLB to 4KB */ 48572243c01STimur Tabi mfspr r3, MAS1 48672243c01STimur Tabi li r2, 0xF00 48772243c01STimur Tabi andc r3, r3, r2 /* Clear the TSIZE bits */ 48872243c01STimur Tabi ori r3, r3, MAS1_TSIZE(BOOKE_PAGESZ_4K)@l 4893ea21536SScott Wood oris r3, r3, MAS1_IPROT@h 49072243c01STimur Tabi mtspr MAS1, r3 49172243c01STimur Tabi 49272243c01STimur Tabi /* 49372243c01STimur Tabi * Set the base address of the TLB to our PC. We assume that 49472243c01STimur Tabi * virtual == physical. We also assume that MAS2_EPN == MAS3_RPN. 49572243c01STimur Tabi */ 49672243c01STimur Tabi lis r3, MAS2_EPN@h 49772243c01STimur Tabi ori r3, r3, MAS2_EPN@l /* R3 = MAS2_EPN */ 49872243c01STimur Tabi 49972243c01STimur Tabi and r1, r1, r3 /* Our PC, rounded down to the nearest page */ 50072243c01STimur Tabi 50172243c01STimur Tabi mfspr r2, MAS2 50272243c01STimur Tabi andc r2, r2, r3 50372243c01STimur Tabi or r2, r2, r1 50433eee330SScott Wood#ifdef CONFIG_SYS_FSL_ERRATUM_A004510 50533eee330SScott Wood cmpwi r27,0 50633eee330SScott Wood beq 1f 50733eee330SScott Wood andi. r15, r2, MAS2_I|MAS2_G /* save the old I/G for later */ 50833eee330SScott Wood rlwinm r2, r2, 0, ~MAS2_I 50933eee330SScott Wood ori r2, r2, MAS2_G 51033eee330SScott Wood1: 51133eee330SScott Wood#endif 51272243c01STimur Tabi mtspr MAS2, r2 /* Set the EPN to our PC base address */ 51372243c01STimur Tabi 51472243c01STimur Tabi mfspr r2, MAS3 51572243c01STimur Tabi andc r2, r2, r3 51672243c01STimur Tabi or r2, r2, r1 51772243c01STimur Tabi mtspr MAS3, r2 /* Set the RPN to our PC base address */ 51872243c01STimur Tabi 51972243c01STimur Tabi isync 52072243c01STimur Tabi msync 52172243c01STimur Tabi tlbwe 52272243c01STimur Tabi 52372243c01STimur Tabi/* 5243ea21536SScott Wood * Clear out any other TLB entries that may exist, to avoid conflicts. 5253ea21536SScott Wood * Our TLB entry is in r14. 5263ea21536SScott Wood */ 5273ea21536SScott Wood li r0, TLBIVAX_ALL | TLBIVAX_TLB0 5283ea21536SScott Wood tlbivax 0, r0 5293ea21536SScott Wood tlbsync 5303ea21536SScott Wood 5313ea21536SScott Wood mfspr r4, SPRN_TLB1CFG 5323ea21536SScott Wood rlwinm r4, r4, 0, TLBnCFG_NENTRY_MASK 5333ea21536SScott Wood 5343ea21536SScott Wood li r3, 0 5353ea21536SScott Wood mtspr MAS1, r3 5363ea21536SScott Wood1: cmpw r3, r14 5373ea21536SScott Wood#if defined(CONFIG_SYS_PPC_E500_DEBUG_TLB) && !defined(CONFIG_NAND_SPL) 5383ea21536SScott Wood cmpwi cr1, r3, CONFIG_SYS_PPC_E500_DEBUG_TLB 5393ea21536SScott Wood cror cr0*4+eq, cr0*4+eq, cr1*4+eq 5403ea21536SScott Wood#endif 5413ea21536SScott Wood rlwinm r5, r3, 16, MAS0_ESEL_MSK 5423ea21536SScott Wood addi r3, r3, 1 5433ea21536SScott Wood beq 2f /* skip the entry we're executing from */ 5443ea21536SScott Wood 5453ea21536SScott Wood oris r5, r5, MAS0_TLBSEL(1)@h 5463ea21536SScott Wood mtspr MAS0, r5 5473ea21536SScott Wood 5483ea21536SScott Wood isync 5493ea21536SScott Wood tlbwe 5503ea21536SScott Wood isync 5513ea21536SScott Wood msync 5523ea21536SScott Wood 5533ea21536SScott Wood2: cmpw r3, r4 5543ea21536SScott Wood blt 1b 5553ea21536SScott Wood 5563ea21536SScott Wood/* 5576ca88b09STimur Tabi * Relocate CCSR, if necessary. We relocate CCSR if (obviously) the default 5586ca88b09STimur Tabi * location is not where we want it. This typically happens on a 36-bit 5596ca88b09STimur Tabi * system, where we want to move CCSR to near the top of 36-bit address space. 5606ca88b09STimur Tabi * 5616ca88b09STimur Tabi * To move CCSR, we create two temporary TLBs, one for the old location, and 5626ca88b09STimur Tabi * another for the new location. On CoreNet systems, we also need to create 5636ca88b09STimur Tabi * a special, temporary LAW. 5646ca88b09STimur Tabi * 5656ca88b09STimur Tabi * As a general rule, TLB0 is used for short-term TLBs, and TLB1 is used for 5666ca88b09STimur Tabi * long-term TLBs, so we use TLB0 here. 5676ca88b09STimur Tabi */ 5686ca88b09STimur Tabi#if (CONFIG_SYS_CCSRBAR_DEFAULT != CONFIG_SYS_CCSRBAR_PHYS) 5696ca88b09STimur Tabi 5706ca88b09STimur Tabi#if !defined(CONFIG_SYS_CCSRBAR_PHYS_HIGH) || !defined(CONFIG_SYS_CCSRBAR_PHYS_LOW) 5716ca88b09STimur Tabi#error "CONFIG_SYS_CCSRBAR_PHYS_HIGH and CONFIG_SYS_CCSRBAR_PHYS_LOW) must be defined." 5726ca88b09STimur Tabi#endif 5736ca88b09STimur Tabi 5746ca88b09STimur Tabicreate_ccsr_new_tlb: 5756ca88b09STimur Tabi /* 5766ca88b09STimur Tabi * Create a TLB for the new location of CCSR. Register R8 is reserved 5776ca88b09STimur Tabi * for the virtual address of this TLB (CONFIG_SYS_CCSRBAR). 5786ca88b09STimur Tabi */ 5793ea21536SScott Wood lis r8, CONFIG_SYS_CCSRBAR@h 5803ea21536SScott Wood ori r8, r8, CONFIG_SYS_CCSRBAR@l 5813ea21536SScott Wood lis r9, (CONFIG_SYS_CCSRBAR + 0x1000)@h 5823ea21536SScott Wood ori r9, r9, (CONFIG_SYS_CCSRBAR + 0x1000)@l 58369c78267SYork Sun create_tlb0_entry 0, \ 58469c78267SYork Sun 0, BOOKE_PAGESZ_4K, \ 58569c78267SYork Sun CONFIG_SYS_CCSRBAR, MAS2_I|MAS2_G, \ 58669c78267SYork Sun CONFIG_SYS_CCSRBAR_PHYS_LOW, MAS3_SW|MAS3_SR, \ 58769c78267SYork Sun CONFIG_SYS_CCSRBAR_PHYS_HIGH, r3 5886ca88b09STimur Tabi /* 589c2efa0aaSTimur Tabi * Create a TLB for the current location of CCSR. Register R9 is reserved 5906ca88b09STimur Tabi * for the virtual address of this TLB (CONFIG_SYS_CCSRBAR + 0x1000). 5916ca88b09STimur Tabi */ 5926ca88b09STimur Tabicreate_ccsr_old_tlb: 59369c78267SYork Sun create_tlb0_entry 1, \ 59469c78267SYork Sun 0, BOOKE_PAGESZ_4K, \ 59569c78267SYork Sun CONFIG_SYS_CCSRBAR + 0x1000, MAS2_I|MAS2_G, \ 59669c78267SYork Sun CONFIG_SYS_CCSRBAR_DEFAULT, MAS3_SW|MAS3_SR, \ 59769c78267SYork Sun 0, r3 /* The default CCSR address is always a 32-bit number */ 59869c78267SYork Sun 5996ca88b09STimur Tabi 60019e43841STimur Tabi /* 60119e43841STimur Tabi * We have a TLB for what we think is the current (old) CCSR. Let's 60219e43841STimur Tabi * verify that, otherwise we won't be able to move it. 60319e43841STimur Tabi * CONFIG_SYS_CCSRBAR_DEFAULT is always a 32-bit number, so we only 60419e43841STimur Tabi * need to compare the lower 32 bits of CCSRBAR on CoreNet systems. 60519e43841STimur Tabi */ 60619e43841STimur Tabiverify_old_ccsr: 60719e43841STimur Tabi lis r0, CONFIG_SYS_CCSRBAR_DEFAULT@h 60819e43841STimur Tabi ori r0, r0, CONFIG_SYS_CCSRBAR_DEFAULT@l 60919e43841STimur Tabi#ifdef CONFIG_FSL_CORENET 61019e43841STimur Tabi lwz r1, 4(r9) /* CCSRBARL */ 61119e43841STimur Tabi#else 61219e43841STimur Tabi lwz r1, 0(r9) /* CCSRBAR, shifted right by 12 */ 61319e43841STimur Tabi slwi r1, r1, 12 61419e43841STimur Tabi#endif 61519e43841STimur Tabi 61619e43841STimur Tabi cmpl 0, r0, r1 61719e43841STimur Tabi 61819e43841STimur Tabi /* 61919e43841STimur Tabi * If the value we read from CCSRBARL is not what we expect, then 62019e43841STimur Tabi * enter an infinite loop. This will at least allow a debugger to 62119e43841STimur Tabi * halt execution and examine TLBs, etc. There's no point in going 62219e43841STimur Tabi * on. 62319e43841STimur Tabi */ 62419e43841STimur Tabiinfinite_debug_loop: 62519e43841STimur Tabi bne infinite_debug_loop 62619e43841STimur Tabi 6276ca88b09STimur Tabi#ifdef CONFIG_FSL_CORENET 6286ca88b09STimur Tabi 6296ca88b09STimur Tabi#define CCSR_LAWBARH0 (CONFIG_SYS_CCSRBAR + 0x1000) 6306ca88b09STimur Tabi#define LAW_EN 0x80000000 6316ca88b09STimur Tabi#define LAW_SIZE_4K 0xb 6326ca88b09STimur Tabi#define CCSRBAR_LAWAR (LAW_EN | (0x1e << 20) | LAW_SIZE_4K) 6336ca88b09STimur Tabi#define CCSRAR_C 0x80000000 /* Commit */ 6346ca88b09STimur Tabi 6356ca88b09STimur Tabicreate_temp_law: 6366ca88b09STimur Tabi /* 6376ca88b09STimur Tabi * On CoreNet systems, we create the temporary LAW using a special LAW 6386ca88b09STimur Tabi * target ID of 0x1e. LAWBARH is at offset 0xc00 in CCSR. 6396ca88b09STimur Tabi */ 6406ca88b09STimur Tabi lis r0, CONFIG_SYS_CCSRBAR_PHYS_HIGH@h 6416ca88b09STimur Tabi ori r0, r0, CONFIG_SYS_CCSRBAR_PHYS_HIGH@l 6426ca88b09STimur Tabi lis r1, CONFIG_SYS_CCSRBAR_PHYS_LOW@h 6436ca88b09STimur Tabi ori r1, r1, CONFIG_SYS_CCSRBAR_PHYS_LOW@l 6446ca88b09STimur Tabi lis r2, CCSRBAR_LAWAR@h 6456ca88b09STimur Tabi ori r2, r2, CCSRBAR_LAWAR@l 6466ca88b09STimur Tabi 6476ca88b09STimur Tabi stw r0, 0xc00(r9) /* LAWBARH0 */ 6486ca88b09STimur Tabi stw r1, 0xc04(r9) /* LAWBARL0 */ 6496ca88b09STimur Tabi sync 6506ca88b09STimur Tabi stw r2, 0xc08(r9) /* LAWAR0 */ 6516ca88b09STimur Tabi 6526ca88b09STimur Tabi /* 6536ca88b09STimur Tabi * Read back from LAWAR to ensure the update is complete. e500mc 6546ca88b09STimur Tabi * cores also require an isync. 6556ca88b09STimur Tabi */ 6566ca88b09STimur Tabi lwz r0, 0xc08(r9) /* LAWAR0 */ 6576ca88b09STimur Tabi isync 6586ca88b09STimur Tabi 6596ca88b09STimur Tabi /* 6606ca88b09STimur Tabi * Read the current CCSRBARH and CCSRBARL using load word instructions. 6616ca88b09STimur Tabi * Follow this with an isync instruction. This forces any outstanding 6626ca88b09STimur Tabi * accesses to configuration space to completion. 6636ca88b09STimur Tabi */ 6646ca88b09STimur Tabiread_old_ccsrbar: 6656ca88b09STimur Tabi lwz r0, 0(r9) /* CCSRBARH */ 666c2efa0aaSTimur Tabi lwz r0, 4(r9) /* CCSRBARL */ 6676ca88b09STimur Tabi isync 6686ca88b09STimur Tabi 6696ca88b09STimur Tabi /* 6706ca88b09STimur Tabi * Write the new values for CCSRBARH and CCSRBARL to their old 6716ca88b09STimur Tabi * locations. The CCSRBARH has a shadow register. When the CCSRBARH 6726ca88b09STimur Tabi * has a new value written it loads a CCSRBARH shadow register. When 6736ca88b09STimur Tabi * the CCSRBARL is written, the CCSRBARH shadow register contents 6746ca88b09STimur Tabi * along with the CCSRBARL value are loaded into the CCSRBARH and 6756ca88b09STimur Tabi * CCSRBARL registers, respectively. Follow this with a sync 6766ca88b09STimur Tabi * instruction. 6776ca88b09STimur Tabi */ 6786ca88b09STimur Tabiwrite_new_ccsrbar: 6796ca88b09STimur Tabi lis r0, CONFIG_SYS_CCSRBAR_PHYS_HIGH@h 6806ca88b09STimur Tabi ori r0, r0, CONFIG_SYS_CCSRBAR_PHYS_HIGH@l 6816ca88b09STimur Tabi lis r1, CONFIG_SYS_CCSRBAR_PHYS_LOW@h 6826ca88b09STimur Tabi ori r1, r1, CONFIG_SYS_CCSRBAR_PHYS_LOW@l 6836ca88b09STimur Tabi lis r2, CCSRAR_C@h 6846ca88b09STimur Tabi ori r2, r2, CCSRAR_C@l 6856ca88b09STimur Tabi 6866ca88b09STimur Tabi stw r0, 0(r9) /* Write to CCSRBARH */ 6876ca88b09STimur Tabi sync /* Make sure we write to CCSRBARH first */ 6886ca88b09STimur Tabi stw r1, 4(r9) /* Write to CCSRBARL */ 6896ca88b09STimur Tabi sync 6906ca88b09STimur Tabi 6916ca88b09STimur Tabi /* 6926ca88b09STimur Tabi * Write a 1 to the commit bit (C) of CCSRAR at the old location. 6936ca88b09STimur Tabi * Follow this with a sync instruction. 6946ca88b09STimur Tabi */ 6956ca88b09STimur Tabi stw r2, 8(r9) 6966ca88b09STimur Tabi sync 6976ca88b09STimur Tabi 6986ca88b09STimur Tabi /* Delete the temporary LAW */ 6996ca88b09STimur Tabidelete_temp_law: 7006ca88b09STimur Tabi li r1, 0 7016ca88b09STimur Tabi stw r1, 0xc08(r8) 7026ca88b09STimur Tabi sync 7036ca88b09STimur Tabi stw r1, 0xc00(r8) 7046ca88b09STimur Tabi stw r1, 0xc04(r8) 7056ca88b09STimur Tabi sync 7066ca88b09STimur Tabi 7076ca88b09STimur Tabi#else /* #ifdef CONFIG_FSL_CORENET */ 7086ca88b09STimur Tabi 7096ca88b09STimur Tabiwrite_new_ccsrbar: 7106ca88b09STimur Tabi /* 7116ca88b09STimur Tabi * Read the current value of CCSRBAR using a load word instruction 7126ca88b09STimur Tabi * followed by an isync. This forces all accesses to configuration 7136ca88b09STimur Tabi * space to complete. 7146ca88b09STimur Tabi */ 7156ca88b09STimur Tabi sync 7166ca88b09STimur Tabi lwz r0, 0(r9) 7176ca88b09STimur Tabi isync 7186ca88b09STimur Tabi 7196ca88b09STimur Tabi/* CONFIG_SYS_CCSRBAR_PHYS right shifted by 12 */ 7206ca88b09STimur Tabi#define CCSRBAR_PHYS_RS12 ((CONFIG_SYS_CCSRBAR_PHYS_HIGH << 20) | \ 7216ca88b09STimur Tabi (CONFIG_SYS_CCSRBAR_PHYS_LOW >> 12)) 7226ca88b09STimur Tabi 7236ca88b09STimur Tabi /* Write the new value to CCSRBAR. */ 7246ca88b09STimur Tabi lis r0, CCSRBAR_PHYS_RS12@h 7256ca88b09STimur Tabi ori r0, r0, CCSRBAR_PHYS_RS12@l 7266ca88b09STimur Tabi stw r0, 0(r9) 7276ca88b09STimur Tabi sync 7286ca88b09STimur Tabi 7296ca88b09STimur Tabi /* 7306ca88b09STimur Tabi * The manual says to perform a load of an address that does not 7316ca88b09STimur Tabi * access configuration space or the on-chip SRAM using an existing TLB, 7326ca88b09STimur Tabi * but that doesn't appear to be necessary. We will do the isync, 7336ca88b09STimur Tabi * though. 7346ca88b09STimur Tabi */ 7356ca88b09STimur Tabi isync 7366ca88b09STimur Tabi 7376ca88b09STimur Tabi /* 7386ca88b09STimur Tabi * Read the contents of CCSRBAR from its new location, followed by 7396ca88b09STimur Tabi * another isync. 7406ca88b09STimur Tabi */ 7416ca88b09STimur Tabi lwz r0, 0(r8) 7426ca88b09STimur Tabi isync 7436ca88b09STimur Tabi 7446ca88b09STimur Tabi#endif /* #ifdef CONFIG_FSL_CORENET */ 7456ca88b09STimur Tabi 7466ca88b09STimur Tabi /* Delete the temporary TLBs */ 7476ca88b09STimur Tabidelete_temp_tlbs: 74869c78267SYork Sun delete_tlb0_entry 0, CONFIG_SYS_CCSRBAR, MAS2_I|MAS2_G, r3 74969c78267SYork Sun delete_tlb0_entry 1, CONFIG_SYS_CCSRBAR + 0x1000, MAS2_I|MAS2_G, r3 7506ca88b09STimur Tabi 7516ca88b09STimur Tabi#endif /* #if (CONFIG_SYS_CCSRBAR_DEFAULT != CONFIG_SYS_CCSRBAR_PHYS) */ 7526ca88b09STimur Tabi 753*6d2b9da1SYork Sun#ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2 754*6d2b9da1SYork Suncreate_ccsr_l2_tlb: 755*6d2b9da1SYork Sun /* 756*6d2b9da1SYork Sun * Create a TLB for the MMR location of CCSR 757*6d2b9da1SYork Sun * to access L2CSR0 register 758*6d2b9da1SYork Sun */ 759*6d2b9da1SYork Sun create_tlb0_entry 0, \ 760*6d2b9da1SYork Sun 0, BOOKE_PAGESZ_4K, \ 761*6d2b9da1SYork Sun CONFIG_SYS_CCSRBAR + 0xC20000, MAS2_I|MAS2_G, \ 762*6d2b9da1SYork Sun CONFIG_SYS_CCSRBAR_PHYS_LOW + 0xC20000, MAS3_SW|MAS3_SR, \ 763*6d2b9da1SYork Sun CONFIG_SYS_CCSRBAR_PHYS_HIGH, r3 764*6d2b9da1SYork Sun 765*6d2b9da1SYork Sunenable_l2_cluster_l2: 766*6d2b9da1SYork Sun /* enable L2 cache */ 767*6d2b9da1SYork Sun lis r3, (CONFIG_SYS_CCSRBAR + 0xC20000)@h 768*6d2b9da1SYork Sun ori r3, r3, (CONFIG_SYS_CCSRBAR + 0xC20000)@l 769*6d2b9da1SYork Sun li r4, 33 /* stash id */ 770*6d2b9da1SYork Sun stw r4, 4(r3) 771*6d2b9da1SYork Sun lis r4, (L2CSR0_L2FI|L2CSR0_L2LFC)@h 772*6d2b9da1SYork Sun ori r4, r4, (L2CSR0_L2FI|L2CSR0_L2LFC)@l 773*6d2b9da1SYork Sun sync 774*6d2b9da1SYork Sun stw r4, 0(r3) /* invalidate L2 */ 775*6d2b9da1SYork Sun1: sync 776*6d2b9da1SYork Sun lwz r0, 0(r3) 777*6d2b9da1SYork Sun twi 0, r0, 0 778*6d2b9da1SYork Sun isync 779*6d2b9da1SYork Sun and. r1, r0, r4 780*6d2b9da1SYork Sun bne 1b 781*6d2b9da1SYork Sun lis r4, L2CSR0_L2E@h 782*6d2b9da1SYork Sun sync 783*6d2b9da1SYork Sun stw r4, 0(r3) /* eanble L2 */ 784*6d2b9da1SYork Sundelete_ccsr_l2_tlb: 785*6d2b9da1SYork Sun delete_tlb0_entry 0, CONFIG_SYS_CCSRBAR + 0xC20000, MAS2_I|MAS2_G, r3 786*6d2b9da1SYork Sun#endif 787*6d2b9da1SYork Sun 78833eee330SScott Wood#ifdef CONFIG_SYS_FSL_ERRATUM_A004510 78933eee330SScott Wood#define DCSR_LAWBARH0 (CONFIG_SYS_CCSRBAR + 0x1000) 79033eee330SScott Wood#define LAW_SIZE_1M 0x13 79133eee330SScott Wood#define DCSRBAR_LAWAR (LAW_EN | (0x1d << 20) | LAW_SIZE_1M) 79233eee330SScott Wood 79333eee330SScott Wood cmpwi r27,0 79433eee330SScott Wood beq 9f 79533eee330SScott Wood 79633eee330SScott Wood /* 79733eee330SScott Wood * Create a TLB entry for CCSR 79833eee330SScott Wood * 79933eee330SScott Wood * We're executing out of TLB1 entry in r14, and that's the only 80033eee330SScott Wood * TLB entry that exists. To allocate some TLB entries for our 80133eee330SScott Wood * own use, flip a bit high enough that we won't flip it again 80233eee330SScott Wood * via incrementing. 80333eee330SScott Wood */ 80433eee330SScott Wood 80533eee330SScott Wood xori r8, r14, 32 80633eee330SScott Wood lis r0, MAS0_TLBSEL(1)@h 80733eee330SScott Wood rlwimi r0, r8, 16, MAS0_ESEL_MSK 80833eee330SScott Wood lis r1, FSL_BOOKE_MAS1(1, 1, 0, 0, BOOKE_PAGESZ_16M)@h 80933eee330SScott Wood ori r1, r1, FSL_BOOKE_MAS1(1, 1, 0, 0, BOOKE_PAGESZ_16M)@l 81033eee330SScott Wood lis r7, CONFIG_SYS_CCSRBAR@h 81133eee330SScott Wood ori r7, r7, CONFIG_SYS_CCSRBAR@l 81233eee330SScott Wood ori r2, r7, MAS2_I|MAS2_G 81333eee330SScott Wood lis r3, FSL_BOOKE_MAS3(CONFIG_SYS_CCSRBAR_PHYS_LOW, 0, (MAS3_SW|MAS3_SR))@h 81433eee330SScott Wood ori r3, r3, FSL_BOOKE_MAS3(CONFIG_SYS_CCSRBAR_PHYS_LOW, 0, (MAS3_SW|MAS3_SR))@l 81533eee330SScott Wood lis r4, CONFIG_SYS_CCSRBAR_PHYS_HIGH@h 81633eee330SScott Wood ori r4, r4, CONFIG_SYS_CCSRBAR_PHYS_HIGH@l 81733eee330SScott Wood mtspr MAS0, r0 81833eee330SScott Wood mtspr MAS1, r1 81933eee330SScott Wood mtspr MAS2, r2 82033eee330SScott Wood mtspr MAS3, r3 82133eee330SScott Wood mtspr MAS7, r4 82233eee330SScott Wood isync 82333eee330SScott Wood tlbwe 82433eee330SScott Wood isync 82533eee330SScott Wood msync 82633eee330SScott Wood 82733eee330SScott Wood /* Map DCSR temporarily to physical address zero */ 82833eee330SScott Wood li r0, 0 82933eee330SScott Wood lis r3, DCSRBAR_LAWAR@h 83033eee330SScott Wood ori r3, r3, DCSRBAR_LAWAR@l 83133eee330SScott Wood 83233eee330SScott Wood stw r0, 0xc00(r7) /* LAWBARH0 */ 83333eee330SScott Wood stw r0, 0xc04(r7) /* LAWBARL0 */ 83433eee330SScott Wood sync 83533eee330SScott Wood stw r3, 0xc08(r7) /* LAWAR0 */ 83633eee330SScott Wood 83733eee330SScott Wood /* Read back from LAWAR to ensure the update is complete. */ 83833eee330SScott Wood lwz r3, 0xc08(r7) /* LAWAR0 */ 83933eee330SScott Wood isync 84033eee330SScott Wood 84133eee330SScott Wood /* Create a TLB entry for DCSR at zero */ 84233eee330SScott Wood 84333eee330SScott Wood addi r9, r8, 1 84433eee330SScott Wood lis r0, MAS0_TLBSEL(1)@h 84533eee330SScott Wood rlwimi r0, r9, 16, MAS0_ESEL_MSK 84633eee330SScott Wood lis r1, FSL_BOOKE_MAS1(1, 1, 0, 0, BOOKE_PAGESZ_1M)@h 84733eee330SScott Wood ori r1, r1, FSL_BOOKE_MAS1(1, 1, 0, 0, BOOKE_PAGESZ_1M)@l 84833eee330SScott Wood li r6, 0 /* DCSR effective address */ 84933eee330SScott Wood ori r2, r6, MAS2_I|MAS2_G 85033eee330SScott Wood li r3, MAS3_SW|MAS3_SR 85133eee330SScott Wood li r4, 0 85233eee330SScott Wood mtspr MAS0, r0 85333eee330SScott Wood mtspr MAS1, r1 85433eee330SScott Wood mtspr MAS2, r2 85533eee330SScott Wood mtspr MAS3, r3 85633eee330SScott Wood mtspr MAS7, r4 85733eee330SScott Wood isync 85833eee330SScott Wood tlbwe 85933eee330SScott Wood isync 86033eee330SScott Wood msync 86133eee330SScott Wood 86233eee330SScott Wood /* enable the timebase */ 86333eee330SScott Wood#define CTBENR 0xe2084 86433eee330SScott Wood li r3, 1 86533eee330SScott Wood addis r4, r7, CTBENR@ha 86633eee330SScott Wood stw r3, CTBENR@l(r4) 86733eee330SScott Wood lwz r3, CTBENR@l(r4) 86833eee330SScott Wood twi 0,r3,0 86933eee330SScott Wood isync 87033eee330SScott Wood 87133eee330SScott Wood .macro erratum_set_ccsr offset value 87233eee330SScott Wood addis r3, r7, \offset@ha 87333eee330SScott Wood lis r4, \value@h 87433eee330SScott Wood addi r3, r3, \offset@l 87533eee330SScott Wood ori r4, r4, \value@l 87633eee330SScott Wood bl erratum_set_value 87733eee330SScott Wood .endm 87833eee330SScott Wood 87933eee330SScott Wood .macro erratum_set_dcsr offset value 88033eee330SScott Wood addis r3, r6, \offset@ha 88133eee330SScott Wood lis r4, \value@h 88233eee330SScott Wood addi r3, r3, \offset@l 88333eee330SScott Wood ori r4, r4, \value@l 88433eee330SScott Wood bl erratum_set_value 88533eee330SScott Wood .endm 88633eee330SScott Wood 88733eee330SScott Wood erratum_set_dcsr 0xb0e08 0xe0201800 88833eee330SScott Wood erratum_set_dcsr 0xb0e18 0xe0201800 88933eee330SScott Wood erratum_set_dcsr 0xb0e38 0xe0400000 89033eee330SScott Wood erratum_set_dcsr 0xb0008 0x00900000 89133eee330SScott Wood erratum_set_dcsr 0xb0e40 0xe00a0000 89233eee330SScott Wood erratum_set_ccsr 0x18600 CONFIG_SYS_FSL_CORENET_SNOOPVEC_COREONLY 89333eee330SScott Wood erratum_set_ccsr 0x10f00 0x415e5000 89433eee330SScott Wood erratum_set_ccsr 0x11f00 0x415e5000 89533eee330SScott Wood 89633eee330SScott Wood /* Make temp mapping uncacheable again, if it was initially */ 89733eee330SScott Wood bl 2f 89833eee330SScott Wood2: mflr r3 89933eee330SScott Wood tlbsx 0, r3 90033eee330SScott Wood mfspr r4, MAS2 90133eee330SScott Wood rlwimi r4, r15, 0, MAS2_I 90233eee330SScott Wood rlwimi r4, r15, 0, MAS2_G 90333eee330SScott Wood mtspr MAS2, r4 90433eee330SScott Wood isync 90533eee330SScott Wood tlbwe 90633eee330SScott Wood isync 90733eee330SScott Wood msync 90833eee330SScott Wood 90933eee330SScott Wood /* Clear the cache */ 91033eee330SScott Wood lis r3,(L1CSR1_ICFI|L1CSR1_ICLFR)@h 91133eee330SScott Wood ori r3,r3,(L1CSR1_ICFI|L1CSR1_ICLFR)@l 91233eee330SScott Wood sync 91333eee330SScott Wood isync 91433eee330SScott Wood mtspr SPRN_L1CSR1,r3 91533eee330SScott Wood isync 91633eee330SScott Wood2: sync 91733eee330SScott Wood mfspr r4,SPRN_L1CSR1 91833eee330SScott Wood and. r4,r4,r3 91933eee330SScott Wood bne 2b 92033eee330SScott Wood 92133eee330SScott Wood lis r3,(L1CSR1_CPE|L1CSR1_ICE)@h 92233eee330SScott Wood ori r3,r3,(L1CSR1_CPE|L1CSR1_ICE)@l 92333eee330SScott Wood sync 92433eee330SScott Wood isync 92533eee330SScott Wood mtspr SPRN_L1CSR1,r3 92633eee330SScott Wood isync 92733eee330SScott Wood2: sync 92833eee330SScott Wood mfspr r4,SPRN_L1CSR1 92933eee330SScott Wood and. r4,r4,r3 93033eee330SScott Wood beq 2b 93133eee330SScott Wood 93233eee330SScott Wood /* Remove temporary mappings */ 93333eee330SScott Wood lis r0, MAS0_TLBSEL(1)@h 93433eee330SScott Wood rlwimi r0, r9, 16, MAS0_ESEL_MSK 93533eee330SScott Wood li r3, 0 93633eee330SScott Wood mtspr MAS0, r0 93733eee330SScott Wood mtspr MAS1, r3 93833eee330SScott Wood isync 93933eee330SScott Wood tlbwe 94033eee330SScott Wood isync 94133eee330SScott Wood msync 94233eee330SScott Wood 94333eee330SScott Wood li r3, 0 94433eee330SScott Wood stw r3, 0xc08(r7) /* LAWAR0 */ 94533eee330SScott Wood lwz r3, 0xc08(r7) 94633eee330SScott Wood isync 94733eee330SScott Wood 94833eee330SScott Wood lis r0, MAS0_TLBSEL(1)@h 94933eee330SScott Wood rlwimi r0, r8, 16, MAS0_ESEL_MSK 95033eee330SScott Wood li r3, 0 95133eee330SScott Wood mtspr MAS0, r0 95233eee330SScott Wood mtspr MAS1, r3 95333eee330SScott Wood isync 95433eee330SScott Wood tlbwe 95533eee330SScott Wood isync 95633eee330SScott Wood msync 95733eee330SScott Wood 95833eee330SScott Wood b 9f 95933eee330SScott Wood 96033eee330SScott Wood /* r3 = addr, r4 = value, clobbers r5, r11, r12 */ 96133eee330SScott Wooderratum_set_value: 96233eee330SScott Wood /* Lock two cache lines into I-Cache */ 96333eee330SScott Wood sync 96433eee330SScott Wood mfspr r11, SPRN_L1CSR1 96533eee330SScott Wood rlwinm r11, r11, 0, ~L1CSR1_ICUL 96633eee330SScott Wood sync 96733eee330SScott Wood isync 96833eee330SScott Wood mtspr SPRN_L1CSR1, r11 96933eee330SScott Wood isync 97033eee330SScott Wood 97133eee330SScott Wood mflr r12 97233eee330SScott Wood bl 5f 97333eee330SScott Wood5: mflr r5 97433eee330SScott Wood addi r5, r5, 2f - 5b 97533eee330SScott Wood icbtls 0, 0, r5 97633eee330SScott Wood addi r5, r5, 64 97733eee330SScott Wood 97833eee330SScott Wood sync 97933eee330SScott Wood mfspr r11, SPRN_L1CSR1 98033eee330SScott Wood3: andi. r11, r11, L1CSR1_ICUL 98133eee330SScott Wood bne 3b 98233eee330SScott Wood 98333eee330SScott Wood icbtls 0, 0, r5 98433eee330SScott Wood addi r5, r5, 64 98533eee330SScott Wood 98633eee330SScott Wood sync 98733eee330SScott Wood mfspr r11, SPRN_L1CSR1 98833eee330SScott Wood3: andi. r11, r11, L1CSR1_ICUL 98933eee330SScott Wood bne 3b 99033eee330SScott Wood 99133eee330SScott Wood b 2f 99233eee330SScott Wood .align 6 99333eee330SScott Wood /* Inside a locked cacheline, wait a while, write, then wait a while */ 99433eee330SScott Wood2: sync 99533eee330SScott Wood 99633eee330SScott Wood mfspr r5, SPRN_TBRL 99733eee330SScott Wood addis r11, r5, 0x10000@h /* wait 65536 timebase ticks */ 99833eee330SScott Wood4: mfspr r5, SPRN_TBRL 99933eee330SScott Wood subf. r5, r5, r11 100033eee330SScott Wood bgt 4b 100133eee330SScott Wood 100233eee330SScott Wood stw r4, 0(r3) 100333eee330SScott Wood 100433eee330SScott Wood mfspr r5, SPRN_TBRL 100533eee330SScott Wood addis r11, r5, 0x10000@h /* wait 65536 timebase ticks */ 100633eee330SScott Wood4: mfspr r5, SPRN_TBRL 100733eee330SScott Wood subf. r5, r5, r11 100833eee330SScott Wood bgt 4b 100933eee330SScott Wood 101033eee330SScott Wood sync 101133eee330SScott Wood 101233eee330SScott Wood /* 101333eee330SScott Wood * Fill out the rest of this cache line and the next with nops, 101433eee330SScott Wood * to ensure that nothing outside the locked area will be 101533eee330SScott Wood * fetched due to a branch. 101633eee330SScott Wood */ 101733eee330SScott Wood .rept 19 101833eee330SScott Wood nop 101933eee330SScott Wood .endr 102033eee330SScott Wood 102133eee330SScott Wood sync 102233eee330SScott Wood mfspr r11, SPRN_L1CSR1 102333eee330SScott Wood rlwinm r11, r11, 0, ~L1CSR1_ICUL 102433eee330SScott Wood sync 102533eee330SScott Wood isync 102633eee330SScott Wood mtspr SPRN_L1CSR1, r11 102733eee330SScott Wood isync 102833eee330SScott Wood 102933eee330SScott Wood mtlr r12 103033eee330SScott Wood blr 103133eee330SScott Wood 103233eee330SScott Wood9: 103333eee330SScott Wood#endif 103433eee330SScott Wood 10356ca88b09STimur Tabicreate_init_ram_area: 1036a47a12beSStefan Roese lis r6,FSL_BOOKE_MAS0(1, 15, 0)@h 1037a47a12beSStefan Roese ori r6,r6,FSL_BOOKE_MAS0(1, 15, 0)@l 1038a47a12beSStefan Roese 10397065b7d4SRuchika Gupta#if !defined(CONFIG_SYS_RAMBOOT) && !defined(CONFIG_SECURE_BOOT) 1040a47a12beSStefan Roese /* create a temp mapping in AS=1 to the 4M boot window */ 104169c78267SYork Sun create_tlb1_entry 15, \ 104269c78267SYork Sun 1, BOOKE_PAGESZ_4M, \ 104369c78267SYork Sun CONFIG_SYS_MONITOR_BASE & 0xffc00000, MAS2_I|MAS2_G, \ 104469c78267SYork Sun 0xffc00000, MAS3_SX|MAS3_SW|MAS3_SR, \ 104569c78267SYork Sun 0, r6 1046a47a12beSStefan Roese 10477065b7d4SRuchika Gupta#elif !defined(CONFIG_SYS_RAMBOOT) && defined(CONFIG_SECURE_BOOT) 10487065b7d4SRuchika Gupta /* create a temp mapping in AS = 1 for Flash mapping 10497065b7d4SRuchika Gupta * created by PBL for ISBC code 10507065b7d4SRuchika Gupta */ 105169c78267SYork Sun create_tlb1_entry 15, \ 105269c78267SYork Sun 1, BOOKE_PAGESZ_1M, \ 105369c78267SYork Sun CONFIG_SYS_MONITOR_BASE, MAS2_I|MAS2_G, \ 105469c78267SYork Sun CONFIG_SYS_PBI_FLASH_WINDOW, MAS3_SX|MAS3_SW|MAS3_SR, \ 105569c78267SYork Sun 0, r6 1056a47a12beSStefan Roese#else 1057a47a12beSStefan Roese /* 10580635b09cSHaiying Wang * create a temp mapping in AS=1 to the 1M CONFIG_SYS_MONITOR_BASE space, the main 10590635b09cSHaiying Wang * image has been relocated to CONFIG_SYS_MONITOR_BASE on the second stage. 1060a47a12beSStefan Roese */ 106169c78267SYork Sun create_tlb1_entry 15, \ 106269c78267SYork Sun 1, BOOKE_PAGESZ_1M, \ 106369c78267SYork Sun CONFIG_SYS_MONITOR_BASE, MAS2_I|MAS2_G, \ 106469c78267SYork Sun CONFIG_SYS_MONITOR_BASE, MAS3_SX|MAS3_SW|MAS3_SR, \ 106569c78267SYork Sun 0, r6 1066a47a12beSStefan Roese#endif 1067a47a12beSStefan Roese 1068a47a12beSStefan Roese /* create a temp mapping in AS=1 to the stack */ 1069a3f18529Syork#if defined(CONFIG_SYS_INIT_RAM_ADDR_PHYS_LOW) && \ 1070a3f18529Syork defined(CONFIG_SYS_INIT_RAM_ADDR_PHYS_HIGH) 107169c78267SYork Sun create_tlb1_entry 14, \ 107269c78267SYork Sun 1, BOOKE_PAGESZ_16K, \ 107369c78267SYork Sun CONFIG_SYS_INIT_RAM_ADDR, 0, \ 107469c78267SYork Sun CONFIG_SYS_INIT_RAM_ADDR_PHYS_LOW, MAS3_SX|MAS3_SW|MAS3_SR, \ 107569c78267SYork Sun CONFIG_SYS_INIT_RAM_ADDR_PHYS_HIGH, r6 1076a47a12beSStefan Roese 107769c78267SYork Sun#else 107869c78267SYork Sun create_tlb1_entry 14, \ 107969c78267SYork Sun 1, BOOKE_PAGESZ_16K, \ 108069c78267SYork Sun CONFIG_SYS_INIT_RAM_ADDR, 0, \ 108169c78267SYork Sun CONFIG_SYS_INIT_RAM_ADDR, MAS3_SX|MAS3_SW|MAS3_SR, \ 108269c78267SYork Sun 0, r6 108369c78267SYork Sun#endif 1084a47a12beSStefan Roese 10855344f7a2SPrabhakar Kushwaha lis r6,MSR_IS|MSR_DS|MSR_DE@h 10865344f7a2SPrabhakar Kushwaha ori r6,r6,MSR_IS|MSR_DS|MSR_DE@l 1087a47a12beSStefan Roese lis r7,switch_as@h 1088a47a12beSStefan Roese ori r7,r7,switch_as@l 1089a47a12beSStefan Roese 1090a47a12beSStefan Roese mtspr SPRN_SRR0,r7 1091a47a12beSStefan Roese mtspr SPRN_SRR1,r6 1092a47a12beSStefan Roese rfi 1093a47a12beSStefan Roese 1094a47a12beSStefan Roeseswitch_as: 1095a47a12beSStefan Roese/* L1 DCache is used for initial RAM */ 1096a47a12beSStefan Roese 1097a47a12beSStefan Roese /* Allocate Initial RAM in data cache. 1098a47a12beSStefan Roese */ 1099a47a12beSStefan Roese lis r3,CONFIG_SYS_INIT_RAM_ADDR@h 1100a47a12beSStefan Roese ori r3,r3,CONFIG_SYS_INIT_RAM_ADDR@l 1101a47a12beSStefan Roese mfspr r2, L1CFG0 1102a47a12beSStefan Roese andi. r2, r2, 0x1ff 1103a47a12beSStefan Roese /* cache size * 1024 / (2 * L1 line size) */ 1104a47a12beSStefan Roese slwi r2, r2, (10 - 1 - L1_CACHE_SHIFT) 1105a47a12beSStefan Roese mtctr r2 1106a47a12beSStefan Roese li r0,0 1107a47a12beSStefan Roese1: 1108a47a12beSStefan Roese dcbz r0,r3 1109a47a12beSStefan Roese dcbtls 0,r0,r3 1110a47a12beSStefan Roese addi r3,r3,CONFIG_SYS_CACHELINE_SIZE 1111a47a12beSStefan Roese bdnz 1b 1112a47a12beSStefan Roese 1113a47a12beSStefan Roese /* Jump out the last 4K page and continue to 'normal' start */ 1114a47a12beSStefan Roese#ifdef CONFIG_SYS_RAMBOOT 1115a47a12beSStefan Roese b _start_cont 1116a47a12beSStefan Roese#else 1117a47a12beSStefan Roese /* Calculate absolute address in FLASH and jump there */ 1118a47a12beSStefan Roese /*--------------------------------------------------------------*/ 1119a47a12beSStefan Roese lis r3,CONFIG_SYS_MONITOR_BASE@h 1120a47a12beSStefan Roese ori r3,r3,CONFIG_SYS_MONITOR_BASE@l 1121a47a12beSStefan Roese addi r3,r3,_start_cont - _start + _START_OFFSET 1122a47a12beSStefan Roese mtlr r3 1123a47a12beSStefan Roese blr 1124a47a12beSStefan Roese#endif 1125a47a12beSStefan Roese 1126a47a12beSStefan Roese .text 1127a47a12beSStefan Roese .globl _start 1128a47a12beSStefan Roese_start: 1129a47a12beSStefan Roese .long 0x27051956 /* U-BOOT Magic Number */ 1130a47a12beSStefan Roese .globl version_string 1131a47a12beSStefan Roeseversion_string: 113209c2e90cSAndreas Bießmann .ascii U_BOOT_VERSION_STRING, "\0" 1133a47a12beSStefan Roese 1134a47a12beSStefan Roese .align 4 1135a47a12beSStefan Roese .globl _start_cont 1136a47a12beSStefan Roese_start_cont: 1137a47a12beSStefan Roese /* Setup the stack in initial RAM,could be L2-as-SRAM or L1 dcache*/ 113889f42899SJoakim Tjernlund lis r3,(CONFIG_SYS_INIT_RAM_ADDR)@h 113989f42899SJoakim Tjernlund ori r3,r3,((CONFIG_SYS_INIT_SP_OFFSET-16)&~0xf)@l /* Align to 16 */ 1140a47a12beSStefan Roese li r0,0 114189f42899SJoakim Tjernlund stw r0,0(r3) /* Terminate Back Chain */ 114289f42899SJoakim Tjernlund stw r0,+4(r3) /* NULL return address. */ 114389f42899SJoakim Tjernlund mr r1,r3 /* Transfer to SP(r1) */ 1144a47a12beSStefan Roese 1145a47a12beSStefan Roese GET_GOT 1146a47a12beSStefan Roese bl cpu_init_early_f 1147a47a12beSStefan Roese 1148a47a12beSStefan Roese /* switch back to AS = 0 */ 1149a47a12beSStefan Roese lis r3,(MSR_CE|MSR_ME|MSR_DE)@h 1150a47a12beSStefan Roese ori r3,r3,(MSR_CE|MSR_ME|MSR_DE)@l 1151a47a12beSStefan Roese mtmsr r3 1152a47a12beSStefan Roese isync 1153a47a12beSStefan Roese 1154a47a12beSStefan Roese bl cpu_init_f 1155a47a12beSStefan Roese bl board_init_f 1156a47a12beSStefan Roese isync 1157a47a12beSStefan Roese 115852ebd9c1SPeter Tyser /* NOTREACHED - board_init_f() does not return */ 115952ebd9c1SPeter Tyser 1160a47a12beSStefan Roese#ifndef CONFIG_NAND_SPL 1161a47a12beSStefan Roese . = EXC_OFF_SYS_RESET 1162a47a12beSStefan Roese .globl _start_of_vectors 1163a47a12beSStefan Roese_start_of_vectors: 1164a47a12beSStefan Roese 1165a47a12beSStefan Roese/* Critical input. */ 1166a47a12beSStefan Roese CRIT_EXCEPTION(0x0100, CriticalInput, CritcalInputException) 1167a47a12beSStefan Roese 1168a47a12beSStefan Roese/* Machine check */ 1169a47a12beSStefan Roese MCK_EXCEPTION(0x200, MachineCheck, MachineCheckException) 1170a47a12beSStefan Roese 1171a47a12beSStefan Roese/* Data Storage exception. */ 1172a47a12beSStefan Roese STD_EXCEPTION(0x0300, DataStorage, UnknownException) 1173a47a12beSStefan Roese 1174a47a12beSStefan Roese/* Instruction Storage exception. */ 1175a47a12beSStefan Roese STD_EXCEPTION(0x0400, InstStorage, UnknownException) 1176a47a12beSStefan Roese 1177a47a12beSStefan Roese/* External Interrupt exception. */ 1178a47a12beSStefan Roese STD_EXCEPTION(0x0500, ExtInterrupt, ExtIntException) 1179a47a12beSStefan Roese 1180a47a12beSStefan Roese/* Alignment exception. */ 1181a47a12beSStefan Roese . = 0x0600 1182a47a12beSStefan RoeseAlignment: 1183a47a12beSStefan Roese EXCEPTION_PROLOG(SRR0, SRR1) 1184a47a12beSStefan Roese mfspr r4,DAR 1185a47a12beSStefan Roese stw r4,_DAR(r21) 1186a47a12beSStefan Roese mfspr r5,DSISR 1187a47a12beSStefan Roese stw r5,_DSISR(r21) 1188a47a12beSStefan Roese addi r3,r1,STACK_FRAME_OVERHEAD 1189a47a12beSStefan Roese EXC_XFER_TEMPLATE(Alignment, AlignmentException, MSR_KERNEL, COPY_EE) 1190a47a12beSStefan Roese 1191a47a12beSStefan Roese/* Program check exception */ 1192a47a12beSStefan Roese . = 0x0700 1193a47a12beSStefan RoeseProgramCheck: 1194a47a12beSStefan Roese EXCEPTION_PROLOG(SRR0, SRR1) 1195a47a12beSStefan Roese addi r3,r1,STACK_FRAME_OVERHEAD 1196a47a12beSStefan Roese EXC_XFER_TEMPLATE(ProgramCheck, ProgramCheckException, 1197a47a12beSStefan Roese MSR_KERNEL, COPY_EE) 1198a47a12beSStefan Roese 1199a47a12beSStefan Roese /* No FPU on MPC85xx. This exception is not supposed to happen. 1200a47a12beSStefan Roese */ 1201a47a12beSStefan Roese STD_EXCEPTION(0x0800, FPUnavailable, UnknownException) 1202a47a12beSStefan Roese 1203a47a12beSStefan Roese . = 0x0900 1204a47a12beSStefan Roese/* 1205a47a12beSStefan Roese * r0 - SYSCALL number 1206a47a12beSStefan Roese * r3-... arguments 1207a47a12beSStefan Roese */ 1208a47a12beSStefan RoeseSystemCall: 1209a47a12beSStefan Roese addis r11,r0,0 /* get functions table addr */ 1210a47a12beSStefan Roese ori r11,r11,0 /* Note: this code is patched in trap_init */ 1211a47a12beSStefan Roese addis r12,r0,0 /* get number of functions */ 1212a47a12beSStefan Roese ori r12,r12,0 1213a47a12beSStefan Roese 1214a47a12beSStefan Roese cmplw 0,r0,r12 1215a47a12beSStefan Roese bge 1f 1216a47a12beSStefan Roese 1217a47a12beSStefan Roese rlwinm r0,r0,2,0,31 /* fn_addr = fn_tbl[r0] */ 1218a47a12beSStefan Roese add r11,r11,r0 1219a47a12beSStefan Roese lwz r11,0(r11) 1220a47a12beSStefan Roese 1221a47a12beSStefan Roese li r20,0xd00-4 /* Get stack pointer */ 1222a47a12beSStefan Roese lwz r12,0(r20) 1223a47a12beSStefan Roese subi r12,r12,12 /* Adjust stack pointer */ 1224a47a12beSStefan Roese li r0,0xc00+_end_back-SystemCall 1225a47a12beSStefan Roese cmplw 0,r0,r12 /* Check stack overflow */ 1226a47a12beSStefan Roese bgt 1f 1227a47a12beSStefan Roese stw r12,0(r20) 1228a47a12beSStefan Roese 1229a47a12beSStefan Roese mflr r0 1230a47a12beSStefan Roese stw r0,0(r12) 1231a47a12beSStefan Roese mfspr r0,SRR0 1232a47a12beSStefan Roese stw r0,4(r12) 1233a47a12beSStefan Roese mfspr r0,SRR1 1234a47a12beSStefan Roese stw r0,8(r12) 1235a47a12beSStefan Roese 1236a47a12beSStefan Roese li r12,0xc00+_back-SystemCall 1237a47a12beSStefan Roese mtlr r12 1238a47a12beSStefan Roese mtspr SRR0,r11 1239a47a12beSStefan Roese 1240a47a12beSStefan Roese1: SYNC 1241a47a12beSStefan Roese rfi 1242a47a12beSStefan Roese_back: 1243a47a12beSStefan Roese 1244a47a12beSStefan Roese mfmsr r11 /* Disable interrupts */ 1245a47a12beSStefan Roese li r12,0 1246a47a12beSStefan Roese ori r12,r12,MSR_EE 1247a47a12beSStefan Roese andc r11,r11,r12 1248a47a12beSStefan Roese SYNC /* Some chip revs need this... */ 1249a47a12beSStefan Roese mtmsr r11 1250a47a12beSStefan Roese SYNC 1251a47a12beSStefan Roese 1252a47a12beSStefan Roese li r12,0xd00-4 /* restore regs */ 1253a47a12beSStefan Roese lwz r12,0(r12) 1254a47a12beSStefan Roese 1255a47a12beSStefan Roese lwz r11,0(r12) 1256a47a12beSStefan Roese mtlr r11 1257a47a12beSStefan Roese lwz r11,4(r12) 1258a47a12beSStefan Roese mtspr SRR0,r11 1259a47a12beSStefan Roese lwz r11,8(r12) 1260a47a12beSStefan Roese mtspr SRR1,r11 1261a47a12beSStefan Roese 1262a47a12beSStefan Roese addi r12,r12,12 /* Adjust stack pointer */ 1263a47a12beSStefan Roese li r20,0xd00-4 1264a47a12beSStefan Roese stw r12,0(r20) 1265a47a12beSStefan Roese 1266a47a12beSStefan Roese SYNC 1267a47a12beSStefan Roese rfi 1268a47a12beSStefan Roese_end_back: 1269a47a12beSStefan Roese 1270a47a12beSStefan Roese STD_EXCEPTION(0x0a00, Decrementer, timer_interrupt) 1271a47a12beSStefan Roese STD_EXCEPTION(0x0b00, IntervalTimer, UnknownException) 1272a47a12beSStefan Roese STD_EXCEPTION(0x0c00, WatchdogTimer, UnknownException) 1273a47a12beSStefan Roese 1274a47a12beSStefan Roese STD_EXCEPTION(0x0d00, DataTLBError, UnknownException) 1275a47a12beSStefan Roese STD_EXCEPTION(0x0e00, InstructionTLBError, UnknownException) 1276a47a12beSStefan Roese 1277a47a12beSStefan Roese CRIT_EXCEPTION(0x0f00, DebugBreakpoint, DebugException ) 1278a47a12beSStefan Roese 1279a47a12beSStefan Roese .globl _end_of_vectors 1280a47a12beSStefan Roese_end_of_vectors: 1281a47a12beSStefan Roese 1282a47a12beSStefan Roese 1283a47a12beSStefan Roese . = . + (0x100 - ( . & 0xff )) /* align for debug */ 1284a47a12beSStefan Roese 1285a47a12beSStefan Roese/* 1286a47a12beSStefan Roese * This code finishes saving the registers to the exception frame 1287a47a12beSStefan Roese * and jumps to the appropriate handler for the exception. 1288a47a12beSStefan Roese * Register r21 is pointer into trap frame, r1 has new stack pointer. 1289a47a12beSStefan Roese */ 1290a47a12beSStefan Roese .globl transfer_to_handler 1291a47a12beSStefan Roesetransfer_to_handler: 1292a47a12beSStefan Roese stw r22,_NIP(r21) 1293a47a12beSStefan Roese lis r22,MSR_POW@h 1294a47a12beSStefan Roese andc r23,r23,r22 1295a47a12beSStefan Roese stw r23,_MSR(r21) 1296a47a12beSStefan Roese SAVE_GPR(7, r21) 1297a47a12beSStefan Roese SAVE_4GPRS(8, r21) 1298a47a12beSStefan Roese SAVE_8GPRS(12, r21) 1299a47a12beSStefan Roese SAVE_8GPRS(24, r21) 1300a47a12beSStefan Roese 1301a47a12beSStefan Roese mflr r23 1302a47a12beSStefan Roese andi. r24,r23,0x3f00 /* get vector offset */ 1303a47a12beSStefan Roese stw r24,TRAP(r21) 1304a47a12beSStefan Roese li r22,0 1305a47a12beSStefan Roese stw r22,RESULT(r21) 1306a47a12beSStefan Roese mtspr SPRG2,r22 /* r1 is now kernel sp */ 1307a47a12beSStefan Roese 1308a47a12beSStefan Roese lwz r24,0(r23) /* virtual address of handler */ 1309a47a12beSStefan Roese lwz r23,4(r23) /* where to go when done */ 1310a47a12beSStefan Roese mtspr SRR0,r24 1311a47a12beSStefan Roese mtspr SRR1,r20 1312a47a12beSStefan Roese mtlr r23 1313a47a12beSStefan Roese SYNC 1314a47a12beSStefan Roese rfi /* jump to handler, enable MMU */ 1315a47a12beSStefan Roese 1316a47a12beSStefan Roeseint_return: 1317a47a12beSStefan Roese mfmsr r28 /* Disable interrupts */ 1318a47a12beSStefan Roese li r4,0 1319a47a12beSStefan Roese ori r4,r4,MSR_EE 1320a47a12beSStefan Roese andc r28,r28,r4 1321a47a12beSStefan Roese SYNC /* Some chip revs need this... */ 1322a47a12beSStefan Roese mtmsr r28 1323a47a12beSStefan Roese SYNC 1324a47a12beSStefan Roese lwz r2,_CTR(r1) 1325a47a12beSStefan Roese lwz r0,_LINK(r1) 1326a47a12beSStefan Roese mtctr r2 1327a47a12beSStefan Roese mtlr r0 1328a47a12beSStefan Roese lwz r2,_XER(r1) 1329a47a12beSStefan Roese lwz r0,_CCR(r1) 1330a47a12beSStefan Roese mtspr XER,r2 1331a47a12beSStefan Roese mtcrf 0xFF,r0 1332a47a12beSStefan Roese REST_10GPRS(3, r1) 1333a47a12beSStefan Roese REST_10GPRS(13, r1) 1334a47a12beSStefan Roese REST_8GPRS(23, r1) 1335a47a12beSStefan Roese REST_GPR(31, r1) 1336a47a12beSStefan Roese lwz r2,_NIP(r1) /* Restore environment */ 1337a47a12beSStefan Roese lwz r0,_MSR(r1) 1338a47a12beSStefan Roese mtspr SRR0,r2 1339a47a12beSStefan Roese mtspr SRR1,r0 1340a47a12beSStefan Roese lwz r0,GPR0(r1) 1341a47a12beSStefan Roese lwz r2,GPR2(r1) 1342a47a12beSStefan Roese lwz r1,GPR1(r1) 1343a47a12beSStefan Roese SYNC 1344a47a12beSStefan Roese rfi 1345a47a12beSStefan Roese 1346a47a12beSStefan Roesecrit_return: 1347a47a12beSStefan Roese mfmsr r28 /* Disable interrupts */ 1348a47a12beSStefan Roese li r4,0 1349a47a12beSStefan Roese ori r4,r4,MSR_EE 1350a47a12beSStefan Roese andc r28,r28,r4 1351a47a12beSStefan Roese SYNC /* Some chip revs need this... */ 1352a47a12beSStefan Roese mtmsr r28 1353a47a12beSStefan Roese SYNC 1354a47a12beSStefan Roese lwz r2,_CTR(r1) 1355a47a12beSStefan Roese lwz r0,_LINK(r1) 1356a47a12beSStefan Roese mtctr r2 1357a47a12beSStefan Roese mtlr r0 1358a47a12beSStefan Roese lwz r2,_XER(r1) 1359a47a12beSStefan Roese lwz r0,_CCR(r1) 1360a47a12beSStefan Roese mtspr XER,r2 1361a47a12beSStefan Roese mtcrf 0xFF,r0 1362a47a12beSStefan Roese REST_10GPRS(3, r1) 1363a47a12beSStefan Roese REST_10GPRS(13, r1) 1364a47a12beSStefan Roese REST_8GPRS(23, r1) 1365a47a12beSStefan Roese REST_GPR(31, r1) 1366a47a12beSStefan Roese lwz r2,_NIP(r1) /* Restore environment */ 1367a47a12beSStefan Roese lwz r0,_MSR(r1) 1368a47a12beSStefan Roese mtspr SPRN_CSRR0,r2 1369a47a12beSStefan Roese mtspr SPRN_CSRR1,r0 1370a47a12beSStefan Roese lwz r0,GPR0(r1) 1371a47a12beSStefan Roese lwz r2,GPR2(r1) 1372a47a12beSStefan Roese lwz r1,GPR1(r1) 1373a47a12beSStefan Roese SYNC 1374a47a12beSStefan Roese rfci 1375a47a12beSStefan Roese 1376a47a12beSStefan Roesemck_return: 1377a47a12beSStefan Roese mfmsr r28 /* Disable interrupts */ 1378a47a12beSStefan Roese li r4,0 1379a47a12beSStefan Roese ori r4,r4,MSR_EE 1380a47a12beSStefan Roese andc r28,r28,r4 1381a47a12beSStefan Roese SYNC /* Some chip revs need this... */ 1382a47a12beSStefan Roese mtmsr r28 1383a47a12beSStefan Roese SYNC 1384a47a12beSStefan Roese lwz r2,_CTR(r1) 1385a47a12beSStefan Roese lwz r0,_LINK(r1) 1386a47a12beSStefan Roese mtctr r2 1387a47a12beSStefan Roese mtlr r0 1388a47a12beSStefan Roese lwz r2,_XER(r1) 1389a47a12beSStefan Roese lwz r0,_CCR(r1) 1390a47a12beSStefan Roese mtspr XER,r2 1391a47a12beSStefan Roese mtcrf 0xFF,r0 1392a47a12beSStefan Roese REST_10GPRS(3, r1) 1393a47a12beSStefan Roese REST_10GPRS(13, r1) 1394a47a12beSStefan Roese REST_8GPRS(23, r1) 1395a47a12beSStefan Roese REST_GPR(31, r1) 1396a47a12beSStefan Roese lwz r2,_NIP(r1) /* Restore environment */ 1397a47a12beSStefan Roese lwz r0,_MSR(r1) 1398a47a12beSStefan Roese mtspr SPRN_MCSRR0,r2 1399a47a12beSStefan Roese mtspr SPRN_MCSRR1,r0 1400a47a12beSStefan Roese lwz r0,GPR0(r1) 1401a47a12beSStefan Roese lwz r2,GPR2(r1) 1402a47a12beSStefan Roese lwz r1,GPR1(r1) 1403a47a12beSStefan Roese SYNC 1404a47a12beSStefan Roese rfmci 1405a47a12beSStefan Roese 1406a47a12beSStefan Roese/* Cache functions. 1407a47a12beSStefan Roese*/ 14080a9fe8eeSMatthew McClintock.globl flush_icache 14090a9fe8eeSMatthew McClintockflush_icache: 1410a47a12beSStefan Roese.globl invalidate_icache 1411a47a12beSStefan Roeseinvalidate_icache: 1412a47a12beSStefan Roese mfspr r0,L1CSR1 1413a47a12beSStefan Roese ori r0,r0,L1CSR1_ICFI 1414a47a12beSStefan Roese msync 1415a47a12beSStefan Roese isync 1416a47a12beSStefan Roese mtspr L1CSR1,r0 1417a47a12beSStefan Roese isync 1418a47a12beSStefan Roese blr /* entire I cache */ 1419a47a12beSStefan Roese 1420a47a12beSStefan Roese.globl invalidate_dcache 1421a47a12beSStefan Roeseinvalidate_dcache: 1422a47a12beSStefan Roese mfspr r0,L1CSR0 1423a47a12beSStefan Roese ori r0,r0,L1CSR0_DCFI 1424a47a12beSStefan Roese msync 1425a47a12beSStefan Roese isync 1426a47a12beSStefan Roese mtspr L1CSR0,r0 1427a47a12beSStefan Roese isync 1428a47a12beSStefan Roese blr 1429a47a12beSStefan Roese 1430a47a12beSStefan Roese .globl icache_enable 1431a47a12beSStefan Roeseicache_enable: 1432a47a12beSStefan Roese mflr r8 1433a47a12beSStefan Roese bl invalidate_icache 1434a47a12beSStefan Roese mtlr r8 1435a47a12beSStefan Roese isync 1436a47a12beSStefan Roese mfspr r4,L1CSR1 1437a47a12beSStefan Roese ori r4,r4,0x0001 1438a47a12beSStefan Roese oris r4,r4,0x0001 1439a47a12beSStefan Roese mtspr L1CSR1,r4 1440a47a12beSStefan Roese isync 1441a47a12beSStefan Roese blr 1442a47a12beSStefan Roese 1443a47a12beSStefan Roese .globl icache_disable 1444a47a12beSStefan Roeseicache_disable: 1445a47a12beSStefan Roese mfspr r0,L1CSR1 1446a47a12beSStefan Roese lis r3,0 1447a47a12beSStefan Roese ori r3,r3,L1CSR1_ICE 1448a47a12beSStefan Roese andc r0,r0,r3 1449a47a12beSStefan Roese mtspr L1CSR1,r0 1450a47a12beSStefan Roese isync 1451a47a12beSStefan Roese blr 1452a47a12beSStefan Roese 1453a47a12beSStefan Roese .globl icache_status 1454a47a12beSStefan Roeseicache_status: 1455a47a12beSStefan Roese mfspr r3,L1CSR1 1456a47a12beSStefan Roese andi. r3,r3,L1CSR1_ICE 1457a47a12beSStefan Roese blr 1458a47a12beSStefan Roese 1459a47a12beSStefan Roese .globl dcache_enable 1460a47a12beSStefan Roesedcache_enable: 1461a47a12beSStefan Roese mflr r8 1462a47a12beSStefan Roese bl invalidate_dcache 1463a47a12beSStefan Roese mtlr r8 1464a47a12beSStefan Roese isync 1465a47a12beSStefan Roese mfspr r0,L1CSR0 1466a47a12beSStefan Roese ori r0,r0,0x0001 1467a47a12beSStefan Roese oris r0,r0,0x0001 1468a47a12beSStefan Roese msync 1469a47a12beSStefan Roese isync 1470a47a12beSStefan Roese mtspr L1CSR0,r0 1471a47a12beSStefan Roese isync 1472a47a12beSStefan Roese blr 1473a47a12beSStefan Roese 1474a47a12beSStefan Roese .globl dcache_disable 1475a47a12beSStefan Roesedcache_disable: 1476a47a12beSStefan Roese mfspr r3,L1CSR0 1477a47a12beSStefan Roese lis r4,0 1478a47a12beSStefan Roese ori r4,r4,L1CSR0_DCE 1479a47a12beSStefan Roese andc r3,r3,r4 148045a68135SKumar Gala mtspr L1CSR0,r3 1481a47a12beSStefan Roese isync 1482a47a12beSStefan Roese blr 1483a47a12beSStefan Roese 1484a47a12beSStefan Roese .globl dcache_status 1485a47a12beSStefan Roesedcache_status: 1486a47a12beSStefan Roese mfspr r3,L1CSR0 1487a47a12beSStefan Roese andi. r3,r3,L1CSR0_DCE 1488a47a12beSStefan Roese blr 1489a47a12beSStefan Roese 1490a47a12beSStefan Roese .globl get_pir 1491a47a12beSStefan Roeseget_pir: 1492a47a12beSStefan Roese mfspr r3,PIR 1493a47a12beSStefan Roese blr 1494a47a12beSStefan Roese 1495a47a12beSStefan Roese .globl get_pvr 1496a47a12beSStefan Roeseget_pvr: 1497a47a12beSStefan Roese mfspr r3,PVR 1498a47a12beSStefan Roese blr 1499a47a12beSStefan Roese 1500a47a12beSStefan Roese .globl get_svr 1501a47a12beSStefan Roeseget_svr: 1502a47a12beSStefan Roese mfspr r3,SVR 1503a47a12beSStefan Roese blr 1504a47a12beSStefan Roese 1505a47a12beSStefan Roese .globl wr_tcr 1506a47a12beSStefan Roesewr_tcr: 1507a47a12beSStefan Roese mtspr TCR,r3 1508a47a12beSStefan Roese blr 1509a47a12beSStefan Roese 1510a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 1511a47a12beSStefan Roese/* Function: in8 */ 1512a47a12beSStefan Roese/* Description: Input 8 bits */ 1513a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 1514a47a12beSStefan Roese .globl in8 1515a47a12beSStefan Roesein8: 1516a47a12beSStefan Roese lbz r3,0x0000(r3) 1517a47a12beSStefan Roese blr 1518a47a12beSStefan Roese 1519a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 1520a47a12beSStefan Roese/* Function: out8 */ 1521a47a12beSStefan Roese/* Description: Output 8 bits */ 1522a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 1523a47a12beSStefan Roese .globl out8 1524a47a12beSStefan Roeseout8: 1525a47a12beSStefan Roese stb r4,0x0000(r3) 1526a47a12beSStefan Roese sync 1527a47a12beSStefan Roese blr 1528a47a12beSStefan Roese 1529a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 1530a47a12beSStefan Roese/* Function: out16 */ 1531a47a12beSStefan Roese/* Description: Output 16 bits */ 1532a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 1533a47a12beSStefan Roese .globl out16 1534a47a12beSStefan Roeseout16: 1535a47a12beSStefan Roese sth r4,0x0000(r3) 1536a47a12beSStefan Roese sync 1537a47a12beSStefan Roese blr 1538a47a12beSStefan Roese 1539a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 1540a47a12beSStefan Roese/* Function: out16r */ 1541a47a12beSStefan Roese/* Description: Byte reverse and output 16 bits */ 1542a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 1543a47a12beSStefan Roese .globl out16r 1544a47a12beSStefan Roeseout16r: 1545a47a12beSStefan Roese sthbrx r4,r0,r3 1546a47a12beSStefan Roese sync 1547a47a12beSStefan Roese blr 1548a47a12beSStefan Roese 1549a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 1550a47a12beSStefan Roese/* Function: out32 */ 1551a47a12beSStefan Roese/* Description: Output 32 bits */ 1552a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 1553a47a12beSStefan Roese .globl out32 1554a47a12beSStefan Roeseout32: 1555a47a12beSStefan Roese stw r4,0x0000(r3) 1556a47a12beSStefan Roese sync 1557a47a12beSStefan Roese blr 1558a47a12beSStefan Roese 1559a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 1560a47a12beSStefan Roese/* Function: out32r */ 1561a47a12beSStefan Roese/* Description: Byte reverse and output 32 bits */ 1562a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 1563a47a12beSStefan Roese .globl out32r 1564a47a12beSStefan Roeseout32r: 1565a47a12beSStefan Roese stwbrx r4,r0,r3 1566a47a12beSStefan Roese sync 1567a47a12beSStefan Roese blr 1568a47a12beSStefan Roese 1569a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 1570a47a12beSStefan Roese/* Function: in16 */ 1571a47a12beSStefan Roese/* Description: Input 16 bits */ 1572a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 1573a47a12beSStefan Roese .globl in16 1574a47a12beSStefan Roesein16: 1575a47a12beSStefan Roese lhz r3,0x0000(r3) 1576a47a12beSStefan Roese blr 1577a47a12beSStefan Roese 1578a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 1579a47a12beSStefan Roese/* Function: in16r */ 1580a47a12beSStefan Roese/* Description: Input 16 bits and byte reverse */ 1581a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 1582a47a12beSStefan Roese .globl in16r 1583a47a12beSStefan Roesein16r: 1584a47a12beSStefan Roese lhbrx r3,r0,r3 1585a47a12beSStefan Roese blr 1586a47a12beSStefan Roese 1587a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 1588a47a12beSStefan Roese/* Function: in32 */ 1589a47a12beSStefan Roese/* Description: Input 32 bits */ 1590a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 1591a47a12beSStefan Roese .globl in32 1592a47a12beSStefan Roesein32: 1593a47a12beSStefan Roese lwz 3,0x0000(3) 1594a47a12beSStefan Roese blr 1595a47a12beSStefan Roese 1596a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 1597a47a12beSStefan Roese/* Function: in32r */ 1598a47a12beSStefan Roese/* Description: Input 32 bits and byte reverse */ 1599a47a12beSStefan Roese/*------------------------------------------------------------------------------- */ 1600a47a12beSStefan Roese .globl in32r 1601a47a12beSStefan Roesein32r: 1602a47a12beSStefan Roese lwbrx r3,r0,r3 1603a47a12beSStefan Roese blr 1604a47a12beSStefan Roese#endif /* !CONFIG_NAND_SPL */ 1605a47a12beSStefan Roese 1606a47a12beSStefan Roese/*------------------------------------------------------------------------------*/ 1607a47a12beSStefan Roese 1608a47a12beSStefan Roese/* 1609a47a12beSStefan Roese * void write_tlb(mas0, mas1, mas2, mas3, mas7) 1610a47a12beSStefan Roese */ 1611a47a12beSStefan Roese .globl write_tlb 1612a47a12beSStefan Roesewrite_tlb: 1613a47a12beSStefan Roese mtspr MAS0,r3 1614a47a12beSStefan Roese mtspr MAS1,r4 1615a47a12beSStefan Roese mtspr MAS2,r5 1616a47a12beSStefan Roese mtspr MAS3,r6 1617a47a12beSStefan Roese#ifdef CONFIG_ENABLE_36BIT_PHYS 1618a47a12beSStefan Roese mtspr MAS7,r7 1619a47a12beSStefan Roese#endif 1620a47a12beSStefan Roese li r3,0 1621a47a12beSStefan Roese#ifdef CONFIG_SYS_BOOK3E_HV 1622a47a12beSStefan Roese mtspr MAS8,r3 1623a47a12beSStefan Roese#endif 1624a47a12beSStefan Roese isync 1625a47a12beSStefan Roese tlbwe 1626a47a12beSStefan Roese msync 1627a47a12beSStefan Roese isync 1628a47a12beSStefan Roese blr 1629a47a12beSStefan Roese 1630a47a12beSStefan Roese/* 1631a47a12beSStefan Roese * void relocate_code (addr_sp, gd, addr_moni) 1632a47a12beSStefan Roese * 1633a47a12beSStefan Roese * This "function" does not return, instead it continues in RAM 1634a47a12beSStefan Roese * after relocating the monitor code. 1635a47a12beSStefan Roese * 1636a47a12beSStefan Roese * r3 = dest 1637a47a12beSStefan Roese * r4 = src 1638a47a12beSStefan Roese * r5 = length in bytes 1639a47a12beSStefan Roese * r6 = cachelinesize 1640a47a12beSStefan Roese */ 1641a47a12beSStefan Roese .globl relocate_code 1642a47a12beSStefan Roeserelocate_code: 1643a47a12beSStefan Roese mr r1,r3 /* Set new stack pointer */ 1644a47a12beSStefan Roese mr r9,r4 /* Save copy of Init Data pointer */ 1645a47a12beSStefan Roese mr r10,r5 /* Save copy of Destination Address */ 1646a47a12beSStefan Roese 1647a47a12beSStefan Roese GET_GOT 1648a47a12beSStefan Roese mr r3,r5 /* Destination Address */ 1649a47a12beSStefan Roese lis r4,CONFIG_SYS_MONITOR_BASE@h /* Source Address */ 1650a47a12beSStefan Roese ori r4,r4,CONFIG_SYS_MONITOR_BASE@l 1651a47a12beSStefan Roese lwz r5,GOT(__init_end) 1652a47a12beSStefan Roese sub r5,r5,r4 1653a47a12beSStefan Roese li r6,CONFIG_SYS_CACHELINE_SIZE /* Cache Line Size */ 1654a47a12beSStefan Roese 1655a47a12beSStefan Roese /* 1656a47a12beSStefan Roese * Fix GOT pointer: 1657a47a12beSStefan Roese * 1658a47a12beSStefan Roese * New GOT-PTR = (old GOT-PTR - CONFIG_SYS_MONITOR_BASE) + Destination Address 1659a47a12beSStefan Roese * 1660a47a12beSStefan Roese * Offset: 1661a47a12beSStefan Roese */ 1662a47a12beSStefan Roese sub r15,r10,r4 1663a47a12beSStefan Roese 1664a47a12beSStefan Roese /* First our own GOT */ 1665a47a12beSStefan Roese add r12,r12,r15 1666a47a12beSStefan Roese /* the the one used by the C code */ 1667a47a12beSStefan Roese add r30,r30,r15 1668a47a12beSStefan Roese 1669a47a12beSStefan Roese /* 1670a47a12beSStefan Roese * Now relocate code 1671a47a12beSStefan Roese */ 1672a47a12beSStefan Roese 1673a47a12beSStefan Roese cmplw cr1,r3,r4 1674a47a12beSStefan Roese addi r0,r5,3 1675a47a12beSStefan Roese srwi. r0,r0,2 1676a47a12beSStefan Roese beq cr1,4f /* In place copy is not necessary */ 1677a47a12beSStefan Roese beq 7f /* Protect against 0 count */ 1678a47a12beSStefan Roese mtctr r0 1679a47a12beSStefan Roese bge cr1,2f 1680a47a12beSStefan Roese 1681a47a12beSStefan Roese la r8,-4(r4) 1682a47a12beSStefan Roese la r7,-4(r3) 1683a47a12beSStefan Roese1: lwzu r0,4(r8) 1684a47a12beSStefan Roese stwu r0,4(r7) 1685a47a12beSStefan Roese bdnz 1b 1686a47a12beSStefan Roese b 4f 1687a47a12beSStefan Roese 1688a47a12beSStefan Roese2: slwi r0,r0,2 1689a47a12beSStefan Roese add r8,r4,r0 1690a47a12beSStefan Roese add r7,r3,r0 1691a47a12beSStefan Roese3: lwzu r0,-4(r8) 1692a47a12beSStefan Roese stwu r0,-4(r7) 1693a47a12beSStefan Roese bdnz 3b 1694a47a12beSStefan Roese 1695a47a12beSStefan Roese/* 1696a47a12beSStefan Roese * Now flush the cache: note that we must start from a cache aligned 1697a47a12beSStefan Roese * address. Otherwise we might miss one cache line. 1698a47a12beSStefan Roese */ 1699a47a12beSStefan Roese4: cmpwi r6,0 1700a47a12beSStefan Roese add r5,r3,r5 1701a47a12beSStefan Roese beq 7f /* Always flush prefetch queue in any case */ 1702a47a12beSStefan Roese subi r0,r6,1 1703a47a12beSStefan Roese andc r3,r3,r0 1704a47a12beSStefan Roese mr r4,r3 1705a47a12beSStefan Roese5: dcbst 0,r4 1706a47a12beSStefan Roese add r4,r4,r6 1707a47a12beSStefan Roese cmplw r4,r5 1708a47a12beSStefan Roese blt 5b 1709a47a12beSStefan Roese sync /* Wait for all dcbst to complete on bus */ 1710a47a12beSStefan Roese mr r4,r3 1711a47a12beSStefan Roese6: icbi 0,r4 1712a47a12beSStefan Roese add r4,r4,r6 1713a47a12beSStefan Roese cmplw r4,r5 1714a47a12beSStefan Roese blt 6b 1715a47a12beSStefan Roese7: sync /* Wait for all icbi to complete on bus */ 1716a47a12beSStefan Roese isync 1717a47a12beSStefan Roese 1718a47a12beSStefan Roese/* 1719a47a12beSStefan Roese * We are done. Do not return, instead branch to second part of board 1720a47a12beSStefan Roese * initialization, now running from RAM. 1721a47a12beSStefan Roese */ 1722a47a12beSStefan Roese 1723a47a12beSStefan Roese addi r0,r10,in_ram - _start + _START_OFFSET 1724689f00fcSPrabhakar Kushwaha 1725689f00fcSPrabhakar Kushwaha /* 1726689f00fcSPrabhakar Kushwaha * As IVPR is going to point RAM address, 1727689f00fcSPrabhakar Kushwaha * Make sure IVOR15 has valid opcode to support debugger 1728689f00fcSPrabhakar Kushwaha */ 1729689f00fcSPrabhakar Kushwaha mtspr IVOR15,r0 1730689f00fcSPrabhakar Kushwaha 1731689f00fcSPrabhakar Kushwaha /* 1732689f00fcSPrabhakar Kushwaha * Re-point the IVPR at RAM 1733689f00fcSPrabhakar Kushwaha */ 1734689f00fcSPrabhakar Kushwaha mtspr IVPR,r10 1735689f00fcSPrabhakar Kushwaha 1736a47a12beSStefan Roese mtlr r0 1737a47a12beSStefan Roese blr /* NEVER RETURNS! */ 1738a47a12beSStefan Roese .globl in_ram 1739a47a12beSStefan Roesein_ram: 1740a47a12beSStefan Roese 1741a47a12beSStefan Roese /* 1742a47a12beSStefan Roese * Relocation Function, r12 point to got2+0x8000 1743a47a12beSStefan Roese * 1744a47a12beSStefan Roese * Adjust got2 pointers, no need to check for 0, this code 1745a47a12beSStefan Roese * already puts a few entries in the table. 1746a47a12beSStefan Roese */ 1747a47a12beSStefan Roese li r0,__got2_entries@sectoff@l 1748a47a12beSStefan Roese la r3,GOT(_GOT2_TABLE_) 1749a47a12beSStefan Roese lwz r11,GOT(_GOT2_TABLE_) 1750a47a12beSStefan Roese mtctr r0 1751a47a12beSStefan Roese sub r11,r3,r11 1752a47a12beSStefan Roese addi r3,r3,-4 1753a47a12beSStefan Roese1: lwzu r0,4(r3) 1754a47a12beSStefan Roese cmpwi r0,0 1755a47a12beSStefan Roese beq- 2f 1756a47a12beSStefan Roese add r0,r0,r11 1757a47a12beSStefan Roese stw r0,0(r3) 1758a47a12beSStefan Roese2: bdnz 1b 1759a47a12beSStefan Roese 1760a47a12beSStefan Roese /* 1761a47a12beSStefan Roese * Now adjust the fixups and the pointers to the fixups 1762a47a12beSStefan Roese * in case we need to move ourselves again. 1763a47a12beSStefan Roese */ 1764a47a12beSStefan Roese li r0,__fixup_entries@sectoff@l 1765a47a12beSStefan Roese lwz r3,GOT(_FIXUP_TABLE_) 1766a47a12beSStefan Roese cmpwi r0,0 1767a47a12beSStefan Roese mtctr r0 1768a47a12beSStefan Roese addi r3,r3,-4 1769a47a12beSStefan Roese beq 4f 1770a47a12beSStefan Roese3: lwzu r4,4(r3) 1771a47a12beSStefan Roese lwzux r0,r4,r11 1772d1e0b10aSJoakim Tjernlund cmpwi r0,0 1773a47a12beSStefan Roese add r0,r0,r11 177434bbf618SJoakim Tjernlund stw r4,0(r3) 1775d1e0b10aSJoakim Tjernlund beq- 5f 1776a47a12beSStefan Roese stw r0,0(r4) 1777d1e0b10aSJoakim Tjernlund5: bdnz 3b 1778a47a12beSStefan Roese4: 1779a47a12beSStefan Roeseclear_bss: 1780a47a12beSStefan Roese /* 1781a47a12beSStefan Roese * Now clear BSS segment 1782a47a12beSStefan Roese */ 1783a47a12beSStefan Roese lwz r3,GOT(__bss_start) 178444c6e659SPo-Yu Chuang lwz r4,GOT(__bss_end__) 1785a47a12beSStefan Roese 1786a47a12beSStefan Roese cmplw 0,r3,r4 1787a47a12beSStefan Roese beq 6f 1788a47a12beSStefan Roese 1789a47a12beSStefan Roese li r0,0 1790a47a12beSStefan Roese5: 1791a47a12beSStefan Roese stw r0,0(r3) 1792a47a12beSStefan Roese addi r3,r3,4 1793a47a12beSStefan Roese cmplw 0,r3,r4 1794a47a12beSStefan Roese bne 5b 1795a47a12beSStefan Roese6: 1796a47a12beSStefan Roese 1797a47a12beSStefan Roese mr r3,r9 /* Init Data pointer */ 1798a47a12beSStefan Roese mr r4,r10 /* Destination Address */ 1799a47a12beSStefan Roese bl board_init_r 1800a47a12beSStefan Roese 1801a47a12beSStefan Roese#ifndef CONFIG_NAND_SPL 1802a47a12beSStefan Roese /* 1803a47a12beSStefan Roese * Copy exception vector code to low memory 1804a47a12beSStefan Roese * 1805a47a12beSStefan Roese * r3: dest_addr 1806a47a12beSStefan Roese * r7: source address, r8: end address, r9: target address 1807a47a12beSStefan Roese */ 1808a47a12beSStefan Roese .globl trap_init 1809a47a12beSStefan Roesetrap_init: 1810a47a12beSStefan Roese mflr r4 /* save link register */ 1811a47a12beSStefan Roese GET_GOT 1812a47a12beSStefan Roese lwz r7,GOT(_start_of_vectors) 1813a47a12beSStefan Roese lwz r8,GOT(_end_of_vectors) 1814a47a12beSStefan Roese 1815a47a12beSStefan Roese li r9,0x100 /* reset vector always at 0x100 */ 1816a47a12beSStefan Roese 1817a47a12beSStefan Roese cmplw 0,r7,r8 1818a47a12beSStefan Roese bgelr /* return if r7>=r8 - just in case */ 1819a47a12beSStefan Roese1: 1820a47a12beSStefan Roese lwz r0,0(r7) 1821a47a12beSStefan Roese stw r0,0(r9) 1822a47a12beSStefan Roese addi r7,r7,4 1823a47a12beSStefan Roese addi r9,r9,4 1824a47a12beSStefan Roese cmplw 0,r7,r8 1825a47a12beSStefan Roese bne 1b 1826a47a12beSStefan Roese 1827a47a12beSStefan Roese /* 1828a47a12beSStefan Roese * relocate `hdlr' and `int_return' entries 1829a47a12beSStefan Roese */ 1830a47a12beSStefan Roese li r7,.L_CriticalInput - _start + _START_OFFSET 1831a47a12beSStefan Roese bl trap_reloc 1832a47a12beSStefan Roese li r7,.L_MachineCheck - _start + _START_OFFSET 1833a47a12beSStefan Roese bl trap_reloc 1834a47a12beSStefan Roese li r7,.L_DataStorage - _start + _START_OFFSET 1835a47a12beSStefan Roese bl trap_reloc 1836a47a12beSStefan Roese li r7,.L_InstStorage - _start + _START_OFFSET 1837a47a12beSStefan Roese bl trap_reloc 1838a47a12beSStefan Roese li r7,.L_ExtInterrupt - _start + _START_OFFSET 1839a47a12beSStefan Roese bl trap_reloc 1840a47a12beSStefan Roese li r7,.L_Alignment - _start + _START_OFFSET 1841a47a12beSStefan Roese bl trap_reloc 1842a47a12beSStefan Roese li r7,.L_ProgramCheck - _start + _START_OFFSET 1843a47a12beSStefan Roese bl trap_reloc 1844a47a12beSStefan Roese li r7,.L_FPUnavailable - _start + _START_OFFSET 1845a47a12beSStefan Roese bl trap_reloc 1846a47a12beSStefan Roese li r7,.L_Decrementer - _start + _START_OFFSET 1847a47a12beSStefan Roese bl trap_reloc 1848a47a12beSStefan Roese li r7,.L_IntervalTimer - _start + _START_OFFSET 1849a47a12beSStefan Roese li r8,_end_of_vectors - _start + _START_OFFSET 1850a47a12beSStefan Roese2: 1851a47a12beSStefan Roese bl trap_reloc 1852a47a12beSStefan Roese addi r7,r7,0x100 /* next exception vector */ 1853a47a12beSStefan Roese cmplw 0,r7,r8 1854a47a12beSStefan Roese blt 2b 1855a47a12beSStefan Roese 185664829bafSPrabhakar Kushwaha /* Update IVORs as per relocated vector table address */ 185764829bafSPrabhakar Kushwaha li r7,0x0100 185864829bafSPrabhakar Kushwaha mtspr IVOR0,r7 /* 0: Critical input */ 185964829bafSPrabhakar Kushwaha li r7,0x0200 186064829bafSPrabhakar Kushwaha mtspr IVOR1,r7 /* 1: Machine check */ 186164829bafSPrabhakar Kushwaha li r7,0x0300 186264829bafSPrabhakar Kushwaha mtspr IVOR2,r7 /* 2: Data storage */ 186364829bafSPrabhakar Kushwaha li r7,0x0400 186464829bafSPrabhakar Kushwaha mtspr IVOR3,r7 /* 3: Instruction storage */ 186564829bafSPrabhakar Kushwaha li r7,0x0500 186664829bafSPrabhakar Kushwaha mtspr IVOR4,r7 /* 4: External interrupt */ 186764829bafSPrabhakar Kushwaha li r7,0x0600 186864829bafSPrabhakar Kushwaha mtspr IVOR5,r7 /* 5: Alignment */ 186964829bafSPrabhakar Kushwaha li r7,0x0700 187064829bafSPrabhakar Kushwaha mtspr IVOR6,r7 /* 6: Program check */ 187164829bafSPrabhakar Kushwaha li r7,0x0800 187264829bafSPrabhakar Kushwaha mtspr IVOR7,r7 /* 7: floating point unavailable */ 187364829bafSPrabhakar Kushwaha li r7,0x0900 187464829bafSPrabhakar Kushwaha mtspr IVOR8,r7 /* 8: System call */ 187564829bafSPrabhakar Kushwaha /* 9: Auxiliary processor unavailable(unsupported) */ 187664829bafSPrabhakar Kushwaha li r7,0x0a00 187764829bafSPrabhakar Kushwaha mtspr IVOR10,r7 /* 10: Decrementer */ 187864829bafSPrabhakar Kushwaha li r7,0x0b00 187964829bafSPrabhakar Kushwaha mtspr IVOR11,r7 /* 11: Interval timer */ 188064829bafSPrabhakar Kushwaha li r7,0x0c00 188164829bafSPrabhakar Kushwaha mtspr IVOR12,r7 /* 12: Watchdog timer */ 188264829bafSPrabhakar Kushwaha li r7,0x0d00 188364829bafSPrabhakar Kushwaha mtspr IVOR13,r7 /* 13: Data TLB error */ 188464829bafSPrabhakar Kushwaha li r7,0x0e00 188564829bafSPrabhakar Kushwaha mtspr IVOR14,r7 /* 14: Instruction TLB error */ 188664829bafSPrabhakar Kushwaha li r7,0x0f00 188764829bafSPrabhakar Kushwaha mtspr IVOR15,r7 /* 15: Debug */ 188864829bafSPrabhakar Kushwaha 1889a47a12beSStefan Roese lis r7,0x0 1890a47a12beSStefan Roese mtspr IVPR,r7 1891a47a12beSStefan Roese 1892a47a12beSStefan Roese mtlr r4 /* restore link register */ 1893a47a12beSStefan Roese blr 1894a47a12beSStefan Roese 1895a47a12beSStefan Roese.globl unlock_ram_in_cache 1896a47a12beSStefan Roeseunlock_ram_in_cache: 1897a47a12beSStefan Roese /* invalidate the INIT_RAM section */ 1898a47a12beSStefan Roese lis r3,(CONFIG_SYS_INIT_RAM_ADDR & ~(CONFIG_SYS_CACHELINE_SIZE-1))@h 1899a47a12beSStefan Roese ori r3,r3,(CONFIG_SYS_INIT_RAM_ADDR & ~(CONFIG_SYS_CACHELINE_SIZE-1))@l 1900a47a12beSStefan Roese mfspr r4,L1CFG0 1901a47a12beSStefan Roese andi. r4,r4,0x1ff 1902a47a12beSStefan Roese slwi r4,r4,(10 - 1 - L1_CACHE_SHIFT) 1903a47a12beSStefan Roese mtctr r4 1904a47a12beSStefan Roese1: dcbi r0,r3 1905a47a12beSStefan Roese addi r3,r3,CONFIG_SYS_CACHELINE_SIZE 1906a47a12beSStefan Roese bdnz 1b 1907a47a12beSStefan Roese sync 1908a47a12beSStefan Roese 1909a47a12beSStefan Roese /* Invalidate the TLB entries for the cache */ 1910a47a12beSStefan Roese lis r3,CONFIG_SYS_INIT_RAM_ADDR@h 1911a47a12beSStefan Roese ori r3,r3,CONFIG_SYS_INIT_RAM_ADDR@l 1912a47a12beSStefan Roese tlbivax 0,r3 1913a47a12beSStefan Roese addi r3,r3,0x1000 1914a47a12beSStefan Roese tlbivax 0,r3 1915a47a12beSStefan Roese addi r3,r3,0x1000 1916a47a12beSStefan Roese tlbivax 0,r3 1917a47a12beSStefan Roese addi r3,r3,0x1000 1918a47a12beSStefan Roese tlbivax 0,r3 1919a47a12beSStefan Roese isync 1920a47a12beSStefan Roese blr 1921a47a12beSStefan Roese 1922a47a12beSStefan Roese.globl flush_dcache 1923a47a12beSStefan Roeseflush_dcache: 1924a47a12beSStefan Roese mfspr r3,SPRN_L1CFG0 1925a47a12beSStefan Roese 1926a47a12beSStefan Roese rlwinm r5,r3,9,3 /* Extract cache block size */ 1927a47a12beSStefan Roese twlgti r5,1 /* Only 32 and 64 byte cache blocks 1928a47a12beSStefan Roese * are currently defined. 1929a47a12beSStefan Roese */ 1930a47a12beSStefan Roese li r4,32 1931a47a12beSStefan Roese subfic r6,r5,2 /* r6 = log2(1KiB / cache block size) - 1932a47a12beSStefan Roese * log2(number of ways) 1933a47a12beSStefan Roese */ 1934a47a12beSStefan Roese slw r5,r4,r5 /* r5 = cache block size */ 1935a47a12beSStefan Roese 1936a47a12beSStefan Roese rlwinm r7,r3,0,0xff /* Extract number of KiB in the cache */ 1937a47a12beSStefan Roese mulli r7,r7,13 /* An 8-way cache will require 13 1938a47a12beSStefan Roese * loads per set. 1939a47a12beSStefan Roese */ 1940a47a12beSStefan Roese slw r7,r7,r6 1941a47a12beSStefan Roese 1942a47a12beSStefan Roese /* save off HID0 and set DCFA */ 1943a47a12beSStefan Roese mfspr r8,SPRN_HID0 1944a47a12beSStefan Roese ori r9,r8,HID0_DCFA@l 1945a47a12beSStefan Roese mtspr SPRN_HID0,r9 1946a47a12beSStefan Roese isync 1947a47a12beSStefan Roese 1948a47a12beSStefan Roese lis r4,0 1949a47a12beSStefan Roese mtctr r7 1950a47a12beSStefan Roese 1951a47a12beSStefan Roese1: lwz r3,0(r4) /* Load... */ 1952a47a12beSStefan Roese add r4,r4,r5 1953a47a12beSStefan Roese bdnz 1b 1954a47a12beSStefan Roese 1955a47a12beSStefan Roese msync 1956a47a12beSStefan Roese lis r4,0 1957a47a12beSStefan Roese mtctr r7 1958a47a12beSStefan Roese 1959a47a12beSStefan Roese1: dcbf 0,r4 /* ...and flush. */ 1960a47a12beSStefan Roese add r4,r4,r5 1961a47a12beSStefan Roese bdnz 1b 1962a47a12beSStefan Roese 1963a47a12beSStefan Roese /* restore HID0 */ 1964a47a12beSStefan Roese mtspr SPRN_HID0,r8 1965a47a12beSStefan Roese isync 1966a47a12beSStefan Roese 1967a47a12beSStefan Roese blr 1968a47a12beSStefan Roese 1969a47a12beSStefan Roese.globl setup_ivors 1970a47a12beSStefan Roesesetup_ivors: 1971a47a12beSStefan Roese 1972a47a12beSStefan Roese#include "fixed_ivor.S" 1973a47a12beSStefan Roese blr 1974a47a12beSStefan Roese#endif /* !CONFIG_NAND_SPL */ 1975