vserver 1.9.5.x5
[linux-2.6.git] / arch / arm / mach-pxa / pm.c
index b110340..901ee68 100644 (file)
@@ -19,6 +19,9 @@
 #include <asm/hardware.h>
 #include <asm/memory.h>
 #include <asm/system.h>
+#include <asm/arch/pxa-regs.h>
+#include <asm/arch/lubbock.h>
+#include <asm/mach/time.h>
 
 
 /*
@@ -32,6 +35,11 @@ extern void pxa_cpu_resume(void);
 #define SAVE(x)                sleep_save[SLEEP_SAVE_##x] = x
 #define RESTORE(x)     x = sleep_save[SLEEP_SAVE_##x]
 
+#define RESTORE_GPLEVEL(n) do { \
+       GPSR##n = sleep_save[SLEEP_SAVE_GPLR##n]; \
+       GPCR##n = ~sleep_save[SLEEP_SAVE_GPLR##n]; \
+} while (0)
+
 /*
  * List of global PXA peripheral registers to preserve.
  * More ones like CP and general purpose register values are preserved
@@ -39,19 +47,13 @@ extern void pxa_cpu_resume(void);
  */
 enum { SLEEP_SAVE_START = 0,
 
-       SLEEP_SAVE_OSCR, SLEEP_SAVE_OIER,
-       SLEEP_SAVE_OSMR0, SLEEP_SAVE_OSMR1, SLEEP_SAVE_OSMR2, SLEEP_SAVE_OSMR3,
-
+       SLEEP_SAVE_GPLR0, SLEEP_SAVE_GPLR1, SLEEP_SAVE_GPLR2,
        SLEEP_SAVE_GPDR0, SLEEP_SAVE_GPDR1, SLEEP_SAVE_GPDR2,
        SLEEP_SAVE_GRER0, SLEEP_SAVE_GRER1, SLEEP_SAVE_GRER2,
        SLEEP_SAVE_GFER0, SLEEP_SAVE_GFER1, SLEEP_SAVE_GFER2,
        SLEEP_SAVE_GAFR0_L, SLEEP_SAVE_GAFR1_L, SLEEP_SAVE_GAFR2_L,
        SLEEP_SAVE_GAFR0_U, SLEEP_SAVE_GAFR1_U, SLEEP_SAVE_GAFR2_U,
 
-       SLEEP_SAVE_FFIER, SLEEP_SAVE_FFLCR, SLEEP_SAVE_FFMCR,
-       SLEEP_SAVE_FFSPR, SLEEP_SAVE_FFISR,
-       SLEEP_SAVE_FFDLL, SLEEP_SAVE_FFDLH,
-
        SLEEP_SAVE_ICMR,
        SLEEP_SAVE_CKEN,
 
@@ -61,42 +63,22 @@ enum {      SLEEP_SAVE_START = 0,
 };
 
 
-static int pxa_pm_enter(u32 state)
+static int pxa_pm_enter(suspend_state_t state)
 {
        unsigned long sleep_save[SLEEP_SAVE_SIZE];
        unsigned long checksum = 0;
-       unsigned long delta;
+       struct timespec delta, rtc;
        int i;
 
        if (state != PM_SUSPEND_MEM)
                return -EINVAL;
 
        /* preserve current time */
-       delta = xtime.tv_sec - RCNR;
-
-       /*
-        * Temporary solution.  This won't be necessary once
-        * we move pxa support into the serial driver
-        * Save the FF UART
-        */
-       SAVE(FFIER);
-       SAVE(FFLCR);
-       SAVE(FFMCR);
-       SAVE(FFSPR);
-       SAVE(FFISR);
-       FFLCR |= 0x80;
-       SAVE(FFDLL);
-       SAVE(FFDLH);
-       FFLCR &= 0xef;
-
-       /* save vital registers */
-       SAVE(OSCR);
-       SAVE(OSMR0);
-       SAVE(OSMR1);
-       SAVE(OSMR2);
-       SAVE(OSMR3);
-       SAVE(OIER);
+       rtc.tv_sec = RCNR;
+       rtc.tv_nsec = 0;
+       save_time_delta(&delta, &rtc);
 
+       SAVE(GPLR0); SAVE(GPLR1); SAVE(GPLR2);
        SAVE(GPDR0); SAVE(GPDR1); SAVE(GPDR2);
        SAVE(GRER0); SAVE(GRER1); SAVE(GRER2);
        SAVE(GFER0); SAVE(GFER1); SAVE(GFER2);
@@ -146,21 +128,15 @@ static int pxa_pm_enter(u32 state)
        PSPR = 0;
 
        /* restore registers */
-       RESTORE(GPDR0); RESTORE(GPDR1); RESTORE(GPDR2);
-       RESTORE(GRER0); RESTORE(GRER1); RESTORE(GRER2);
-       RESTORE(GFER0); RESTORE(GFER1); RESTORE(GFER2);
        RESTORE(GAFR0_L); RESTORE(GAFR0_U);
        RESTORE(GAFR1_L); RESTORE(GAFR1_U);
        RESTORE(GAFR2_L); RESTORE(GAFR2_U);
+       RESTORE_GPLEVEL(0); RESTORE_GPLEVEL(1); RESTORE_GPLEVEL(2);
+       RESTORE(GPDR0); RESTORE(GPDR1); RESTORE(GPDR2);
+       RESTORE(GRER0); RESTORE(GRER1); RESTORE(GRER2);
+       RESTORE(GFER0); RESTORE(GFER1); RESTORE(GFER2);
 
-       PSSR = PSSR_PH;
-
-       RESTORE(OSMR0);
-       RESTORE(OSMR1);
-       RESTORE(OSMR2);
-       RESTORE(OSMR3);
-       RESTORE(OSCR);
-       RESTORE(OIER);
+       PSSR = PSSR_RDH | PSSR_PH;
 
        RESTORE(CKEN);
 
@@ -168,24 +144,9 @@ static int pxa_pm_enter(u32 state)
        ICCR = 1;
        RESTORE(ICMR);
 
-       /*
-        * Temporary solution.  This won't be necessary once
-        * we move pxa support into the serial driver.
-        * Restore the FF UART.
-        */
-       RESTORE(FFMCR);
-       RESTORE(FFSPR);
-       RESTORE(FFLCR);
-       FFLCR |= 0x80;
-       RESTORE(FFDLH);
-       RESTORE(FFDLL);
-       RESTORE(FFLCR);
-       RESTORE(FFISR);
-       FFFCR = 0x07;
-       RESTORE(FFIER);
-
        /* restore current time */
-       xtime.tv_sec = RCNR + delta;
+       rtc.tv_sec = RCNR;
+       restore_time_delta(&delta, &rtc);
 
 #ifdef DEBUG
        printk(KERN_DEBUG "*** made it back from resume\n");
@@ -202,7 +163,7 @@ unsigned long sleep_phys_sp(void *sp)
 /*
  * Called after processes are frozen, but before we shut down devices.
  */
-static int pxa_pm_prepare(u32 state)
+static int pxa_pm_prepare(suspend_state_t state)
 {
        return 0;
 }
@@ -210,7 +171,7 @@ static int pxa_pm_prepare(u32 state)
 /*
  * Called after devices are re-setup, but before processes are thawed.
  */
-static int pxa_pm_finish(u32 state)
+static int pxa_pm_finish(suspend_state_t state)
 {
        return 0;
 }