Skip to contentSkip to conversation

rockchip: Miscellaneous RK35xx clock fixes

PATCH Superseded Jonas Karlman 4 participants 94 messages Oct 11 – Nov 17

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover rockchip: Miscellaneous RK35xx clock fixes

This series fixes a few trivial copy-paste mistakes and other misc clock issues for RK35xx SoCs.

Some of these fixes have only been compile tested as it involves clocks or rates that are rarely used in U-Boot.

The 'special pll handling' should ideally be moved into clk_rk3588 driver, something that can be done in a future follow-up series.

Similarly, any refactoring has been held back for a future follow-up series.

Changes in v2:
- Add patch to fix automatic PLL fractional calculation
- Add patch to request a working rate for saradc on RK3528
- Split "Fix trivial clock configuration errors"
- Update commit messages
- Add fixes tag
- Collect r-b tags

Jonas Karlman (37):
clk: rockchip: pll: Fix fractional PLL rate calculation
clk: rockchip: pll: Fix automatic PLL fractional parameter calculation
clk: rockchip: pll: Always write the dsmpd flag
clk: rockchip: pll: Always write the k parameter
clk: rockchip: pll: Use PLL_FIXED_MODE flag on RK3588/RK3576 PPLL
clk: rockchip: pll: Limit special rk3588_pll handling to RK3588
clk: rockchip: rk3568: Use correct clock id for GPLL
clk: rockchip: rk3568: Fix PWM0 parent selection mask
clk: rockchip: rk3568: Use PWM0 divider shift
clk: rockchip: rk3568: Use correct PLL rate for CLK_MAC0_2TOP
clk: rockchip: rk3588: Use GPLL rate for CLK_TSADC
clk: rockchip: rk3588: Use correct PLL rate for SCLK_UARTx divider
clk: rockchip: rk3588: Fix ACLK_BUS_ROOT divider encoding
clk: rockchip: rk3588: Set ACLK_BUS_ROOT to 375 MHz
clk: rockchip: rk3588: Remove redundant PLL register macros
clk: rockchip: rk3588: Rename PPLL register macro
clk: rockchip: rk3588: Align BxPLL entries in PLL table
clk: rockchip: rk3588: Use SPLL_HZ constant
clk: rockchip: rk3576: Use correct mode register for VPLL
clk: rockchip: rk3576: Fix ACLK_TOP_MID parent selection
clk: rockchip: rk3576: Fix I2C rate selection
clk: rockchip: rk3576: Fix CLK_I2C8 rate change
clk: rockchip: rk3576: Use correct clock register for CLK_SARADC
clk: rockchip: rk3576: Use correct TSADC clock register
clk: rockchip: rk3576: Use correct PLL rate for UART fractional clocks
clk: rockchip: rk3576: Use correct PLL rate for UART divisor
clk: rockchip: rk3576: Rename PPLL register macro
clk: rockchip: rk3576: Remove unused BPLL register macro
clk: rockchip: rk3576: Group LPLL register macro with CCI macros
clk: rockchip: rk3576: Align BPLL entry in PLL table
clk: rockchip: rk3528: Return correct rate for CLK_PWMx
clk: rockchip: rk3528: Fix VOP clock configuration
clk: rockchip: rk3528: Align PPLL entry in PLL table
clk: rockchip: rk3506: Return correct rate for CLK_I2C0 and CLK_I2C1
clk: rockchip: rk3568: Drop unused GRF syscon lookup
clk: rockchip: rk3588: Drop unused GRF syscon lookup
adc: rockchip-saradc: Use 3 MHz clock rate for RK3528

 arch/arm/include/asm/arch-rockchip/clock.h    |  2 +-
 .../include/asm/arch-rockchip/cru_rk3568.h    |  1 -
 .../include/asm/arch-rockchip/cru_rk3576.h    |  5 +-
 .../include/asm/arch-rockchip/cru_rk3588.h    |  6 +-
 drivers/adc/rockchip-saradc.c                 |  2 +-
 drivers/clk/rockchip/clk_pll.c                | 75 ++++++++++---------
 drivers/clk/rockchip/clk_rk3506.c             |  2 +
 drivers/clk/rockchip/clk_rk3528.c             |  7 +-
 drivers/clk/rockchip/clk_rk3568.c             | 12 +--
 drivers/clk/rockchip/clk_rk3576.c             | 26 +++----
 drivers/clk/rockchip/clk_rk3588.c             | 35 ++++-----
 11 files changed, 82 insertions(+), 91 deletions(-)
Signature · 1 line
2.55.0
#1 lore raw

PATCH v2 1/37 clk: rockchip: pll: Fix fractional PLL rate calculation

The fractional part of the rk3036-style PLL rate is divided by postdiv1 twice instead of by both postdiv1 and postdiv2. The integer part also loses precision by calculating in MHz before converting to Hz.

Calculate both parts in Hz using u64 arithmetic and apply post-dividers on the combined integer and fractional parts. This also closely matches the Linux implementation.

Fixes bbda2ed5840c ("rockchip: clk: pll: add common pll setting funcs")

---
Changes in v2:
- Change implementation to closer match Linux implementation
- Update commit message
- Add fixes tag

---
 drivers/clk/rockchip/clk_pll.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/clk/rockchip/clk_pll.c +6 -5
