From patchwork Sun Apr 24 21:10:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 8921801 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 936379F1C1 for ; Sun, 24 Apr 2016 21:12:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C300A201C7 for ; Sun, 24 Apr 2016 21:12:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DEC4B20103 for ; Sun, 24 Apr 2016 21:12:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1auRJA-0001q7-2D; Sun, 24 Apr 2016 21:11:12 +0000 Received: from sauhun.de ([89.238.76.85] helo=pokefinder.org) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1auRJ7-0001oC-Op for linux-arm-kernel@lists.infradead.org; Sun, 24 Apr 2016 21:11:10 +0000 Received: from p4fe25a3b.dip0.t-ipconnect.de ([79.226.90.59]:33900 helo=katana) by pokefinder.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1auRIk-0001iI-2x; Sun, 24 Apr 2016 23:10:46 +0200 Date: Sun, 24 Apr 2016 23:10:44 +0200 From: Wolfram Sang To: Peter Griffin Subject: Re: [PATCH] i2c: st: Implement i2c_bus_recovery_info callbacks Message-ID: <20160424211044.GD4317@katana> References: <1460467759-11737-1-git-send-email-peter.griffin@linaro.org> MIME-Version: 1.0 In-Reply-To: <1460467759-11737-1-git-send-email-peter.griffin@linaro.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160424_141109_996659_D851D324 X-CRM114-Status: GOOD ( 13.69 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Frederic Pillon , srinivas.kandagatla@gmail.com, patrice.chotard@st.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, lee.jones@linaro.org, linux-arm-kernel@lists.infradead.org, maxime.coquelin@st.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP > +/* > + * i2c bus recovery routines > + * get_scl and set_scl must be defined to avoid the recover_bus field of > + * i2c_bus_recovery_info to be overriden with NULL during the > + * i2c_add_adapter call > + */ Oh, that shouldn't be like this. Can you try this patch and remove the empty functions please? > +static int st_i2c_recover_bus(struct i2c_adapter *i2c_adap) > +{ Can you describe what the function does? It is not clear to me that it generates 9 scl pulses. > + struct st_i2c_dev *i2c_dev = i2c_get_adapdata(i2c_adap); > + u32 ctl; > + > + dev_err(i2c_dev->dev, "Trying to recover bus\n"); This is not an error. Either dev_dbg or drop it, I'd say. > + > + /* Disable interrupts */ > + writel_relaxed(0, i2c_dev->base + SSC_IEN); > + > + st_i2c_hw_config(i2c_dev); > + > + ctl = SSC_CTL_EN | SSC_CTL_MS | SSC_CTL_EN_RX_FIFO | SSC_CTL_EN_TX_FIFO; > + st_i2c_set_bits(i2c_dev->base + SSC_CTL, ctl); > + > + st_i2c_clr_bits(i2c_dev->base + SSC_I2C, SSC_I2C_I2CM); > + usleep_range(8000, 10000); > + > + writel_relaxed(0, i2c_dev->base + SSC_TBUF); > + usleep_range(2000, 4000); > + st_i2c_set_bits(i2c_dev->base + SSC_I2C, SSC_I2C_I2CM); > + > + return 0; > +} Thanks, Wolfram diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 4979728f7fb2de..604936955807e5 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -1595,10 +1595,12 @@ static int i2c_register_adapter(struct i2c_adapter *adap) bri->get_scl = get_scl_gpio_value; bri->set_scl = set_scl_gpio_value; - } else if (!bri->set_scl || !bri->get_scl) { + } else if (bri->recover_bus == i2c_generic_scl_recovery) { /* Generic SCL recovery */ - dev_err(&adap->dev, "No {get|set}_gpio() found, not using recovery\n"); - adap->bus_recovery_info = NULL; + if (!bri->set_scl || !bri->get_scl) { + dev_err(&adap->dev, "No {get|set}_scl() found, not using recovery\n"); + adap->bus_recovery_info = NULL; + } } }