From: "Jernej Škrabec" <jernej.skrabec@gmail.com>
To: Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Chen-Yu Tsai <wens@csie.org>,
Samuel Holland <samuel@sholland.org>,
Andre Przywara <andre.przywara@arm.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>,
linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 03/15] clk: sunxi-ng: Add support for update bit
Date: Tue, 04 Mar 2025 16:28:48 +0100 [thread overview]
Message-ID: <3616088.iIbC2pHGDl@jernej-laptop> (raw)
In-Reply-To: <20250304012805.28594-4-andre.przywara@arm.com>
Dne torek, 4. marec 2025 ob 02:27:53 Srednjeevropski standardni čas je Andre Przywara napisal(a):
> Some clocks in the Allwinner A523 SoC contain an "update bit" (bit 27),
> which must be set to apply any register changes, namely the mux
> selector, the divider and the gate bit.
>
> Add a new CCU feature bit to mark those clocks, and set bit 27 whenever
> we are applying any changes.
>
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> ---
> drivers/clk/sunxi-ng/ccu_common.h | 4 ++++
> drivers/clk/sunxi-ng/ccu_div.c | 2 ++
> drivers/clk/sunxi-ng/ccu_gate.c | 4 ++++
> drivers/clk/sunxi-ng/ccu_mux.c | 2 ++
> 4 files changed, 12 insertions(+)
>
> diff --git a/drivers/clk/sunxi-ng/ccu_common.h b/drivers/clk/sunxi-ng/ccu_common.h
> index 50fd268329671..d41d33bdff470 100644
> --- a/drivers/clk/sunxi-ng/ccu_common.h
> +++ b/drivers/clk/sunxi-ng/ccu_common.h
> @@ -20,10 +20,14 @@
> #define CCU_FEATURE_KEY_FIELD BIT(8)
> #define CCU_FEATURE_CLOSEST_RATE BIT(9)
> #define CCU_FEATURE_DUAL_DIV BIT(10)
> +#define CCU_FEATURE_UPDATE_BIT27 BIT(11)
There is no reason to have "BIT27" in the name of the macro. This is similar
to KEY_FIELD, which is generic name and doesn't specify either key or position
of this key field. Maybe just CCU_FEATURE_UPDATE_BIT or something equaly
generic.
With that fixed:
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Best regards,
Jernej
>
> /* MMC timing mode switch bit */
> #define CCU_MMC_NEW_TIMING_MODE BIT(30)
>
> +/* Some clocks need this bit to actually apply register changes */
> +#define CCU_SUNXI_UPDATE_BIT BIT(27)
> +
> struct device_node;
>
> struct ccu_common {
> diff --git a/drivers/clk/sunxi-ng/ccu_div.c b/drivers/clk/sunxi-ng/ccu_div.c
> index 7f4691f09e01f..2d8b98fe4b13a 100644
> --- a/drivers/clk/sunxi-ng/ccu_div.c
> +++ b/drivers/clk/sunxi-ng/ccu_div.c
> @@ -106,6 +106,8 @@ static int ccu_div_set_rate(struct clk_hw *hw, unsigned long rate,
>
> reg = readl(cd->common.base + cd->common.reg);
> reg &= ~GENMASK(cd->div.width + cd->div.shift - 1, cd->div.shift);
> + if (cd->common.features & CCU_FEATURE_UPDATE_BIT27)
> + reg |= CCU_SUNXI_UPDATE_BIT;
>
> writel(reg | (val << cd->div.shift),
> cd->common.base + cd->common.reg);
> diff --git a/drivers/clk/sunxi-ng/ccu_gate.c b/drivers/clk/sunxi-ng/ccu_gate.c
> index ac52fd6bff677..0490f95781361 100644
> --- a/drivers/clk/sunxi-ng/ccu_gate.c
> +++ b/drivers/clk/sunxi-ng/ccu_gate.c
> @@ -20,6 +20,8 @@ void ccu_gate_helper_disable(struct ccu_common *common, u32 gate)
> spin_lock_irqsave(common->lock, flags);
>
> reg = readl(common->base + common->reg);
> + if (common->features & CCU_FEATURE_UPDATE_BIT27)
> + reg |= CCU_SUNXI_UPDATE_BIT;
> writel(reg & ~gate, common->base + common->reg);
>
> spin_unlock_irqrestore(common->lock, flags);
> @@ -44,6 +46,8 @@ int ccu_gate_helper_enable(struct ccu_common *common, u32 gate)
> spin_lock_irqsave(common->lock, flags);
>
> reg = readl(common->base + common->reg);
> + if (common->features & CCU_FEATURE_UPDATE_BIT27)
> + reg |= CCU_SUNXI_UPDATE_BIT;
> writel(reg | gate, common->base + common->reg);
>
> spin_unlock_irqrestore(common->lock, flags);
> diff --git a/drivers/clk/sunxi-ng/ccu_mux.c b/drivers/clk/sunxi-ng/ccu_mux.c
> index d7ffbdeee9e04..82ee21e0d3a68 100644
> --- a/drivers/clk/sunxi-ng/ccu_mux.c
> +++ b/drivers/clk/sunxi-ng/ccu_mux.c
> @@ -197,6 +197,8 @@ int ccu_mux_helper_set_parent(struct ccu_common *common,
> /* The key field always reads as zero. */
> if (common->features & CCU_FEATURE_KEY_FIELD)
> reg |= CCU_MUX_KEY_VALUE;
> + if (common->features & CCU_FEATURE_UPDATE_BIT27)
> + reg |= CCU_SUNXI_UPDATE_BIT;
>
> reg &= ~GENMASK(cm->width + cm->shift - 1, cm->shift);
> writel(reg | (index << cm->shift), common->base + common->reg);
>
next prev parent reply other threads:[~2025-03-04 16:36 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-04 1:27 [PATCH v3 00/15] clk: sunxi-ng: add A523 clock support Andre Przywara
2025-03-04 1:27 ` [PATCH v3 01/15] clk: sunxi-ng: mp: introduce dual-divider clock Andre Przywara
2025-03-04 1:27 ` [PATCH v3 02/15] clk: sunxi-ng: mp: provide wrappers for setting feature flags Andre Przywara
2025-03-04 1:27 ` [PATCH v3 03/15] clk: sunxi-ng: Add support for update bit Andre Przywara
2025-03-04 15:28 ` Jernej Škrabec [this message]
2025-03-07 0:18 ` Andre Przywara
2025-03-04 1:27 ` [PATCH v3 04/15] dt-bindings: clk: sunxi-ng: document Allwinner A523 CCU Andre Przywara
2025-03-04 8:25 ` Krzysztof Kozlowski
2025-03-04 10:36 ` Andre Przywara
2025-03-04 14:11 ` Rob Herring
2025-03-05 11:34 ` Andre Przywara
2025-03-04 1:27 ` [PATCH v3 05/15] dt-bindings: clk: sunxi-ng: add compatible for the A523 PRCM-CCU Andre Przywara
2025-03-04 8:24 ` Krzysztof Kozlowski
2025-03-04 1:27 ` [PATCH v3 06/15] clk: sunxi-ng: Add support for the A523/T527 CCU PLLs Andre Przywara
2025-03-04 1:27 ` [PATCH v3 07/15] clk: sunxi-ng: a523: Add support for bus clocks Andre Przywara
2025-03-04 1:27 ` [PATCH v3 08/15] clk: sunxi-ng: a523: add video mod clocks Andre Przywara
2025-03-04 1:27 ` [PATCH v3 09/15] clk: sunxi-ng: a523: add system " Andre Przywara
2025-03-04 1:28 ` [PATCH v3 10/15] clk: sunxi-ng: a523: add interface " Andre Przywara
2025-03-04 1:28 ` [PATCH v3 11/15] clk: sunxi-ng: a523: add USB " Andre Przywara
2025-03-04 1:28 ` [PATCH v3 12/15] clk: sunxi-ng: a523: remaining " Andre Przywara
2025-03-04 1:28 ` [PATCH v3 13/15] clk: sunxi-ng: a523: add bus clock gates Andre Przywara
2025-03-04 1:28 ` [PATCH v3 14/15] clk: sunxi-ng: a523: add reset lines Andre Przywara
2025-03-04 1:28 ` [PATCH v3 15/15] clk: sunxi-ng: add support for the A523/T527 PRCM CCU Andre Przywara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3616088.iIbC2pHGDl@jernej-laptop \
--to=jernej.skrabec@gmail.com \
--cc=andre.przywara@arm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=mturquette@baylibre.com \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=samuel@sholland.org \
--cc=sboyd@kernel.org \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).