2 * This file contains the power_save function for 6xx & 7xxx CPUs
3 * rewritten in assembler
5 * Warning ! This code assumes that if your machine has a 750fx
6 * it will have PLL 1 set to low speed mode (used during NAP/DOZE).
7 * if this is not the case some additional changes will have to
8 * be done to check a runtime var (a bit like powersave-nap)
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
16 #include <linux/config.h>
17 #include <linux/threads.h>
20 #include <asm/cputable.h>
21 #include <asm/thread_info.h>
22 #include <asm/ppc_asm.h>
23 #include <asm/asm-offsets.h>
28 * Init idle, called at early CPU setup time from head.S for each CPU
29 * Make sure no rest of NAP mode remains in HID0, save default
30 * values for some CPU specific registers. Called with r24
31 * containing CPU number and r3 reloc offset
33 _GLOBAL(init_idle_6xx)
36 rlwinm r4,r4,0,10,8 /* Clear NAP */
39 END_FTR_SECTION_IFSET(CPU_FTR_CAN_NAP)
46 addis r6,r5, nap_save_msscr0@ha
47 stw r4,nap_save_msscr0@l(r6)
48 END_FTR_SECTION_IFSET(CPU_FTR_NAP_DISABLE_L2_PR)
51 addis r6,r5,nap_save_hid1@ha
52 stw r4,nap_save_hid1@l(r6)
53 END_FTR_SECTION_IFSET(CPU_FTR_DUAL_PLL_750FX)
57 * Here is the power_save_6xx function. This could eventually be
58 * split into several functions & changing the function pointer
59 * depending on the various features.
62 /* Check if we can nap or doze, put HID0 mask in r3
67 END_FTR_SECTION_IFSET(CPU_FTR_CAN_DOZE)
69 /* We must dynamically check for the NAP feature as it
70 * can be cleared by CPU init after the fixups are done
72 lis r4,cur_cpu_spec@ha
73 lwz r4,cur_cpu_spec@l(r4)
74 lwz r4,CPU_SPEC_FEATURES(r4)
75 andi. r0,r4,CPU_FTR_CAN_NAP
77 /* Now check if user or arch enabled NAP mode */
78 lis r4,powersave_nap@ha
79 lwz r4,powersave_nap@l(r4)
84 END_FTR_SECTION_IFSET(CPU_FTR_CAN_NAP)
88 /* Some pre-nap cleanups needed on some CPUs */
89 andis. r0,r3,HID0_NAP@h
92 /* Disable L2 prefetch on some 745x and try to ensure
93 * L2 prefetch engines are idle. As explained by errata
94 * text, we can't be sure they are, we just hope very hard
95 * that well be enough (sic !). At least I noticed Apple
96 * doesn't even bother doing the dcbf's here...
109 END_FTR_SECTION_IFSET(CPU_FTR_NAP_DISABLE_L2_PR)
112 /* Go to low speed mode on some 750FX */
113 lis r4,powersave_lowspeed@ha
114 lwz r4,powersave_lowspeed@l(r4)
121 END_FTR_SECTION_IFSET(CPU_FTR_DUAL_PLL_750FX)
123 /* Go to NAP or DOZE now */
125 lis r5,(HID0_NAP|HID0_SLEEP)@h
127 oris r5,r5,HID0_DOZE@h
128 END_FTR_SECTION_IFSET(CPU_FTR_CAN_DOZE)
132 oris r4,r4,HID0_DPM@h /* that should be done once for all */
133 END_FTR_SECTION_IFCLR(CPU_FTR_NO_DPM)
138 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
139 rlwinm r9,r1,0,0,31-THREAD_SHIFT /* current thread_info */
140 lwz r8,TI_LOCAL_FLAGS(r9) /* set napping bit */
141 ori r8,r8,_TLF_NAPPING /* so when we take an exception */
142 stw r8,TI_LOCAL_FLAGS(r9) /* it will return to our caller */
152 * Return from NAP/DOZE mode, restore some CPU specific registers,
153 * we are called with DR/IR still off and r2 containing physical
154 * address of current. R11 points to the exception frame (physical
155 * address). We have to preserve r10.
157 _GLOBAL(power_save_6xx_restore)
158 lwz r9,_LINK(r11) /* interrupted in ppc6xx_idle: */
159 stw r9,_NIP(r11) /* make it do a blr */
163 lwz r11,TI_CPU(r12) /* get cpu number * 4 */
168 /* Todo make sure all these are in the same page
169 * and load r11 (@ha part + CPU offset) only once
173 andis. r9,r9,HID0_NAP@h
175 addis r9,r11,(nap_save_msscr0-KERNELBASE)@ha
176 lwz r9,nap_save_msscr0@l(r9)
177 mtspr SPRN_MSSCR0, r9
181 END_FTR_SECTION_IFSET(CPU_FTR_NAP_DISABLE_L2_PR)
183 addis r9,r11,(nap_save_hid1-KERNELBASE)@ha
184 lwz r9,nap_save_hid1@l(r9)
186 END_FTR_SECTION_IFSET(CPU_FTR_DUAL_PLL_750FX)
187 b transfer_to_handler_cont
191 _GLOBAL(nap_save_msscr0)
194 _GLOBAL(nap_save_hid1)
197 _GLOBAL(powersave_lowspeed)