1b2441318SGreg Kroah-Hartman/* SPDX-License-Identifier: GPL-2.0 */ 245320bcbSPaul Mackerras#include <linux/threads.h> 3*2da37761SChristophe Leroy#include <linux/linkage.h> 4*2da37761SChristophe Leroy 545320bcbSPaul Mackerras#include <asm/processor.h> 645320bcbSPaul Mackerras#include <asm/page.h> 745320bcbSPaul Mackerras#include <asm/cputable.h> 845320bcbSPaul Mackerras#include <asm/thread_info.h> 945320bcbSPaul Mackerras#include <asm/ppc_asm.h> 1045320bcbSPaul Mackerras#include <asm/asm-offsets.h> 117c03d653SBenjamin Herrenschmidt#include <asm/mmu.h> 122c86cd18SChristophe Leroy#include <asm/feature-fixups.h> 1345320bcbSPaul Mackerras 1445320bcbSPaul Mackerras/* 1545320bcbSPaul Mackerras * Structure for storing CPU registers on the save area. 1645320bcbSPaul Mackerras */ 1745320bcbSPaul Mackerras#define SL_SP 0 1845320bcbSPaul Mackerras#define SL_PC 4 1945320bcbSPaul Mackerras#define SL_MSR 8 2045320bcbSPaul Mackerras#define SL_SDR1 0xc 2145320bcbSPaul Mackerras#define SL_SPRG0 0x10 /* 4 sprg's */ 2245320bcbSPaul Mackerras#define SL_DBAT0 0x20 2345320bcbSPaul Mackerras#define SL_IBAT0 0x28 2445320bcbSPaul Mackerras#define SL_DBAT1 0x30 2545320bcbSPaul Mackerras#define SL_IBAT1 0x38 2645320bcbSPaul Mackerras#define SL_DBAT2 0x40 2745320bcbSPaul Mackerras#define SL_IBAT2 0x48 2845320bcbSPaul Mackerras#define SL_DBAT3 0x50 2945320bcbSPaul Mackerras#define SL_IBAT3 0x58 306ecb78efSChristophe Leroy#define SL_DBAT4 0x60 316ecb78efSChristophe Leroy#define SL_IBAT4 0x68 326ecb78efSChristophe Leroy#define SL_DBAT5 0x70 336ecb78efSChristophe Leroy#define SL_IBAT5 0x78 346ecb78efSChristophe Leroy#define SL_DBAT6 0x80 356ecb78efSChristophe Leroy#define SL_IBAT6 0x88 366ecb78efSChristophe Leroy#define SL_DBAT7 0x90 376ecb78efSChristophe Leroy#define SL_IBAT7 0x98 386ecb78efSChristophe Leroy#define SL_TB 0xa0 396ecb78efSChristophe Leroy#define SL_R2 0xa8 406ecb78efSChristophe Leroy#define SL_CR 0xac 416ecb78efSChristophe Leroy#define SL_LR 0xb0 426ecb78efSChristophe Leroy#define SL_R12 0xb4 /* r12 to r31 */ 4345320bcbSPaul Mackerras#define SL_SIZE (SL_R12 + 80) 4445320bcbSPaul Mackerras 4545320bcbSPaul Mackerras .section .data 4645320bcbSPaul Mackerras .align 5 4745320bcbSPaul Mackerras 4845320bcbSPaul Mackerras_GLOBAL(swsusp_save_area) 4945320bcbSPaul Mackerras .space SL_SIZE 5045320bcbSPaul Mackerras 5145320bcbSPaul Mackerras 5245320bcbSPaul Mackerras .section .text 5345320bcbSPaul Mackerras .align 5 5445320bcbSPaul Mackerras 5545320bcbSPaul Mackerras_GLOBAL(swsusp_arch_suspend) 5645320bcbSPaul Mackerras 5745320bcbSPaul Mackerras lis r11,swsusp_save_area@h 5845320bcbSPaul Mackerras ori r11,r11,swsusp_save_area@l 5945320bcbSPaul Mackerras 6045320bcbSPaul Mackerras mflr r0 6145320bcbSPaul Mackerras stw r0,SL_LR(r11) 6245320bcbSPaul Mackerras mfcr r0 6345320bcbSPaul Mackerras stw r0,SL_CR(r11) 6445320bcbSPaul Mackerras stw r1,SL_SP(r11) 6545320bcbSPaul Mackerras stw r2,SL_R2(r11) 6645320bcbSPaul Mackerras stmw r12,SL_R12(r11) 6745320bcbSPaul Mackerras 6845320bcbSPaul Mackerras /* Save MSR & SDR1 */ 6945320bcbSPaul Mackerras mfmsr r4 7045320bcbSPaul Mackerras stw r4,SL_MSR(r11) 7145320bcbSPaul Mackerras mfsdr1 r4 7245320bcbSPaul Mackerras stw r4,SL_SDR1(r11) 7345320bcbSPaul Mackerras 7445320bcbSPaul Mackerras /* Get a stable timebase and save it */ 7545320bcbSPaul Mackerras1: mftbu r4 7645320bcbSPaul Mackerras stw r4,SL_TB(r11) 7745320bcbSPaul Mackerras mftb r5 7845320bcbSPaul Mackerras stw r5,SL_TB+4(r11) 7945320bcbSPaul Mackerras mftbu r3 8045320bcbSPaul Mackerras cmpw r3,r4 8145320bcbSPaul Mackerras bne 1b 8245320bcbSPaul Mackerras 8345320bcbSPaul Mackerras /* Save SPRGs */ 8445320bcbSPaul Mackerras mfsprg r4,0 8545320bcbSPaul Mackerras stw r4,SL_SPRG0(r11) 8645320bcbSPaul Mackerras mfsprg r4,1 8745320bcbSPaul Mackerras stw r4,SL_SPRG0+4(r11) 8845320bcbSPaul Mackerras mfsprg r4,2 8945320bcbSPaul Mackerras stw r4,SL_SPRG0+8(r11) 9045320bcbSPaul Mackerras mfsprg r4,3 9145320bcbSPaul Mackerras stw r4,SL_SPRG0+12(r11) 9245320bcbSPaul Mackerras 9345320bcbSPaul Mackerras /* Save BATs */ 9445320bcbSPaul Mackerras mfdbatu r4,0 9545320bcbSPaul Mackerras stw r4,SL_DBAT0(r11) 9645320bcbSPaul Mackerras mfdbatl r4,0 9745320bcbSPaul Mackerras stw r4,SL_DBAT0+4(r11) 9845320bcbSPaul Mackerras mfdbatu r4,1 9945320bcbSPaul Mackerras stw r4,SL_DBAT1(r11) 10045320bcbSPaul Mackerras mfdbatl r4,1 10145320bcbSPaul Mackerras stw r4,SL_DBAT1+4(r11) 10245320bcbSPaul Mackerras mfdbatu r4,2 10345320bcbSPaul Mackerras stw r4,SL_DBAT2(r11) 10445320bcbSPaul Mackerras mfdbatl r4,2 10545320bcbSPaul Mackerras stw r4,SL_DBAT2+4(r11) 10645320bcbSPaul Mackerras mfdbatu r4,3 10745320bcbSPaul Mackerras stw r4,SL_DBAT3(r11) 10845320bcbSPaul Mackerras mfdbatl r4,3 10945320bcbSPaul Mackerras stw r4,SL_DBAT3+4(r11) 11045320bcbSPaul Mackerras mfibatu r4,0 11145320bcbSPaul Mackerras stw r4,SL_IBAT0(r11) 11245320bcbSPaul Mackerras mfibatl r4,0 11345320bcbSPaul Mackerras stw r4,SL_IBAT0+4(r11) 11445320bcbSPaul Mackerras mfibatu r4,1 11545320bcbSPaul Mackerras stw r4,SL_IBAT1(r11) 11645320bcbSPaul Mackerras mfibatl r4,1 11745320bcbSPaul Mackerras stw r4,SL_IBAT1+4(r11) 11845320bcbSPaul Mackerras mfibatu r4,2 11945320bcbSPaul Mackerras stw r4,SL_IBAT2(r11) 12045320bcbSPaul Mackerras mfibatl r4,2 12145320bcbSPaul Mackerras stw r4,SL_IBAT2+4(r11) 12245320bcbSPaul Mackerras mfibatu r4,3 12345320bcbSPaul Mackerras stw r4,SL_IBAT3(r11) 12445320bcbSPaul Mackerras mfibatl r4,3 12545320bcbSPaul Mackerras stw r4,SL_IBAT3+4(r11) 12645320bcbSPaul Mackerras 1276ecb78efSChristophe LeroyBEGIN_MMU_FTR_SECTION 1286ecb78efSChristophe Leroy mfspr r4,SPRN_DBAT4U 1296ecb78efSChristophe Leroy stw r4,SL_DBAT4(r11) 1306ecb78efSChristophe Leroy mfspr r4,SPRN_DBAT4L 1316ecb78efSChristophe Leroy stw r4,SL_DBAT4+4(r11) 1326ecb78efSChristophe Leroy mfspr r4,SPRN_DBAT5U 1336ecb78efSChristophe Leroy stw r4,SL_DBAT5(r11) 1346ecb78efSChristophe Leroy mfspr r4,SPRN_DBAT5L 1356ecb78efSChristophe Leroy stw r4,SL_DBAT5+4(r11) 1366ecb78efSChristophe Leroy mfspr r4,SPRN_DBAT6U 1376ecb78efSChristophe Leroy stw r4,SL_DBAT6(r11) 1386ecb78efSChristophe Leroy mfspr r4,SPRN_DBAT6L 1396ecb78efSChristophe Leroy stw r4,SL_DBAT6+4(r11) 1406ecb78efSChristophe Leroy mfspr r4,SPRN_DBAT7U 1416ecb78efSChristophe Leroy stw r4,SL_DBAT7(r11) 1426ecb78efSChristophe Leroy mfspr r4,SPRN_DBAT7L 1436ecb78efSChristophe Leroy stw r4,SL_DBAT7+4(r11) 1446ecb78efSChristophe Leroy mfspr r4,SPRN_IBAT4U 1456ecb78efSChristophe Leroy stw r4,SL_IBAT4(r11) 1466ecb78efSChristophe Leroy mfspr r4,SPRN_IBAT4L 1476ecb78efSChristophe Leroy stw r4,SL_IBAT4+4(r11) 1486ecb78efSChristophe Leroy mfspr r4,SPRN_IBAT5U 1496ecb78efSChristophe Leroy stw r4,SL_IBAT5(r11) 1506ecb78efSChristophe Leroy mfspr r4,SPRN_IBAT5L 1516ecb78efSChristophe Leroy stw r4,SL_IBAT5+4(r11) 1526ecb78efSChristophe Leroy mfspr r4,SPRN_IBAT6U 1536ecb78efSChristophe Leroy stw r4,SL_IBAT6(r11) 1546ecb78efSChristophe Leroy mfspr r4,SPRN_IBAT6L 1556ecb78efSChristophe Leroy stw r4,SL_IBAT6+4(r11) 1566ecb78efSChristophe Leroy mfspr r4,SPRN_IBAT7U 1576ecb78efSChristophe Leroy stw r4,SL_IBAT7(r11) 1586ecb78efSChristophe Leroy mfspr r4,SPRN_IBAT7L 1596ecb78efSChristophe Leroy stw r4,SL_IBAT7+4(r11) 1606ecb78efSChristophe LeroyEND_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS) 1616ecb78efSChristophe Leroy 16245320bcbSPaul Mackerras#if 0 16345320bcbSPaul Mackerras /* Backup various CPU config stuffs */ 16445320bcbSPaul Mackerras bl __save_cpu_setup 16545320bcbSPaul Mackerras#endif 16645320bcbSPaul Mackerras /* Call the low level suspend stuff (we should probably have made 16745320bcbSPaul Mackerras * a stackframe... 16845320bcbSPaul Mackerras */ 16945320bcbSPaul Mackerras bl swsusp_save 17045320bcbSPaul Mackerras 17145320bcbSPaul Mackerras /* Restore LR from the save area */ 17245320bcbSPaul Mackerras lis r11,swsusp_save_area@h 17345320bcbSPaul Mackerras ori r11,r11,swsusp_save_area@l 17445320bcbSPaul Mackerras lwz r0,SL_LR(r11) 17545320bcbSPaul Mackerras mtlr r0 17645320bcbSPaul Mackerras 17745320bcbSPaul Mackerras blr 17845320bcbSPaul Mackerras 17945320bcbSPaul Mackerras 18045320bcbSPaul Mackerras/* Resume code */ 18145320bcbSPaul Mackerras_GLOBAL(swsusp_arch_resume) 18245320bcbSPaul Mackerras 1832e6f40deSJohannes Berg#ifdef CONFIG_ALTIVEC 18445320bcbSPaul Mackerras /* Stop pending alitvec streams and memory accesses */ 18545320bcbSPaul MackerrasBEGIN_FTR_SECTION 186d51f86cfSAlexey Kardashevskiy PPC_DSSALL 18745320bcbSPaul MackerrasEND_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) 1882e6f40deSJohannes Berg#endif 18945320bcbSPaul Mackerras sync 19045320bcbSPaul Mackerras 19145320bcbSPaul Mackerras /* Disable MSR:DR to make sure we don't take a TLB or 19245320bcbSPaul Mackerras * hash miss during the copy, as our hash table will 19325985edcSLucas De Marchi * for a while be unusable. For .text, we assume we are 19445320bcbSPaul Mackerras * covered by a BAT. This works only for non-G5 at this 19545320bcbSPaul Mackerras * point. G5 will need a better approach, possibly using 19645320bcbSPaul Mackerras * a small temporary hash table filled with large mappings, 19745320bcbSPaul Mackerras * disabling the MMU completely isn't a good option for 19845320bcbSPaul Mackerras * performance reasons. 19945320bcbSPaul Mackerras * (Note that 750's may have the same performance issue as 20045320bcbSPaul Mackerras * the G5 in this case, we should investigate using moving 20145320bcbSPaul Mackerras * BATs for these CPUs) 20245320bcbSPaul Mackerras */ 20345320bcbSPaul Mackerras mfmsr r0 20445320bcbSPaul Mackerras sync 20545320bcbSPaul Mackerras rlwinm r0,r0,0,28,26 /* clear MSR_DR */ 20645320bcbSPaul Mackerras mtmsr r0 20745320bcbSPaul Mackerras sync 20845320bcbSPaul Mackerras isync 20945320bcbSPaul Mackerras 21045320bcbSPaul Mackerras /* Load ptr the list of pages to copy in r3 */ 21175534b50SRafael J. Wysocki lis r11,(restore_pblist - KERNELBASE)@h 21275534b50SRafael J. Wysocki ori r11,r11,restore_pblist@l 21345320bcbSPaul Mackerras lwz r10,0(r11) 21445320bcbSPaul Mackerras 21545320bcbSPaul Mackerras /* Copy the pages. This is a very basic implementation, to 21645320bcbSPaul Mackerras * be replaced by something more cache efficient */ 21745320bcbSPaul Mackerras1: 21845320bcbSPaul Mackerras tophys(r3,r10) 21945320bcbSPaul Mackerras li r0,256 22045320bcbSPaul Mackerras mtctr r0 22145320bcbSPaul Mackerras lwz r11,pbe_address(r3) /* source */ 22245320bcbSPaul Mackerras tophys(r5,r11) 22345320bcbSPaul Mackerras lwz r10,pbe_orig_address(r3) /* destination */ 22445320bcbSPaul Mackerras tophys(r6,r10) 22545320bcbSPaul Mackerras2: 22645320bcbSPaul Mackerras lwz r8,0(r5) 22745320bcbSPaul Mackerras lwz r9,4(r5) 22845320bcbSPaul Mackerras lwz r10,8(r5) 22945320bcbSPaul Mackerras lwz r11,12(r5) 23045320bcbSPaul Mackerras addi r5,r5,16 23145320bcbSPaul Mackerras stw r8,0(r6) 23245320bcbSPaul Mackerras stw r9,4(r6) 23345320bcbSPaul Mackerras stw r10,8(r6) 23445320bcbSPaul Mackerras stw r11,12(r6) 23545320bcbSPaul Mackerras addi r6,r6,16 23645320bcbSPaul Mackerras bdnz 2b 23745320bcbSPaul Mackerras lwz r10,pbe_next(r3) 23845320bcbSPaul Mackerras cmpwi 0,r10,0 23945320bcbSPaul Mackerras bne 1b 24045320bcbSPaul Mackerras 24145320bcbSPaul Mackerras /* Do a very simple cache flush/inval of the L1 to ensure 24245320bcbSPaul Mackerras * coherency of the icache 24345320bcbSPaul Mackerras */ 24445320bcbSPaul Mackerras lis r3,0x0002 24545320bcbSPaul Mackerras mtctr r3 24645320bcbSPaul Mackerras li r3, 0 24745320bcbSPaul Mackerras1: 24845320bcbSPaul Mackerras lwz r0,0(r3) 24945320bcbSPaul Mackerras addi r3,r3,0x0020 25045320bcbSPaul Mackerras bdnz 1b 25145320bcbSPaul Mackerras isync 25245320bcbSPaul Mackerras sync 25345320bcbSPaul Mackerras 25445320bcbSPaul Mackerras /* Now flush those cache lines */ 25545320bcbSPaul Mackerras lis r3,0x0002 25645320bcbSPaul Mackerras mtctr r3 25745320bcbSPaul Mackerras li r3, 0 25845320bcbSPaul Mackerras1: 25945320bcbSPaul Mackerras dcbf 0,r3 26045320bcbSPaul Mackerras addi r3,r3,0x0020 26145320bcbSPaul Mackerras bdnz 1b 26245320bcbSPaul Mackerras sync 26345320bcbSPaul Mackerras 26445320bcbSPaul Mackerras /* Ok, we are now running with the kernel data of the old 26545320bcbSPaul Mackerras * kernel fully restored. We can get to the save area 26645320bcbSPaul Mackerras * easily now. As for the rest of the code, it assumes the 26745320bcbSPaul Mackerras * loader kernel and the booted one are exactly identical 26845320bcbSPaul Mackerras */ 26945320bcbSPaul Mackerras lis r11,swsusp_save_area@h 27045320bcbSPaul Mackerras ori r11,r11,swsusp_save_area@l 27145320bcbSPaul Mackerras tophys(r11,r11) 27245320bcbSPaul Mackerras 27345320bcbSPaul Mackerras#if 0 27445320bcbSPaul Mackerras /* Restore various CPU config stuffs */ 27545320bcbSPaul Mackerras bl __restore_cpu_setup 27645320bcbSPaul Mackerras#endif 27745320bcbSPaul Mackerras /* Restore the BATs, and SDR1. Then we can turn on the MMU. 27845320bcbSPaul Mackerras * This is a bit hairy as we are running out of those BATs, 27945320bcbSPaul Mackerras * but first, our code is probably in the icache, and we are 28045320bcbSPaul Mackerras * writing the same value to the BAT, so that should be fine, 28145320bcbSPaul Mackerras * though a better solution will have to be found long-term 28245320bcbSPaul Mackerras */ 28345320bcbSPaul Mackerras lwz r4,SL_SDR1(r11) 28445320bcbSPaul Mackerras mtsdr1 r4 28545320bcbSPaul Mackerras lwz r4,SL_SPRG0(r11) 28645320bcbSPaul Mackerras mtsprg 0,r4 28745320bcbSPaul Mackerras lwz r4,SL_SPRG0+4(r11) 28845320bcbSPaul Mackerras mtsprg 1,r4 28945320bcbSPaul Mackerras lwz r4,SL_SPRG0+8(r11) 29045320bcbSPaul Mackerras mtsprg 2,r4 29145320bcbSPaul Mackerras lwz r4,SL_SPRG0+12(r11) 29245320bcbSPaul Mackerras mtsprg 3,r4 29345320bcbSPaul Mackerras 29445320bcbSPaul Mackerras#if 0 29545320bcbSPaul Mackerras lwz r4,SL_DBAT0(r11) 29645320bcbSPaul Mackerras mtdbatu 0,r4 29745320bcbSPaul Mackerras lwz r4,SL_DBAT0+4(r11) 29845320bcbSPaul Mackerras mtdbatl 0,r4 29945320bcbSPaul Mackerras lwz r4,SL_DBAT1(r11) 30045320bcbSPaul Mackerras mtdbatu 1,r4 30145320bcbSPaul Mackerras lwz r4,SL_DBAT1+4(r11) 30245320bcbSPaul Mackerras mtdbatl 1,r4 30345320bcbSPaul Mackerras lwz r4,SL_DBAT2(r11) 30445320bcbSPaul Mackerras mtdbatu 2,r4 30545320bcbSPaul Mackerras lwz r4,SL_DBAT2+4(r11) 30645320bcbSPaul Mackerras mtdbatl 2,r4 30745320bcbSPaul Mackerras lwz r4,SL_DBAT3(r11) 30845320bcbSPaul Mackerras mtdbatu 3,r4 30945320bcbSPaul Mackerras lwz r4,SL_DBAT3+4(r11) 31045320bcbSPaul Mackerras mtdbatl 3,r4 31145320bcbSPaul Mackerras lwz r4,SL_IBAT0(r11) 31245320bcbSPaul Mackerras mtibatu 0,r4 31345320bcbSPaul Mackerras lwz r4,SL_IBAT0+4(r11) 31445320bcbSPaul Mackerras mtibatl 0,r4 31545320bcbSPaul Mackerras lwz r4,SL_IBAT1(r11) 31645320bcbSPaul Mackerras mtibatu 1,r4 31745320bcbSPaul Mackerras lwz r4,SL_IBAT1+4(r11) 31845320bcbSPaul Mackerras mtibatl 1,r4 31945320bcbSPaul Mackerras lwz r4,SL_IBAT2(r11) 32045320bcbSPaul Mackerras mtibatu 2,r4 32145320bcbSPaul Mackerras lwz r4,SL_IBAT2+4(r11) 32245320bcbSPaul Mackerras mtibatl 2,r4 32345320bcbSPaul Mackerras lwz r4,SL_IBAT3(r11) 32445320bcbSPaul Mackerras mtibatu 3,r4 32545320bcbSPaul Mackerras lwz r4,SL_IBAT3+4(r11) 32645320bcbSPaul Mackerras mtibatl 3,r4 3277c03d653SBenjamin HerrenschmidtBEGIN_MMU_FTR_SECTION 3286ecb78efSChristophe Leroy lwz r4,SL_DBAT4(r11) 32945320bcbSPaul Mackerras mtspr SPRN_DBAT4U,r4 3306ecb78efSChristophe Leroy lwz r4,SL_DBAT4+4(r11) 33145320bcbSPaul Mackerras mtspr SPRN_DBAT4L,r4 3326ecb78efSChristophe Leroy lwz r4,SL_DBAT5(r11) 33345320bcbSPaul Mackerras mtspr SPRN_DBAT5U,r4 3346ecb78efSChristophe Leroy lwz r4,SL_DBAT5+4(r11) 33545320bcbSPaul Mackerras mtspr SPRN_DBAT5L,r4 3366ecb78efSChristophe Leroy lwz r4,SL_DBAT6(r11) 33745320bcbSPaul Mackerras mtspr SPRN_DBAT6U,r4 3386ecb78efSChristophe Leroy lwz r4,SL_DBAT6+4(r11) 33945320bcbSPaul Mackerras mtspr SPRN_DBAT6L,r4 3406ecb78efSChristophe Leroy lwz r4,SL_DBAT7(r11) 34145320bcbSPaul Mackerras mtspr SPRN_DBAT7U,r4 3426ecb78efSChristophe Leroy lwz r4,SL_DBAT7+4(r11) 34345320bcbSPaul Mackerras mtspr SPRN_DBAT7L,r4 3446ecb78efSChristophe Leroy lwz r4,SL_IBAT4(r11) 34545320bcbSPaul Mackerras mtspr SPRN_IBAT4U,r4 3466ecb78efSChristophe Leroy lwz r4,SL_IBAT4+4(r11) 34745320bcbSPaul Mackerras mtspr SPRN_IBAT4L,r4 3486ecb78efSChristophe Leroy lwz r4,SL_IBAT5(r11) 34945320bcbSPaul Mackerras mtspr SPRN_IBAT5U,r4 3506ecb78efSChristophe Leroy lwz r4,SL_IBAT5+4(r11) 35145320bcbSPaul Mackerras mtspr SPRN_IBAT5L,r4 3526ecb78efSChristophe Leroy lwz r4,SL_IBAT6(r11) 35345320bcbSPaul Mackerras mtspr SPRN_IBAT6U,r4 3546ecb78efSChristophe Leroy lwz r4,SL_IBAT6+4(r11) 35545320bcbSPaul Mackerras mtspr SPRN_IBAT6L,r4 3566ecb78efSChristophe Leroy lwz r4,SL_IBAT7(r11) 35745320bcbSPaul Mackerras mtspr SPRN_IBAT7U,r4 3586ecb78efSChristophe Leroy lwz r4,SL_IBAT7+4(r11) 35945320bcbSPaul Mackerras mtspr SPRN_IBAT7L,r4 3607c03d653SBenjamin HerrenschmidtEND_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS) 3616ecb78efSChristophe Leroy#endif 36245320bcbSPaul Mackerras 36345320bcbSPaul Mackerras /* Flush all TLBs */ 36445320bcbSPaul Mackerras lis r4,0x1000 36545320bcbSPaul Mackerras1: addic. r4,r4,-0x1000 36645320bcbSPaul Mackerras tlbie r4 367e443ed35SAnton Vorontsov bgt 1b 36845320bcbSPaul Mackerras sync 36945320bcbSPaul Mackerras 37045320bcbSPaul Mackerras /* restore the MSR and turn on the MMU */ 37145320bcbSPaul Mackerras lwz r3,SL_MSR(r11) 37245320bcbSPaul Mackerras bl turn_on_mmu 37345320bcbSPaul Mackerras tovirt(r11,r11) 37445320bcbSPaul Mackerras 37545320bcbSPaul Mackerras /* Restore TB */ 37645320bcbSPaul Mackerras li r3,0 37745320bcbSPaul Mackerras mttbl r3 37845320bcbSPaul Mackerras lwz r3,SL_TB(r11) 37945320bcbSPaul Mackerras lwz r4,SL_TB+4(r11) 38045320bcbSPaul Mackerras mttbu r3 38145320bcbSPaul Mackerras mttbl r4 38245320bcbSPaul Mackerras 38345320bcbSPaul Mackerras /* Kick decrementer */ 38445320bcbSPaul Mackerras li r0,1 38545320bcbSPaul Mackerras mtdec r0 38645320bcbSPaul Mackerras 38745320bcbSPaul Mackerras /* Restore the callee-saved registers and return */ 38845320bcbSPaul Mackerras lwz r0,SL_CR(r11) 38945320bcbSPaul Mackerras mtcr r0 39045320bcbSPaul Mackerras lwz r2,SL_R2(r11) 39145320bcbSPaul Mackerras lmw r12,SL_R12(r11) 39245320bcbSPaul Mackerras lwz r1,SL_SP(r11) 39345320bcbSPaul Mackerras lwz r0,SL_LR(r11) 39445320bcbSPaul Mackerras mtlr r0 39545320bcbSPaul Mackerras 39645320bcbSPaul Mackerras // XXX Note: we don't really need to call swsusp_resume 39745320bcbSPaul Mackerras 39845320bcbSPaul Mackerras li r3,0 39945320bcbSPaul Mackerras blr 4005f32e836SChristophe Leroy_ASM_NOKPROBE_SYMBOL(swsusp_arch_resume) 40145320bcbSPaul Mackerras 40245320bcbSPaul Mackerras/* FIXME:This construct is actually not useful since we don't shut 40345320bcbSPaul Mackerras * down the instruction MMU, we could just flip back MSR-DR on. 40445320bcbSPaul Mackerras */ 405*2da37761SChristophe LeroySYM_FUNC_START_LOCAL(turn_on_mmu) 40645320bcbSPaul Mackerras mflr r4 40745320bcbSPaul Mackerras mtsrr0 r4 40845320bcbSPaul Mackerras mtsrr1 r3 40945320bcbSPaul Mackerras sync 41045320bcbSPaul Mackerras isync 41145320bcbSPaul Mackerras rfi 4125f32e836SChristophe Leroy_ASM_NOKPROBE_SYMBOL(turn_on_mmu) 413*2da37761SChristophe LeroySYM_FUNC_END(turn_on_mmu) 41445320bcbSPaul Mackerras 415