Merge tag 'drm-next-2019-01-05' of git://anongit.freedesktop.org/drm/drm
[linux-2.6-block.git] / arch / powerpc / kernel / idle_e500.S
CommitLineData
fc4033b2
KG
1/*
2 * Copyright (C) 2008 Freescale Semiconductor, Inc. All rights reserved.
3 * Dave Liu <daveliu@freescale.com>
4 * copy from idle_6xx.S and modify for e500 based processor,
5 * implement the power_save function in idle.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#include <linux/threads.h>
14#include <asm/reg.h>
15#include <asm/page.h>
16#include <asm/cputable.h>
17#include <asm/thread_info.h>
18#include <asm/ppc_asm.h>
19#include <asm/asm-offsets.h>
2c86cd18 20#include <asm/feature-fixups.h>
fc4033b2
KG
21
22 .text
23
24_GLOBAL(e500_idle)
9778b696 25 CURRENT_THREAD_INFO(r3, r1)
fc4033b2
KG
26 lwz r4,TI_LOCAL_FLAGS(r3) /* set napping bit */
27 ori r4,r4,_TLF_NAPPING /* so when we take an exception */
28 stw r4,TI_LOCAL_FLAGS(r3) /* it will return to our caller */
29
e33ee8b6 30#ifdef CONFIG_PPC_E500MC
ebf714ff
SW
31 wrteei 1
321: wait
33
34 /*
35 * Guard against spurious wakeups (e.g. from a hypervisor) --
36 * any real interrupt will cause us to return to LR due to
37 * _TLF_NAPPING.
38 */
39 b 1b
40#else
fc4033b2
KG
41 /* Check if we can nap or doze, put HID0 mask in r3 */
42 lis r3,0
43BEGIN_FTR_SECTION
44 lis r3,HID0_DOZE@h
45END_FTR_SECTION_IFSET(CPU_FTR_CAN_DOZE)
46
47BEGIN_FTR_SECTION
48 /* Now check if user enabled NAP mode */
49 lis r4,powersave_nap@ha
50 lwz r4,powersave_nap@l(r4)
51 cmpwi 0,r4,0
52 beq 1f
53 stwu r1,-16(r1)
54 mflr r0
55 stw r0,20(r1)
56 bl flush_dcache_L1
57 lwz r0,20(r1)
58 addi r1,r1,16
59 mtlr r0
60 lis r3,HID0_NAP@h
61END_FTR_SECTION_IFSET(CPU_FTR_CAN_NAP)
621:
63 /* Go to NAP or DOZE now */
64 mfspr r4,SPRN_HID0
65 rlwinm r4,r4,0,~(HID0_DOZE|HID0_NAP|HID0_SLEEP)
66 or r4,r4,r3
67 isync
68 mtspr SPRN_HID0,r4
69 isync
70
71 mfmsr r7
72 oris r7,r7,MSR_WE@h
73 ori r7,r7,MSR_EE
74 msync
75 mtmsr r7
76 isync
772: b 2b
ebf714ff 78#endif /* !E500MC */
fc4033b2
KG
79
80/*
81 * Return from NAP/DOZE mode, restore some CPU specific registers,
82 * r2 containing physical address of current.
83 * r11 points to the exception frame (physical address).
84 * We have to preserve r10.
85 */
86_GLOBAL(power_save_ppc32_restore)
87 lwz r9,_LINK(r11) /* interrupted in e500_idle */
88 stw r9,_NIP(r11) /* make it do a blr */
89
90#ifdef CONFIG_SMP
9778b696 91 CURRENT_THREAD_INFO(r12, r1)
fc4033b2
KG
92 lwz r11,TI_CPU(r12) /* get cpu number * 4 */
93 slwi r11,r11,2
94#else
95 li r11,0
96#endif
7888bc2b 97
fc4033b2 98 b transfer_to_handler_cont