From: claudiu beznea <claudiu.beznea@tuxon.dev>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: mturquette@baylibre.com, sboyd@kernel.org, robh+dt@kernel.org,
krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org,
linus.walleij@linaro.org, gregkh@linuxfoundation.org,
jirislaby@kernel.org, magnus.damm@gmail.com,
catalin.marinas@arm.com, will@kernel.org,
quic_bjorande@quicinc.com, konrad.dybcio@linaro.org,
arnd@arndb.de, neil.armstrong@linaro.org,
prabhakar.mahadev-lad.rj@bp.renesas.com,
biju.das.jz@bp.renesas.com, linux-renesas-soc@vger.kernel.org,
linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
linux-serial@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 10/28] clk: renesas: rzg2l: refactor sd mux driver
Date: Thu, 5 Oct 2023 07:24:30 +0300 [thread overview]
Message-ID: <0d0448c7-c33b-8960-d2ed-0a22e2f7fb3d@tuxon.dev> (raw)
In-Reply-To: <CAMuHMdUJj+h5LfhQXTNkN3Cp2wP62SX6fY3frzytJQBcKXDJJQ@mail.gmail.com>
Hi, Geert,
On 04.10.2023 14:30, Geert Uytterhoeven wrote:
> Hi Claudiu,
>
> On Fri, Sep 29, 2023 at 7:39 AM Claudiu <claudiu.beznea@tuxon.dev> wrote:
>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>
>> Refactor SD MUX driver to be able to reuse the same code on RZ/G3S.
>> RZ/G2{L, UL} has a limitation with regards to switching the clock source
>> for SD MUX (MUX clock source has to be switched to 266MHz before switching
>> b/w 533MHz and 400MHz). This limitation has been introduced as a clock
>> notifier that is registered on platform based initialization data thus the
>> SD MUX code could be reused on RZ/G3S.
>>
>> As both RZ/G2{L, UL} and RZ/G3S has specific bits in specific registers
>> to check if the clock switching has been done, this configuration (register
>> offset, register bits and bits width) is now passed though
>> struct cpg_core_clk::sconf (status configuration) from platform specific
>> initialization code.
>>
>> Along with struct cpg_core_clk::sconf the mux table indices are also
>> passed from platform specific initialization code.
>>
>> Also, mux flags are now passed to DEF_SD_MUX() as they will be later
>> used by RZ/G3S.
>>
>> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>> ---
>>
>> Changes in v2:
>> - s/indexes/indices in commit description
>> - mentioned in commit description that mux flags can now be passed to
>> driver though DEF_SD_MUX() macro
>> - removed SoC specific names from macros' names
>> - added spaces after { and before } when initializing arrays
>> - preserved the order of .[gs]set_parent() API definitions for simpler
>> diff b/w versions
>> - removed SD_MUX_NOTIF macro
>
> Thanks for the update!
>
>> --- a/drivers/clk/renesas/rzg2l-cpg.c
>> +++ b/drivers/clk/renesas/rzg2l-cpg.c
>
>> @@ -142,6 +146,77 @@ static void rzg2l_cpg_del_clk_provider(void *data)
>> of_clk_del_provider(data);
>> }
>>
>> +/* Must be called in atomic context. */
>> +static int rzg2l_cpg_wait_clk_update_done(void __iomem *base, u32 conf)
>> +{
>> + u32 bitmask = GENMASK(GET_WIDTH(conf) - 1, 0) << GET_SHIFT(conf);
>> + u32 off = GET_REG_OFFSET(conf);
>> + u32 val;
>> +
>> + return readl_poll_timeout_atomic(base + off, val, !(val & bitmask), 10, 200);
>> +}
>> +
>> +int rzg2l_cpg_sd_mux_clk_notifier(struct notifier_block *nb, unsigned long event,
>> + void *data)
>> +{
>> + struct clk_notifier_data *cnd = data;
>> + struct clk_hw *hw = __clk_get_hw(cnd->clk);
>> + struct clk_hw_data *clk_hw_data = to_clk_hw_data(hw);
>> + struct rzg2l_cpg_priv *priv = clk_hw_data->priv;
>> + u32 off = GET_REG_OFFSET(clk_hw_data->conf);
>> + u32 shift = GET_SHIFT(clk_hw_data->conf);
>> + const u32 clk_src_266 = 3;
>> + unsigned long flags;
>> + u32 bitmask;
>> + int ret;
>> +
>> + if (event != PRE_RATE_CHANGE || (cnd->new_rate / MEGA == 266))
>> + return 0;
>
> include/linux/clk.h:
>
> * PRE_RATE_CHANGE - called immediately before the clk rate is changed,
> * to indicate that the rate change will proceed. Drivers must
> * immediately terminate any operations that will be affected by the
> * rate change. Callbacks may either return NOTIFY_DONE, NOTIFY_OK,
> * NOTIFY_STOP or NOTIFY_BAD.
Indeed I missed these.
>
>> +
>> + spin_lock_irqsave(&priv->rmw_lock, flags);
>> +
>> + /*
>> + * As per the HW manual, we should not directly switch from 533 MHz to
>> + * 400 MHz and vice versa. To change the setting from 2’b01 (533 MHz)
>> + * to 2’b10 (400 MHz) or vice versa, Switch to 2’b11 (266 MHz) first,
>> + * and then switch to the target setting (2’b01 (533 MHz) or 2’b10
>> + * (400 MHz)).
>> + * Setting a value of '0' to the SEL_SDHI0_SET or SEL_SDHI1_SET clock
>> + * switching register is prohibited.
>> + * The clock mux has 3 input clocks(533 MHz, 400 MHz, and 266 MHz), and
>> + * the index to value mapping is done by adding 1 to the index.
>> + */
>> + bitmask = (GENMASK(GET_WIDTH(clk_hw_data->conf) - 1, 0) << shift) << 16;
>> + writel(bitmask | (clk_src_266 << shift), priv->base + off);
>> +
>> + /* Wait for the update done. */
>> + ret = rzg2l_cpg_wait_clk_update_done(priv->base, clk_hw_data->sconf);
>> +
>> + spin_unlock_irqrestore(&priv->rmw_lock, flags);
>> +
>> + if (ret)
>> + dev_err(priv->dev, "failed to switch to safe clk source\n");
>> +
>> + return ret;
>
> Likewise.
>
>> +}
>
>>
>> static const struct clk_ops rzg2l_cpg_sd_clk_mux_ops = {
>> .determine_rate = __clk_mux_determine_rate_closest,
>> - .set_parent = rzg2l_cpg_sd_clk_mux_set_parent,
>> - .get_parent = rzg2l_cpg_sd_clk_mux_get_parent,
>> + .set_parent = rzg2l_cpg_sd_mux_clk_set_parent,
>> + .get_parent = rzg2l_cpg_sd_mux_clk_get_parent,
>
> Please keep the old names, for consistency with
> __clk_mux_determine_rate_closest() and drivers/clk/clk-mux.c, and to
> reduce the diff.
>
> Any existing inconsistent use of "clk_mux" vs. "mux_clk" can be resolved
> later with a separate patch, if anyone cares.
ok
>
>> --- a/drivers/clk/renesas/rzg2l-cpg.h
>> +++ b/drivers/clk/renesas/rzg2l-cpg.h
>
>> @@ -272,4 +276,6 @@ extern const struct rzg2l_cpg_info r9a07g044_cpg_info;
>> extern const struct rzg2l_cpg_info r9a07g054_cpg_info;
>> extern const struct rzg2l_cpg_info r9a09g011_cpg_info;
>>
>> +int rzg2l_cpg_sd_mux_clk_notifier(struct notifier_block *nb, unsigned long event, void *data);
>
> rzg2l_cpg_sd_clk_mux_notifier()?
ok
>
>> +
>> #endif
>
> The rest LGTM.
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
next prev parent reply other threads:[~2023-10-05 4:24 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-29 5:38 [PATCH v2 00/28] Add new Renesas RZ/G3S SoC and RZ/G3S SMARC EVK Claudiu
2023-09-29 5:38 ` [PATCH v2 01/28] dt-bindings: serial: renesas,scif: document r9a08g045 support Claudiu
2023-09-29 5:38 ` [PATCH v2 02/28] clk: renesas: rzg2l: wait for status bit of SD mux before continuing Claudiu
2023-10-03 15:14 ` Geert Uytterhoeven
2023-09-29 5:38 ` [PATCH v2 03/28] clk: renesas: rzg2l: lock around writes to mux register Claudiu
2023-10-03 15:18 ` Geert Uytterhoeven
2023-09-29 5:38 ` [PATCH v2 04/28] clk: renesas: rzg2l: trust value returned by hardware Claudiu
2023-10-03 15:19 ` Geert Uytterhoeven
2023-09-29 5:38 ` [PATCH v2 05/28] clk: renesas: rzg2l: fix computation formula Claudiu
2023-10-04 8:08 ` Geert Uytterhoeven
2023-09-29 5:38 ` [PATCH v2 06/28] clk: renesas: rzg2l: remove critical area Claudiu
2023-10-04 8:11 ` Geert Uytterhoeven
2023-09-29 5:38 ` [PATCH v2 07/28] clk: renesas: rzg2l: add support for RZ/G3S PLL Claudiu
2023-10-04 8:45 ` Geert Uytterhoeven
2023-09-29 5:38 ` [PATCH v2 08/28] clk: renesas: rzg2l: add struct clk_hw_data Claudiu
2023-10-04 8:47 ` Geert Uytterhoeven
2023-09-29 5:38 ` [PATCH v2 09/28] clk: renesas: rzg2l: remove CPG_SDHI_DSEL from generic header Claudiu
2023-10-04 8:50 ` Geert Uytterhoeven
2023-09-29 5:38 ` [PATCH v2 10/28] clk: renesas: rzg2l: refactor sd mux driver Claudiu
2023-10-04 11:30 ` Geert Uytterhoeven
2023-10-05 4:24 ` claudiu beznea [this message]
2023-09-29 5:38 ` [PATCH v2 11/28] clk: renesas: rzg2l: add a divider clock for RZ/G3S Claudiu
2023-10-04 12:30 ` Geert Uytterhoeven
2023-10-05 5:04 ` claudiu beznea
2023-10-09 11:57 ` Geert Uytterhoeven
2023-09-29 5:38 ` [PATCH v2 12/28] dt-bindings: clock: renesas,rzg2l-cpg: document RZ/G3S SoC Claudiu
2023-10-04 12:37 ` Geert Uytterhoeven
2023-09-29 5:39 ` [PATCH v2 13/28] clk: renesas: add minimal boot support for " Claudiu
2023-10-04 12:41 ` Geert Uytterhoeven
2023-09-29 5:39 ` [PATCH v2 14/28] pinctrl: renesas: rzg2l: index all registers based on port offset Claudiu
2023-10-04 12:52 ` Geert Uytterhoeven
2023-09-29 5:39 ` [PATCH v2 15/28] pinctrl: renesas: rzg2l: adapt for different SD/PWPR register offsets Claudiu
2023-10-04 12:57 ` Geert Uytterhoeven
2023-09-29 5:39 ` [PATCH v2 16/28] pinctrl: renesas: rzg2l: adapt function number for RZ/G3S Claudiu
2023-10-04 12:58 ` Geert Uytterhoeven
2023-09-29 5:39 ` [PATCH v2 17/28] pinctrl: renesas: rzg2l: move ds and oi to SoC specific configuration Claudiu
2023-10-04 13:18 ` Geert Uytterhoeven
2023-09-29 5:39 ` [PATCH v2 18/28] pinctrl: renesas: rzg2l: add support for different ds values on different groups Claudiu
2023-09-29 9:24 ` Paul Barker
2023-10-04 13:17 ` Geert Uytterhoeven
2023-10-05 5:05 ` claudiu beznea
2023-10-05 10:04 ` Geert Uytterhoeven
2023-09-29 5:39 ` [PATCH v2 19/28] dt-bindings: pinctrl: renesas: set additionalProperties: false Claudiu
2023-09-29 14:09 ` Conor Dooley
2023-10-02 14:50 ` Rob Herring
2023-10-03 3:57 ` claudiu beznea
2023-09-29 5:39 ` [PATCH v2 20/28] dt-bindings: pinctrl: renesas: document RZ/G3S SoC Claudiu
2023-09-29 14:07 ` Conor Dooley
2023-10-04 13:21 ` Geert Uytterhoeven
2023-09-29 5:39 ` [PATCH v2 21/28] pinctrl: renesas: rzg2l: add support for " Claudiu
2023-10-04 13:24 ` Geert Uytterhoeven
2023-09-29 5:39 ` [PATCH v2 22/28] arm64: dts: renesas: add initial DTSI " Claudiu
2023-10-04 13:29 ` Geert Uytterhoeven
2023-09-29 5:39 ` [PATCH v2 23/28] dt-bindings: arm: renesas: document RZ/G3S SMARC SoM Claudiu
2023-09-29 14:05 ` Conor Dooley
2023-10-04 13:28 ` Geert Uytterhoeven
2023-09-29 5:39 ` [PATCH v2 24/28] arm64: dts: renesas: rzg3l-smarc-som: add initial support for " Claudiu
2023-10-04 13:30 ` Geert Uytterhoeven
2023-09-29 5:39 ` [PATCH v2 25/28] arm64: dts: renesas: rzg3s-smarc: add initial device tree for RZ SMARC Carrier-II Board Claudiu
2023-10-04 13:31 ` Geert Uytterhoeven
2023-09-29 5:39 ` [PATCH v2 26/28] dt-bindings: arm: renesas: document SMARC Carrier-II EVK Claudiu
2023-09-29 14:05 ` Conor Dooley
2023-10-04 13:32 ` Geert Uytterhoeven
2023-09-29 5:39 ` [PATCH v2 27/28] arm64: dts: renesas: r9a08g045s33-smarc: add initial device tree for RZ/G3S SMARC EVK board Claudiu
2023-10-04 13:33 ` Geert Uytterhoeven
2023-09-29 5:39 ` [PATCH v2 28/28] arm64: defconfig: enable RZ/G3S (R9A08G045) SoC Claudiu
2023-10-04 13:34 ` Geert Uytterhoeven
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=0d0448c7-c33b-8960-d2ed-0a22e2f7fb3d@tuxon.dev \
--to=claudiu.beznea@tuxon.dev \
--cc=arnd@arndb.de \
--cc=biju.das.jz@bp.renesas.com \
--cc=catalin.marinas@arm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=konrad.dybcio@linaro.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=mturquette@baylibre.com \
--cc=neil.armstrong@linaro.org \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=quic_bjorande@quicinc.com \
--cc=robh+dt@kernel.org \
--cc=sboyd@kernel.org \
--cc=will@kernel.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).