From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761021AbcIACKR (ORCPT ); Wed, 31 Aug 2016 22:10:17 -0400 Received: from lucky1.263xmail.com ([211.157.147.132]:60936 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753885AbcIACKQ (ORCPT ); Wed, 31 Aug 2016 22:10:16 -0400 X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 X-RL-SENDER: david.wu@rock-chips.com X-FST-TO: linux-kernel@vger.kernel.org X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: david.wu@rock-chips.com X-UNIQUE-TAG: <6eb9555ce27adee38e69a3c0ea45ceb0> X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 Subject: Re: [PATCH] i2c: rk3x: Restore clock settings at resume time To: Douglas Anderson , wsa@the-dreams.de, heiko@sntech.de References: <1472505756-8302-1-git-send-email-dianders@chromium.org> Cc: linux-rockchip@lists.infradead.org, wxt@rock-chips.com, linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org From: "David.Wu" Message-ID: <19e4d0bf-28c9-0f10-fac9-c05d1e69d510@rock-chips.com> Date: Thu, 1 Sep 2016 10:10:08 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <1472505756-8302-1-git-send-email-dianders@chromium.org> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Doug, Last replied email HTML HEAD error, resend it. ÔÚ 2016/8/30 5:22, Douglas Anderson дµÀ: > 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 > I do the suspend/resume stress test on my rk3399 & rk3288 board more than 24 hours, the patch works well, it looks nice to me. Reviewed-by: David Wu Tested-by: David Wu > Signed-off-by: Douglas Anderson > --- > Tested on chromeos-4.4 kernel with backports. > > drivers/i2c/busses/i2c-rk3x.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c > index 3b87afe82f63..0df5ad6bfa31 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, > return ret < 0 ? ret : num; > } > > +static __maybe_unused int rk3x_i2c_resume(struct device *dev) > +{ > + struct rk3x_i2c *i2c = dev_get_drvdata(dev); > + > + rk3x_i2c_adapt_div(i2c, clk_get_rate(i2c->clk)); > + > + return 0; > +} > + > static u32 rk3x_i2c_func(struct i2c_adapter *adap) > { > return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_PROTOCOL_MANGLING; > @@ -1332,12 +1341,15 @@ static int rk3x_i2c_remove(struct platform_device *pdev) > return 0; > } > > +static const SIMPLE_DEV_PM_OPS(rk3x_i2c_pm_ops, NULL, rk3x_i2c_resume); > + > static struct platform_driver rk3x_i2c_driver = { > .probe = rk3x_i2c_probe, > .remove = rk3x_i2c_remove, > .driver = { > .name = "rk3x-i2c", > .of_match_table = rk3x_i2c_match, > + .pm = &rk3x_i2c_pm_ops, > }, > }; > >