Re: [PATCH v6 4/5] i2c: aspeed: added driver for Aspeed I2C
From: Benjamin Herrenschmidt
Date: Tue Mar 28 2017 - 05:11:01 EST
On Mon, 2017-03-27 at 22:12 -0700, Brendan Higgins wrote:
> +ÂÂÂÂÂÂÂ/* Set AC Timing */
> +ÂÂÂÂÂÂÂif (clk_freq / 1000 > 1000) {
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂaspeed_i2c_write(bus, aspeed_i2c_read(bus,
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ ASPEED_I2C_FUN_CTRL_REG) |
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂASPEED_I2CD_M_HIGH_SPEED_EN |
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂASPEED_I2CD_M_SDA_DRIVE_1T_EN |
s/ASPEED_I2CD_M_SDA_DRIVE_1T_EN/ASPEED_I2CD_M_SCL_DRIVE_1T_EN/
(and in the definition too)
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂASPEED_I2CD_SDA_DRIVE_1T_EN,
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂASPEED_I2C_FUN_CTRL_REG);
> +
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂaspeed_i2c_write(bus, 0x3, ASPEED_I2C_AC_TIMING_REG2);
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂaspeed_i2c_write(bus, aspeed_i2c_get_clk_reg_val(divisor),
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ ASPEED_I2C_AC_TIMING_REG1);
> +ÂÂÂÂÂÂÂ} else {
I don't think that's right. AFAIK ASPEED_I2CD_M_HIGH_SPEED_EN is about
ignoring the timing register completely and going for full speed which
is a few Mhz (I forgot how much). At least from my (possibly incorrect)
reading of the spec and the SDK driver.
Or maybe that's what you intend by the above ? Anything above 1Mhz ?
I think there's a blurb somewhere that says that setting that bit makes
it ignore the timing register completely. The definition is:
<<
Enable High Speed master mode
0 : normal speed mode
1 : high speed mode (3.4Mbps)
High speed mode can only use buffer mode for transfer. And only master
mode supports speed switching capability
>>
The spec of the base clock field of the timing register also says
<<
When switch to High Speed (HS) mode, the divisor will be switch to 0 by
hardware automatically
>>
Note also that we aren't use buffer mode anyway so this can't work as-
is, we're using byte mode.
The other interesting question is what is the frequency threshold for
setting ASPEED_I2CD_M_SCL_DRIVE_1T_EN (and the SDA one) ?
Those bits are somewhat orthogonal to ASPEED_I2CD_M_HIGH_SPEED_EN. They
make the device drive the signals for a clock when they go up to "speed
up" the rising edge more than a normal pull up would do.
If you have some fast devices, it would be interesting to scope the
signal see from what speed it becomes interesting to set the 1T enable
bits to speed up rising edges.
Cheers,
Ben.