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 25300C433EF for ; Wed, 23 Feb 2022 02:33:42 +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=O0ZDViC22niYGBN5ob2kxhaxvzo1VPzC/efVNLFT8FQ=; b=KD9NqKiyLrGkmt Da1ody1CpGs+H/+r3eGE4BbYpLtKTLEpizyBONBLjGSZ7fWdj2nQLkiDIWpm2UjxGVf08RXa7i1F9 BnZ/Za5T64HPgevh6Gu7wWzQMuSgvE+fNaMKgNp9Rl+Ro7QUodNLPnNJ/fnA9TNwtztCEIqKm+mXz 7dFSYpDdcPJzP2KHRcq9xnQImaRWuJr7hnQ5B3xItR72kQhwHMWWmdMUs1ADbrqyr3T+Ff9kVnQJA eKIkANWRQ74qlLnZZ/6bhI80G9Hr2NxTNJLLw2LE+vYyWRwdTixl9g0ZjDcMxLh2NCN6iYoZ55rI4 iDXz26ewoKgRlD8fAQoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMhS4-00CK9e-Ri; Wed, 23 Feb 2022 02:32:25 +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 1nMhR9-00CJda-DG; Wed, 23 Feb 2022 02:31:31 +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 DDE1961516; Wed, 23 Feb 2022 02:31:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2C64C340E8; Wed, 23 Feb 2022 02:31:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645583486; bh=z6WtXkdplajcHr5U4+TEBsmCq0vuiEtw9uFAEm14z5M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XmvbvVuub4yJ0jyKrSgFG1zYMs8pKlpeZmxQhxu0NGkrts5eQyvn5jERm/CM17avC cMUp4OzfSHSHVxXwCzWpjZVl9ODiWF5Z6/neLd5oHctHhQfTWEyu+p3qz5CQZmwCtF CK3jI5DeP0bzRiORBeSp3e4wyIbyAgMARH1URdP9WzF7AGdl/NkAZ6sLCKl6zC7cJJ q8WQxSm97D+JKrtVgBPbWqUcMsSP49TIw4HqbEy/kiJcKwxUWlmtCQltHAiWhtsXKf WfM8JvDUSzA0WD2onZoep6CugHhc4JS6NxnVFJaN/8aFLAH2d2iR3uxAp1rHuk+bKf 5UcExefX8lmPA== 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.4 03/13] i2c: bcm2835: Avoid clock stretching timeouts Date: Tue, 22 Feb 2022 21:31:07 -0500 Message-Id: <20220223023118.241815-3-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220223023118.241815-1-sashal@kernel.org> References: <20220223023118.241815-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_183127_529786_2C95B528 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 5ab901ad615dd..c265fe4621621 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) @@ -479,6 +484,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