Haavard Skinnemoen | 7e59128 | 2008-02-24 23:24:26 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Low-level Power Management code. |
| 3 | * |
| 4 | * Copyright (C) 2008 Atmel Corporation |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
| 10 | #include <asm/asm.h> |
| 11 | #include <asm/asm-offsets.h> |
| 12 | #include <asm/thread_info.h> |
| 13 | #include <asm/arch/pm.h> |
| 14 | |
| 15 | .section .bss, "wa", @nobits |
| 16 | .global disable_idle_sleep |
| 17 | .type disable_idle_sleep, @object |
| 18 | disable_idle_sleep: |
| 19 | .int 4 |
| 20 | .size disable_idle_sleep, . - disable_idle_sleep |
| 21 | |
| 22 | /* Keep this close to the irq handlers */ |
| 23 | .section .irq.text, "ax", @progbits |
| 24 | |
| 25 | /* |
| 26 | * void cpu_enter_idle(void) |
| 27 | * |
| 28 | * Put the CPU into "idle" mode, in which it will consume |
| 29 | * significantly less power. |
| 30 | * |
| 31 | * If an interrupt comes along in the window between |
| 32 | * unmask_interrupts and the sleep instruction below, the |
| 33 | * interrupt code will adjust the return address so that we |
| 34 | * never execute the sleep instruction. This is required |
| 35 | * because the AP7000 doesn't unmask interrupts when entering |
| 36 | * sleep modes; later CPUs may not need this workaround. |
| 37 | */ |
| 38 | .global cpu_enter_idle |
| 39 | .type cpu_enter_idle, @function |
| 40 | cpu_enter_idle: |
| 41 | mask_interrupts |
| 42 | get_thread_info r8 |
| 43 | ld.w r9, r8[TI_flags] |
| 44 | bld r9, TIF_NEED_RESCHED |
| 45 | brcs .Lret_from_sleep |
| 46 | sbr r9, TIF_CPU_GOING_TO_SLEEP |
| 47 | st.w r8[TI_flags], r9 |
| 48 | unmask_interrupts |
| 49 | sleep CPU_SLEEP_IDLE |
| 50 | .size cpu_idle_sleep, . - cpu_idle_sleep |
| 51 | |
| 52 | /* |
| 53 | * Common return path for PM functions that don't run from |
| 54 | * SRAM. |
| 55 | */ |
| 56 | .global cpu_idle_skip_sleep |
| 57 | .type cpu_idle_skip_sleep, @function |
| 58 | cpu_idle_skip_sleep: |
| 59 | mask_interrupts |
| 60 | ld.w r9, r8[TI_flags] |
| 61 | cbr r9, TIF_CPU_GOING_TO_SLEEP |
| 62 | st.w r8[TI_flags], r9 |
| 63 | .Lret_from_sleep: |
| 64 | unmask_interrupts |
| 65 | retal r12 |
| 66 | .size cpu_idle_skip_sleep, . - cpu_idle_skip_sleep |