0001-clk-rockchip-rk3399-Set-hardcoded-clock-rates-same-a.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. From 27d49512277677afb7f71e093b007b3e2022b83e Mon Sep 17 00:00:00 2001
  2. From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
  3. Date: Fri, 8 Oct 2021 17:33:22 +0300
  4. Subject: [PATCH] clk: rockchip: rk3399: Set hardcoded clock rates same as
  5. devicetree
  6. Update hardcoded RK3399 clock rate definitions to match those in its
  7. devicetree (rk3399.dtsi), based on clock-controller assigned-clocks.
  8. Add and initialize NPLL since it's on that list, though nothing seems to
  9. use it in the driver so far.
  10. Also update VOP ACLK to 400MHz as it divides from CPLL (now 800MHz).
  11. All this stops the displayed vendor bitmap from getting disfigured
  12. when chainloading U-Boot from coreboot+depthcharge (as RW_LEGACY).
  13. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
  14. Link: https://github.com/alpernebbi/u-boot/commit/7e73b7a7550cfdd22a1413c263026e41e56e7617
  15. ---
  16. .../include/asm/arch-rockchip/cru_rk3399.h | 19 ++++++++++---------
  17. drivers/clk/rockchip/clk_rk3399.c | 10 ++++++----
  18. 2 files changed, 16 insertions(+), 13 deletions(-)
  19. diff --git a/arch/arm/include/asm/arch-rockchip/cru_rk3399.h b/arch/arm/include/asm/arch-rockchip/cru_rk3399.h
  20. index d941a129f3e5..54035c0df1f3 100644
  21. --- a/arch/arm/include/asm/arch-rockchip/cru_rk3399.h
  22. +++ b/arch/arm/include/asm/arch-rockchip/cru_rk3399.h
  23. @@ -69,7 +69,8 @@ check_member(rockchip_cru, sdio1_con[1], 0x594);
  24. #define LPLL_HZ (600*MHz)
  25. #define BPLL_HZ (600*MHz)
  26. #define GPLL_HZ (594*MHz)
  27. -#define CPLL_HZ (384*MHz)
  28. +#define CPLL_HZ (800*MHz)
  29. +#define NPLL_HZ (1000*MHz)
  30. #define PPLL_HZ (676*MHz)
  31. #define PMU_PCLK_HZ (48*MHz)
  32. @@ -82,16 +83,16 @@ check_member(rockchip_cru, sdio1_con[1], 0x594);
  33. #define ATCLK_CORE_B_HZ (300*MHz)
  34. #define PCLK_DBG_B_HZ (100*MHz)
  35. -#define PERIHP_ACLK_HZ (148500*KHz)
  36. -#define PERIHP_HCLK_HZ (148500*KHz)
  37. -#define PERIHP_PCLK_HZ (37125*KHz)
  38. +#define PERIHP_ACLK_HZ (150*MHz)
  39. +#define PERIHP_HCLK_HZ (75*MHz)
  40. +#define PERIHP_PCLK_HZ (37500*KHz)
  41. -#define PERILP0_ACLK_HZ (99000*KHz)
  42. -#define PERILP0_HCLK_HZ (99000*KHz)
  43. -#define PERILP0_PCLK_HZ (49500*KHz)
  44. +#define PERILP0_ACLK_HZ (100*MHz)
  45. +#define PERILP0_HCLK_HZ (100*MHz)
  46. +#define PERILP0_PCLK_HZ (50*MHz)
  47. -#define PERILP1_HCLK_HZ (99000*KHz)
  48. -#define PERILP1_PCLK_HZ (49500*KHz)
  49. +#define PERILP1_HCLK_HZ (100*MHz)
  50. +#define PERILP1_PCLK_HZ (50*MHz)
  51. #define PWM_CLOCK_HZ PMU_PCLK_HZ
  52. diff --git a/drivers/clk/rockchip/clk_rk3399.c b/drivers/clk/rockchip/clk_rk3399.c
  53. index f748fb5189e0..33f02c2d633c 100644
  54. --- a/drivers/clk/rockchip/clk_rk3399.c
  55. +++ b/drivers/clk/rockchip/clk_rk3399.c
  56. @@ -54,10 +54,11 @@ struct pll_div {
  57. .fbdiv = (u32)((u64)hz * _refdiv * _postdiv1 * _postdiv2 / OSC_HZ),\
  58. .postdiv1 = _postdiv1, .postdiv2 = _postdiv2};
  59. -static const struct pll_div gpll_init_cfg = PLL_DIVISORS(GPLL_HZ, 2, 2, 1);
  60. -static const struct pll_div cpll_init_cfg = PLL_DIVISORS(CPLL_HZ, 1, 2, 2);
  61. +static const struct pll_div gpll_init_cfg = PLL_DIVISORS(GPLL_HZ, 1, 4, 1);
  62. +static const struct pll_div cpll_init_cfg = PLL_DIVISORS(CPLL_HZ, 1, 3, 1);
  63. +static const struct pll_div npll_init_cfg = PLL_DIVISORS(NPLL_HZ, 1, 3, 1);
  64. #if !defined(CONFIG_SPL_BUILD)
  65. -static const struct pll_div ppll_init_cfg = PLL_DIVISORS(PPLL_HZ, 2, 2, 1);
  66. +static const struct pll_div ppll_init_cfg = PLL_DIVISORS(PPLL_HZ, 3, 2, 1);
  67. #endif
  68. static const struct pll_div apll_l_1600_cfg = PLL_DIVISORS(1600 * MHz, 3, 1, 1);
  69. @@ -682,7 +683,7 @@ static ulong rk3399_spi_set_clk(struct rockchip_cru *cru, ulong clk_id, uint hz)
  70. static ulong rk3399_vop_set_clk(struct rockchip_cru *cru, ulong clk_id, u32 hz)
  71. {
  72. struct pll_div vpll_config = {0};
  73. - int aclk_vop = 198 * MHz;
  74. + int aclk_vop = 400 * MHz;
  75. void *aclkreg_addr, *dclkreg_addr;
  76. u32 div;
  77. @@ -1336,6 +1337,7 @@ static void rkclk_init(struct rockchip_cru *cru)
  78. /* configure gpll cpll */
  79. rkclk_set_pll(&cru->gpll_con[0], &gpll_init_cfg);
  80. rkclk_set_pll(&cru->cpll_con[0], &cpll_init_cfg);
  81. + rkclk_set_pll(&cru->npll_con[0], &npll_init_cfg);
  82. /* configure perihp aclk, hclk, pclk */
  83. aclk_div = GPLL_HZ / PERIHP_ACLK_HZ - 1;
  84. --
  85. 2.42.0