From nobody Mon Feb 9 01:35:16 2026 Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6223D238C1F; Thu, 8 Jan 2026 02:11:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.211.166.183 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767838319; cv=none; b=T0KjdsvPWIN/9tC0kMFBev9iGFzhsA1yAggvK3N8ZOuGp9fyuesTxRw7JFVtX8CvlXpP7uK/IUqeHSZfLsPZf9TEkTdvf13LkzB7N1dREUgwsq3TEVo3UV0tCNhrkTLoEUhJhMkYU64/bA4YE7BP1Ni+cPCuB9msFYjg8AiC8yo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767838319; c=relaxed/simple; bh=ipL2B/NzInRqtMt2AU3bNhpY6GimKKXFXudISgvQy5c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ETFjTDGGuJ3HlIXuunFepANrvA/65W/jfs654CUD2RVcZX4XnJD3KYGbGjvCg/Ir9kHWhTRlUcUgJ7PW52gefQz7lqiATL3dggTrVyCHuOLDmsJdlOBxdxQpc9lwYaNgva99hDkNrXcrAkglgYZDexlYsLOgY4p/rJKiSIEpTjg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gentoo.org; spf=pass smtp.mailfrom=gentoo.org; arc=none smtp.client-ip=140.211.166.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gentoo.org Received: from [127.0.0.1] (unknown [116.232.18.222]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dlan) by smtp.gentoo.org (Postfix) with ESMTPSA id 941EC341EAD; Thu, 08 Jan 2026 02:11:53 +0000 (UTC) From: Yixun Lan Date: Thu, 08 Jan 2026 10:11:06 +0800 Subject: [PATCH v5 2/5] clk: spacemit: ccu_mix: add inverted enable gate clock Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260108-k3-clk-v5-2-42a11b74ad58@gentoo.org> References: <20260108-k3-clk-v5-0-42a11b74ad58@gentoo.org> In-Reply-To: <20260108-k3-clk-v5-0-42a11b74ad58@gentoo.org> To: Stephen Boyd , Michael Turquette , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Haylen Chu , Guodong Xu , Inochi Amaoto , Yao Zi , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, spacemit@lists.linux.dev, linux-kernel@vger.kernel.org, Yixun Lan X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3259; i=dlan@gentoo.org; h=from:subject:message-id; bh=ipL2B/NzInRqtMt2AU3bNhpY6GimKKXFXudISgvQy5c=; b=owEB6QIW/ZANAwAKATGq6kdZTbvtAcsmYgBpXxJSwMOvqNQH5ctJ9yTO5K2YL6p5T/i+91TMQ pxNrsfC7u+JAq8EAAEKAJkWIQS1urjJwxtxFWcCI9wxqupHWU277QUCaV8SUhsUgAAAAAAEAA5t YW51MiwyLjUrMS4xMSwyLDJfFIAAAAAALgAoaXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5 maWZ0aGhvcnNlbWFuLm5ldEI1QkFCOEM5QzMxQjcxMTU2NzAyMjNEQzMxQUFFQTQ3NTk0REJCRU QACgkQMarqR1lNu+09lRAAi6nac5kUuRukaaX76ecHj96dL9sXE9REJ1TucEDGsOOI1pcWT0M89 drsN8E8Om+SYczq/F5GgpaYmmxupB3lXV3UETudDsU+2tRwo3g8awfaWvLvnKNmTNzEfS+szzb9 dc688VRhAhqtTPx7WrSK4vr001MJ+YXhX9t/nIdjInQcs0FDeDbd400teOQUxSfFDagcFHqRuxA iS3DWXOC3eTbhsjyVqGD0OQvCimL0I9zJSZX5bqwIRgTJWDPwoikKeiul4ekeUG8u6DPwlQVtig A1mg2DNVEfBDo8pjaPnbhVGYCinSmwvV7lNwtTngbaPbpY5ukI0dsQUzqcqS/ypfW4U5UIhgsrx xfh9DMb+BOs9Mdj1dRjk1dFNTjPc1ujL0R0v6bjO7Fos5WGIdSDYr5Z7gJhXqKTFx3TZX7nmUjM Ue9ycnBW9ryrI4fDq0Q8RBwqqfgcvs3EGEhHTThBlUOTVYLRquH/DY3l1cImgDD2Fa7s8WbFV0G d7RZrG6aD0vrzjzftUv/U/4gYoxfX4vTyRAPNoBp9eCKGh0YM6Dq2ALrPlTzhOCGmgexq4ZgGWp 7MpXoScZYQuB+a4pIDfHPAoOSaYpslebaMhFjgXc0jkChpklOjHsQ0mSLHmqRByiRf1WDSBp9DX Y/+nk1NJKGrJgIO5kfxqzNTuu2JvbY= X-Developer-Key: i=dlan@gentoo.org; a=openpgp; fpr=50B03A1A5CBCD33576EF8CD7920C0DBCAABEFD55 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 --- 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 67f8b12b4f5b..9578366e9746 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 =3D hw_to_ccu_mix(hw); + struct ccu_gate_config *gate =3D &mix->gate; + u32 val =3D gate->inverted ? gate->mask : 0; =20 - ccu_update(&mix->common, ctrl, mix->gate.mask, 0); + ccu_update(&mix->common, ctrl, gate->mask, val); } =20 static int ccu_gate_enable(struct clk_hw *hw) { struct ccu_mix *mix =3D hw_to_ccu_mix(hw); struct ccu_gate_config *gate =3D &mix->gate; + u32 val =3D gate->inverted ? 0 : gate->mask; =20 - ccu_update(&mix->common, ctrl, gate->mask, gate->mask); - + ccu_update(&mix->common, ctrl, gate->mask, val); return 0; } =20 @@ -34,8 +36,10 @@ static int ccu_gate_is_enabled(struct clk_hw *hw) { struct ccu_mix *mix =3D hw_to_ccu_mix(hw); struct ccu_gate_config *gate =3D &mix->gate; + u32 tmp =3D ccu_read(&mix->common, ctrl) & gate->mask; + u32 val =3D gate->inverted ? 0 : gate->mask; =20 - return (ccu_read(&mix->common, ctrl) & gate->mask) =3D=3D gate->mask; + return !!(tmp =3D=3D val); } =20 static unsigned long ccu_factor_recalc_rate(struct clk_hw *hw, diff --git a/drivers/clk/spacemit/ccu_mix.h b/drivers/clk/spacemit/ccu_mix.h index c406508e3504..dbba9bf49b3b 100644 --- a/drivers/clk/spacemit/ccu_mix.h +++ b/drivers/clk/spacemit/ccu_mix.h @@ -16,9 +16,11 @@ * * @mask: Mask to enable the gate. Some clocks may have more than one bit * set in this field. + * @inverted: Enable bit is inverted, 1 - disable clock, 0 - enable clock */ struct ccu_gate_config { u32 mask; + bool inverted; }; =20 struct ccu_factor_config { @@ -48,6 +50,7 @@ struct ccu_mix { #define CCU_FACTOR_INIT(_div, _mul) { .div =3D _div, .mul =3D _mul } #define CCU_MUX_INIT(_shift, _width) { .shift =3D _shift, .width =3D _widt= h } #define CCU_DIV_INIT(_shift, _width) { .shift =3D _shift, .width =3D _widt= h } +#define CCU_GATE_FLAGS_INIT(_mask, _inverted) { .mask =3D _mask, .inverted= =3D _inverted } =20 #define CCU_PARENT_HW(_parent) { .hw =3D &_parent.common.hw } #define CCU_PARENT_NAME(_name) { .fw_name =3D #_name } @@ -101,6 +104,15 @@ static struct ccu_mix _name =3D { \ } \ } =20 +#define CCU_GATE_FLAGS_DEFINE(_name, _parent, _reg_ctrl, _mask_gate, _inve= rted, _flags) \ +static struct ccu_mix _name =3D { \ + .gate =3D CCU_GATE_FLAGS_INIT(_mask_gate, _inverted), \ + .common =3D { \ + .reg_ctrl =3D _reg_ctrl, \ + CCU_MIX_INITHW(_name, _parent, spacemit_ccu_gate_ops, _flags), \ + } \ +} + #define CCU_FACTOR_GATE_FLAGS_DEFINE(_name, _parent, _reg_ctrl, _mask_gate= , _div, \ _mul, _flags) \ static struct ccu_mix _name =3D { \ --=20 2.52.0