aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElaine Zhang <zhangqing@rock-chips.com>2017-07-31 21:17:03 -0400
committerHeiko Stuebner <heiko@sntech.de>2017-08-08 11:30:29 -0400
commit334614058886fc5002dbfa2c4c72f89b3830f7e1 (patch)
tree1377d1f3e5e03778e1fd3ea5100d01e880f2f704
parent6d4ce2b7d90e24e07ec7f763043b90eda22c8351 (diff)
clk: rockchip: modify rk3128 clk driver to also support rk3126
rk3128 and rk3126 have some gate registers describe differences. So need to make some distinctions. The RK3126 and RK3128 Same clock description we move it to the common clock branches. And the different clks description use the own clock branches. Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com> Signed-off-by: Heiko Stuebner <heiko@sntech.de>
-rw-r--r--drivers/clk/rockchip/clk-rk3128.c69
1 files changed, 55 insertions, 14 deletions
diff --git a/drivers/clk/rockchip/clk-rk3128.c b/drivers/clk/rockchip/clk-rk3128.c
index e243f2eae68f..62d7854e4b87 100644
--- a/drivers/clk/rockchip/clk-rk3128.c
+++ b/drivers/clk/rockchip/clk-rk3128.c
@@ -201,7 +201,7 @@ static struct rockchip_clk_branch rk3128_uart2_fracmux __initdata =
201 MUX(SCLK_UART2, "sclk_uart2", mux_uart2_p, CLK_SET_RATE_PARENT, 201 MUX(SCLK_UART2, "sclk_uart2", mux_uart2_p, CLK_SET_RATE_PARENT,
202 RK2928_CLKSEL_CON(15), 8, 2, MFLAGS); 202 RK2928_CLKSEL_CON(15), 8, 2, MFLAGS);
203 203
204static struct rockchip_clk_branch rk3128_clk_branches[] __initdata = { 204static struct rockchip_clk_branch common_clk_branches[] __initdata = {
205 /* 205 /*
206 * Clock-Architecture Diagram 1 206 * Clock-Architecture Diagram 1
207 */ 207 */
@@ -459,10 +459,6 @@ static struct rockchip_clk_branch rk3128_clk_branches[] __initdata = {
459 RK2928_CLKSEL_CON(2), 14, 2, MFLAGS, 8, 5, DFLAGS, 459 RK2928_CLKSEL_CON(2), 14, 2, MFLAGS, 8, 5, DFLAGS,
460 RK2928_CLKGATE_CON(10), 15, GFLAGS), 460 RK2928_CLKGATE_CON(10), 15, GFLAGS),
461 461
462 COMPOSITE(SCLK_SFC, "sclk_sfc", mux_sclk_sfc_src_p, 0,
463 RK2928_CLKSEL_CON(11), 14, 2, MFLAGS, 8, 5, DFLAGS,
464 RK2928_CLKGATE_CON(3), 15, GFLAGS),
465
466 COMPOSITE_NOMUX(PCLK_PMU_PRE, "pclk_pmu_pre", "cpll", 0, 462 COMPOSITE_NOMUX(PCLK_PMU_PRE, "pclk_pmu_pre", "cpll", 0,
467 RK2928_CLKSEL_CON(29), 8, 6, DFLAGS, 463 RK2928_CLKSEL_CON(29), 8, 6, DFLAGS,
468 RK2928_CLKGATE_CON(1), 0, GFLAGS), 464 RK2928_CLKGATE_CON(1), 0, GFLAGS),
@@ -495,7 +491,6 @@ static struct rockchip_clk_branch rk3128_clk_branches[] __initdata = {
495 GATE(ACLK_DMAC, "aclk_dmac", "aclk_peri", 0, RK2928_CLKGATE_CON(5), 1, GFLAGS), 491 GATE(ACLK_DMAC, "aclk_dmac", "aclk_peri", 0, RK2928_CLKGATE_CON(5), 1, GFLAGS),
496 GATE(0, "aclk_peri_niu", "aclk_peri", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(9), 15, GFLAGS), 492 GATE(0, "aclk_peri_niu", "aclk_peri", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(9), 15, GFLAGS),
497 GATE(0, "aclk_cpu_to_peri", "aclk_peri", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(4), 2, GFLAGS), 493 GATE(0, "aclk_cpu_to_peri", "aclk_peri", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(4), 2, GFLAGS),
498 GATE(HCLK_GPS, "hclk_gps", "aclk_peri", 0, RK2928_CLKGATE_CON(3), 14, GFLAGS),
499 494
500 GATE(HCLK_I2S_8CH, "hclk_i2s_8ch", "hclk_peri", 0, RK2928_CLKGATE_CON(7), 4, GFLAGS), 495 GATE(HCLK_I2S_8CH, "hclk_i2s_8ch", "hclk_peri", 0, RK2928_CLKGATE_CON(7), 4, GFLAGS),
501 GATE(0, "hclk_peri_matrix", "hclk_peri", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(4), 0, GFLAGS), 496 GATE(0, "hclk_peri_matrix", "hclk_peri", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(4), 0, GFLAGS),
@@ -541,7 +536,6 @@ static struct rockchip_clk_branch rk3128_clk_branches[] __initdata = {
541 GATE(0, "hclk_rom", "hclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(5), 6, GFLAGS), 536 GATE(0, "hclk_rom", "hclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(5), 6, GFLAGS),
542 GATE(HCLK_CRYPTO, "hclk_crypto", "hclk_cpu", 0, RK2928_CLKGATE_CON(3), 5, GFLAGS), 537 GATE(HCLK_CRYPTO, "hclk_crypto", "hclk_cpu", 0, RK2928_CLKGATE_CON(3), 5, GFLAGS),
543 538
544 GATE(PCLK_HDMI, "pclk_hdmi", "pclk_cpu", 0, RK2928_CLKGATE_CON(3), 8, GFLAGS),
545 GATE(PCLK_ACODEC, "pclk_acodec", "pclk_cpu", 0, RK2928_CLKGATE_CON(5), 14, GFLAGS), 539 GATE(PCLK_ACODEC, "pclk_acodec", "pclk_cpu", 0, RK2928_CLKGATE_CON(5), 14, GFLAGS),
546 GATE(0, "pclk_ddrupctl", "pclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(5), 7, GFLAGS), 540 GATE(0, "pclk_ddrupctl", "pclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(5), 7, GFLAGS),
547 GATE(0, "pclk_grf", "pclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(5), 4, GFLAGS), 541 GATE(0, "pclk_grf", "pclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(5), 4, GFLAGS),
@@ -561,6 +555,21 @@ static struct rockchip_clk_branch rk3128_clk_branches[] __initdata = {
561 MMC(SCLK_EMMC_SAMPLE, "emmc_sample", "sclk_emmc", RK3228_EMMC_CON1, 0), 555 MMC(SCLK_EMMC_SAMPLE, "emmc_sample", "sclk_emmc", RK3228_EMMC_CON1, 0),
562}; 556};
563 557
558static struct rockchip_clk_branch rk3126_clk_branches[] __initdata = {
559 GATE(0, "pclk_stimer", "pclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(3), 15, GFLAGS),
560 GATE(0, "pclk_s_efuse", "pclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(3), 14, GFLAGS),
561 GATE(0, "pclk_sgrf", "pclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(3), 8, GFLAGS),
562};
563
564static struct rockchip_clk_branch rk3128_clk_branches[] __initdata = {
565 COMPOSITE(SCLK_SFC, "sclk_sfc", mux_sclk_sfc_src_p, 0,
566 RK2928_CLKSEL_CON(11), 14, 2, MFLAGS, 8, 5, DFLAGS,
567 RK2928_CLKGATE_CON(3), 15, GFLAGS),
568
569 GATE(HCLK_GPS, "hclk_gps", "aclk_peri", 0, RK2928_CLKGATE_CON(3), 14, GFLAGS),
570 GATE(PCLK_HDMI, "pclk_hdmi", "pclk_cpu", 0, RK2928_CLKGATE_CON(3), 8, GFLAGS),
571};
572
564static const char *const rk3128_critical_clocks[] __initconst = { 573static const char *const rk3128_critical_clocks[] __initconst = {
565 "aclk_cpu", 574 "aclk_cpu",
566 "hclk_cpu", 575 "hclk_cpu",
@@ -570,7 +579,7 @@ static const char *const rk3128_critical_clocks[] __initconst = {
570 "pclk_peri", 579 "pclk_peri",
571}; 580};
572 581
573static void __init rk3128_clk_init(struct device_node *np) 582static struct rockchip_clk_provider *__init rk3128_common_clk_init(struct device_node *np)
574{ 583{
575 struct rockchip_clk_provider *ctx; 584 struct rockchip_clk_provider *ctx;
576 void __iomem *reg_base; 585 void __iomem *reg_base;
@@ -578,23 +587,21 @@ static void __init rk3128_clk_init(struct device_node *np)
578 reg_base = of_iomap(np, 0); 587 reg_base = of_iomap(np, 0);
579 if (!reg_base) { 588 if (!reg_base) {
580 pr_err("%s: could not map cru region\n", __func__); 589 pr_err("%s: could not map cru region\n", __func__);
581 return; 590 return ERR_PTR(-ENOMEM);
582 } 591 }
583 592
584 ctx = rockchip_clk_init(np, reg_base, CLK_NR_CLKS); 593 ctx = rockchip_clk_init(np, reg_base, CLK_NR_CLKS);
585 if (IS_ERR(ctx)) { 594 if (IS_ERR(ctx)) {
586 pr_err("%s: rockchip clk init failed\n", __func__); 595 pr_err("%s: rockchip clk init failed\n", __func__);
587 iounmap(reg_base); 596 iounmap(reg_base);
588 return; 597 return ERR_PTR(-ENOMEM);
589 } 598 }
590 599
591 rockchip_clk_register_plls(ctx, rk3128_pll_clks, 600 rockchip_clk_register_plls(ctx, rk3128_pll_clks,
592 ARRAY_SIZE(rk3128_pll_clks), 601 ARRAY_SIZE(rk3128_pll_clks),
593 RK3128_GRF_SOC_STATUS0); 602 RK3128_GRF_SOC_STATUS0);
594 rockchip_clk_register_branches(ctx, rk3128_clk_branches, 603 rockchip_clk_register_branches(ctx, common_clk_branches,
595 ARRAY_SIZE(rk3128_clk_branches)); 604 ARRAY_SIZE(common_clk_branches));
596 rockchip_clk_protect_critical(rk3128_critical_clocks,
597 ARRAY_SIZE(rk3128_critical_clocks));
598 605
599 rockchip_clk_register_armclk(ctx, ARMCLK, "armclk", 606 rockchip_clk_register_armclk(ctx, ARMCLK, "armclk",
600 mux_armclk_p, ARRAY_SIZE(mux_armclk_p), 607 mux_armclk_p, ARRAY_SIZE(mux_armclk_p),
@@ -606,6 +613,40 @@ static void __init rk3128_clk_init(struct device_node *np)
606 613
607 rockchip_register_restart_notifier(ctx, RK2928_GLB_SRST_FST, NULL); 614 rockchip_register_restart_notifier(ctx, RK2928_GLB_SRST_FST, NULL);
608 615
616 return ctx;
617}
618
619static void __init rk3126_clk_init(struct device_node *np)
620{
621 struct rockchip_clk_provider *ctx;
622
623 ctx = rk3128_common_clk_init(np);
624 if (IS_ERR(ctx))
625 return;
626
627 rockchip_clk_register_branches(ctx, rk3126_clk_branches,
628 ARRAY_SIZE(rk3126_clk_branches));
629 rockchip_clk_protect_critical(rk3128_critical_clocks,
630 ARRAY_SIZE(rk3128_critical_clocks));
631
632 rockchip_clk_of_add_provider(np, ctx);
633}
634
635CLK_OF_DECLARE(rk3126_cru, "rockchip,rk3126-cru", rk3126_clk_init);
636
637static void __init rk3128_clk_init(struct device_node *np)
638{
639 struct rockchip_clk_provider *ctx;
640
641 ctx = rk3128_common_clk_init(np);
642 if (IS_ERR(ctx))
643 return;
644
645 rockchip_clk_register_branches(ctx, rk3128_clk_branches,
646 ARRAY_SIZE(rk3128_clk_branches));
647 rockchip_clk_protect_critical(rk3128_critical_clocks,
648 ARRAY_SIZE(rk3128_critical_clocks));
649
609 rockchip_clk_of_add_provider(np, ctx); 650 rockchip_clk_of_add_provider(np, ctx);
610} 651}
611 652