From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Eddie Huang <eddie.huang@mediatek.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
Xudong Chen <xudong.chen@mediatek.com>,
srv_heupstream@mediatek.com, Pawel Moll <pawel.moll@arm.com>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
Wolfram Sang <wsa@the-dreams.de>,
Liguo Zhang <liguo.zhang@mediatek.com>,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
Rob Herring <robh+dt@kernel.org>,
linux-mediatek@lists.infradead.org, linux-i2c@vger.kernel.org,
Sascha Hauer <kernel@pengutronix.de>,
Kumar Gala <galak@codeaurora.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v8 2/3] I2C: mediatek: Add driver for MediaTek I2C controller
Date: Wed, 20 May 2015 10:33:35 +0200 [thread overview]
Message-ID: <20150520083335.GQ24769@pengutronix.de> (raw)
In-Reply-To: <1432108775.12796.11.camel@mtksdaap41>
Hello Eddie,
On Wed, May 20, 2015 at 03:59:35PM +0800, Eddie Huang wrote:
> On Wed, 2015-05-20 at 09:11 +0200, Uwe Kleine-König wrote:
> > On Wed, May 20, 2015 at 10:40:11AM +0800, Eddie Huang wrote:
> > > On Mon, 2015-05-18 at 20:43 +0200, Uwe Kleine-König wrote:
> > > > On Tue, May 19, 2015 at 12:40:08AM +0800, Eddie Huang wrote:
> > > > > +/* calculate i2c port speed */
> > > > It would be nice to summarize the clock frequency settings here.
> > > > Something like:
> > > >
> > > > /*
> > > > * The input clock is divided by the value specified in the
> > > > * device tree as clock-div. The actual bus speed is then
> > > > * derived from this frequency by the following formula:
> > > > * ....
> > > >
> > > > This would make it possible to verify your calculations below.
> > >
> > > The comment will be:
> > > /*
> > > * khz: I2C bus clock
> > > * hclk: The input clock is divided by the value specified in the
> > > * device tree as clock-div
> > and which one of the two clocks you're writing about is hclk now? I
> > assume the divided one.
> > > * div = (sample_cnt + 1) * (step_cnt + 1)
> > > * khz = (hclk / 2) / div
> > khz for the 2nd time.
> >
> > > *
> > > * The calculation is to get div value that let result of
> > > * ((hclk / 2) / div) most approach and less than khz
> > > */
> > I imagined something more hardware related. A list of register (or
> > register bit fields) that influence the frequency and a formula
>
> > i2c_freq = parent_clk / clock-div * (...)
> >
> > (It seems to be a bit more complicated here as there are two registers
> > involved that are set differently depending on the target frequency.)
>
> Yes, hardware is a little complicated. I rewrite the comment:
>
> /*
> * Calculate i2c port speed
> *
> * Hardware design:
> * i2c_bus_freq = parent_clk / (clock-div * 2 * (sample_cnt) *
> (step_cnt))
> * clock-div: fixed in hardware, but may be various in different SoCs
... fixed in hardware, but different on different SoCs.
> *
> * The calculation want to pick the highest bus frequency that is still
> * less than or equal to i2c->speed_hz. and the calculation try to get
> * sample_cnt and step_cnt to fill in hardware register.
"The calculation picks the highest bus frequency that is still less than
or equal to i2c->speed_hz." and I'd drop the last sentence.
With that in mind I'll reply once more to the original patch.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
next prev parent reply other threads:[~2015-05-20 8:33 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-18 16:40 [PATCH v8 0/3] ARM: mediatek: Add driver for Mediatek I2C Eddie Huang
[not found] ` <1431967209-5261-1-git-send-email-eddie.huang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2015-05-18 16:40 ` [PATCH v8 1/3] dt-bindings: Add I2C bindings for mt65xx/mt81xx Eddie Huang
[not found] ` <1431967209-5261-2-git-send-email-eddie.huang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2015-05-18 18:29 ` Uwe Kleine-König
2015-05-18 16:40 ` [PATCH v8 2/3] I2C: mediatek: Add driver for MediaTek I2C controller Eddie Huang
[not found] ` <1431967209-5261-3-git-send-email-eddie.huang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2015-05-18 18:43 ` Uwe Kleine-König
2015-05-19 14:48 ` Matthias Brugger
2015-05-19 19:49 ` Uwe Kleine-König
[not found] ` <20150519194917.GI24769-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2015-05-20 5:33 ` Eddie Huang
2015-05-20 3:07 ` Yingjoe Chen
[not found] ` <20150518184300.GB28888-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2015-05-20 2:40 ` Eddie Huang
2015-05-20 7:11 ` Uwe Kleine-König
[not found] ` <20150520071152.GP24769-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2015-05-20 7:59 ` Eddie Huang
2015-05-20 8:33 ` Uwe Kleine-König [this message]
2015-05-20 8:57 ` Uwe Kleine-König
[not found] ` <20150520085715.GA17078-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2015-05-20 13:03 ` Yingjoe Chen
2015-05-20 15:37 ` Uwe Kleine-König
2015-05-21 7:01 ` Eddie Huang
2015-05-18 16:40 ` [PATCH v8 3/3] I2C: mediatek: Add driver for MediaTek MT8173 " Eddie Huang
2015-05-19 14:45 ` Matthias Brugger
[not found] ` <CABuKBeKJ=V6bP9iU9xDN0JecTTFoLDUfsX_QP5rpPj1bn167Vg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-05-20 2:53 ` Eddie Huang
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=20150520083335.GQ24769@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=devicetree@vger.kernel.org \
--cc=eddie.huang@mediatek.com \
--cc=galak@codeaurora.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=kernel@pengutronix.de \
--cc=liguo.zhang@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.org \
--cc=srv_heupstream@mediatek.com \
--cc=wsa@the-dreams.de \
--cc=xudong.chen@mediatek.com \
/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).