]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mx25: Fix imx_get_perclk()
authorBenoît Thébaudeau <benoit@wsystem.com>
Wed, 3 May 2017 09:59:04 +0000 (11:59 +0200)
committerStefano Babic <sbabic@denx.de>
Wed, 31 May 2017 08:14:17 +0000 (10:14 +0200)
imx_get_perclk() used the AHB clock as the clock source for all PER
clocks, but the USB PLL output can also be a PER clock source if the
corresponding PER CLK MUX bit is set in CCM.MCR.

Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com>
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
arch/arm/cpu/arm926ejs/mx25/generic.c

index 0b1a8f4bbc2ad1bcb319e2ef45a477b8bd9cc494..f02cffb95e44084e6ef1b8b60c2400c4fd8a5c58 100644 (file)
@@ -58,6 +58,14 @@ static ulong imx_get_mpllclk(void)
        return imx_decode_pll(readl(&ccm->mpctl), fref);
 }
 
+static ulong imx_get_upllclk(void)
+{
+       struct ccm_regs *ccm = (struct ccm_regs *)IMX_CCM_BASE;
+       ulong fref = MXC_HCLK;
+
+       return imx_decode_pll(readl(&ccm->upctl), fref);
+}
+
 static ulong imx_get_armclk(void)
 {
        struct ccm_regs *ccm = (struct ccm_regs *)IMX_CCM_BASE;
@@ -95,7 +103,8 @@ static ulong imx_get_ipgclk(void)
 static ulong imx_get_perclk(int clk)
 {
        struct ccm_regs *ccm = (struct ccm_regs *)IMX_CCM_BASE;
-       ulong fref = imx_get_ahbclk();
+       ulong fref = readl(&ccm->mcr) & (1 << clk) ? imx_get_upllclk() :
+                                                    imx_get_ahbclk();
        ulong div;
 
        div = readl(&ccm->pcdr[CCM_PERCLK_REG(clk)]);