diff mbox

[U-Boot] MX6: Correct calculation of PLL_SYS

Message ID 1402346833-14679-1-git-send-email-andre@bluewatersys.com
State Awaiting Upstream
Delegated to: Stefano Babic
Headers show

Commit Message

Andre Renaud June 9, 2014, 8:47 p.m. UTC
DIV_SELECT is used as Fout = Fin * div_select / 2.0, so we should do
the shift after the multiply to avoid rounding errors

Signed-off-by: Andre Renaud <andre@bluewatersys.com>
---
 arch/arm/cpu/armv7/mx6/clock.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefano Babic July 9, 2014, 12:56 p.m. UTC | #1
On 09/06/2014 22:47, Andre Renaud wrote:
> DIV_SELECT is used as Fout = Fin * div_select / 2.0, so we should do
> the shift after the multiply to avoid rounding errors
> 
> Signed-off-by: Andre Renaud <andre@bluewatersys.com>
> ---
>  arch/arm/cpu/armv7/mx6/clock.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/cpu/armv7/mx6/clock.c b/arch/arm/cpu/armv7/mx6/clock.c
> index bd65a08..7dd83ec 100644
> --- a/arch/arm/cpu/armv7/mx6/clock.c

Applied to u-boot-imx, as a fix, thanks !

Best regards,
Stefano Babic
diff mbox

Patch

diff --git a/arch/arm/cpu/armv7/mx6/clock.c b/arch/arm/cpu/armv7/mx6/clock.c
index bd65a08..7dd83ec 100644
--- a/arch/arm/cpu/armv7/mx6/clock.c
+++ b/arch/arm/cpu/armv7/mx6/clock.c
@@ -80,7 +80,7 @@  static u32 decode_pll(enum pll_clocks pll, u32 infreq)
 		div = __raw_readl(&imx_ccm->analog_pll_sys);
 		div &= BM_ANADIG_PLL_SYS_DIV_SELECT;
 
-		return infreq * (div >> 1);
+		return (infreq * div) >> 1;
 	case PLL_BUS:
 		div = __raw_readl(&imx_ccm->analog_pll_528);
 		div &= BM_ANADIG_PLL_528_DIV_SELECT;