19b781727SPaul Mackerras/* 29b781727SPaul Mackerras * This file contains low level CPU setup functions. 39b781727SPaul Mackerras * Copyright (C) 2003 Benjamin Herrenschmidt (benh@kernel.crashing.org) 49b781727SPaul Mackerras * 59b781727SPaul Mackerras * This program is free software; you can redistribute it and/or 69b781727SPaul Mackerras * modify it under the terms of the GNU General Public License 79b781727SPaul Mackerras * as published by the Free Software Foundation; either version 89b781727SPaul Mackerras * 2 of the License, or (at your option) any later version. 99b781727SPaul Mackerras * 109b781727SPaul Mackerras */ 119b781727SPaul Mackerras 129b781727SPaul Mackerras#include <asm/processor.h> 139b781727SPaul Mackerras#include <asm/page.h> 149b781727SPaul Mackerras#include <asm/cputable.h> 159b781727SPaul Mackerras#include <asm/ppc_asm.h> 169b781727SPaul Mackerras#include <asm/asm-offsets.h> 179b781727SPaul Mackerras#include <asm/cache.h> 182319f123SKumar Gala#include <asm/mmu.h> 192c86cd18SChristophe Leroy#include <asm/feature-fixups.h> 209b781727SPaul Mackerras 219b781727SPaul Mackerras_GLOBAL(__setup_cpu_603) 221f1936ffSBenjamin Herrenschmidt mflr r5 232319f123SKumar GalaBEGIN_MMU_FTR_SECTION 242319f123SKumar Gala li r10,0 25ee43eb78SBenjamin Herrenschmidt mtspr SPRN_SPRG_603_LRU,r10 /* init SW LRU tracking */ 262319f123SKumar GalaEND_MMU_FTR_SECTION_IFSET(MMU_FTR_NEED_DTLB_SW_LRU) 27*93c4a162SChristophe Leroy lis r10, (swapper_pg_dir - PAGE_OFFSET)@h 28*93c4a162SChristophe Leroy ori r10, r10, (swapper_pg_dir - PAGE_OFFSET)@l 29*93c4a162SChristophe Leroy mtspr SPRN_SPRG_PGDIR, r10 30*93c4a162SChristophe Leroy 31fc215fe7SKumar GalaBEGIN_FTR_SECTION 32fc215fe7SKumar Gala bl __init_fpu_registers 33fc215fe7SKumar GalaEND_FTR_SECTION_IFCLR(CPU_FTR_FPU_UNAVAILABLE) 34fc215fe7SKumar Gala bl setup_common_caches 351f1936ffSBenjamin Herrenschmidt mtlr r5 36fc215fe7SKumar Gala blr 379b781727SPaul Mackerras_GLOBAL(__setup_cpu_604) 381f1936ffSBenjamin Herrenschmidt mflr r5 399b781727SPaul Mackerras bl setup_common_caches 409b781727SPaul Mackerras bl setup_604_hid0 411f1936ffSBenjamin Herrenschmidt mtlr r5 429b781727SPaul Mackerras blr 439b781727SPaul Mackerras_GLOBAL(__setup_cpu_750) 441f1936ffSBenjamin Herrenschmidt mflr r5 459b781727SPaul Mackerras bl __init_fpu_registers 469b781727SPaul Mackerras bl setup_common_caches 479b781727SPaul Mackerras bl setup_750_7400_hid0 481f1936ffSBenjamin Herrenschmidt mtlr r5 499b781727SPaul Mackerras blr 509b781727SPaul Mackerras_GLOBAL(__setup_cpu_750cx) 511f1936ffSBenjamin Herrenschmidt mflr r5 529b781727SPaul Mackerras bl __init_fpu_registers 539b781727SPaul Mackerras bl setup_common_caches 549b781727SPaul Mackerras bl setup_750_7400_hid0 559b781727SPaul Mackerras bl setup_750cx 561f1936ffSBenjamin Herrenschmidt mtlr r5 579b781727SPaul Mackerras blr 589b781727SPaul Mackerras_GLOBAL(__setup_cpu_750fx) 591f1936ffSBenjamin Herrenschmidt mflr r5 609b781727SPaul Mackerras bl __init_fpu_registers 619b781727SPaul Mackerras bl setup_common_caches 629b781727SPaul Mackerras bl setup_750_7400_hid0 639b781727SPaul Mackerras bl setup_750fx 641f1936ffSBenjamin Herrenschmidt mtlr r5 659b781727SPaul Mackerras blr 669b781727SPaul Mackerras_GLOBAL(__setup_cpu_7400) 671f1936ffSBenjamin Herrenschmidt mflr r5 689b781727SPaul Mackerras bl __init_fpu_registers 699b781727SPaul Mackerras bl setup_7400_workarounds 709b781727SPaul Mackerras bl setup_common_caches 719b781727SPaul Mackerras bl setup_750_7400_hid0 721f1936ffSBenjamin Herrenschmidt mtlr r5 739b781727SPaul Mackerras blr 749b781727SPaul Mackerras_GLOBAL(__setup_cpu_7410) 751f1936ffSBenjamin Herrenschmidt mflr r5 769b781727SPaul Mackerras bl __init_fpu_registers 779b781727SPaul Mackerras bl setup_7410_workarounds 789b781727SPaul Mackerras bl setup_common_caches 799b781727SPaul Mackerras bl setup_750_7400_hid0 809b781727SPaul Mackerras li r3,0 819b781727SPaul Mackerras mtspr SPRN_L2CR2,r3 821f1936ffSBenjamin Herrenschmidt mtlr r5 839b781727SPaul Mackerras blr 849b781727SPaul Mackerras_GLOBAL(__setup_cpu_745x) 851f1936ffSBenjamin Herrenschmidt mflr r5 869b781727SPaul Mackerras bl setup_common_caches 879b781727SPaul Mackerras bl setup_745x_specifics 881f1936ffSBenjamin Herrenschmidt mtlr r5 899b781727SPaul Mackerras blr 909b781727SPaul Mackerras 919b781727SPaul Mackerras/* Enable caches for 603's, 604, 750 & 7400 */ 929b781727SPaul Mackerrassetup_common_caches: 939b781727SPaul Mackerras mfspr r11,SPRN_HID0 949b781727SPaul Mackerras andi. r0,r11,HID0_DCE 959b781727SPaul Mackerras ori r11,r11,HID0_ICE|HID0_DCE 969b781727SPaul Mackerras ori r8,r11,HID0_ICFI 979b781727SPaul Mackerras bne 1f /* don't invalidate the D-cache */ 989b781727SPaul Mackerras ori r8,r8,HID0_DCI /* unless it wasn't enabled */ 999b781727SPaul Mackerras1: sync 1009b781727SPaul Mackerras mtspr SPRN_HID0,r8 /* enable and invalidate caches */ 1019b781727SPaul Mackerras sync 1029b781727SPaul Mackerras mtspr SPRN_HID0,r11 /* enable caches */ 1039b781727SPaul Mackerras sync 1049b781727SPaul Mackerras isync 1059b781727SPaul Mackerras blr 1069b781727SPaul Mackerras 1079b781727SPaul Mackerras/* 604, 604e, 604ev, ... 1089b781727SPaul Mackerras * Enable superscalar execution & branch history table 1099b781727SPaul Mackerras */ 1109b781727SPaul Mackerrassetup_604_hid0: 1119b781727SPaul Mackerras mfspr r11,SPRN_HID0 1129b781727SPaul Mackerras ori r11,r11,HID0_SIED|HID0_BHTE 1139b781727SPaul Mackerras ori r8,r11,HID0_BTCD 1149b781727SPaul Mackerras sync 1159b781727SPaul Mackerras mtspr SPRN_HID0,r8 /* flush branch target address cache */ 1169b781727SPaul Mackerras sync /* on 604e/604r */ 1179b781727SPaul Mackerras mtspr SPRN_HID0,r11 1189b781727SPaul Mackerras sync 1199b781727SPaul Mackerras isync 1209b781727SPaul Mackerras blr 1219b781727SPaul Mackerras 1229b781727SPaul Mackerras/* 7400 <= rev 2.7 and 7410 rev = 1.0 suffer from some 1239b781727SPaul Mackerras * erratas we work around here. 1249b781727SPaul Mackerras * Moto MPC710CE.pdf describes them, those are errata 1259b781727SPaul Mackerras * #3, #4 and #5 1269b781727SPaul Mackerras * Note that we assume the firmware didn't choose to 1279b781727SPaul Mackerras * apply other workarounds (there are other ones documented 1289b781727SPaul Mackerras * in the .pdf). It appear that Apple firmware only works 1299b781727SPaul Mackerras * around #3 and with the same fix we use. We may want to 1309b781727SPaul Mackerras * check if the CPU is using 60x bus mode in which case 1319b781727SPaul Mackerras * the workaround for errata #4 is useless. Also, we may 132c03983acSJean Delvare * want to explicitly clear HID0_NOPDST as this is not 1339b781727SPaul Mackerras * needed once we have applied workaround #5 (though it's 1349b781727SPaul Mackerras * not set by Apple's firmware at least). 1359b781727SPaul Mackerras */ 1369b781727SPaul Mackerrassetup_7400_workarounds: 1379b781727SPaul Mackerras mfpvr r3 1389b781727SPaul Mackerras rlwinm r3,r3,0,20,31 1399b781727SPaul Mackerras cmpwi 0,r3,0x0207 1409b781727SPaul Mackerras ble 1f 1419b781727SPaul Mackerras blr 1429b781727SPaul Mackerrassetup_7410_workarounds: 1439b781727SPaul Mackerras mfpvr r3 1449b781727SPaul Mackerras rlwinm r3,r3,0,20,31 1459b781727SPaul Mackerras cmpwi 0,r3,0x0100 1469b781727SPaul Mackerras bnelr 1479b781727SPaul Mackerras1: 1489b781727SPaul Mackerras mfspr r11,SPRN_MSSSR0 1499b781727SPaul Mackerras /* Errata #3: Set L1OPQ_SIZE to 0x10 */ 1509b781727SPaul Mackerras rlwinm r11,r11,0,9,6 1519b781727SPaul Mackerras oris r11,r11,0x0100 1529b781727SPaul Mackerras /* Errata #4: Set L2MQ_SIZE to 1 (check for MPX mode first ?) */ 1539b781727SPaul Mackerras oris r11,r11,0x0002 1549b781727SPaul Mackerras /* Errata #5: Set DRLT_SIZE to 0x01 */ 1559b781727SPaul Mackerras rlwinm r11,r11,0,5,2 1569b781727SPaul Mackerras oris r11,r11,0x0800 1579b781727SPaul Mackerras sync 1589b781727SPaul Mackerras mtspr SPRN_MSSSR0,r11 1599b781727SPaul Mackerras sync 1609b781727SPaul Mackerras isync 1619b781727SPaul Mackerras blr 1629b781727SPaul Mackerras 1639b781727SPaul Mackerras/* 740/750/7400/7410 164027dfac6SMichael Ellerman * Enable Store Gathering (SGE), Address Broadcast (ABE), 1659b781727SPaul Mackerras * Branch History Table (BHTE), Branch Target ICache (BTIC) 1669b781727SPaul Mackerras * Dynamic Power Management (DPM), Speculative (SPD) 1679b781727SPaul Mackerras * Clear Instruction cache throttling (ICTC) 1689b781727SPaul Mackerras */ 1699b781727SPaul Mackerrassetup_750_7400_hid0: 1709b781727SPaul Mackerras mfspr r11,SPRN_HID0 1719b781727SPaul Mackerras ori r11,r11,HID0_SGE | HID0_ABE | HID0_BHTE | HID0_BTIC 1729b781727SPaul Mackerras oris r11,r11,HID0_DPM@h 1739b781727SPaul MackerrasBEGIN_FTR_SECTION 1749b781727SPaul Mackerras xori r11,r11,HID0_BTIC 1759b781727SPaul MackerrasEND_FTR_SECTION_IFSET(CPU_FTR_NO_BTIC) 1769b781727SPaul MackerrasBEGIN_FTR_SECTION 1779b781727SPaul Mackerras xoris r11,r11,HID0_DPM@h /* disable dynamic power mgmt */ 1789b781727SPaul MackerrasEND_FTR_SECTION_IFSET(CPU_FTR_NO_DPM) 1799b781727SPaul Mackerras li r3,HID0_SPD 1809b781727SPaul Mackerras andc r11,r11,r3 /* clear SPD: enable speculative */ 1819b781727SPaul Mackerras li r3,0 1829b781727SPaul Mackerras mtspr SPRN_ICTC,r3 /* Instruction Cache Throttling off */ 1839b781727SPaul Mackerras isync 1849b781727SPaul Mackerras mtspr SPRN_HID0,r11 1859b781727SPaul Mackerras sync 1869b781727SPaul Mackerras isync 1879b781727SPaul Mackerras blr 1889b781727SPaul Mackerras 1899b781727SPaul Mackerras/* 750cx specific 1909b781727SPaul Mackerras * Looks like we have to disable NAP feature for some PLL settings... 1919b781727SPaul Mackerras * (waiting for confirmation) 1929b781727SPaul Mackerras */ 1939b781727SPaul Mackerrassetup_750cx: 1949b781727SPaul Mackerras mfspr r10, SPRN_HID1 1959b781727SPaul Mackerras rlwinm r10,r10,4,28,31 1969b781727SPaul Mackerras cmpwi cr0,r10,7 1979b781727SPaul Mackerras cmpwi cr1,r10,9 1989b781727SPaul Mackerras cmpwi cr2,r10,11 1999b781727SPaul Mackerras cror 4*cr0+eq,4*cr0+eq,4*cr1+eq 2009b781727SPaul Mackerras cror 4*cr0+eq,4*cr0+eq,4*cr2+eq 2019b781727SPaul Mackerras bnelr 2021f1936ffSBenjamin Herrenschmidt lwz r6,CPU_SPEC_FEATURES(r4) 2039b781727SPaul Mackerras li r7,CPU_FTR_CAN_NAP 2049b781727SPaul Mackerras andc r6,r6,r7 2051f1936ffSBenjamin Herrenschmidt stw r6,CPU_SPEC_FEATURES(r4) 2069b781727SPaul Mackerras blr 2079b781727SPaul Mackerras 2089b781727SPaul Mackerras/* 750fx specific 2099b781727SPaul Mackerras */ 2109b781727SPaul Mackerrassetup_750fx: 2119b781727SPaul Mackerras blr 2129b781727SPaul Mackerras 2139b781727SPaul Mackerras/* MPC 745x 2149b781727SPaul Mackerras * Enable Store Gathering (SGE), Branch Folding (FOLD) 2159b781727SPaul Mackerras * Branch History Table (BHTE), Branch Target ICache (BTIC) 2169b781727SPaul Mackerras * Dynamic Power Management (DPM), Speculative (SPD) 2179b781727SPaul Mackerras * Ensure our data cache instructions really operate. 2189b781727SPaul Mackerras * Timebase has to be running or we wouldn't have made it here, 2199b781727SPaul Mackerras * just ensure we don't disable it. 2209b781727SPaul Mackerras * Clear Instruction cache throttling (ICTC) 2219b781727SPaul Mackerras * Enable L2 HW prefetch 2229b781727SPaul Mackerras */ 2239b781727SPaul Mackerrassetup_745x_specifics: 2249b781727SPaul Mackerras /* We check for the presence of an L3 cache setup by 2259b781727SPaul Mackerras * the firmware. If any, we disable NAP capability as 2269b781727SPaul Mackerras * it's known to be bogus on rev 2.1 and earlier 2279b781727SPaul Mackerras */ 2282198c070SJon LoeligerBEGIN_FTR_SECTION 2299b781727SPaul Mackerras mfspr r11,SPRN_L3CR 2309b781727SPaul Mackerras andis. r11,r11,L3CR_L3E@h 2319b781727SPaul Mackerras beq 1f 2322198c070SJon LoeligerEND_FTR_SECTION_IFSET(CPU_FTR_L3CR) 2331f1936ffSBenjamin Herrenschmidt lwz r6,CPU_SPEC_FEATURES(r4) 2349bbf0b57SPaul Mackerras andis. r0,r6,CPU_FTR_L3_DISABLE_NAP@h 2359b781727SPaul Mackerras beq 1f 2369b781727SPaul Mackerras li r7,CPU_FTR_CAN_NAP 2379b781727SPaul Mackerras andc r6,r6,r7 2381f1936ffSBenjamin Herrenschmidt stw r6,CPU_SPEC_FEATURES(r4) 2399b781727SPaul Mackerras1: 2409b781727SPaul Mackerras mfspr r11,SPRN_HID0 2419b781727SPaul Mackerras 2429b781727SPaul Mackerras /* All of the bits we have to set..... 2439b781727SPaul Mackerras */ 2449b781727SPaul Mackerras ori r11,r11,HID0_SGE | HID0_FOLD | HID0_BHTE 2459b781727SPaul Mackerras ori r11,r11,HID0_LRSTK | HID0_BTIC 2469b781727SPaul Mackerras oris r11,r11,HID0_DPM@h 247f1f8b494SGerhard PircherBEGIN_MMU_FTR_SECTION 248f1f8b494SGerhard Pircher oris r11,r11,HID0_HIGH_BAT@h 249f1f8b494SGerhard PircherEND_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS) 2509b781727SPaul MackerrasBEGIN_FTR_SECTION 2519b781727SPaul Mackerras xori r11,r11,HID0_BTIC 2529b781727SPaul MackerrasEND_FTR_SECTION_IFSET(CPU_FTR_NO_BTIC) 2539b781727SPaul MackerrasBEGIN_FTR_SECTION 2549b781727SPaul Mackerras xoris r11,r11,HID0_DPM@h /* disable dynamic power mgmt */ 2559b781727SPaul MackerrasEND_FTR_SECTION_IFSET(CPU_FTR_NO_DPM) 2569b781727SPaul Mackerras 2579b781727SPaul Mackerras /* All of the bits we have to clear.... 2589b781727SPaul Mackerras */ 2599b781727SPaul Mackerras li r3,HID0_SPD | HID0_NOPDST | HID0_NOPTI 2609b781727SPaul Mackerras andc r11,r11,r3 /* clear SPD: enable speculative */ 2619b781727SPaul Mackerras li r3,0 2629b781727SPaul Mackerras 2639b781727SPaul Mackerras mtspr SPRN_ICTC,r3 /* Instruction Cache Throttling off */ 2649b781727SPaul Mackerras isync 2659b781727SPaul Mackerras mtspr SPRN_HID0,r11 2669b781727SPaul Mackerras sync 2679b781727SPaul Mackerras isync 2689b781727SPaul Mackerras 2699b781727SPaul Mackerras /* Enable L2 HW prefetch, if L2 is enabled 2709b781727SPaul Mackerras */ 2719b781727SPaul Mackerras mfspr r3,SPRN_L2CR 2729b781727SPaul Mackerras andis. r3,r3,L2CR_L2E@h 2739b781727SPaul Mackerras beqlr 2749b781727SPaul Mackerras mfspr r3,SPRN_MSSCR0 2759b781727SPaul Mackerras ori r3,r3,3 2769b781727SPaul Mackerras sync 2779b781727SPaul Mackerras mtspr SPRN_MSSCR0,r3 2789b781727SPaul Mackerras sync 2799b781727SPaul Mackerras isync 2809b781727SPaul Mackerras blr 2819b781727SPaul Mackerras 2829b781727SPaul Mackerras/* 2839b781727SPaul Mackerras * Initialize the FPU registers. This is needed to work around an errata 2849b781727SPaul Mackerras * in some 750 cpus where using a not yet initialized FPU register after 2859b781727SPaul Mackerras * power on reset may hang the CPU 2869b781727SPaul Mackerras */ 2879b781727SPaul Mackerras_GLOBAL(__init_fpu_registers) 2889b781727SPaul Mackerras mfmsr r10 2899b781727SPaul Mackerras ori r11,r10,MSR_FP 2909b781727SPaul Mackerras mtmsr r11 2919b781727SPaul Mackerras isync 2929b781727SPaul Mackerras addis r9,r3,empty_zero_page@ha 2939b781727SPaul Mackerras addi r9,r9,empty_zero_page@l 2949b781727SPaul Mackerras REST_32FPRS(0,r9) 2959b781727SPaul Mackerras sync 2969b781727SPaul Mackerras mtmsr r10 2979b781727SPaul Mackerras isync 2989b781727SPaul Mackerras blr 2999b781727SPaul Mackerras 3009b781727SPaul Mackerras 3019b781727SPaul Mackerras/* Definitions for the table use to save CPU states */ 3029b781727SPaul Mackerras#define CS_HID0 0 3039b781727SPaul Mackerras#define CS_HID1 4 3049b781727SPaul Mackerras#define CS_HID2 8 3059b781727SPaul Mackerras#define CS_MSSCR0 12 3069b781727SPaul Mackerras#define CS_MSSSR0 16 3079b781727SPaul Mackerras#define CS_ICTRL 20 3089b781727SPaul Mackerras#define CS_LDSTCR 24 3099b781727SPaul Mackerras#define CS_LDSTDB 28 3109b781727SPaul Mackerras#define CS_SIZE 32 3119b781727SPaul Mackerras 3129b781727SPaul Mackerras .data 3139b781727SPaul Mackerras .balign L1_CACHE_BYTES 3149b781727SPaul Mackerrascpu_state_storage: 3159b781727SPaul Mackerras .space CS_SIZE 3169b781727SPaul Mackerras .balign L1_CACHE_BYTES,0 3179b781727SPaul Mackerras .text 3189b781727SPaul Mackerras 3199b781727SPaul Mackerras/* Called in normal context to backup CPU 0 state. This 3209b781727SPaul Mackerras * does not include cache settings. This function is also 3219b781727SPaul Mackerras * called for machine sleep. This does not include the MMU 3229b781727SPaul Mackerras * setup, BATs, etc... but rather the "special" registers 3239b781727SPaul Mackerras * like HID0, HID1, MSSCR0, etc... 3249b781727SPaul Mackerras */ 3259b781727SPaul Mackerras_GLOBAL(__save_cpu_setup) 3269b781727SPaul Mackerras /* Some CR fields are volatile, we back it up all */ 3279b781727SPaul Mackerras mfcr r7 3289b781727SPaul Mackerras 3299b781727SPaul Mackerras /* Get storage ptr */ 3309b781727SPaul Mackerras lis r5,cpu_state_storage@h 3319b781727SPaul Mackerras ori r5,r5,cpu_state_storage@l 3329b781727SPaul Mackerras 333d7cceda9SChristophe Leroy /* Save HID0 (common to all CONFIG_PPC_BOOK3S_32 cpus) */ 3349b781727SPaul Mackerras mfspr r3,SPRN_HID0 3359b781727SPaul Mackerras stw r3,CS_HID0(r5) 3369b781727SPaul Mackerras 3379b781727SPaul Mackerras /* Now deal with CPU type dependent registers */ 3389b781727SPaul Mackerras mfspr r3,SPRN_PVR 3399b781727SPaul Mackerras srwi r3,r3,16 3409b781727SPaul Mackerras cmplwi cr0,r3,0x8000 /* 7450 */ 3419b781727SPaul Mackerras cmplwi cr1,r3,0x000c /* 7400 */ 3429b781727SPaul Mackerras cmplwi cr2,r3,0x800c /* 7410 */ 3439b781727SPaul Mackerras cmplwi cr3,r3,0x8001 /* 7455 */ 3449b781727SPaul Mackerras cmplwi cr4,r3,0x8002 /* 7457 */ 3459b781727SPaul Mackerras cmplwi cr5,r3,0x8003 /* 7447A */ 3469b781727SPaul Mackerras cmplwi cr6,r3,0x7000 /* 750FX */ 3479b781727SPaul Mackerras cmplwi cr7,r3,0x8004 /* 7448 */ 3489b781727SPaul Mackerras /* cr1 is 7400 || 7410 */ 3499b781727SPaul Mackerras cror 4*cr1+eq,4*cr1+eq,4*cr2+eq 3509b781727SPaul Mackerras /* cr0 is 74xx */ 3519b781727SPaul Mackerras cror 4*cr0+eq,4*cr0+eq,4*cr3+eq 3529b781727SPaul Mackerras cror 4*cr0+eq,4*cr0+eq,4*cr4+eq 3539b781727SPaul Mackerras cror 4*cr0+eq,4*cr0+eq,4*cr1+eq 3549b781727SPaul Mackerras cror 4*cr0+eq,4*cr0+eq,4*cr5+eq 3559b781727SPaul Mackerras cror 4*cr0+eq,4*cr0+eq,4*cr7+eq 3569b781727SPaul Mackerras bne 1f 3579b781727SPaul Mackerras /* Backup 74xx specific regs */ 3589b781727SPaul Mackerras mfspr r4,SPRN_MSSCR0 3599b781727SPaul Mackerras stw r4,CS_MSSCR0(r5) 3609b781727SPaul Mackerras mfspr r4,SPRN_MSSSR0 3619b781727SPaul Mackerras stw r4,CS_MSSSR0(r5) 3629b781727SPaul Mackerras beq cr1,1f 3639b781727SPaul Mackerras /* Backup 745x specific registers */ 3649b781727SPaul Mackerras mfspr r4,SPRN_HID1 3659b781727SPaul Mackerras stw r4,CS_HID1(r5) 3669b781727SPaul Mackerras mfspr r4,SPRN_ICTRL 3679b781727SPaul Mackerras stw r4,CS_ICTRL(r5) 3689b781727SPaul Mackerras mfspr r4,SPRN_LDSTCR 3699b781727SPaul Mackerras stw r4,CS_LDSTCR(r5) 3709b781727SPaul Mackerras mfspr r4,SPRN_LDSTDB 3719b781727SPaul Mackerras stw r4,CS_LDSTDB(r5) 3729b781727SPaul Mackerras1: 3739b781727SPaul Mackerras bne cr6,1f 3749b781727SPaul Mackerras /* Backup 750FX specific registers */ 3759b781727SPaul Mackerras mfspr r4,SPRN_HID1 3769b781727SPaul Mackerras stw r4,CS_HID1(r5) 3779b781727SPaul Mackerras /* If rev 2.x, backup HID2 */ 3789b781727SPaul Mackerras mfspr r3,SPRN_PVR 3799b781727SPaul Mackerras andi. r3,r3,0xff00 3809b781727SPaul Mackerras cmpwi cr0,r3,0x0200 3819b781727SPaul Mackerras bne 1f 3829b781727SPaul Mackerras mfspr r4,SPRN_HID2 3839b781727SPaul Mackerras stw r4,CS_HID2(r5) 3849b781727SPaul Mackerras1: 3859b781727SPaul Mackerras mtcr r7 3869b781727SPaul Mackerras blr 3879b781727SPaul Mackerras 3889b781727SPaul Mackerras/* Called with no MMU context (typically MSR:IR/DR off) to 3899b781727SPaul Mackerras * restore CPU state as backed up by the previous 3909b781727SPaul Mackerras * function. This does not include cache setting 3919b781727SPaul Mackerras */ 3929b781727SPaul Mackerras_GLOBAL(__restore_cpu_setup) 3939b781727SPaul Mackerras /* Some CR fields are volatile, we back it up all */ 3949b781727SPaul Mackerras mfcr r7 3959b781727SPaul Mackerras 3969b781727SPaul Mackerras /* Get storage ptr */ 3979b781727SPaul Mackerras lis r5,(cpu_state_storage-KERNELBASE)@h 3989b781727SPaul Mackerras ori r5,r5,cpu_state_storage@l 3999b781727SPaul Mackerras 4009b781727SPaul Mackerras /* Restore HID0 */ 4019b781727SPaul Mackerras lwz r3,CS_HID0(r5) 4029b781727SPaul Mackerras sync 4039b781727SPaul Mackerras isync 4049b781727SPaul Mackerras mtspr SPRN_HID0,r3 4059b781727SPaul Mackerras sync 4069b781727SPaul Mackerras isync 4079b781727SPaul Mackerras 4089b781727SPaul Mackerras /* Now deal with CPU type dependent registers */ 4099b781727SPaul Mackerras mfspr r3,SPRN_PVR 4109b781727SPaul Mackerras srwi r3,r3,16 4119b781727SPaul Mackerras cmplwi cr0,r3,0x8000 /* 7450 */ 4129b781727SPaul Mackerras cmplwi cr1,r3,0x000c /* 7400 */ 4139b781727SPaul Mackerras cmplwi cr2,r3,0x800c /* 7410 */ 4149b781727SPaul Mackerras cmplwi cr3,r3,0x8001 /* 7455 */ 4159b781727SPaul Mackerras cmplwi cr4,r3,0x8002 /* 7457 */ 4169b781727SPaul Mackerras cmplwi cr5,r3,0x8003 /* 7447A */ 4179b781727SPaul Mackerras cmplwi cr6,r3,0x7000 /* 750FX */ 4189b781727SPaul Mackerras cmplwi cr7,r3,0x8004 /* 7448 */ 4199b781727SPaul Mackerras /* cr1 is 7400 || 7410 */ 4209b781727SPaul Mackerras cror 4*cr1+eq,4*cr1+eq,4*cr2+eq 4219b781727SPaul Mackerras /* cr0 is 74xx */ 4229b781727SPaul Mackerras cror 4*cr0+eq,4*cr0+eq,4*cr3+eq 4239b781727SPaul Mackerras cror 4*cr0+eq,4*cr0+eq,4*cr4+eq 4249b781727SPaul Mackerras cror 4*cr0+eq,4*cr0+eq,4*cr1+eq 4259b781727SPaul Mackerras cror 4*cr0+eq,4*cr0+eq,4*cr5+eq 4269b781727SPaul Mackerras cror 4*cr0+eq,4*cr0+eq,4*cr7+eq 4279b781727SPaul Mackerras bne 2f 4289b781727SPaul Mackerras /* Restore 74xx specific regs */ 4299b781727SPaul Mackerras lwz r4,CS_MSSCR0(r5) 4309b781727SPaul Mackerras sync 4319b781727SPaul Mackerras mtspr SPRN_MSSCR0,r4 4329b781727SPaul Mackerras sync 4339b781727SPaul Mackerras isync 4349b781727SPaul Mackerras lwz r4,CS_MSSSR0(r5) 4359b781727SPaul Mackerras sync 4369b781727SPaul Mackerras mtspr SPRN_MSSSR0,r4 4379b781727SPaul Mackerras sync 4389b781727SPaul Mackerras isync 4399b781727SPaul Mackerras bne cr2,1f 4409b781727SPaul Mackerras /* Clear 7410 L2CR2 */ 4419b781727SPaul Mackerras li r4,0 4429b781727SPaul Mackerras mtspr SPRN_L2CR2,r4 4439b781727SPaul Mackerras1: beq cr1,2f 4449b781727SPaul Mackerras /* Restore 745x specific registers */ 4459b781727SPaul Mackerras lwz r4,CS_HID1(r5) 4469b781727SPaul Mackerras sync 4479b781727SPaul Mackerras mtspr SPRN_HID1,r4 4489b781727SPaul Mackerras isync 4499b781727SPaul Mackerras sync 4509b781727SPaul Mackerras lwz r4,CS_ICTRL(r5) 4519b781727SPaul Mackerras sync 4529b781727SPaul Mackerras mtspr SPRN_ICTRL,r4 4539b781727SPaul Mackerras isync 4549b781727SPaul Mackerras sync 4559b781727SPaul Mackerras lwz r4,CS_LDSTCR(r5) 4569b781727SPaul Mackerras sync 4579b781727SPaul Mackerras mtspr SPRN_LDSTCR,r4 4589b781727SPaul Mackerras isync 4599b781727SPaul Mackerras sync 4609b781727SPaul Mackerras lwz r4,CS_LDSTDB(r5) 4619b781727SPaul Mackerras sync 4629b781727SPaul Mackerras mtspr SPRN_LDSTDB,r4 4639b781727SPaul Mackerras isync 4649b781727SPaul Mackerras sync 4659b781727SPaul Mackerras2: bne cr6,1f 4669b781727SPaul Mackerras /* Restore 750FX specific registers 4679b781727SPaul Mackerras * that is restore HID2 on rev 2.x and PLL config & switch 4689b781727SPaul Mackerras * to PLL 0 on all 4699b781727SPaul Mackerras */ 4709b781727SPaul Mackerras /* If rev 2.x, restore HID2 with low voltage bit cleared */ 4719b781727SPaul Mackerras mfspr r3,SPRN_PVR 4729b781727SPaul Mackerras andi. r3,r3,0xff00 4739b781727SPaul Mackerras cmpwi cr0,r3,0x0200 4749b781727SPaul Mackerras bne 4f 4759b781727SPaul Mackerras lwz r4,CS_HID2(r5) 4769b781727SPaul Mackerras rlwinm r4,r4,0,19,17 4779b781727SPaul Mackerras mtspr SPRN_HID2,r4 4789b781727SPaul Mackerras sync 4799b781727SPaul Mackerras4: 4809b781727SPaul Mackerras lwz r4,CS_HID1(r5) 4819b781727SPaul Mackerras rlwinm r5,r4,0,16,14 4829b781727SPaul Mackerras mtspr SPRN_HID1,r5 4839b781727SPaul Mackerras /* Wait for PLL to stabilize */ 4849b781727SPaul Mackerras mftbl r5 4859b781727SPaul Mackerras3: mftbl r6 4869b781727SPaul Mackerras sub r6,r6,r5 4879b781727SPaul Mackerras cmplwi cr0,r6,10000 4889b781727SPaul Mackerras ble 3b 4899b781727SPaul Mackerras /* Setup final PLL */ 4909b781727SPaul Mackerras mtspr SPRN_HID1,r4 4919b781727SPaul Mackerras1: 4929b781727SPaul Mackerras mtcr r7 4939b781727SPaul Mackerras blr 4949b781727SPaul Mackerras 495