From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Subject: Re: [RFC PATCH] mxs: i2c: Implement arbitrary clock speed derivation algorithm Date: Thu, 24 Jan 2013 13:21:14 +0100 Message-ID: <201301241321.15117.marex@denx.de> References: <1354297715-12201-1-git-send-email-marex@denx.de> <20130124072555.GD8364@nekote.pengutronix.de> Mime-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20130124072555.GD8364-8EAEigeeuNG034pCzgS/Qg7AFbiQbgqx@public.gmane.org> Sender: linux-i2c-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Wolfram Sang Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Fabio Estevam , Shawn Guo List-Id: linux-i2c@vger.kernel.org Dear Wolfram Sang, > Hi Marek, > > On Fri, Nov 30, 2012 at 06:48:35PM +0100, Marek Vasut wrote: > > This patch drops the i2c timing tables from this driver and instead > > derives the timing based from the requested clock sleep. The timing > > tables were completely wrong anyway when observed on a scope. > > > > This new algorithm is also only derived by using a scope, but it seems > > to produce much more accurate result. > > > > Signed-off-by: Marek Vasut > > Cc: Fabio Estevam > > Cc: Shawn Guo > > Cc: Wolfram Sang > > --- > > > > drivers/i2c/busses/i2c-mxs.c | 94 > > ++++++++++++++++++++++++------------------ 1 file changed, 55 > > insertions(+), 39 deletions(-) > > > > NOTE: Can someone please test if this patch works for them as well? > > > > I tested this on DENX M28EVK and Freescale MX28EVK. > > Second call for testers. [...] > > +static void mxs_i2c_derive_timing(struct mxs_i2c_dev *i2c, int speed) > > +{ > > + /* The I2C block clock run at 24MHz */ > > + const uint32_t clk = 24000000; > > + uint32_t base; > > + uint16_t high_count, low_count, rcv_count, xmit_count; > > + struct device *dev = i2c->dev; > > + > > + if (speed > 540000) { > > + dev_err(dev, "Speed too high (%d Hz), using 540 kHz\n", speed); > > + speed = 540000; > > + } else if (speed < 12000) { > > + dev_err(dev, "Speed too low (%d Hz), using 12 kHz\n", speed); > > + speed = 12000; > > + } > > I'd think dev_warn would do, since we are able to continue. No need to > resend, though. > > Rest looks good, thanks! Ah, good catch. We can put this one on hold, it's not as important as the PIO/DMA one. I'd like to see the PIO/DMA one hit mainline though. Thanks! Best regards, Marek Vasut