clk: spacemit: mark K1 pll1_d8 as critical
authorAlex Elder <elder@riscstar.com>
Thu, 12 Jun 2025 22:48:55 +0000 (17:48 -0500)
committerYixun Lan <dlan@gentoo.org>
Fri, 4 Jul 2025 01:06:33 +0000 (09:06 +0800)
commit7554729de27daf6d54bcf8689d863bbe267828bf
tree67dae8e5912eafdd929c36774e19dd91c4e3c414
parent19272b37aa4f83ca52bdf9c16d5d81bdd1354494
clk: spacemit: mark K1 pll1_d8 as critical

The pll1_d8 clock is enabled by the boot loader, and is ultimately a
parent for numerous clocks, including those used by APB and AXI buses.
Guodong Xu discovered that this clock got disabled while responding to
getting -EPROBE_DEFER when requesting a reset controller.

The needed clock (CLK_DMA, along with its parents) had already been
enabled.  To respond to the probe deferral return, the CLK_DMA clock
was disabled, and this led to parent clocks also reducing their enable
count.  When the enable count for pll1_d8 was decremented it became 0,
which caused it to be disabled.  This led to a system hang.

Marking that clock critical resolves this by preventing it from being
disabled.

Define a new macro CCU_FACTOR_GATE_DEFINE() to allow clock flags to
be supplied for a CCU_FACTOR_GATE clock.

Fixes: 1b72c59db0add ("clk: spacemit: Add clock support for SpacemiT K1 SoC")
Signed-off-by: Alex Elder <elder@riscstar.com>
Tested-by: Guodong Xu <guodong@riscstar.com>
Reviewed-by: Haylen Chu <heylenay@4d2.org>
Link: https://lore.kernel.org/r/20250612224856.1105924-1-elder@riscstar.com
Signed-off-by: Yixun Lan <dlan@gentoo.org>
drivers/clk/spacemit/ccu-k1.c
drivers/clk/spacemit/ccu_mix.h