[PATCH RFC] i2c: rk3x: handle dynamic clock rate changes correctly
addy ke
addy.ke at rock-chips.com
Sun Sep 14 20:11:24 PDT 2014
Hi Max
On 2014/9/13 19:26, Max Schwarz wrote:
> Hello Addy,
>
> On Wednesday 10 September 2014 at 16:16:10, Addy wrote:
>>> @@ -724,16 +816,28 @@ static int rk3x_i2c_probe(struct platform_device
>>> *pdev)
>>>
>>> return ret;
>>>
>>> }
>>>
>>> + i2c->clk_rate_nb.notifier_call = rk3x_i2c_clk_notifier_cb;
>>> + ret = clk_notifier_register(i2c->clk, &i2c->clk_rate_nb);
>>> + if (ret != 0) {
>>> + dev_err(&pdev->dev, "Unable to register clock notifier\n");
>>> + goto err_clk;
>>> + }
>>> +
>>> + i2c->clk_freq = clk_get_rate(i2c->clk);
>>> + rk3x_i2c_set_scl_rate(i2c, i2c->scl_frequency);
>>
>> I have tested on rk3288-pinky board:
>> I2c clock must be enabled before driver call rk3x_i2c_set_scl_rate()
>> to write div value to CLKDIV register. If not, system will crash.
>>
>> So we need call clk_enable() before rk3x_i2c_set_scl_rate().
>
> Interesting. It works without problems on RK3188. Do you know if the clock has
> to be kept enabled for some time? Or is it okay to do it like this?
>
> clk_enable(i2c->clk);
> rk3x_i2c_set_scl_rate(i2c, i2c->scl_frequency);
> clk_disable(i2c->clk);
>
> Cheers,
> Max
>
Before write value to i2c register, it is necessary to enable i2c's clock and parent clock!
In the linux-rockchip branch code, the i2c's clock and parent clock are enabled by default.
So there are no problems on it.
But on rk388-pinky board, pclk_peri is disabled when i2c driver is probed.
(Maybe its reference count drops to 0 and it is disabled by clk driver)
Hi, Doug
Do you known why pclk_peri is disabled when i2c driver is probed?
My test branch is cros/chromeos-3.14.
>
>
More information about the Linux-rockchip
mailing list