We analyzd the problem " The clock-frequency of i2c@7000c400 in u-boot dts is 400000,
But we actually measured is 490K" , and found the i2c bus type is TYPE_114 on u-boot, and the clk rate will used new calculation as the picture as follow:
Both are setting the i2c clk rate similarly except that in uboot we have an extra multiplication by 2 as highlighted above. Also this doesn’t seem to be fitting into the equation in the comments section:
Below could be the change cause it. Could you try to revert it to try.
i2c: tegra: add standardized clk/reset API support
clk/reset API was tested on T186 platform and previous chip like
T210/T124 will still use the old APIs.
Bug 200211165
Here’s the bulk of Bryan’s change (mostly for T186, it would appear):
static void i2c_init_controller(struct i2c_bus *i2c_bus)
{
if (!i2c_bus->speed)
@@ -78,8 +126,12 @@ static void i2c_init_controller(struct i2c_bus *i2c_bus)
* here, in section 23.3.1, but in fact we seem to need a factor of
* 16 to get the right frequency.
*/
+#ifdef CONFIG_TEGRA186
+ i2c_init_clock(i2c_bus, i2c_bus->speed * 2 * 8);
+#else
clock_start_periph_pll(i2c_bus->periph_id, CLOCK_ID_PERIPH,
i2c_bus->speed * 2 * 8);
+#endif
if (i2c_bus->type == TYPE_114) {
/*
@@ -94,12 +146,17 @@ static void i2c_init_controller(struct i2c_bus *i2c_bus)
* is running, we hang, and we need it for the new calc.
*/
int clk_div_stdfst_mode = readl(&i2c_bus->regs->clk_div) >> 16;
+ unsigned rate = CLK_MULT_STD_FAST_MODE *
+ (clk_div_stdfst_mode + 1) * i2c_bus->speed * 2;
debug("%s: CLK_DIV_STD_FAST_MODE setting = %d\n", __func__,
clk_div_stdfst_mode);
+#ifdef CONFIG_TEGRA186
+ i2c_init_clock(i2c_bus, rate);
+#else
clock_start_periph_pll(i2c_bus->periph_id, CLOCK_ID_PERIPH,
- CLK_MULT_STD_FAST_MODE * (clk_div_stdfst_mode + 1) *
- i2c_bus->speed * 2);
+ rate);
+#endif
}
Please measure the I2C clock on a T210 board (Nano, TX1, etc.) with our Rel32 BSP and see what you get. Stop in U-Boot by pressing any key on the console so you can measure it w/U-Boot settings, then proceed to boot to kernel (via ‘boot’ in the console) and measure it again w/the kernel clock settings.
Hi , we add i2c device in U-boot, and test it is 490K , also we add the same i2c device in Kernel dts 400K, and it is about 392K , it is right in Kernel.
Hi,the issuse you can test yourself, we just used , not create new method.
And I don’t think how difficult it is, you should ask your R & D department, Why this configuration?
we just want to know how to get 400K i2c clk?