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.
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.
13 #include <linux/threads.h>
16 #include <asm/cputable.h>
17 #include <asm/thread_info.h>
18 #include <asm/ppc_asm.h>
19 #include <asm/asm-offsets.h>
24 rlwinm r3,r1,0,0,31-THREAD_SHIFT /* current thread_info */
25 lwz r4,TI_LOCAL_FLAGS(r3) /* set napping bit */
26 ori r4,r4,_TLF_NAPPING /* so when we take an exception */
27 stw r4,TI_LOCAL_FLAGS(r3) /* it will return to our caller */
29 /* Check if we can nap or doze, put HID0 mask in r3 */
33 END_FTR_SECTION_IFSET(CPU_FTR_CAN_DOZE)
36 /* Now check if user enabled NAP mode */
37 lis r4,powersave_nap@ha
38 lwz r4,powersave_nap@l(r4)
49 END_FTR_SECTION_IFSET(CPU_FTR_CAN_NAP)
56 andi. r4,r7,L2CSR0_L2FL@l
58 END_FTR_SECTION_IFSET(CPU_FTR_L2CSR|CPU_FTR_CAN_NAP)
60 /* Go to NAP or DOZE now */
62 rlwinm r4,r4,0,~(HID0_DOZE|HID0_NAP|HID0_SLEEP)
77 * Return from NAP/DOZE mode, restore some CPU specific registers,
78 * r2 containing physical address of current.
79 * r11 points to the exception frame (physical address).
80 * We have to preserve r10.
82 _GLOBAL(power_save_ppc32_restore)
83 lwz r9,_LINK(r11) /* interrupted in e500_idle */
84 stw r9,_NIP(r11) /* make it do a blr */
87 rlwinm r12,r1,0,0,31-THREAD_SHIFT
88 lwz r11,TI_CPU(r12) /* get cpu number * 4 */
94 b transfer_to_handler_cont