index f677525bba22..74b7ff5faa03 100644
@@ -371,7 +371,7 @@ static ulong rk3036_pll_get_rate(struct rockchip_pll_clock *pll,
 {
 	u32 refdiv, fbdiv, postdiv1, postdiv2, dsmpd, frac;
 	u32 con = 0, shift, mask;
-	ulong rate;
+	u64 rate;
 	int mode;
 
 	con = readl(base + pll->mode_offset);
@@ -403,17 +403,18 @@ static ulong rk3036_pll_get_rate(struct rockchip_pll_clock *pll,
 		con = readl(base + pll->con_offset + 0x8);
 		frac = (con & RK3036_PLLCON2_FRAC_MASK) >>
 			RK3036_PLLCON2_FRAC_SHIFT;
-		rate = (24 * fbdiv / (refdiv * postdiv1 * postdiv2)) * 1000000;
+		rate = OSC_HZ * (u64)fbdiv;
+		do_div(rate, refdiv);
 		if (dsmpd == 0) {
 			u64 frac_rate = OSC_HZ * (u64)frac;
 
 			do_div(frac_rate, refdiv);
 			frac_rate >>= 24;
-			do_div(frac_rate, postdiv1);
-			do_div(frac_rate, postdiv1);
 			rate += frac_rate;
 		}
-		return rate;
+		do_div(rate, postdiv1);
+		do_div(rate, postdiv2);
+		return (ulong)rate;
 	case RKCLK_PLL_MODE_DEEP:
 	default:
 		return 32768;
Signature · 1 line
2.55.0
Reviewed-by on v2 1/37
#2 lore raw

Re: [PATCH v2 01/37] clk: rockchip: pll: Fix fractional PLL rate calculation

Quoted 10 lines · Jonas Karlman

clk: rockchip: pll: Fix fractional PLL rate calculation

The fractional part of the rk3036-style PLL rate is divided by postdiv1 twice instead of by both postdiv1 and postdiv2. The integer part also loses precision by calculating in MHz before converting to Hz.

Calculate both parts in Hz using u64 arithmetic and apply post-dividers on the combined integer and fractional parts. This also closely matches the Linux implementation.

Quoted 5 lines
Fixes bbda2ed5840c ("rockchip: clk: pll: add common pll setting funcs")
 drivers/clk/rockchip/clk_pll.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
#3 lore raw

PATCH v2 2/37 clk: rockchip: pll: Fix automatic PLL fractional parameter calculation

In reply to Jonas Karlman

Use 64-bit arithmetic for f_frac << 24 to prevent truncation before division when automatically configuring fractional PLLs.

This closely matches the vendor kernel implementation.

Fixes bbda2ed5840c ("rockchip: clk: pll: add common pll setting funcs")

---
v2: New patch

---
 drivers/clk/rockchip/clk_pll.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/clk/rockchip/clk_pll.c +5 -5
index 74b7ff5faa03..5cb0e954ba4a 100644
@@ -114,7 +114,7 @@ rockchip_pll_clk_set_by_auto(ulong fin_hz,
 	struct rockchip_pll_rate_table *rate_table = &rockchip_auto_table;
 	/* FIXME set postdiv1/2 always 1*/
 	u32 foutvco = fout_hz;
-	ulong fin_64, frac_64;
+	u64 fin_64, frac_64;
 	u32 f_frac, postdiv1, postdiv2;
 	ulong clk_gcd = 0;
 
@@ -156,10 +156,10 @@ rockchip_pll_clk_set_by_auto(ulong fin_hz,
 
 		f_frac = (foutvco % MHZ);
 		fin_64 = fin_hz;
-		fin_64 = fin_64 / rate_table->refdiv;
-		frac_64 = f_frac << 24;
-		frac_64 = frac_64 / fin_64;
-		rate_table->frac = frac_64;
+		do_div(fin_64, (u64)rate_table->refdiv);
+		frac_64 = (u64)f_frac << 24;
+		do_div(frac_64, fin_64);
+		rate_table->frac = (u32)frac_64;
 		if (rate_table->frac > 0)
 			rate_table->dsmpd = 0;
 		debug("frac = %x\n", rate_table->frac);
Signature · 1 line
2.55.0
Reviewed-by on v2 2/37
#4 lore raw

Re: [PATCH v2 02/37] clk: rockchip: pll: Fix automatic PLL fractional parameter calculation

Quoted 5 lines · Jonas Karlman

clk: rockchip: pll: Fix automatic PLL fractional parameter calculation

Use 64-bit arithmetic for f_frac << 24 to prevent truncation before division when automatically configuring fractional PLLs.

Quoted 7 lines

This closely matches the vendor kernel implementation.

Fixes bbda2ed5840c ("rockchip: clk: pll: add common pll setting funcs")
 drivers/clk/rockchip/clk_pll.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
#5 lore raw

PATCH v2 3/37 clk: rockchip: pll: Always write the dsmpd flag

In reply to Jonas Karlman

The dsmpd flag controls whether an rk3036-style PLL uses fractional mode. When changing from a fractional rate to an integer rate, the dsmpd field is left cleared, keeping fractional mode active.

Always write dsmpd to the register so integer rates disable fractional mode. This also matches how Linux configures these PLLs.

Fixes bbda2ed5840c ("rockchip: clk: pll: add common pll setting funcs")

---
Changes in v2:
- Update commit message
- Add fixes tag
- Collect r-b tag

---
 drivers/clk/rockchip/clk_pll.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/clk/rockchip/clk_pll.c +4 -5
index 5cb0e954ba4a..5de930e41dce 100644
@@ -331,13 +331,12 @@ static int rk3036_pll_set_rate(struct rockchip_pll_clock *pll,
 		     rate->fbdiv);
 	rk_clrsetreg(base + pll->con_offset + 0x4,
 		     (RK3036_PLLCON1_POSTDIV2_MASK |
-		     RK3036_PLLCON1_REFDIV_MASK),
+		     RK3036_PLLCON1_REFDIV_MASK |
+		     RK3036_PLLCON1_DSMPD_MASK),
 		     (rate->postdiv2 << RK3036_PLLCON1_POSTDIV2_SHIFT |
-		     rate->refdiv << RK3036_PLLCON1_REFDIV_SHIFT));
+		     rate->refdiv << RK3036_PLLCON1_REFDIV_SHIFT |
+		     rate->dsmpd << RK3036_PLLCON1_DSMPD_SHIFT));
 	if (!rate->dsmpd) {
-		rk_clrsetreg(base + pll->con_offset + 0x4,
-			     RK3036_PLLCON1_DSMPD_MASK,
-			     rate->dsmpd << RK3036_PLLCON1_DSMPD_SHIFT);
 		writel((readl(base + pll->con_offset + 0x8) &
 			(~RK3036_PLLCON2_FRAC_MASK)) |
 			    (rate->frac << RK3036_PLLCON2_FRAC_SHIFT),
Signature · 1 line
2.55.0
Reviewed-by on v2 3/37
#6 lore raw

Re: [PATCH v2 03/37] clk: rockchip: pll: Always write the dsmpd flag

Quoted 9 lines · Jonas Karlman

clk: rockchip: pll: Always write the dsmpd flag

The dsmpd flag controls whether an rk3036-style PLL uses fractional mode. When changing from a fractional rate to an integer rate, the dsmpd field is left cleared, keeping fractional mode active.

Always write dsmpd to the register so integer rates disable fractional mode. This also matches how Linux configures these PLLs.

Quoted 6 lines
Fixes bbda2ed5840c ("rockchip: clk: pll: add common pll setting funcs")
 drivers/clk/rockchip/clk_pll.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
#7 lore raw

PATCH v2 4/37 clk: rockchip: pll: Always write the k parameter

In reply to Jonas Karlman

The k parameter supplies the fractional part of an rk3588-style PLL rate. When changing from a fractional rate to an integer rate, the k value is left unchanged, leaving the old fractional part active.

Always write k to the register, including zero, so integer rates clear any prior fractional part. This also matches how Linux configures these PLLs.

Fixes b851c006a150 ("clk: rockchip: pll: Add pll_rk3588 type for rk3588")

---
Changes in v2:
- Update commit message
- Add fixes tag
- Collect r-b tag

---
 drivers/clk/rockchip/clk_pll.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/clk/rockchip/clk_pll.c +3 -5
index 5de930e41dce..6664fe3921b8 100644
@@ -490,11 +490,9 @@ static int rk3588_pll_set_rate(struct rockchip_pll_clock *pll,
 		     RK3588_PLLCON1_S_MASK),
 		     (rate->p << RK3588_PLLCON1_P_SHIFT |
 		     rate->s << RK3588_PLLCON1_S_SHIFT));
-	if (rate->k) {
-		rk_clrsetreg(base + pll->con_offset + RK3588_PLLCON(2),
-			     RK3588_PLLCON2_K_MASK,
-			     rate->k << RK3588_PLLCON2_K_SHIFT);
-	}
+	rk_clrsetreg(base + pll->con_offset + RK3588_PLLCON(2),
+		     RK3588_PLLCON2_K_MASK,
+		     rate->k << RK3588_PLLCON2_K_SHIFT);
 	/* Power up */
 	rk_clrreg(base + pll->con_offset + RK3588_PLLCON(1),
 		  RK3588_PLLCON1_PWRDOWN);
Signature · 1 line
2.55.0
Reviewed-by on v2 4/37
#8 lore raw

Re: [PATCH v2 04/37] clk: rockchip: pll: Always write the k parameter

Quoted 10 lines · Jonas Karlman

clk: rockchip: pll: Always write the k parameter

The k parameter supplies the fractional part of an rk3588-style PLL rate. When changing from a fractional rate to an integer rate, the k value is left unchanged, leaving the old fractional part active.

Always write k to the register, including zero, so integer rates clear any prior fractional part. This also matches how Linux configures these PLLs.

Quoted 6 lines
Fixes b851c006a150 ("clk: rockchip: pll: Add pll_rk3588 type for rk3588")
 drivers/clk/rockchip/clk_pll.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
#9 lore raw

PATCH v2 5/37 clk: rockchip: pll: Use PLL_FIXED_MODE flag on RK3588/RK3576 PPLL

In reply to Jonas Karlman

The PPLL on RK3588 and RK3576 has no PLL mode register and cannot switch between slow, deep slow or normal mode.

Extend ROCKCHIP_PLL_FIXED_MODE support to the pll_rk3588 type and mark both PPLLs with this flag. Skip mode register writes when changing rates and treat the PLLs as operating in normal mode when reading rates.

---
Changes in v2:
- Update comment in clock.h header
- Update commit message
- Collect r-b tag

---
 arch/arm/include/asm/arch-rockchip/clock.h |  2 +-
 drivers/clk/rockchip/clk_pll.c             | 21 +++++++++++++--------
 drivers/clk/rockchip/clk_rk3576.c          |  3 ++-
 drivers/clk/rockchip/clk_rk3588.c          |  3 ++-
 4 files changed, 18 insertions(+), 11 deletions(-)
arch/arm/include/asm/arch-rockchip/clock.h +1 -1
index 8d3819778eb1..43b63f72703d 100644
@@ -19,7 +19,7 @@ struct udevice;
  * PLL flags
  */
 #define ROCKCHIP_PLL_SYNC_RATE		BIT(0)
-/* normal mode only. now only for pll_rk3036, pll_rk3328 type */
+/* normal mode only. */
 #define ROCKCHIP_PLL_FIXED_MODE		BIT(1)
 
 enum {
drivers/clk/rockchip/clk_pll.c +13 -8
index 6664fe3921b8..a2b16543e811 100644
@@ -462,9 +462,11 @@ static int rk3588_pll_set_rate(struct rockchip_pll_clock *pll,
 	if (pll_id == 3)
 		rk_clrsetreg(base + 0x84c, 0x1 << 1, 0x1 << 1);
 
-	rk_clrsetreg(base + pll->mode_offset,
-		     pll->mode_mask << pll->mode_shift,
-		     RKCLK_PLL_MODE_SLOW << pll->mode_shift);
+	if (!(pll->pll_flags & ROCKCHIP_PLL_FIXED_MODE)) {
+		rk_clrsetreg(base + pll->mode_offset,
+			     pll->mode_mask << pll->mode_shift,
+			     RKCLK_PLL_MODE_SLOW << pll->mode_shift);
+	}
 	if (pll_id == 0)
 		rk_clrsetreg(base + RK3588_B0PLL_CLKSEL_CON(0),
 			     pll->mode_mask << 6,
@@ -504,8 +506,11 @@ static int rk3588_pll_set_rate(struct rockchip_pll_clock *pll,
 		debug("%s: wait pll lock, pll_id=%ld\n", __func__, pll_id);
 	}
 
-	rk_clrsetreg(base + pll->mode_offset, pll->mode_mask << pll->mode_shift,
-		     RKCLK_PLL_MODE_NORMAL << pll->mode_shift);
+	if (!(pll->pll_flags & ROCKCHIP_PLL_FIXED_MODE)) {
+		rk_clrsetreg(base + pll->mode_offset,
+			     pll->mode_mask << pll->mode_shift,
+			     RKCLK_PLL_MODE_NORMAL << pll->mode_shift);
+	}
 	if (pll_id == 0) {
 		rk_clrsetreg(base + RK3588_B0PLL_CLKSEL_CON(0),
 			     pll->mode_mask << 6,
@@ -566,10 +571,10 @@ static ulong rk3588_pll_get_rate(struct rockchip_pll_clock *pll,
 
 	con = readl(base + pll->mode_offset);
 	shift = pll->mode_shift;
-	if (pll_id == 8)
-		mode = RKCLK_PLL_MODE_NORMAL;
-	else
+	if (!(pll->pll_flags & ROCKCHIP_PLL_FIXED_MODE))
 		mode = (con & (pll->mode_mask << shift)) >> shift;
+	else
+		mode = RKCLK_PLL_MODE_NORMAL;
 	switch (mode) {
 	case RKCLK_PLL_MODE_SLOW:
 		return OSC_HZ;
drivers/clk/rockchip/clk_rk3576.c +2 -1
index db8ce25852fd..92bde425b0ee 100644
@@ -57,7 +57,8 @@ static struct rockchip_pll_clock rk3576_pll_clks[] = {
 	[GPLL] = PLL(pll_rk3588, PLL_GPLL, RK3576_PLL_CON(112),
 		     RK3576_MODE_CON0, 2, 15, 0, rk3576_24m_pll_rates),
 	[PPLL] = PLL(pll_rk3588, PLL_PPLL, RK3576_PMU_PLL_CON(128),
-		     RK3576_MODE_CON0, 10, 15, 0, rk3576_24m_pll_rates),
+		     RK3576_MODE_CON0, 10, 15, ROCKCHIP_PLL_FIXED_MODE,
+		     rk3576_24m_pll_rates),
 };
 
 #ifdef CONFIG_SPL_BUILD
drivers/clk/rockchip/clk_rk3588.c +2 -1
index be401a9faeec..b9fd4bec311b 100644
@@ -62,7 +62,8 @@ static struct rockchip_pll_clock rk3588_pll_clks[] = {
 	[NPLL] = PLL(pll_rk3588, PLL_NPLL, RK3588_PLL_CON(120),
 		     RK3588_MODE_CON0, 0, 15, 0, rk3588_pll_rates),
 	[PPLL] = PLL(pll_rk3588, PLL_PPLL, RK3588_PMU_PLL_CON(128),
-		     RK3588_MODE_CON0, 10, 15, 0, rk3588_pll_rates),
+		     RK3588_MODE_CON0, 10, 15, ROCKCHIP_PLL_FIXED_MODE,
+		     rk3588_pll_rates),
 #ifdef CONFIG_XPL_BUILD
 	/*
 	 * The SPLL is part of the SBUSCRU, not the main CRU and as
Signature · 1 line
2.55.0
Reviewed-by on v2 5/37
#10 lore raw

Re: [PATCH v2 05/37] clk: rockchip: pll: Use PLL_FIXED_MODE flag on RK3588/RK3576 PPLL

Quoted 9 lines · Jonas Karlman

clk: rockchip: pll: Use PLL_FIXED_MODE flag on RK3588/RK3576 PPLL

The PPLL on RK3588 and RK3576 has no PLL mode register and cannot switch between slow, deep slow or normal mode.

Extend ROCKCHIP_PLL_FIXED_MODE support to the pll_rk3588 type and mark both PPLLs with this flag. Skip mode register writes when changing rates and treat the PLLs as operating in normal mode when reading rates.

Quoted 8 lines
 arch/arm/include/asm/arch-rockchip/clock.h |  2 +-
 drivers/clk/rockchip/clk_pll.c             | 21 +++++++++++++--------
 drivers/clk/rockchip/clk_rk3576.c          |  3 ++-
 drivers/clk/rockchip/clk_rk3588.c          |  3 ++-
 4 files changed, 18 insertions(+), 11 deletions(-)
#11 lore raw

PATCH v2 6/37 clk: rockchip: pll: Limit special rk3588_pll handling to RK3588

In reply to Jonas Karlman

The rk3588_pll_set_rate() function contains special handling intended only for PLLs on RK3588 that are also applied to PLLs on RK3576.

This special handling should ideally be moved from the common pll funcs into the clk_rk3588 driver. Add IS_ENABLED() guards as an initial step to limit this special handling to PLLs on RK3588 targets.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

---
Changes in v2:
- Add fixes tag
- Collect r-b tag

---
 drivers/clk/rockchip/clk_pll.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/clk/rockchip/clk_pll.c +8 -8
index a2b16543e811..e00975565a0c 100644
@@ -459,7 +459,7 @@ static int rk3588_pll_set_rate(struct rockchip_pll_clock *pll,
 	 * When power on or changing PLL setting,
 	 * we must force PLL into slow mode to ensure output stable clock.
 	 */
-	if (pll_id == 3)
+	if (IS_ENABLED(CONFIG_ROCKCHIP_RK3588) && pll_id == 3)
 		rk_clrsetreg(base + 0x84c, 0x1 << 1, 0x1 << 1);
 
 	if (!(pll->pll_flags & ROCKCHIP_PLL_FIXED_MODE)) {
@@ -467,15 +467,15 @@ static int rk3588_pll_set_rate(struct rockchip_pll_clock *pll,
 			     pll->mode_mask << pll->mode_shift,
 			     RKCLK_PLL_MODE_SLOW << pll->mode_shift);
 	}
-	if (pll_id == 0)
+	if (IS_ENABLED(CONFIG_ROCKCHIP_RK3588) && pll_id == 0)
 		rk_clrsetreg(base + RK3588_B0PLL_CLKSEL_CON(0),
 			     pll->mode_mask << 6,
 			     RKCLK_PLL_MODE_SLOW << 6);
-	else if (pll_id == 1)
+	else if (IS_ENABLED(CONFIG_ROCKCHIP_RK3588) && pll_id == 1)
 		rk_clrsetreg(base + RK3588_B1PLL_CLKSEL_CON(0),
 			     pll->mode_mask << 6,
 			     RKCLK_PLL_MODE_SLOW << 6);
-	else if (pll_id == 2)
+	else if (IS_ENABLED(CONFIG_ROCKCHIP_RK3588) && pll_id == 2)
 		rk_clrsetreg(base + RK3588_LPLL_CLKSEL_CON(5),
 			     pll->mode_mask << 14,
 			     RKCLK_PLL_MODE_SLOW << 14);
@@ -511,7 +511,7 @@ static int rk3588_pll_set_rate(struct rockchip_pll_clock *pll,
 			     pll->mode_mask << pll->mode_shift,
 			     RKCLK_PLL_MODE_NORMAL << pll->mode_shift);
 	}
-	if (pll_id == 0) {
+	if (IS_ENABLED(CONFIG_ROCKCHIP_RK3588) && pll_id == 0) {
 		rk_clrsetreg(base + RK3588_B0PLL_CLKSEL_CON(0),
 			     pll->mode_mask << 6,
 			     2 << 6);
@@ -521,7 +521,7 @@ static int rk3588_pll_set_rate(struct rockchip_pll_clock *pll,
 		rk_clrsetreg(base + RK3588_B0PLL_CLKSEL_CON(1),
 			     RK3588_CORE_DIV_MASK << RK3588_CORE_B13_DIV_SHIFT,
 			     0 << RK3588_CORE_B13_DIV_SHIFT);
-	} else if (pll_id == 1) {
+	} else if (IS_ENABLED(CONFIG_ROCKCHIP_RK3588) && pll_id == 1) {
 		rk_clrsetreg(base + RK3588_B1PLL_CLKSEL_CON(0),
 			     pll->mode_mask << 6,
 			     2 << 6);
@@ -531,7 +531,7 @@ static int rk3588_pll_set_rate(struct rockchip_pll_clock *pll,
 		rk_clrsetreg(base + RK3588_B1PLL_CLKSEL_CON(1),
 			     RK3588_CORE_DIV_MASK << RK3588_CORE_B13_DIV_SHIFT,
 			     0 << RK3588_CORE_B13_DIV_SHIFT);
-	} else if (pll_id == 2) {
+	} else if (IS_ENABLED(CONFIG_ROCKCHIP_RK3588) && pll_id == 2) {
 		rk_clrsetreg(base + RK3588_LPLL_CLKSEL_CON(5),
 			     pll->mode_mask << 14,
 			     2 << 14);
@@ -549,7 +549,7 @@ static int rk3588_pll_set_rate(struct rockchip_pll_clock *pll,
 			     0 << RK3588_CORE_L02_DIV_SHIFT);
 	}
 
-	if (pll_id == 3)
+	if (IS_ENABLED(CONFIG_ROCKCHIP_RK3588) && pll_id == 3)
 		rk_clrsetreg(base + 0x84c, 0x1 << 1, 0);
 
 	debug("PLL at %p: con0=%x con1= %x con2= %x mode= %x\n",
Signature · 1 line
2.55.0
Reviewed-by on v2 6/37
#12 lore raw

Re: [PATCH v2 06/37] clk: rockchip: pll: Limit special rk3588_pll handling to RK3588

Quoted 9 lines · Jonas Karlman

clk: rockchip: pll: Limit special rk3588_pll handling to RK3588

The rk3588_pll_set_rate() function contains special handling intended only for PLLs on RK3588 that are also applied to PLLs on RK3576.

This special handling should ideally be moved from the common pll funcs into the clk_rk3588 driver. Add IS_ENABLED() guards as an initial step to limit this special handling to PLLs on RK3588 targets.

Quoted 6 lines
Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")
 drivers/clk/rockchip/clk_pll.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
#13 lore raw

PATCH v2 7/37 clk: rockchip: rk3568: Use correct clock id for GPLL

In reply to Jonas Karlman

The GPLL entry incorrectly uses PLL_HPLL. Use PLL_GPLL to match the PLL represented by this entry.

Fixes 4a262feba3a5 ("rockchip: rk3568: add clock driver")

---
Changes in v2:
- Split from "rk3568: Fix trivial clock configuration errors"
- Add fixes tag
- Collect r-b tag

---
 drivers/clk/rockchip/clk_rk3568.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk_rk3568.c +1 -1
index bb49af358e60..86881728667a 100644
@@ -77,7 +77,7 @@ static struct rockchip_pll_clock rk3568_pll_clks[] = {
 		     RK3568_MODE_CON, 2, 10, 0, NULL),
 	[CPLL] = PLL(pll_rk3328, PLL_CPLL, RK3568_PLL_CON(24),
 		     RK3568_MODE_CON, 4, 10, 0, rk3568_pll_rates),
-	[GPLL] = PLL(pll_rk3328, PLL_HPLL, RK3568_PLL_CON(16),
+	[GPLL] = PLL(pll_rk3328, PLL_GPLL, RK3568_PLL_CON(16),
 		     RK3568_MODE_CON, 6, 10, 0, rk3568_pll_rates),
 	[NPLL] = PLL(pll_rk3328, PLL_NPLL, RK3568_PLL_CON(32),
 		     RK3568_MODE_CON, 10, 10, 0, rk3568_pll_rates),
Signature · 1 line
2.55.0
Reviewed-by on v2 7/37
#14 lore raw

Re: [PATCH v2 07/37] clk: rockchip: rk3568: Use correct clock id for GPLL

Quoted 11 lines · Jonas Karlman

clk: rockchip: rk3568: Use correct clock id for GPLL

The GPLL entry incorrectly uses PLL_HPLL. Use PLL_GPLL to match the PLL represented by this entry.

Fixes 4a262feba3a5 ("rockchip: rk3568: add clock driver")
 drivers/clk/rockchip/clk_rk3568.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#15 lore raw

PATCH v2 8/37 clk: rockchip: rk3568: Fix PWM0 parent selection mask

In reply to Jonas Karlman

The CLK_PWM0 divider mask is used twice, leaving the parent selection unchanged. Change to use the intended CLK_PWM0 parent selection mask.

Fixes 4a262feba3a5 ("rockchip: rk3568: add clock driver")

---
Changes in v2:
- Split from "rk3568: Fix trivial clock configuration errors"
- Add fixes tag
- Collect r-b tag

---
 drivers/clk/rockchip/clk_rk3568.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk_rk3568.c +1 -1
index 86881728667a..88bbfb68cac6 100644
@@ -299,7 +299,7 @@ static ulong rk3568_pwm_set_pmuclk(struct rk3568_pmuclk_priv *priv,
 			src_clk_div = DIV_ROUND_UP(priv->ppll_hz, rate);
 			assert(src_clk_div - 1 <= 127);
 			rk_clrsetreg(&pmucru->pmu_clksel_con[6],
-				     CLK_PWM0_DIV_MASK | CLK_PWM0_DIV_MASK,
+				     CLK_PWM0_SEL_MASK | CLK_PWM0_DIV_MASK,
 				     (CLK_PWM0_SEL_PPLL << CLK_PWM0_SEL_SHIFT) |
 				     (src_clk_div - 1) << CLK_PWM0_DIV_SHIFT);
 		}
Signature · 1 line
2.55.0
Reviewed-by on v2 8/37
#16 lore raw

Re: [PATCH v2 08/37] clk: rockchip: rk3568: Fix PWM0 parent selection mask

Quoted 11 lines · Jonas Karlman

clk: rockchip: rk3568: Fix PWM0 parent selection mask

The CLK_PWM0 divider mask is used twice, leaving the parent selection unchanged. Change to use the intended CLK_PWM0 parent selection mask.

Fixes 4a262feba3a5 ("rockchip: rk3568: add clock driver")
 drivers/clk/rockchip/clk_rk3568.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#17 lore raw

PATCH v2 9/37 clk: rockchip: rk3568: Use PWM0 divider shift

In reply to Jonas Karlman

Use CLK_PWM0_DIV_SHIFT rather than CLK_PWM0_SEL_SHIFT when writing the PWM0 divider and the oscillator was selected as parent.

This has no behavior change, shifting zero by either constant still result in same zero value.

Fixes 4a262feba3a5 ("rockchip: rk3568: add clock driver")

---
Changes in v2:
- Split from "rk3568: Fix trivial clock configuration errors"
- Add fixes tag
- Collect r-b tag

---
 drivers/clk/rockchip/clk_rk3568.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk_rk3568.c +1 -1
index 88bbfb68cac6..398f76488470 100644
@@ -294,7 +294,7 @@ static ulong rk3568_pwm_set_pmuclk(struct rk3568_pmuclk_priv *priv,
 				     CLK_PWM0_SEL_MASK | CLK_PWM0_DIV_MASK,
 				     (CLK_PWM0_SEL_XIN24M <<
 				      CLK_PWM0_SEL_SHIFT) |
-				     0 << CLK_PWM0_SEL_SHIFT);
+				     0 << CLK_PWM0_DIV_SHIFT);
 		} else {
 			src_clk_div = DIV_ROUND_UP(priv->ppll_hz, rate);
 			assert(src_clk_div - 1 <= 127);
Signature · 1 line
2.55.0
Reviewed-by on v2 9/37
#18 lore raw

Re: [PATCH v2 09/37] clk: rockchip: rk3568: Use PWM0 divider shift

Quoted 8 lines · Jonas Karlman

clk: rockchip: rk3568: Use PWM0 divider shift

Use CLK_PWM0_DIV_SHIFT rather than CLK_PWM0_SEL_SHIFT when writing the PWM0 divider and the oscillator was selected as parent.

This has no behavior change, shifting zero by either constant still result in same zero value.

Quoted 6 lines
Fixes 4a262feba3a5 ("rockchip: rk3568: add clock driver")
 drivers/clk/rockchip/clk_rk3568.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#19 lore raw

PATCH v2 10/37 clk: rockchip: rk3568: Use correct PLL rate for CLK_MAC0_2TOP

In reply to Jonas Karlman

Use the PPLL rate instead of HPLL rate when the PPLL is parent of the CLK_MAC0_2TOP clock.

Fixes 4a262feba3a5 ("rockchip: rk3568: add clock driver")

---
Changes in v2:
- Split from "rk3568: Fix trivial clock configuration errors"
- Add fixes tag
- Collect r-b tag

---
 drivers/clk/rockchip/clk_rk3568.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk_rk3568.c +1 -1
index 398f76488470..940b824103cc 100644
@@ -1882,7 +1882,7 @@ static ulong rk3568_gmac_src_get_clk(struct rk3568_clk_priv *priv,
 	case CLK_MAC0_2TOP_SEL_25M:
 		return 25 * MHz;
 	case CLK_MAC0_2TOP_SEL_PPLL:
-		return rk3568_pmu_pll_get_rate(priv, HPLL);
+		return rk3568_pmu_pll_get_rate(priv, PPLL);
 	default:
 		return -ENOENT;
 	}
Signature · 1 line
2.55.0
Reviewed-by on v2 10/37
#20 lore raw

Re: [PATCH v2 10/37] clk: rockchip: rk3568: Use correct PLL rate for CLK_MAC0_2TOP

Quoted 11 lines · Jonas Karlman

clk: rockchip: rk3568: Use correct PLL rate for CLK_MAC0_2TOP

Use the PPLL rate instead of HPLL rate when the PPLL is parent of the CLK_MAC0_2TOP clock.

Fixes 4a262feba3a5 ("rockchip: rk3568: add clock driver")
 drivers/clk/rockchip/clk_rk3568.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#21 lore raw

PATCH v2 11/37 clk: rockchip: rk3588: Use GPLL rate for CLK_TSADC

In reply to Jonas Karlman

Use the GPLL rate instead of using a hardcoded 100 MHz parent rate when GPLL is parent of the CLK_TSADC clock.

Fixes 7a474df74023 ("clk: rockchip: Add rk3588 clk support")

---
Changes in v2:
- Split from "rk3588: Fix trivial clock configuration errors"
- Add fixes tag

---
 drivers/clk/rockchip/clk_rk3588.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk_rk3588.c +1 -1
index b9fd4bec311b..a4fd3a57ad7f 100644
@@ -655,7 +655,7 @@ static ulong rk3588_adc_get_clk(struct rk3588_clk_priv *priv, ulong clk_id)
 		if (sel == CLK_TSADC_SEL_24M)
 			prate = OSC_HZ;
 		else
-			prate = 100 * MHz;
+			prate = priv->gpll_hz;
 		return DIV_TO_RATE(prate, div);
 	default:
 		return -ENOENT;
Signature · 1 line
2.55.0
Reviewed-by on v2 11/37
#22 lore raw

Re: [PATCH v2 11/37] clk: rockchip: rk3588: Use GPLL rate for CLK_TSADC

Quoted 10 lines · Jonas Karlman

clk: rockchip: rk3588: Use GPLL rate for CLK_TSADC

Use the GPLL rate instead of using a hardcoded 100 MHz parent rate when GPLL is parent of the CLK_TSADC clock.

Fixes 7a474df74023 ("clk: rockchip: Add rk3588 clk support")
 drivers/clk/rockchip/clk_rk3588.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#23 lore raw

PATCH v2 12/37 clk: rockchip: rk3588: Use correct PLL rate for SCLK_UARTx divider

In reply to Jonas Karlman

Calculate the divider from the CPLL rate instead of the GPLL rate when CPLL is selected as the SCLK_UARTx parent.

Fixes 7a474df74023 ("clk: rockchip: Add rk3588 clk support")

---
Changes in v2:
- Split from "rk3588: Fix trivial clock configuration errors"
- Add fixes tag

---
 drivers/clk/rockchip/clk_rk3588.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk_rk3588.c +1 -1
index a4fd3a57ad7f..dbb4cd57e250 100644
@@ -1343,7 +1343,7 @@ static ulong rk3588_uart_set_rate(struct rk3588_clk_priv *priv,
 	} else if (priv->cpll_hz % rate == 0) {
 		clk_src = CLK_UART_SRC_SEL_CPLL;
 		uart_src = CLK_UART_SEL_SRC;
-		div = DIV_ROUND_UP(priv->gpll_hz, rate);
+		div = DIV_ROUND_UP(priv->cpll_hz, rate);
 	} else if (rate == OSC_HZ) {
 		clk_src = CLK_UART_SRC_SEL_GPLL;
 		uart_src = CLK_UART_SEL_XIN24M;
Signature · 1 line
2.55.0
Reviewed-by on v2 12/37
#24 lore raw

Re: [PATCH v2 12/37] clk: rockchip: rk3588: Use correct PLL rate for SCLK_UARTx divider

Quoted 10 lines · Jonas Karlman

clk: rockchip: rk3588: Use correct PLL rate for SCLK_UARTx divider

Calculate the divider from the CPLL rate instead of the GPLL rate when CPLL is selected as the SCLK_UARTx parent.

Fixes 7a474df74023 ("clk: rockchip: Add rk3588 clk support")
 drivers/clk/rockchip/clk_rk3588.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#25 lore raw

PATCH v2 13/37 clk: rockchip: rk3588: Fix ACLK_BUS_ROOT divider encoding

In reply to Jonas Karlman

The ACLK_BUS_ROOT divider field stores the divisor minus one. Subtract one when writing the field so the clock uses the intended divisor.

Fixes 7a474df74023 ("clk: rockchip: Add rk3588 clk support")

---
Changes in v2:
- Split from "rk3588: Fix ACLK_BUS_ROOT rate set during probe"
- Add fixes tag
- Collect r-b tag

---
 drivers/clk/rockchip/clk_rk3588.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk_rk3588.c +1 -1
index dbb4cd57e250..50e0a27819df 100644
@@ -1927,7 +1927,7 @@ static void rk3588_clk_init(struct rk3588_clk_priv *priv)
 	rk_clrsetreg(&priv->cru->clksel_con[38],
 		     ACLK_BUS_ROOT_SEL_MASK |
 		     ACLK_BUS_ROOT_DIV_MASK,
-		     div << ACLK_BUS_ROOT_DIV_SHIFT);
+		     (div - 1) << ACLK_BUS_ROOT_DIV_SHIFT);
 
 	if (priv->cpll_hz != CPLL_HZ) {
 		ret = rockchip_pll_set_rate(&rk3588_pll_clks[CPLL], priv->cru,
Signature · 1 line
2.55.0
Reviewed-by on v2 13/37
#26 lore raw

Re: [PATCH v2 13/37] clk: rockchip: rk3588: Fix ACLK_BUS_ROOT divider encoding

Quoted 11 lines · Jonas Karlman

clk: rockchip: rk3588: Fix ACLK_BUS_ROOT divider encoding

The ACLK_BUS_ROOT divider field stores the divisor minus one. Subtract one when writing the field so the clock uses the intended divisor.

Fixes 7a474df74023 ("clk: rockchip: Add rk3588 clk support")
 drivers/clk/rockchip/clk_rk3588.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#27 lore raw

PATCH v2 14/37 clk: rockchip: rk3588: Set ACLK_BUS_ROOT to 375 MHz

In reply to Jonas Karlman

The clock driver always reports ACLK_BUS_ROOT rate as 375 MHz. However, the clock is initialized to use GPLL as parent and a target rate of 300 MHz, with GPLLs typicall 1.188 GHz rate the clock ends up at 297 MHz.

Change to use CPLL as parent and request a 375 MHz rate, the same rate that is already being reported by the driver and what the SoC DT uses in assigned-clock-rates. With CPLLs typicall 1.5 GHz rate, this matches the parent and rate Linux typically ends up using for this clock.

Fixes 716ed2a8c0bb ("clk: rockchip: rk3588: add hardcoded assigned clocks values")

---
Changes in v2:
- Split from "rk3588: Fix ACLK_BUS_ROOT rate set during probe"
- Add fixes tag
- Collect r-b tag

---
 drivers/clk/rockchip/clk_rk3588.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clk/rockchip/clk_rk3588.c +3 -3
index 50e0a27819df..872e36748caf 100644
@@ -1923,10 +1923,10 @@ static void rk3588_clk_init(struct rk3588_clk_priv *priv)
 {
 	int ret, div;
 
-	div = DIV_ROUND_UP(GPLL_HZ, 300 * MHz);
+	div = DIV_ROUND_UP(CPLL_HZ, 375 * MHz);
 	rk_clrsetreg(&priv->cru->clksel_con[38],
-		     ACLK_BUS_ROOT_SEL_MASK |
-		     ACLK_BUS_ROOT_DIV_MASK,
+		     ACLK_BUS_ROOT_SEL_MASK | ACLK_BUS_ROOT_DIV_MASK,
+		     (ACLK_BUS_ROOT_SEL_CPLL << ACLK_BUS_ROOT_SEL_SHIFT) |
 		     (div - 1) << ACLK_BUS_ROOT_DIV_SHIFT);
 
 	if (priv->cpll_hz != CPLL_HZ) {
Signature · 1 line
2.55.0
#28 lore raw

Re: [PATCH v2 14/37] clk: rockchip: rk3588: Set ACLK_BUS_ROOT to 375 MHz

Hi Jonas,

Quoted 5 lines · Jonas Karlman

clk: rockchip: rk3588: Set ACLK_BUS_ROOT to 375 MHz

The clock driver always reports ACLK_BUS_ROOT rate as 375 MHz. However, the clock is initialized to use GPLL as parent and a target rate of 300 MHz, with GPLLs typicall 1.188 GHz rate the clock ends up at 297 MHz.

'typicall' should be 'typical', here and in the next paragraph, and 'GPLLs' and 'CPLLs' should be 'GPLL's' and 'CPLL's'. Please can you fix these if you send a v3.

The code change looks fine to me. It matches the assigned-clock-rates value in the SoC DT and the 375 MHz that rk3588_clk_get_rate() reports.

Quoted 6 lines

Change to use CPLL as parent and request a 375 MHz rate, the same rate that is already being reported by the driver and what the SoC DT uses in assigned-clock-rates. With CPLLs typicall 1.5 GHz rate, this matches the parent and rate Linux typically ends up using for this clock.

Quoted 6 lines
Fixes 716ed2a8c0bb ("clk: rockchip: rk3588: add hardcoded assigned clocks values")
 drivers/clk/rockchip/clk_rk3588.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Regards,
Simon

#29 lore raw

PATCH v2 15/37 clk: rockchip: rk3588: Remove redundant PLL register macros

In reply to Jonas Karlman

Remove the duplicate RK3588_PLL_CON definition and the unused RK3588_MODE_CON definition. RK3588_MODE_CON0 is used by the driver.

Fixes 165d258386a7 ("arm: rockchip: Add cru header for rk3588")

---
Changes in v2:
- Split from "rk3588: Fix trivial clock configuration errors"
- Add fixes tag

---
 arch/arm/include/asm/arch-rockchip/cru_rk3588.h | 3 ---
 1 file changed, 3 deletions(-)
arch/arm/include/asm/arch-rockchip/cru_rk3588.h +0 -3
index afce8a44af3b..c83010e518ee 100644
@@ -105,9 +105,6 @@ struct pll_rate_table {
 	unsigned int k;
 };
 
-#define RK3588_PLL_CON(x)		((x) * 0x4)
-#define RK3588_MODE_CON			0x280
-
 #define RK3588_PHP_CRU_BASE		0x8000
 #define RK3588_PMU_CRU_BASE		0x30000
 #define RK3588_BIGCORE0_CRU_BASE	0x50000
Signature · 1 line
2.55.0
Reviewed-by on v2 15/37
#30 lore raw

Re: [PATCH v2 15/37] clk: rockchip: rk3588: Remove redundant PLL register macros

Quoted 10 lines · Jonas Karlman

clk: rockchip: rk3588: Remove redundant PLL register macros

Remove the duplicate RK3588_PLL_CON definition and the unused RK3588_MODE_CON definition. RK3588_MODE_CON0 is used by the driver.

Fixes 165d258386a7 ("arm: rockchip: Add cru header for rk3588")
 arch/arm/include/asm/arch-rockchip/cru_rk3588.h | 3 ---
 1 file changed, 3 deletions(-)
#31 lore raw

PATCH v2 16/37 clk: rockchip: rk3588: Rename PPLL register macro

In reply to Jonas Karlman

The PPLL registers belong to the PHP CRU, rather than the PMU CRU. Rename the register macro and update the PPLL entry to reflect this.

Fixes 165d258386a7 ("arm: rockchip: Add cru header for rk3588")

---
Changes in v2:
- Split from "rk3588: Fix trivial clock configuration errors"
- Add fixes tag

---
 arch/arm/include/asm/arch-rockchip/cru_rk3588.h | 2 +-
 drivers/clk/rockchip/clk_rk3588.c               | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/include/asm/arch-rockchip/cru_rk3588.h +1 -1
index c83010e518ee..39295adeb38a 100644
@@ -126,10 +126,10 @@ struct pll_rate_table {
 #define RK3588_SDMMC_CON0		0xC30
 #define RK3588_SDMMC_CON1		0xC34
 
+#define RK3588_PHP_PLL_CON(x)		((x) * 0x4 + RK3588_PHP_CRU_BASE)
 #define RK3588_PHP_CLKGATE_CON(x)	((x) * 0x4 + RK3588_PHP_CRU_BASE + 0x800)
 #define RK3588_PHP_SOFTRST_CON(x)	((x) * 0x4 + RK3588_PHP_CRU_BASE + 0xa00)
 
-#define RK3588_PMU_PLL_CON(x)		((x) * 0x4 + RK3588_PHP_CRU_BASE)
 #define RK3588_PMU_CLKSEL_CON(x)	((x) * 0x4 + RK3588_PMU_CRU_BASE + 0x300)
 #define RK3588_PMU_CLKGATE_CON(x)	((x) * 0x4 + RK3588_PMU_CRU_BASE + 0x800)
 #define RK3588_PMU_SOFTRST_CON(x)	((x) * 0x4 + RK3588_PMU_CRU_BASE + 0xa00)
drivers/clk/rockchip/clk_rk3588.c +1 -1
index 872e36748caf..3b21c7f8465d 100644
@@ -61,7 +61,7 @@ static struct rockchip_pll_clock rk3588_pll_clks[] = {
 		     RK3588_MODE_CON0, 2, 15, 0, rk3588_pll_rates),
 	[NPLL] = PLL(pll_rk3588, PLL_NPLL, RK3588_PLL_CON(120),
 		     RK3588_MODE_CON0, 0, 15, 0, rk3588_pll_rates),
-	[PPLL] = PLL(pll_rk3588, PLL_PPLL, RK3588_PMU_PLL_CON(128),
+	[PPLL] = PLL(pll_rk3588, PLL_PPLL, RK3588_PHP_PLL_CON(128),
 		     RK3588_MODE_CON0, 10, 15, ROCKCHIP_PLL_FIXED_MODE,
 		     rk3588_pll_rates),
 #ifdef CONFIG_XPL_BUILD
Signature · 1 line
2.55.0
Reviewed-by on v2 16/37
#32 lore raw

Re: [PATCH v2 16/37] clk: rockchip: rk3588: Rename PPLL register macro

Quoted 11 lines · Jonas Karlman

clk: rockchip: rk3588: Rename PPLL register macro

The PPLL registers belong to the PHP CRU, rather than the PMU CRU. Rename the register macro and update the PPLL entry to reflect this.

Fixes 165d258386a7 ("arm: rockchip: Add cru header for rk3588")
 arch/arm/include/asm/arch-rockchip/cru_rk3588.h | 2 +-
 drivers/clk/rockchip/clk_rk3588.c               | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
#33 lore raw

PATCH v2 17/37 clk: rockchip: rk3588: Align BxPLL entries in PLL table

In reply to Jonas Karlman

Keep the B0PLL and B1PLL entries formatted in a similar way matching the other PLL entries for consistency.

---
v2: Split from "rk3588: Fix trivial clock configuration errors"

---
 drivers/clk/rockchip/clk_rk3588.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/clk/rockchip/clk_rk3588.c +2 -4
index 3b21c7f8465d..aba200ad2390 100644
@@ -44,11 +44,9 @@ static struct rockchip_pll_rate_table rk3588_pll_rates[] = {
 
 static struct rockchip_pll_clock rk3588_pll_clks[] = {
 	[B0PLL] = PLL(pll_rk3588, PLL_B0PLL, RK3588_B0_PLL_CON(0),
-		      RK3588_B0_PLL_MODE_CON, 0, 15, 0,
-		      rk3588_pll_rates),
+		      RK3588_B0_PLL_MODE_CON, 0, 15, 0, rk3588_pll_rates),
 	[B1PLL] = PLL(pll_rk3588, PLL_B1PLL, RK3588_B1_PLL_CON(8),
-		      RK3588_B1_PLL_MODE_CON, 0, 15, 0,
-		      rk3588_pll_rates),
+		      RK3588_B1_PLL_MODE_CON, 0, 15, 0, rk3588_pll_rates),
 	[LPLL] = PLL(pll_rk3588, PLL_LPLL, RK3588_LPLL_CON(16),
 		     RK3588_LPLL_MODE_CON, 0, 15, 0, rk3588_pll_rates),
 	[V0PLL] = PLL(pll_rk3588, PLL_V0PLL, RK3588_PLL_CON(88),
Signature · 1 line
2.55.0
Reviewed-by on v2 17/37
#34 lore raw

Re: [PATCH v2 17/37] clk: rockchip: rk3588: Align BxPLL entries in PLL table

Quoted 9 lines · Jonas Karlman

clk: rockchip: rk3588: Align BxPLL entries in PLL table

Keep the B0PLL and B1PLL entries formatted in a similar way matching the other PLL entries for consistency.

 drivers/clk/rockchip/clk_rk3588.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
#35 lore raw

PATCH v2 18/37 clk: rockchip: rk3588: Use SPLL_HZ constant

In reply to Jonas Karlman

The SPLL rate is set to SPLL_HZ (702 MHz) in SPL phase.

Replace '702 * MHz' with use of the SPLL_HZ constant for consistency.

---
Changes in v2:
- Update commit message
- Collect r-b tag

---
 drivers/clk/rockchip/clk_rk3588.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/clk/rockchip/clk_rk3588.c +4 -4
index aba200ad2390..662ff44397ac 100644
@@ -777,7 +777,7 @@ static ulong rk3588_mmc_get_clk(struct rk3588_clk_priv *priv, ulong clk_id)
 		sel = (con & DCLK_DECOM_SEL_MASK) >>
 		      DCLK_DECOM_SEL_SHIFT;
 		if (sel == DCLK_DECOM_SEL_SPLL)
-			prate = 702 * MHz;
+			prate = SPLL_HZ;
 		else
 			prate = priv->gpll_hz;
 		return DIV_TO_RATE(prate, div);
@@ -817,9 +817,9 @@ static ulong rk3588_mmc_set_clk(struct rk3588_clk_priv *priv,
 		}
 		break;
 	case DCLK_DECOM:
-		if (!(702 * MHz % rate)) {
+		if (!(SPLL_HZ % rate)) {
 			src_clk = DCLK_DECOM_SEL_SPLL;
-			div = DIV_ROUND_UP(702 * MHz, rate);
+			div = DIV_ROUND_UP(SPLL_HZ, rate);
 		} else {
 			src_clk = DCLK_DECOM_SEL_GPLL;
 			div = DIV_ROUND_UP(priv->gpll_hz, rate);
@@ -942,7 +942,7 @@ static ulong rk3588_aclk_vop_get_clk(struct rk3588_clk_priv *priv, ulong clk_id)
 		else if (sel == ACLK_VOP_ROOT_SEL_NPLL)
 			parent = priv->npll_hz;
 		else
-			parent = 702 * MHz;
+			parent = SPLL_HZ;
 		return DIV_TO_RATE(parent, div);
 	case ACLK_VOP_LOW_ROOT:
 		con = readl(&cru->clksel_con[110]);
Signature · 1 line
2.55.0
Reviewed-by on v2 18/37
#36 lore raw

Re: [PATCH v2 18/37] clk: rockchip: rk3588: Use SPLL_HZ constant

Quoted 11 lines · Jonas Karlman

clk: rockchip: rk3588: Use SPLL_HZ constant

The SPLL rate is set to SPLL_HZ (702 MHz) in SPL phase.

Replace '702 * MHz' with use of the SPLL_HZ constant for consistency.

 drivers/clk/rockchip/clk_rk3588.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
#37 lore raw

PATCH v2 19/37 clk: rockchip: rk3576: Use correct mode register for VPLL

In reply to Jonas Karlman

Change to use correct PLL mode register when VPLL rate is changed.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

---
Changes in v2:
- Split from "rk3576: Fix trivial clock configuration errors"
- Add fixes tag

---
 drivers/clk/rockchip/clk_rk3576.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk_rk3576.c +1 -1
index 92bde425b0ee..abfd57e2447e 100644
@@ -49,7 +49,7 @@ static struct rockchip_pll_clock rk3576_pll_clks[] = {
 	[LPLL] = PLL(pll_rk3588, PLL_LPLL, RK3576_LPLL_CON(16),
 		     RK3576_LPLL_MODE_CON0, 0, 15, 0, rk3576_24m_pll_rates),
 	[VPLL] = PLL(pll_rk3588, PLL_VPLL, RK3576_PLL_CON(88),
-		      RK3576_LPLL_MODE_CON0, 4, 15, 0, rk3576_24m_pll_rates),
+		     RK3576_MODE_CON0, 4, 15, 0, rk3576_24m_pll_rates),
 	[AUPLL] = PLL(pll_rk3588, PLL_AUPLL, RK3576_PLL_CON(96),
 		      RK3576_MODE_CON0, 6, 15, 0, rk3576_24m_pll_rates),
 	[CPLL] = PLL(pll_rk3588, PLL_CPLL, RK3576_PLL_CON(104),
Signature · 1 line
2.55.0
Reviewed-by on v2 19/37
#38 lore raw

Re: [PATCH v2 19/37] clk: rockchip: rk3576: Use correct mode register for VPLL

Quoted 9 lines · Jonas Karlman

clk: rockchip: rk3576: Use correct mode register for VPLL

Change to use correct PLL mode register when VPLL rate is changed.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")
 drivers/clk/rockchip/clk_rk3576.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by on v2 19/37
#39 lore raw

Re: [PATCH v2 19/37] clk: rockchip: rk3576: Use correct mode register for VPLL

In reply to Jonas Karlman

Hi Jonas,

Quoted 4 lines · Jonas Karlman

Change to use correct PLL mode register when VPLL rate is changed.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

Looking at the other clocks, I **think** RK3576_BPLL_MODE_CON0 and RK3576_LPLL_MODE_CON0 are completely wrong?

The offsets should be

(0x27238000 - 0x27200000 + 0x280)
(0x27240000 - 0x27200000 + 0x280)

no? At the same time, I don't think it matters since we won't change the LPLL and BPLL (LITTLE and big cores PLL I believe?) in U-Boot. It seems that the kernel has it correct though and they have

#define RK3576_BIGCORE_CRU_BASE 0x38000
#define RK3576_LITCORE_CRU_BASE 0x40000

Thanks!
Quentin

#40 lore raw

Re: [PATCH v2 19/37] clk: rockchip: rk3576: Use correct mode register for VPLL

Hi Quentin,

Quoted 5 lines · Quentin Schulz

Hi Jonas,

Quoted 2 lines · Jonas Karlman

Change to use correct PLL mode register when VPLL rate is changed.

Quoted 7 lines
Quoted 2 lines
Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

Looking at the other clocks, I **think** RK3576_BPLL_MODE_CON0 and RK3576_LPLL_MODE_CON0 are completely wrong?

They should be correct and match what you describe below?

Quoted 7 lines

The offsets should be

(0x27238000 - 0x27200000 + 0x280)
(0x27240000 - 0x27200000 + 0x280)

no?

Correct, the MODE_CON0 are expected to be the offset from base parameter to rockchip_pll_set_rate(), i.e. priv->cru, 0x27200000 for RK3576.

With below defines in cru_rk3576.h the MODE_CON0s should end up with same values as you describe above, or am I missing something?

  #define RK3576_BIGCORE_CRU_BASE		0x38000
  #define RK3576_LITCORE_CRU_BASE		0x40000

  #define RK3576_CRU_BASE			0x27200000

  #define RK3576_BPLL_MODE_CON0		(RK3576_BIGCORE_CRU_BASE + 0x280)
  #define RK3576_LPLL_MODE_CON0		(RK3576_LITCORE_CRU_BASE + 0x280)

I see now that there are exact GRF base addresses in addition to relative CRU base addresses, maybe that adds to some confusion?

For the pending future refactoring series I have instead opted to define all exact CRU base addresses, and instead uses something like:

  #define RK3576_CRU_BASE			0x27200000
  #define RK3576_BIGCORE_CRU_BASE		0x27238000
  #define RK3576_LITCORE_CRU_BASE		0x27240000

  #define RK3576_BPLL_MODE_CON0		(RK3576_BIGCORE_CRU_BASE - RK3576_CRU_BASE + 0x0280)
  #define RK3576_LPLL_MODE_CON0		(RK3576_LITCORE_CRU_BASE - RK3576_CRU_BASE + 0x0280)

To avoid mixing defines of exact and relative CRU base addresses.

Quoted 6 lines

At the same time, I don't think it matters since we won't change the LPLL and BPLL (LITTLE and big cores PLL I believe?) in U-Boot. It seems that the kernel has it correct though and they have

#define RK3576_BIGCORE_CRU_BASE 0x38000
#define RK3576_LITCORE_CRU_BASE 0x40000

This also seem to match what is currently used in cru_rk3576.h.

Regards,
Jonas

Quoted 3 lines

Thanks!
Quentin

#41 lore raw

Re: [PATCH v2 19/37] clk: rockchip: rk3576: Use correct mode register for VPLL

Hi Jonas,

Quoted 55 lines · Jonas Karlman

Hi Quentin,

Quoted 5 lines · Quentin Schulz

Hi Jonas,

Quoted 2 lines · Jonas Karlman

Change to use correct PLL mode register when VPLL rate is changed.

Quoted 7 lines
Quoted 2 lines
Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

Looking at the other clocks, I **think** RK3576_BPLL_MODE_CON0 and RK3576_LPLL_MODE_CON0 are completely wrong?

They should be correct and match what you describe below?

Quoted 7 lines

The offsets should be

(0x27238000 - 0x27200000 + 0x280)
(0x27240000 - 0x27200000 + 0x280)

no?

Correct, the MODE_CON0 are expected to be the offset from base parameter to rockchip_pll_set_rate(), i.e. priv->cru, 0x27200000 for RK3576.

With below defines in cru_rk3576.h the MODE_CON0s should end up with same values as you describe above, or am I missing something?

   #define RK3576_BIGCORE_CRU_BASE		0x38000
   #define RK3576_LITCORE_CRU_BASE		0x40000

   #define RK3576_CRU_BASE			0x27200000

   #define RK3576_BPLL_MODE_CON0		(RK3576_BIGCORE_CRU_BASE + 0x280)
   #define RK3576_LPLL_MODE_CON0		(RK3576_LITCORE_CRU_BASE + 0x280)

I see now that there are exact GRF base addresses in addition to relative CRU base addresses, maybe that adds to some confusion?

For the pending future refactoring series I have instead opted to define all exact CRU base addresses, and instead uses something like:

   #define RK3576_CRU_BASE			0x27200000
   #define RK3576_BIGCORE_CRU_BASE		0x27238000
   #define RK3576_LITCORE_CRU_BASE		0x27240000

   #define RK3576_BPLL_MODE_CON0		(RK3576_BIGCORE_CRU_BASE - RK3576_CRU_BASE + 0x0280)
   #define RK3576_LPLL_MODE_CON0		(RK3576_LITCORE_CRU_BASE - RK3576_CRU_BASE + 0x0280)

To avoid mixing defines of exact and relative CRU base addresses.

Quoted 9 lines
Quoted 6 lines

At the same time, I don't think it matters since we won't change the LPLL and BPLL (LITTLE and big cores PLL I believe?) in U-Boot. It seems that the kernel has it correct though and they have

#define RK3576_BIGCORE_CRU_BASE 0x38000
#define RK3576_LITCORE_CRU_BASE 0x40000

This also seem to match what is currently used in cru_rk3576.h.

Seems like I somehow missed this mail and checked locally before sending https://lore.kernel.org/u-boot/[email protected]/ and indeed I came to the same conclusion: I got confused by the GRF base addresses, the current macros/constants are sound. Thanks for checking on your side, it is reassuring we came to the same conclusion separately :)

As for the rework: I would like to have the same value in U-Boot driver vs the Linux kernel driver, otherwise it'll make porting fixes too error-prone I believe. It's fine to set it to addr - cru_base_addr instead of a hardcoded value but the meaning of the same constant should stay the same between the kernel and U-Boot.

Cheers,
Quentin

#42 lore raw

PATCH v2 20/37 clk: rockchip: rk3576: Fix ACLK_TOP_MID parent selection

In reply to Jonas Karlman

Write the intended parent clock for the calculated divisor instead of forcing it to GPLL when ACLK_TOP_MID rate is changed.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

---
Changes in v2:
- Split from "rk3576: Fix trivial clock configuration errors"
- Add fixes tag

---
 drivers/clk/rockchip/clk_rk3576.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/clk/rockchip/clk_rk3576.c +1 -2
index abfd57e2447e..b4a5a145bab0 100644
@@ -320,8 +320,7 @@ static ulong rk3576_top_set_clk(struct rk3576_clk_priv *priv,
 		rk_clrsetreg(&cru->clksel_con[10],
 			     ACLK_TOP_MID_DIV_MASK |
 			     ACLK_TOP_MID_SEL_MASK,
-			     (ACLK_TOP_MID_SEL_GPLL <<
-			      ACLK_TOP_MID_SEL_SHIFT) |
+			     (src_clk << ACLK_TOP_MID_SEL_SHIFT) |
 			     (src_clk_div - 1) << ACLK_TOP_MID_DIV_SHIFT);
 		break;
 	case PCLK_TOP_ROOT:
Signature · 1 line
2.55.0
Reviewed-by on v2 20/37
#43 lore raw

Re: [PATCH v2 20/37] clk: rockchip: rk3576: Fix ACLK_TOP_MID parent selection

Hi Jonas,

Quoted 13 lines · Jonas Karlman

clk: rockchip: rk3576: Fix ACLK_TOP_MID parent selection

Write the intended parent clock for the calculated divisor instead of forcing it to GPLL when ACLK_TOP_MID rate is changed.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")
 drivers/clk/rockchip/clk_rk3576.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

drivers/clk/rockchip/clk_rk3576.c static ulong rk3576_top_set_clk(struct rk3576_clk_priv *priv, · line 321

Quoted 4 lines
drivers/clk/rockchip/clk_rk3576.c +1 -2
@@ -320,8 +320,7 @@ static ulong rk3576_top_set_clk(struct rk3576_clk_priv *priv,
-			     (ACLK_TOP_MID_SEL_GPLL <<
-			      ACLK_TOP_MID_SEL_SHIFT) |
+			     (src_clk << ACLK_TOP_MID_SEL_SHIFT) |
 			     (src_clk_div - 1) << ACLK_TOP_MID_DIV_SHIFT);

BTW the ACLK_TOP case just above has a similar copy-paste mistake. It shifts the divider by the select shift:

    (src_clk_div - 1) << ACLK_TOP_SEL_SHIFT);

It should use ACLK_TOP_DIV_SHIFT (0). As it stands the divider lands in bits 5 and 6 and overwrites the parent selection, while the real divider field is cleared, so ACLK_TOP gets the wrong rate whenever it is set. It would be worth fixing this in the series, either here or in a separate patch.

Reviewed-by on v2 20/37
#44 lore raw

Re: [PATCH v2 20/37] clk: rockchip: rk3576: Fix ACLK_TOP_MID parent selection

In reply to Jonas Karlman

Hi Jonas,

Quoted 5 lines · Jonas Karlman

Write the intended parent clock for the calculated divisor instead of forcing it to GPLL when ACLK_TOP_MID rate is changed.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

Thanks!
Quentin

#45 lore raw

PATCH v2 21/37 clk: rockchip: rk3576: Fix I2C rate selection

In reply to Jonas Karlman

The I2C clocks supports use of source clocks with 200, 100, 50 or 24 MHz rates. However, the driver fails to select any source other than the 50 or 24 MHz source clocks.

Fix code logic to allow selection of all four supported source clocks.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

---
Changes in v2:
- Split from "rk3576: Fix trivial clock configuration errors"
- Add fixes tag

---
 drivers/clk/rockchip/clk_rk3576.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk_rk3576.c +1 -1
index b4a5a145bab0..314a543895a3 100644
@@ -428,7 +428,7 @@ static ulong rk3576_i2c_set_clk(struct rk3576_clk_priv *priv, ulong clk_id,
 		src_clk = CLK_I2C_SEL_200M;
 	else if (rate >= 99 * MHz)
 		src_clk = CLK_I2C_SEL_100M;
-	if (rate >= 50 * MHz)
+	else if (rate >= 50 * MHz)
 		src_clk = CLK_I2C_SEL_50M;
 	else
 		src_clk = CLK_I2C_SEL_OSC;
Signature · 1 line
2.55.0
Reviewed-by on v2 21/37
#46 lore raw

Re: [PATCH v2 21/37] clk: rockchip: rk3576: Fix I2C rate selection

Quoted 6 lines · Jonas Karlman

clk: rockchip: rk3576: Fix I2C rate selection

The I2C clocks supports use of source clocks with 200, 100, 50 or 24 MHz rates. However, the driver fails to select any source other than the 50 or 24 MHz source clocks.

Quoted 7 lines

Fix code logic to allow selection of all four supported source clocks.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")
 drivers/clk/rockchip/clk_rk3576.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by on v2 21/37
#47 lore raw

Re: [PATCH v2 21/37] clk: rockchip: rk3576: Fix I2C rate selection

In reply to Jonas Karlman

Hi Jonas,

Quoted 8 lines · Jonas Karlman

The I2C clocks supports use of source clocks with 200, 100, 50 or 24 MHz rates. However, the driver fails to select any source other than the 50 or 24 MHz source clocks.

Fix code logic to allow selection of all four supported source clocks.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

Thanks!
Quentin

#48 lore raw

PATCH v2 22/37 clk: rockchip: rk3576: Fix CLK_I2C8 rate change

In reply to Jonas Karlman

Add missing break to prevent rate change of CLK_I2C8 to fall through and also affect the CLK_I2C9 rate.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

---
Changes in v2:
- Split from "rk3576: Fix trivial clock configuration errors"
- Add fixes tag

---
 drivers/clk/rockchip/clk_rk3576.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/rockchip/clk_rk3576.c +1 -0
index 314a543895a3..04b0f6b13ed3 100644
@@ -469,6 +469,7 @@ static ulong rk3576_i2c_set_clk(struct rk3576_clk_priv *priv, ulong clk_id,
 	case CLK_I2C8:
 		rk_clrsetreg(&cru->clksel_con[57], CLK_I2C8_SEL_MASK,
 			     src_clk << CLK_I2C8_SEL_SHIFT);
+		break;
 	case CLK_I2C9:
 		rk_clrsetreg(&cru->clksel_con[58], CLK_I2C9_SEL_MASK,
 			     src_clk << CLK_I2C9_SEL_SHIFT);
Signature · 1 line
2.55.0
Reviewed-by on v2 22/37
#49 lore raw

Re: [PATCH v2 22/37] clk: rockchip: rk3576: Fix CLK_I2C8 rate change

Quoted 10 lines · Jonas Karlman

clk: rockchip: rk3576: Fix CLK_I2C8 rate change

Add missing break to prevent rate change of CLK_I2C8 to fall through and also affect the CLK_I2C9 rate.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")
 drivers/clk/rockchip/clk_rk3576.c | 1 +
 1 file changed, 1 insertion(+)
#51 lore raw

PATCH v2 23/37 clk: rockchip: rk3576: Use correct clock register for CLK_SARADC

In reply to Jonas Karlman

Parent and divider fields for CLK_SARADC are located in CLKSEL_CON58 not in CLKSEL_CON59. Change to use correct CLKSEL_CON for the CLK_SARADC clock.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

---
Changes in v2:
- Split from "rk3576: Fix trivial clock configuration errors"
- Add fixes tag

---
 drivers/clk/rockchip/clk_rk3576.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk_rk3576.c +1 -1
index 04b0f6b13ed3..17f9b01ff0c8 100644
@@ -691,7 +691,7 @@ static ulong rk3576_adc_set_clk(struct rk3576_clk_priv *priv,
 		} else {
 			src_clk_div = DIV_ROUND_UP(priv->gpll_hz, rate);
 			assert(src_clk_div - 1 <= 255);
-			rk_clrsetreg(&cru->clksel_con[59],
+			rk_clrsetreg(&cru->clksel_con[58],
 				     CLK_SARADC_SEL_MASK |
 				     CLK_SARADC_DIV_MASK,
 				     (CLK_SARADC_SEL_GPLL <<
Signature · 1 line
2.55.0
Reviewed-by on v2 23/37
#52 lore raw

Re: [PATCH v2 23/37] clk: rockchip: rk3576: Use correct clock register for CLK_SARADC

Quoted 11 lines · Jonas Karlman

clk: rockchip: rk3576: Use correct clock register for CLK_SARADC

Parent and divider fields for CLK_SARADC are located in CLKSEL_CON58 not in CLKSEL_CON59. Change to use correct CLKSEL_CON for the CLK_SARADC clock.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")
 drivers/clk/rockchip/clk_rk3576.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by on v2 23/37
#53 lore raw

Re: [PATCH v2 23/37] clk: rockchip: rk3576: Use correct clock register for CLK_SARADC

In reply to Jonas Karlman

Hi Jonas,

Quoted 6 lines · Jonas Karlman

Parent and divider fields for CLK_SARADC are located in CLKSEL_CON58 not in CLKSEL_CON59. Change to use correct CLKSEL_CON for the CLK_SARADC clock.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

Thanks!
Quentin

#54 lore raw

PATCH v2 24/37 clk: rockchip: rk3576: Use correct TSADC clock register

In reply to Jonas Karlman

Parent and divider fields for CLK_TSADC are located in CLKSEL_CON59 not in CLKSEL_CON58. Change to use correct CLKSEL_CON for the CLK_TSADC clock.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

---
Changes in v2:
- Split from "rk3576: Fix trivial clock configuration errors"
- Add fixes tag

---
 drivers/clk/rockchip/clk_rk3576.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk_rk3576.c +1 -1
index 17f9b01ff0c8..e66368b01b5e 100644
@@ -703,7 +703,7 @@ static ulong rk3576_adc_set_clk(struct rk3576_clk_priv *priv,
 	case CLK_TSADC:
 		src_clk_div = DIV_ROUND_UP(OSC_HZ, rate);
 		assert(src_clk_div - 1 <= 255);
-		rk_clrsetreg(&cru->clksel_con[58],
+		rk_clrsetreg(&cru->clksel_con[59],
 			     CLK_TSADC_DIV_MASK,
 			     (src_clk_div - 1) <<
 			     CLK_TSADC_DIV_SHIFT);
Signature · 1 line
2.55.0
Reviewed-by on v2 24/37
#55 lore raw

Re: [PATCH v2 24/37] clk: rockchip: rk3576: Use correct TSADC clock register

Quoted 11 lines · Jonas Karlman

clk: rockchip: rk3576: Use correct TSADC clock register

Parent and divider fields for CLK_TSADC are located in CLKSEL_CON59 not in CLKSEL_CON58. Change to use correct CLKSEL_CON for the CLK_TSADC clock.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")
 drivers/clk/rockchip/clk_rk3576.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by on v2 24/37
#56 lore raw

Re: [PATCH v2 24/37] clk: rockchip: rk3576: Use correct TSADC clock register

In reply to Jonas Karlman

Hi Jonas,

Quoted 6 lines · Jonas Karlman

Parent and divider fields for CLK_TSADC are located in CLKSEL_CON59 not in CLKSEL_CON58. Change to use correct CLKSEL_CON for the CLK_TSADC clock.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

Thanks!
Quentin

#57 lore raw

PATCH v2 25/37 clk: rockchip: rk3576: Use correct PLL rate for UART fractional clocks

In reply to Jonas Karlman

Use the GPLL rate instead of the CPLL rate when GPLL is selected as the UART fractional clock parent.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

---
Changes in v2:
- Split from "rk3576: Fix trivial clock configuration errors"
- Add fixes tag

---
 drivers/clk/rockchip/clk_rk3576.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk_rk3576.c +1 -1
index e66368b01b5e..7908a3c95765 100644
@@ -1715,7 +1715,7 @@ static ulong rk3576_uart_frac_set_rate(struct rk3576_clk_priv *priv,
 		p_rate = OSC_HZ;
 	} else {
 		clk_src = CLK_UART_SRC_SEL_GPLL;
-		p_rate = priv->cpll_hz;
+		p_rate = priv->gpll_hz;
 	}
 
 	rational_best_approximation(rate, p_rate, GENMASK(16 - 1, 0),
Signature · 1 line
2.55.0
Reviewed-by on v2 25/37
#58 lore raw

Re: [PATCH v2 25/37] clk: rockchip: rk3576: Use correct PLL rate for UART fractional clocks

Quoted 10 lines · Jonas Karlman

clk: rockchip: rk3576: Use correct PLL rate for UART fractional clocks

Use the GPLL rate instead of the CPLL rate when GPLL is selected as the UART fractional clock parent.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")
 drivers/clk/rockchip/clk_rk3576.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by on v2 25/37
#59 lore raw

Re: [PATCH v2 25/37] clk: rockchip: rk3576: Use correct PLL rate for UART fractional clocks

In reply to Jonas Karlman

Hi Jonas,

Quoted 5 lines · Jonas Karlman

Use the GPLL rate instead of the CPLL rate when GPLL is selected as the UART fractional clock parent.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

Thanks!
Quentin

#60 lore raw

PATCH v2 26/37 clk: rockchip: rk3576: Use correct PLL rate for UART divisor

In reply to Jonas Karlman

Calculate the UART divisor from the CPLL rate instead of the GPLL rate when CPLL is selected as parent clock.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

---
Changes in v2:
- Split from "rk3576: Fix trivial clock configuration errors"
- Add fixes tag

---
 drivers/clk/rockchip/clk_rk3576.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk_rk3576.c +1 -1
index 7908a3c95765..a7110b86c063 100644
@@ -1843,7 +1843,7 @@ static ulong rk3576_uart_set_rate(struct rk3576_clk_priv *priv,
 		div = DIV_ROUND_UP(priv->gpll_hz, rate);
 	} else if (!(priv->cpll_hz % rate)) {
 		clk_src = CLK_UART_SEL_CPLL;
-		div = DIV_ROUND_UP(priv->gpll_hz, rate);
+		div = DIV_ROUND_UP(priv->cpll_hz, rate);
 	} else if (!(rk3576_uart_frac_get_rate(priv, CLK_UART_FRAC_0) % rate)) {
 		clk_src = CLK_UART_SEL_FRAC0;
 		div = DIV_ROUND_UP(rk3576_uart_frac_get_rate(priv, CLK_UART_FRAC_0), rate);
Signature · 1 line
2.55.0
Reviewed-by on v2 26/37
#61 lore raw

Re: [PATCH v2 26/37] clk: rockchip: rk3576: Use correct PLL rate for UART divisor

Hi Jonas,

Quoted 13 lines · Jonas Karlman

clk: rockchip: rk3576: Use correct PLL rate for UART divisor

Calculate the UART divisor from the CPLL rate instead of the GPLL rate when CPLL is selected as parent clock.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")
 drivers/clk/rockchip/clk_rk3576.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

drivers/clk/rockchip/clk_rk3576.c static ulong rk3576_uart_set_rate(struct rk3576_clk_priv *priv, · line 1843

Quoted 2 lines
drivers/clk/rockchip/clk_rk3576.c +1 -1
@@ -1843,7 +1843,7 @@ static ulong rk3576_uart_set_rate(struct rk3576_clk_priv *priv,
-		div = DIV_ROUND_UP(priv->gpll_hz, rate);
+		div = DIV_ROUND_UP(priv->cpll_hz, rate);

BTW rk3576_uart_get_rate() a little higher up has a similar bug. For UART1 it uses the shift as the mask:

    src = (con & CLK_UART1_SRC_SEL_SHIFT) >> CLK_UART1_SRC_SEL_SHIFT;

so src is always 0 (GPLL) and SCLK_UART1 reports the wrong rate whenever another parent is selected. It should use CLK_UART1_SRC_SEL_MASK instead. That could go in a separate patch in this series, or in a follow-up.

Reviewed-by on v2 26/37
#62 lore raw

Re: [PATCH v2 26/37] clk: rockchip: rk3576: Use correct PLL rate for UART divisor

In reply to Jonas Karlman

Hi Jonas,

Quoted 5 lines · Jonas Karlman

Calculate the UART divisor from the CPLL rate instead of the GPLL rate when CPLL is selected as parent clock.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

Thanks!
Quentin

#63 lore raw

PATCH v2 27/37 clk: rockchip: rk3576: Rename PPLL register macro

In reply to Jonas Karlman

The PPLL registers belong to the PHP CRU, rather than the PMU CRU. Rename the register macro and update the PPLL entry and users to reflect this.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

---
Changes in v2:
- Split from "rk3576: Fix trivial clock configuration errors"
- Add fixes tag

---
 arch/arm/include/asm/arch-rockchip/cru_rk3576.h | 2 +-
 drivers/clk/rockchip/clk_rk3576.c               | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/include/asm/arch-rockchip/cru_rk3576.h +1 -1
index fb77fbd7307a..380151e0f8d5 100644
@@ -127,11 +127,11 @@ struct pll_rate_table {
 #define RK3576_SDMMC_CON0		0xC30
 #define RK3576_SDMMC_CON1		0xC34
 
+#define RK3576_PHP_PLL_CON(x)		((x) * 0x4 + RK3576_PHP_CRU_BASE)
 #define RK3576_PHP_CLKSEL_CON(x)	((x) * 0x4 + RK3576_PHP_CRU_BASE + 0x300)
 #define RK3576_PHP_CLKGATE_CON(x)	((x) * 0x4 + RK3576_PHP_CRU_BASE + 0x800)
 #define RK3576_PHP_SOFTRST_CON(x)	((x) * 0x4 + RK3576_PHP_CRU_BASE + 0xa00)
 
-#define RK3576_PMU_PLL_CON(x)		((x) * 0x4 + RK3576_PHP_CRU_BASE)
 #define RK3576_PMU_CLKSEL_CON(x)	((x) * 0x4 + RK3576_PMU_CRU_BASE + 0x300)
 #define RK3576_PMU_CLKGATE_CON(x)	((x) * 0x4 + RK3576_PMU_CRU_BASE + 0x800)
 #define RK3576_PMU_SOFTRST_CON(x)	((x) * 0x4 + RK3576_PMU_CRU_BASE + 0xa00)
drivers/clk/rockchip/clk_rk3576.c +2 -2
index a7110b86c063..ce97997c73ea 100644
@@ -56,7 +56,7 @@ static struct rockchip_pll_clock rk3576_pll_clks[] = {
 		     RK3576_MODE_CON0, 8, 15, 0, rk3576_24m_pll_rates),
 	[GPLL] = PLL(pll_rk3588, PLL_GPLL, RK3576_PLL_CON(112),
 		     RK3576_MODE_CON0, 2, 15, 0, rk3576_24m_pll_rates),
-	[PPLL] = PLL(pll_rk3588, PLL_PPLL, RK3576_PMU_PLL_CON(128),
+	[PPLL] = PLL(pll_rk3588, PLL_PPLL, RK3576_PHP_PLL_CON(128),
 		     RK3576_MODE_CON0, 10, 15, ROCKCHIP_PLL_FIXED_MODE,
 		     rk3576_24m_pll_rates),
 };
@@ -2458,7 +2458,7 @@ static int rk3576_clk_probe(struct udevice *dev)
 	       RK3576_SCRU_BASE + RK3576_MODE_CON0);
 	/* fix ppll\aupll\cpll */
 	writel(BITS_WITH_WMASK(2, 0x7U, 6),
-	       RK3576_CRU_BASE + RK3576_PMU_PLL_CON(129));
+	       RK3576_CRU_BASE + RK3576_PHP_PLL_CON(129));
 	writel(BITS_WITH_WMASK(2, 0x7U, 6),
 	       RK3576_CRU_BASE + RK3576_PLL_CON(97));
 	writel(BITS_WITH_WMASK(2, 0x7U, 6),
Signature · 1 line
2.55.0
Reviewed-by on v2 27/37
#64 lore raw

Re: [PATCH v2 27/37] clk: rockchip: rk3576: Rename PPLL register macro

Quoted 6 lines · Jonas Karlman

clk: rockchip: rk3576: Rename PPLL register macro

The PPLL registers belong to the PHP CRU, rather than the PMU CRU. Rename the register macro and update the PPLL entry and users to reflect this.

Quoted 6 lines
Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")
 arch/arm/include/asm/arch-rockchip/cru_rk3576.h | 2 +-
 drivers/clk/rockchip/clk_rk3576.c               | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
Reviewed-by on v2 27/37
#65 lore raw

Re: [PATCH v2 27/37] clk: rockchip: rk3576: Rename PPLL register macro

In reply to Jonas Karlman

Hi Jonas,

Quoted 6 lines · Jonas Karlman

The PPLL registers belong to the PHP CRU, rather than the PMU CRU. Rename the register macro and update the PPLL entry and users to reflect this.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")
Quoted 31 lines

---
Changes in v2:
- Split from "rk3576: Fix trivial clock configuration errors"
- Add fixes tag

---
  arch/arm/include/asm/arch-rockchip/cru_rk3576.h | 2 +-
  drivers/clk/rockchip/clk_rk3576.c               | 4 ++--
  2 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/include/asm/arch-rockchip/cru_rk3576.h +1 -1
index fb77fbd7307a..380151e0f8d5 100644
@@ -127,11 +127,11 @@ struct pll_rate_table {
  #define RK3576_SDMMC_CON0		0xC30
  #define RK3576_SDMMC_CON1		0xC34
 
+#define RK3576_PHP_PLL_CON(x)		((x) * 0x4 + RK3576_PHP_CRU_BASE)
  #define RK3576_PHP_CLKSEL_CON(x)	((x) * 0x4 + RK3576_PHP_CRU_BASE + 0x300)
  #define RK3576_PHP_CLKGATE_CON(x)	((x) * 0x4 + RK3576_PHP_CRU_BASE + 0x800)
  #define RK3576_PHP_SOFTRST_CON(x)	((x) * 0x4 + RK3576_PHP_CRU_BASE + 0xa00)
 
-#define RK3576_PMU_PLL_CON(x)		((x) * 0x4 + RK3576_PHP_CRU_BASE)
  #define RK3576_PMU_CLKSEL_CON(x)	((x) * 0x4 + RK3576_PMU_CRU_BASE + 0x300)
  #define RK3576_PMU_CLKGATE_CON(x)	((x) * 0x4 + RK3576_PMU_CRU_BASE + 0x800)
  #define RK3576_PMU_SOFTRST_CON(x)	((x) * 0x4 + RK3576_PMU_CRU_BASE + 0xa00)
drivers/clk/rockchip/clk_rk3576.c +0 -0
index a7110b86c063..ce97997c73ea 100644

drivers/clk/rockchip/clk_rk3576.c static struct rockchip_pll_clock rk3576_pll_clks[] = { · line 60

Quoted 6 lines
drivers/clk/rockchip/clk_rk3576.c +1 -1
@@ -56,7 +56,7 @@ static struct rockchip_pll_clock rk3576_pll_clks[] = {
  		     RK3576_MODE_CON0, 8, 15, 0, rk3576_24m_pll_rates),
  	[GPLL] = PLL(pll_rk3588, PLL_GPLL, RK3576_PLL_CON(112),
  		     RK3576_MODE_CON0, 2, 15, 0, rk3576_24m_pll_rates),
-	[PPLL] = PLL(pll_rk3588, PLL_PPLL, RK3576_PMU_PLL_CON(128),
+	[PPLL] = PLL(pll_rk3588, PLL_PPLL, RK3576_PHP_PLL_CON(128),
  		     RK3576_MODE_CON0, 10, 15, ROCKCHIP_PLL_FIXED_MODE,

I anticipate an issue when merging here as this series was based off https://git.u-boot-project.org/u-boot/contributors/kwiboo/u-boot/-/commit/989305aa79a2791da67497fe67ce2cefec61d6ac and not main/next. Will fix when applying.

Thanks!
Quentin

#66 lore raw

PATCH v2 28/37 clk: rockchip: rk3576: Remove unused BPLL register macro

In reply to Jonas Karlman

The BPLL con registers are located in the main CRU and not in the BIGCORE CRU.

Remove the unused and incorrect RK3576_BPLL_CON macro.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

---
Changes in v2:
- Split from "rk3576: Fix trivial clock configuration errors"
- Add fixes tag

---
 arch/arm/include/asm/arch-rockchip/cru_rk3576.h | 1 -
 1 file changed, 1 deletion(-)
arch/arm/include/asm/arch-rockchip/cru_rk3576.h +0 -1
index 380151e0f8d5..12257797445e 100644
@@ -140,7 +140,6 @@ struct pll_rate_table {
 #define RK3576_CCI_CLKGATE_CON(x)	((x) * 0x4 + RK3576_CCI_CRU_BASE + 0x800)
 #define RK3576_CCI_SOFTRST_CON(x)	((x) * 0x4 + RK3576_CCI_CRU_BASE + 0xa00)
 
-#define RK3576_BPLL_CON(x)		((x) * 0x4 + RK3576_BIGCORE_CRU_BASE)
 #define RK3576_BIGCORE_CLKSEL_CON(x)	((x) * 0x4 + RK3576_BIGCORE_CRU_BASE + 0x300)
 #define RK3576_BIGCORE_CLKGATE_CON(x)	((x) * 0x4 + RK3576_BIGCORE_CRU_BASE + 0x800)
 #define RK3576_BIGCORE_SOFTRST_CON(x)	((x) * 0x4 + RK3576_BIGCORE_CRU_BASE + 0xa00)
Signature · 1 line
2.55.0
Reviewed-by on v2 28/37
#67 lore raw

Re: [PATCH v2 28/37] clk: rockchip: rk3576: Remove unused BPLL register macro

Quoted 5 lines · Jonas Karlman

clk: rockchip: rk3576: Remove unused BPLL register macro

The BPLL con registers are located in the main CRU and not in the BIGCORE CRU.

Quoted 7 lines

Remove the unused and incorrect RK3576_BPLL_CON macro.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")
 arch/arm/include/asm/arch-rockchip/cru_rk3576.h | 1 -
 1 file changed, 1 deletion(-)
Reviewed-by on v2 28/37
#68 lore raw

Re: [PATCH v2 28/37] clk: rockchip: rk3576: Remove unused BPLL register macro

In reply to Jonas Karlman

Hi Jonas,

Quoted 7 lines · Jonas Karlman

The BPLL con registers are located in the main CRU and not in the BIGCORE CRU.

Remove the unused and incorrect RK3576_BPLL_CON macro.

Fixes 3919310b37ec ("clk: rockchip: Add rk3576 clk support")

Thanks!
Quentin

#69 lore raw

PATCH v2 29/37 clk: rockchip: rk3576: Group LPLL register macro with CCI macros

In reply to Jonas Karlman

Move the RK3576_LPLL_CON macro alongside the other CCI CRU register macros for consistency.

---
v2: Split from "rk3576: Fix trivial clock configuration errors"

---
 arch/arm/include/asm/arch-rockchip/cru_rk3576.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/arch-rockchip/cru_rk3576.h +1 -1
index 12257797445e..41e225245843 100644
@@ -136,6 +136,7 @@ struct pll_rate_table {
 #define RK3576_PMU_CLKGATE_CON(x)	((x) * 0x4 + RK3576_PMU_CRU_BASE + 0x800)
 #define RK3576_PMU_SOFTRST_CON(x)	((x) * 0x4 + RK3576_PMU_CRU_BASE + 0xa00)
 
+#define RK3576_LPLL_CON(x)		((x) * 0x4 + RK3576_CCI_CRU_BASE)
 #define RK3576_CCI_CLKSEL_CON(x)	((x) * 0x4 + RK3576_CCI_CRU_BASE + 0x300)
 #define RK3576_CCI_CLKGATE_CON(x)	((x) * 0x4 + RK3576_CCI_CRU_BASE + 0x800)
 #define RK3576_CCI_SOFTRST_CON(x)	((x) * 0x4 + RK3576_CCI_CRU_BASE + 0xa00)
@@ -143,7 +144,6 @@ struct pll_rate_table {
 #define RK3576_BIGCORE_CLKSEL_CON(x)	((x) * 0x4 + RK3576_BIGCORE_CRU_BASE + 0x300)
 #define RK3576_BIGCORE_CLKGATE_CON(x)	((x) * 0x4 + RK3576_BIGCORE_CRU_BASE + 0x800)
 #define RK3576_BIGCORE_SOFTRST_CON(x)	((x) * 0x4 + RK3576_BIGCORE_CRU_BASE + 0xa00)
-#define RK3576_LPLL_CON(x)		((x) * 0x4 + RK3576_CCI_CRU_BASE)
 #define RK3576_LITCORE_CLKSEL_CON(x)	((x) * 0x4 + RK3576_LITCORE_CRU_BASE + 0x300)
 #define RK3576_LITCORE_CLKGATE_CON(x)	((x) * 0x4 + RK3576_LITCORE_CRU_BASE + 0x800)
 #define RK3576_LITCORE_SOFTRST_CON(x)	((x) * 0x4 + RK3576_LITCORE_CRU_BASE + 0xa00)
Signature · 1 line
2.55.0
Reviewed-by on v2 29/37
#70 lore raw

Re: [PATCH v2 29/37] clk: rockchip: rk3576: Group LPLL register macro with CCI macros

Quoted 9 lines · Jonas Karlman

clk: rockchip: rk3576: Group LPLL register macro with CCI macros

Move the RK3576_LPLL_CON macro alongside the other CCI CRU register macros for consistency.

 arch/arm/include/asm/arch-rockchip/cru_rk3576.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#72 lore raw

PATCH v2 30/37 clk: rockchip: rk3576: Align BPLL entry in PLL table

In reply to Jonas Karlman

Keep the BPLL entry formatted in a similar way matching the other PLL entries for consistency.

---
v2: Split from "rk3576: Fix trivial clock configuration errors"

---
 drivers/clk/rockchip/clk_rk3576.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/clk/rockchip/clk_rk3576.c +1 -2
index ce97997c73ea..75b705ffba2f 100644
@@ -44,8 +44,7 @@ static struct rockchip_pll_rate_table rk3576_24m_pll_rates[] = {
 
 static struct rockchip_pll_clock rk3576_pll_clks[] = {
 	[BPLL] = PLL(pll_rk3588, PLL_BPLL, RK3576_PLL_CON(0),
-		      RK3576_BPLL_MODE_CON0, 0, 15, 0,
-		      rk3576_24m_pll_rates),
+		     RK3576_BPLL_MODE_CON0, 0, 15, 0, rk3576_24m_pll_rates),
 	[LPLL] = PLL(pll_rk3588, PLL_LPLL, RK3576_LPLL_CON(16),
 		     RK3576_LPLL_MODE_CON0, 0, 15, 0, rk3576_24m_pll_rates),
 	[VPLL] = PLL(pll_rk3588, PLL_VPLL, RK3576_PLL_CON(88),
Signature · 1 line
2.55.0
Reviewed-by on v2 30/37
#73 lore raw

Re: [PATCH v2 30/37] clk: rockchip: rk3576: Align BPLL entry in PLL table

Quoted 9 lines · Jonas Karlman

clk: rockchip: rk3576: Align BPLL entry in PLL table

Keep the BPLL entry formatted in a similar way matching the other PLL entries for consistency.

 drivers/clk/rockchip/clk_rk3576.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
#75 lore raw

PATCH v2 31/37 clk: rockchip: rk3528: Return correct rate for CLK_PWMx

In reply to Jonas Karlman

The PWM clock getter overwrites the 100 MHz rate with the oscillator rate because the 50 MHz parent test starts a separate if-else statement.

Change to use else-if so the getter returns 100 MHz when the 100 MHz parent is selected.

Fixes 5a7a856b132f ("clk: rockchip: Add support for RK3528")

---
Changes in v2:
- Split from "rk3528: Fix trivial clock configuration errors"
- Add fixes tag
- Collect r-b tag

---
 drivers/clk/rockchip/clk_rk3528.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk_rk3528.c +1 -1
index cf8c3a623495..812710872729 100644
@@ -770,7 +770,7 @@ static ulong rk3528_pwm_get_clk(struct rk3528_clk_priv *priv, ulong clk_id)
 	sel = (con & mask) >> shift;
 	if (sel == CLK_PWM0_SEL_CLK_MATRIX_100M_SRC)
 		rate = 100 * MHz;
-	if (sel == CLK_PWM0_SEL_CLK_MATRIX_50M_SRC)
+	else if (sel == CLK_PWM0_SEL_CLK_MATRIX_50M_SRC)
 		rate = 50 * MHz;
 	else
 		rate = OSC_HZ;
Signature · 1 line
2.55.0
Reviewed-by on v2 31/37
#76 lore raw

Re: [PATCH v2 31/37] clk: rockchip: rk3528: Return correct rate for CLK_PWMx

Quoted 8 lines · Jonas Karlman

clk: rockchip: rk3528: Return correct rate for CLK_PWMx

The PWM clock getter overwrites the 100 MHz rate with the oscillator rate because the 50 MHz parent test starts a separate if-else statement.

Change to use else-if so the getter returns 100 MHz when the 100 MHz parent is selected.

Quoted 6 lines
Fixes 5a7a856b132f ("clk: rockchip: Add support for RK3528")
 drivers/clk/rockchip/clk_rk3528.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#77 lore raw

PATCH v2 32/37 clk: rockchip: rk3528: Fix VOP clock configuration

In reply to Jonas Karlman

Setting rate of the VOP clocks never changes the clock parent and the old divisor value is OR with new divisor value due to incorrect args being passed to rk_clrsetreg() call.

Use selector and divisor masks and values correctly in rk_clrsetreg() call to ensure VOP clocks are configured as expected.

Video is not supported for this SoC, so nothing is likely going to try to change rate of VOP clocks until video support have been implemented.

Fixes 5a7a856b132f ("clk: rockchip: Add support for RK3528")

---
Changes in v2:
- Split from "rk3528: Fix trivial clock configuration errors"
- Add fixes tag
- Collect r-b tag

---
 drivers/clk/rockchip/clk_rk3528.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk_rk3528.c +1 -1
index 812710872729..82a1b6e85b5b 100644
@@ -1097,7 +1097,7 @@ static ulong rk3528_dclk_vop_set_clk(struct rk3528_clk_priv *priv,
 	}
 
 	div = ((DIV_ROUND_UP(prate, rate) - 1) << div_shift) & div_mask;
-	rk_clrsetreg(&cru->clksel_con[id], sel, div);
+	rk_clrsetreg(&cru->clksel_con[id], sel_mask | div_mask, sel | div);
 
 	return rk3528_dclk_vop_get_clk(priv, clk_id);
 }
Signature · 1 line
2.55.0
Reviewed-by on v2 32/37
#78 lore raw

Re: [PATCH v2 32/37] clk: rockchip: rk3528: Fix VOP clock configuration

Quoted 12 lines · Jonas Karlman

clk: rockchip: rk3528: Fix VOP clock configuration

Setting rate of the VOP clocks never changes the clock parent and the old divisor value is OR with new divisor value due to incorrect args being passed to rk_clrsetreg() call.

Use selector and divisor masks and values correctly in rk_clrsetreg() call to ensure VOP clocks are configured as expected.

Video is not supported for this SoC, so nothing is likely going to try to change rate of VOP clocks until video support have been implemented.

Quoted 6 lines
Fixes 5a7a856b132f ("clk: rockchip: Add support for RK3528")
 drivers/clk/rockchip/clk_rk3528.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#79 lore raw

PATCH v2 33/37 clk: rockchip: rk3528: Align PPLL entry in PLL table

In reply to Jonas Karlman

Keep the PPLL entry formatted in a similar way matching the other PLL entries for consistency.

---
Changes in v2:
- Split from "rk3528: Fix trivial clock configuration errors"
- Collect r-b tag

---
 drivers/clk/rockchip/clk_rk3528.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/rockchip/clk_rk3528.c +2 -1
index 82a1b6e85b5b..83e302dbc3c4 100644
@@ -72,7 +72,8 @@ static struct rockchip_pll_clock rk3528_pll_clks[] = {
 		     RK3528_MODE_CON, 4, 10, 0, rk3528_pll_rates),
 
 	[PPLL] = PLL(pll_rk3328, PLL_PPLL, RK3528_PCIE_PLL_CON(32),
-		     RK3528_MODE_CON, 6, 10, ROCKCHIP_PLL_FIXED_MODE, rk3528_pll_rates),
+		     RK3528_MODE_CON, 6, 10, ROCKCHIP_PLL_FIXED_MODE,
+		     rk3528_pll_rates),
 
 	[DPLL] = PLL(pll_rk3328, PLL_DPLL, RK3528_DDRPHY_PLL_CON(16),
 		     RK3528_DDRPHY_MODE_CON, 0, 10, 0, rk3528_pll_rates),
Signature · 1 line
2.55.0
Reviewed-by on v2 33/37
#80 lore raw

Re: [PATCH v2 33/37] clk: rockchip: rk3528: Align PPLL entry in PLL table

Quoted 10 lines · Jonas Karlman

clk: rockchip: rk3528: Align PPLL entry in PLL table

Keep the PPLL entry formatted in a similar way matching the other PLL entries for consistency.

 drivers/clk/rockchip/clk_rk3528.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
#81 lore raw

PATCH v2 34/37 clk: rockchip: rk3506: Return correct rate for CLK_I2C0 and CLK_I2C1

In reply to Jonas Karlman

The getter for CLK_I2C0 and CLK_I2C1 both fall through and instead return the rate for CLK_I2C2.

Add the missing breaks so correct rate is returned for affected clocks.

Fixes fbf72dce915a ("clk: rockchip: Add support for RK3506")

---
Changes in v2:
- Update commit subject and message
- Add fixes tag
- Collect r-b tag

---
 drivers/clk/rockchip/clk_rk3506.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/clk/rockchip/clk_rk3506.c +2 -0
index 38066c5c3e3c..457082eea87b 100644
@@ -537,10 +537,12 @@ static ulong rk3506_i2c_get_rate(struct rk3506_clk_priv *priv, ulong clk_id)
 		con = readl(RK3506_CLKSEL_CON(32));
 		sel = FIELD_GET(CLK_I2C0_SEL_MASK, con);
 		div = FIELD_GET(CLK_I2C0_DIV_MASK, con);
+		break;
 	case CLK_I2C1:
 		con = readl(RK3506_CLKSEL_CON(32));
 		sel = FIELD_GET(CLK_I2C1_SEL_MASK, con);
 		div = FIELD_GET(CLK_I2C1_DIV_MASK, con);
+		break;
 	case CLK_I2C2:
 		con = readl(RK3506_CLKSEL_CON(33));
 		sel = FIELD_GET(CLK_I2C2_SEL_MASK, con);
Signature · 1 line
2.55.0
Reviewed-by on v2 34/37
#82 lore raw

Re: [PATCH v2 34/37] clk: rockchip: rk3506: Return correct rate for CLK_I2C0 and CLK_I2C1

Quoted 5 lines · Jonas Karlman

clk: rockchip: rk3506: Return correct rate for CLK_I2C0 and CLK_I2C1

The getter for CLK_I2C0 and CLK_I2C1 both fall through and instead return the rate for CLK_I2C2.

Quoted 8 lines

Add the missing breaks so correct rate is returned for affected clocks.

Fixes fbf72dce915a ("clk: rockchip: Add support for RK3506")
 drivers/clk/rockchip/clk_rk3506.c | 2 ++
 1 file changed, 2 insertions(+)
#83 lore raw

PATCH v2 35/37 clk: rockchip: rk3568: Drop unused GRF syscon lookup

In reply to Jonas Karlman

The RK3568 clock driver lookup and stores a reference to the GRF regs. However, the grf field is never dereferenced, let's drop it.

---
v2: Collect r-b tag

---
 arch/arm/include/asm/arch-rockchip/cru_rk3568.h | 1 -
 drivers/clk/rockchip/clk_rk3568.c               | 4 ----
 2 files changed, 5 deletions(-)
arch/arm/include/asm/arch-rockchip/cru_rk3568.h +0 -1
index 9c7ddd751f72..d72f241d0150 100644
@@ -44,7 +44,6 @@ struct rk3568_pmuclk_priv {
 
 struct rk3568_clk_priv {
 	struct rk3568_cru *cru;
-	struct rk3568_grf *grf;
 	ulong ppll_hz;
 	ulong hpll_hz;
 	ulong gpll_hz;
drivers/clk/rockchip/clk_rk3568.c +0 -4
index 940b824103cc..9f3e9322161e 100644
@@ -2907,10 +2907,6 @@ static int rk3568_clk_probe(struct udevice *dev)
 	struct rk3568_clk_priv *priv = dev_get_priv(dev);
 	int ret;
 
-	priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
-	if (IS_ERR(priv->grf))
-		return PTR_ERR(priv->grf);
-
 	rk3568_clk_init(priv);
 
 	/* Process 'assigned-{clocks/clock-parents/clock-rates}' properties */
Signature · 1 line
2.55.0
Reviewed-by on v2 35/37
#84 lore raw

Re: [PATCH v2 35/37] clk: rockchip: rk3568: Drop unused GRF syscon lookup

Quoted 11 lines · Jonas Karlman

clk: rockchip: rk3568: Drop unused GRF syscon lookup

The RK3568 clock driver lookup and stores a reference to the GRF regs. However, the grf field is never dereferenced, let's drop it.

 arch/arm/include/asm/arch-rockchip/cru_rk3568.h | 1 -
 drivers/clk/rockchip/clk_rk3568.c               | 4 ----
 2 files changed, 5 deletions(-)
#85 lore raw

PATCH v2 36/37 clk: rockchip: rk3588: Drop unused GRF syscon lookup

In reply to Jonas Karlman

The RK3588 clock driver lookup and stores a reference to the GRF regs. However, the grf field is never dereferenced and struct rk3588_grf is not defined in any header, let's drop it.

---
v2: Collect r-b tag

---
 arch/arm/include/asm/arch-rockchip/cru_rk3588.h | 1 -
 drivers/clk/rockchip/clk_rk3588.c               | 4 ----
 2 files changed, 5 deletions(-)
arch/arm/include/asm/arch-rockchip/cru_rk3588.h +0 -1
index 39295adeb38a..85cc17840436 100644
@@ -41,7 +41,6 @@ struct rk3588_clk_info {
 
 struct rk3588_clk_priv {
 	struct rk3588_cru *cru;
-	struct rk3588_grf *grf;
 	ulong ppll_hz;
 	ulong gpll_hz;
 	ulong cpll_hz;
drivers/clk/rockchip/clk_rk3588.c +0 -4
index 662ff44397ac..9e26ca669fc5 100644
@@ -1977,10 +1977,6 @@ static int rk3588_clk_probe(struct udevice *dev)
 	}
 #endif
 
-	priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
-	if (IS_ERR(priv->grf))
-		return PTR_ERR(priv->grf);
-
 	rk3588_clk_init(priv);
 
 	/* Process 'assigned-{clocks/clock-parents/clock-rates}' properties */
Signature · 1 line
2.55.0
Reviewed-by on v2 36/37
#86 lore raw

Re: [PATCH v2 36/37] clk: rockchip: rk3588: Drop unused GRF syscon lookup

Quoted 6 lines · Jonas Karlman

clk: rockchip: rk3588: Drop unused GRF syscon lookup

The RK3588 clock driver lookup and stores a reference to the GRF regs. However, the grf field is never dereferenced and struct rk3588_grf is not defined in any header, let's drop it.

Quoted 6 lines
 arch/arm/include/asm/arch-rockchip/cru_rk3588.h | 1 -
 drivers/clk/rockchip/clk_rk3588.c               | 4 ----
 2 files changed, 5 deletions(-)
#87 lore raw

PATCH v2 37/37 adc: rockchip-saradc: Use 3 MHz clock rate for RK3528

In reply to Jonas Karlman

The RK3528 CLK_SARADC divider field stores the divisor minus one. Its three bits encode divisors 1-8, allowing rates of 24, 12, 8, 6, 4.8, 4, ~3.43 or 3 MHz from the 24 MHz oscillator.

When the driver requests 1 MHz rate, the required divisor of 24 is encoded as 23. This value is truncated to 7 in the three-bit field, selecting a divisor of 8 and producing a 3 MHz clock.

Request 3 MHz explicitly to match the rate already used after value truncation.

Fixes 6ef723af18b9 ("adc: rockchip-saradc: Add support for RK3528")

---
v2: New patch

---
 drivers/adc/rockchip-saradc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/adc/rockchip-saradc.c +1 -1
index 1515951403c9..15fd6b66d304 100644
@@ -342,7 +342,7 @@ static const struct rockchip_saradc_data rk3399_saradc_data = {
 static const struct rockchip_saradc_data rk3528_saradc_data = {
 	.num_bits = 10,
 	.num_channels = 4,
-	.clk_rate = 1000000,
+	.clk_rate = 3000000,
 	.channel_data = rockchip_saradc_channel_data_v2,
 	.start_channel = rockchip_saradc_start_channel_v2,
 };
Signature · 1 line
2.55.0
Reviewed-by on v2 37/37
#88 lore raw

Re: [PATCH v2 37/37] adc: rockchip-saradc: Use 3 MHz clock rate for RK3528

Hi Jonas,

Quoted 9 lines · Jonas Karlman

adc: rockchip-saradc: Use 3 MHz clock rate for RK3528

The RK3528 CLK_SARADC divider field stores the divisor minus one. Its three bits encode divisors 1-8, allowing rates of 24, 12, 8, 6, 4.8, 4, ~3.43 or 3 MHz from the 24 MHz oscillator.

When the driver requests 1 MHz rate, the required divisor of 24 is encoded as 23. This value is truncated to 7 in the three-bit field, selecting a divisor of 8 and producing a 3 MHz clock.

Just to check, is this really just truncation? rk3528_adc_set_clk() calls rk_clrsetreg(&cru->clksel_con[74], mask, (div - 1) << shift) and rk_clrsetreg() does not apply the mask to 'set', so the write is ((0x7 | 0x17) << 16) | 0x17, which also write-enables and sets bit 4. Bit 4 is in the CLK_TSADC divider field (bits 7:3), so each SARADC probe has also been changing the TSADC divider. That is a better reason for this patch than matching the rate, so please can you mention it in the commit message.

I suppose you could rk3528_adc_set_clk() clamp the divider to the field width, so that an out-of-range request can't corrupt the neighbouring field. Bad for code size though.

Quoted 9 lines

Request 3 MHz explicitly to match the rate already used after value truncation.

Fixes 6ef723af18b9 ("adc: rockchip-saradc: Add support for RK3528")
 drivers/adc/rockchip-saradc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#89 lore raw

Re: [PATCH v2 37/37] adc: rockchip-saradc: Use 3 MHz clock rate for RK3528

Hi Simon,

Quoted 13 lines · Simon Glass

Hi Jonas,

Quoted 9 lines · Jonas Karlman

adc: rockchip-saradc: Use 3 MHz clock rate for RK3528

The RK3528 CLK_SARADC divider field stores the divisor minus one. Its three bits encode divisors 1-8, allowing rates of 24, 12, 8, 6, 4.8, 4, ~3.43 or 3 MHz from the 24 MHz oscillator.

When the driver requests 1 MHz rate, the required divisor of 24 is encoded as 23. This value is truncated to 7 in the three-bit field, selecting a divisor of 8 and producing a 3 MHz clock.

Quoted 8 lines

Just to check, is this really just truncation? rk3528_adc_set_clk() calls rk_clrsetreg(&cru->clksel_con[74], mask, (div - 1) << shift) and rk_clrsetreg() does not apply the mask to 'set', so the write is ((0x7 | 0x17) << 16) | 0x17, which also write-enables and sets bit 4. Bit 4 is in the CLK_TSADC divider field (bits 7:3), so each SARADC probe has also been changing the TSADC divider. That is a better reason for this patch than matching the rate, so please can you mention it in the commit message.

The motivation from the saradc driver perspective is that it should request a rate that is supported by the clock, not to work around shortcomings in the clock driver.

I do not think there is a reason to mention the internal clock driver issues, those will be handled in a separate refactoring series that changes clock driver to use FIELD_GET/FIELD_PREP macros and make set_rate fail for rates that does not FIELD_FIT.

Quoted 4 lines

I suppose you could rk3528_adc_set_clk() clamp the divider to the field width, so that an out-of-range request can't corrupt the neighbouring field. Bad for code size though.

I have already converted all RK35xx clock drivers to use FIELD-macros in my local tree. Such refactoring will be sent as follow-up series as mentioned in cover letter. This series tries to fix issues that were discovered when the clock drivers were initially converted/refactored.

Regards,
Jonas

Quoted 12 lines
Quoted 10 lines

Request 3 MHz explicitly to match the rate already used after value truncation.

Fixes 6ef723af18b9 ("adc: rockchip-saradc: Add support for RK3528")
 drivers/adc/rockchip-saradc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Acked-by on v2 37/37
#90 lore raw

Re: [PATCH v2 37/37] adc: rockchip-saradc: Use 3 MHz clock rate for RK3528

In reply to Jonas Karlman

Hi Jonas,

Quoted 8 lines · Jonas Karlman

The RK3528 CLK_SARADC divider field stores the divisor minus one. Its three bits encode divisors 1-8, allowing rates of 24, 12, 8, 6, 4.8, 4, ~3.43 or 3 MHz from the 24 MHz oscillator.

When the driver requests 1 MHz rate, the required divisor of 24 is encoded as 23. This value is truncated to 7 in the three-bit field, selecting a divisor of 8 and producing a 3 MHz clock.

Quoted 5 lines

Request 3 MHz explicitly to match the rate already used after value truncation.

Fixes 6ef723af18b9 ("adc: rockchip-saradc: Add support for RK3528")

I don't have access to RK3528 TRM so:

Thanks!
Quentin

#91 lore raw
In reply to Jonas Karlman

Hi Jonas,

Quoted 2 lines · Jonas Karlman

Some of these fixes have only been compile tested as it involves clocks or rates that are rarely used in U-Boot.

Please can you say which patches were tested on hardware, and on which boards? Patches 1 to 6 and 14 change PLL and bus-clock setup that every RK3568/RK3576/RK3588 board runs at boot, so they carry more risk than the one-line copy-paste fixes. Knowing which ones still need a run on real hardware would help the people testing on the various SoCs.

Quoted 2 lines

This series fixes a few trivial copy-paste mistakes and other misc clock issues for RK35xx SoCs.

Within each SoC the fixes are mixed with cosmetic changes (the macro renames and removals, the PLL-table alignment, SPLL_HZ and the GRF lookup drops). Several of the cosmetic ones carry a Fixes: tag even though they don't change behaviour, e.g. the PPLL macro renames, the unused-macro removals and the PWM0 shift change, whose commit message says as much. It would be worth moving the real fixes to the front of the series and keeping Fixes: only on patches that change behaviour. Then the fixes can be picked up (and backported) on their own, while the tidy-ups wait for the next merge window. What do you think?

Regards,
Simon

#92 lore raw

Hi Simon,

Quoted 7 lines · Simon Glass

Hi Jonas,

Quoted 2 lines · Jonas Karlman

Some of these fixes have only been compile tested as it involves clocks or rates that are rarely used in U-Boot.

Quoted 6 lines

Please can you say which patches were tested on hardware, and on which boards? Patches 1 to 6 and 14 change PLL and bus-clock setup that every RK3568/RK3576/RK3588 board runs at boot, so they carry more risk than the one-line copy-paste fixes. Knowing which ones still need a run on real hardware would help the people testing on the various SoCs.

All patches have been runtime tested on multiple boards of the affected SoCs, however a few of the fixes affect clocks or rates that no board or SoC is likely to use, e.g. VOP clocks or clock rates that board DTs or drivers is very unlikely to request. So technically some of the fixes have not been fully tested during runtime.

Quoted 10 lines
Quoted 3 lines

This series fixes a few trivial copy-paste mistakes and other misc clock issues for RK35xx SoCs.

Within each SoC the fixes are mixed with cosmetic changes (the macro renames and removals, the PLL-table alignment, SPLL_HZ and the GRF lookup drops). Several of the cosmetic ones carry a Fixes: tag even though they don't change behaviour, e.g. the PPLL macro renames, the unused-macro removals and the PWM0 shift change, whose commit message says as much.

Some/most of the Fixes tags where added at request of Quentin.

Most of the issues where discovered during a conversion of these drivers to use FIELD_GET/FIELD_PREP, and most looked like simple copy-paste errors.

Quoted 4 lines

It would be worth moving the real fixes to the front of the series and keeping Fixes: only on patches that change behaviour. Then the fixes can be picked up (and backported) on their own, while the tidy-ups wait for the next merge window. What do you think?

Fixes patches are already placed first within each soc-grouping, would likely split this series per such grouping if there is a need for a v3.

Regards,
Jonas

Quoted 3 lines

Regards,
Simon

#93 lore raw
In reply to Jonas Karlman
Quoted 59 lines · Jonas Karlman

This series fixes a few trivial copy-paste mistakes and other misc clock issues for RK35xx SoCs.

Some of these fixes have only been compile tested as it involves clocks or rates that are rarely used in U-Boot.

The 'special pll handling' should ideally be moved into clk_rk3588 driver, something that can be done in a future follow-up series.

Similarly, any refactoring has been held back for a future follow-up series.

Changes in v2:
- Add patch to fix automatic PLL fractional calculation
- Add patch to request a working rate for saradc on RK3528
- Split "Fix trivial clock configuration errors"
- Update commit messages
- Add fixes tag
- Collect r-b tags

Jonas Karlman (37):
clk: rockchip: pll: Fix fractional PLL rate calculation
clk: rockchip: pll: Fix automatic PLL fractional parameter calculation
clk: rockchip: pll: Always write the dsmpd flag
clk: rockchip: pll: Always write the k parameter
clk: rockchip: pll: Use PLL_FIXED_MODE flag on RK3588/RK3576 PPLL
clk: rockchip: pll: Limit special rk3588_pll handling to RK3588
clk: rockchip: rk3568: Use correct clock id for GPLL
clk: rockchip: rk3568: Fix PWM0 parent selection mask
clk: rockchip: rk3568: Use PWM0 divider shift
clk: rockchip: rk3568: Use correct PLL rate for CLK_MAC0_2TOP
clk: rockchip: rk3588: Use GPLL rate for CLK_TSADC
clk: rockchip: rk3588: Use correct PLL rate for SCLK_UARTx divider
clk: rockchip: rk3588: Fix ACLK_BUS_ROOT divider encoding
clk: rockchip: rk3588: Set ACLK_BUS_ROOT to 375 MHz
clk: rockchip: rk3588: Remove redundant PLL register macros
clk: rockchip: rk3588: Rename PPLL register macro
clk: rockchip: rk3588: Align BxPLL entries in PLL table
clk: rockchip: rk3588: Use SPLL_HZ constant
clk: rockchip: rk3576: Use correct mode register for VPLL
clk: rockchip: rk3576: Fix ACLK_TOP_MID parent selection
clk: rockchip: rk3576: Fix I2C rate selection
clk: rockchip: rk3576: Fix CLK_I2C8 rate change
clk: rockchip: rk3576: Use correct clock register for CLK_SARADC
clk: rockchip: rk3576: Use correct TSADC clock register
clk: rockchip: rk3576: Use correct PLL rate for UART fractional clocks
clk: rockchip: rk3576: Use correct PLL rate for UART divisor
clk: rockchip: rk3576: Rename PPLL register macro
clk: rockchip: rk3576: Remove unused BPLL register macro
clk: rockchip: rk3576: Group LPLL register macro with CCI macros
clk: rockchip: rk3576: Align BPLL entry in PLL table
clk: rockchip: rk3528: Return correct rate for CLK_PWMx
clk: rockchip: rk3528: Fix VOP clock configuration
clk: rockchip: rk3528: Align PPLL entry in PLL table
clk: rockchip: rk3506: Return correct rate for CLK_I2C0 and CLK_I2C1
clk: rockchip: rk3568: Drop unused GRF syscon lookup
clk: rockchip: rk3588: Drop unused GRF syscon lookup
adc: rockchip-saradc: Use 3 MHz clock rate for RK3528

Quoted 13 lines
  arch/arm/include/asm/arch-rockchip/clock.h    |  2 +-
  .../include/asm/arch-rockchip/cru_rk3568.h    |  1 -
  .../include/asm/arch-rockchip/cru_rk3576.h    |  5 +-
  .../include/asm/arch-rockchip/cru_rk3588.h    |  6 +-
  drivers/adc/rockchip-saradc.c                 |  2 +-
  drivers/clk/rockchip/clk_pll.c                | 75 ++++++++++---------
  drivers/clk/rockchip/clk_rk3506.c             |  2 +
  drivers/clk/rockchip/clk_rk3528.c             |  7 +-
  drivers/clk/rockchip/clk_rk3568.c             | 12 +--
  drivers/clk/rockchip/clk_rk3576.c             | 26 +++----
  drivers/clk/rockchip/clk_rk3588.c             | 35 ++++-----
  11 files changed, 82 insertions(+), 91 deletions(-)

Applied to https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip (u-boot-rockchip-2027.04), thanks!

[19/37] clk: rockchip: rk3576: Use correct mode register for VPLL

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/c823d81f321d5dda72913a8f55cf24cc16be599f
[20/37] clk: rockchip: rk3576: Fix ACLK_TOP_MID parent selection

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/08bfc9404d2119a411966cc5e2e2b7947b8f1da1
[21/37] clk: rockchip: rk3576: Fix I2C rate selection

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/667f289e5d6acd5c0ed21636841ded453dd4cf35
[22/37] clk: rockchip: rk3576: Fix CLK_I2C8 rate change

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/eb14d812d43f54736ae54c4f91bdbb495e2e77a6
[23/37] clk: rockchip: rk3576: Use correct clock register for CLK_SARADC

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/70b332b9f2506b0d9c3b3110fa02d2c1b8cfce90
[24/37] clk: rockchip: rk3576: Use correct TSADC clock register

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/76dafc2ec43e577d0cac76fd10b0554dcd6639f5
[25/37] clk: rockchip: rk3576: Use correct PLL rate for UART fractional clocks

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/5bddf9c424069880fd6ae944155a3fa1652930b8
[26/37] clk: rockchip: rk3576: Use correct PLL rate for UART divisor

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/cbf6a1861c39192dee3341c01dd303ea9abeef43
[27/37] clk: rockchip: rk3576: Rename PPLL register macro

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/edaf43c86c020f0773fffe567d3ee19aebaaedf5
[28/37] clk: rockchip: rk3576: Remove unused BPLL register macro

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/3275c34bf89ebaf3d674634ce22d77a72786b86d
[29/37] clk: rockchip: rk3576: Group LPLL register macro with CCI macros

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/85764f09df205cd52251f875f9db92e2eb1075e8
[30/37] clk: rockchip: rk3576: Align BPLL entry in PLL table

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/2da9803d9b697da4672e2fe5c834b43106149dcb
[34/37] clk: rockchip: rk3506: Return correct rate for CLK_I2C0 and CLK_I2C1

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/1a7307125f6bb7288735349b50305d05806ef7a3
[35/37] clk: rockchip: rk3568: Drop unused GRF syscon lookup

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/6dfb0b4ada2c3a13de5cc159e8058b23f606629c
[36/37] clk: rockchip: rk3588: Drop unused GRF syscon lookup

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/bac001a2402702f26d033ce435dc97185556cc41
[37/37] adc: rockchip-saradc: Use 3 MHz clock rate for RK3528

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/23066d3253419eeab5fe601d48d2c9df9b1526b1

Best regards,

Signature · 1 line
Quentin Schulz <[email protected]>