Skip to content

Commit 8f32e9d

Browse files
MrVanabelvesa
authored andcommitted
clk: imx: composite-8m: Enable gate clk with mcore_booted
Bootloader might disable some CCM ROOT Slices. So if mcore_booted set with display CCM ROOT disabled by Bootloader, kernel display BLK CTRL driver imx8m_blk_ctrl_driver_init may hang the system because the BUS clk is disabled. Add back gate ops, but with disable doing nothing, then the CCM ROOT will be enabled when used. Fixes: bb7e897 ("clk: imx8m: check mcore_booted before register clk") Reviewed-by: Ye Li <[email protected]> Reviewed-by: Jacky Bai <[email protected]> Signed-off-by: Peng Fan <[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 e52fd71 commit 8f32e9d

File tree

1 file changed

+42
-11
lines changed

1 file changed

+42
-11
lines changed

drivers/clk/imx/clk-composite-8m.c

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,34 @@ static const struct clk_ops imx8m_clk_composite_mux_ops = {
204204
.determine_rate = imx8m_clk_composite_mux_determine_rate,
205205
};
206206

207+
static int imx8m_clk_composite_gate_enable(struct clk_hw *hw)
208+
{
209+
struct clk_gate *gate = to_clk_gate(hw);
210+
unsigned long flags;
211+
u32 val;
212+
213+
spin_lock_irqsave(gate->lock, flags);
214+
215+
val = readl(gate->reg);
216+
val |= BIT(gate->bit_idx);
217+
writel(val, gate->reg);
218+
219+
spin_unlock_irqrestore(gate->lock, flags);
220+
221+
return 0;
222+
}
223+
224+
static void imx8m_clk_composite_gate_disable(struct clk_hw *hw)
225+
{
226+
/* composite clk requires the disable hook */
227+
}
228+
229+
static const struct clk_ops imx8m_clk_composite_gate_ops = {
230+
.enable = imx8m_clk_composite_gate_enable,
231+
.disable = imx8m_clk_composite_gate_disable,
232+
.is_enabled = clk_gate_is_enabled,
233+
};
234+
207235
struct clk_hw *__imx8m_clk_hw_composite(const char *name,
208236
const char * const *parent_names,
209237
int num_parents, void __iomem *reg,
@@ -217,6 +245,7 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,
217245
struct clk_mux *mux;
218246
const struct clk_ops *divider_ops;
219247
const struct clk_ops *mux_ops;
248+
const struct clk_ops *gate_ops;
220249

221250
mux = kzalloc(sizeof(*mux), GFP_KERNEL);
222251
if (!mux)
@@ -257,20 +286,22 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,
257286
div->flags = CLK_DIVIDER_ROUND_CLOSEST;
258287

259288
/* skip registering the gate ops if M4 is enabled */
260-
if (!mcore_booted) {
261-
gate = kzalloc(sizeof(*gate), GFP_KERNEL);
262-
if (!gate)
263-
goto free_div;
264-
265-
gate_hw = &gate->hw;
266-
gate->reg = reg;
267-
gate->bit_idx = PCG_CGC_SHIFT;
268-
gate->lock = &imx_ccm_lock;
269-
}
289+
gate = kzalloc(sizeof(*gate), GFP_KERNEL);
290+
if (!gate)
291+
goto free_div;
292+
293+
gate_hw = &gate->hw;
294+
gate->reg = reg;
295+
gate->bit_idx = PCG_CGC_SHIFT;
296+
gate->lock = &imx_ccm_lock;
297+
if (!mcore_booted)
298+
gate_ops = &clk_gate_ops;
299+
else
300+
gate_ops = &imx8m_clk_composite_gate_ops;
270301

271302
hw = clk_hw_register_composite(NULL, name, parent_names, num_parents,
272303
mux_hw, mux_ops, div_hw,
273-
divider_ops, gate_hw, &clk_gate_ops, flags);
304+
divider_ops, gate_hw, gate_ops, flags);
274305
if (IS_ERR(hw))
275306
goto free_gate;
276307

0 commit comments

Comments
 (0)