From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?Beno=C3=AEt_Th=C3=A9baudeau?= Date: Thu, 27 Sep 2012 22:22:51 +0200 (CEST) Subject: [U-Boot] [PATCH v2 08/14] mx5 clocks: Fix get_periph_clk() In-Reply-To: <1065839952.5372238.1348777198067.JavaMail.root@advansee.com> Message-ID: <1215647551.5372449.1348777371377.JavaMail.root@advansee.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de In the case periph_clk comes from periph_apm_clk, the latter is selected by the CCM.CBCMR.periph_apm_sel mux, which can source the lp_apm clock from its input ?2. get_periph_clk() returned 0 instead of the lp_apm clock frequency in this case. Signed-off-by: Beno?t Th?baudeau Cc: Stefano Babic --- This patch supersedes http://patchwork.ozlabs.org/patch/177406/ . Changes for v2: - Consequences from the previous cleanup patches. - Add detailed description. .../arch/arm/cpu/armv7/mx5/clock.c | 42 ++++++++++---------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git u-boot-imx-e1eb75b.orig/arch/arm/cpu/armv7/mx5/clock.c u-boot-imx-e1eb75b/arch/arm/cpu/armv7/mx5/clock.c index 6d984cb..b155214 100644 --- u-boot-imx-e1eb75b.orig/arch/arm/cpu/armv7/mx5/clock.c +++ u-boot-imx-e1eb75b/arch/arm/cpu/armv7/mx5/clock.c @@ -235,6 +235,26 @@ static u32 get_fpm(void) #endif /* + * This function returns the low power audio clock. + */ +static u32 get_lp_apm(void) +{ + u32 ret_val = 0; + u32 ccsr = readl(&mxc_ccm->ccsr); + + if (ccsr & MXC_CCM_CCSR_LP_APM) +#if defined(CONFIG_MX51) + ret_val = get_fpm(); +#elif defined(CONFIG_MX53) + ret_val = decode_pll(mxc_plls[PLL4_CLOCK], MXC_HCLK); +#endif + else + ret_val = MXC_HCLK; + + return ret_val; +} + +/* * Get mcu main rate */ u32 get_mcu_main_clk(void) @@ -262,6 +282,8 @@ u32 get_periph_clk(void) return decode_pll(mxc_plls[PLL1_CLOCK], MXC_HCLK); case 1: return decode_pll(mxc_plls[PLL3_CLOCK], MXC_HCLK); + case 2: + return get_lp_apm(); default: return 0; } @@ -331,26 +353,6 @@ static u32 get_uart_clk(void) } /* - * This function returns the low power audio clock. - */ -static u32 get_lp_apm(void) -{ - u32 ret_val = 0; - u32 ccsr = readl(&mxc_ccm->ccsr); - - if (ccsr & MXC_CCM_CCSR_LP_APM) -#if defined(CONFIG_MX51) - ret_val = get_fpm(); -#elif defined(CONFIG_MX53) - ret_val = decode_pll(mxc_plls[PLL4_CLOCK], MXC_HCLK); -#endif - else - ret_val = MXC_HCLK; - - return ret_val; -} - -/* * get cspi clock rate. */ static u32 imx_get_cspiclk(void)