Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 51A31C433F5 for ; Wed, 23 Feb 2022 02:32:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VaaxrcsHXfwz/HNegH+8Y4jbYAI9O/A+ursu3RKf8O0=; b=g/Yk+CrdfQjry0 tOVTqfe8H6aSl5+YmNILW2PBBcblFyTVpGIPshWHCkyxemZRhz7aHeLl5+Y0BYjgPwGT4d2AyLMpb FakDib9UJRuXOSAJr3MmevsPIQaFTlE+q6qg7vC+7dw8yxrJFxA8f3nJ+5m3jLth1Rdw+xCAt9dWz UTBdT+C4GVUmcFQL6x1vHcuIXpFjirCtukBk921/v5xhIsjdiW/pya3fTV9fX3QiR9B8tJQ6Ovk1E efa7rPF08DDxJs3QQDWz3I3VmkPkhdPzwZAU4OCPpa+T46fcg6ue86uCNFyy367zN1jBwiV4j+3QF Z0B6j3d6dzlQH3jfg9vA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMhR1-00CJV6-W4; Wed, 23 Feb 2022 02:31:20 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMhQS-00CJCx-Ds; Wed, 23 Feb 2022 02:30:46 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 023BA614FF; Wed, 23 Feb 2022 02:30:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF483C340E8; Wed, 23 Feb 2022 02:30:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645583443; bh=YfYYgfEG/tUw+RF/Z5+2ChlPUubhZWSVdHx6WExWyhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d7oObSqrIjl7fXz2E5VKK7yeum1x4eYK+XN9jX9QG2Q9l7w5Ci/Arx4TcH2kpqjUM AsfC3kstNyr/XUVVAk5YWDm4mXPAKPFWJiACurabvD9gtykSLUqIy1n9mmzvoDIeue XpumZtBwAHSifoybFXm1hNUubtAydMqIoaOWHQk4g0LFNPxZJLvEMzjMWD4S9/EZW+ didumffsTCdAJ5P4voqe+BuIKHFqT4aqIMk//fUBGzHOoqg7RKN8luV2AJDQ8Q6KZz fwc5EmwMpGWQwRowGSLgZgvwvCWe+Uq0ReKv3+c6WeZtS14TVj4n6j/OKJ4ufBaJ1t Cgh4Eofpreajg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Eric Anholt , Stefan Wahren , Wolfram Sang , Sasha Levin , f.fainelli@gmail.com, rjui@broadcom.com, sbranden@broadcom.com, bcm-kernel-feedback-list@broadcom.com, nsaenz@kernel.org, prabhakar.mahadev-lad.rj@bp.renesas.com, linux-i2c@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.10 03/18] i2c: bcm2835: Avoid clock stretching timeouts Date: Tue, 22 Feb 2022 21:30:20 -0500 Message-Id: <20220223023035.241551-3-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220223023035.241551-1-sashal@kernel.org> References: <20220223023035.241551-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220222_183044_515434_0B856FC1 X-CRM114-Status: GOOD ( 13.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Eric Anholt [ Upstream commit 9495b9b31abe525ebd93da58de2c88b9f66d3a0e ] 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 BugLink: https://github.com/raspberrypi/linux/issues/3064 Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- 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 37443edbf7546..ad3b124a2e376 100644 --- a/drivers/i2c/busses/i2c-bcm2835.c +++ b/drivers/i2c/busses/i2c-bcm2835.c @@ -23,6 +23,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) @@ -477,6 +482,12 @@ static int bcm2835_i2c_probe(struct platform_device *pdev) adap->dev.of_node = pdev->dev.of_node; adap->quirks = of_device_get_match_data(&pdev->dev); + /* + * 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); -- 2.34.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel