]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/powerpc/platforms/52xx/lite5200_pm.c
Suspend: Introduce begin() and end() callbacks
[linux-2.6-omap-h63xx.git] / arch / powerpc / platforms / 52xx / lite5200_pm.c
index f26afcd41757ad1bb96f81ec78b9995d7ccc7db6..41c7fd91e99e5836cbaef5c7d6803334bc37a206 100644 (file)
@@ -1,5 +1,5 @@
 #include <linux/init.h>
-#include <linux/pm.h>
+#include <linux/suspend.h>
 #include <asm/io.h>
 #include <asm/time.h>
 #include <asm/mpc52xx.h>
@@ -18,6 +18,8 @@ static void __iomem *sram;
 static const int sram_size = 0x4000;   /* 16 kBytes */
 static void __iomem *mbar;
 
+static suspend_state_t lite5200_pm_target_state;
+
 static int lite5200_pm_valid(suspend_state_t state)
 {
        switch (state) {
@@ -29,17 +31,37 @@ static int lite5200_pm_valid(suspend_state_t state)
        }
 }
 
-static int lite5200_pm_prepare(suspend_state_t state)
+static int lite5200_pm_begin(suspend_state_t state)
 {
+       if (lite5200_pm_valid(state)) {
+               lite5200_pm_target_state = state;
+               return 0;
+       }
+       return -EINVAL;
+}
+
+static int lite5200_pm_prepare(void)
+{
+       struct device_node *np;
+       const struct of_device_id immr_ids[] = {
+               { .compatible = "fsl,mpc5200-immr", },
+               { .compatible = "fsl,mpc5200b-immr", },
+               { .type = "soc", .compatible = "mpc5200", }, /* lite5200 */
+               { .type = "builtin", .compatible = "mpc5200", }, /* efika */
+               {}
+       };
+
        /* deep sleep? let mpc52xx code handle that */
-       if (state == PM_SUSPEND_STANDBY)
-               return mpc52xx_pm_prepare(state);
+       if (lite5200_pm_target_state == PM_SUSPEND_STANDBY)
+               return mpc52xx_pm_prepare();
 
-       if (state != PM_SUSPEND_MEM)
+       if (lite5200_pm_target_state != PM_SUSPEND_MEM)
                return -EINVAL;
 
        /* map registers */
-       mbar = mpc52xx_find_and_map("mpc5200");
+       np = of_find_matching_node(NULL, immr_ids);
+       mbar = of_iomap(np, 0);
+       of_node_put(np);
        if (!mbar) {
                printk(KERN_ERR "%s:%i Error mapping registers\n", __func__, __LINE__);
                return -ENOSYS;
@@ -190,24 +212,29 @@ static int lite5200_pm_enter(suspend_state_t state)
        return 0;
 }
 
-static int lite5200_pm_finish(suspend_state_t state)
+static void lite5200_pm_finish(void)
 {
        /* deep sleep? let mpc52xx code handle that */
-       if (state == PM_SUSPEND_STANDBY) {
-               return mpc52xx_pm_finish(state);
-       }
-       return 0;
+       if (lite5200_pm_target_state == PM_SUSPEND_STANDBY)
+               mpc52xx_pm_finish();
+}
+
+static void lite5200_pm_end(void)
+{
+       lite5200_pm_target_state = PM_SUSPEND_ON;
 }
 
-static struct pm_ops lite5200_pm_ops = {
+static struct platform_suspend_ops lite5200_pm_ops = {
        .valid          = lite5200_pm_valid,
+       .begin          = lite5200_pm_begin,
        .prepare        = lite5200_pm_prepare,
        .enter          = lite5200_pm_enter,
        .finish         = lite5200_pm_finish,
+       .end            = lite5200_pm_end,
 };
 
 int __init lite5200_pm_init(void)
 {
-       pm_set_ops(&lite5200_pm_ops);
+       suspend_set_ops(&lite5200_pm_ops);
        return 0;
 }