[PATCH RFC 2/4] clk: spacemit: ccu_mix: add inverted enable gate clock

Yao Zi me at ziyao.cc
Wed Dec 10 19:26:25 PST 2025


On Thu, Dec 11, 2025 at 09:19:42AM +0800, Yixun Lan wrote:
> K3 SoC has the clock IP which support to write value 0 for enabling the
> clock, while write 1 for disabling it, thus the enable BIT is inverted.
> So, introduce a flag to support the inverted gate clock.
> 
> Signed-off-by: Yixun Lan <dlan at gentoo.org>
> ---
>  drivers/clk/spacemit/ccu_mix.c | 12 ++++++++----
>  drivers/clk/spacemit/ccu_mix.h | 12 ++++++++++++
>  2 files changed, 20 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/clk/spacemit/ccu_mix.c b/drivers/clk/spacemit/ccu_mix.c
> index 7b7990875372..14fbf7048c89 100644
> --- a/drivers/clk/spacemit/ccu_mix.c
> +++ b/drivers/clk/spacemit/ccu_mix.c
> @@ -16,17 +16,19 @@
>  static void ccu_gate_disable(struct clk_hw *hw)
>  {
>  	struct ccu_mix *mix = hw_to_ccu_mix(hw);
> +	struct ccu_gate_config *gate = &mix->gate;
> +	u32 val = gate->inverted ? gate->mask : 0;
>  
> -	ccu_update(&mix->common, ctrl, mix->gate.mask, 0);
> +	ccu_update(&mix->common, ctrl, gate->mask, val);
>  }
>  
>  static int ccu_gate_enable(struct clk_hw *hw)
>  {
>  	struct ccu_mix *mix = hw_to_ccu_mix(hw);
>  	struct ccu_gate_config *gate = &mix->gate;
> +	u32 val = gate->inverted ? 0 : gate->mask;
>  
> -	ccu_update(&mix->common, ctrl, gate->mask, gate->mask);
> -
> +	ccu_update(&mix->common, ctrl, gate->mask, val);

An unrelated blank line gets removed here, is this intended?

>  	return 0;
>  }

Regards,
Yao Zi



More information about the linux-riscv mailing list