Hi all,
this small series introduces support for the new Clock CONFIG features
added by SCMI v3.2 specification [1].
It does NOT add support, still, for the SCMI v3.2 Clock reparenting
features added in v3.2 too.
After a small refactoring in [1/6], support for the new CONFIG_SET message
format is added in [2/6]: this is just internal rework to support new and
legacy (pre-v3.2) message formats.
Patch [3/6] adds support for the new v3.2 CONFIG_GET command and adds a new
related Clock operation .state_get() to retrieve the enabled state of one
clock when talking to a v3.2 compliant server.
Patch [4/6] extend .state_get() support to legacy SCMI platforms implementing
pre-v3.2 SCMI stacks: in such a scenario we can use the old CLOCK_ATTRIBUTES
command to retrieve the clock state.
Patch [5/6] finally wires up this new .state_get() clock operation to the
Linux Clock framework .is_enabled() callback, AS-LONG-AS the underlying
configured SCMI stack supports atomic operations. (since .is_enabled() is
required not to sleep)
This *should* ease unused clocks management by the Linux Clock framework.
Last but not least, patch [6/6] exposes a couple more SCMI Clock operations
in order to be able to set/get OEM specific clock configuration values as
described in SCMI v3.2 specification; it is marked as RFC since, even
though trivial and tested in emulation, there are really at the moment NO
real users for these new OEM-related clock operations.
Tested on JUNO and on an SCMI emulation setup.
Based on v6.5-rc5.
Any feedback welcome,
Thanks,
Cristian
[1]: https://developer.arm.com/documentation/den0056/e
Cristian Marussi (6):
firmware: arm_scmi: Simplify enable/disable Clock operations
firmware: arm_scmi: Add Clock v3.2 CONFIG_SET support
firmware: arm_scmi: Add v3.2 Clock CONFIG_GET support
firmware: arm_scmi: Add Clock .state_get support to pre-v3.2
clk: scmi: Add support for .is_enabled clk_ops
[RFC] firmware: arm_scmi: Add Clock OEM config clock operations
drivers/clk/clk-scmi.c | 31 ++++-
drivers/firmware/arm_scmi/clock.c | 220 +++++++++++++++++++++++++++---
include/linux/scmi_protocol.h | 19 ++-
3 files changed, 240 insertions(+), 30 deletions(-)
--
2.41.0
Add support for v3.2 Clock CONFIG_GET command and related new clock
protocol operation state_get() to retrieve the status of a clock.
Signed-off-by: Cristian Marussi <[email protected]>
---
drivers/firmware/arm_scmi/clock.c | 64 +++++++++++++++++++++++++++++++
include/linux/scmi_protocol.h | 3 ++
2 files changed, 67 insertions(+)
diff --git a/drivers/firmware/arm_scmi/clock.c b/drivers/firmware/arm_scmi/clock.c
index 63bd043365cd..aaa95624493d 100644
--- a/drivers/firmware/arm_scmi/clock.c
+++ b/drivers/firmware/arm_scmi/clock.c
@@ -21,6 +21,7 @@ enum scmi_clock_protocol_cmd {
CLOCK_NAME_GET = 0x8,
CLOCK_RATE_NOTIFY = 0x9,
CLOCK_RATE_CHANGE_REQUESTED_NOTIFY = 0xA,
+ CLOCK_CONFIG_GET = 0xB,
};
enum clk_state {
@@ -59,6 +60,19 @@ struct scmi_msg_clock_config_set_v21 {
__le32 oem_config_val;
};
+struct scmi_msg_clock_config_get {
+ __le32 id;
+ __le32 flags;
+#define REGMASK_OEM_TYPE_GET GENMASK(7, 0)
+};
+
+struct scmi_msg_resp_clock_config_get {
+ __le32 attributes;
+ __le32 config;
+#define IS_CLK_ENABLED(x) le32_get_bits((x), BIT(0))
+ __le32 oem_config_val;
+};
+
struct scmi_msg_clock_describe_rates {
__le32 id;
__le32 rate_index;
@@ -496,6 +510,55 @@ static int scmi_clock_disable(const struct scmi_protocol_handle *ph, u32 clk_id,
NULL_OEM_TYPE, 0, atomic);
}
+static int
+scmi_clock_config_get(const struct scmi_protocol_handle *ph, u32 clk_id,
+ u8 oem_type, u32 *attributes, bool *enabled,
+ u32 *oem_val, bool atomic)
+{
+ int ret;
+ u32 flags;
+ struct scmi_xfer *t;
+ struct scmi_msg_clock_config_get *cfg;
+
+ ret = ph->xops->xfer_get_init(ph, CLOCK_CONFIG_GET,
+ sizeof(*cfg), 0, &t);
+ if (ret)
+ return ret;
+
+ t->hdr.poll_completion = atomic;
+
+ flags = FIELD_PREP(REGMASK_OEM_TYPE_GET, oem_type);
+
+ cfg = t->tx.buf;
+ cfg->id = cpu_to_le32(clk_id);
+ cfg->flags = cpu_to_le32(flags);
+
+ ret = ph->xops->do_xfer(ph, t);
+ if (!ret) {
+ struct scmi_msg_resp_clock_config_get *resp = t->rx.buf;
+
+ if (attributes)
+ *attributes = le32_to_cpu(resp->attributes);
+
+ if (enabled)
+ *enabled = IS_CLK_ENABLED(resp->config);
+
+ if (oem_val && oem_type)
+ *oem_val = le32_to_cpu(resp->oem_config_val);
+ }
+
+ ph->xops->xfer_put(ph, t);
+
+ return ret;
+}
+
+static int scmi_clock_state_get(const struct scmi_protocol_handle *ph,
+ u32 clk_id, bool *enabled, bool atomic)
+{
+ return scmi_clock_config_get(ph, clk_id, NULL_OEM_TYPE, NULL,
+ enabled, NULL, atomic);
+}
+
static int scmi_clock_count_get(const struct scmi_protocol_handle *ph)
{
struct clock_info *ci = ph->get_priv(ph);
@@ -526,6 +589,7 @@ static const struct scmi_clk_proto_ops clk_proto_ops = {
.rate_set = scmi_clock_rate_set,
.enable = scmi_clock_enable,
.disable = scmi_clock_disable,
+ .state_get = scmi_clock_state_get,
};
static int scmi_clk_rate_notify(const struct scmi_protocol_handle *ph,
diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
index b4c631a8d0ac..d11ca4286d57 100644
--- a/include/linux/scmi_protocol.h
+++ b/include/linux/scmi_protocol.h
@@ -80,6 +80,7 @@ struct scmi_protocol_handle;
* @rate_set: set the clock rate of a clock
* @enable: enables the specified clock
* @disable: disables the specified clock
+ * @state_get: get the status of the specified clock
*/
struct scmi_clk_proto_ops {
int (*count_get)(const struct scmi_protocol_handle *ph);
@@ -94,6 +95,8 @@ struct scmi_clk_proto_ops {
bool atomic);
int (*disable)(const struct scmi_protocol_handle *ph, u32 clk_id,
bool atomic);
+ int (*state_get)(const struct scmi_protocol_handle *ph, u32 clk_id,
+ bool *enabled, bool atomic);
};
/**
--
2.41.0