Commit 79e137b1 authored by Jerome Brunet's avatar Jerome Brunet Committed by Wolfram Sang

i2c: meson: keep peripheral clock enabled

SCL rate appears to be different than what is expected. For example,
We get 164kHz on i2c3 of the vim3 when 400kHz is expected. This is
partially due to the peripheral clock being disabled when the clock is
set.

Let's keep the peripheral clock on after probe to fix the problem. This
does not affect the SCL output which is still gated when i2c is idle.

Fixes: 09af1c2f ("i2c: meson: set clock divider in probe instead of setting it for each transfer")
Signed-off-by: default avatarJerome Brunet <jbrunet@baylibre.com>
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
parent 28683e84
...@@ -370,16 +370,12 @@ static int meson_i2c_xfer_messages(struct i2c_adapter *adap, ...@@ -370,16 +370,12 @@ static int meson_i2c_xfer_messages(struct i2c_adapter *adap,
struct meson_i2c *i2c = adap->algo_data; struct meson_i2c *i2c = adap->algo_data;
int i, ret = 0; int i, ret = 0;
clk_enable(i2c->clk);
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
ret = meson_i2c_xfer_msg(i2c, msgs + i, i == num - 1, atomic); ret = meson_i2c_xfer_msg(i2c, msgs + i, i == num - 1, atomic);
if (ret) if (ret)
break; break;
} }
clk_disable(i2c->clk);
return ret ?: i; return ret ?: i;
} }
...@@ -448,7 +444,7 @@ static int meson_i2c_probe(struct platform_device *pdev) ...@@ -448,7 +444,7 @@ static int meson_i2c_probe(struct platform_device *pdev)
return ret; return ret;
} }
ret = clk_prepare(i2c->clk); ret = clk_prepare_enable(i2c->clk);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "can't prepare clock\n"); dev_err(&pdev->dev, "can't prepare clock\n");
return ret; return ret;
...@@ -470,7 +466,7 @@ static int meson_i2c_probe(struct platform_device *pdev) ...@@ -470,7 +466,7 @@ static int meson_i2c_probe(struct platform_device *pdev)
ret = i2c_add_adapter(&i2c->adap); ret = i2c_add_adapter(&i2c->adap);
if (ret < 0) { if (ret < 0) {
clk_unprepare(i2c->clk); clk_disable_unprepare(i2c->clk);
return ret; return ret;
} }
...@@ -488,7 +484,7 @@ static int meson_i2c_remove(struct platform_device *pdev) ...@@ -488,7 +484,7 @@ static int meson_i2c_remove(struct platform_device *pdev)
struct meson_i2c *i2c = platform_get_drvdata(pdev); struct meson_i2c *i2c = platform_get_drvdata(pdev);
i2c_del_adapter(&i2c->adap); i2c_del_adapter(&i2c->adap);
clk_unprepare(i2c->clk); clk_disable_unprepare(i2c->clk);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment