Skip to content

Commit cbfff43

Browse files
diandersWolfram Sang
authored andcommitted
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 <[email protected]> Reviewed-by: David Wu <[email protected]> Tested-by: David Wu <[email protected]> [wsa: removed duplicate const] Signed-off-by: Wolfram Sang <[email protected]>
1 parent e0603c8 commit cbfff43

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/i2c/busses/i2c-rk3x.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,15 @@ static int rk3x_i2c_xfer(struct i2c_adapter *adap,
11111111
return ret < 0 ? ret : num;
11121112
}
11131113

1114+
static __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+
11141123
static u32 rk3x_i2c_func(struct i2c_adapter *adap)
11151124
{
11161125
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)
13341343
return 0;
13351344
}
13361345

1346+
static SIMPLE_DEV_PM_OPS(rk3x_i2c_pm_ops, NULL, rk3x_i2c_resume);
1347+
13371348
static struct platform_driver rk3x_i2c_driver = {
13381349
.probe = rk3x_i2c_probe,
13391350
.remove = rk3x_i2c_remove,
13401351
.driver = {
13411352
.name = "rk3x-i2c",
13421353
.of_match_table = rk3x_i2c_match,
1354+
.pm = &rk3x_i2c_pm_ops,
13431355
},
13441356
};
13451357

0 commit comments

Comments
 (0)