aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Turquette <mturquette@baylibre.com>2016-02-15 14:59:45 -0500
committerMichael Turquette <mturquette@baylibre.com>2016-02-15 14:59:45 -0500
commit70750ff2c91049beca635e0a31ac19f8b54aebee (patch)
treebd63e9999741ecda668f74bdd83d97432eac0aea
parent7208d1d9c568de02ca89cc976d206e4196803140 (diff)
parent36714529f8bbd4f8eaf93b50f4a64c52a24879aa (diff)
Merge tag 'v4.6-rockchip-clk1' of git://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip into clk-next
Introduction of a factor type and a variant containing a gate to be able to also declare factor clocks in their correct place in the clock tree instead of having to register factor clocks in the init callback separately. And as always some more clock-ids and non-regression fixes for mistakes introduced in past kernel releases.
-rw-r--r--arch/arm/boot/dts/rk3288-veyron.dtsi2
-rw-r--r--drivers/clk/rockchip/clk-rk3036.c33
-rw-r--r--drivers/clk/rockchip/clk-rk3188.c27
-rw-r--r--drivers/clk/rockchip/clk-rk3228.c38
-rw-r--r--drivers/clk/rockchip/clk-rk3288.c38
-rw-r--r--drivers/clk/rockchip/clk-rk3368.c82
-rw-r--r--drivers/clk/rockchip/clk.c64
-rw-r--r--drivers/clk/rockchip/clk.h28
-rw-r--r--include/dt-bindings/clock/rk3188-cru-common.h1
9 files changed, 159 insertions, 154 deletions
diff --git a/arch/arm/boot/dts/rk3288-veyron.dtsi b/arch/arm/boot/dts/rk3288-veyron.dtsi
index 9fce91ffff6f..cb27a8f5a8e2 100644
--- a/arch/arm/boot/dts/rk3288-veyron.dtsi
+++ b/arch/arm/boot/dts/rk3288-veyron.dtsi
@@ -421,7 +421,7 @@
421 status = "okay"; 421 status = "okay";
422 422
423 assigned-clocks = <&cru SCLK_USBPHY480M_SRC>; 423 assigned-clocks = <&cru SCLK_USBPHY480M_SRC>;
424 assigned-clock-parents = <&cru SCLK_OTGPHY0>; 424 assigned-clock-parents = <&usbphy0>;
425 dr_mode = "host"; 425 dr_mode = "host";
426}; 426};
427 427
diff --git a/drivers/clk/rockchip/clk-rk3036.c b/drivers/clk/rockchip/clk-rk3036.c
index bc7fbac83ab7..0703c8f08ef8 100644
--- a/drivers/clk/rockchip/clk-rk3036.c
+++ b/drivers/clk/rockchip/clk-rk3036.c
@@ -177,6 +177,8 @@ static struct rockchip_clk_branch rk3036_clk_branches[] __initdata = {
177 GATE(0, "gpll_armclk", "gpll", CLK_IGNORE_UNUSED, 177 GATE(0, "gpll_armclk", "gpll", CLK_IGNORE_UNUSED,
178 RK2928_CLKGATE_CON(0), 6, GFLAGS), 178 RK2928_CLKGATE_CON(0), 6, GFLAGS),
179 179
180 FACTOR(0, "xin12m", "xin24m", 0, 1, 2),
181
180 /* 182 /*
181 * Clock-Architecture Diagram 2 183 * Clock-Architecture Diagram 2
182 */ 184 */
@@ -187,6 +189,7 @@ static struct rockchip_clk_branch rk3036_clk_branches[] __initdata = {
187 RK2928_CLKGATE_CON(0), 8, GFLAGS), 189 RK2928_CLKGATE_CON(0), 8, GFLAGS),
188 COMPOSITE_NOGATE(0, "ddrphy2x", mux_ddrphy_p, CLK_IGNORE_UNUSED, 190 COMPOSITE_NOGATE(0, "ddrphy2x", mux_ddrphy_p, CLK_IGNORE_UNUSED,
189 RK2928_CLKSEL_CON(26), 8, 1, MFLAGS, 0, 2, DFLAGS | CLK_DIVIDER_POWER_OF_TWO), 191 RK2928_CLKSEL_CON(26), 8, 1, MFLAGS, 0, 2, DFLAGS | CLK_DIVIDER_POWER_OF_TWO),
192 FACTOR(0, "ddrphy", "ddrphy2x", 0, 1, 2),
190 193
191 COMPOSITE_NOMUX(0, "pclk_dbg", "armclk", CLK_IGNORE_UNUSED, 194 COMPOSITE_NOMUX(0, "pclk_dbg", "armclk", CLK_IGNORE_UNUSED,
192 RK2928_CLKSEL_CON(1), 0, 4, DFLAGS | CLK_DIVIDER_READ_ONLY, 195 RK2928_CLKSEL_CON(1), 0, 4, DFLAGS | CLK_DIVIDER_READ_ONLY,
@@ -263,6 +266,8 @@ static struct rockchip_clk_branch rk3036_clk_branches[] __initdata = {
263 COMPOSITE(0, "aclk_vcodec", mux_pll_src_3plls_p, 0, 266 COMPOSITE(0, "aclk_vcodec", mux_pll_src_3plls_p, 0,
264 RK2928_CLKSEL_CON(32), 14, 2, MFLAGS, 8, 5, DFLAGS, 267 RK2928_CLKSEL_CON(32), 14, 2, MFLAGS, 8, 5, DFLAGS,
265 RK2928_CLKGATE_CON(3), 11, GFLAGS), 268 RK2928_CLKGATE_CON(3), 11, GFLAGS),
269 FACTOR_GATE(HCLK_VCODEC, "hclk_vcodec", "aclk_vcodec", 0, 1, 4,
270 RK2928_CLKGATE_CON(3), 12, GFLAGS),
266 271
267 COMPOSITE(0, "aclk_hvec", mux_pll_src_3plls_p, 0, 272 COMPOSITE(0, "aclk_hvec", mux_pll_src_3plls_p, 0,
268 RK2928_CLKSEL_CON(20), 0, 2, MFLAGS, 2, 5, DFLAGS, 273 RK2928_CLKSEL_CON(20), 0, 2, MFLAGS, 2, 5, DFLAGS,
@@ -351,6 +356,7 @@ static struct rockchip_clk_branch rk3036_clk_branches[] __initdata = {
351 COMPOSITE_NOMUX(SCLK_MAC, "mac_clk", "mac_clk_ref", 0, 356 COMPOSITE_NOMUX(SCLK_MAC, "mac_clk", "mac_clk_ref", 0,
352 RK2928_CLKSEL_CON(21), 4, 5, DFLAGS, 357 RK2928_CLKSEL_CON(21), 4, 5, DFLAGS,
353 RK2928_CLKGATE_CON(2), 6, GFLAGS), 358 RK2928_CLKGATE_CON(2), 6, GFLAGS),
359 FACTOR(0, "sclk_macref_out", "hclk_peri_src", 0, 1, 2),
354 360
355 MUX(SCLK_HDMI, "dclk_hdmi", mux_dclk_p, 0, 361 MUX(SCLK_HDMI, "dclk_hdmi", mux_dclk_p, 0,
356 RK2928_CLKSEL_CON(31), 0, 1, MFLAGS), 362 RK2928_CLKSEL_CON(31), 0, 1, MFLAGS),
@@ -376,11 +382,9 @@ static struct rockchip_clk_branch rk3036_clk_branches[] __initdata = {
376 GATE(ACLK_VIO, "aclk_vio", "aclk_disp1_pre", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(6), 13, GFLAGS), 382 GATE(ACLK_VIO, "aclk_vio", "aclk_disp1_pre", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(6), 13, GFLAGS),
377 GATE(ACLK_LCDC, "aclk_lcdc", "aclk_disp1_pre", 0, RK2928_CLKGATE_CON(9), 6, GFLAGS), 383 GATE(ACLK_LCDC, "aclk_lcdc", "aclk_disp1_pre", 0, RK2928_CLKGATE_CON(9), 6, GFLAGS),
378 384
379 GATE(HCLK_VIO_BUS, "hclk_vio_bus", "hclk_disp_pre", 0, RK2928_CLKGATE_CON(6), 12, GFLAGS), 385 GATE(HCLK_VIO_BUS, "hclk_vio_bus", "hclk_disp_pre", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(6), 12, GFLAGS),
380 GATE(HCLK_LCDC, "hclk_lcdc", "hclk_disp_pre", 0, RK2928_CLKGATE_CON(9), 5, GFLAGS), 386 GATE(HCLK_LCDC, "hclk_lcdc", "hclk_disp_pre", 0, RK2928_CLKGATE_CON(9), 5, GFLAGS),
381 387
382 /* hclk_video gates */
383 GATE(HCLK_VCODEC, "hclk_vcodec", "hclk_disp_pre", 0, RK2928_CLKGATE_CON(3), 12, GFLAGS),
384 388
385 /* xin24m gates */ 389 /* xin24m gates */
386 GATE(SCLK_PVTM_CORE, "sclk_pvtm_core", "xin24m", 0, RK2928_CLKGATE_CON(10), 0, GFLAGS), 390 GATE(SCLK_PVTM_CORE, "sclk_pvtm_core", "xin24m", 0, RK2928_CLKGATE_CON(10), 0, GFLAGS),
@@ -444,34 +448,11 @@ static void __init rk3036_clk_init(struct device_node *np)
444 448
445 rockchip_clk_init(np, reg_base, CLK_NR_CLKS); 449 rockchip_clk_init(np, reg_base, CLK_NR_CLKS);
446 450
447 /* xin12m is created by an cru-internal divider */
448 clk = clk_register_fixed_factor(NULL, "xin12m", "xin24m", 0, 1, 2);
449 if (IS_ERR(clk))
450 pr_warn("%s: could not register clock xin12m: %ld\n",
451 __func__, PTR_ERR(clk));
452
453 clk = clk_register_fixed_factor(NULL, "usb480m", "xin24m", 0, 20, 1); 451 clk = clk_register_fixed_factor(NULL, "usb480m", "xin24m", 0, 20, 1);
454 if (IS_ERR(clk)) 452 if (IS_ERR(clk))
455 pr_warn("%s: could not register clock usb480m: %ld\n", 453 pr_warn("%s: could not register clock usb480m: %ld\n",
456 __func__, PTR_ERR(clk)); 454 __func__, PTR_ERR(clk));
457 455
458 clk = clk_register_fixed_factor(NULL, "ddrphy", "ddrphy2x", 0, 1, 2);
459 if (IS_ERR(clk))
460 pr_warn("%s: could not register clock ddrphy: %ld\n",
461 __func__, PTR_ERR(clk));
462
463 clk = clk_register_fixed_factor(NULL, "hclk_vcodec_pre",
464 "aclk_vcodec", 0, 1, 4);
465 if (IS_ERR(clk))
466 pr_warn("%s: could not register clock hclk_vcodec_pre: %ld\n",
467 __func__, PTR_ERR(clk));
468
469 clk = clk_register_fixed_factor(NULL, "sclk_macref_out",
470 "hclk_peri_src", 0, 1, 2);
471 if (IS_ERR(clk))
472 pr_warn("%s: could not register clock sclk_macref_out: %ld\n",
473 __func__, PTR_ERR(clk));
474
475 rockchip_clk_register_plls(rk3036_pll_clks, 456 rockchip_clk_register_plls(rk3036_pll_clks,
476 ARRAY_SIZE(rk3036_pll_clks), 457 ARRAY_SIZE(rk3036_pll_clks),
477 RK3036_GRF_SOC_STATUS0); 458 RK3036_GRF_SOC_STATUS0);
diff --git a/drivers/clk/rockchip/clk-rk3188.c b/drivers/clk/rockchip/clk-rk3188.c
index 7f7444cbf6fc..40bab3901491 100644
--- a/drivers/clk/rockchip/clk-rk3188.c
+++ b/drivers/clk/rockchip/clk-rk3188.c
@@ -339,13 +339,15 @@ static struct rockchip_clk_branch common_clk_branches[] __initdata = {
339 INVERTER(0, "pclk_cif0", "pclkin_cif0", 339 INVERTER(0, "pclk_cif0", "pclkin_cif0",
340 RK2928_CLKSEL_CON(30), 8, IFLAGS), 340 RK2928_CLKSEL_CON(30), 8, IFLAGS),
341 341
342 FACTOR(0, "xin12m", "xin24m", 0, 1, 2),
343
342 /* 344 /*
343 * the 480m are generated inside the usb block from these clocks, 345 * the 480m are generated inside the usb block from these clocks,
344 * but they are also a source for the hsicphy clock. 346 * but they are also a source for the hsicphy clock.
345 */ 347 */
346 GATE(SCLK_OTGPHY0, "sclk_otgphy0", "usb480m", CLK_IGNORE_UNUSED, 348 GATE(SCLK_OTGPHY0, "sclk_otgphy0", "xin24m", CLK_IGNORE_UNUSED,
347 RK2928_CLKGATE_CON(1), 5, GFLAGS), 349 RK2928_CLKGATE_CON(1), 5, GFLAGS),
348 GATE(SCLK_OTGPHY1, "sclk_otgphy1", "usb480m", CLK_IGNORE_UNUSED, 350 GATE(SCLK_OTGPHY1, "sclk_otgphy1", "xin24m", CLK_IGNORE_UNUSED,
349 RK2928_CLKGATE_CON(1), 6, GFLAGS), 351 RK2928_CLKGATE_CON(1), 6, GFLAGS),
350 352
351 COMPOSITE(0, "mac_src", mux_mac_p, 0, 353 COMPOSITE(0, "mac_src", mux_mac_p, 0,
@@ -605,7 +607,7 @@ static struct rockchip_clk_branch rk3066a_clk_branches[] __initdata = {
605 GATE(SCLK_TIMER2, "timer2", "xin24m", 0, 607 GATE(SCLK_TIMER2, "timer2", "xin24m", 0,
606 RK2928_CLKGATE_CON(3), 2, GFLAGS), 608 RK2928_CLKGATE_CON(3), 2, GFLAGS),
607 609
608 COMPOSITE_NOMUX(0, "sclk_tsadc", "xin24m", 0, 610 COMPOSITE_NOMUX(SCLK_TSADC, "sclk_tsadc", "xin24m", 0,
609 RK2928_CLKSEL_CON(34), 0, 16, DFLAGS, 611 RK2928_CLKSEL_CON(34), 0, 16, DFLAGS,
610 RK2928_CLKGATE_CON(2), 15, GFLAGS), 612 RK2928_CLKGATE_CON(2), 15, GFLAGS),
611 613
@@ -662,11 +664,11 @@ static struct clk_div_table div_rk3188_aclk_core_t[] = {
662 { /* sentinel */ }, 664 { /* sentinel */ },
663}; 665};
664 666
665PNAME(mux_hsicphy_p) = { "sclk_otgphy0", "sclk_otgphy1", 667PNAME(mux_hsicphy_p) = { "sclk_otgphy0_480m", "sclk_otgphy1_480m",
666 "gpll", "cpll" }; 668 "gpll", "cpll" };
667 669
668static struct rockchip_clk_branch rk3188_i2s0_fracmux __initdata = 670static struct rockchip_clk_branch rk3188_i2s0_fracmux __initdata =
669 MUX(SCLK_I2S0, "sclk_i2s0", mux_sclk_i2s0_p, 0, 671 MUX(SCLK_I2S0, "sclk_i2s0", mux_sclk_i2s0_p, CLK_SET_RATE_PARENT,
670 RK2928_CLKSEL_CON(3), 8, 2, MFLAGS); 672 RK2928_CLKSEL_CON(3), 8, 2, MFLAGS);
671 673
672static struct rockchip_clk_branch rk3188_clk_branches[] __initdata = { 674static struct rockchip_clk_branch rk3188_clk_branches[] __initdata = {
@@ -722,7 +724,7 @@ static struct rockchip_clk_branch rk3188_clk_branches[] __initdata = {
722 COMPOSITE_NOMUX(0, "i2s0_pre", "i2s_src", 0, 724 COMPOSITE_NOMUX(0, "i2s0_pre", "i2s_src", 0,
723 RK2928_CLKSEL_CON(3), 0, 7, DFLAGS, 725 RK2928_CLKSEL_CON(3), 0, 7, DFLAGS,
724 RK2928_CLKGATE_CON(0), 9, GFLAGS), 726 RK2928_CLKGATE_CON(0), 9, GFLAGS),
725 COMPOSITE_FRACMUX(0, "i2s0_frac", "i2s0_pre", 0, 727 COMPOSITE_FRACMUX(0, "i2s0_frac", "i2s0_pre", CLK_SET_RATE_PARENT,
726 RK2928_CLKSEL_CON(7), 0, 728 RK2928_CLKSEL_CON(7), 0,
727 RK2928_CLKGATE_CON(0), 10, GFLAGS, 729 RK2928_CLKGATE_CON(0), 10, GFLAGS,
728 &rk3188_i2s0_fracmux), 730 &rk3188_i2s0_fracmux),
@@ -748,12 +750,12 @@ static const char *const rk3188_critical_clocks[] __initconst = {
748 "hclk_peri", 750 "hclk_peri",
749 "pclk_cpu", 751 "pclk_cpu",
750 "pclk_peri", 752 "pclk_peri",
753 "hclk_cpubus"
751}; 754};
752 755
753static void __init rk3188_common_clk_init(struct device_node *np) 756static void __init rk3188_common_clk_init(struct device_node *np)
754{ 757{
755 void __iomem *reg_base; 758 void __iomem *reg_base;
756 struct clk *clk;
757 759
758 reg_base = of_iomap(np, 0); 760 reg_base = of_iomap(np, 0);
759 if (!reg_base) { 761 if (!reg_base) {
@@ -763,17 +765,6 @@ static void __init rk3188_common_clk_init(struct device_node *np)
763 765
764 rockchip_clk_init(np, reg_base, CLK_NR_CLKS); 766 rockchip_clk_init(np, reg_base, CLK_NR_CLKS);
765 767
766 /* xin12m is created by an cru-internal divider */
767 clk = clk_register_fixed_factor(NULL, "xin12m", "xin24m", 0, 1, 2);
768 if (IS_ERR(clk))
769 pr_warn("%s: could not register clock xin12m: %ld\n",
770 __func__, PTR_ERR(clk));
771
772 clk = clk_register_fixed_factor(NULL, "usb480m", "xin24m", 0, 20, 1);
773 if (IS_ERR(clk))
774 pr_warn("%s: could not register clock usb480m: %ld\n",
775 __func__, PTR_ERR(clk));
776
777 rockchip_clk_register_branches(common_clk_branches, 768 rockchip_clk_register_branches(common_clk_branches,
778 ARRAY_SIZE(common_clk_branches)); 769 ARRAY_SIZE(common_clk_branches));
779 770
diff --git a/drivers/clk/rockchip/clk-rk3228.c b/drivers/clk/rockchip/clk-rk3228.c
index 981a50205339..c515915850a1 100644
--- a/drivers/clk/rockchip/clk-rk3228.c
+++ b/drivers/clk/rockchip/clk-rk3228.c
@@ -187,7 +187,7 @@ static struct rockchip_clk_branch rk3228_clk_branches[] __initdata = {
187 RK2928_CLKGATE_CON(7), 1, GFLAGS), 187 RK2928_CLKGATE_CON(7), 1, GFLAGS),
188 GATE(0, "ddrc", "ddrphy_pre", CLK_IGNORE_UNUSED, 188 GATE(0, "ddrc", "ddrphy_pre", CLK_IGNORE_UNUSED,
189 RK2928_CLKGATE_CON(8), 5, GFLAGS), 189 RK2928_CLKGATE_CON(8), 5, GFLAGS),
190 GATE(0, "ddrphy", "ddrphy_pre", CLK_IGNORE_UNUSED, 190 FACTOR_GATE(0, "ddrphy", "ddrphy4x", CLK_IGNORE_UNUSED, 1, 4,
191 RK2928_CLKGATE_CON(7), 0, GFLAGS), 191 RK2928_CLKGATE_CON(7), 0, GFLAGS),
192 192
193 /* PD_CORE */ 193 /* PD_CORE */
@@ -240,13 +240,13 @@ static struct rockchip_clk_branch rk3228_clk_branches[] __initdata = {
240 COMPOSITE(0, "aclk_vpu_pre", mux_pll_src_4plls_p, 0, 240 COMPOSITE(0, "aclk_vpu_pre", mux_pll_src_4plls_p, 0,
241 RK2928_CLKSEL_CON(32), 5, 2, MFLAGS, 0, 5, DFLAGS, 241 RK2928_CLKSEL_CON(32), 5, 2, MFLAGS, 0, 5, DFLAGS,
242 RK2928_CLKGATE_CON(3), 11, GFLAGS), 242 RK2928_CLKGATE_CON(3), 11, GFLAGS),
243 GATE(0, "hclk_vpu_src", "aclk_vpu_pre", 0, 243 FACTOR_GATE(0, "hclk_vpu_pre", "aclk_vpu_pre", 0, 1, 4,
244 RK2928_CLKGATE_CON(4), 4, GFLAGS), 244 RK2928_CLKGATE_CON(4), 4, GFLAGS),
245 245
246 COMPOSITE(0, "aclk_rkvdec_pre", mux_pll_src_4plls_p, 0, 246 COMPOSITE(0, "aclk_rkvdec_pre", mux_pll_src_4plls_p, 0,
247 RK2928_CLKSEL_CON(28), 6, 2, MFLAGS, 0, 5, DFLAGS, 247 RK2928_CLKSEL_CON(28), 6, 2, MFLAGS, 0, 5, DFLAGS,
248 RK2928_CLKGATE_CON(3), 2, GFLAGS), 248 RK2928_CLKGATE_CON(3), 2, GFLAGS),
249 GATE(0, "hclk_rkvdec_src", "aclk_rkvdec_pre", 0, 249 FACTOR_GATE(0, "hclk_rkvdec_pre", "aclk_rkvdec_pre", 0, 1, 4,
250 RK2928_CLKGATE_CON(4), 5, GFLAGS), 250 RK2928_CLKGATE_CON(4), 5, GFLAGS),
251 251
252 COMPOSITE(0, "sclk_vdec_cabac", mux_pll_src_4plls_p, 0, 252 COMPOSITE(0, "sclk_vdec_cabac", mux_pll_src_4plls_p, 0,
@@ -371,6 +371,8 @@ static struct rockchip_clk_branch rk3228_clk_branches[] __initdata = {
371 MUX(0, "dclk_vop", mux_dclk_vop_p, 0, 371 MUX(0, "dclk_vop", mux_dclk_vop_p, 0,
372 RK2928_CLKSEL_CON(27), 1, 1, MFLAGS), 372 RK2928_CLKSEL_CON(27), 1, 1, MFLAGS),
373 373
374 FACTOR(0, "xin12m", "xin24m", 0, 1, 2),
375
374 COMPOSITE(0, "i2s0_src", mux_pll_src_2plls_p, 0, 376 COMPOSITE(0, "i2s0_src", mux_pll_src_2plls_p, 0,
375 RK2928_CLKSEL_CON(9), 15, 1, MFLAGS, 0, 7, DFLAGS, 377 RK2928_CLKSEL_CON(9), 15, 1, MFLAGS, 0, 7, DFLAGS,
376 RK2928_CLKGATE_CON(0), 3, GFLAGS), 378 RK2928_CLKGATE_CON(0), 3, GFLAGS),
@@ -605,13 +607,13 @@ static struct rockchip_clk_branch rk3228_clk_branches[] __initdata = {
605 607
606 /* PD_MMC */ 608 /* PD_MMC */
607 MMC(SCLK_SDMMC_DRV, "sdmmc_drv", "sclk_sdmmc", RK3228_SDMMC_CON0, 1), 609 MMC(SCLK_SDMMC_DRV, "sdmmc_drv", "sclk_sdmmc", RK3228_SDMMC_CON0, 1),
608 MMC(SCLK_SDMMC_SAMPLE, "sdmmc_sample", "sclk_sdmmc", RK3228_SDMMC_CON1, 1), 610 MMC(SCLK_SDMMC_SAMPLE, "sdmmc_sample", "sclk_sdmmc", RK3228_SDMMC_CON1, 0),
609 611
610 MMC(SCLK_SDIO_DRV, "sdio_drv", "sclk_sdio", RK3228_SDIO_CON0, 1), 612 MMC(SCLK_SDIO_DRV, "sdio_drv", "sclk_sdio", RK3228_SDIO_CON0, 1),
611 MMC(SCLK_SDIO_SAMPLE, "sdio_sample", "sclk_sdio", RK3228_SDIO_CON1, 1), 613 MMC(SCLK_SDIO_SAMPLE, "sdio_sample", "sclk_sdio", RK3228_SDIO_CON1, 0),
612 614
613 MMC(SCLK_EMMC_DRV, "emmc_drv", "sclk_emmc", RK3228_EMMC_CON0, 1), 615 MMC(SCLK_EMMC_DRV, "emmc_drv", "sclk_emmc", RK3228_EMMC_CON0, 1),
614 MMC(SCLK_EMMC_SAMPLE, "emmc_sample", "sclk_emmc", RK3228_EMMC_CON1, 1), 616 MMC(SCLK_EMMC_SAMPLE, "emmc_sample", "sclk_emmc", RK3228_EMMC_CON1, 0),
615}; 617};
616 618
617static const char *const rk3228_critical_clocks[] __initconst = { 619static const char *const rk3228_critical_clocks[] __initconst = {
@@ -624,7 +626,6 @@ static const char *const rk3228_critical_clocks[] __initconst = {
624static void __init rk3228_clk_init(struct device_node *np) 626static void __init rk3228_clk_init(struct device_node *np)
625{ 627{
626 void __iomem *reg_base; 628 void __iomem *reg_base;
627 struct clk *clk;
628 629
629 reg_base = of_iomap(np, 0); 630 reg_base = of_iomap(np, 0);
630 if (!reg_base) { 631 if (!reg_base) {
@@ -634,29 +635,6 @@ static void __init rk3228_clk_init(struct device_node *np)
634 635
635 rockchip_clk_init(np, reg_base, CLK_NR_CLKS); 636 rockchip_clk_init(np, reg_base, CLK_NR_CLKS);
636 637
637 /* xin12m is created by an cru-internal divider */
638 clk = clk_register_fixed_factor(NULL, "xin12m", "xin24m", 0, 1, 2);
639 if (IS_ERR(clk))
640 pr_warn("%s: could not register clock xin12m: %ld\n",
641 __func__, PTR_ERR(clk));
642
643 clk = clk_register_fixed_factor(NULL, "ddrphy_pre", "ddrphy4x", 0, 1, 4);
644 if (IS_ERR(clk))
645 pr_warn("%s: could not register clock ddrphy_pre: %ld\n",
646 __func__, PTR_ERR(clk));
647
648 clk = clk_register_fixed_factor(NULL, "hclk_vpu_pre",
649 "hclk_vpu_src", 0, 1, 4);
650 if (IS_ERR(clk))
651 pr_warn("%s: could not register clock hclk_vpu_pre: %ld\n",
652 __func__, PTR_ERR(clk));
653
654 clk = clk_register_fixed_factor(NULL, "hclk_rkvdec_pre",
655 "hclk_rkvdec_src", 0, 1, 4);
656 if (IS_ERR(clk))
657 pr_warn("%s: could not register clock hclk_rkvdec_pre: %ld\n",
658 __func__, PTR_ERR(clk));
659
660 rockchip_clk_register_plls(rk3228_pll_clks, 638 rockchip_clk_register_plls(rk3228_pll_clks,
661 ARRAY_SIZE(rk3228_pll_clks), 639 ARRAY_SIZE(rk3228_pll_clks),
662 RK3228_GRF_SOC_STATUS0); 640 RK3228_GRF_SOC_STATUS0);
diff --git a/drivers/clk/rockchip/clk-rk3288.c b/drivers/clk/rockchip/clk-rk3288.c
index 984fc187d12e..3cb72163a512 100644
--- a/drivers/clk/rockchip/clk-rk3288.c
+++ b/drivers/clk/rockchip/clk-rk3288.c
@@ -195,8 +195,8 @@ PNAME(mux_hsadcout_p) = { "hsadc_src", "ext_hsadc" };
195PNAME(mux_edp_24m_p) = { "ext_edp_24m", "xin24m" }; 195PNAME(mux_edp_24m_p) = { "ext_edp_24m", "xin24m" };
196PNAME(mux_tspout_p) = { "cpll", "gpll", "npll", "xin27m" }; 196PNAME(mux_tspout_p) = { "cpll", "gpll", "npll", "xin27m" };
197 197
198PNAME(mux_usbphy480m_p) = { "sclk_otgphy1", "sclk_otgphy2", 198PNAME(mux_usbphy480m_p) = { "sclk_otgphy1_480m", "sclk_otgphy2_480m",
199 "sclk_otgphy0" }; 199 "sclk_otgphy0_480m" };
200PNAME(mux_hsicphy480m_p) = { "cpll", "gpll", "usbphy480m_src" }; 200PNAME(mux_hsicphy480m_p) = { "cpll", "gpll", "usbphy480m_src" };
201PNAME(mux_hsicphy12m_p) = { "hsicphy12m_xin12m", "hsicphy12m_usbphy" }; 201PNAME(mux_hsicphy12m_p) = { "hsicphy12m_xin12m", "hsicphy12m_usbphy" };
202 202
@@ -333,6 +333,8 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {
333 GATE(0, "aclk_bus_2pmu", "aclk_cpu_pre", CLK_IGNORE_UNUSED, 333 GATE(0, "aclk_bus_2pmu", "aclk_cpu_pre", CLK_IGNORE_UNUSED,
334 RK3288_CLKGATE_CON(0), 7, GFLAGS), 334 RK3288_CLKGATE_CON(0), 7, GFLAGS),
335 335
336 FACTOR(0, "xin12m", "xin24m", 0, 1, 2),
337
336 COMPOSITE(0, "i2s_src", mux_pll_src_cpll_gpll_p, 0, 338 COMPOSITE(0, "i2s_src", mux_pll_src_cpll_gpll_p, 0,
337 RK3288_CLKSEL_CON(4), 15, 1, MFLAGS, 0, 7, DFLAGS, 339 RK3288_CLKSEL_CON(4), 15, 1, MFLAGS, 0, 7, DFLAGS,
338 RK3288_CLKGATE_CON(4), 1, GFLAGS), 340 RK3288_CLKGATE_CON(4), 1, GFLAGS),
@@ -399,12 +401,10 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {
399 */ 401 */
400 GATE(ACLK_VCODEC, "aclk_vcodec", "aclk_vdpu", 0, 402 GATE(ACLK_VCODEC, "aclk_vcodec", "aclk_vdpu", 0,
401 RK3288_CLKGATE_CON(9), 0, GFLAGS), 403 RK3288_CLKGATE_CON(9), 0, GFLAGS),
402 /* 404
403 * We introduce a virtul node of hclk_vodec_pre_v to split one clock 405 FACTOR_GATE(0, "hclk_vcodec_pre", "aclk_vdpu", 0, 1, 4,
404 * struct with a gate and a fix divider into two node in software.
405 */
406 GATE(0, "hclk_vcodec_pre_v", "aclk_vdpu", 0,
407 RK3288_CLKGATE_CON(3), 10, GFLAGS), 406 RK3288_CLKGATE_CON(3), 10, GFLAGS),
407
408 GATE(HCLK_VCODEC, "hclk_vcodec", "hclk_vcodec_pre", 0, 408 GATE(HCLK_VCODEC, "hclk_vcodec", "hclk_vcodec_pre", 0,
409 RK3288_CLKGATE_CON(9), 1, GFLAGS), 409 RK3288_CLKGATE_CON(9), 1, GFLAGS),
410 410
@@ -537,11 +537,11 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {
537 RK3288_CLKSEL_CON(35), 6, 2, MFLAGS, 0, 5, DFLAGS, 537 RK3288_CLKSEL_CON(35), 6, 2, MFLAGS, 0, 5, DFLAGS,
538 RK3288_CLKGATE_CON(4), 10, GFLAGS), 538 RK3288_CLKGATE_CON(4), 10, GFLAGS),
539 539
540 GATE(SCLK_OTGPHY0, "sclk_otgphy0", "usb480m", CLK_IGNORE_UNUSED, 540 GATE(SCLK_OTGPHY0, "sclk_otgphy0", "xin24m", CLK_IGNORE_UNUSED,
541 RK3288_CLKGATE_CON(13), 4, GFLAGS), 541 RK3288_CLKGATE_CON(13), 4, GFLAGS),
542 GATE(SCLK_OTGPHY1, "sclk_otgphy1", "usb480m", CLK_IGNORE_UNUSED, 542 GATE(SCLK_OTGPHY1, "sclk_otgphy1", "xin24m", CLK_IGNORE_UNUSED,
543 RK3288_CLKGATE_CON(13), 5, GFLAGS), 543 RK3288_CLKGATE_CON(13), 5, GFLAGS),
544 GATE(SCLK_OTGPHY2, "sclk_otgphy2", "usb480m", CLK_IGNORE_UNUSED, 544 GATE(SCLK_OTGPHY2, "sclk_otgphy2", "xin24m", CLK_IGNORE_UNUSED,
545 RK3288_CLKGATE_CON(13), 6, GFLAGS), 545 RK3288_CLKGATE_CON(13), 6, GFLAGS),
546 GATE(SCLK_OTG_ADP, "sclk_otg_adp", "xin32k", CLK_IGNORE_UNUSED, 546 GATE(SCLK_OTG_ADP, "sclk_otg_adp", "xin32k", CLK_IGNORE_UNUSED,
547 RK3288_CLKGATE_CON(13), 7, GFLAGS), 547 RK3288_CLKGATE_CON(13), 7, GFLAGS),
@@ -888,24 +888,6 @@ static void __init rk3288_clk_init(struct device_node *np)
888 888
889 rockchip_clk_init(np, rk3288_cru_base, CLK_NR_CLKS); 889 rockchip_clk_init(np, rk3288_cru_base, CLK_NR_CLKS);
890 890
891 /* xin12m is created by an cru-internal divider */
892 clk = clk_register_fixed_factor(NULL, "xin12m", "xin24m", 0, 1, 2);
893 if (IS_ERR(clk))
894 pr_warn("%s: could not register clock xin12m: %ld\n",
895 __func__, PTR_ERR(clk));
896
897
898 clk = clk_register_fixed_factor(NULL, "usb480m", "xin24m", 0, 20, 1);
899 if (IS_ERR(clk))
900 pr_warn("%s: could not register clock usb480m: %ld\n",
901 __func__, PTR_ERR(clk));
902
903 clk = clk_register_fixed_factor(NULL, "hclk_vcodec_pre",
904 "hclk_vcodec_pre_v", 0, 1, 4);
905 if (IS_ERR(clk))
906 pr_warn("%s: could not register clock hclk_vcodec_pre: %ld\n",
907 __func__, PTR_ERR(clk));
908
909 /* Watchdog pclk is controlled by RK3288_SGRF_SOC_CON0[1]. */ 891 /* Watchdog pclk is controlled by RK3288_SGRF_SOC_CON0[1]. */
910 clk = clk_register_fixed_factor(NULL, "pclk_wdt", "pclk_pd_alive", 0, 1, 1); 892 clk = clk_register_fixed_factor(NULL, "pclk_wdt", "pclk_pd_alive", 0, 1, 1);
911 if (IS_ERR(clk)) 893 if (IS_ERR(clk))
diff --git a/drivers/clk/rockchip/clk-rk3368.c b/drivers/clk/rockchip/clk-rk3368.c
index 21f3ea909fab..c2b0421f2076 100644
--- a/drivers/clk/rockchip/clk-rk3368.c
+++ b/drivers/clk/rockchip/clk-rk3368.c
@@ -121,7 +121,7 @@ PNAME(mux_i2s_2ch_p) = { "i2s_2ch_src", "i2s_2ch_frac",
121 "dummy", "xin12m" }; 121 "dummy", "xin12m" };
122PNAME(mux_spdif_8ch_p) = { "spdif_8ch_pre", "spdif_8ch_frac", 122PNAME(mux_spdif_8ch_p) = { "spdif_8ch_pre", "spdif_8ch_frac",
123 "ext_i2s", "xin12m" }; 123 "ext_i2s", "xin12m" };
124PNAME(mux_edp_24m_p) = { "dummy", "xin24m" }; 124PNAME(mux_edp_24m_p) = { "xin24m", "dummy" };
125PNAME(mux_vip_out_p) = { "vip_src", "xin24m" }; 125PNAME(mux_vip_out_p) = { "vip_src", "xin24m" };
126PNAME(mux_usbphy480m_p) = { "usbotg_out", "xin24m" }; 126PNAME(mux_usbphy480m_p) = { "usbotg_out", "xin24m" };
127PNAME(mux_hsic_usbphy480m_p) = { "usbotg_out", "dummy" }; 127PNAME(mux_hsic_usbphy480m_p) = { "usbotg_out", "dummy" };
@@ -165,7 +165,7 @@ static const struct rockchip_cpuclk_reg_data rk3368_cpuclkb_data = {
165 .core_reg = RK3368_CLKSEL_CON(0), 165 .core_reg = RK3368_CLKSEL_CON(0),
166 .div_core_shift = 0, 166 .div_core_shift = 0,
167 .div_core_mask = 0x1f, 167 .div_core_mask = 0x1f,
168 .mux_core_shift = 15, 168 .mux_core_shift = 7,
169}; 169};
170 170
171static const struct rockchip_cpuclk_reg_data rk3368_cpuclkl_data = { 171static const struct rockchip_cpuclk_reg_data rk3368_cpuclkl_data = {
@@ -218,29 +218,29 @@ static const struct rockchip_cpuclk_reg_data rk3368_cpuclkl_data = {
218 } 218 }
219 219
220static struct rockchip_cpuclk_rate_table rk3368_cpuclkb_rates[] __initdata = { 220static struct rockchip_cpuclk_rate_table rk3368_cpuclkb_rates[] __initdata = {
221 RK3368_CPUCLKB_RATE(1512000000, 2, 6, 6), 221 RK3368_CPUCLKB_RATE(1512000000, 1, 5, 5),
222 RK3368_CPUCLKB_RATE(1488000000, 2, 5, 5), 222 RK3368_CPUCLKB_RATE(1488000000, 1, 4, 4),
223 RK3368_CPUCLKB_RATE(1416000000, 2, 5, 5), 223 RK3368_CPUCLKB_RATE(1416000000, 1, 4, 4),
224 RK3368_CPUCLKB_RATE(1200000000, 2, 4, 4), 224 RK3368_CPUCLKB_RATE(1200000000, 1, 3, 3),
225 RK3368_CPUCLKB_RATE(1008000000, 2, 4, 4), 225 RK3368_CPUCLKB_RATE(1008000000, 1, 3, 3),
226 RK3368_CPUCLKB_RATE( 816000000, 2, 3, 3), 226 RK3368_CPUCLKB_RATE( 816000000, 1, 2, 2),
227 RK3368_CPUCLKB_RATE( 696000000, 2, 3, 3), 227 RK3368_CPUCLKB_RATE( 696000000, 1, 2, 2),
228 RK3368_CPUCLKB_RATE( 600000000, 2, 2, 2), 228 RK3368_CPUCLKB_RATE( 600000000, 1, 1, 1),
229 RK3368_CPUCLKB_RATE( 408000000, 2, 2, 2), 229 RK3368_CPUCLKB_RATE( 408000000, 1, 1, 1),
230 RK3368_CPUCLKB_RATE( 312000000, 2, 2, 2), 230 RK3368_CPUCLKB_RATE( 312000000, 1, 1, 1),
231}; 231};
232 232
233static struct rockchip_cpuclk_rate_table rk3368_cpuclkl_rates[] __initdata = { 233static struct rockchip_cpuclk_rate_table rk3368_cpuclkl_rates[] __initdata = {
234 RK3368_CPUCLKL_RATE(1512000000, 2, 7, 7), 234 RK3368_CPUCLKL_RATE(1512000000, 1, 6, 6),
235 RK3368_CPUCLKL_RATE(1488000000, 2, 6, 6), 235 RK3368_CPUCLKL_RATE(1488000000, 1, 5, 5),
236 RK3368_CPUCLKL_RATE(1416000000, 2, 6, 6), 236 RK3368_CPUCLKL_RATE(1416000000, 1, 5, 5),
237 RK3368_CPUCLKL_RATE(1200000000, 2, 5, 5), 237 RK3368_CPUCLKL_RATE(1200000000, 1, 4, 4),
238 RK3368_CPUCLKL_RATE(1008000000, 2, 5, 5), 238 RK3368_CPUCLKL_RATE(1008000000, 1, 4, 4),
239 RK3368_CPUCLKL_RATE( 816000000, 2, 4, 4), 239 RK3368_CPUCLKL_RATE( 816000000, 1, 3, 3),
240 RK3368_CPUCLKL_RATE( 696000000, 2, 3, 3), 240 RK3368_CPUCLKL_RATE( 696000000, 1, 2, 2),
241 RK3368_CPUCLKL_RATE( 600000000, 2, 3, 3), 241 RK3368_CPUCLKL_RATE( 600000000, 1, 2, 2),
242 RK3368_CPUCLKL_RATE( 408000000, 2, 2, 2), 242 RK3368_CPUCLKL_RATE( 408000000, 1, 1, 1),
243 RK3368_CPUCLKL_RATE( 312000000, 2, 2, 2), 243 RK3368_CPUCLKL_RATE( 312000000, 1, 1, 1),
244}; 244};
245 245
246static struct rockchip_clk_branch rk3368_clk_branches[] __initdata = { 246static struct rockchip_clk_branch rk3368_clk_branches[] __initdata = {
@@ -248,6 +248,8 @@ static struct rockchip_clk_branch rk3368_clk_branches[] __initdata = {
248 * Clock-Architecture Diagram 2 248 * Clock-Architecture Diagram 2
249 */ 249 */
250 250
251 FACTOR(0, "xin12m", "xin24m", 0, 1, 2),
252
251 MUX(SCLK_USBPHY480M, "usbphy_480m", mux_usbphy480m_p, CLK_SET_RATE_PARENT, 253 MUX(SCLK_USBPHY480M, "usbphy_480m", mux_usbphy480m_p, CLK_SET_RATE_PARENT,
252 RK3368_CLKSEL_CON(13), 8, 1, MFLAGS), 254 RK3368_CLKSEL_CON(13), 8, 1, MFLAGS),
253 255
@@ -299,7 +301,7 @@ static struct rockchip_clk_branch rk3368_clk_branches[] __initdata = {
299 COMPOSITE_NOGATE_DIVTBL(0, "ddrphy_src", mux_ddrphy_p, CLK_IGNORE_UNUSED, 301 COMPOSITE_NOGATE_DIVTBL(0, "ddrphy_src", mux_ddrphy_p, CLK_IGNORE_UNUSED,
300 RK3368_CLKSEL_CON(13), 4, 1, MFLAGS, 0, 2, DFLAGS, div_ddrphy_t), 302 RK3368_CLKSEL_CON(13), 4, 1, MFLAGS, 0, 2, DFLAGS, div_ddrphy_t),
301 303
302 GATE(0, "sclk_ddr", "ddrphy_div4", CLK_IGNORE_UNUSED, 304 FACTOR_GATE(0, "sclk_ddr", "ddrphy_src", CLK_IGNORE_UNUSED, 1, 4,
303 RK3368_CLKGATE_CON(6), 14, GFLAGS), 305 RK3368_CLKGATE_CON(6), 14, GFLAGS),
304 GATE(0, "sclk_ddr4x", "ddrphy_src", CLK_IGNORE_UNUSED, 306 GATE(0, "sclk_ddr4x", "ddrphy_src", CLK_IGNORE_UNUSED,
305 RK3368_CLKGATE_CON(6), 15, GFLAGS), 307 RK3368_CLKGATE_CON(6), 15, GFLAGS),
@@ -353,7 +355,7 @@ static struct rockchip_clk_branch rk3368_clk_branches[] __initdata = {
353 COMPOSITE_FRAC(0, "spdif_8ch_frac", "spdif_8ch_src", CLK_SET_RATE_PARENT, 355 COMPOSITE_FRAC(0, "spdif_8ch_frac", "spdif_8ch_src", CLK_SET_RATE_PARENT,
354 RK3368_CLKSEL_CON(32), 0, 356 RK3368_CLKSEL_CON(32), 0,
355 RK3368_CLKGATE_CON(6), 5, GFLAGS), 357 RK3368_CLKGATE_CON(6), 5, GFLAGS),
356 COMPOSITE_NODIV(SCLK_SPDIF_8CH, "sclk_spdif_8ch", mux_spdif_8ch_p, 0, 358 COMPOSITE_NODIV(SCLK_SPDIF_8CH, "sclk_spdif_8ch", mux_spdif_8ch_p, CLK_SET_RATE_PARENT,
357 RK3368_CLKSEL_CON(31), 8, 2, MFLAGS, 359 RK3368_CLKSEL_CON(31), 8, 2, MFLAGS,
358 RK3368_CLKGATE_CON(6), 6, GFLAGS), 360 RK3368_CLKGATE_CON(6), 6, GFLAGS),
359 COMPOSITE(0, "i2s_2ch_src", mux_pll_src_cpll_gpll_p, 0, 361 COMPOSITE(0, "i2s_2ch_src", mux_pll_src_cpll_gpll_p, 0,
@@ -362,7 +364,7 @@ static struct rockchip_clk_branch rk3368_clk_branches[] __initdata = {
362 COMPOSITE_FRAC(0, "i2s_2ch_frac", "i2s_2ch_src", CLK_SET_RATE_PARENT, 364 COMPOSITE_FRAC(0, "i2s_2ch_frac", "i2s_2ch_src", CLK_SET_RATE_PARENT,
363 RK3368_CLKSEL_CON(54), 0, 365 RK3368_CLKSEL_CON(54), 0,
364 RK3368_CLKGATE_CON(5), 14, GFLAGS), 366 RK3368_CLKGATE_CON(5), 14, GFLAGS),
365 COMPOSITE_NODIV(SCLK_I2S_2CH, "sclk_i2s_2ch", mux_i2s_2ch_p, 0, 367 COMPOSITE_NODIV(SCLK_I2S_2CH, "sclk_i2s_2ch", mux_i2s_2ch_p, CLK_SET_RATE_PARENT,
366 RK3368_CLKSEL_CON(53), 8, 2, MFLAGS, 368 RK3368_CLKSEL_CON(53), 8, 2, MFLAGS,
367 RK3368_CLKGATE_CON(5), 15, GFLAGS), 369 RK3368_CLKGATE_CON(5), 15, GFLAGS),
368 370
@@ -384,18 +386,18 @@ static struct rockchip_clk_branch rk3368_clk_branches[] __initdata = {
384 * Clock-Architecture Diagram 3 386 * Clock-Architecture Diagram 3
385 */ 387 */
386 388
387 COMPOSITE(0, "aclk_vepu", mux_pll_src_cpll_gpll_usb_p, 0, 389 COMPOSITE(0, "aclk_vepu", mux_pll_src_cpll_gpll_npll_usb_p, 0,
388 RK3368_CLKSEL_CON(15), 6, 2, MFLAGS, 0, 5, DFLAGS, 390 RK3368_CLKSEL_CON(15), 6, 2, MFLAGS, 0, 5, DFLAGS,
389 RK3368_CLKGATE_CON(4), 6, GFLAGS), 391 RK3368_CLKGATE_CON(4), 6, GFLAGS),
390 COMPOSITE(0, "aclk_vdpu", mux_pll_src_cpll_gpll_usb_p, 0, 392 COMPOSITE(0, "aclk_vdpu", mux_pll_src_cpll_gpll_npll_usb_p, 0,
391 RK3368_CLKSEL_CON(15), 14, 2, MFLAGS, 8, 5, DFLAGS, 393 RK3368_CLKSEL_CON(15), 14, 2, MFLAGS, 8, 5, DFLAGS,
392 RK3368_CLKGATE_CON(4), 7, GFLAGS), 394 RK3368_CLKGATE_CON(4), 7, GFLAGS),
393 395
394 /* 396 /*
395 * We introduce a virtual node of hclk_vodec_pre_v to split one clock 397 * We use aclk_vdpu by default ---GRF_SOC_CON0[7] setting in system,
396 * struct with a gate and a fix divider into two node in software. 398 * so we ignore the mux and make clocks nodes as following,
397 */ 399 */
398 GATE(0, "hclk_video_pre_v", "aclk_vdpu", 0, 400 FACTOR_GATE(0, "hclk_video_pre", "aclk_vdpu", 0, 1, 4,
399 RK3368_CLKGATE_CON(4), 8, GFLAGS), 401 RK3368_CLKGATE_CON(4), 8, GFLAGS),
400 402
401 COMPOSITE(0, "sclk_hevc_cabac_src", mux_pll_src_cpll_gpll_npll_usb_p, 0, 403 COMPOSITE(0, "sclk_hevc_cabac_src", mux_pll_src_cpll_gpll_npll_usb_p, 0,
@@ -442,7 +444,7 @@ static struct rockchip_clk_branch rk3368_clk_branches[] __initdata = {
442 GATE(SCLK_HDMI_HDCP, "sclk_hdmi_hdcp", "xin24m", 0, 444 GATE(SCLK_HDMI_HDCP, "sclk_hdmi_hdcp", "xin24m", 0,
443 RK3368_CLKGATE_CON(4), 13, GFLAGS), 445 RK3368_CLKGATE_CON(4), 13, GFLAGS),
444 GATE(SCLK_HDMI_CEC, "sclk_hdmi_cec", "xin32k", 0, 446 GATE(SCLK_HDMI_CEC, "sclk_hdmi_cec", "xin32k", 0,
445 RK3368_CLKGATE_CON(5), 12, GFLAGS), 447 RK3368_CLKGATE_CON(4), 12, GFLAGS),
446 448
447 COMPOSITE_NODIV(0, "vip_src", mux_pll_src_cpll_gpll_p, 0, 449 COMPOSITE_NODIV(0, "vip_src", mux_pll_src_cpll_gpll_p, 0,
448 RK3368_CLKSEL_CON(21), 15, 1, MFLAGS, 450 RK3368_CLKSEL_CON(21), 15, 1, MFLAGS,
@@ -842,24 +844,6 @@ static void __init rk3368_clk_init(struct device_node *np)
842 844
843 rockchip_clk_init(np, reg_base, CLK_NR_CLKS); 845 rockchip_clk_init(np, reg_base, CLK_NR_CLKS);
844 846
845 /* xin12m is created by a cru-internal divider */
846 clk = clk_register_fixed_factor(NULL, "xin12m", "xin24m", 0, 1, 2);
847 if (IS_ERR(clk))
848 pr_warn("%s: could not register clock xin12m: %ld\n",
849 __func__, PTR_ERR(clk));
850
851 /* ddrphy_div4 is created by a cru-internal divider */
852 clk = clk_register_fixed_factor(NULL, "ddrphy_div4", "ddrphy_src", 0, 1, 4);
853 if (IS_ERR(clk))
854 pr_warn("%s: could not register clock xin12m: %ld\n",
855 __func__, PTR_ERR(clk));
856
857 clk = clk_register_fixed_factor(NULL, "hclk_video_pre",
858 "hclk_video_pre_v", 0, 1, 4);
859 if (IS_ERR(clk))
860 pr_warn("%s: could not register clock hclk_vcodec_pre: %ld\n",
861 __func__, PTR_ERR(clk));
862
863 /* Watchdog pclk is controlled by sgrf_soc_con3[7]. */ 847 /* Watchdog pclk is controlled by sgrf_soc_con3[7]. */
864 clk = clk_register_fixed_factor(NULL, "pclk_wdt", "pclk_pd_alive", 0, 1, 1); 848 clk = clk_register_fixed_factor(NULL, "pclk_wdt", "pclk_pd_alive", 0, 1, 1);
865 if (IS_ERR(clk)) 849 if (IS_ERR(clk))
diff --git a/drivers/clk/rockchip/clk.c b/drivers/clk/rockchip/clk.c
index f7e8693ad28b..ec06350c78c4 100644
--- a/drivers/clk/rockchip/clk.c
+++ b/drivers/clk/rockchip/clk.c
@@ -70,7 +70,7 @@ static struct clk *rockchip_clk_register_branch(const char *name,
70 if (gate_offset >= 0) { 70 if (gate_offset >= 0) {
71 gate = kzalloc(sizeof(*gate), GFP_KERNEL); 71 gate = kzalloc(sizeof(*gate), GFP_KERNEL);
72 if (!gate) 72 if (!gate)
73 return ERR_PTR(-ENOMEM); 73 goto err_gate;
74 74
75 gate->flags = gate_flags; 75 gate->flags = gate_flags;
76 gate->reg = base + gate_offset; 76 gate->reg = base + gate_offset;
@@ -82,7 +82,7 @@ static struct clk *rockchip_clk_register_branch(const char *name,
82 if (div_width > 0) { 82 if (div_width > 0) {
83 div = kzalloc(sizeof(*div), GFP_KERNEL); 83 div = kzalloc(sizeof(*div), GFP_KERNEL);
84 if (!div) 84 if (!div)
85 return ERR_PTR(-ENOMEM); 85 goto err_div;
86 86
87 div->flags = div_flags; 87 div->flags = div_flags;
88 div->reg = base + muxdiv_offset; 88 div->reg = base + muxdiv_offset;
@@ -102,6 +102,11 @@ static struct clk *rockchip_clk_register_branch(const char *name,
102 flags); 102 flags);
103 103
104 return clk; 104 return clk;
105err_div:
106 kfree(gate);
107err_gate:
108 kfree(mux);
109 return ERR_PTR(-ENOMEM);
105} 110}
106 111
107struct rockchip_clk_frac { 112struct rockchip_clk_frac {
@@ -262,6 +267,53 @@ static struct clk *rockchip_clk_register_frac_branch(const char *name,
262 return clk; 267 return clk;
263} 268}
264 269
270static struct clk *rockchip_clk_register_factor_branch(const char *name,
271 const char *const *parent_names, u8 num_parents,
272 void __iomem *base, unsigned int mult, unsigned int div,
273 int gate_offset, u8 gate_shift, u8 gate_flags,
274 unsigned long flags, spinlock_t *lock)
275{
276 struct clk *clk;
277 struct clk_gate *gate = NULL;
278 struct clk_fixed_factor *fix = NULL;
279
280 /* without gate, register a simple factor clock */
281 if (gate_offset == 0) {
282 return clk_register_fixed_factor(NULL, name,
283 parent_names[0], flags, mult,
284 div);
285 }
286
287 gate = kzalloc(sizeof(*gate), GFP_KERNEL);
288 if (!gate)
289 return ERR_PTR(-ENOMEM);
290
291 gate->flags = gate_flags;
292 gate->reg = base + gate_offset;
293 gate->bit_idx = gate_shift;
294 gate->lock = lock;
295
296 fix = kzalloc(sizeof(*fix), GFP_KERNEL);
297 if (!fix) {
298 kfree(gate);
299 return ERR_PTR(-ENOMEM);
300 }
301
302 fix->mult = mult;
303 fix->div = div;
304
305 clk = clk_register_composite(NULL, name, parent_names, num_parents,
306 NULL, NULL,
307 &fix->hw, &clk_fixed_factor_ops,
308 &gate->hw, &clk_gate_ops, flags);
309 if (IS_ERR(clk)) {
310 kfree(fix);
311 kfree(gate);
312 }
313
314 return clk;
315}
316
265static DEFINE_SPINLOCK(clk_lock); 317static DEFINE_SPINLOCK(clk_lock);
266static struct clk **clk_table; 318static struct clk **clk_table;
267static void __iomem *reg_base; 319static void __iomem *reg_base;
@@ -397,6 +449,14 @@ void __init rockchip_clk_register_branches(
397 reg_base + list->muxdiv_offset, 449 reg_base + list->muxdiv_offset,
398 list->div_shift, list->div_flags, &clk_lock); 450 list->div_shift, list->div_flags, &clk_lock);
399 break; 451 break;
452 case branch_factor:
453 clk = rockchip_clk_register_factor_branch(
454 list->name, list->parent_names,
455 list->num_parents, reg_base,
456 list->div_shift, list->div_width,
457 list->gate_offset, list->gate_shift,
458 list->gate_flags, flags, &clk_lock);
459 break;
400 } 460 }
401 461
402 /* none of the cases above matched */ 462 /* none of the cases above matched */
diff --git a/drivers/clk/rockchip/clk.h b/drivers/clk/rockchip/clk.h
index ff8bd23a93ec..39c198bbcbee 100644
--- a/drivers/clk/rockchip/clk.h
+++ b/drivers/clk/rockchip/clk.h
@@ -254,6 +254,7 @@ enum rockchip_clk_branch_type {
254 branch_gate, 254 branch_gate,
255 branch_mmc, 255 branch_mmc,
256 branch_inverter, 256 branch_inverter,
257 branch_factor,
257}; 258};
258 259
259struct rockchip_clk_branch { 260struct rockchip_clk_branch {
@@ -508,6 +509,33 @@ struct rockchip_clk_branch {
508 .div_flags = if, \ 509 .div_flags = if, \
509 } 510 }
510 511
512#define FACTOR(_id, cname, pname, f, fm, fd) \
513 { \
514 .id = _id, \
515 .branch_type = branch_factor, \
516 .name = cname, \
517 .parent_names = (const char *[]){ pname }, \
518 .num_parents = 1, \
519 .flags = f, \
520 .div_shift = fm, \
521 .div_width = fd, \
522 }
523
524#define FACTOR_GATE(_id, cname, pname, f, fm, fd, go, gb, gf) \
525 { \
526 .id = _id, \
527 .branch_type = branch_factor, \
528 .name = cname, \
529 .parent_names = (const char *[]){ pname }, \
530 .num_parents = 1, \
531 .flags = f, \
532 .div_shift = fm, \
533 .div_width = fd, \
534 .gate_offset = go, \
535 .gate_shift = gb, \
536 .gate_flags = gf, \
537 }
538
511void rockchip_clk_init(struct device_node *np, void __iomem *base, 539void rockchip_clk_init(struct device_node *np, void __iomem *base,
512 unsigned long nr_clks); 540 unsigned long nr_clks);
513struct regmap *rockchip_clk_get_grf(void); 541struct regmap *rockchip_clk_get_grf(void);
diff --git a/include/dt-bindings/clock/rk3188-cru-common.h b/include/dt-bindings/clock/rk3188-cru-common.h
index 8df77a7c030b..4f53e70f68ee 100644
--- a/include/dt-bindings/clock/rk3188-cru-common.h
+++ b/include/dt-bindings/clock/rk3188-cru-common.h
@@ -55,6 +55,7 @@
55#define SCLK_TIMER6 90 55#define SCLK_TIMER6 90
56#define SCLK_JTAG 91 56#define SCLK_JTAG 91
57#define SCLK_SMC 92 57#define SCLK_SMC 92
58#define SCLK_TSADC 93
58 59
59#define DCLK_LCDC0 190 60#define DCLK_LCDC0 190
60#define DCLK_LCDC1 191 61#define DCLK_LCDC1 191