diff options
author | Terry Lv <r65388@freescale.com> | 2011-03-29 21:11:38 +0800 |
---|---|---|
committer | Terry Lv <r65388@freescale.com> | 2011-04-11 12:48:40 +0800 |
commit | e8bbf29eaca7aa59eba25e122056f4fb7e0e3f09 (patch) | |
tree | a97eb894bbde1bc42ef42a98c42459ffb2ad383c | |
parent | 80426bc69f49f8aba415a73115bb33697e8b1cf6 (diff) | |
download | u-boot-imx-e8bbf29eaca7aa59eba25e122056f4fb7e0e3f09.zip u-boot-imx-e8bbf29eaca7aa59eba25e122056f4fb7e0e3f09.tar.gz u-boot-imx-e8bbf29eaca7aa59eba25e122056f4fb7e0e3f09.tar.bz2 |
ENGR00141335-2: get more accurate ipg_per clock frequency
Add perclk_lp_apm_sel check to function __get_ipg_per_clk.
This will get more accute clock frequency.
Signed-off-by: Terry Lv <r65388@freescale.com>
-rw-r--r-- | cpu/arm_cortexa8/mx53/generic.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/cpu/arm_cortexa8/mx53/generic.c b/cpu/arm_cortexa8/mx53/generic.c index 3065965..23a2640 100644 --- a/cpu/arm_cortexa8/mx53/generic.c +++ b/cpu/arm_cortexa8/mx53/generic.c @@ -146,23 +146,6 @@ static u32 __get_ipg_clk(void) return __get_periph_clk() / ((ahb_podf + 1) * (ipg_podf + 1)); } -static u32 __get_ipg_per_clk(void) -{ - u32 pred1, pred2, podf; - if (__REG(MXC_CCM_CBCMR) & MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL) - return __get_ipg_clk(); - /* Fixme: not handle what about lpm */ - podf = __REG(MXC_CCM_CBCDR); - pred1 = (podf & MXC_CCM_CBCDR_PERCLK_PRED1_MASK) >> - MXC_CCM_CBCDR_PERCLK_PRED1_OFFSET; - pred2 = (podf & MXC_CCM_CBCDR_PERCLK_PRED2_MASK) >> - 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)); -} - /*! * This function returns the low power audio clock. */ @@ -179,6 +162,30 @@ static u32 __get_lp_apm(void) return ret_val; } +static u32 __get_ipg_per_clk(void) +{ + u32 pred1, pred2, podf; + u32 clk_root; + if (__REG(MXC_CCM_CBCMR) & MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL) + return __get_ipg_clk(); + + /* Fixme: not handle what about lpm */ + if (__REG(MXC_CCM_CBCMR) & MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL) + clk_root = __get_lp_apm(); + else + clk_root = __get_periph_clk(); + + podf = __REG(MXC_CCM_CBCDR); + pred1 = (podf & MXC_CCM_CBCDR_PERCLK_PRED1_MASK) >> + MXC_CCM_CBCDR_PERCLK_PRED1_OFFSET; + pred2 = (podf & MXC_CCM_CBCDR_PERCLK_PRED2_MASK) >> + MXC_CCM_CBCDR_PERCLK_PRED2_OFFSET; + podf = (podf & MXC_CCM_CBCDR_PERCLK_PODF_MASK) >> + MXC_CCM_CBCDR_PERCLK_PODF_OFFSET; + + return clk_root / ((pred1 + 1) * (pred2 + 1) * (podf + 1)); +} + /* static u32 __get_perclk_lp_apm(void) { |