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