public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/7] i2c: mxs: Abstract out the MXS I2C speed setup
Date: Tue, 13 Nov 2012 14:45:24 +0100	[thread overview]
Message-ID: <201211131445.24639.marex@denx.de> (raw)
In-Reply-To: <20121113082927.5575C2002E1@gemini.denx.de>

Dear Wolfgang Denk,

> Dear Marek,
> 
> In message <1352766871-892-4-git-send-email-marex@denx.de> you wrote:
> > This patch pulls out the I2C speed setup from the i2c_init() call
> > and implements the bus configuration lookup table with register
> > values that needs to be programmed into the I2C IP to run at
> > particular speed.
> > 
> > This patch is a first step towards implementing run-time I2C bus
> > speed configuration for the MXS I2C IP.
> 
> Thanks.
> 
> > +static struct mxs_i2c_speed_table {
> > +	uint32_t	speed;
> > +	uint32_t	timing0;
> > +	uint32_t	timing1;
> > +} mxs_i2c_tbl[] = {
> > +	{
> > +		100000,
> > +		(0x0078 << I2C_TIMING0_HIGH_COUNT_OFFSET) |
> > +		(0x0030 << I2C_TIMING0_RCV_COUNT_OFFSET),
> > +		(0x0080 << I2C_TIMING1_LOW_COUNT_OFFSET) |
> > +		(0x0030 << I2C_TIMING1_XMIT_COUNT_OFFSET)
> > +	},
> > +	{
> > +		400000,
> > +		(0x000f << I2C_TIMING0_HIGH_COUNT_OFFSET) |
> > +		(0x0007 << I2C_TIMING0_RCV_COUNT_OFFSET),
> > +		(0x001f << I2C_TIMING1_LOW_COUNT_OFFSET) |
> > +		(0x000f << I2C_TIMING1_XMIT_COUNT_OFFSET),
> > +	}
> > +};
> 
> Do we really need such a compile-time initialized table which will
> have to include all possible I2C speeds anybody is ever going to use
> on any board?

Yes

> And if board XXX wants to use a funny I2C clock, we have to add yet
> another entry to this common file?   Such a solution does not scale.

The problem is, the algorithm to compute these values is not described in the 
MX28 manual. There're only values for 100 and 400kHz speed in the manual.

> Can we not rather calculate these register values for any arbitrary
> I2C clock given?

That's what I'd love to do ... no luck so far. That's why there is the crappy 
table.

> Best regards,
> 
> Wolfgang Denk

Best regards,
Marek Vasut

  reply	other threads:[~2012-11-13 13:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-13  0:34 [U-Boot] [PATCH 1/7] i2c: Use __weak instead of __attribute__((weak, alias)) Marek Vasut
2012-11-13  0:34 ` [U-Boot] [PATCH 2/7] i2c: Staticize local functions in mxc i2c driver Marek Vasut
2012-11-13  0:34 ` [U-Boot] [PATCH 3/7] i2c: kerneldoc: Add kerneldoc annotations to cmd_i2c.c Marek Vasut
2012-11-13  0:34 ` [U-Boot] [PATCH 4/7] i2c: mxs: Abstract out the MXS I2C speed setup Marek Vasut
2012-11-13  8:29   ` Wolfgang Denk
2012-11-13 13:45     ` Marek Vasut [this message]
2012-11-13  0:34 ` [U-Boot] [PATCH 5/7] i2c: mxs: Implement i2c_get/set_bus_speed() Marek Vasut
2012-11-13  0:34 ` [U-Boot] [PATCH 6/7] i2c: mxs: Use i2c_set_bus_speed() in i2c_init() Marek Vasut
2012-11-13  0:34 ` [U-Boot] [PATCH 7/7] i2c: mxs: Fix TIMING2 register value Marek Vasut
2012-11-13  7:16 ` [U-Boot] [PATCH 1/7] i2c: Use __weak instead of __attribute__((weak, alias)) Wolfgang Denk
2012-11-13 13:48   ` Marek Vasut

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=201211131445.24639.marex@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.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