From: Sebin Francis <sebin.francis@ti.com>
To: Peng Fan <peng.fan@nxp.com>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Sudeep Holla <sudeep.holla@arm.com>,
Cristian Marussi <cristian.marussi@arm.com>,
Marco Felsch <m.felsch@pengutronix.de>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Brian Masney <bmasney@redhat.com>, Dhruva Gole <d-gole@ti.com>
Cc: Dan Carpenter <dan.carpenter@linaro.org>,
Geert Uytterhoeven <geert@linux-m68k.org>,
<linux-clk@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<arm-scmi@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<devicetree@vger.kernel.org>
Subject: Re: [PATCH v4 3/5] clk: conf: Support assigned-clock-sscs
Date: Mon, 6 Oct 2025 16:14:21 +0530 [thread overview]
Message-ID: <98d588bd-7b46-4df4-b31c-2bb53a47c279@ti.com> (raw)
In-Reply-To: <20250915-clk-ssc-version1-v4-3-5a2cee2f0351@nxp.com>
Hi Peng,
On 15/09/25 13:59, Peng Fan wrote:
> Parse the Spread Spectrum Configuration(SSC) from device tree and configure
> them before using the clock.
>
> Each SSC is three u32 elements which means '<modfreq spreaddepth
> modmethod>', so assigned-clock-sscs is an array of multiple three u32
> elements.
>
> Reviewed-by: Brian Masney <bmasney@redhat.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/clk/clk-conf.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 69 insertions(+)
>
> diff --git a/drivers/clk/clk-conf.c b/drivers/clk/clk-conf.c
> index 303a0bb26e54a95655ce094a35b989c97ebc6fd8..dd6083597db3f8f27d86abf5640dfc3fb39a9b88 100644
> --- a/drivers/clk/clk-conf.c
> +++ b/drivers/clk/clk-conf.c
> @@ -155,6 +155,71 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier)
> return 0;
> }
>
> +static int __set_clk_spread_spectrum(struct device_node *node, bool clk_supplier)
> +{
> + struct clk_spread_spectrum *sscs __free(kfree) = NULL;
> + u32 elem_size = sizeof(struct clk_spread_spectrum);
> + struct of_phandle_args clkspec;
> + int rc, count, index;
> + struct clk *clk;
> +
> + /* modfreq, spreadPercent, modmethod */
> + count = of_property_count_elems_of_size(node, "assigned-clock-sscs", elem_size);
> + if (count <= 0)
> + return 0;
> +
> + sscs = kcalloc(count, elem_size, GFP_KERNEL);
> + if (!sscs)
> + return -ENOMEM;
> +
> + rc = of_property_read_u32_array(node, "assigned-clock-sscs", (u32 *)sscs,
> + count * 3);
> + if (rc)
> + return rc;
> +
> + for (index = 0; index < count; index++) {
> + struct clk_spread_spectrum *conf = &sscs[index];
> + struct clk_hw *hw;
> +
> + if (!conf->modfreq_hz && !conf->spread_bp && !conf->method)
> + continue;
> +
> + rc = of_parse_phandle_with_args(node, "assigned-clocks", "#clock-cells",
> + index, &clkspec);
> + if (rc < 0) {
> + /* skip empty (null) phandles */
> + if (rc == -ENOENT)
> + continue;
> + else
> + return rc;
> + }
> +
> + if (clkspec.np == node && !clk_supplier) {
> + of_node_put(clkspec.np);
> + return 0;
> + }
> +
> + clk = of_clk_get_from_provider(&clkspec);
> + of_node_put(clkspec.np);
> + if (IS_ERR(clk)) {
> + if (PTR_ERR(clk) != -EPROBE_DEFER)
> + pr_warn("clk: couldn't get clock %d for %pOF\n",
> + index, node);
> + return PTR_ERR(clk);
> + }
> +
> + hw = __clk_get_hw(clk);
> + rc = clk_hw_set_spread_spectrum(hw, conf);
> + if (rc < 0)
> + pr_err("clk: couldn't set %s clk spread spectrum %u %u %u: %d\n",
> + __clk_get_name(clk), conf->modfreq_hz, conf->spread_bp,
> + conf->method, rc);
> + clk_put(clk);
> + }
> +
> + return 0;
> +}
> +
> /**
> * of_clk_set_defaults() - parse and set assigned clocks configuration
> * @node: device node to apply clock settings for
> @@ -174,6 +239,10 @@ int of_clk_set_defaults(struct device_node *node, bool clk_supplier)
> if (!node)
> return 0;
>
> + rc = __set_clk_spread_spectrum(node, clk_supplier);
> + if (rc < 0)
> + return rc;
> +
> rc = __set_clk_parents(node, clk_supplier);
> if (rc < 0)
> return rc;
>
Here you are setting the clock's ssc before the setting the parent and
rate, is it possible to move it below setting of parent and rate?
because the ssc is enabled after the parent and rate is set to a clock.
Thanks
Sebin
next prev parent reply other threads:[~2025-10-06 10:44 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-15 8:29 [PATCH v4 0/5] clk: Support spread spectrum and use it in clk-scmi Peng Fan
2025-09-15 8:29 ` [PATCH v4 1/5] dt-bindings: clock: Add spread spectrum definition Peng Fan
2025-09-22 16:02 ` Rob Herring (Arm)
2025-09-15 8:29 ` [PATCH v4 2/5] clk: Introduce clk_hw_set_spread_spectrum Peng Fan
2025-09-21 20:53 ` Stephen Boyd
2025-09-22 2:05 ` Peng Fan
2025-09-15 8:29 ` [PATCH v4 3/5] clk: conf: Support assigned-clock-sscs Peng Fan
2025-10-06 10:44 ` Sebin Francis [this message]
2025-10-08 12:31 ` Peng Fan
2025-09-15 8:29 ` [PATCH v4 4/5] clk: Add KUnit tests for assigned-clock-sscs Peng Fan
2025-09-15 12:29 ` Brian Masney
2025-09-15 8:29 ` [PATCH v4 5/5] clk: scmi: Support Spread Spectrum for NXP i.MX95 Peng Fan
2025-09-23 10:52 ` Sebin Francis
2025-09-23 11:57 ` Peng Fan
2025-09-24 9:25 ` Sebin Francis
2025-09-24 11:43 ` Peng Fan
2025-09-24 12:15 ` Sebin Francis
2025-09-24 12:40 ` Cristian Marussi
2025-09-24 12:59 ` Sudeep Holla
2025-09-24 14:14 ` Peng Fan
2025-09-24 13:13 ` Sudeep Holla
2025-09-24 14:35 ` Peng Fan
2025-09-24 14:44 ` [PATCH v4 0/5] clk: Support spread spectrum and use it in clk-scmi Peng Fan
2025-09-24 15:33 ` Brian Masney
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=98d588bd-7b46-4df4-b31c-2bb53a47c279@ti.com \
--to=sebin.francis@ti.com \
--cc=arm-scmi@vger.kernel.org \
--cc=bmasney@redhat.com \
--cc=conor+dt@kernel.org \
--cc=cristian.marussi@arm.com \
--cc=d-gole@ti.com \
--cc=dan.carpenter@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=geert@linux-m68k.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=m.felsch@pengutronix.de \
--cc=mturquette@baylibre.com \
--cc=peng.fan@nxp.com \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=sudeep.holla@arm.com \
/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