aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Anderson <dianders@chromium.org>2016-08-29 17:22:36 -0400
committerWolfram Sang <wsa@the-dreams.de>2016-09-08 16:50:33 -0400
commitcbfff439c54f37fc363b1d365183fa61af43585c (patch)
treebce37b2dd8c72755fd23bcd7a14c4106c9dbf8ff
parente0603c8dd298171bd64227c65c6bbd6a861e1a78 (diff)
i2c: rk3x: Restore clock settings at resume time
Depending on a number of factors including: - Which exact Rockchip SoC we're working with - How deep we suspend - Which i2c port we're on We might lose the state of the i2c registers at suspend time. Specifically we've found that on rk3399 the i2c ports that are not in the PMU power domain lose their state with the current suspend depth configured by ARM Tursted Firmware. Note that there are very few actual i2c registers that aren't configured per transfer anyway so all we actually need to re-configure are the clock config registers. We'll just add a call to rk3x_i2c_adapt_div() at resume time and be done with it. NOTE: On rk3399 on ports whose power was lost, I put printouts in at resume time. I saw things like: before: con=0x00010300, div=0x00060006 after: con=0x00010200, div=0x00180025 Signed-off-by: Douglas Anderson <dianders@chromium.org> Reviewed-by: David Wu <david.wu@rock-chips.com> Tested-by: David Wu <david.wu@rock-chips.com> [wsa: removed duplicate const] Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r--drivers/i2c/busses/i2c-rk3x.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c
index dce1abd43c7f..5c5b7cada8be 100644
--- a/drivers/i2c/busses/i2c-rk3x.c
+++ b/drivers/i2c/busses/i2c-rk3x.c
@@ -1111,6 +1111,15 @@ static int rk3x_i2c_xfer(struct i2c_adapter *adap,
1111 return ret < 0 ? ret : num; 1111 return ret < 0 ? ret : num;
1112} 1112}
1113 1113
1114static __maybe_unused int rk3x_i2c_resume(struct device *dev)
1115{
1116 struct rk3x_i2c *i2c = dev_get_drvdata(dev);
1117
1118 rk3x_i2c_adapt_div(i2c, clk_get_rate(i2c->clk));
1119
1120 return 0;
1121}
1122
1114static u32 rk3x_i2c_func(struct i2c_adapter *adap) 1123static u32 rk3x_i2c_func(struct i2c_adapter *adap)
1115{ 1124{
1116 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_PROTOCOL_MANGLING; 1125 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_PROTOCOL_MANGLING;
@@ -1334,12 +1343,15 @@ static int rk3x_i2c_remove(struct platform_device *pdev)
1334 return 0; 1343 return 0;
1335} 1344}
1336 1345
1346static SIMPLE_DEV_PM_OPS(rk3x_i2c_pm_ops, NULL, rk3x_i2c_resume);
1347
1337static struct platform_driver rk3x_i2c_driver = { 1348static struct platform_driver rk3x_i2c_driver = {
1338 .probe = rk3x_i2c_probe, 1349 .probe = rk3x_i2c_probe,
1339 .remove = rk3x_i2c_remove, 1350 .remove = rk3x_i2c_remove,
1340 .driver = { 1351 .driver = {
1341 .name = "rk3x-i2c", 1352 .name = "rk3x-i2c",
1342 .of_match_table = rk3x_i2c_match, 1353 .of_match_table = rk3x_i2c_match,
1354 .pm = &rk3x_i2c_pm_ops,
1343 }, 1355 },
1344}; 1356};
1345 1357