aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhao Chenhui <chenhui.zhao@freescale.com>2012-04-19 05:51:34 -0400
committerWolfram Sang <w.sang@pengutronix.de>2012-05-12 08:28:12 -0400
commit531183e5d27312d68fab40352cd13426aa761473 (patch)
tree3e6ebe9104413dd8cae0fa85f04259364d2397ac
parentad33707417e4fa3dd4b12f9ed912e2349a984026 (diff)
i2c-mpc: avoid I2C abnormal after resuming from deep sleep
When entering deep sleep, the value in the registers I2CFDR and I2CDFSRR are lost. This causes I2C access to fail after resuming. Add suspend/resume routines to save/restore the registers I2CFDR and I2CDFSRR. Signed-off-by: Zhao Chenhui <chenhui.zhao@freescale.com> Signed-off-by: Li Yang <leoli@freescale.com> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
-rw-r--r--drivers/i2c/busses/i2c-mpc.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 206caacd30d7..b76731edbf10 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -64,6 +64,9 @@ struct mpc_i2c {
64 struct i2c_adapter adap; 64 struct i2c_adapter adap;
65 int irq; 65 int irq;
66 u32 real_clk; 66 u32 real_clk;
67#ifdef CONFIG_PM
68 u8 fdr, dfsrr;
69#endif
67}; 70};
68 71
69struct mpc_i2c_divider { 72struct mpc_i2c_divider {
@@ -703,6 +706,30 @@ static int __devexit fsl_i2c_remove(struct platform_device *op)
703 return 0; 706 return 0;
704}; 707};
705 708
709#ifdef CONFIG_PM
710static int mpc_i2c_suspend(struct device *dev)
711{
712 struct mpc_i2c *i2c = dev_get_drvdata(dev);
713
714 i2c->fdr = readb(i2c->base + MPC_I2C_FDR);
715 i2c->dfsrr = readb(i2c->base + MPC_I2C_DFSRR);
716
717 return 0;
718}
719
720static int mpc_i2c_resume(struct device *dev)
721{
722 struct mpc_i2c *i2c = dev_get_drvdata(dev);
723
724 writeb(i2c->fdr, i2c->base + MPC_I2C_FDR);
725 writeb(i2c->dfsrr, i2c->base + MPC_I2C_DFSRR);
726
727 return 0;
728}
729
730SIMPLE_DEV_PM_OPS(mpc_i2c_pm_ops, mpc_i2c_suspend, mpc_i2c_resume);
731#endif
732
706static struct mpc_i2c_data mpc_i2c_data_512x __devinitdata = { 733static struct mpc_i2c_data mpc_i2c_data_512x __devinitdata = {
707 .setup = mpc_i2c_setup_512x, 734 .setup = mpc_i2c_setup_512x,
708}; 735};
@@ -747,6 +774,9 @@ static struct platform_driver mpc_i2c_driver = {
747 .owner = THIS_MODULE, 774 .owner = THIS_MODULE,
748 .name = DRV_NAME, 775 .name = DRV_NAME,
749 .of_match_table = mpc_i2c_of_match, 776 .of_match_table = mpc_i2c_of_match,
777#ifdef CONFIG_PM
778 .pm = &mpc_i2c_pm_ops,
779#endif
750 }, 780 },
751}; 781};
752 782