xref: /openbmc/linux/arch/powerpc/platforms/powermac/sleep.S (revision cdd38c5f1ce4398ec58fec95904b75824daab7b5)
12874c5fdSThomas Gleixner/* SPDX-License-Identifier: GPL-2.0-or-later */
2f6d57916SPaul Mackerras/*
3f6d57916SPaul Mackerras * This file contains sleep low-level functions for PowerBook G3.
4f6d57916SPaul Mackerras *    Copyright (C) 1999 Benjamin Herrenschmidt (benh@kernel.crashing.org)
5f6d57916SPaul Mackerras *    and Paul Mackerras (paulus@samba.org).
6f6d57916SPaul Mackerras */
7f6d57916SPaul Mackerras
8f6d57916SPaul Mackerras#include <asm/processor.h>
9f6d57916SPaul Mackerras#include <asm/page.h>
10f6d57916SPaul Mackerras#include <asm/ppc_asm.h>
11f6d57916SPaul Mackerras#include <asm/cputable.h>
12f6d57916SPaul Mackerras#include <asm/cache.h>
13f6d57916SPaul Mackerras#include <asm/thread_info.h>
14f6d57916SPaul Mackerras#include <asm/asm-offsets.h>
157c03d653SBenjamin Herrenschmidt#include <asm/mmu.h>
162c86cd18SChristophe Leroy#include <asm/feature-fixups.h>
17f6d57916SPaul Mackerras
18f6d57916SPaul Mackerras#define MAGIC	0x4c617273	/* 'Lars' */
19f6d57916SPaul Mackerras
20f6d57916SPaul Mackerras/*
21f6d57916SPaul Mackerras * Structure for storing CPU registers on the stack.
22f6d57916SPaul Mackerras */
23f6d57916SPaul Mackerras#define SL_SP		0
24f6d57916SPaul Mackerras#define SL_PC		4
25f6d57916SPaul Mackerras#define SL_MSR		8
26f6d57916SPaul Mackerras#define SL_SDR1		0xc
27f6d57916SPaul Mackerras#define SL_SPRG0	0x10	/* 4 sprg's */
28f6d57916SPaul Mackerras#define SL_DBAT0	0x20
29f6d57916SPaul Mackerras#define SL_IBAT0	0x28
30f6d57916SPaul Mackerras#define SL_DBAT1	0x30
31f6d57916SPaul Mackerras#define SL_IBAT1	0x38
32f6d57916SPaul Mackerras#define SL_DBAT2	0x40
33f6d57916SPaul Mackerras#define SL_IBAT2	0x48
34f6d57916SPaul Mackerras#define SL_DBAT3	0x50
35f6d57916SPaul Mackerras#define SL_IBAT3	0x58
366ecb78efSChristophe Leroy#define SL_DBAT4	0x60
376ecb78efSChristophe Leroy#define SL_IBAT4	0x68
386ecb78efSChristophe Leroy#define SL_DBAT5	0x70
396ecb78efSChristophe Leroy#define SL_IBAT5	0x78
406ecb78efSChristophe Leroy#define SL_DBAT6	0x80
416ecb78efSChristophe Leroy#define SL_IBAT6	0x88
426ecb78efSChristophe Leroy#define SL_DBAT7	0x90
436ecb78efSChristophe Leroy#define SL_IBAT7	0x98
446ecb78efSChristophe Leroy#define SL_TB		0xa0
456ecb78efSChristophe Leroy#define SL_R2		0xa8
466ecb78efSChristophe Leroy#define SL_CR		0xac
47*db972a37SChristophe Leroy#define SL_LR		0xb0
48*db972a37SChristophe Leroy#define SL_R12		0xb4	/* r12 to r31 */
49f6d57916SPaul Mackerras#define SL_SIZE		(SL_R12 + 80)
50f6d57916SPaul Mackerras
51f6d57916SPaul Mackerras	.section .text
52f6d57916SPaul Mackerras	.align	5
53f6d57916SPaul Mackerras
547f8c4c50SSrinivasa Ds#if defined(CONFIG_PM) || defined(CONFIG_CPU_FREQ_PMAC) || \
557f8c4c50SSrinivasa Ds    (defined(CONFIG_HOTPLUG_CPU) && defined(CONFIG_PPC32))
56f6d57916SPaul Mackerras
57f6d57916SPaul Mackerras/* This gets called by via-pmu.c late during the sleep process.
58f6d57916SPaul Mackerras * The PMU was already send the sleep command and will shut us down
59f6d57916SPaul Mackerras * soon. We need to save all that is needed and setup the wakeup
60f6d57916SPaul Mackerras * vector that will be called by the ROM on wakeup
61f6d57916SPaul Mackerras */
62f6d57916SPaul Mackerras_GLOBAL(low_sleep_handler)
63d7cceda9SChristophe Leroy#ifndef CONFIG_PPC_BOOK3S_32
64f6d57916SPaul Mackerras	blr
65f6d57916SPaul Mackerras#else
66f6d57916SPaul Mackerras	mflr	r0
67*db972a37SChristophe Leroy	lis	r11,sleep_storage@ha
68*db972a37SChristophe Leroy	addi	r11,r11,sleep_storage@l
69*db972a37SChristophe Leroy	stw	r0,SL_LR(r11)
70f6d57916SPaul Mackerras	mfcr	r0
71*db972a37SChristophe Leroy	stw	r0,SL_CR(r11)
72*db972a37SChristophe Leroy	stw	r1,SL_SP(r11)
73*db972a37SChristophe Leroy	stw	r2,SL_R2(r11)
74*db972a37SChristophe Leroy	stmw	r12,SL_R12(r11)
75f6d57916SPaul Mackerras
76f6d57916SPaul Mackerras	/* Save MSR & SDR1 */
77f6d57916SPaul Mackerras	mfmsr	r4
78*db972a37SChristophe Leroy	stw	r4,SL_MSR(r11)
79f6d57916SPaul Mackerras	mfsdr1	r4
80*db972a37SChristophe Leroy	stw	r4,SL_SDR1(r11)
81f6d57916SPaul Mackerras
82f6d57916SPaul Mackerras	/* Get a stable timebase and save it */
83f6d57916SPaul Mackerras1:	mftbu	r4
84*db972a37SChristophe Leroy	stw	r4,SL_TB(r11)
85f6d57916SPaul Mackerras	mftb	r5
86*db972a37SChristophe Leroy	stw	r5,SL_TB+4(r11)
87f6d57916SPaul Mackerras	mftbu	r3
88f6d57916SPaul Mackerras	cmpw	r3,r4
89f6d57916SPaul Mackerras	bne	1b
90f6d57916SPaul Mackerras
91f6d57916SPaul Mackerras	/* Save SPRGs */
92f6d57916SPaul Mackerras	mfsprg	r4,0
93*db972a37SChristophe Leroy	stw	r4,SL_SPRG0(r11)
94f6d57916SPaul Mackerras	mfsprg	r4,1
95*db972a37SChristophe Leroy	stw	r4,SL_SPRG0+4(r11)
96f6d57916SPaul Mackerras	mfsprg	r4,2
97*db972a37SChristophe Leroy	stw	r4,SL_SPRG0+8(r11)
98f6d57916SPaul Mackerras	mfsprg	r4,3
99*db972a37SChristophe Leroy	stw	r4,SL_SPRG0+12(r11)
100f6d57916SPaul Mackerras
101f6d57916SPaul Mackerras	/* Save BATs */
102f6d57916SPaul Mackerras	mfdbatu	r4,0
103*db972a37SChristophe Leroy	stw	r4,SL_DBAT0(r11)
104f6d57916SPaul Mackerras	mfdbatl	r4,0
105*db972a37SChristophe Leroy	stw	r4,SL_DBAT0+4(r11)
106f6d57916SPaul Mackerras	mfdbatu	r4,1
107*db972a37SChristophe Leroy	stw	r4,SL_DBAT1(r11)
108f6d57916SPaul Mackerras	mfdbatl	r4,1
109*db972a37SChristophe Leroy	stw	r4,SL_DBAT1+4(r11)
110f6d57916SPaul Mackerras	mfdbatu	r4,2
111*db972a37SChristophe Leroy	stw	r4,SL_DBAT2(r11)
112f6d57916SPaul Mackerras	mfdbatl	r4,2
113*db972a37SChristophe Leroy	stw	r4,SL_DBAT2+4(r11)
114f6d57916SPaul Mackerras	mfdbatu	r4,3
115*db972a37SChristophe Leroy	stw	r4,SL_DBAT3(r11)
116f6d57916SPaul Mackerras	mfdbatl	r4,3
117*db972a37SChristophe Leroy	stw	r4,SL_DBAT3+4(r11)
118f6d57916SPaul Mackerras	mfibatu	r4,0
119*db972a37SChristophe Leroy	stw	r4,SL_IBAT0(r11)
120f6d57916SPaul Mackerras	mfibatl	r4,0
121*db972a37SChristophe Leroy	stw	r4,SL_IBAT0+4(r11)
122f6d57916SPaul Mackerras	mfibatu	r4,1
123*db972a37SChristophe Leroy	stw	r4,SL_IBAT1(r11)
124f6d57916SPaul Mackerras	mfibatl	r4,1
125*db972a37SChristophe Leroy	stw	r4,SL_IBAT1+4(r11)
126f6d57916SPaul Mackerras	mfibatu	r4,2
127*db972a37SChristophe Leroy	stw	r4,SL_IBAT2(r11)
128f6d57916SPaul Mackerras	mfibatl	r4,2
129*db972a37SChristophe Leroy	stw	r4,SL_IBAT2+4(r11)
130f6d57916SPaul Mackerras	mfibatu	r4,3
131*db972a37SChristophe Leroy	stw	r4,SL_IBAT3(r11)
132f6d57916SPaul Mackerras	mfibatl	r4,3
133*db972a37SChristophe Leroy	stw	r4,SL_IBAT3+4(r11)
134f6d57916SPaul Mackerras
1356ecb78efSChristophe LeroyBEGIN_MMU_FTR_SECTION
1366ecb78efSChristophe Leroy	mfspr	r4,SPRN_DBAT4U
137*db972a37SChristophe Leroy	stw	r4,SL_DBAT4(r11)
1386ecb78efSChristophe Leroy	mfspr	r4,SPRN_DBAT4L
139*db972a37SChristophe Leroy	stw	r4,SL_DBAT4+4(r11)
1406ecb78efSChristophe Leroy	mfspr	r4,SPRN_DBAT5U
141*db972a37SChristophe Leroy	stw	r4,SL_DBAT5(r11)
1426ecb78efSChristophe Leroy	mfspr	r4,SPRN_DBAT5L
143*db972a37SChristophe Leroy	stw	r4,SL_DBAT5+4(r11)
1446ecb78efSChristophe Leroy	mfspr	r4,SPRN_DBAT6U
145*db972a37SChristophe Leroy	stw	r4,SL_DBAT6(r11)
1466ecb78efSChristophe Leroy	mfspr	r4,SPRN_DBAT6L
147*db972a37SChristophe Leroy	stw	r4,SL_DBAT6+4(r11)
1486ecb78efSChristophe Leroy	mfspr	r4,SPRN_DBAT7U
149*db972a37SChristophe Leroy	stw	r4,SL_DBAT7(r11)
1506ecb78efSChristophe Leroy	mfspr	r4,SPRN_DBAT7L
151*db972a37SChristophe Leroy	stw	r4,SL_DBAT7+4(r11)
1526ecb78efSChristophe Leroy	mfspr	r4,SPRN_IBAT4U
153*db972a37SChristophe Leroy	stw	r4,SL_IBAT4(r11)
1546ecb78efSChristophe Leroy	mfspr	r4,SPRN_IBAT4L
155*db972a37SChristophe Leroy	stw	r4,SL_IBAT4+4(r11)
1566ecb78efSChristophe Leroy	mfspr	r4,SPRN_IBAT5U
157*db972a37SChristophe Leroy	stw	r4,SL_IBAT5(r11)
1586ecb78efSChristophe Leroy	mfspr	r4,SPRN_IBAT5L
159*db972a37SChristophe Leroy	stw	r4,SL_IBAT5+4(r11)
1606ecb78efSChristophe Leroy	mfspr	r4,SPRN_IBAT6U
161*db972a37SChristophe Leroy	stw	r4,SL_IBAT6(r11)
1626ecb78efSChristophe Leroy	mfspr	r4,SPRN_IBAT6L
163*db972a37SChristophe Leroy	stw	r4,SL_IBAT6+4(r11)
1646ecb78efSChristophe Leroy	mfspr	r4,SPRN_IBAT7U
165*db972a37SChristophe Leroy	stw	r4,SL_IBAT7(r11)
1666ecb78efSChristophe Leroy	mfspr	r4,SPRN_IBAT7L
167*db972a37SChristophe Leroy	stw	r4,SL_IBAT7+4(r11)
1686ecb78efSChristophe LeroyEND_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS)
1696ecb78efSChristophe Leroy
170f6d57916SPaul Mackerras	/* Backup various CPU config stuffs */
171f6d57916SPaul Mackerras	bl	__save_cpu_setup
172f6d57916SPaul Mackerras
173f6d57916SPaul Mackerras	/* The ROM can wake us up via 2 different vectors:
174f6d57916SPaul Mackerras	 *  - On wallstreet & lombard, we must write a magic
175f6d57916SPaul Mackerras	 *    value 'Lars' at address 4 and a pointer to a
176f6d57916SPaul Mackerras	 *    memory location containing the PC to resume from
177f6d57916SPaul Mackerras	 *    at address 0.
178f6d57916SPaul Mackerras	 *  - On Core99, we must store the wakeup vector at
179f6d57916SPaul Mackerras	 *    address 0x80 and eventually it's parameters
180f6d57916SPaul Mackerras	 *    at address 0x84. I've have some trouble with those
181f6d57916SPaul Mackerras	 *    parameters however and I no longer use them.
182f6d57916SPaul Mackerras	 */
183f6d57916SPaul Mackerras	lis	r5,grackle_wake_up@ha
184f6d57916SPaul Mackerras	addi	r5,r5,grackle_wake_up@l
185f6d57916SPaul Mackerras	tophys(r5,r5)
186*db972a37SChristophe Leroy	stw	r5,SL_PC(r11)
187f6d57916SPaul Mackerras	lis	r4,KERNELBASE@h
188*db972a37SChristophe Leroy	tophys(r5,r11)
189f6d57916SPaul Mackerras	addi	r5,r5,SL_PC
190f6d57916SPaul Mackerras	lis	r6,MAGIC@ha
191f6d57916SPaul Mackerras	addi	r6,r6,MAGIC@l
192f6d57916SPaul Mackerras	stw	r5,0(r4)
193f6d57916SPaul Mackerras	stw	r6,4(r4)
194f6d57916SPaul Mackerras	/* Setup stuffs at 0x80-0x84 for Core99 */
195f6d57916SPaul Mackerras	lis	r3,core99_wake_up@ha
196f6d57916SPaul Mackerras	addi	r3,r3,core99_wake_up@l
197f6d57916SPaul Mackerras	tophys(r3,r3)
198f6d57916SPaul Mackerras	stw	r3,0x80(r4)
199f6d57916SPaul Mackerras	stw	r5,0x84(r4)
200f6d57916SPaul Mackerras
20139f87561SMichael Ellerman	.globl	low_cpu_offline_self
20239f87561SMichael Ellermanlow_cpu_offline_self:
203f6d57916SPaul Mackerras	/* Flush & disable all caches */
204f6d57916SPaul Mackerras	bl	flush_disable_caches
205f6d57916SPaul Mackerras
206f6d57916SPaul Mackerras	/* Turn off data relocation. */
207f6d57916SPaul Mackerras	mfmsr	r3		/* Save MSR in r7 */
208f6d57916SPaul Mackerras	rlwinm	r3,r3,0,28,26	/* Turn off DR bit */
209f6d57916SPaul Mackerras	sync
210f6d57916SPaul Mackerras	mtmsr	r3
211f6d57916SPaul Mackerras	isync
212f6d57916SPaul Mackerras
213f6d57916SPaul MackerrasBEGIN_FTR_SECTION
214f6d57916SPaul Mackerras	/* Flush any pending L2 data prefetches to work around HW bug */
215f6d57916SPaul Mackerras	sync
216f6d57916SPaul Mackerras	lis	r3,0xfff0
217f6d57916SPaul Mackerras	lwz	r0,0(r3)	/* perform cache-inhibited load to ROM */
218f6d57916SPaul Mackerras	sync			/* (caches are disabled at this point) */
219f6d57916SPaul MackerrasEND_FTR_SECTION_IFSET(CPU_FTR_SPEC7450)
220f6d57916SPaul Mackerras
221f6d57916SPaul Mackerras/*
222f6d57916SPaul Mackerras * Set the HID0 and MSR for sleep.
223f6d57916SPaul Mackerras */
224f6d57916SPaul Mackerras	mfspr	r2,SPRN_HID0
225f6d57916SPaul Mackerras	rlwinm	r2,r2,0,10,7	/* clear doze, nap */
226f6d57916SPaul Mackerras	oris	r2,r2,HID0_SLEEP@h
227f6d57916SPaul Mackerras	sync
228f6d57916SPaul Mackerras	isync
229f6d57916SPaul Mackerras	mtspr	SPRN_HID0,r2
230f6d57916SPaul Mackerras	sync
231f6d57916SPaul Mackerras
232f6d57916SPaul Mackerras/* This loop puts us back to sleep in case we have a spurrious
233f6d57916SPaul Mackerras * wakeup so that the host bridge properly stays asleep. The
234f6d57916SPaul Mackerras * CPU will be turned off, either after a known time (about 1
235f6d57916SPaul Mackerras * second) on wallstreet & lombard, or as soon as the CPU enters
236f6d57916SPaul Mackerras * SLEEP mode on core99
237f6d57916SPaul Mackerras */
238f6d57916SPaul Mackerras	mfmsr	r2
239f6d57916SPaul Mackerras	oris	r2,r2,MSR_POW@h
240f6d57916SPaul Mackerras1:	sync
241f6d57916SPaul Mackerras	mtmsr	r2
242f6d57916SPaul Mackerras	isync
243f6d57916SPaul Mackerras	b	1b
24439f87561SMichael Ellerman_ASM_NOKPROBE_SYMBOL(low_cpu_offline_self)
245f6d57916SPaul Mackerras/*
246f6d57916SPaul Mackerras * Here is the resume code.
247f6d57916SPaul Mackerras */
248f6d57916SPaul Mackerras
249f6d57916SPaul Mackerras
250f6d57916SPaul Mackerras/*
251f6d57916SPaul Mackerras * Core99 machines resume here
252f6d57916SPaul Mackerras * r4 has the physical address of SL_PC(sp) (unused)
253f6d57916SPaul Mackerras */
254f6d57916SPaul Mackerras_GLOBAL(core99_wake_up)
255f6d57916SPaul Mackerras	/* Make sure HID0 no longer contains any sleep bit and that data cache
256f6d57916SPaul Mackerras	 * is disabled
257f6d57916SPaul Mackerras	 */
258f6d57916SPaul Mackerras	mfspr	r3,SPRN_HID0
259f6d57916SPaul Mackerras	rlwinm	r3,r3,0,11,7		/* clear SLEEP, NAP, DOZE bits */
260f6d57916SPaul Mackerras	rlwinm	3,r3,0,18,15		/* clear DCE, ICE */
261f6d57916SPaul Mackerras	mtspr	SPRN_HID0,r3
262f6d57916SPaul Mackerras	sync
263f6d57916SPaul Mackerras	isync
264f6d57916SPaul Mackerras
265f6d57916SPaul Mackerras	/* sanitize MSR */
266f6d57916SPaul Mackerras	mfmsr	r3
267f6d57916SPaul Mackerras	ori	r3,r3,MSR_EE|MSR_IP
268f6d57916SPaul Mackerras	xori	r3,r3,MSR_EE|MSR_IP
269f6d57916SPaul Mackerras	sync
270f6d57916SPaul Mackerras	isync
271f6d57916SPaul Mackerras	mtmsr	r3
272f6d57916SPaul Mackerras	sync
273f6d57916SPaul Mackerras	isync
274f6d57916SPaul Mackerras
275f6d57916SPaul Mackerras	/* Recover sleep storage */
276f6d57916SPaul Mackerras	lis	r3,sleep_storage@ha
277f6d57916SPaul Mackerras	addi	r3,r3,sleep_storage@l
278f6d57916SPaul Mackerras	tophys(r3,r3)
279*db972a37SChristophe Leroy	addi	r1,r3,SL_PC
280f6d57916SPaul Mackerras
281f6d57916SPaul Mackerras	/* Pass thru to older resume code ... */
28232a82067SChristophe Leroy_ASM_NOKPROBE_SYMBOL(core99_wake_up)
283f6d57916SPaul Mackerras/*
284f6d57916SPaul Mackerras * Here is the resume code for older machines.
285f6d57916SPaul Mackerras * r1 has the physical address of SL_PC(sp).
286f6d57916SPaul Mackerras */
287f6d57916SPaul Mackerras
288f6d57916SPaul Mackerrasgrackle_wake_up:
289f6d57916SPaul Mackerras
290f6d57916SPaul Mackerras	/* Restore the kernel's segment registers before
291f6d57916SPaul Mackerras	 * we do any r1 memory access as we are not sure they
292f6d57916SPaul Mackerras	 * are in a sane state above the first 256Mb region
293f6d57916SPaul Mackerras	 */
2942c637d2dSChristophe Leroy	bl	load_segment_registers
295f6d57916SPaul Mackerras	sync
296f6d57916SPaul Mackerras	isync
297f6d57916SPaul Mackerras
298f6d57916SPaul Mackerras	subi	r1,r1,SL_PC
299f6d57916SPaul Mackerras
300f6d57916SPaul Mackerras	/* Restore various CPU config stuffs */
301f6d57916SPaul Mackerras	bl	__restore_cpu_setup
302f6d57916SPaul Mackerras
303f6d57916SPaul Mackerras	/* Make sure all FPRs have been initialized */
304f6d57916SPaul Mackerras	bl	reloc_offset
305f6d57916SPaul Mackerras	bl	__init_fpu_registers
306f6d57916SPaul Mackerras
307f6d57916SPaul Mackerras	/* Invalidate & enable L1 cache, we don't care about
308f6d57916SPaul Mackerras	 * whatever the ROM may have tried to write to memory
309f6d57916SPaul Mackerras	 */
310f6d57916SPaul Mackerras	bl	__inval_enable_L1
311f6d57916SPaul Mackerras
312f6d57916SPaul Mackerras	/* Restore the BATs, and SDR1.  Then we can turn on the MMU. */
313f6d57916SPaul Mackerras	lwz	r4,SL_SDR1(r1)
314f6d57916SPaul Mackerras	mtsdr1	r4
315f6d57916SPaul Mackerras	lwz	r4,SL_SPRG0(r1)
316f6d57916SPaul Mackerras	mtsprg	0,r4
317f6d57916SPaul Mackerras	lwz	r4,SL_SPRG0+4(r1)
318f6d57916SPaul Mackerras	mtsprg	1,r4
319f6d57916SPaul Mackerras	lwz	r4,SL_SPRG0+8(r1)
320f6d57916SPaul Mackerras	mtsprg	2,r4
321f6d57916SPaul Mackerras	lwz	r4,SL_SPRG0+12(r1)
322f6d57916SPaul Mackerras	mtsprg	3,r4
323f6d57916SPaul Mackerras
324f6d57916SPaul Mackerras	lwz	r4,SL_DBAT0(r1)
325f6d57916SPaul Mackerras	mtdbatu	0,r4
326f6d57916SPaul Mackerras	lwz	r4,SL_DBAT0+4(r1)
327f6d57916SPaul Mackerras	mtdbatl	0,r4
328f6d57916SPaul Mackerras	lwz	r4,SL_DBAT1(r1)
329f6d57916SPaul Mackerras	mtdbatu	1,r4
330f6d57916SPaul Mackerras	lwz	r4,SL_DBAT1+4(r1)
331f6d57916SPaul Mackerras	mtdbatl	1,r4
332f6d57916SPaul Mackerras	lwz	r4,SL_DBAT2(r1)
333f6d57916SPaul Mackerras	mtdbatu	2,r4
334f6d57916SPaul Mackerras	lwz	r4,SL_DBAT2+4(r1)
335f6d57916SPaul Mackerras	mtdbatl	2,r4
336f6d57916SPaul Mackerras	lwz	r4,SL_DBAT3(r1)
337f6d57916SPaul Mackerras	mtdbatu	3,r4
338f6d57916SPaul Mackerras	lwz	r4,SL_DBAT3+4(r1)
339f6d57916SPaul Mackerras	mtdbatl	3,r4
340f6d57916SPaul Mackerras	lwz	r4,SL_IBAT0(r1)
341f6d57916SPaul Mackerras	mtibatu	0,r4
342f6d57916SPaul Mackerras	lwz	r4,SL_IBAT0+4(r1)
343f6d57916SPaul Mackerras	mtibatl	0,r4
344f6d57916SPaul Mackerras	lwz	r4,SL_IBAT1(r1)
345f6d57916SPaul Mackerras	mtibatu	1,r4
346f6d57916SPaul Mackerras	lwz	r4,SL_IBAT1+4(r1)
347f6d57916SPaul Mackerras	mtibatl	1,r4
348f6d57916SPaul Mackerras	lwz	r4,SL_IBAT2(r1)
349f6d57916SPaul Mackerras	mtibatu	2,r4
350f6d57916SPaul Mackerras	lwz	r4,SL_IBAT2+4(r1)
351f6d57916SPaul Mackerras	mtibatl	2,r4
352f6d57916SPaul Mackerras	lwz	r4,SL_IBAT3(r1)
353f6d57916SPaul Mackerras	mtibatu	3,r4
354f6d57916SPaul Mackerras	lwz	r4,SL_IBAT3+4(r1)
355f6d57916SPaul Mackerras	mtibatl	3,r4
356f6d57916SPaul Mackerras
3577c03d653SBenjamin HerrenschmidtBEGIN_MMU_FTR_SECTION
3586ecb78efSChristophe Leroy	lwz	r4,SL_DBAT4(r1)
359f6d57916SPaul Mackerras	mtspr	SPRN_DBAT4U,r4
3606ecb78efSChristophe Leroy	lwz	r4,SL_DBAT4+4(r1)
361f6d57916SPaul Mackerras	mtspr	SPRN_DBAT4L,r4
3626ecb78efSChristophe Leroy	lwz	r4,SL_DBAT5(r1)
363f6d57916SPaul Mackerras	mtspr	SPRN_DBAT5U,r4
3646ecb78efSChristophe Leroy	lwz	r4,SL_DBAT5+4(r1)
365f6d57916SPaul Mackerras	mtspr	SPRN_DBAT5L,r4
3666ecb78efSChristophe Leroy	lwz	r4,SL_DBAT6(r1)
367f6d57916SPaul Mackerras	mtspr	SPRN_DBAT6U,r4
3686ecb78efSChristophe Leroy	lwz	r4,SL_DBAT6+4(r1)
369f6d57916SPaul Mackerras	mtspr	SPRN_DBAT6L,r4
3706ecb78efSChristophe Leroy	lwz	r4,SL_DBAT7(r1)
371f6d57916SPaul Mackerras	mtspr	SPRN_DBAT7U,r4
3726ecb78efSChristophe Leroy	lwz	r4,SL_DBAT7+4(r1)
373f6d57916SPaul Mackerras	mtspr	SPRN_DBAT7L,r4
3746ecb78efSChristophe Leroy	lwz	r4,SL_IBAT4(r1)
375f6d57916SPaul Mackerras	mtspr	SPRN_IBAT4U,r4
3766ecb78efSChristophe Leroy	lwz	r4,SL_IBAT4+4(r1)
377f6d57916SPaul Mackerras	mtspr	SPRN_IBAT4L,r4
3786ecb78efSChristophe Leroy	lwz	r4,SL_IBAT5(r1)
379f6d57916SPaul Mackerras	mtspr	SPRN_IBAT5U,r4
3806ecb78efSChristophe Leroy	lwz	r4,SL_IBAT5+4(r1)
381f6d57916SPaul Mackerras	mtspr	SPRN_IBAT5L,r4
3826ecb78efSChristophe Leroy	lwz	r4,SL_IBAT6(r1)
383f6d57916SPaul Mackerras	mtspr	SPRN_IBAT6U,r4
3846ecb78efSChristophe Leroy	lwz	r4,SL_IBAT6+4(r1)
385f6d57916SPaul Mackerras	mtspr	SPRN_IBAT6L,r4
3866ecb78efSChristophe Leroy	lwz	r4,SL_IBAT7(r1)
387f6d57916SPaul Mackerras	mtspr	SPRN_IBAT7U,r4
3886ecb78efSChristophe Leroy	lwz	r4,SL_IBAT7+4(r1)
389f6d57916SPaul Mackerras	mtspr	SPRN_IBAT7L,r4
3907c03d653SBenjamin HerrenschmidtEND_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS)
391f6d57916SPaul Mackerras
392f6d57916SPaul Mackerras	/* Flush all TLBs */
393f6d57916SPaul Mackerras	lis	r4,0x1000
394f6d57916SPaul Mackerras1:	addic.	r4,r4,-0x1000
395f6d57916SPaul Mackerras	tlbie	r4
396f6d57916SPaul Mackerras	blt	1b
397f6d57916SPaul Mackerras	sync
398f6d57916SPaul Mackerras
399f6d57916SPaul Mackerras	/* Restore TB */
400f6d57916SPaul Mackerras	li	r3,0
401f6d57916SPaul Mackerras	mttbl	r3
402f6d57916SPaul Mackerras	lwz	r3,SL_TB(r1)
403f6d57916SPaul Mackerras	lwz	r4,SL_TB+4(r1)
404f6d57916SPaul Mackerras	mttbu	r3
405f6d57916SPaul Mackerras	mttbl	r4
406f6d57916SPaul Mackerras
407f6d57916SPaul Mackerras	/* Restore the callee-saved registers and return */
408f6d57916SPaul Mackerras	lwz	r0,SL_CR(r1)
409f6d57916SPaul Mackerras	mtcr	r0
410f6d57916SPaul Mackerras	lwz	r2,SL_R2(r1)
411f6d57916SPaul Mackerras	lmw	r12,SL_R12(r1)
412f6d57916SPaul Mackerras
413*db972a37SChristophe Leroy	/* restore the MSR and SP and turn on the MMU and return */
414*db972a37SChristophe Leroy	lwz	r3,SL_MSR(r1)
415*db972a37SChristophe Leroy	lwz	r4,SL_LR(r1)
416*db972a37SChristophe Leroy	lwz	r1,SL_SP(r1)
417f6d57916SPaul Mackerras	mtsrr0	r4
418f6d57916SPaul Mackerras	mtsrr1	r3
419f6d57916SPaul Mackerras	sync
420f6d57916SPaul Mackerras	isync
421f6d57916SPaul Mackerras	rfi
422*db972a37SChristophe Leroy_ASM_NOKPROBE_SYMBOL(grackle_wake_up)
423f6d57916SPaul Mackerras
424f6d57916SPaul Mackerras#endif /* defined(CONFIG_PM) || defined(CONFIG_CPU_FREQ) */
425f6d57916SPaul Mackerras
426*db972a37SChristophe Leroy	.section .bss
4277dffb720SStephen Rothwell	.balign	L1_CACHE_BYTES
428f6d57916SPaul Mackerrassleep_storage:
429*db972a37SChristophe Leroy	.space SL_SIZE
4307dffb720SStephen Rothwell	.balign	L1_CACHE_BYTES, 0
431f6d57916SPaul Mackerras
432d7cceda9SChristophe Leroy#endif /* CONFIG_PPC_BOOK3S_32 */
433f6d57916SPaul Mackerras	.section .text
434