[U-Boot] [PATCH V3+] I2C: mxc_i2c rework

Jason Hui jason.hui at linaro.org
Fri Jul 29 08:55:14 CEST 2011


Hi, Marek,

On Thu, Jul 14, 2011 at 5:58 AM, Marek Vasut <marek.vasut at gmail.com> wrote:
> Rewrite the mxc_i2c driver.
>  * This version is much closer to Linux implementation.
>  * Fixes IPG_PERCLK being incorrectly used as clock source
>  * Fixes behaviour of the driver on iMX51
>  * Clean up coding style a bit ;-)
>

why you change i2c clock from IPG_PERCLK to IPG_CLK?

[...]
> +static void i2c_imx_set_clk(unsigned int rate)
>  {
> -       int freq;
> +       struct mxc_i2c_regs *i2c_regs = (struct mxc_i2c_regs *)I2C_BASE;
> +       unsigned int i2c_clk_rate;
> +       unsigned int div;
>        int i;
>
> +       /* Divider value calculation */
>  #if defined(CONFIG_MX31)
>        struct clock_control_regs *sc_regs =
>                (struct clock_control_regs *)CCM_BASE;
>
> -       freq = mx31_get_ipg_clk();
> +       i2c_clk_rate = mx31_get_ipg_clk();
>        /* start the required I2C clock */
>        writel(readl(&sc_regs->cgr0) | (3 << I2C_CLK_OFFSET),
>                &sc_regs->cgr0);
>  #else
> -       freq = mxc_get_clock(MXC_IPG_PERCLK);
> +       i2c_clk_rate = mxc_get_clock(MXC_IPG_CLK);
>  #endif

There are two clocks for i2c:

Peripheral clock (IPBus): source from  ipg_clk_root, which is for IP
bus register read/write.
Block clock: source from perclk_root, which is I2C function clock.

We need get perclk not ipg clock, right?

BTW, do you test this driver on mx53?

Jason
>


More information about the U-Boot mailing list