[PATCH] sunxi: clock: H6/H616: Fix PLL6 clock calculation

16 views
Skip to first unread message

Andre Przywara

unread,
Apr 28, 2021, 6:06:35 AM4/28/21
to Jagan Teki, Jernej Skrabec, Icenowy Zheng, u-b...@lists.denx.de, linux...@googlegroups.com
The "n" factor of the PLL_PERIPH0 clock is using the usual +1 encoding,
so we need to adjust the register value before doing the calculation.

This fixes the MMC clock setup on those SoCs, which could be slightly off
due to the wrong parent frequency:
mmc 2 set mod-clk req 52000000 parent 1176000000 n 2 m 12 rate 49000000

Signed-off-by: Andre Przywara <andre.p...@arm.com>
---
arch/arm/mach-sunxi/clock_sun50i_h6.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-sunxi/clock_sun50i_h6.c b/arch/arm/mach-sunxi/clock_sun50i_h6.c
index 492fc4a3fca..a947463e0a5 100644
--- a/arch/arm/mach-sunxi/clock_sun50i_h6.c
+++ b/arch/arm/mach-sunxi/clock_sun50i_h6.c
@@ -94,7 +94,7 @@ unsigned int clock_get_pll6(void)
int m = IS_ENABLED(CONFIG_MACH_SUN50I_H6) ? 4 : 2;

uint32_t rval = readl(&ccm->pll6_cfg);
- int n = ((rval & CCM_PLL6_CTRL_N_MASK) >> CCM_PLL6_CTRL_N_SHIFT);
+ int n = ((rval & CCM_PLL6_CTRL_N_MASK) >> CCM_PLL6_CTRL_N_SHIFT) + 1;
int div1 = ((rval & CCM_PLL6_CTRL_DIV1_MASK) >>
CCM_PLL6_CTRL_DIV1_SHIFT) + 1;
int div2 = ((rval & CCM_PLL6_CTRL_DIV2_MASK) >>
--
2.17.5

Jernej Škrabec

unread,
Apr 28, 2021, 11:21:39 AM4/28/21
to Jagan Teki, linux...@googlegroups.com, Icenowy Zheng, u-b...@lists.denx.de, linux...@googlegroups.com, andre.p...@arm.com
Hi!

Dne sreda, 28. april 2021 ob 12:05:55 CEST je Andre Przywara napisal(a):
> The "n" factor of the PLL_PERIPH0 clock is using the usual +1 encoding,
> so we need to adjust the register value before doing the calculation.
>
> This fixes the MMC clock setup on those SoCs, which could be slightly off
> due to the wrong parent frequency:
> mmc 2 set mod-clk req 52000000 parent 1176000000 n 2 m 12 rate 49000000
>
> Signed-off-by: Andre Przywara <andre.p...@arm.com>

Good catch!

Reviewed-by: Jernej Skrabec <jernej....@siol.net>

Best regards,
Jernej


Reply all
Reply to author
Forward
0 new messages