linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: u.kleine-koenig@pengutronix.de (Uwe Kleine-König)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v8 2/3] I2C: mediatek: Add driver for MediaTek I2C controller
Date: Wed, 20 May 2015 09:11:52 +0200	[thread overview]
Message-ID: <20150520071152.GP24769@pengutronix.de> (raw)
In-Reply-To: <1432089611.13819.9.camel@mtksdaap41>

Hello Eddie,

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.)

> > > +static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int clk_src_in_hz)
clk_src_in_hz is the module's input rate already divided by clock-div.
This clock-div value is fixed in hardware and unchangeable, right?
Maybe give that divided clock a nice name?

The target frequency is i2c->speed_hz, so among the possible frequencies
we want to pick the highest one that is still less than or equal
i2c->speed_hz, right?

> > > +		/* Set the hign speed mode register */
I just notice s/hign/high/ here.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

  reply	other threads:[~2015-05-20  7:11 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
2015-05-18 16:40 ` [PATCH v8 1/3] dt-bindings: Add I2C bindings for mt65xx/mt81xx Eddie Huang
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
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
2015-05-20  5:33         ` Eddie Huang
2015-05-20  3:07       ` Yingjoe Chen
2015-05-20  2:40     ` Eddie Huang
2015-05-20  7:11       ` Uwe Kleine-König [this message]
2015-05-20  7:59         ` Eddie Huang
2015-05-20  8:33           ` Uwe Kleine-König
2015-05-20  8:57   ` Uwe Kleine-König
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
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=20150520071152.GP24769@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).