From patchwork Fri Jun 15 05:17:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 10465707 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D823060348 for ; Fri, 15 Jun 2018 05:17:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAAE028B09 for ; Fri, 15 Jun 2018 05:17:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF44228CA6; Fri, 15 Jun 2018 05:17:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23C4828B09 for ; Fri, 15 Jun 2018 05:17:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755294AbeFOFRs (ORCPT ); Fri, 15 Jun 2018 01:17:48 -0400 Received: from sauhun.de ([88.99.104.3]:55344 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754165AbeFOFRs (ORCPT ); Fri, 15 Jun 2018 01:17:48 -0400 Received: from localhost (softbank126012118084.bbtec.net [126.12.118.84]) by pokefinder.org (Postfix) with ESMTPSA id 58B5254006A; Fri, 15 Jun 2018 07:17:44 +0200 (CEST) From: Wolfram Sang To: linux-i2c@vger.kernel.org, cerg2010cerg2010@mail.ru Cc: linux-renesas-soc@vger.kernel.org, dri-devel@lists.freedesktop.org, Wolfram Sang Subject: [RFT] i2c: algos: bit: prepare/unprepare before sending initial STOP Date: Fri, 15 Jun 2018 14:17:23 +0900 Message-Id: <20180615051723.7193-1-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.11.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some adapters need to be prepared/unprepared before bitbanging the bus. Do this for the initial STOP, too. Signed-off-by: Wolfram Sang --- Ok, another idea to fix the regression. I'm not 100% sure if the placement is perfect, but it should serve well enough as a proof of concept to see if this is the actual issue. It looks promising, though. drivers/i2c/algos/i2c-algo-bit.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c index 4a34f311e1ff..fab4437ecbb5 100644 --- a/drivers/i2c/algos/i2c-algo-bit.c +++ b/drivers/i2c/algos/i2c-algo-bit.c @@ -648,10 +648,19 @@ static int __i2c_bit_add_bus(struct i2c_adapter *adap, adap->quirks = &i2c_bit_quirk_no_clk_stretch; /* Bring bus to a known state. Looks like STOP if bus is not free yet */ + if (bit_adap->pre_xfer) { + ret = bit_adap->pre_xfer(adap); + if (ret < 0) + return ret; + } + setscl(bit_adap, 1); udelay(bit_adap->udelay); setsda(bit_adap, 1); + if (bit_adap->post_xfer) + bit_adap->post_xfer(adap); + ret = add_adapter(adap); if (ret < 0) return ret;