From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753563AbcFBQgH (ORCPT ); Thu, 2 Jun 2016 12:36:07 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:61960 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752701AbcFBQgF (ORCPT ); Thu, 2 Jun 2016 12:36:05 -0400 Subject: Re: [PATCH] i2c: bcm2835: Set up the clock stretching timeout at boot. To: Eric Anholt , Wolfram Sang References: <1464818845-5348-1-git-send-email-eric@anholt.net> Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rpi-kernel@lists.infradead.org From: Stefan Wahren Message-ID: <30fcc305-971d-4a1c-18c1-08c28585e260@i2se.com> Date: Thu, 2 Jun 2016 18:35:34 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <1464818845-5348-1-git-send-email-eric@anholt.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:nafJoaLaoNEDYp/ZT3I3KC+uLwMrs7Ts2RkVy4l6zFOxaPscBTS ZuXauL3nVs/BURGp5aBjBzt1Tzx/t1pnbRGXInxkr9UHasK7RvCIVGyPZg7H7sgBqZCNBd+ R9srYH6Q6JumU/zcL6BqaBN5oOA7hKqQQaRlJuhmHaqHq/VbAkLBKXaNHi8Zr8K5//PMKJ4 HqqK/wa6JqdvMULz7zFhg== X-UI-Out-Filterresults: notjunk:1;V01:K0:XgTxQU/upYU=:J8eGuGmXLN5bbbfX+kzbkE bL/hl43eu4cyn5G9iL3+sX2LaYDlFrRLpmBL4vo0fYL6apgQAHFQLbh2pZjzKH86v02dPpdNy ykpp35DCt4fftBBeS4z7AF4o2ZI7YzDOXXuDvYWRiPSpF4Qdjwg0NMO3Itu0/30QDqKZfhdY1 8zp7TXD4la96wW7UKCD3i/yKJnb77CQ5/sANoj5UwRNMqTrIkEuUU9djLgRGlgHHkoscDI2Tu xMf+IWPBhj9bq+DpNZEO1vCLIkNkeglL3d8H0Y2Nt0NEV69O2CuhCvSNs1WLcWX02S71PcM0S 61dZ76N9gkkvILHtBEIu9Rk7okE17W9vE0BjC0XWdfu1tUvoA40CBxN/1gvR/MSWM2Ne3yuu/ jubHy/E3a/C4YpQ2QCvOQcMvsjf8aPJhy7h6PudRNSZR1J5T6zLKyXI94ahQibSYOA0ZZdvKd 9bUkaZdv/y9d8RzNWSc2Hog9WK3nWYYnTm19Yczda0Z7G3gSQ17lO5f1wxVs4hROO8D7hTTCI +dYf1rQP3Ib/7DbERrEzfX2WA05kRXGAEvIMViV4Qozjb8w4q/kiTjLyLxC+8sYc1q2ulfanN UbGvhwVFs1o5+L61+XC2w0x7+Gr8nhjkZRLf77cCWiLJp4/ICkqV6Pm2gP9vAgD9hc5Nyu9+5 xp2RjLjpmdXino24pZkZW7P6iEXNunTHG1G5Z3Ml0XpawVt/H7WfZFEXyvCwFPC54lXPMyetC og9Pd9JYr9wWucWX Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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. Stefan > irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); > if (!irq) { > dev_err(&pdev->dev, "No IRQ resource\n");