Commit 451debe5 authored by Maxime Ripard's avatar Maxime Ripard

drm/sun4i: backend: Make sure we enforce the clock rate

The backend needs to run at 300MHz to be functional. This was done so far
using assigned-clocks in the device tree, but that is easy to forget, and
doesn't provide any other guarantee than the rate is going to be roughly
the one requested at probe time.

Therefore it's pretty fragile, so let's just use the exclusive clock API to
enforce it.
Reviewed-by: default avatarChen-Yu Tsai <wens@csie.org>
Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20200107165957.672435-1-maxime@cerno.tech
parent f66ff55a
...@@ -856,6 +856,13 @@ static int sun4i_backend_bind(struct device *dev, struct device *master, ...@@ -856,6 +856,13 @@ static int sun4i_backend_bind(struct device *dev, struct device *master,
ret = PTR_ERR(backend->mod_clk); ret = PTR_ERR(backend->mod_clk);
goto err_disable_bus_clk; goto err_disable_bus_clk;
} }
ret = clk_set_rate_exclusive(backend->mod_clk, 300000000);
if (ret) {
dev_err(dev, "Couldn't set the module clock frequency\n");
goto err_disable_bus_clk;
}
clk_prepare_enable(backend->mod_clk); clk_prepare_enable(backend->mod_clk);
backend->ram_clk = devm_clk_get(dev, "ram"); backend->ram_clk = devm_clk_get(dev, "ram");
...@@ -932,6 +939,7 @@ static int sun4i_backend_bind(struct device *dev, struct device *master, ...@@ -932,6 +939,7 @@ static int sun4i_backend_bind(struct device *dev, struct device *master,
err_disable_ram_clk: err_disable_ram_clk:
clk_disable_unprepare(backend->ram_clk); clk_disable_unprepare(backend->ram_clk);
err_disable_mod_clk: err_disable_mod_clk:
clk_rate_exclusive_put(backend->mod_clk);
clk_disable_unprepare(backend->mod_clk); clk_disable_unprepare(backend->mod_clk);
err_disable_bus_clk: err_disable_bus_clk:
clk_disable_unprepare(backend->bus_clk); clk_disable_unprepare(backend->bus_clk);
...@@ -952,6 +960,7 @@ static void sun4i_backend_unbind(struct device *dev, struct device *master, ...@@ -952,6 +960,7 @@ static void sun4i_backend_unbind(struct device *dev, struct device *master,
sun4i_backend_free_sat(dev); sun4i_backend_free_sat(dev);
clk_disable_unprepare(backend->ram_clk); clk_disable_unprepare(backend->ram_clk);
clk_rate_exclusive_put(backend->mod_clk);
clk_disable_unprepare(backend->mod_clk); clk_disable_unprepare(backend->mod_clk);
clk_disable_unprepare(backend->bus_clk); clk_disable_unprepare(backend->bus_clk);
reset_control_assert(backend->reset); reset_control_assert(backend->reset);
......
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