Commit 09cef8bd authored by Jia Hongtao's avatar Jia Hongtao Committed by Kumar Gala

powerpc/85xx: Add lbc suspend support for PM

Power supply for LBC registers is off when system go to deep-sleep state.
We save the values of registers before suspend and restore to registers
after resume.

We removed the last two reservation arrays from struct fsl_lbc_regs for
allocating less memory and minimizing the memcpy size.
Signed-off-by: default avatarJiang Yutang <b14898@freescale.com>
Signed-off-by: default avatarJia Hongtao <B38951@freescale.com>
Signed-off-by: default avatarLi Yang <leoli@freescale.com>
Signed-off-by: default avatarKumar Gala <galak@kernel.crashing.org>
parent 05737c7c
...@@ -238,8 +238,6 @@ struct fsl_lbc_regs { ...@@ -238,8 +238,6 @@ struct fsl_lbc_regs {
#define FPAR_LP_CI_SHIFT 0 #define FPAR_LP_CI_SHIFT 0
__be32 fbcr; /**< Flash Byte Count Register */ __be32 fbcr; /**< Flash Byte Count Register */
#define FBCR_BC 0x00000FFF #define FBCR_BC 0x00000FFF
u8 res11[0x8];
u8 res8[0xF00];
}; };
/* /*
...@@ -294,6 +292,11 @@ struct fsl_lbc_ctrl { ...@@ -294,6 +292,11 @@ struct fsl_lbc_ctrl {
/* status read from LTESR by irq handler */ /* status read from LTESR by irq handler */
unsigned int irq_status; unsigned int irq_status;
#ifdef CONFIG_SUSPEND
/* save regs when system go to deep-sleep */
struct fsl_lbc_regs *saved_regs;
#endif
}; };
extern int fsl_upm_run_pattern(struct fsl_upm *upm, void __iomem *io_base, extern int fsl_upm_run_pattern(struct fsl_upm *upm, void __iomem *io_base,
......
...@@ -332,6 +332,38 @@ static int __devinit fsl_lbc_ctrl_probe(struct platform_device *dev) ...@@ -332,6 +332,38 @@ static int __devinit fsl_lbc_ctrl_probe(struct platform_device *dev)
return ret; return ret;
} }
#ifdef CONFIG_SUSPEND
/* save lbc registers */
static int fsl_lbc_suspend(struct platform_device *pdev, pm_message_t state)
{
struct fsl_lbc_ctrl *ctrl = dev_get_drvdata(&pdev->dev);
struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
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));
return 0;
}
/* restore lbc registers */
static int fsl_lbc_resume(struct platform_device *pdev)
{
struct fsl_lbc_ctrl *ctrl = dev_get_drvdata(&pdev->dev);
struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
if (ctrl->saved_regs) {
_memcpy_toio(lbc, ctrl->saved_regs,
sizeof(struct fsl_lbc_regs));
kfree(ctrl->saved_regs);
ctrl->saved_regs = NULL;
}
return 0;
}
#endif /* CONFIG_SUSPEND */
static const struct of_device_id fsl_lbc_match[] = { static const struct of_device_id fsl_lbc_match[] = {
{ .compatible = "fsl,elbc", }, { .compatible = "fsl,elbc", },
{ .compatible = "fsl,pq3-localbus", }, { .compatible = "fsl,pq3-localbus", },
...@@ -346,6 +378,10 @@ static struct platform_driver fsl_lbc_ctrl_driver = { ...@@ -346,6 +378,10 @@ static struct platform_driver fsl_lbc_ctrl_driver = {
.of_match_table = fsl_lbc_match, .of_match_table = fsl_lbc_match,
}, },
.probe = fsl_lbc_ctrl_probe, .probe = fsl_lbc_ctrl_probe,
#ifdef CONFIG_SUSPEND
.suspend = fsl_lbc_suspend,
.resume = fsl_lbc_resume,
#endif
}; };
static int __init fsl_lbc_init(void) static int __init fsl_lbc_init(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment