diff mbox

[U-Boot] lpc32xx: fix calculation of HCLK PLL output clock

Message ID 1443997125-4942-1-git-send-email-vz@mleia.com
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Vladimir Zapolskiy Oct. 4, 2015, 10:18 p.m. UTC
Execution branches on feedback mode are swapped, this has no effect
if default direct mode is on (then p_div is equal to 1 and Fout equals
to Fcco), that's why the problem remained unnoticed for a long time.

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
---
 arch/arm/cpu/arm926ejs/lpc32xx/clk.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Tom Rini Oct. 12, 2015, 3:16 p.m. UTC | #1
On Sun, Oct 04, 2015 at 11:18:45PM +0100, Vladimir Zapolskiy wrote:

> Execution branches on feedback mode are swapped, this has no effect
> if default direct mode is on (then p_div is equal to 1 and Fout equals
> to Fcco), that's why the problem remained unnoticed for a long time.
> 
> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/arch/arm/cpu/arm926ejs/lpc32xx/clk.c b/arch/arm/cpu/arm926ejs/lpc32xx/clk.c
index 1ef8a36..f5e2103 100644
--- a/arch/arm/cpu/arm926ejs/lpc32xx/clk.c
+++ b/arch/arm/cpu/arm926ejs/lpc32xx/clk.c
@@ -54,12 +54,12 @@  unsigned int get_hclk_pll_rate(void)
 	if (fref > 27000000ULL || fref < 1000000ULL)
 		return 0;
 
-	fout = fref * m_div;
-	if (val & CLK_HCLK_PLL_FEEDBACK) {
-		fcco = fout;
+	fcco = fref * m_div;
+	fout = fcco;
+	if (val & CLK_HCLK_PLL_FEEDBACK)
+		fcco *= p_div;
+	else
 		do_div(fout, p_div);
-	} else
-		fcco = fout * p_div;
 
 	if (fcco > 320000000ULL || fcco < 156000000ULL)
 		return 0;