Patchwork [U-Boot,06/10] mx5 clocks: Fix get_ipg_per_clk()

login
register
mail settings
Submitter Benoît Thébaudeau
Date Aug. 14, 2012, 6:07 p.m.
Message ID <362780271.2408594.1344967651378.JavaMail.root@advansee.com>
Download mbox | patch
Permalink /patch/177407/
State Superseded
Delegated to: Stefano Babic
Headers show

Comments

Benoît Thébaudeau - Aug. 14, 2012, 6:07 p.m.
This fixes the "IPG PERCLK" frequency printed by the clocks command.

It also fixes i2c support.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
Cc: Stefano Babic <sbabic@denx.de>
---
 .../arch/arm/cpu/armv7/mx5/clock.c                 |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Patch

diff --git u-boot-4d3c95f.orig/arch/arm/cpu/armv7/mx5/clock.c u-boot-4d3c95f/arch/arm/cpu/armv7/mx5/clock.c
index b92ac49..b13c55a 100644
--- u-boot-4d3c95f.orig/arch/arm/cpu/armv7/mx5/clock.c
+++ u-boot-4d3c95f/arch/arm/cpu/armv7/mx5/clock.c
@@ -359,11 +359,15 @@  static u32 get_ipg_clk(void)
  */
 static u32 get_ipg_per_clk(void)
 {
-	u32 pred1, pred2, podf;
+	u32 freq, pred1, pred2, podf;
 
 	if (__raw_readl(&mxc_ccm->cbcmr) & MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL)
 		return get_ipg_clk();
-	/* Fixme: not handle what about lpm*/
+
+	if (__raw_readl(&mxc_ccm->cbcmr) & MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL)
+		freq = get_lp_apm();
+	else
+		freq = get_periph_clk();
 	podf = __raw_readl(&mxc_ccm->cbcdr);
 	pred1 = (podf & MXC_CCM_CBCDR_PERCLK_PRED1_MASK) >>
 		MXC_CCM_CBCDR_PERCLK_PRED1_OFFSET;
@@ -371,8 +375,7 @@  static u32 get_ipg_per_clk(void)
 		MXC_CCM_CBCDR_PERCLK_PRED2_OFFSET;
 	podf = (podf & MXC_CCM_CBCDR_PERCLK_PODF_MASK) >>
 		MXC_CCM_CBCDR_PERCLK_PODF_OFFSET;
-
-	return get_periph_clk() / ((pred1 + 1) * (pred2 + 1) * (podf + 1));
+	return freq / ((pred1 + 1) * (pred2 + 1) * (podf + 1));
 }
 
 /*