1a47a12beSStefan Roese/* 2709389b6SYork Sun * Copyright 2008-2012 Freescale Semiconductor, Inc. 3a47a12beSStefan Roese * Kumar Gala <kumar.gala@freescale.com> 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 2425ddd1fbSWolfgang Denk#include <asm-offsets.h> 25a47a12beSStefan Roese#include <config.h> 26a47a12beSStefan Roese#include <mpc85xx.h> 27a47a12beSStefan Roese#include <version.h> 28a47a12beSStefan Roese 29a47a12beSStefan Roese#define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */ 30a47a12beSStefan Roese 31a47a12beSStefan Roese#include <ppc_asm.tmpl> 32a47a12beSStefan Roese#include <ppc_defs.h> 33a47a12beSStefan Roese 34a47a12beSStefan Roese#include <asm/cache.h> 35a47a12beSStefan Roese#include <asm/mmu.h> 36a47a12beSStefan Roese 37a47a12beSStefan Roese/* To boot secondary cpus, we need a place for them to start up. 38a47a12beSStefan Roese * Normally, they start at 0xfffffffc, but that's usually the 39a47a12beSStefan Roese * firmware, and we don't want to have to run the firmware again. 40a47a12beSStefan Roese * Instead, the primary cpu will set the BPTR to point here to 41a47a12beSStefan Roese * this page. We then set up the core, and head to 42a47a12beSStefan Roese * start_secondary. Note that this means that the code below 43a47a12beSStefan Roese * must never exceed 1023 instructions (the branch at the end 44a47a12beSStefan Roese * would then be the 1024th). 45a47a12beSStefan Roese */ 46a47a12beSStefan Roese .globl __secondary_start_page 47a47a12beSStefan Roese .align 12 48a47a12beSStefan Roese__secondary_start_page: 49a47a12beSStefan Roese/* First do some preliminary setup */ 50a47a12beSStefan Roese lis r3, HID0_EMCP@h /* enable machine check */ 51a47a12beSStefan Roese#ifndef CONFIG_E500MC 52a47a12beSStefan Roese ori r3,r3,HID0_TBEN@l /* enable Timebase */ 53a47a12beSStefan Roese#endif 54a47a12beSStefan Roese#ifdef CONFIG_PHYS_64BIT 55a47a12beSStefan Roese ori r3,r3,HID0_ENMAS7@l /* enable MAS7 updates */ 56a47a12beSStefan Roese#endif 57a47a12beSStefan Roese mtspr SPRN_HID0,r3 58a47a12beSStefan Roese 59a47a12beSStefan Roese#ifndef CONFIG_E500MC 60a47a12beSStefan Roese li r3,(HID1_ASTME|HID1_ABE)@l /* Addr streaming & broadcast */ 61a47a12beSStefan Roese mfspr r0,PVR 62a47a12beSStefan Roese andi. r0,r0,0xff 63a47a12beSStefan Roese cmpwi r0,0x50@l /* if we are rev 5.0 or greater set MBDD */ 64a47a12beSStefan Roese blt 1f 65a47a12beSStefan Roese /* Set MBDD bit also */ 66a47a12beSStefan Roese ori r3, r3, HID1_MBDD@l 67a47a12beSStefan Roese1: 68a47a12beSStefan Roese mtspr SPRN_HID1,r3 69a47a12beSStefan Roese#endif 70a47a12beSStefan Roese 7143f082bbSKumar Gala#ifdef CONFIG_SYS_FSL_ERRATUM_CPU_A003999 7243f082bbSKumar Gala mfspr r3,977 7343f082bbSKumar Gala oris r3,r3,0x0100 7443f082bbSKumar Gala mtspr 977,r3 7543f082bbSKumar Gala#endif 7643f082bbSKumar Gala 7733eee330SScott Wood#ifdef CONFIG_SYS_FSL_ERRATUM_A004510 7833eee330SScott Wood mfspr r3,SPRN_SVR 7933eee330SScott Wood rlwinm r3,r3,0,0xff 8033eee330SScott Wood li r4,CONFIG_SYS_FSL_ERRATUM_A004510_SVR_REV 8133eee330SScott Wood cmpw r3,r4 8233eee330SScott Wood beq 1f 8333eee330SScott Wood 8433eee330SScott Wood#ifdef CONFIG_SYS_FSL_ERRATUM_A004510_SVR_REV2 8533eee330SScott Wood li r4,CONFIG_SYS_FSL_ERRATUM_A004510_SVR_REV2 8633eee330SScott Wood cmpw r3,r4 8733eee330SScott Wood beq 1f 8833eee330SScott Wood#endif 8933eee330SScott Wood 9033eee330SScott Wood /* Not a supported revision affected by erratum */ 9133eee330SScott Wood b 2f 9233eee330SScott Wood 9333eee330SScott Wood1: /* Erratum says set bits 55:60 to 001001 */ 9433eee330SScott Wood msync 9533eee330SScott Wood isync 9633eee330SScott Wood mfspr r3,976 9733eee330SScott Wood li r4,0x48 9833eee330SScott Wood rlwimi r3,r4,0,0x1f8 9933eee330SScott Wood mtspr 976,r3 10033eee330SScott Wood isync 10133eee330SScott Wood2: 10233eee330SScott Wood#endif 10333eee330SScott Wood 104a47a12beSStefan Roese /* Enable branch prediction */ 105a47a12beSStefan Roese lis r3,BUCSR_ENABLE@h 106a47a12beSStefan Roese ori r3,r3,BUCSR_ENABLE@l 107a47a12beSStefan Roese mtspr SPRN_BUCSR,r3 108a47a12beSStefan Roese 109a47a12beSStefan Roese /* Ensure TB is 0 */ 110a47a12beSStefan Roese li r3,0 111a47a12beSStefan Roese mttbl r3 112a47a12beSStefan Roese mttbu r3 113a47a12beSStefan Roese 114a47a12beSStefan Roese /* Enable/invalidate the I-Cache */ 115a47a12beSStefan Roese lis r2,(L1CSR1_ICFI|L1CSR1_ICLFR)@h 116a47a12beSStefan Roese ori r2,r2,(L1CSR1_ICFI|L1CSR1_ICLFR)@l 117a47a12beSStefan Roese mtspr SPRN_L1CSR1,r2 118a47a12beSStefan Roese1: 119a47a12beSStefan Roese mfspr r3,SPRN_L1CSR1 120a47a12beSStefan Roese and. r1,r3,r2 121a47a12beSStefan Roese bne 1b 122a47a12beSStefan Roese 123a47a12beSStefan Roese lis r3,(L1CSR1_CPE|L1CSR1_ICE)@h 124a47a12beSStefan Roese ori r3,r3,(L1CSR1_CPE|L1CSR1_ICE)@l 125a47a12beSStefan Roese mtspr SPRN_L1CSR1,r3 126a47a12beSStefan Roese isync 127a47a12beSStefan Roese2: 128a47a12beSStefan Roese mfspr r3,SPRN_L1CSR1 129a47a12beSStefan Roese andi. r1,r3,L1CSR1_ICE@l 130a47a12beSStefan Roese beq 2b 131a47a12beSStefan Roese 132a47a12beSStefan Roese /* Enable/invalidate the D-Cache */ 133a47a12beSStefan Roese lis r2,(L1CSR0_DCFI|L1CSR0_DCLFR)@h 134a47a12beSStefan Roese ori r2,r2,(L1CSR0_DCFI|L1CSR0_DCLFR)@l 135a47a12beSStefan Roese mtspr SPRN_L1CSR0,r2 136a47a12beSStefan Roese1: 137a47a12beSStefan Roese mfspr r3,SPRN_L1CSR0 138a47a12beSStefan Roese and. r1,r3,r2 139a47a12beSStefan Roese bne 1b 140a47a12beSStefan Roese 141a47a12beSStefan Roese lis r3,(L1CSR0_CPE|L1CSR0_DCE)@h 142a47a12beSStefan Roese ori r3,r3,(L1CSR0_CPE|L1CSR0_DCE)@l 143a47a12beSStefan Roese mtspr SPRN_L1CSR0,r3 144a47a12beSStefan Roese isync 145a47a12beSStefan Roese2: 146a47a12beSStefan Roese mfspr r3,SPRN_L1CSR0 147a47a12beSStefan Roese andi. r1,r3,L1CSR0_DCE@l 148a47a12beSStefan Roese beq 2b 149a47a12beSStefan Roese 150a47a12beSStefan Roese#define toreset(x) (x - __secondary_start_page + 0xfffff000) 151a47a12beSStefan Roese 152a47a12beSStefan Roese /* get our PIR to figure out our table entry */ 153ffd06e02SYork Sun lis r3,toreset(__spin_table_addr)@h 154ffd06e02SYork Sun ori r3,r3,toreset(__spin_table_addr)@l 155ffd06e02SYork Sun lwz r3,0(r3) 156a47a12beSStefan Roese 157ffd06e02SYork Sun /* 158ffd06e02SYork Sun * r10 has the base address for the entry. 159ffd06e02SYork Sun * we cannot access it yet before setting up a new TLB 160ffd06e02SYork Sun */ 161a47a12beSStefan Roese mfspr r0,SPRN_PIR 162709389b6SYork Sun#if defined(CONFIG_E6500) 163709389b6SYork Sun/* 164709389b6SYork Sun * PIR definition for E6500 165709389b6SYork Sun * 0-17 Reserved (logic 0s) 1660c7e65f3STimur Tabi * 8-19 CHIP_ID, 2'b00 - SoC 1 167709389b6SYork Sun * all others - reserved 1680c7e65f3STimur Tabi * 20-24 CLUSTER_ID 5'b00000 - CCM 1 169709389b6SYork Sun * all others - reserved 1700c7e65f3STimur Tabi * 25-26 CORE_CLUSTER_ID 2'b00 - cluster 1 1710c7e65f3STimur Tabi * 2'b01 - cluster 2 1720c7e65f3STimur Tabi * 2'b10 - cluster 3 1730c7e65f3STimur Tabi * 2'b11 - cluster 4 1740c7e65f3STimur Tabi * 27-28 CORE_ID 2'b00 - core 0 1750c7e65f3STimur Tabi * 2'b01 - core 1 1760c7e65f3STimur Tabi * 2'b10 - core 2 1770c7e65f3STimur Tabi * 2'b11 - core 3 1780c7e65f3STimur Tabi * 29-31 THREAD_ID 3'b000 - thread 0 1790c7e65f3STimur Tabi * 3'b001 - thread 1 180709389b6SYork Sun */ 181709389b6SYork Sun rlwinm r4,r0,29,25,31 182709389b6SYork Sun#elif defined(CONFIG_E500MC) 183a47a12beSStefan Roese rlwinm r4,r0,27,27,31 184a47a12beSStefan Roese#else 185a47a12beSStefan Roese mr r4,r0 186a47a12beSStefan Roese#endif 187ffd06e02SYork Sun slwi r8,r4,6 /* spin table is padded to 64 byte */ 188a47a12beSStefan Roese add r10,r3,r8 189a47a12beSStefan Roese 190709389b6SYork Sun#ifdef CONFIG_E6500 191709389b6SYork Sun mfspr r0,SPRN_PIR 192709389b6SYork Sun /* 193709389b6SYork Sun * core 0 thread 0: pir reset value 0x00, new pir 0 194709389b6SYork Sun * core 0 thread 1: pir reset value 0x01, new pir 1 195709389b6SYork Sun * core 1 thread 0: pir reset value 0x08, new pir 2 196709389b6SYork Sun * core 1 thread 1: pir reset value 0x09, new pir 3 197709389b6SYork Sun * core 2 thread 0: pir reset value 0x10, new pir 4 198709389b6SYork Sun * core 2 thread 1: pir reset value 0x11, new pir 5 199709389b6SYork Sun * etc. 200709389b6SYork Sun * 201709389b6SYork Sun * Only thread 0 of each core will be running, updating PIR doesn't 202709389b6SYork Sun * need to deal with the thread bits. 203709389b6SYork Sun */ 204709389b6SYork Sun rlwinm r4,r0,30,24,30 205709389b6SYork Sun#endif 206709389b6SYork Sun 207709389b6SYork Sun mtspr SPRN_PIR,r4 /* write to PIR register */ 208709389b6SYork Sun 2096d2b9da1SYork Sun#ifdef CONFIG_SYS_CACHE_STASHING 2106d2b9da1SYork Sun /* set stash id to (coreID) * 2 + 32 + L1 CT (0) */ 2116d2b9da1SYork Sun slwi r8,r4,1 2126d2b9da1SYork Sun addi r8,r8,32 2136d2b9da1SYork Sun mtspr L1CSR2,r8 2146d2b9da1SYork Sun#endif 2156d2b9da1SYork Sun 2165e23ab0aSYork Sun#if defined(CONFIG_SYS_P4080_ERRATUM_CPU22) || \ 2175e23ab0aSYork Sun defined(CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011) 2185e23ab0aSYork Sun /* 2195e23ab0aSYork Sun * CPU22 applies to P4080 rev 1.0, 2.0, fixed in 3.0 2205e23ab0aSYork Sun * NMG_CPU_A011 applies to P4080 rev 1.0, 2.0, fixed in 3.0 2215e23ab0aSYork Sun * also appleis to P3041 rev 1.0, 1.1, P2041 rev 1.0, 1.1 2225e23ab0aSYork Sun */ 2231e9ea85fSYork Sun mfspr r3,SPRN_SVR 2245e23ab0aSYork Sun rlwinm r6,r3,24,~0x800 /* clear E bit */ 2251e9ea85fSYork Sun 2265e23ab0aSYork Sun lis r5,SVR_P4080@h 2275e23ab0aSYork Sun ori r5,r5,SVR_P4080@l 2285e23ab0aSYork Sun cmpw r6,r5 2295e23ab0aSYork Sun bne 1f 2305e23ab0aSYork Sun 2315e23ab0aSYork Sun rlwinm r3,r3,0,0xf0 2325e23ab0aSYork Sun li r5,0x30 2335e23ab0aSYork Sun cmpw r3,r5 2345e23ab0aSYork Sun bge 2f 2355e23ab0aSYork Sun1: 23657125f22SYork Sun#ifdef CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011 23757125f22SYork Sun lis r3,toreset(enable_cpu_a011_workaround)@ha 23857125f22SYork Sun lwz r3,toreset(enable_cpu_a011_workaround)@l(r3) 23957125f22SYork Sun cmpwi r3,0 24057125f22SYork Sun beq 2f 24157125f22SYork Sun#endif 2425e23ab0aSYork Sun mfspr r3,L1CSR2 2435e23ab0aSYork Sun oris r3,r3,(L1CSR2_DCWS)@h 2445e23ab0aSYork Sun mtspr L1CSR2,r3 2451e9ea85fSYork Sun2: 246fd3c9befSKumar Gala#endif 247fd3c9befSKumar Gala 248a47a12beSStefan Roese#ifdef CONFIG_BACKSIDE_L2_CACHE 249acf3f8daSKumar Gala /* skip L2 setup on P2040/P2040E as they have no L2 */ 250feae3424SYork Sun mfspr r3,SPRN_SVR 251feae3424SYork Sun rlwinm r6,r3,24,~0x800 /* clear E bit of SVR */ 252feae3424SYork Sun 253acf3f8daSKumar Gala lis r3,SVR_P2040@h 254acf3f8daSKumar Gala ori r3,r3,SVR_P2040@l 255feae3424SYork Sun cmpw r6,r3 256acf3f8daSKumar Gala beq 3f 257acf3f8daSKumar Gala 258a47a12beSStefan Roese /* Enable/invalidate the L2 cache */ 259a47a12beSStefan Roese msync 260a47a12beSStefan Roese lis r2,(L2CSR0_L2FI|L2CSR0_L2LFC)@h 261a47a12beSStefan Roese ori r2,r2,(L2CSR0_L2FI|L2CSR0_L2LFC)@l 262a47a12beSStefan Roese mtspr SPRN_L2CSR0,r2 263a47a12beSStefan Roese1: 264a47a12beSStefan Roese mfspr r3,SPRN_L2CSR0 265a47a12beSStefan Roese and. r1,r3,r2 266a47a12beSStefan Roese bne 1b 267a47a12beSStefan Roese 268a47a12beSStefan Roese#ifdef CONFIG_SYS_CACHE_STASHING 269a47a12beSStefan Roese /* set stash id to (coreID) * 2 + 32 + L2 (1) */ 270a47a12beSStefan Roese addi r3,r8,1 271a47a12beSStefan Roese mtspr SPRN_L2CSR1,r3 272a47a12beSStefan Roese#endif 273a47a12beSStefan Roese 274a47a12beSStefan Roese lis r3,CONFIG_SYS_INIT_L2CSR0@h 275a47a12beSStefan Roese ori r3,r3,CONFIG_SYS_INIT_L2CSR0@l 276a47a12beSStefan Roese mtspr SPRN_L2CSR0,r3 277a47a12beSStefan Roese isync 278a47a12beSStefan Roese2: 279a47a12beSStefan Roese mfspr r3,SPRN_L2CSR0 280a47a12beSStefan Roese andis. r1,r3,L2CSR0_L2E@h 281a47a12beSStefan Roese beq 2b 282a47a12beSStefan Roese#endif 283acf3f8daSKumar Gala3: 284ffd06e02SYork Sun /* setup mapping for the spin table, WIMGE=0b00100 */ 285ffd06e02SYork Sun lis r13,toreset(__spin_table_addr)@h 286ffd06e02SYork Sun ori r13,r13,toreset(__spin_table_addr)@l 287ffd06e02SYork Sun lwz r13,0(r13) 288ffd06e02SYork Sun /* mask by 4K */ 289ffd06e02SYork Sun rlwinm r13,r13,0,0,19 290a47a12beSStefan Roese 291ffd06e02SYork Sun lis r11,(MAS0_TLBSEL(1)|MAS0_ESEL(1))@h 292ffd06e02SYork Sun mtspr SPRN_MAS0,r11 293ffd06e02SYork Sun lis r11,(MAS1_VALID|MAS1_IPROT)@h 294ffd06e02SYork Sun ori r11,r11,(MAS1_TS|MAS1_TSIZE(BOOKE_PAGESZ_4K))@l 295ffd06e02SYork Sun mtspr SPRN_MAS1,r11 296ffd06e02SYork Sun oris r11,r13,(MAS2_M|MAS2_G)@h 297ffd06e02SYork Sun ori r11,r13,(MAS2_M|MAS2_G)@l 298ffd06e02SYork Sun mtspr SPRN_MAS2,r11 299ffd06e02SYork Sun oris r11,r13,(MAS3_SX|MAS3_SW|MAS3_SR)@h 300ffd06e02SYork Sun ori r11,r13,(MAS3_SX|MAS3_SW|MAS3_SR)@l 301ffd06e02SYork Sun mtspr SPRN_MAS3,r11 302ffd06e02SYork Sun li r11,0 303ffd06e02SYork Sun mtspr SPRN_MAS7,r11 304ffd06e02SYork Sun tlbwe 305ffd06e02SYork Sun 306ffd06e02SYork Sun /* 307ffd06e02SYork Sun * __bootpg_addr has the address of __second_half_boot_page 308ffd06e02SYork Sun * jump there in AS=1 space with cache enabled 309ffd06e02SYork Sun */ 310ffd06e02SYork Sun lis r13,toreset(__bootpg_addr)@h 311ffd06e02SYork Sun ori r13,r13,toreset(__bootpg_addr)@l 312ffd06e02SYork Sun lwz r11,0(r13) 313ffd06e02SYork Sun mtspr SPRN_SRR0,r11 314ffd06e02SYork Sun mfmsr r13 315ffd06e02SYork Sun ori r12,r13,MSR_IS|MSR_DS@l 316ffd06e02SYork Sun mtspr SPRN_SRR1,r12 317ffd06e02SYork Sun rfi 318ffd06e02SYork Sun 319ffd06e02SYork Sun /* 320ffd06e02SYork Sun * Allocate some space for the SDRAM address of the bootpg. 321ffd06e02SYork Sun * This variable has to be in the boot page so that it can 322ffd06e02SYork Sun * be accessed by secondary cores when they come out of reset. 323ffd06e02SYork Sun */ 324ffd06e02SYork Sun .align L1_CACHE_SHIFT 325ffd06e02SYork Sun .globl __bootpg_addr 326ffd06e02SYork Sun__bootpg_addr: 327ffd06e02SYork Sun .long 0 328ffd06e02SYork Sun 329ffd06e02SYork Sun .global __spin_table_addr 330ffd06e02SYork Sun__spin_table_addr: 331ffd06e02SYork Sun .long 0 332ffd06e02SYork Sun 333ffd06e02SYork Sun /* 334ffd06e02SYork Sun * This variable is set by cpu_init_r() after parsing hwconfig 335ffd06e02SYork Sun * to enable workaround for erratum NMG_CPU_A011. 336ffd06e02SYork Sun */ 337ffd06e02SYork Sun .align L1_CACHE_SHIFT 338ffd06e02SYork Sun .global enable_cpu_a011_workaround 339ffd06e02SYork Sunenable_cpu_a011_workaround: 340ffd06e02SYork Sun .long 1 341ffd06e02SYork Sun 342ffd06e02SYork Sun /* Fill in the empty space. The actual reset vector is 343ffd06e02SYork Sun * the last word of the page */ 344ffd06e02SYork Sun__secondary_start_code_end: 345ffd06e02SYork Sun .space 4092 - (__secondary_start_code_end - __secondary_start_page) 346ffd06e02SYork Sun__secondary_reset_vector: 347ffd06e02SYork Sun b __secondary_start_page 348ffd06e02SYork Sun 349ffd06e02SYork Sun 350ffd06e02SYork Sun/* this is a separated page for the spin table and cacheable boot code */ 351ffd06e02SYork Sun .align L1_CACHE_SHIFT 352ffd06e02SYork Sun .global __second_half_boot_page 353ffd06e02SYork Sun__second_half_boot_page: 354*2a5fcb83SYork Sun#ifdef CONFIG_PPC_SPINTABLE_COMPATIBLE 355*2a5fcb83SYork Sun lis r3,(spin_table_compat - __second_half_boot_page)@h 356*2a5fcb83SYork Sun ori r3,r3,(spin_table_compat - __second_half_boot_page)@l 357*2a5fcb83SYork Sun add r3,r3,r11 /* r11 has the address of __second_half_boot_page */ 358*2a5fcb83SYork Sun lwz r14,0(r3) 359*2a5fcb83SYork Sun#endif 360*2a5fcb83SYork Sun 361ffd06e02SYork Sun#define EPAPR_MAGIC 0x45504150 362a47a12beSStefan Roese#define ENTRY_ADDR_UPPER 0 363a47a12beSStefan Roese#define ENTRY_ADDR_LOWER 4 364a47a12beSStefan Roese#define ENTRY_R3_UPPER 8 365a47a12beSStefan Roese#define ENTRY_R3_LOWER 12 366a47a12beSStefan Roese#define ENTRY_RESV 16 367a47a12beSStefan Roese#define ENTRY_PIR 20 368ffd06e02SYork Sun#define ENTRY_SIZE 64 369ffd06e02SYork Sun /* 370ffd06e02SYork Sun * setup the entry 371ffd06e02SYork Sun * r10 has the base address of the spin table. 372ffd06e02SYork Sun * spin table is defined as 373ffd06e02SYork Sun * struct { 374ffd06e02SYork Sun * uint64_t entry_addr; 375ffd06e02SYork Sun * uint64_t r3; 376ffd06e02SYork Sun * uint32_t rsvd1; 377ffd06e02SYork Sun * uint32_t pir; 378ffd06e02SYork Sun * }; 379ffd06e02SYork Sun * we pad this struct to 64 bytes so each entry is in its own cacheline 380ffd06e02SYork Sun */ 381a47a12beSStefan Roese li r3,0 382a47a12beSStefan Roese li r8,1 383ffd06e02SYork Sun mfspr r4,SPRN_PIR 384a47a12beSStefan Roese stw r3,ENTRY_ADDR_UPPER(r10) 385a47a12beSStefan Roese stw r3,ENTRY_R3_UPPER(r10) 386a47a12beSStefan Roese stw r4,ENTRY_R3_LOWER(r10) 387ffd06e02SYork Sun stw r3,ENTRY_RESV(r10) 388ffd06e02SYork Sun stw r4,ENTRY_PIR(r10) 389ffd06e02SYork Sun msync 390ffd06e02SYork Sun stw r8,ENTRY_ADDR_LOWER(r10) 391a47a12beSStefan Roese 392a47a12beSStefan Roese /* spin waiting for addr */ 393*2a5fcb83SYork Sun3: 394*2a5fcb83SYork Sun/* 395*2a5fcb83SYork Sun * To comply with ePAPR 1.1, the spin table has been moved to cache-enabled 396*2a5fcb83SYork Sun * memory. Old OS may not work with this change. A patch is waiting to be 397*2a5fcb83SYork Sun * accepted for Linux kernel. Other OS needs similar fix to spin table. 398*2a5fcb83SYork Sun * For OSes with old spin table code, we can enable this temporary fix by 399*2a5fcb83SYork Sun * setting environmental variable "spin_table_compat". For new OSes, set 400*2a5fcb83SYork Sun * "spin_table_compat=no". After Linux is fixed, we can remove this macro 401*2a5fcb83SYork Sun * and related code. For now, it is enabled by default. 402*2a5fcb83SYork Sun */ 403*2a5fcb83SYork Sun#ifdef CONFIG_PPC_SPINTABLE_COMPATIBLE 404*2a5fcb83SYork Sun cmpwi r14,0 405*2a5fcb83SYork Sun beq 4f 406*2a5fcb83SYork Sun dcbf 0, r10 407*2a5fcb83SYork Sun sync 408*2a5fcb83SYork Sun4: 409*2a5fcb83SYork Sun#endif 410*2a5fcb83SYork Sun lwz r4,ENTRY_ADDR_LOWER(r10) 411a47a12beSStefan Roese andi. r11,r4,1 412ffd06e02SYork Sun bne 3b 413a47a12beSStefan Roese isync 414a47a12beSStefan Roese 415a47a12beSStefan Roese /* setup IVORs to match fixed offsets */ 416a47a12beSStefan Roese#include "fixed_ivor.S" 417a47a12beSStefan Roese 418a47a12beSStefan Roese /* get the upper bits of the addr */ 419a47a12beSStefan Roese lwz r11,ENTRY_ADDR_UPPER(r10) 420a47a12beSStefan Roese 421a47a12beSStefan Roese /* setup branch addr */ 422a47a12beSStefan Roese mtspr SPRN_SRR0,r4 423a47a12beSStefan Roese 424a47a12beSStefan Roese /* mark the entry as released */ 425a47a12beSStefan Roese li r8,3 426a47a12beSStefan Roese stw r8,ENTRY_ADDR_LOWER(r10) 427a47a12beSStefan Roese 428a47a12beSStefan Roese /* mask by ~64M to setup our tlb we will jump to */ 429a47a12beSStefan Roese rlwinm r12,r4,0,0,5 430a47a12beSStefan Roese 431ffd06e02SYork Sun /* 432ffd06e02SYork Sun * setup r3, r4, r5, r6, r7, r8, r9 433ffd06e02SYork Sun * r3 contains the value to put in the r3 register at secondary cpu 434ffd06e02SYork Sun * entry. The high 32-bits are ignored on 32-bit chip implementations. 435ffd06e02SYork Sun * 64-bit chip implementations however shall load all 64-bits 436ffd06e02SYork Sun */ 437ffd06e02SYork Sun#ifdef CONFIG_SYS_PPC64 438ffd06e02SYork Sun ld r3,ENTRY_R3_UPPER(r10) 439ffd06e02SYork Sun#else 440a47a12beSStefan Roese lwz r3,ENTRY_R3_LOWER(r10) 441ffd06e02SYork Sun#endif 442a47a12beSStefan Roese li r4,0 443a47a12beSStefan Roese li r5,0 4443f0997b3SYork Sun li r6,0 445a47a12beSStefan Roese lis r7,(64*1024*1024)@h 446a47a12beSStefan Roese li r8,0 447a47a12beSStefan Roese li r9,0 448a47a12beSStefan Roese 449a47a12beSStefan Roese /* load up the pir */ 450a47a12beSStefan Roese lwz r0,ENTRY_PIR(r10) 451a47a12beSStefan Roese mtspr SPRN_PIR,r0 452a47a12beSStefan Roese mfspr r0,SPRN_PIR 453a47a12beSStefan Roese stw r0,ENTRY_PIR(r10) 454a47a12beSStefan Roese 455a47a12beSStefan Roese mtspr IVPR,r12 456a47a12beSStefan Roese/* 457a47a12beSStefan Roese * Coming here, we know the cpu has one TLB mapping in TLB1[0] 458a47a12beSStefan Roese * which maps 0xfffff000-0xffffffff one-to-one. We set up a 459a47a12beSStefan Roese * second mapping that maps addr 1:1 for 64M, and then we jump to 460a47a12beSStefan Roese * addr 461a47a12beSStefan Roese */ 462a47a12beSStefan Roese lis r10,(MAS0_TLBSEL(1)|MAS0_ESEL(0))@h 463a47a12beSStefan Roese mtspr SPRN_MAS0,r10 464a47a12beSStefan Roese lis r10,(MAS1_VALID|MAS1_IPROT)@h 465a47a12beSStefan Roese ori r10,r10,(MAS1_TSIZE(BOOKE_PAGESZ_64M))@l 466a47a12beSStefan Roese mtspr SPRN_MAS1,r10 467a47a12beSStefan Roese /* WIMGE = 0b00000 for now */ 468a47a12beSStefan Roese mtspr SPRN_MAS2,r12 469a47a12beSStefan Roese ori r12,r12,(MAS3_SX|MAS3_SW|MAS3_SR) 470a47a12beSStefan Roese mtspr SPRN_MAS3,r12 471a47a12beSStefan Roese#ifdef CONFIG_ENABLE_36BIT_PHYS 472a47a12beSStefan Roese mtspr SPRN_MAS7,r11 473a47a12beSStefan Roese#endif 474a47a12beSStefan Roese tlbwe 475a47a12beSStefan Roese 476a47a12beSStefan Roese/* Now we have another mapping for this page, so we jump to that 477a47a12beSStefan Roese * mapping 478a47a12beSStefan Roese */ 479a47a12beSStefan Roese mtspr SPRN_SRR1,r13 480a47a12beSStefan Roese rfi 481a47a12beSStefan Roese 482a47a12beSStefan Roese 483ffd06e02SYork Sun .align 6 484a47a12beSStefan Roese .globl __spin_table 485a47a12beSStefan Roese__spin_table: 486a47a12beSStefan Roese .space CONFIG_MAX_CPUS*ENTRY_SIZE 487*2a5fcb83SYork Sun 488*2a5fcb83SYork Sun#ifdef CONFIG_PPC_SPINTABLE_COMPATIBLE 489*2a5fcb83SYork Sun .align L1_CACHE_SHIFT 490*2a5fcb83SYork Sun .global spin_table_compat 491*2a5fcb83SYork Sunspin_table_compat: 492*2a5fcb83SYork Sun .long 1 493*2a5fcb83SYork Sun 494*2a5fcb83SYork Sun#endif 495*2a5fcb83SYork Sun 496ffd06e02SYork Sun__spin_table_end: 497ffd06e02SYork Sun .space 4096 - (__spin_table_end - __spin_table) 498