From patchwork Wed Oct 7 08:45:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christian Eggers X-Patchwork-Id: 11820199 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BABB26CB for ; Wed, 7 Oct 2020 08:48:05 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7EFBE21D7A for ; Wed, 7 Oct 2020 08:48:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="2xv4WawJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7EFBE21D7A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arri.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=eZ9WLCMOay2+kOann9FVJhm4dMLKng2qTq5FjNF05t4=; b=2xv4WawJMNLtVjGfaGMzm5jhR weOzb21vhx5pU8pAFd2LiJgydJK09jshth7ABOt9b3L2KCO/bMf6ko1UDKc1uIVsT6or7qRhqhh1c Ch81Ntt+u9V9eQlo+Y66jHiDPzFxrng3sH9e/KVKeVIoL/D7Yc7mcn8Lyn2b7xM7okxvE1JA6LCbo ZxCkg6Y8beKfn9EZH1VGH1a7VD/4amZMd5qmK4a0ziJGHewFiaD7nXfR6AuaxFg7VNyysMWCF2t2n snQlecwkfZ/5avLl7a041cN3UiJFFJ6/e6lWsDyLF/OSLZeBZvzYbdrAh8MaGiiXn4BBM9UGKFwfW T856+CVNQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQ573-0007Wo-0v; Wed, 07 Oct 2020 08:47:53 +0000 Received: from mailout07.rmx.de ([94.199.90.95]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQ56z-0007Vs-Nw for linux-arm-kernel@lists.infradead.org; Wed, 07 Oct 2020 08:47:50 +0000 Received: from kdin02.retarus.com (kdin02.dmz1.retloc [172.19.17.49]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailout07.rmx.de (Postfix) with ESMTPS id 4C5nz56dJWzBvZd; Wed, 7 Oct 2020 10:47:45 +0200 (CEST) Received: from mta.arri.de (unknown [217.111.95.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by kdin02.retarus.com (Postfix) with ESMTPS id 4C5nxy6PCwz2TTLm; Wed, 7 Oct 2020 10:46:46 +0200 (CEST) Received: from N95HX1G2.wgnetz.xx (192.168.54.119) by mta.arri.de (192.168.100.104) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 7 Oct 2020 10:46:21 +0200 From: Christian Eggers To: Oleksij Rempel , Shawn Guo , Sascha Hauer , Fabio Estevam , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , "David Laight" Subject: [PATCH v5 1/3] i2c: imx: Fix reset of I2SR_IAL flag Date: Wed, 7 Oct 2020 10:45:22 +0200 Message-ID: <20201007084524.10835-2-ceggers@arri.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201007084524.10835-1-ceggers@arri.de> References: <20201007084524.10835-1-ceggers@arri.de> MIME-Version: 1.0 X-Originating-IP: [192.168.54.119] X-RMX-ID: 20201007-104650-4C5nxy6PCwz2TTLm-0@kdin02 X-RMX-SOURCE: 217.111.95.66 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201007_044750_060803_C6C6A770 X-CRM114-Status: GOOD ( 17.37 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [94.199.90.95 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [94.199.90.95 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, Krzysztof Kozlowski , NXP Linux Team , Pengutronix Kernel Team , stable@vger.kernel.org, Christian Eggers , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org According to the "VFxxx Controller Reference Manual" (and the comment block starting at line 97), Vybrid requires writing a one for clearing an interrupt flag. Syncing the method for clearing I2SR_IIF in i2c_imx_isr(). Signed-off-by: Christian Eggers Fixes: 4b775022f6fd ("i2c: imx: add struct to hold more configurable quirks") Reviewed-by: Uwe Kleine-König Cc: stable@vger.kernel.org Acked-by: Oleksij Rempel --- drivers/i2c/busses/i2c-imx.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 0ab5381aa012..cbdcab73a055 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -412,6 +412,19 @@ static void i2c_imx_dma_free(struct imx_i2c_struct *i2c_imx) dma->chan_using = NULL; } +static void i2c_imx_clear_irq(struct imx_i2c_struct *i2c_imx, unsigned int bits) +{ + unsigned int temp; + + /* + * i2sr_clr_opcode is the value to clear all interrupts. Here we want to + * clear only , so we write ~i2sr_clr_opcode with just + * toggled. This is required because i.MX needs W1C and Vybrid uses W0C. + */ + temp = ~i2c_imx->hwdata->i2sr_clr_opcode ^ bits; + imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2SR); +} + static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy, bool atomic) { unsigned long orig_jiffies = jiffies; @@ -424,8 +437,7 @@ static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy, bool a /* check for arbitration lost */ if (temp & I2SR_IAL) { - temp &= ~I2SR_IAL; - imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2SR); + i2c_imx_clear_irq(i2c_imx, I2SR_IAL); return -EAGAIN; } @@ -623,9 +635,7 @@ static irqreturn_t i2c_imx_isr(int irq, void *dev_id) if (temp & I2SR_IIF) { /* save status register */ i2c_imx->i2csr = temp; - temp &= ~I2SR_IIF; - temp |= (i2c_imx->hwdata->i2sr_clr_opcode & I2SR_IIF); - imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2SR); + i2c_imx_clear_irq(i2c_imx, I2SR_IIF); wake_up(&i2c_imx->queue); return IRQ_HANDLED; } From patchwork Wed Oct 7 08:45:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Eggers X-Patchwork-Id: 11820201 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0721D6CB for ; Wed, 7 Oct 2020 08:49:02 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BBD1B21D7A for ; Wed, 7 Oct 2020 08:49:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="TMYpG/T6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BBD1B21D7A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arri.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=61g6Ap70Lp/IOkAp/EZldb2cVpSn8ypmdlUkQmIKTkU=; b=TMYpG/T60DE6kks74pGLCFhSW k4M0b4zNNPxc8L4UnjRIkCD249PBw8a5iEB6WjvCkpWk0dg2qtnkVpOmG2SqW6h5Evil2pSY9Hvh8 0Aj0ZBzkEC+YpxEnIm9WsDSDTxXQTpu0JmeCWpSELdgVZklH09+6amtyqyTeUGmyj++WlT1XB88X/ 9oiTamKZtUI77Dw/zhbk3rZ5BZiKRxpz9yy23oyrDHS0PSeSZq0mmgQW2juFJ2ApkDEhNUw+sHRez tBjHmJCU6CU05DH5LwODsFOkqkutdbB8vt+azpIsyEi4kkAy4HVaz4wJipPdXuoBvlq1IKIRBcanJ jOAEyXLlg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQ57w-0007gh-Qz; Wed, 07 Oct 2020 08:48:48 +0000 Received: from mailout01.rmx.de ([94.199.90.91]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQ57s-0007ej-Nz for linux-arm-kernel@lists.infradead.org; Wed, 07 Oct 2020 08:48:45 +0000 Received: from kdin02.retarus.com (kdin02.dmz1.retloc [172.19.17.49]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailout01.rmx.de (Postfix) with ESMTPS id 4C5p065Bzjz2SV5X; Wed, 7 Oct 2020 10:48:38 +0200 (CEST) Received: from mta.arri.de (unknown [217.111.95.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by kdin02.retarus.com (Postfix) with ESMTPS id 4C5nz56Zb1z2TTLV; Wed, 7 Oct 2020 10:47:45 +0200 (CEST) Received: from N95HX1G2.wgnetz.xx (192.168.54.119) by mta.arri.de (192.168.100.104) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 7 Oct 2020 10:46:56 +0200 From: Christian Eggers To: Oleksij Rempel , Shawn Guo , Sascha Hauer , Fabio Estevam , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , "David Laight" Subject: [PATCH v5 2/3] i2c: imx: Check for I2SR_IAL after every byte Date: Wed, 7 Oct 2020 10:45:23 +0200 Message-ID: <20201007084524.10835-3-ceggers@arri.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201007084524.10835-1-ceggers@arri.de> References: <20201007084524.10835-1-ceggers@arri.de> MIME-Version: 1.0 X-Originating-IP: [192.168.54.119] X-RMX-ID: 20201007-104745-4C5nz56Zb1z2TTLV-0@kdin02 X-RMX-SOURCE: 217.111.95.66 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201007_044844_910165_13B97E4B X-CRM114-Status: GOOD ( 14.84 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [94.199.90.91 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [94.199.90.91 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, Krzysztof Kozlowski , NXP Linux Team , Pengutronix Kernel Team , stable@vger.kernel.org, Christian Eggers , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Arbitration Lost (IAL) can happen after every single byte transfer. If arbitration is lost, the I2C hardware will autonomously switch from master mode to slave. If a transfer is not aborted in this state, consecutive transfers will not be executed by the hardware and will timeout. Signed-off-by: Christian Eggers Tested (not extensively) on Vybrid VF500 (Toradex VF50): Tested-by: Krzysztof Kozlowski Cc: stable@vger.kernel.org Acked-by: Oleksij Rempel --- drivers/i2c/busses/i2c-imx.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index cbdcab73a055..63575af41c09 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -490,6 +490,16 @@ static int i2c_imx_trx_complete(struct imx_i2c_struct *i2c_imx, bool atomic) dev_dbg(&i2c_imx->adapter.dev, "<%s> Timeout\n", __func__); return -ETIMEDOUT; } + + /* check for arbitration lost */ + if (i2c_imx->i2csr & I2SR_IAL) { + dev_dbg(&i2c_imx->adapter.dev, "<%s> Arbitration lost\n", __func__); + i2c_imx_clear_irq(i2c_imx, I2SR_IAL); + + i2c_imx->i2csr = 0; + return -EAGAIN; + } + dev_dbg(&i2c_imx->adapter.dev, "<%s> TRX complete\n", __func__); i2c_imx->i2csr = 0; return 0; From patchwork Wed Oct 7 08:45:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Eggers X-Patchwork-Id: 11820209 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DAE3E6CB for ; Wed, 7 Oct 2020 08:51:35 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7EB1821D7A for ; Wed, 7 Oct 2020 08:51:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="04dlpl4I" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7EB1821D7A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arri.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zv/C00QDcsEgnEv2qAWQwgsjqOCJQgBhzFTOvhR7IGg=; b=04dlpl4Ia+SsII2DlZWWIroIS 0VxjjHid6gXySPHIwMpZz7o+kx2qsQCYA9FOK9QTte7SLD9yQNkvSCP+oguvh3L+OKRxbsdifkfum XMIcv4lmQwEnLrR0VHm5f6vD2Q+n2swJZvrsDuuekfehvsqEab+/BQHV/3tMKlfFg/SfMcchFvNm+ 6qEQMOpn0bJ0opemlCNbHRy0/O6QfdwCNY1/6ayol5FblGEJ0/Dp6a8ZHDYne0jhgKmAIGSa2iWR6 /749c43MZhi2c2Jq7prVXVczWqp0eaCPPpC7sojyk5YtTlgHupl4q94dHJjSp2U5pJ7NRn67awcia 2Wvm2DPtw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQ59H-00089x-Ex; Wed, 07 Oct 2020 08:50:11 +0000 Received: from mailout04.rmx.de ([94.199.90.94]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQ59D-00087c-8p for linux-arm-kernel@lists.infradead.org; Wed, 07 Oct 2020 08:50:09 +0000 Received: from kdin02.retarus.com (kdin02.dmz1.retloc [172.19.17.49]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailout04.rmx.de (Postfix) with ESMTPS id 4C5p1l2LB5z3qxQ3; Wed, 7 Oct 2020 10:50:03 +0200 (CEST) Received: from mta.arri.de (unknown [217.111.95.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by kdin02.retarus.com (Postfix) with ESMTPS id 4C5p0k3gQCz2TTL4; Wed, 7 Oct 2020 10:49:10 +0200 (CEST) Received: from N95HX1G2.wgnetz.xx (192.168.54.119) by mta.arri.de (192.168.100.104) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 7 Oct 2020 10:47:26 +0200 From: Christian Eggers To: Oleksij Rempel , Shawn Guo , Sascha Hauer , Fabio Estevam , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , "David Laight" Subject: [PATCH v5 3/3] i2c: imx: Don't generate STOP condition if arbitration has been lost Date: Wed, 7 Oct 2020 10:45:24 +0200 Message-ID: <20201007084524.10835-4-ceggers@arri.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201007084524.10835-1-ceggers@arri.de> References: <20201007084524.10835-1-ceggers@arri.de> MIME-Version: 1.0 X-Originating-IP: [192.168.54.119] X-RMX-ID: 20201007-104916-4C5p0k3gQCz2TTL4-0@kdin02 X-RMX-SOURCE: 217.111.95.66 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201007_045007_592606_22CABF08 X-CRM114-Status: GOOD ( 15.45 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [94.199.90.94 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [94.199.90.94 listed in wl.mailspike.net] 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, Krzysztof Kozlowski , NXP Linux Team , Pengutronix Kernel Team , stable@vger.kernel.org, Christian Eggers , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org If arbitration is lost, the master automatically changes to slave mode. I2SR_IBB may or may not be reset by hardware. Raising a STOP condition by resetting I2CR_MSTA has no effect and will not clear I2SR_IBB. So calling i2c_imx_bus_busy() is not required and would busy-wait until timeout. Signed-off-by: Christian Eggers Tested (not extensively) on Vybrid VF500 (Toradex VF50): Tested-by: Krzysztof Kozlowski Cc: stable@vger.kernel.org # Requires trivial backporting, simple remove # the 3rd argument from the calls to # i2c_imx_bus_busy(). Acked-by: Oleksij Rempel --- drivers/i2c/busses/i2c-imx.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 63575af41c09..5d8a79319b2b 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -615,6 +615,8 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx, bool atomic) /* Stop I2C transaction */ dev_dbg(&i2c_imx->adapter.dev, "<%s>\n", __func__); temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR); + if (!(temp & I2CR_MSTA)) + i2c_imx->stopped = 1; temp &= ~(I2CR_MSTA | I2CR_MTX); if (i2c_imx->dma) temp &= ~I2CR_DMAEN; @@ -778,9 +780,12 @@ static int i2c_imx_dma_read(struct imx_i2c_struct *i2c_imx, */ dev_dbg(dev, "<%s> clear MSTA\n", __func__); temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR); + if (!(temp & I2CR_MSTA)) + i2c_imx->stopped = 1; temp &= ~(I2CR_MSTA | I2CR_MTX); imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR); - i2c_imx_bus_busy(i2c_imx, 0, false); + if (!i2c_imx->stopped) + i2c_imx_bus_busy(i2c_imx, 0, false); } else { /* * For i2c master receiver repeat restart operation like: @@ -905,9 +910,12 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs, dev_dbg(&i2c_imx->adapter.dev, "<%s> clear MSTA\n", __func__); temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR); + if (!(temp & I2CR_MSTA)) + i2c_imx->stopped = 1; temp &= ~(I2CR_MSTA | I2CR_MTX); imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR); - i2c_imx_bus_busy(i2c_imx, 0, atomic); + if (!i2c_imx->stopped) + i2c_imx_bus_busy(i2c_imx, 0, atomic); } else { /* * For i2c master receiver repeat restart operation like: