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

clk: sunxi: Move mbus to mod0 file

Move the MBUS clock to the module clocks file. It's pretty trivial, but still
requires to enable the clocks to make sure it won't get disabled.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>

+12 -57
+12
drivers/clk/sunxi/clk-mod0.c
··· 80 80 sunxi_factors_register(node, &sun4i_a10_mod0_data, &sun4i_a10_mod0_lock); 81 81 } 82 82 CLK_OF_DECLARE(sun4i_a10_mod0, "allwinner,sun4i-a10-mod0-clk", sun4i_a10_mod0_setup); 83 + 84 + static DEFINE_SPINLOCK(sun5i_a13_mbus_lock); 85 + 86 + static void __init sun5i_a13_mbus_setup(struct device_node *node) 87 + { 88 + struct clk *mbus = sunxi_factors_register(node, &sun4i_a10_mod0_data, &sun5i_a13_mbus_lock); 89 + 90 + /* The MBUS clocks needs to be always enabled */ 91 + __clk_get(mbus); 92 + clk_prepare_enable(mbus); 93 + } 94 + CLK_OF_DECLARE(sun5i_a13_mbus, "allwinner,sun5i-a13-mbus-clk", sun5i_a13_mbus_setup);
-57
drivers/clk/sunxi/clk-sunxi.c
··· 320 320 321 321 322 322 323 - /** 324 - * sun4i_get_mod0_factors() - calculates m, n factors for MOD0-style clocks 325 - * MOD0 rate is calculated as follows 326 - * rate = (parent_rate >> p) / (m + 1); 327 - */ 328 - 329 - static void sun4i_get_mod0_factors(u32 *freq, u32 parent_rate, 330 - u8 *n, u8 *k, u8 *m, u8 *p) 331 - { 332 - u8 div, calcm, calcp; 333 - 334 - /* These clocks can only divide, so we will never be able to achieve 335 - * frequencies higher than the parent frequency */ 336 - if (*freq > parent_rate) 337 - *freq = parent_rate; 338 - 339 - div = DIV_ROUND_UP(parent_rate, *freq); 340 - 341 - if (div < 16) 342 - calcp = 0; 343 - else if (div / 2 < 16) 344 - calcp = 1; 345 - else if (div / 4 < 16) 346 - calcp = 2; 347 - else 348 - calcp = 3; 349 - 350 - calcm = DIV_ROUND_UP(div, 1 << calcp); 351 - 352 - *freq = (parent_rate >> calcp) / calcm; 353 - 354 - /* we were called to round the frequency, we can now return */ 355 - if (n == NULL) 356 - return; 357 - 358 - *m = calcm - 1; 359 - *p = calcp; 360 - } 361 - 362 - 363 323 364 324 /** 365 325 * sun7i_a20_get_out_factors() - calculates m, p factors for CLK_OUT_A/B ··· 455 495 }; 456 496 457 497 /* user manual says "n" but it's really "p" */ 458 - static struct clk_factors_config sun4i_mod0_config = { 459 - .mshift = 0, 460 - .mwidth = 4, 461 - .pshift = 16, 462 - .pwidth = 2, 463 - }; 464 - 465 - /* user manual says "n" but it's really "p" */ 466 498 static struct clk_factors_config sun7i_a20_out_config = { 467 499 .mshift = 8, 468 500 .mwidth = 5, ··· 509 557 static const struct factors_data sun4i_apb1_data __initconst = { 510 558 .table = &sun4i_apb1_config, 511 559 .getter = sun4i_get_apb1_factors, 512 - }; 513 - 514 - static const struct factors_data sun4i_mod0_data __initconst = { 515 - .enable = 31, 516 - .mux = 24, 517 - .table = &sun4i_mod0_config, 518 - .getter = sun4i_get_mod0_factors, 519 560 }; 520 561 521 562 static const struct factors_data sun7i_a20_out_data __initconst = { ··· 1064 1119 {.compatible = "allwinner,sun7i-a20-pll4-clk", .data = &sun7i_a20_pll4_data,}, 1065 1120 {.compatible = "allwinner,sun6i-a31-pll6-clk", .data = &sun6i_a31_pll6_data,}, 1066 1121 {.compatible = "allwinner,sun4i-a10-apb1-clk", .data = &sun4i_apb1_data,}, 1067 - {.compatible = "allwinner,sun5i-a13-mbus-clk", .data = &sun4i_mod0_data,}, 1068 1122 {.compatible = "allwinner,sun7i-a20-out-clk", .data = &sun7i_a20_out_data,}, 1069 1123 {} 1070 1124 }; ··· 1175 1231 CLK_OF_DECLARE(sun4i_a10_clk_init, "allwinner,sun4i-a10", sun4i_a10_init_clocks); 1176 1232 1177 1233 static const char *sun5i_critical_clocks[] __initdata = { 1178 - "mbus", 1179 1234 "pll5_ddr", 1180 1235 "ahb_sdram", 1181 1236 };