hh.org updates
[hh.org.git] / arch / arm / mach-pxa / eseries / e400_pm.c
blobf06927a2798fe4913d3c4621c453121e6448a8ef
1 /*
2 * e-series wince-bootloader support
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 */
10 #include <linux/init.h>
11 #include <linux/kernel.h>
12 #include <linux/ioport.h>
13 #include <linux/device.h>
14 #include <linux/input.h>
15 #include <linux/delay.h>
16 #include <linux/interrupt.h>
18 #include <asm/mach-types.h>
19 #include <asm/hardware.h>
20 #include <asm/mach/arch.h>
21 #include <asm/arch/pxa-pm_ll.h>
22 #include <asm/arch/pxa-regs.h>
24 extern void pxa_cpu_resume(void);
26 static u32 saved_value[4];
27 static u32 *save_base;
29 static unsigned long calc_csum(u32 *buf) {
30 unsigned long val = 0x5a72;
31 int i;
33 for(i = 0 ; i < 0x5e ; i++) {
34 val += *buf;
35 val = ((val<<1)&0xfffffffe)|((val>>31)&0x1);
36 buf++;
38 return val;
41 static void eseries_pxa_ll_pm_suspend(unsigned long resume_addr) {
42 saved_value[0] = *save_base;
43 saved_value[1] = *(save_base+(36>>2));
45 // asm ("mrc p15, 0, %0, cr3, cr0;\n" :"=r"(rp) );
46 // *(save_base+(0x9c>>2)) = 1; // FIXME - flush cache
48 *save_base = 0; // FIXME - flush cache
49 *(save_base+(36>>2)) = resume_addr; // FIXME - flush cache
51 PSPR = calc_csum(save_base);
52 return;
55 static void eseries_pxa_ll_pm_resume(void) {
56 *(save_base) = saved_value[0]; // FIXME - flush cache
57 *(save_base+(36>>2)) = saved_value[1]; // FIXME - flush cache
60 static struct pxa_ll_pm_ops eseries_ll_pm_ops = {
61 .suspend = eseries_pxa_ll_pm_suspend,
62 .resume = eseries_pxa_ll_pm_resume,
65 static int __init eseries_ll_pm_init(void)
67 save_base = 0;
69 if(machine_is_e400() || machine_is_e750())
70 save_base = phys_to_virt(0xa3f7a000);
71 if(machine_is_e800())
72 save_base = phys_to_virt(0xa00b8000);
74 if(save_base) {
75 printk("Initialising wince bootloader suspend workaround\n");
76 pxa_pm_set_ll_ops(&eseries_ll_pm_ops);
79 return 0;
82 module_init(eseries_ll_pm_init);
84 MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
85 MODULE_DESCRIPTION("implement e-series pm using the wince loader");
86 MODULE_LICENSE("GPLv2");