From: Eric Anholt <eric@anholt.net>
To: Stefan Wahren <stefan.wahren@i2se.com>, Wolfram Sang <wsa@the-dreams.de>
Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-rpi-kernel@lists.infradead.org,
Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [PATCH] i2c: bcm2835: Set up the clock stretching timeout at boot.
Date: Thu, 02 Jun 2016 11:02:32 -0700 [thread overview]
Message-ID: <8760trbhaf.fsf@eliezer.anholt.net> (raw)
In-Reply-To: <25336b03-76d1-2466-fbc0-9f363d3e7638@i2se.com>
[-- Attachment #1: Type: text/plain, Size: 2382 bytes --]
Stefan Wahren <stefan.wahren@i2se.com> writes:
> Hi Eric,
>
> Am 02.06.2016 um 00:07 schrieb Eric Anholt:
>> The register at poweron contains 0x40, which at our typical 100khz bus
>> rate means .64ms instead of the desired 25ms.
>>
>> Fixes many clock stretching timeouts when talking to the DSI panel's
>> bridge chip, and will hopefully fix talking to the FXL6408 GPIO
>> expander on the Pi3 as well.
>>
>> Signed-off-by: Eric Anholt <eric@anholt.net>
>> ---
>> drivers/i2c/busses/i2c-bcm2835.c | 15 +++++++++++++++
>> 1 file changed, 15 insertions(+)
>>
>> diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
>> index 818b051d25e6..1348f224013d 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)
>> @@ -238,6 +243,7 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
>> u32 bus_clk_rate, divider;
>> int ret;
>> struct i2c_adapter *adap;
>> + u32 clkt;
>>
>> i2c_dev = devm_kzalloc(&pdev->dev, sizeof(*i2c_dev), GFP_KERNEL);
>> if (!i2c_dev)
>> @@ -280,6 +286,15 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
>> }
>> bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_DIV, divider);
>>
>> + /*
>> + * SMBUS says "Devices participating in a transfer will
>> + * timeout when any clock low exceeds the value of
>> + * T_TIMEOUT,MIN of 25 ms."
>> + */
>> + clkt = DIV_ROUND_UP(25 * bus_clk_rate, 1000);
>> + clkt = min(clkt, 0xffffu);
>> + bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_CLKT, clkt);
>> +
>
> could we really assume that the clk rate never change after driver probing?
>
> This also affects Gerd's patch [PATCH 28/32] i2c: bcm2835: Set up the
> rising/falling edge delays.
The I2C_DIV register setup you see in this hunk is what is producing the
SCL clock, so this code is in the right place. If we need to add
switching of bus rates at runtime then we'd have to move all of it,
which would be a separate change.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]
next prev parent reply other threads:[~2016-06-02 18:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-01 22:07 [PATCH] i2c: bcm2835: Set up the clock stretching timeout at boot Eric Anholt
2016-06-02 16:35 ` Stefan Wahren
[not found] ` <25336b03-76d1-2466-fbc0-9f363d3e7638@i2se.com>
2016-06-02 18:02 ` Eric Anholt [this message]
2016-07-04 0:31 ` Wolfram Sang
2016-07-04 1:02 ` Eric Anholt
2016-07-22 7:27 ` Wolfram Sang
2016-10-03 19:50 ` 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=8760trbhaf.fsf@eliezer.anholt.net \
--to=eric@anholt.net \
--cc=kraxel@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=stefan.wahren@i2se.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