Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20200107165957.672435-1-maxime@cerno.tech

+9
+9
drivers/gpu/drm/sun4i/sun4i_backend.c
··· 856 856 ret = PTR_ERR(backend->mod_clk); 857 857 goto err_disable_bus_clk; 858 858 } 859 + 860 + ret = clk_set_rate_exclusive(backend->mod_clk, 300000000); 861 + if (ret) { 862 + dev_err(dev, "Couldn't set the module clock frequency\n"); 863 + goto err_disable_bus_clk; 864 + } 865 + 859 866 clk_prepare_enable(backend->mod_clk); 860 867 861 868 backend->ram_clk = devm_clk_get(dev, "ram"); ··· 939 932 err_disable_ram_clk: 940 933 clk_disable_unprepare(backend->ram_clk); 941 934 err_disable_mod_clk: 935 + clk_rate_exclusive_put(backend->mod_clk); 942 936 clk_disable_unprepare(backend->mod_clk); 943 937 err_disable_bus_clk: 944 938 clk_disable_unprepare(backend->bus_clk); ··· 960 952 sun4i_backend_free_sat(dev); 961 953 962 954 clk_disable_unprepare(backend->ram_clk); 955 + clk_rate_exclusive_put(backend->mod_clk); 963 956 clk_disable_unprepare(backend->mod_clk); 964 957 clk_disable_unprepare(backend->bus_clk); 965 958 reset_control_assert(backend->reset);