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

Configure Feed

Select the types of activity you want to include in your feed.

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>

+44 -28
+44 -28
drivers/clk/sunxi/clk-sunxi.c
··· 1172 1172 } 1173 1173 } 1174 1174 1175 - /** 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) 1175 + static void __init sunxi_init_clocks(const char *clocks[], int nclocks) 1182 1176 { 1183 - struct clk *clk; 1177 + unsigned int i; 1184 1178 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 - 1196 - static void __init sunxi_init_clocks(struct device_node *np) 1197 - { 1198 1179 /* Register factor clocks */ 1199 1180 of_sunxi_table_clock_setup(clk_factors_match, sunxi_factors_clk_setup); 1200 1181 ··· 1191 1210 /* Register gate clocks */ 1192 1211 of_sunxi_table_clock_setup(clk_gates_match, sunxi_gates_clk_setup); 1193 1212 1194 - /* Enable core system clocks */ 1195 - sunxi_clock_protect(); 1213 + /* Protect the clocks that needs to stay on */ 1214 + for (i = 0; i < nclocks; i++) { 1215 + struct clk *clk = clk_get(NULL, clocks[i]); 1216 + 1217 + if (!IS_ERR(clk)) 1218 + clk_prepare_enable(clk); 1219 + } 1196 1220 } 1197 - CLK_OF_DECLARE(sun4i_a10_clk_init, "allwinner,sun4i-a10", sunxi_init_clocks); 1198 - CLK_OF_DECLARE(sun5i_a10s_clk_init, "allwinner,sun5i-a10s", sunxi_init_clocks); 1199 - CLK_OF_DECLARE(sun5i_a13_clk_init, "allwinner,sun5i-a13", sunxi_init_clocks); 1200 - CLK_OF_DECLARE(sun6i_a31_clk_init, "allwinner,sun6i-a31", sunxi_init_clocks); 1201 - CLK_OF_DECLARE(sun7i_a20_clk_init, "allwinner,sun7i-a20", sunxi_init_clocks); 1221 + 1222 + static const char *sun4i_a10_critical_clocks[] __initdata = { 1223 + "pll5_ddr", 1224 + }; 1225 + 1226 + static void __init sun4i_a10_init_clocks(struct device_node *node) 1227 + { 1228 + sunxi_init_clocks(sun4i_a10_critical_clocks, 1229 + ARRAY_SIZE(sun4i_a10_critical_clocks)); 1230 + } 1231 + CLK_OF_DECLARE(sun4i_a10_clk_init, "allwinner,sun4i-a10", sun4i_a10_init_clocks); 1232 + 1233 + static const char *sun5i_critical_clocks[] __initdata = { 1234 + "mbus", 1235 + "pll5_ddr", 1236 + }; 1237 + 1238 + static void __init sun5i_init_clocks(struct device_node *node) 1239 + { 1240 + sunxi_init_clocks(sun5i_critical_clocks, 1241 + ARRAY_SIZE(sun5i_critical_clocks)); 1242 + } 1243 + CLK_OF_DECLARE(sun5i_a10s_clk_init, "allwinner,sun5i-a10s", sun5i_init_clocks); 1244 + CLK_OF_DECLARE(sun5i_a13_clk_init, "allwinner,sun5i-a13", sun5i_init_clocks); 1245 + CLK_OF_DECLARE(sun7i_a20_clk_init, "allwinner,sun7i-a20", sun5i_init_clocks); 1246 + 1247 + static const char *sun6i_critical_clocks[] __initdata = { 1248 + }; 1249 + 1250 + static void __init sun6i_init_clocks(struct device_node *node) 1251 + { 1252 + sunxi_init_clocks(sun6i_critical_clocks, 1253 + ARRAY_SIZE(sun6i_critical_clocks)); 1254 + } 1255 + CLK_OF_DECLARE(sun6i_a31_clk_init, "allwinner,sun6i-a31", sun6i_init_clocks);