Commit e4ad2b01 authored by Cristian Marussi's avatar Cristian Marussi Committed by Sudeep Holla

firmware: arm_scmi: Add clock check for extended config support

SCMI v3.2 added support to set/get clock custom OEM types; such support is
conditionally present, though, depending on an extended config attribute
bit possibly advertised by the platform server on a per-domain base.

Add a check to verify if OEM types are supported before allowing any kind
of OEM-specific get/set operation. Also add a check around all the new
v3.2 clock features.
Signed-off-by: default avatarCristian Marussi <cristian.marussi@arm.com>
Link: https://lore.kernel.org/r/20240214183006.3403207-4-cristian.marussi@arm.comSigned-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
parent 8c80c42a
...@@ -54,6 +54,7 @@ struct scmi_msg_resp_clock_attributes { ...@@ -54,6 +54,7 @@ struct scmi_msg_resp_clock_attributes {
#define SUPPORTS_RATE_CHANGE_REQUESTED_NOTIF(x) ((x) & BIT(30)) #define SUPPORTS_RATE_CHANGE_REQUESTED_NOTIF(x) ((x) & BIT(30))
#define SUPPORTS_EXTENDED_NAMES(x) ((x) & BIT(29)) #define SUPPORTS_EXTENDED_NAMES(x) ((x) & BIT(29))
#define SUPPORTS_PARENT_CLOCK(x) ((x) & BIT(28)) #define SUPPORTS_PARENT_CLOCK(x) ((x) & BIT(28))
#define SUPPORTS_EXTENDED_CONFIG(x) ((x) & BIT(27))
#define SUPPORTS_GET_PERMISSIONS(x) ((x) & BIT(1)) #define SUPPORTS_GET_PERMISSIONS(x) ((x) & BIT(1))
u8 name[SCMI_SHORT_NAME_MAX_SIZE]; u8 name[SCMI_SHORT_NAME_MAX_SIZE];
__le32 clock_enable_latency; __le32 clock_enable_latency;
...@@ -388,10 +389,14 @@ static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph, ...@@ -388,10 +389,14 @@ static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph,
if (cinfo->notify_rate_change_requested_cmd && if (cinfo->notify_rate_change_requested_cmd &&
SUPPORTS_RATE_CHANGE_REQUESTED_NOTIF(attributes)) SUPPORTS_RATE_CHANGE_REQUESTED_NOTIF(attributes))
clk->rate_change_requested_notifications = true; clk->rate_change_requested_notifications = true;
if (SUPPORTS_PARENT_CLOCK(attributes)) if (PROTOCOL_REV_MAJOR(version) >= 0x3) {
scmi_clock_possible_parents(ph, clk_id, clk); if (SUPPORTS_PARENT_CLOCK(attributes))
if (SUPPORTS_GET_PERMISSIONS(attributes)) scmi_clock_possible_parents(ph, clk_id, clk);
scmi_clock_get_permissions(ph, clk_id, clk); if (SUPPORTS_GET_PERMISSIONS(attributes))
scmi_clock_get_permissions(ph, clk_id, clk);
if (SUPPORTS_EXTENDED_CONFIG(attributes))
clk->extended_config = true;
}
} }
return ret; return ret;
...@@ -700,7 +705,7 @@ scmi_clock_get_parent(const struct scmi_protocol_handle *ph, u32 clk_id, ...@@ -700,7 +705,7 @@ scmi_clock_get_parent(const struct scmi_protocol_handle *ph, u32 clk_id,
return ret; return ret;
} }
/* For SCMI clock v2.1 and onwards */ /* For SCMI clock v3.0 and onwards */
static int static int
scmi_clock_config_set_v2(const struct scmi_protocol_handle *ph, u32 clk_id, scmi_clock_config_set_v2(const struct scmi_protocol_handle *ph, u32 clk_id,
enum clk_state state, u8 oem_type, u32 oem_val, enum clk_state state, u8 oem_type, u32 oem_val,
...@@ -773,7 +778,7 @@ static int scmi_clock_disable(const struct scmi_protocol_handle *ph, u32 clk_id, ...@@ -773,7 +778,7 @@ static int scmi_clock_disable(const struct scmi_protocol_handle *ph, u32 clk_id,
NULL_OEM_TYPE, 0, atomic); NULL_OEM_TYPE, 0, atomic);
} }
/* For SCMI clock v2.1 and onwards */ /* For SCMI clock v3.0 and onwards */
static int static int
scmi_clock_config_get_v2(const struct scmi_protocol_handle *ph, u32 clk_id, scmi_clock_config_get_v2(const struct scmi_protocol_handle *ph, u32 clk_id,
u8 oem_type, u32 *attributes, bool *enabled, u8 oem_type, u32 *attributes, bool *enabled,
...@@ -860,6 +865,14 @@ static int scmi_clock_config_oem_set(const struct scmi_protocol_handle *ph, ...@@ -860,6 +865,14 @@ static int scmi_clock_config_oem_set(const struct scmi_protocol_handle *ph,
bool atomic) bool atomic)
{ {
struct clock_info *ci = ph->get_priv(ph); struct clock_info *ci = ph->get_priv(ph);
struct scmi_clock_info *clk;
clk = scmi_clock_domain_lookup(ci, clk_id);
if (IS_ERR(clk))
return PTR_ERR(clk);
if (!clk->extended_config)
return -EOPNOTSUPP;
return ci->clock_config_set(ph, clk_id, CLK_STATE_UNCHANGED, return ci->clock_config_set(ph, clk_id, CLK_STATE_UNCHANGED,
oem_type, oem_val, atomic); oem_type, oem_val, atomic);
...@@ -870,6 +883,14 @@ static int scmi_clock_config_oem_get(const struct scmi_protocol_handle *ph, ...@@ -870,6 +883,14 @@ static int scmi_clock_config_oem_get(const struct scmi_protocol_handle *ph,
u32 *attributes, bool atomic) u32 *attributes, bool atomic)
{ {
struct clock_info *ci = ph->get_priv(ph); struct clock_info *ci = ph->get_priv(ph);
struct scmi_clock_info *clk;
clk = scmi_clock_domain_lookup(ci, clk_id);
if (IS_ERR(clk))
return PTR_ERR(clk);
if (!clk->extended_config)
return -EOPNOTSUPP;
return ci->clock_config_get(ph, clk_id, oem_type, attributes, return ci->clock_config_get(ph, clk_id, oem_type, attributes,
NULL, oem_val, atomic); NULL, oem_val, atomic);
......
...@@ -50,6 +50,7 @@ struct scmi_clock_info { ...@@ -50,6 +50,7 @@ struct scmi_clock_info {
bool state_ctrl_forbidden; bool state_ctrl_forbidden;
bool rate_ctrl_forbidden; bool rate_ctrl_forbidden;
bool parent_ctrl_forbidden; bool parent_ctrl_forbidden;
bool extended_config;
union { union {
struct { struct {
int num_rates; int num_rates;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment