From patchwork Tue Oct 6 16:08:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christian Eggers X-Patchwork-Id: 11818927 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 7C95959D for ; Tue, 6 Oct 2020 16:11:38 +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 3965E20760 for ; Tue, 6 Oct 2020 16:11:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hoQLnKEB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3965E20760 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=Y/nQ6tdmy+rcp/r75FR5YBGfhrD4hGaRhR+r+2ZZF/o=; b=hoQLnKEBDZcvkF5sPFR88aPT3 N5ggmA2kILDUMiafOX0ukfrIo9H8DMOTd2yj9g9Uex/caiuu32NflI6KV0bo/4siYFCwEzVVFcI0f dGK8RByL4ZXp7EbFnKdHofJ81a6AB1C3+44lXfxldEv2MPBhkSHXdNcRXX0s/8chFaeiCSPYElCcm mVLxwHZBBzikYifA4kuvngxiHmjcM/jpmY6judLQczi2i6b26iw6OzntD9uXKbfWp4T2AG81ZSu+W rBRDNx5NiKmHs6poXYhBRV/m1ohpFeZvxZYwOOseeWW9YPSJG3gBXdN6eFSUHTYRmQXi/w9ERbQJx iks8j1H7Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPpXS-0004Ou-Da; Tue, 06 Oct 2020 16:10:06 +0000 Received: from mailout11.rmx.de ([94.199.88.76]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPpXO-0004N2-OF for linux-arm-kernel@lists.infradead.org; Tue, 06 Oct 2020 16:10:05 +0000 Received: from kdin01.retarus.com (kdin01.dmz1.retloc [172.19.17.48]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailout11.rmx.de (Postfix) with ESMTPS id 4C5Mqn71bxz40dw; Tue, 6 Oct 2020 18:09:57 +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 kdin01.retarus.com (Postfix) with ESMTPS id 4C5Mpv1Grzz2xNp; Tue, 6 Oct 2020 18:09:11 +0200 (CEST) Received: from N95HX1G2.wgnetz.xx (192.168.54.45) by mta.arri.de (192.168.100.104) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 6 Oct 2020 18:08:58 +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 v4 1/3] i2c: imx: Fix reset of I2SR_IAL flag Date: Tue, 6 Oct 2020 18:08:12 +0200 Message-ID: <20201006160814.22047-2-ceggers@arri.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201006160814.22047-1-ceggers@arri.de> References: <20201006160814.22047-1-ceggers@arri.de> MIME-Version: 1.0 X-Originating-IP: [192.168.54.45] X-RMX-ID: 20201006-180911-4C5Mpv1Grzz2xNp-0@kdin01 X-RMX-SOURCE: 217.111.95.66 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201006_121003_021311_5EF93F79 X-CRM114-Status: GOOD ( 17.67 ) 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.88.76 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [94.199.88.76 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 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, stable@vger.kernel.org, NXP Linux Team , Pengutronix Kernel Team , 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 Cc: stable@vger.kernel.org Reviewed-by: Uwe Kleine-König --- 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; }