powerpc/fsl-lbc: Modify suspend/resume entry sequence
authorRaghav Dogra <raghav.dogra@nxp.com>
Tue, 9 Feb 2016 09:39:08 +0000 (15:09 +0530)
committerScott Wood <oss@buserror.net>
Wed, 9 Mar 2016 16:44:17 +0000 (10:44 -0600)
Modify platform driver suspend/resume to syscore
suspend/resume. This is because p1022ds needs to use
localbus when entering the PCIE resume.

Signed-off-by: Raghav Dogra <raghav.dogra@nxp.com>
[scottwood: dropped makefile churn]
Signed-off-by: Scott Wood <oss@buserror.net>
arch/powerpc/sysdev/fsl_lbc.c

index 47f781059eeb667b3114f1990e5ce0863a8490f3..424b67fdb57f722bb47c8fd33530bfe98ac40e11 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
 #include <linux/mod_devicetable.h>
+#include <linux/syscore_ops.h>
 #include <asm/prom.h>
 #include <asm/fsl_lbc.h>
 
@@ -352,24 +353,42 @@ err:
 #ifdef CONFIG_SUSPEND
 
 /* save lbc registers */
-static int fsl_lbc_suspend(struct platform_device *pdev, pm_message_t state)
+static int fsl_lbc_syscore_suspend(void)
 {
-       struct fsl_lbc_ctrl *ctrl = dev_get_drvdata(&pdev->dev);
-       struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
+       struct fsl_lbc_ctrl *ctrl;
+       struct fsl_lbc_regs __iomem *lbc;
+
+       ctrl = fsl_lbc_ctrl_dev;
+       if (!ctrl)
+               goto out;
+
+       lbc = ctrl->regs;
+       if (!lbc)
+               goto out;
 
        ctrl->saved_regs = kmalloc(sizeof(struct fsl_lbc_regs), GFP_KERNEL);
        if (!ctrl->saved_regs)
                return -ENOMEM;
 
        _memcpy_fromio(ctrl->saved_regs, lbc, sizeof(struct fsl_lbc_regs));
+
+out:
        return 0;
 }
 
 /* restore lbc registers */
-static int fsl_lbc_resume(struct platform_device *pdev)
+static void fsl_lbc_syscore_resume(void)
 {
-       struct fsl_lbc_ctrl *ctrl = dev_get_drvdata(&pdev->dev);
-       struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
+       struct fsl_lbc_ctrl *ctrl;
+       struct fsl_lbc_regs __iomem *lbc;
+
+       ctrl = fsl_lbc_ctrl_dev;
+       if (!ctrl)
+               goto out;
+
+       lbc = ctrl->regs;
+       if (!lbc)
+               goto out;
 
        if (ctrl->saved_regs) {
                _memcpy_toio(lbc, ctrl->saved_regs,
@@ -377,7 +396,9 @@ static int fsl_lbc_resume(struct platform_device *pdev)
                kfree(ctrl->saved_regs);
                ctrl->saved_regs = NULL;
        }
-       return 0;
+
+out:
+       return;
 }
 #endif /* CONFIG_SUSPEND */
 
@@ -389,20 +410,26 @@ static const struct of_device_id fsl_lbc_match[] = {
        {},
 };
 
+#ifdef CONFIG_SUSPEND
+static struct syscore_ops lbc_syscore_pm_ops = {
+       .suspend = fsl_lbc_syscore_suspend,
+       .resume = fsl_lbc_syscore_resume,
+};
+#endif
+
 static struct platform_driver fsl_lbc_ctrl_driver = {
        .driver = {
                .name = "fsl-lbc",
                .of_match_table = fsl_lbc_match,
        },
        .probe = fsl_lbc_ctrl_probe,
-#ifdef CONFIG_SUSPEND
-       .suspend     = fsl_lbc_suspend,
-       .resume      = fsl_lbc_resume,
-#endif
 };
 
 static int __init fsl_lbc_init(void)
 {
+#ifdef CONFIG_SUSPEND
+       register_syscore_ops(&lbc_syscore_pm_ops);
+#endif
        return platform_driver_register(&fsl_lbc_ctrl_driver);
 }
 subsys_initcall(fsl_lbc_init);
This page took 0.026187 seconds and 5 git commands to generate.