[ARM] pxa: Allow platforms to override PSPR setting
authorRussell King <rmk@dyn-67.arm.linux.org.uk>
Wed, 27 Aug 2008 11:55:04 +0000 (12:55 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Tue, 9 Sep 2008 15:32:52 +0000 (16:32 +0100)
Currently, we set PSPR just before entering sleep mode.  However,
some platforms have different requirements for setting PSPR in
order to properly wake up.

Set PSPR earlier in the suspend cycle so that platforms can
change the setting by using a sysdev driver instead.

Acked-by: Eric Miao <eric.miao@marvell.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/mach-pxa/include/mach/pm.h
arch/arm/mach-pxa/pm.c
arch/arm/mach-pxa/pxa25x.c
arch/arm/mach-pxa/pxa27x.c

index 261e5bc958db158739c6ad45bfcd8e36b1c8ae19..83342469acaca8faeb46f11ea81db7fe7ce34fb2 100644 (file)
@@ -15,6 +15,8 @@ struct pxa_cpu_pm_fns {
        void    (*restore)(unsigned long *);
        int     (*valid)(suspend_state_t state);
        void    (*enter)(suspend_state_t state);
+       int     (*prepare)(void);
+       void    (*finish)(void);
 };
 
 extern struct pxa_cpu_pm_fns *pxa_cpu_pm_fns;
index 1b539e675579cc3388f72699e1c2aba12a148691..164eb0bb6321f5bf0bbd626b14587188cb629a4c 100644 (file)
@@ -86,9 +86,27 @@ static int pxa_pm_valid(suspend_state_t state)
        return -EINVAL;
 }
 
+static int pxa_pm_prepare(void)
+{
+       int ret = 0;
+
+       if (pxa_cpu_pm_fns && pxa_cpu_pm_fns->prepare)
+               ret = pxa_cpu_pm_fns->prepare();
+
+       return ret;
+}
+
+static void pxa_pm_finish(void)
+{
+       if (pxa_cpu_pm_fns && pxa_cpu_pm_fns->finish)
+               pxa_cpu_pm_fns->finish();
+}
+
 static struct platform_suspend_ops pxa_pm_ops = {
        .valid          = pxa_pm_valid,
        .enter          = pxa_pm_enter,
+       .prepare        = pxa_pm_prepare,
+       .finish         = pxa_pm_finish,
 };
 
 static int __init pxa_pm_init(void)
index 305452b56e91dfcda49e81c5876c0ed0ca935583..db7be22ccd179dee6468720c59388be5a8955d54 100644 (file)
@@ -234,9 +234,6 @@ static void pxa25x_cpu_pm_save(unsigned long *sleep_save)
 
 static void pxa25x_cpu_pm_restore(unsigned long *sleep_save)
 {
-       /* ensure not to come back here if it wasn't intended */
-       PSPR = 0;
-
        /* restore registers */
        RESTORE(GAFR0_L); RESTORE(GAFR0_U);
        RESTORE(GAFR1_L); RESTORE(GAFR1_U);
@@ -256,19 +253,32 @@ static void pxa25x_cpu_pm_enter(suspend_state_t state)
 
        switch (state) {
        case PM_SUSPEND_MEM:
-               /* set resume return address */
-               PSPR = virt_to_phys(pxa_cpu_resume);
                pxa25x_cpu_suspend(PWRMODE_SLEEP);
                break;
        }
 }
 
+static int pxa25x_cpu_pm_prepare(void)
+{
+       /* set resume return address */
+       PSPR = virt_to_phys(pxa_cpu_resume);
+       return 0;
+}
+
+static void pxa25x_cpu_pm_finish(void)
+{
+       /* ensure not to come back here if it wasn't intended */
+       PSPR = 0;
+}
+
 static struct pxa_cpu_pm_fns pxa25x_cpu_pm_fns = {
        .save_count     = SLEEP_SAVE_COUNT,
        .valid          = suspend_valid_only_mem,
        .save           = pxa25x_cpu_pm_save,
        .restore        = pxa25x_cpu_pm_restore,
        .enter          = pxa25x_cpu_pm_enter,
+       .prepare        = pxa25x_cpu_pm_prepare,
+       .finish         = pxa25x_cpu_pm_finish,
 };
 
 static void __init pxa25x_init_pm(void)
index c33cf6ac8c81fdd6c2416bdd54608b339ab6e9f0..4835207c142680c733b437aca03397e9404de8e9 100644 (file)
@@ -220,9 +220,6 @@ void pxa27x_cpu_pm_save(unsigned long *sleep_save)
 
 void pxa27x_cpu_pm_restore(unsigned long *sleep_save)
 {
-       /* ensure not to come back here if it wasn't intended */
-       PSPR = 0;
-
        /* restore registers */
        RESTORE(GAFR0_L); RESTORE(GAFR0_U);
        RESTORE(GAFR1_L); RESTORE(GAFR1_U);
@@ -259,8 +256,6 @@ void pxa27x_cpu_pm_enter(suspend_state_t state)
                pxa_cpu_standby();
                break;
        case PM_SUSPEND_MEM:
-               /* set resume return address */
-               PSPR = virt_to_phys(pxa_cpu_resume);
                pxa27x_cpu_suspend(PWRMODE_SLEEP);
                break;
        }
@@ -271,12 +266,27 @@ static int pxa27x_cpu_pm_valid(suspend_state_t state)
        return state == PM_SUSPEND_MEM || state == PM_SUSPEND_STANDBY;
 }
 
+static int pxa27x_cpu_pm_prepare(void)
+{
+       /* set resume return address */
+       PSPR = virt_to_phys(pxa_cpu_resume);
+       return 0;
+}
+
+static void pxa27x_cpu_pm_finish(void)
+{
+       /* ensure not to come back here if it wasn't intended */
+       PSPR = 0;
+}
+
 static struct pxa_cpu_pm_fns pxa27x_cpu_pm_fns = {
        .save_count     = SLEEP_SAVE_COUNT,
        .save           = pxa27x_cpu_pm_save,
        .restore        = pxa27x_cpu_pm_restore,
        .valid          = pxa27x_cpu_pm_valid,
        .enter          = pxa27x_cpu_pm_enter,
+       .prepare        = pxa27x_cpu_pm_prepare,
+       .finish         = pxa27x_cpu_pm_finish,
 };
 
 static void __init pxa27x_init_pm(void)