From patchwork Fri Feb 23 21:42:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 10239897 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 4554760225 for ; Fri, 23 Feb 2018 21:45:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FD97299F6 for ; Fri, 23 Feb 2018 21:45:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 229C1299F8; Fri, 23 Feb 2018 21:45:35 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 83CD4299F6 for ; Fri, 23 Feb 2018 21:45:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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:In-Reply-To: References:List-Owner; bh=aojnPd+Wfw4ZifsnvYunw8GSggBKVBR16n7kYQ7GZfQ=; b=eaI bg8vR5vF4P7vQnUgydkfi8gpzwF5ZIP79s+yu4GEgGlhhvv6OfOmdmBmkqkuLb1AbwIrWxkPgtKNo jPB0KQrhNVh8SkHUwYQ8J4DKJ4ujnpZdvryfvaTsw7gB0so5m8tJLdXaQp/j5dxKa+IePa9fJd3Bk 5OWlqdo/snrOVu5gH/3GaTvFHSw21Xuv8dGiWEZAvuXiQyS7E/CZh+pS30WFZAdp+UNjk3Hu3rIIj m/htjRov6ZmbJpX4qkIzOqJe6FSfm29t2z+vlA/oVdszHXY0zvamQf3DhVmT6jLU0fckWoG4xWYM4 uqSMD0cSkAfc+/guYVj8slRDGQhfj7w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1epL9h-0000s3-TJ; Fri, 23 Feb 2018 21:45:25 +0000 Received: from mout.kundenserver.de ([212.227.126.135]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1epL9Z-00088z-IX; Fri, 23 Feb 2018 21:45:19 +0000 Received: from localhost.localdomain ([95.90.209.156]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.167]) with ESMTPSA (Nemesis) id 0M53tq-1eX8Ks1rnq-00zJTp; Fri, 23 Feb 2018 22:44:56 +0100 From: Stefan Wahren To: Wolfram Sang , Eric Anholt Subject: [PATCH] i2c: bcm2835: Avoid clock stretching timeouts Date: Fri, 23 Feb 2018 22:42:31 +0100 Message-Id: <1519422151-6218-1-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 2.7.4 X-Provags-ID: V03:K0:3RJLbDksd1i3pH/LKF/P7GiuYUSDsWW9M1g7vZDdsfpOsb03EY9 N8/n81TMWwgB9XOkoB5ytbUlbThCLDBOR96m5x68VbpjSMV0rT+gTvi9AbzF5kYj1u6TMq4 HFC0+djmwjAN/1yBR7vjZxJEg0wvKRG7QqCySm7Z76/9jT+oZ434wBz0WK//REcJ6KsXv9A bkwvx+h56M2bkjJ2gjhrw== X-UI-Out-Filterresults: notjunk:1; V01:K0:+KBCSvHI0cs=:tdK+ktpLvaCMijcyQEJq7l sDGAM83LdOyyc4c0qhb1vVa3K94f4fEtyiF5aoZj+sIuCsIvZPlZnK44VZrT/vLBWD/Powa5I nXX7yyQXEyLaDgVUe58pyz0T/5wXGyfGrWv7mJV3Sh8BqwC1MfXT/25IjYhCfSvVsMBCYlqxI 0bOKwXCyiBNHPfL/+RMi+iFXCA67LW5GgW7UVi1mY/OqzQKm0Vw9YsQIBFUtsPnPLwGW93/gK 8v+X3blx7kyxCs953MuCT9SPxAwvg+ASjF/4ZVAjXCwILtSBuFApIYtXs5Lf4y2vRGPb4nSm9 /MH6EAaKEL2Duv/OZDuxIi7AW45aJzFpvhtFN173GF9sNOOiT4d4f5HySFMPCxxyImBjgtZxq RvbYV9uMMqU7QqV5YOgfszfoWgkZ4VQ2pgqUXwYGY/Sn12BPaCY3Vof9GFSJlwzgcSGTFYppQ IWAIgL+XC6Rt4bL0PxAco7DH5F5X2jE5k/MKP6pwKVi0n324WCiPoXLm/vIMLRkuuWpIjT3Bt pRQaNlmll8X/H3GyLYiEhalvkEdMs0MqECYOJoc9dnzf+60y6VC+NCyn8fnOrVk0MIEVb8FEo DU1pEbHXClXyB2P4vDDBd8gQzRyfbflH1oxTUq/XI1qllFoqn//n/9fzqAOYSmE00aEa/x/A6 ARXv3Kum0RAs4wDV0FiLYCNpKw3IEVtHgYN2Y3d+EnBzzcBKO3mH3O/JFybDLS5Usc+BEgr6i Si+itEXlch5m1R/rX+qdHVWGZlV8IzCTV6Mu2mWQAYlurlK8GkznLZjxw5k= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180223_134517_928536_26EC5264 X-CRM114-Status: GOOD ( 10.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Wahren , =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= , linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rpi-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Anholt The CLKT register contains at poweron 0x40, which at our typical 100kHz bus rate means .64ms. But there is no specified limit to how long devices should be able to stretch the clocks, so just disable the timeout. We still have a timeout wrapping the entire transfer. Signed-off-by: Eric Anholt Signed-off-by: Stefan Wahren --- Hi, just like "i2c: bcm2835: Set up the rising/falling edge delays" this is a outstanding bugfix. Unfortunately i only have I2C slaves, which doesn't stretch the clock. So test feedback is very welcome. drivers/i2c/busses/i2c-bcm2835.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c index 44deae7..ccd2565 100644 --- a/drivers/i2c/busses/i2c-bcm2835.c +++ b/drivers/i2c/busses/i2c-bcm2835.c @@ -28,6 +28,11 @@ #define BCM2835_I2C_FIFO 0x10 #define BCM2835_I2C_DIV 0x14 #define BCM2835_I2C_DEL 0x18 +/* + * 16-bit field for the number of SCL cycles to wait after rising SCL + * before deciding the slave is not responding. 0 disables the + * timeout detection. + */ #define BCM2835_I2C_CLKT 0x1c #define BCM2835_I2C_C_READ BIT(0) @@ -386,6 +391,12 @@ static int bcm2835_i2c_probe(struct platform_device *pdev) adap->dev.of_node = pdev->dev.of_node; adap->quirks = &bcm2835_i2c_quirks; + /* + * Disable the hardware clock stretching timeout. SMBUS + * specifies a limit for how long the device can stretch the + * clock, but core I2C doesn't. + */ + bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_CLKT, 0); bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, 0); ret = i2c_add_adapter(adap);