MLK-13480-1 ARM: imx: improve composite clk parent index setting
authorAnson Huang <Anson.Huang@nxp.com>
Fri, 18 Nov 2016 13:53:59 +0000 (21:53 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:52:38 +0000 (14:52 -0500)
The PCC clock bit field definition is as below:

000b - Clock is off.
001b - Clock option 1
010b - Clock option 2
011b - Clock option 3
100b - Clock option 4
101b - Clock option 5

So previous clock driver sets PCC clock parent to
start from index value 1 by setting CLK_MUX_INDEX_ONE
flag, however it has an issue of getting clock parent
when the register field value is 0, below is the clk
get parent code from clk driver:

if (val && (mux->flags & CLK_MUX_INDEX_BIT))
val = ffs(val) - 1;

if (val && (mux->flags & CLK_MUX_INDEX_ONE))
val--;

The val is 0, so the parent will be returned as first
clock parent in PCC register field which is 001b,
that will cause setting clk parent fail when the
reset value is 0 and we try to set clk parent to
option 1, as clk driver thinks current clk parent
is same as the new parent.

Fix this issue by adding dummy clock as option0, ths
clk gate is controlled by bit 30, so it would NOT impact
gating function.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
drivers/clk/imx/clk-composite.c
drivers/clk/imx/clk-imx7ulp.c

index 2e70f78..f329a92 100644 (file)
@@ -42,7 +42,6 @@ struct clk *imx_clk_composite(const char *name, const char **parent_name,
                mux->reg = reg;
                mux->shift = PCG_PCS_SHIFT;
                mux->mask = PCG_PCS_MASK;
-               mux->flags = CLK_MUX_INDEX_ONE;
                /* mux->lock */
        }
 
index ad24f7e..51f9f80 100644 (file)
@@ -27,9 +27,9 @@ static const char *apll_sels[]                = { "apll", "apll_pfd_sel", };
 static const char *sys_sels[]          = { "dummy", "osc", "sirc", "firc", "ckil", "apll", "spll", "upll", };
 static const char *ddr_sels[]          = { "apll_pfd_sel", "upll", };
 static const char *nic_sels[]          = { "firc", "ddr_div", };
-static const char *periph_plat_sels[]  = { "nic1_bus", "nic1_div", "ddr_div", "apll_pfd2", "apll_pfd1", "apll_pfd0", "upll", };
+static const char *periph_plat_sels[]  = { "dummy", "nic1_bus", "nic1_div", "ddr_div", "apll_pfd2", "apll_pfd1", "apll_pfd0", "upll", };
 /* the dummy in only a space holder of spll_bus clk */
-static const char *periph_slow_sels[]  = { "osc", "mpll", "firc", "ckil", "nic1_bus", "nic1_div", "dummy", };
+static const char *periph_slow_sels[]  = { "dummy", "osc", "mpll", "firc", "ckil", "nic1_bus", "nic1_div", "dummy", };
 static struct clk *clks[IMX7ULP_CLK_END];
 static struct clk_onecell_data clk_data;
 
@@ -157,8 +157,6 @@ static void __init imx7ulp_clocks_init(struct device_node *scg_node)
        for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
                imx_clk_prepare_enable(clks[clks_init_on[i]]);
 
-       imx_clk_set_parent(clks[IMX7ULP_CLK_LPTPM5], clks[IMX7ULP_CLK_FIRC]);
-
        pr_info("i.MX7ULP clock tree init done.\n");
 }