linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Wahren <wahrenst@gmx.net>
To: Eric Anholt <eric@anholt.net>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Ray Jui <rjui@broadcom.com>,
	Scott Branden <sbranden@broadcom.com>,
	Wolfram Sang <wsa@the-dreams.de>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>
Cc: bcm-kernel-feedback-list@broadcom.com,
	linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org,
	linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org,
	devicetree@vger.kernel.org, Stefan Wahren <wahrenst@gmx.net>
Subject: [PATCH V2 08/13] i2c: bcm2835: Avoid clk stretch quirk for BCM2711
Date: Tue, 13 Aug 2019 18:20:43 +0200	[thread overview]
Message-ID: <1565713248-4906-9-git-send-email-wahrenst@gmx.net> (raw)
In-Reply-To: <1565713248-4906-1-git-send-email-wahrenst@gmx.net>

The I2C block on the BCM2711 isn't affected by the clock stretching bug.
So there is no need to apply the corresponding quirk.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 drivers/i2c/busses/i2c-bcm2835.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
index 67752f7..340da70 100644
--- a/drivers/i2c/busses/i2c-bcm2835.c
+++ b/drivers/i2c/busses/i2c-bcm2835.c
@@ -12,6 +12,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>

@@ -50,6 +51,9 @@
 #define BCM2835_I2C_CDIV_MIN	0x0002
 #define BCM2835_I2C_CDIV_MAX	0xFFFE

+#define NO_STRETCH_BUG	false
+#define STRETCH_BUG	true
+
 struct bcm2835_i2c_dev {
 	struct device *dev;
 	void __iomem *regs;
@@ -389,7 +393,7 @@ static const struct i2c_algorithm bcm2835_i2c_algo = {
 };

 /*
- * This HW was reported to have problems with clock stretching:
+ * The BCM2835 was reported to have problems with clock stretching:
  * http://www.advamation.com/knowhow/raspberrypi/rpi-i2c-bug.html
  * https://www.raspberrypi.org/forums/viewtopic.php?p=146272
  */
@@ -406,6 +410,9 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
 	struct clk *bus_clk;
 	struct clk *mclk;
 	u32 bus_clk_rate;
+	bool clk_stretch_bug;
+
+	clk_stretch_bug = (bool)of_device_get_match_data(&pdev->dev);

 	i2c_dev = devm_kzalloc(&pdev->dev, sizeof(*i2c_dev), GFP_KERNEL);
 	if (!i2c_dev)
@@ -475,7 +482,9 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
 	adap->algo = &bcm2835_i2c_algo;
 	adap->dev.parent = &pdev->dev;
 	adap->dev.of_node = pdev->dev.of_node;
-	adap->quirks = &bcm2835_i2c_quirks;
+
+	if (clk_stretch_bug)
+		adap->quirks = &bcm2835_i2c_quirks;

 	bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, 0);

@@ -501,7 +510,8 @@ static int bcm2835_i2c_remove(struct platform_device *pdev)
 }

 static const struct of_device_id bcm2835_i2c_of_match[] = {
-	{ .compatible = "brcm,bcm2835-i2c" },
+	{ .compatible = "brcm,bcm2711-i2c", .data = (void *)NO_STRETCH_BUG },
+	{ .compatible = "brcm,bcm2835-i2c", .data = (void *)STRETCH_BUG },
 	{},
 };
 MODULE_DEVICE_TABLE(of, bcm2835_i2c_of_match);
--
2.7.4


  parent reply	other threads:[~2019-08-13 16:21 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-13 16:20 [PATCH V2 00/13] ARM: Add minimal Raspberry Pi 4 support Stefan Wahren
2019-08-13 16:20 ` [PATCH V2 01/13] ARM: dts: bcm283x: Enable HDMI at board level Stefan Wahren
2019-08-13 16:20 ` [PATCH V2 02/13] ARM: dts: bcm283x: Move BCM2835/6/7 specific to bcm2835-common.dtsi Stefan Wahren
2019-08-13 16:20 ` [PATCH V2 03/13] dt-bindings: bcm2835-cprman: Add bcm2711 support Stefan Wahren
2019-08-16 17:41   ` Stephen Boyd
2019-08-27 16:00   ` Rob Herring
2019-08-13 16:20 ` [PATCH V2 04/13] clk: bcm2835: Introduce SoC specific clock registration Stefan Wahren
2019-08-13 16:20 ` [PATCH V2 05/13] clk: bcm2835: Add BCM2711_CLOCK_EMMC2 support Stefan Wahren
2019-09-12 17:24   ` Matthias Brugger
2019-09-12 18:52     ` Eric Anholt
2019-09-13  1:20       ` Stefan Wahren
2019-09-13  7:13         ` Matthias Brugger
2019-09-13 23:02           ` Florian Fainelli
2019-08-13 16:20 ` [PATCH V2 06/13] clk: bcm2835: Mark PLLD_PER as CRITICAL Stefan Wahren
2019-08-16 17:39   ` Stephen Boyd
2019-08-13 16:20 ` [PATCH V2 07/13] dt-bindings: i2c: bcm2835: Add brcm,bcm2711 compatible Stefan Wahren
2019-08-27 16:00   ` Rob Herring
2019-08-13 16:20 ` Stefan Wahren [this message]
2019-08-14 19:36   ` [PATCH V2 08/13] i2c: bcm2835: Avoid clk stretch quirk for BCM2711 Wolfram Sang
2019-08-17  7:32     ` Stefan Wahren
2019-08-17  8:30       ` Wolfram Sang
2019-08-13 16:20 ` [PATCH V2 09/13] dt-bindings: arm: Convert BCM2835 board/soc bindings to json-schema Stefan Wahren
2019-08-13 17:22   ` Rob Herring
2019-08-14 19:21     ` Stefan Wahren
2019-08-14 23:06       ` Rob Herring
2019-08-13 16:20 ` [PATCH V2 10/13] dt-bindings: arm: bcm2835: Add Raspberry Pi 4 to DT schema Stefan Wahren
2019-08-13 16:20 ` [PATCH V2 11/13] ARM: bcm: Add support for BCM2711 SoC Stefan Wahren
2019-09-10 14:13   ` Matthias Brugger
2019-08-13 16:20 ` [PATCH V2 12/13] ARM: dts: Add minimal Raspberry Pi 4 support Stefan Wahren
2019-08-13 16:20 ` [PATCH V2 13/13] MAINTAINERS: Add BCM2711 to BCM2835 ARCH Stefan Wahren
2019-08-13 20:42 ` [PATCH V2 00/13] ARM: Add minimal Raspberry Pi 4 support Eric Anholt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1565713248-4906-9-git-send-email-wahrenst@gmx.net \
    --to=wahrenst@gmx.net \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=devicetree@vger.kernel.org \
    --cc=eric@anholt.net \
    --cc=f.fainelli@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=mturquette@baylibre.com \
    --cc=rjui@broadcom.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=sbranden@broadcom.com \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).