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: 10465805 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 C6E52603B4 for ; Fri, 15 Jun 2018 06:58:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB9A228892 for ; Fri, 15 Jun 2018 06:58:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B05A3288EE; Fri, 15 Jun 2018 06:58:33 +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=-5.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B878B28892 for ; Fri, 15 Jun 2018 06:58:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 759CB6EAB9; Fri, 15 Jun 2018 06:57:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 368 seconds by postgrey-1.36 at gabe; Fri, 15 Jun 2018 05:23:56 UTC Received: from pokefinder.org (sauhun.de [88.99.104.3]) by gabe.freedesktop.org (Postfix) with ESMTP id 95CB96E97D for ; Fri, 15 Jun 2018 05:23:56 +0000 (UTC) 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 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 X-Mailman-Approved-At: Fri, 15 Jun 2018 06:57:41 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-renesas-soc@vger.kernel.org, Wolfram Sang , dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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;