diff options
author | Maxime Ripard <maxime.ripard@free-electrons.com> | 2014-05-09 23:33:39 -0400 |
---|---|---|
committer | Maxime Ripard <maxime.ripard@free-electrons.com> | 2014-06-11 04:25:01 -0400 |
commit | 134a6690a3caf6d52d0bc1b643650c6051c791d2 (patch) | |
tree | 5c538a36fcad37b35db9e3c2b69f8ab61c1adc09 /drivers/clk | |
parent | 59cb10e32a60533865e26dc9a8303306ba972a70 (diff) |
clk: sunxi: Rework clock protection code
Since we start to have a lot of clocks to protect, some of them in a
few SoCs only, it becomes difficult to handle the clock protection
without having to add per machine exceptions.
Add per-SoC data to tell which clock to leave enabled.
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Emilio López <emilio@elopez.com.ar>
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/sunxi/clk-sunxi.c | 72 |
1 files changed, 44 insertions, 28 deletions
diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c index 880095048d4d..4e8ff4565e59 100644 --- a/drivers/clk/sunxi/clk-sunxi.c +++ b/drivers/clk/sunxi/clk-sunxi.c | |||
@@ -1172,29 +1172,10 @@ static void __init of_sunxi_table_clock_setup(const struct of_device_id *clk_mat | |||
1172 | } | 1172 | } |
1173 | } | 1173 | } |
1174 | 1174 | ||
1175 | /** | 1175 | static void __init sunxi_init_clocks(const char *clocks[], int nclocks) |
1176 | * System clock protection | ||
1177 | * | ||
1178 | * By enabling these critical clocks, we prevent their accidental gating | ||
1179 | * by the framework | ||
1180 | */ | ||
1181 | static void __init sunxi_clock_protect(void) | ||
1182 | { | 1176 | { |
1183 | struct clk *clk; | 1177 | unsigned int i; |
1184 | |||
1185 | /* memory bus clock - sun5i+ */ | ||
1186 | clk = clk_get(NULL, "mbus"); | ||
1187 | if (!IS_ERR(clk)) | ||
1188 | clk_prepare_enable(clk); | ||
1189 | |||
1190 | /* DDR clock - sun4i+ */ | ||
1191 | clk = clk_get(NULL, "pll5_ddr"); | ||
1192 | if (!IS_ERR(clk)) | ||
1193 | clk_prepare_enable(clk); | ||
1194 | } | ||
1195 | 1178 | ||
1196 | static void __init sunxi_init_clocks(struct device_node *np) | ||
1197 | { | ||
1198 | /* Register factor clocks */ | 1179 | /* Register factor clocks */ |
1199 | of_sunxi_table_clock_setup(clk_factors_match, sunxi_factors_clk_setup); | 1180 | of_sunxi_table_clock_setup(clk_factors_match, sunxi_factors_clk_setup); |
1200 | 1181 | ||
@@ -1210,11 +1191,46 @@ static void __init sunxi_init_clocks(struct device_node *np) | |||
1210 | /* Register gate clocks */ | 1191 | /* Register gate clocks */ |
1211 | of_sunxi_table_clock_setup(clk_gates_match, sunxi_gates_clk_setup); | 1192 | of_sunxi_table_clock_setup(clk_gates_match, sunxi_gates_clk_setup); |
1212 | 1193 | ||
1213 | /* Enable core system clocks */ | 1194 | /* Protect the clocks that needs to stay on */ |
1214 | sunxi_clock_protect(); | 1195 | for (i = 0; i < nclocks; i++) { |
1196 | struct clk *clk = clk_get(NULL, clocks[i]); | ||
1197 | |||
1198 | if (!IS_ERR(clk)) | ||
1199 | clk_prepare_enable(clk); | ||
1200 | } | ||
1201 | } | ||
1202 | |||
1203 | static const char *sun4i_a10_critical_clocks[] __initdata = { | ||
1204 | "pll5_ddr", | ||
1205 | }; | ||
1206 | |||
1207 | static void __init sun4i_a10_init_clocks(struct device_node *node) | ||
1208 | { | ||
1209 | sunxi_init_clocks(sun4i_a10_critical_clocks, | ||
1210 | ARRAY_SIZE(sun4i_a10_critical_clocks)); | ||
1211 | } | ||
1212 | CLK_OF_DECLARE(sun4i_a10_clk_init, "allwinner,sun4i-a10", sun4i_a10_init_clocks); | ||
1213 | |||
1214 | static const char *sun5i_critical_clocks[] __initdata = { | ||
1215 | "mbus", | ||
1216 | "pll5_ddr", | ||
1217 | }; | ||
1218 | |||
1219 | static void __init sun5i_init_clocks(struct device_node *node) | ||
1220 | { | ||
1221 | sunxi_init_clocks(sun5i_critical_clocks, | ||
1222 | ARRAY_SIZE(sun5i_critical_clocks)); | ||
1223 | } | ||
1224 | CLK_OF_DECLARE(sun5i_a10s_clk_init, "allwinner,sun5i-a10s", sun5i_init_clocks); | ||
1225 | CLK_OF_DECLARE(sun5i_a13_clk_init, "allwinner,sun5i-a13", sun5i_init_clocks); | ||
1226 | CLK_OF_DECLARE(sun7i_a20_clk_init, "allwinner,sun7i-a20", sun5i_init_clocks); | ||
1227 | |||
1228 | static const char *sun6i_critical_clocks[] __initdata = { | ||
1229 | }; | ||
1230 | |||
1231 | static void __init sun6i_init_clocks(struct device_node *node) | ||
1232 | { | ||
1233 | sunxi_init_clocks(sun6i_critical_clocks, | ||
1234 | ARRAY_SIZE(sun6i_critical_clocks)); | ||
1215 | } | 1235 | } |
1216 | CLK_OF_DECLARE(sun4i_a10_clk_init, "allwinner,sun4i-a10", sunxi_init_clocks); | 1236 | CLK_OF_DECLARE(sun6i_a31_clk_init, "allwinner,sun6i-a31", sun6i_init_clocks); |
1217 | CLK_OF_DECLARE(sun5i_a10s_clk_init, "allwinner,sun5i-a10s", sunxi_init_clocks); | ||
1218 | CLK_OF_DECLARE(sun5i_a13_clk_init, "allwinner,sun5i-a13", sunxi_init_clocks); | ||
1219 | CLK_OF_DECLARE(sun6i_a31_clk_init, "allwinner,sun6i-a31", sunxi_init_clocks); | ||
1220 | CLK_OF_DECLARE(sun7i_a20_clk_init, "allwinner,sun7i-a20", sunxi_init_clocks); | ||