UPSTREAM: i2c: rk3x: Restore clock settings at resume time
authorDoug Anderson <dianders@chromium.org>
Mon, 29 Aug 2016 21:22:36 +0000 (14:22 -0700)
committerHuang, Tao <huangtao@rock-chips.com>
Wed, 14 Sep 2016 10:55:54 +0000 (18:55 +0800)
commit5330549bfd5592b75e96606690dcc689a7634924
tree253aa5e0c380585a3f7164ab9b6dbb0c26d549e6
parent89f21aa60dc1b7732df8ada8a8649dd4f2da3598
UPSTREAM: 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

Change-Id: I9799a77b9f332ef6b72ca2a8c1ee348b470a4d53
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>
drivers/i2c/busses/i2c-rk3x.c