From: Zhao Chenhui <chenhui.zhao@freescale.com>
To: <linux-i2c@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>,
Zhao Chenhui <chenhui.zhao@freescale.com>,
Li Yang <leoli@freescale.com>
Subject: [PATCH] i2c-mpc: avoid I2C abnormal after resuming from deep sleep
Date: Wed, 29 Feb 2012 18:39:21 +0800 [thread overview]
Message-ID: <1330511961-22498-1-git-send-email-chenhui.zhao@freescale.com> (raw)
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>
---
drivers/i2c/busses/i2c-mpc.c | 34 +++++++++++++++++++++++++++++++++-
1 files changed, 33 insertions(+), 1 deletions(-)
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index a8ebb84..f95a647 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -1,7 +1,9 @@
/*
* (C) Copyright 2003-2004
* Humboldt Solutions Ltd, adrian@humboldt.co.uk.
-
+ *
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ *
* This is a combined i2c adapter and algorithm driver for the
* MPC107/Tsi107 PowerPC northbridge and processors that include
* the same I2C unit (8240, 8245, 85xx).
@@ -64,6 +66,9 @@ struct mpc_i2c {
struct i2c_adapter adap;
int irq;
u32 real_clk;
+#ifdef CONFIG_PM
+ u8 fdr, dfsrr;
+#endif
};
struct mpc_i2c_divider {
@@ -668,6 +673,30 @@ static int __devexit fsl_i2c_remove(struct platform_device *op)
return 0;
};
+#ifdef CONFIG_PM
+static int mpc_i2c_suspend(struct device *dev)
+{
+ struct mpc_i2c *i2c = dev_get_drvdata(dev);
+
+ i2c->fdr = readb(i2c->base + MPC_I2C_FDR);
+ i2c->dfsrr = readb(i2c->base + MPC_I2C_DFSRR);
+
+ return 0;
+}
+
+static int mpc_i2c_resume(struct device *dev)
+{
+ struct mpc_i2c *i2c = dev_get_drvdata(dev);
+
+ writeb(i2c->fdr, i2c->base + MPC_I2C_FDR);
+ writeb(i2c->dfsrr, i2c->base + MPC_I2C_DFSRR);
+
+ return 0;
+}
+
+SIMPLE_DEV_PM_OPS(mpc_i2c_pm_ops, mpc_i2c_suspend, mpc_i2c_resume);
+#endif
+
static struct mpc_i2c_data mpc_i2c_data_512x __devinitdata = {
.setup = mpc_i2c_setup_512x,
};
@@ -712,6 +741,9 @@ static struct platform_driver mpc_i2c_driver = {
.owner = THIS_MODULE,
.name = DRV_NAME,
.of_match_table = mpc_i2c_of_match,
+#ifdef CONFIG_PM
+ .pm = &mpc_i2c_pm_ops,
+#endif
},
};
--
1.6.4.1
next reply other threads:[~2012-02-29 10:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-29 10:39 Zhao Chenhui [this message]
2012-02-29 13:02 ` Shubhrajyoti Datta
2012-02-29 18:08 ` Tabi Timur-B04825
2012-02-29 18:45 ` Wolfram Sang
2012-03-01 11:27 ` Ben Dooks
2012-04-17 14:21 ` Wolfram Sang
2012-04-18 10:20 ` Li Yang-R58472
2012-04-18 10:33 ` Wolfram Sang
2012-04-18 14:44 ` Li Yang
2012-04-18 21:49 ` Tabi Timur-B04825
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1330511961-22498-1-git-send-email-chenhui.zhao@freescale.com \
--to=chenhui.zhao@freescale.com \
--cc=leoli@freescale.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®