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)
commit60abcc2ba8da8d0e526e243eb22b870ecaa036b4
tree7fd93ef65580cfb8880181a611ff93e77b09b216
parent9f615ac42121d8b2dd69f4f5011e10e751cf2b0b
MLK-13480-1 ARM: imx: improve composite clk parent index setting

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