MLK-17439 mx7ulp: Change clock rate calculation for NIC1 BUS and EXT
authorYe Li <ye.li@nxp.com>
Mon, 22 Jan 2018 03:22:40 +0000 (19:22 -0800)
committerYe Li <ye.li@nxp.com>
Fri, 24 May 2019 11:28:41 +0000 (04:28 -0700)
On i.MX7ULP B0, there is change in NIC clock dividers architecture.
On A0, the NIC1 BUS and EXT dividers were in a chain with NIC1 DIV, but
on B0 they are parallel with NIC1 DIV. So now the dividers are independent.
This patch modifies the scg_nic_get_rate function according to this change.

Signed-off-by: Ye Li <ye.li@nxp.com>
Acked-by: Peng Fan <peng.fan@nxp.com>
(cherry picked from commit 1a53e025c6be73a84570a3857cb709d98e49ef96)
(cherry picked from commit ae54e190e6085687658419c4d971ae51fe91c589)

arch/arm/mach-imx/mx7ulp/scg.c

index 3bedeb4..283752b 100644 (file)
@@ -353,7 +353,7 @@ static u32 scg_ddr_get_rate(void)
 
 static u32 scg_nic_get_rate(enum scg_clk clk)
 {
-       u32 reg, val, rate;
+       u32 reg, val, rate, nic0_rate;
        u32 shift, mask;
 
        reg = readl(&scg1_regs->niccsr);
@@ -371,6 +371,7 @@ static u32 scg_nic_get_rate(enum scg_clk clk)
        val = (reg & SCG_NICCSR_NIC0DIV_MASK) >> SCG_NICCSR_NIC0DIV_SHIFT;
 
        rate = rate / (val + 1);
+       nic0_rate = rate;
 
        clk_debug("scg_nic_get_rate NIC0 rate %u\n", rate);
 
@@ -412,6 +413,10 @@ static u32 scg_nic_get_rate(enum scg_clk clk)
                return 0;
        }
 
+       /* On RevB, the nic_bus and nic_ext dividers are parallel not chained with nic div */
+       if (soc_rev() >= CHIP_REV_2_0)
+               rate = nic0_rate;
+
        val = (reg & mask) >> shift;
        rate = rate / (val + 1);