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

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>

authored by

Elaine Zhang and committed by
Heiko Stuebner
33461405 6d4ce2b7

+55 -14
+55 -14
drivers/clk/rockchip/clk-rk3128.c
··· 201 201 MUX(SCLK_UART2, "sclk_uart2", mux_uart2_p, CLK_SET_RATE_PARENT, 202 202 RK2928_CLKSEL_CON(15), 8, 2, MFLAGS); 203 203 204 - static struct rockchip_clk_branch rk3128_clk_branches[] __initdata = { 204 + static struct rockchip_clk_branch common_clk_branches[] __initdata = { 205 205 /* 206 206 * Clock-Architecture Diagram 1 207 207 */ ··· 459 459 RK2928_CLKSEL_CON(2), 14, 2, MFLAGS, 8, 5, DFLAGS, 460 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 462 COMPOSITE_NOMUX(PCLK_PMU_PRE, "pclk_pmu_pre", "cpll", 0, 467 463 RK2928_CLKSEL_CON(29), 8, 6, DFLAGS, 468 464 RK2928_CLKGATE_CON(1), 0, GFLAGS), ··· 491 495 GATE(ACLK_DMAC, "aclk_dmac", "aclk_peri", 0, RK2928_CLKGATE_CON(5), 1, GFLAGS), 492 496 GATE(0, "aclk_peri_niu", "aclk_peri", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(9), 15, GFLAGS), 493 497 GATE(0, "aclk_cpu_to_peri", "aclk_peri", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(4), 2, GFLAGS), 494 - GATE(HCLK_GPS, "hclk_gps", "aclk_peri", 0, RK2928_CLKGATE_CON(3), 14, GFLAGS), 495 498 496 499 GATE(HCLK_I2S_8CH, "hclk_i2s_8ch", "hclk_peri", 0, RK2928_CLKGATE_CON(7), 4, GFLAGS), 497 500 GATE(0, "hclk_peri_matrix", "hclk_peri", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(4), 0, GFLAGS), ··· 536 541 GATE(0, "hclk_rom", "hclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(5), 6, GFLAGS), 537 542 GATE(HCLK_CRYPTO, "hclk_crypto", "hclk_cpu", 0, RK2928_CLKGATE_CON(3), 5, GFLAGS), 538 543 539 - GATE(PCLK_HDMI, "pclk_hdmi", "pclk_cpu", 0, RK2928_CLKGATE_CON(3), 8, GFLAGS), 540 544 GATE(PCLK_ACODEC, "pclk_acodec", "pclk_cpu", 0, RK2928_CLKGATE_CON(5), 14, GFLAGS), 541 545 GATE(0, "pclk_ddrupctl", "pclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(5), 7, GFLAGS), 542 546 GATE(0, "pclk_grf", "pclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(5), 4, GFLAGS), ··· 555 561 MMC(SCLK_EMMC_SAMPLE, "emmc_sample", "sclk_emmc", RK3228_EMMC_CON1, 0), 556 562 }; 557 563 564 + static struct rockchip_clk_branch rk3126_clk_branches[] __initdata = { 565 + GATE(0, "pclk_stimer", "pclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(3), 15, GFLAGS), 566 + GATE(0, "pclk_s_efuse", "pclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(3), 14, GFLAGS), 567 + GATE(0, "pclk_sgrf", "pclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(3), 8, GFLAGS), 568 + }; 569 + 570 + static struct rockchip_clk_branch rk3128_clk_branches[] __initdata = { 571 + COMPOSITE(SCLK_SFC, "sclk_sfc", mux_sclk_sfc_src_p, 0, 572 + RK2928_CLKSEL_CON(11), 14, 2, MFLAGS, 8, 5, DFLAGS, 573 + RK2928_CLKGATE_CON(3), 15, GFLAGS), 574 + 575 + GATE(HCLK_GPS, "hclk_gps", "aclk_peri", 0, RK2928_CLKGATE_CON(3), 14, GFLAGS), 576 + GATE(PCLK_HDMI, "pclk_hdmi", "pclk_cpu", 0, RK2928_CLKGATE_CON(3), 8, GFLAGS), 577 + }; 578 + 558 579 static const char *const rk3128_critical_clocks[] __initconst = { 559 580 "aclk_cpu", 560 581 "hclk_cpu", ··· 579 570 "pclk_peri", 580 571 }; 581 572 582 - static void __init rk3128_clk_init(struct device_node *np) 573 + static struct rockchip_clk_provider *__init rk3128_common_clk_init(struct device_node *np) 583 574 { 584 575 struct rockchip_clk_provider *ctx; 585 576 void __iomem *reg_base; ··· 587 578 reg_base = of_iomap(np, 0); 588 579 if (!reg_base) { 589 580 pr_err("%s: could not map cru region\n", __func__); 590 - return; 581 + return ERR_PTR(-ENOMEM); 591 582 } 592 583 593 584 ctx = rockchip_clk_init(np, reg_base, CLK_NR_CLKS); 594 585 if (IS_ERR(ctx)) { 595 586 pr_err("%s: rockchip clk init failed\n", __func__); 596 587 iounmap(reg_base); 597 - return; 588 + return ERR_PTR(-ENOMEM); 598 589 } 599 590 600 591 rockchip_clk_register_plls(ctx, rk3128_pll_clks, 601 592 ARRAY_SIZE(rk3128_pll_clks), 602 593 RK3128_GRF_SOC_STATUS0); 603 - rockchip_clk_register_branches(ctx, rk3128_clk_branches, 604 - ARRAY_SIZE(rk3128_clk_branches)); 605 - rockchip_clk_protect_critical(rk3128_critical_clocks, 606 - ARRAY_SIZE(rk3128_critical_clocks)); 594 + rockchip_clk_register_branches(ctx, common_clk_branches, 595 + ARRAY_SIZE(common_clk_branches)); 607 596 608 597 rockchip_clk_register_armclk(ctx, ARMCLK, "armclk", 609 598 mux_armclk_p, ARRAY_SIZE(mux_armclk_p), ··· 612 605 ROCKCHIP_SOFTRST_HIWORD_MASK); 613 606 614 607 rockchip_register_restart_notifier(ctx, RK2928_GLB_SRST_FST, NULL); 608 + 609 + return ctx; 610 + } 611 + 612 + static void __init rk3126_clk_init(struct device_node *np) 613 + { 614 + struct rockchip_clk_provider *ctx; 615 + 616 + ctx = rk3128_common_clk_init(np); 617 + if (IS_ERR(ctx)) 618 + return; 619 + 620 + rockchip_clk_register_branches(ctx, rk3126_clk_branches, 621 + ARRAY_SIZE(rk3126_clk_branches)); 622 + rockchip_clk_protect_critical(rk3128_critical_clocks, 623 + ARRAY_SIZE(rk3128_critical_clocks)); 624 + 625 + rockchip_clk_of_add_provider(np, ctx); 626 + } 627 + 628 + CLK_OF_DECLARE(rk3126_cru, "rockchip,rk3126-cru", rk3126_clk_init); 629 + 630 + static void __init rk3128_clk_init(struct device_node *np) 631 + { 632 + struct rockchip_clk_provider *ctx; 633 + 634 + ctx = rk3128_common_clk_init(np); 635 + if (IS_ERR(ctx)) 636 + return; 637 + 638 + rockchip_clk_register_branches(ctx, rk3128_clk_branches, 639 + ARRAY_SIZE(rk3128_clk_branches)); 640 + rockchip_clk_protect_critical(rk3128_critical_clocks, 641 + ARRAY_SIZE(rk3128_critical_clocks)); 615 642 616 643 rockchip_clk_of_add_provider(np, ctx); 617 644 }