From: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
To: Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Russell King <linux@armlinux.org.uk>,
Sudeep Holla <sudeep.holla@arm.com>,
Cristian Marussi <cristian.marussi@arm.com>
Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk@kernel.org>,
Dario Binacchi <dario.binacchi@amarulasolutions.com>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
imx@lists.linux.dev, Peng Fan <peng.fan@nxp.com>
Subject: [PATCH 3/3] clk: scmi: Support spread spectrum
Date: Fri, 24 Jan 2025 22:25:19 +0800 [thread overview]
Message-ID: <20250124-clk-ssc-v1-3-2d39f6baf2af@nxp.com> (raw)
In-Reply-To: <20250124-clk-ssc-v1-0-2d39f6baf2af@nxp.com>
From: Peng Fan <peng.fan@nxp.com>
Support Spread Spectrum for i.MX95 with adding
scmi_clk_set_spread_spectrum_imx
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/clk/clk-scmi.c | 37 +++++++++++++++++++++++++++++++++++++
include/linux/scmi_protocol.h | 5 +++++
2 files changed, 42 insertions(+)
diff --git a/drivers/clk/clk-scmi.c b/drivers/clk/clk-scmi.c
index 15510c2ff21c0335f5cb30677343bd4ef59c0738..e43902aea6bee3633f8328acddcf54eef907b640 100644
--- a/drivers/clk/clk-scmi.c
+++ b/drivers/clk/clk-scmi.c
@@ -98,6 +98,35 @@ static int scmi_clk_set_parent(struct clk_hw *hw, u8 parent_index)
return scmi_proto_clk_ops->parent_set(clk->ph, clk->id, parent_index);
}
+static int scmi_clk_set_spread_spectrum_imx(struct clk_hw *hw,
+ struct clk_spread_spectrum *clk_ss)
+{
+ struct scmi_clk *clk = to_scmi_clk(hw);
+ int ret;
+ u32 val;
+
+ /* SCMI OEM Duty Cycle is expressed as a percentage */
+ /*
+ * extConfigValue[7:0] - spread percentage (%)
+ * extConfigValue[23:8] - Modulation Frequency (KHz)
+ * extConfigValue[24] - Enable/Disable
+ * extConfigValue[31:25] - Reserved
+ */
+ val = FIELD_PREP(IMX_CLOCK_EXT_SS_PERCENTAGE_MASK, clk_ss->spreadpercent);
+ val |= FIELD_PREP(IMX_CLOCK_EXT_SS_MOD_FREQ_MASK, clk_ss->modfreq);
+ val |= IMX_CLOCK_EXT_SS_ENABLE_MASK;
+ ret = scmi_proto_clk_ops->config_oem_set(clk->ph, clk->id,
+ SCMI_CLOCK_CFG_NXP_IMX_SSC,
+ val, false);
+ if (ret)
+ dev_warn(clk->dev,
+ "Failed to set spread spectrum(%u,%u,%u) for clock ID %d\n",
+ clk_ss->modfreq, clk_ss->spreadpercent, clk_ss->method,
+ clk->id);
+
+ return ret;
+}
+
static u8 scmi_clk_get_parent(struct clk_hw *hw)
{
struct scmi_clk *clk = to_scmi_clk(hw);
@@ -266,6 +295,11 @@ static int scmi_clk_ops_init(struct device *dev, struct scmi_clk *sclk,
* Return: A pointer to the allocated and configured clk_ops on success,
* or NULL on allocation failure.
*/
+static const char * const scmi_clk_ssc_allowlist[] = {
+ "fsl,imx95",
+ NULL
+};
+
static const struct clk_ops *
scmi_clk_ops_alloc(struct device *dev, unsigned long feats_key)
{
@@ -316,6 +350,9 @@ scmi_clk_ops_alloc(struct device *dev, unsigned long feats_key)
ops->set_duty_cycle = scmi_clk_set_duty_cycle;
}
+ if (of_machine_compatible_match(scmi_clk_ssc_allowlist))
+ ops->set_spread_spectrum = scmi_clk_set_spread_spectrum_imx;
+
return ops;
}
diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
index 688466a0e816247d24704f7ba109667a14226b67..7012d5efef00eb7b52f17d0f3d8d69f3d0063557 100644
--- a/include/linux/scmi_protocol.h
+++ b/include/linux/scmi_protocol.h
@@ -80,9 +80,14 @@ enum scmi_clock_oem_config {
SCMI_CLOCK_CFG_DUTY_CYCLE = 0x1,
SCMI_CLOCK_CFG_PHASE,
SCMI_CLOCK_CFG_OEM_START = 0x80,
+ SCMI_CLOCK_CFG_NXP_IMX_SSC = 0x80,
SCMI_CLOCK_CFG_OEM_END = 0xFF,
};
+#define IMX_CLOCK_EXT_SS_PERCENTAGE_MASK GENMASK(7, 0)
+#define IMX_CLOCK_EXT_SS_MOD_FREQ_MASK GENMASK(23, 8)
+#define IMX_CLOCK_EXT_SS_ENABLE_MASK BIT(24)
+
/**
* struct scmi_clk_proto_ops - represents the various operations provided
* by SCMI Clock Protocol
--
2.35.3
next prev parent reply other threads:[~2025-01-24 13:19 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-24 14:25 [PATCH 0/3] clk: Support spread spectrum and use it in clk-scmi Peng Fan (OSS)
2025-01-24 14:25 ` [PATCH 1/3] clk: Introduce clk_set_spread_spectrum Peng Fan (OSS)
2025-01-24 13:51 ` Dan Carpenter
2025-01-28 20:25 ` Stephen Boyd
2025-02-02 10:42 ` Peng Fan
2025-02-03 9:43 ` Cristian Marussi
2025-02-03 11:47 ` Peng Fan
2025-02-03 11:22 ` Cristian Marussi
2025-02-04 0:31 ` Peng Fan
2025-01-24 14:25 ` [PATCH 2/3] clk: conf: Support assigned-clock-sscs Peng Fan (OSS)
2025-01-24 14:25 ` Peng Fan (OSS) [this message]
2025-01-24 21:33 ` [PATCH 3/3] clk: scmi: Support spread spectrum kernel test robot
2025-01-28 12:07 ` Cristian Marussi
2025-01-25 12:58 ` [PATCH 0/3] clk: Support spread spectrum and use it in clk-scmi Dario Binacchi
2025-01-27 7:42 ` Krzysztof Kozlowski
2025-01-27 7:59 ` Dario Binacchi
2025-01-27 8:31 ` Krzysztof Kozlowski
2025-01-27 8:35 ` Dario Binacchi
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=20250124-clk-ssc-v1-3-2d39f6baf2af@nxp.com \
--to=peng.fan@oss.nxp.com \
--cc=arm-scmi@vger.kernel.org \
--cc=cristian.marussi@arm.com \
--cc=dario.binacchi@amarulasolutions.com \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=krzk@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mturquette@baylibre.com \
--cc=peng.fan@nxp.com \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=sboyd@kernel.org \
--cc=shawnguo@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