14 #include <asm/cacheflush.h>
19 #include <mach/sram.h>
23 #define SRAM_PAGE_FLAGS (SYSREG_BIT(TLBELO_D) | SYSREG_BF(SZ, 1) \
24 | SYSREG_BF(AP, 3) | SYSREG_BIT(G))
27 static unsigned long pm_sram_start;
28 static size_t pm_sram_size;
31 static void (*avr32_pm_enter_standby)(
unsigned long sdramc_base);
32 static void (*avr32_pm_enter_str)(
unsigned long sdramc_base);
38 static void *avr32_pm_map_sram(
void)
41 unsigned long page_addr;
45 vaddr = (
unsigned long)pm_sram_area->
addr;
66 return (
void *)(vaddr + pm_sram_start - page_addr);
73 static void avr32_pm_unmap_sram(
void)
120 sram = avr32_pm_map_sram();
131 pr_debug(
"%s: Entering standby...\n", __func__);
138 avr32_pm_unmap_sram();
142 sram = avr32_pm_map_sram();
153 pr_debug(
"%s: Entering suspend-to-ram...\n", __func__);
160 avr32_pm_unmap_sram();
164 pr_debug(
"%s: Entering idle...\n", __func__);
169 pr_debug(
"%s: Invalid suspend state %d\n", __func__, state);
180 .valid = avr32_pm_valid_state,
181 .enter = avr32_pm_enter,
184 static unsigned long avr32_pm_offset(
void *
symbol)
186 extern u8 pm_exception[];
188 return (
unsigned long)symbol - (
unsigned long)pm_exception;
191 static int __init avr32_pm_init(
void)
193 extern u8 pm_exception[];
195 extern u8 pm_standby[];
196 extern u8 pm_suspend_to_ram[];
197 extern u8 pm_sram_end[];
204 pm_sram_size = avr32_pm_offset(pm_sram_end);
219 dst = avr32_pm_map_sram();
220 memcpy(dst, pm_exception, pm_sram_size);
223 avr32_pm_unmap_sram();
226 avr32_pm_enter_standby = dst + avr32_pm_offset(pm_standby);
227 avr32_pm_enter_str = dst + avr32_pm_offset(pm_suspend_to_ram);
232 printk(
"AVR32 AP Power Management enabled\n");
240 pr_err(
"AVR32 Power Management initialization failed\n");