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: 877315 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zp4X26kBZz9sWD for ; Sat, 24 Feb 2018 08:45:22 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752342AbeBWVpV (ORCPT ); Fri, 23 Feb 2018 16:45:21 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:54665 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752215AbeBWVpU (ORCPT ); Fri, 23 Feb 2018 16:45:20 -0500 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 Cc: =?utf-8?q?Noralf_Tr=C3=B8nnes?= , linux-i2c@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Stefan Wahren 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= Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org 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);