Skip to content

Commit ae8a10d

Browse files
JackyBaiabelvesa
authored andcommitted
clk: imx: disable the pfd when set pfdv2 clock rate
It is possible that a PFD is enabled in HW but not in SW. That means the enable count & prepare count of the PFD clock is '0', so the 'CLK_SET_RATE' flag can do nothing when the rate is changed while the PFD is hw enabled. In order to safely change the pfd rate, we can disable the PFD directly if it is hw enabled but not used by SW end user. Signed-off-by: Jacky Bai <[email protected]> Reviewed-by: Abel Vesa <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Abel Vesa <[email protected]>
1 parent 75c6f1a commit ae8a10d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

drivers/clk/imx/clk-pfdv2.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,17 @@ static int clk_pfdv2_set_rate(struct clk_hw *hw, unsigned long rate,
161161
if (!rate)
162162
return -EINVAL;
163163

164-
/* PFD can NOT change rate without gating */
165-
WARN_ON(clk_pfdv2_is_enabled(hw));
164+
/*
165+
* PFD can NOT change rate without gating.
166+
* as the PFDs may enabled in HW by default but no
167+
* consumer used it, the enable count is '0', so the
168+
* 'SET_RATE_GATE' can NOT help on blocking the set_rate
169+
* ops especially for 'assigned-clock-xxx'. In order
170+
* to simplify the case, just disable the PFD if it is
171+
* enabled in HW but not in SW.
172+
*/
173+
if (clk_pfdv2_is_enabled(hw))
174+
clk_pfdv2_disable(hw);
166175

167176
tmp = tmp * 18 + rate / 2;
168177
do_div(tmp, rate);

0 commit comments

Comments
 (0)