[U-Boot] [PATCH 4/7] i2c: mxs: Abstract out the MXS I2C speed setup
Marek Vasut
marex at denx.de
Tue Nov 13 14:45:24 CET 2012
Dear Wolfgang Denk,
> Dear Marek,
>
> In message <1352766871-892-4-git-send-email-marex at 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
More information about the U-Boot
mailing list