From: Brian Masney <bmasney@redhat.com>
To: Peng Fan <peng.fan@nxp.com>
Cc: 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>,
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
Subject: Re: [PATCH v2 1/3] clk: Introduce clk_hw_set_spread_spectrum
Date: Tue, 2 Sep 2025 18:01:12 -0400 [thread overview]
Message-ID: <aLdpKEwfqP448eMd@x1> (raw)
In-Reply-To: <20250901-clk-ssc-version1-v2-1-1d0a486dffe6@nxp.com>
On Mon, Sep 01, 2025 at 11:51:45AM +0800, Peng Fan wrote:
> Add clk_hw_set_spread_spectrum to configure a clock to enable spread
> spectrum feature. set_spread_spectrum ops is added for clk drivers to
> have their own hardware specific implementation.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/clk/clk.c | 26 ++++++++++++++++++++++++++
> include/linux/clk-provider.h | 26 ++++++++++++++++++++++++++
> 2 files changed, 52 insertions(+)
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index b821b2cdb155331c85fafbd2fac8ab3703a08e4d..06db8918a1b35e3280e565272bc4603a88295a92 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -2802,6 +2802,32 @@ int clk_set_max_rate(struct clk *clk, unsigned long rate)
> }
> EXPORT_SYMBOL_GPL(clk_set_max_rate);
>
> +int clk_hw_set_spread_spectrum(struct clk_hw *hw, struct clk_spread_spectrum *conf)
> +{
> + struct clk_core *core;
> + int ret;
> +
> + if (!hw)
> + return 0;
> +
> + core = hw->core;
> +
> + clk_prepare_lock();
> +
> + ret = clk_pm_runtime_get(core);
> + if (ret)
> + goto fail;
> +
> + if (core->ops->set_spread_spectrum)
> + ret = core->ops->set_spread_spectrum(hw, conf);
> +
> + clk_pm_runtime_put(core);
> +
> +fail:
> + clk_prepare_unlock();
> + return ret;
> +}
> +
> /**
> * clk_get_parent - return the parent of a clk
> * @clk: the clk whose parent gets returned
> diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
> index 630705a47129453c241f1b1755f2c2f2a7ed8f77..251035a96244c34ff2cbaaa349a08f4ea094e7fc 100644
> --- a/include/linux/clk-provider.h
> +++ b/include/linux/clk-provider.h
> @@ -84,6 +84,24 @@ struct clk_duty {
> unsigned int den;
> };
>
> +#define CLK_SSC_NO_SPREAD 0
> +#define CLK_SSC_CENTER_SPREAD 1
> +#define CLK_SSC_UP_SPREAD 2
> +#define CLK_SSC_DOWN_SPREAD 3
> +
> +/**
> + * struct clk_spread_spectrum - Structure encoding spread spectrum of a clock
> + *
> + * @modfreq_hz: Modulation frequency
> + * @spread_bp: Modulation percent in permyriad
> + * @method: Modulation method
> + */
> +struct clk_spread_spectrum {
> + u32 modfreq_hz;
> + u32 spread_bp;
> + u32 method;
> +};
> +
> /**
> * struct clk_ops - Callback operations for hardware clocks; these are to
> * be provided by the clock implementation, and will be called by drivers
> @@ -178,6 +196,11 @@ struct clk_duty {
> * separately via calls to .set_parent and .set_rate.
> * Returns 0 on success, -EERROR otherwise.
> *
> + * @set_spread_spectrum: Configure the modulation frequency, modulation percentage
> + * and method. This callback is optional for clocks that does not
> + * support spread spectrum feature or no need to enable this feature.
> + * Returns 0 on success, -EERROR otherwise.
I think it would be worthwhile to call out in the kdocs that this helps
to reduce EMI. How does this sound?
@set_spread_spectrum: Optional callback used to configure the spread
spectrum modulation frequency, percentage, and method
to reduce EMI by spreading the clock frequency over a
wider range.
Returns 0 on success, -EERROR otherwise.
Everything else looks good to me.
Brian
next prev parent reply other threads:[~2025-09-02 22:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-01 3:51 [PATCH v2 0/3] clk: Support spread spectrum and use it in clk-scmi Peng Fan
2025-09-01 3:51 ` [PATCH v2 1/3] clk: Introduce clk_hw_set_spread_spectrum Peng Fan
2025-09-02 22:01 ` Brian Masney [this message]
2025-09-07 13:04 ` Peng Fan
2025-09-01 3:51 ` [PATCH v2 2/3] clk: conf: Support assigned-clock-sscs Peng Fan
2025-09-02 21:49 ` Brian Masney
2025-09-09 8:50 ` Peng Fan
2025-09-09 9:39 ` Brian Masney
2025-09-02 23:56 ` Brian Masney
2025-09-07 13:12 ` Peng Fan
2025-09-01 3:51 ` [PATCH v2 3/3] clk: scmi: Support Spread Spectrum for NXP i.MX95 Peng Fan
2025-09-07 13:19 ` Peng Fan
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=aLdpKEwfqP448eMd@x1 \
--to=bmasney@redhat.com \
--cc=arm-scmi@vger.kernel.org \
--cc=cristian.marussi@arm.com \
--cc=dan.carpenter@linaro.org \
--cc=geert@linux-m68k.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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.