linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] i2c: rcar: reinit hardware on resume
@ 2017-04-17 18:32 Wolfram Sang
  2017-04-18  0:35 ` Kuninori Morimoto
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfram Sang @ 2017-04-17 18:32 UTC (permalink / raw)
  To: linux-i2c
  Cc: linux-renesas-soc, Kuninori Morimoto, Geert Uytterhoeven,
	Wolfram Sang

On resume, reinit hardware to ensure state machine and clock settings
are proper. This code assumes:

* bus clock is a fixed value, so no need to recalculate timings after probe
* handling RuntimePM is not needed, because register content is kept
  when disabling the IP core clock

Tested with r8a7796 (M3-W) and r8a7790 (H2).

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

@Geert: do you agree to my assumptions?

 drivers/i2c/busses/i2c-rcar.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 26f2ff22e97e55..7010c77df11daa 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -907,10 +907,27 @@ static int rcar_i2c_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int rcar_i2c_resume(struct device *dev)
+{
+	struct rcar_i2c_priv *priv = dev_get_drvdata(dev);
+
+	rcar_i2c_init(priv);
+
+	return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(rcar_i2c_pm, NULL, rcar_i2c_resume);
+#define RCAR_I2C_PM	(&rcar_i2c_pm)
+#else
+#define RCAR_I2C_PM	NULL
+#endif
+
 static struct platform_driver rcar_i2c_driver = {
 	.driver	= {
 		.name	= "i2c-rcar",
 		.of_match_table = rcar_i2c_dt_ids,
+		.pm	= RCAR_I2C_PM,
 	},
 	.probe		= rcar_i2c_probe,
 	.remove		= rcar_i2c_remove,
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-18  7:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-17 18:32 [RFC] i2c: rcar: reinit hardware on resume Wolfram Sang
2017-04-18  0:35 ` Kuninori Morimoto
2017-04-18  7:07   ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).