Arm SCMI updates for v7.0

A set of cleanups, refactoring, and fixes to the Arm SCMI stack:
 
 1. Rework protocol version negotiation by moving version discovery and
    downgrade handling into the SCMI core and performing negotiation early,
    before protocol initialization. Remove legacy per-protocol versioning
    logic now made redundant by centralized SCMI handling.
 
 2. Increase the internal MAX_OPPS limit in the SCMI performance protocol
    to 64, allowing platforms with larger OPP tables to be fully supported.
 
 3. Reduce duplicated boilerplate in pinctrl and related protocols by
    consolidating validation and lookup logic in protocol get info helpers.
 
 4. Refactor reset protocol domain handling by introducing a shared lookup
    helper, ensuring consistent validation and error reporting.
 
 5. Fix potential undefined behaviour by properly initializing pointers
    annotated with the __free attribute.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEunHlEgbzHrJD3ZPhAEG6vDF+4pgFAmlk3lYACgkQAEG6vDF+
 4pj2WhAAr3tJz05oUqHs75yJ92jr+wp7i1hymgsHOy46DHv+M3BjKg6cQ36S3ZaS
 QBNZB4wDYB5mkxRjFtQtJbtGkDI7guCj4Oje7oFFQnf25VEqlwNGHUqNUdE4CHGp
 g4HqbAzdtCQrOp4u9DFAdP63Sl0Dbo9qaa0i/RdxVAXN2Pylpe2NnlX5006cEgiZ
 d8wBjLoGOn3bhtn0ETaPzfAvBZWPOLqAFf16wNJPR5uPS/PFGflCRdwTtdLBjA5v
 5vEc0nZ993PDnCOMTom0BnccHdKyw8CZXnP5UMeXfjLxm9mrUeVCJKrsZeJkfKhH
 5MgEhRlmisxbtlLLPbS0sEOPklYrFlMvsJT+NjfnFQL3E4xuBDyJztHlLxqdUXrr
 KIuYYaTsUSGnDOE3MV7lD+y+4AzH/7pjk501h69ZbCwXRKzTNnVKwBcIe5gSoH8O
 KE9Qp1KANxGUF8Px3xHTHwKe8oXiVPsPECZCA0Ldaal6Zs5P+ncHITPNS6BZ0I3f
 PNZIUr7BBJs4828jXSOnaXBTannGVZKWy8BUVtm6hcWFiAoz6n588jsQL1Vi8ku4
 7l/vn2QH4QWrHSp9yZ4UwuizNLkiQu4ES5oCxmH9hH8EHeNIjiGGJ1oRVVOe6Wos
 FGfvRDwrE0++4jz1ErvF3p4jUVSauD9R3fjewO7/IWeA1dIzWoc=
 =ueRY
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmlw7zcACgkQmmx57+YA
 GNnTTBAAm1uDSAwVQoat9Hz7fzaB47ll2h/5voIOP0O9m+MLDExZUuDP9O+PUt2K
 IDXVkp1T3jiSY9HUV3bxzYGrrndaseT+pQvd5ujRHI2kRIjo3qJY2RJjKhpjLhfj
 vhehpr6S9+E0fylSVSECAu4HtaOW4IXRS2yim5YJQCDuxADQouc1KGToWyYoJP0V
 X6XU3shZKY+UBaw6pr73e3eph8Qi0Y0QsrYrqi3X9Mg2cP5hT/ClQUqBTMNjZp/O
 fiGo7Bh1hGRzBdfpu8h473SihIosYYALGx0fVqueOzO9iYb7dkZJ6EQQf+S0yA0E
 Co1BEKJcdXLRy2TBXV0akcFWo3Qs+ZJUeB59OPnAy6kT/jIpx0BPnj/uQSTRm0mV
 XdO0M1r3j/GvRtbyZhCfdRppTpTaQLRhzR6CBxhfW1rxxPtyZKu/vQ+es0/eh7bu
 db466zZIK/CIfKksoo2i8ruqyFmEAoC5QTKWunfq9R6ulFaQLMj8rIjcC2B7CAb4
 l3+csKgMW+ZQG0acuqSybEuIp9TBsm6caWuSXwEZZFFcvXk5BDdSkD5Mv0Bbynqv
 aZf3JCN0ePLBUgP6VpiSpNkHCpomxzB1qcoRhqMjXb1zPolixg9GZuNRpYYeiOOZ
 r4O6zcc2/cjP97XiZ9rpIBmL72VzKyd8QZsexKuvrhkF29KbIRg=
 =rTFA
 -----END PGP SIGNATURE-----

Merge tag 'scmi-updates-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into soc/drivers

Arm SCMI updates for v7.0

A set of cleanups, refactoring, and fixes to the Arm SCMI stack:

1. Rework protocol version negotiation by moving version discovery and
   downgrade handling into the SCMI core and performing negotiation early,
   before protocol initialization. Remove legacy per-protocol versioning
   logic now made redundant by centralized SCMI handling.

2. Increase the internal MAX_OPPS limit in the SCMI performance protocol
   to 64, allowing platforms with larger OPP tables to be fully supported.

3. Reduce duplicated boilerplate in pinctrl and related protocols by
   consolidating validation and lookup logic in protocol get info helpers.

4. Refactor reset protocol domain handling by introducing a shared lookup
   helper, ensuring consistent validation and error reporting.

5. Fix potential undefined behaviour by properly initializing pointers
   annotated with the __free attribute.

* tag 'scmi-updates-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux:
  firmware: arm_scmi: Remove legacy protocol versioning logic
  firmware: arm_scmi: Rework protocol version negotiation logic
  firmware: arm_scmi: Increase performance MAX_OPPS limit to 64
  firmware: arm_scmi: Move boiler plate code into the get info functions
  firmware: arm_scmi: Refactor reset domain handling
  firmware: arm_scmi: Fix uninitialized pointers with __free attr

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
Arnd Bergmann 2026-01-21 16:22:21 +01:00
commit 34f60ff256
17 changed files with 238 additions and 282 deletions

View File

@ -375,18 +375,13 @@ static int scmi_base_protocol_init(const struct scmi_protocol_handle *ph)
{
int id, ret;
u8 *prot_imp;
u32 version;
char name[SCMI_SHORT_NAME_MAX_SIZE];
struct device *dev = ph->dev;
struct scmi_revision_info *rev = scmi_revision_area_get(ph);
ret = ph->xops->version_get(ph, &version);
if (ret)
return ret;
rev->major_ver = PROTOCOL_REV_MAJOR(version);
rev->minor_ver = PROTOCOL_REV_MINOR(version);
ph->set_priv(ph, rev, version);
rev->major_ver = PROTOCOL_REV_MAJOR(ph->version);
rev->minor_ver = PROTOCOL_REV_MINOR(ph->version);
ph->set_priv(ph, rev);
ret = scmi_base_attributes_get(ph);
if (ret)

View File

@ -157,7 +157,6 @@ struct scmi_clock_rate_notify_payld {
};
struct clock_info {
u32 version;
int num_clocks;
int max_async_req;
bool notify_rate_changed_cmd;
@ -346,8 +345,7 @@ scmi_clock_get_permissions(const struct scmi_protocol_handle *ph, u32 clk_id,
}
static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph,
u32 clk_id, struct clock_info *cinfo,
u32 version)
u32 clk_id, struct clock_info *cinfo)
{
int ret;
u32 attributes;
@ -370,7 +368,7 @@ static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph,
attributes = le32_to_cpu(attr->attributes);
strscpy(clk->name, attr->name, SCMI_SHORT_NAME_MAX_SIZE);
/* clock_enable_latency field is present only since SCMI v3.1 */
if (PROTOCOL_REV_MAJOR(version) >= 0x2)
if (PROTOCOL_REV_MAJOR(ph->version) >= 0x2)
latency = le32_to_cpu(attr->clock_enable_latency);
clk->enable_latency = latency ? : U32_MAX;
}
@ -381,7 +379,7 @@ static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph,
* If supported overwrite short name with the extended one;
* on error just carry on and use already provided short name.
*/
if (!ret && PROTOCOL_REV_MAJOR(version) >= 0x2) {
if (!ret && PROTOCOL_REV_MAJOR(ph->version) >= 0x2) {
if (SUPPORTS_EXTENDED_NAMES(attributes))
ph->hops->extended_name_get(ph, CLOCK_NAME_GET, clk_id,
NULL, clk->name,
@ -393,7 +391,7 @@ static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph,
if (cinfo->notify_rate_change_requested_cmd &&
SUPPORTS_RATE_CHANGE_REQUESTED_NOTIF(attributes))
clk->rate_change_requested_notifications = true;
if (PROTOCOL_REV_MAJOR(version) >= 0x3) {
if (PROTOCOL_REV_MAJOR(ph->version) >= 0x3) {
if (SUPPORTS_PARENT_CLOCK(attributes))
scmi_clock_possible_parents(ph, clk_id, clk);
if (SUPPORTS_GET_PERMISSIONS(attributes))
@ -1068,16 +1066,11 @@ static const struct scmi_protocol_events clk_protocol_events = {
static int scmi_clock_protocol_init(const struct scmi_protocol_handle *ph)
{
u32 version;
int clkid, ret;
struct clock_info *cinfo;
ret = ph->xops->version_get(ph, &version);
if (ret)
return ret;
dev_dbg(ph->dev, "Clock Version %d.%d\n",
PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version));
PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version));
cinfo = devm_kzalloc(ph->dev, sizeof(*cinfo), GFP_KERNEL);
if (!cinfo)
@ -1095,12 +1088,12 @@ static int scmi_clock_protocol_init(const struct scmi_protocol_handle *ph)
for (clkid = 0; clkid < cinfo->num_clocks; clkid++) {
struct scmi_clock_info *clk = cinfo->clk + clkid;
ret = scmi_clock_attributes_get(ph, clkid, cinfo, version);
ret = scmi_clock_attributes_get(ph, clkid, cinfo);
if (!ret)
scmi_clock_describe_rates_get(ph, clkid, clk);
}
if (PROTOCOL_REV_MAJOR(version) >= 0x3) {
if (PROTOCOL_REV_MAJOR(ph->version) >= 0x3) {
cinfo->clock_config_set = scmi_clock_config_set_v2;
cinfo->clock_config_get = scmi_clock_config_get_v2;
} else {
@ -1108,8 +1101,7 @@ static int scmi_clock_protocol_init(const struct scmi_protocol_handle *ph)
cinfo->clock_config_get = scmi_clock_config_get;
}
cinfo->version = version;
return ph->set_priv(ph, cinfo, version);
return ph->set_priv(ph, cinfo);
}
static const struct scmi_protocol scmi_clock = {

View File

@ -1627,17 +1627,15 @@ static int version_get(const struct scmi_protocol_handle *ph, u32 *version)
*
* @ph: A reference to the protocol handle.
* @priv: The private data to set.
* @version: The detected protocol version for the core to register.
*
* Return: 0 on Success
*/
static int scmi_set_protocol_priv(const struct scmi_protocol_handle *ph,
void *priv, u32 version)
void *priv)
{
struct scmi_protocol_instance *pi = ph_to_pi(ph);
pi->priv = priv;
pi->version = version;
return 0;
}
@ -1657,7 +1655,6 @@ static void *scmi_get_protocol_priv(const struct scmi_protocol_handle *ph)
}
static const struct scmi_xfer_ops xfer_ops = {
.version_get = version_get,
.xfer_get_init = xfer_get_init,
.reset_rx_to_maxsz = reset_rx_to_maxsz,
.do_xfer = do_xfer,
@ -2112,6 +2109,76 @@ static int scmi_protocol_version_negotiate(struct scmi_protocol_handle *ph)
return ret;
}
/**
* scmi_protocol_version_initialize - Initialize protocol version
* @dev: A device reference.
* @pi: A reference to the protocol instance being initialized
*
* At first retrieve the newest protocol version supported by the platform for
* this specific protoocol.
*
* Negotiation is attempted only when the platform advertised a protocol
* version newer than the most recent version known to this agent, since
* backward compatibility is NOT assured in general between versions.
*
* Failing to negotiate a fallback version or to query supported version at
* all will result in an attempt to use the newest version known to this agent
* even though compatibility is NOT assured.
*
* Versions are defined as:
*
* pi->version: the version supported by the platform as returned by the query.
* pi->proto->supported_version: the newest version supported by this agent
* for this protocol.
* pi->negotiated_version: The version successfully negotiated with the platform.
* ph->version: The final version effectively chosen for this session.
*/
static void scmi_protocol_version_initialize(struct device *dev,
struct scmi_protocol_instance *pi)
{
struct scmi_protocol_handle *ph = &pi->ph;
int ret;
/*
* Query and store platform supported protocol version: this is usually
* the newest version the platfom can support.
*/
ret = version_get(ph, &pi->version);
if (ret) {
dev_warn(dev,
"Failed to query supported version for protocol 0x%X.\n",
pi->proto->id);
goto best_effort;
}
/* Need to negotiate at all ? */
if (pi->version <= pi->proto->supported_version) {
ph->version = pi->version;
return;
}
/* Attempt negotiation */
ret = scmi_protocol_version_negotiate(ph);
if (!ret) {
ph->version = pi->negotiated_version;
dev_info(dev,
"Protocol 0x%X successfully negotiated version 0x%X\n",
pi->proto->id, ph->version);
return;
}
dev_warn(dev,
"Detected UNSUPPORTED higher version 0x%X for protocol 0x%X.\n",
pi->version, pi->proto->id);
best_effort:
/* Fallback to use newest version known to this agent */
ph->version = pi->proto->supported_version;
dev_warn(dev,
"Trying version 0x%X. Backward compatibility is NOT assured.\n",
ph->version);
}
/**
* scmi_alloc_init_protocol_instance - Allocate and initialize a protocol
* instance descriptor.
@ -2157,6 +2224,13 @@ scmi_alloc_init_protocol_instance(struct scmi_info *info,
pi->ph.set_priv = scmi_set_protocol_priv;
pi->ph.get_priv = scmi_get_protocol_priv;
refcount_set(&pi->users, 1);
/*
* Initialize effectively used protocol version performing any
* possibly needed negotiations.
*/
scmi_protocol_version_initialize(handle->dev, pi);
/* proto->init is assured NON NULL by scmi_protocol_register */
ret = pi->proto->instance_init(&pi->ph);
if (ret)
@ -2184,22 +2258,6 @@ scmi_alloc_init_protocol_instance(struct scmi_info *info,
devres_close_group(handle->dev, pi->gid);
dev_dbg(handle->dev, "Initialized protocol: 0x%X\n", pi->proto->id);
if (pi->version > proto->supported_version) {
ret = scmi_protocol_version_negotiate(&pi->ph);
if (!ret) {
dev_info(handle->dev,
"Protocol 0x%X successfully negotiated version 0x%X\n",
proto->id, pi->negotiated_version);
} else {
dev_warn(handle->dev,
"Detected UNSUPPORTED higher version 0x%X for protocol 0x%X.\n",
pi->version, pi->proto->id);
dev_warn(handle->dev,
"Trying version 0x%X. Backward compatibility is NOT assured.\n",
pi->proto->supported_version);
}
}
return pi;
clean:

View File

@ -27,7 +27,7 @@
/* Updated only after ALL the mandatory features for that version are merged */
#define SCMI_PROTOCOL_SUPPORTED_VERSION 0x40000
#define MAX_OPPS 32
#define MAX_OPPS 64
enum scmi_performance_protocol_cmd {
PERF_DOMAIN_ATTRIBUTES = 0x3,
@ -178,7 +178,6 @@ struct perf_dom_info {
})
struct scmi_perf_info {
u32 version;
u16 num_domains;
enum scmi_power_scale power_scale;
u64 stats_addr;
@ -215,7 +214,7 @@ static int scmi_perf_attributes_get(const struct scmi_protocol_handle *ph,
if (POWER_SCALE_IN_MILLIWATT(flags))
pi->power_scale = SCMI_POWER_MILLIWATTS;
if (PROTOCOL_REV_MAJOR(pi->version) >= 0x3)
if (PROTOCOL_REV_MAJOR(ph->version) >= 0x3)
if (POWER_SCALE_IN_MICROWATT(flags))
pi->power_scale = SCMI_POWER_MICROWATTS;
@ -251,8 +250,7 @@ static void scmi_perf_xa_destroy(void *data)
static int
scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph,
struct perf_dom_info *dom_info,
bool notify_lim_cmd, bool notify_lvl_cmd,
u32 version)
bool notify_lim_cmd, bool notify_lvl_cmd)
{
int ret;
u32 flags;
@ -280,7 +278,7 @@ scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph,
dom_info->perf_level_notify =
SUPPORTS_PERF_LEVEL_NOTIFY(flags);
dom_info->perf_fastchannels = SUPPORTS_PERF_FASTCHANNELS(flags);
if (PROTOCOL_REV_MAJOR(version) >= 0x4)
if (PROTOCOL_REV_MAJOR(ph->version) >= 0x4)
dom_info->level_indexing_mode =
SUPPORTS_LEVEL_INDEXING(flags);
dom_info->rate_limit_us = le32_to_cpu(attr->rate_limit_us) &
@ -323,7 +321,7 @@ scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph,
* If supported overwrite short name with the extended one;
* on error just carry on and use already provided short name.
*/
if (!ret && PROTOCOL_REV_MAJOR(version) >= 0x3 &&
if (!ret && PROTOCOL_REV_MAJOR(ph->version) >= 0x3 &&
SUPPORTS_EXTENDED_NAMES(flags))
ph->hops->extended_name_get(ph, PERF_DOMAIN_NAME_GET,
dom_info->id, NULL, dom_info->info.name,
@ -345,19 +343,14 @@ static int opp_cmp_func(const void *opp1, const void *opp2)
return t1->perf - t2->perf;
}
struct scmi_perf_ipriv {
u32 version;
struct perf_dom_info *perf_dom;
};
static void iter_perf_levels_prepare_message(void *message,
unsigned int desc_index,
const void *priv)
{
struct scmi_msg_perf_describe_levels *msg = message;
const struct scmi_perf_ipriv *p = priv;
const struct perf_dom_info *perf_dom = priv;
msg->domain = cpu_to_le32(p->perf_dom->id);
msg->domain = cpu_to_le32(perf_dom->id);
/* Set the number of OPPs to be skipped/already read */
msg->level_index = cpu_to_le32(desc_index);
}
@ -445,21 +438,21 @@ iter_perf_levels_process_response(const struct scmi_protocol_handle *ph,
{
int ret;
struct scmi_opp *opp;
struct scmi_perf_ipriv *p = priv;
struct perf_dom_info *perf_dom = priv;
opp = &p->perf_dom->opp[p->perf_dom->opp_count];
if (PROTOCOL_REV_MAJOR(p->version) <= 0x3)
ret = process_response_opp(ph->dev, p->perf_dom, opp,
opp = &perf_dom->opp[perf_dom->opp_count];
if (PROTOCOL_REV_MAJOR(ph->version) <= 0x3)
ret = process_response_opp(ph->dev, perf_dom, opp,
st->loop_idx, response);
else
ret = process_response_opp_v4(ph->dev, p->perf_dom, opp,
ret = process_response_opp_v4(ph->dev, perf_dom, opp,
st->loop_idx, response);
/* Skip BAD duplicates received from firmware */
if (ret)
return ret == -EBUSY ? 0 : ret;
p->perf_dom->opp_count++;
perf_dom->opp_count++;
dev_dbg(ph->dev, "Level %d Power %d Latency %dus Ifreq %d Index %d\n",
opp->perf, opp->power, opp->trans_latency_us,
@ -470,7 +463,7 @@ iter_perf_levels_process_response(const struct scmi_protocol_handle *ph,
static int
scmi_perf_describe_levels_get(const struct scmi_protocol_handle *ph,
struct perf_dom_info *perf_dom, u32 version)
struct perf_dom_info *perf_dom)
{
int ret;
void *iter;
@ -479,15 +472,11 @@ scmi_perf_describe_levels_get(const struct scmi_protocol_handle *ph,
.update_state = iter_perf_levels_update_state,
.process_response = iter_perf_levels_process_response,
};
struct scmi_perf_ipriv ppriv = {
.version = version,
.perf_dom = perf_dom,
};
iter = ph->hops->iter_response_init(ph, &ops, MAX_OPPS,
PERF_DESCRIBE_LEVELS,
sizeof(struct scmi_msg_perf_describe_levels),
&ppriv);
perf_dom);
if (IS_ERR(iter))
return PTR_ERR(iter);
@ -576,7 +565,6 @@ static int __scmi_perf_limits_set(const struct scmi_protocol_handle *ph,
static int scmi_perf_limits_set(const struct scmi_protocol_handle *ph,
u32 domain, u32 max_perf, u32 min_perf)
{
struct scmi_perf_info *pi = ph->get_priv(ph);
struct perf_dom_info *dom;
dom = scmi_perf_domain_lookup(ph, domain);
@ -586,7 +574,7 @@ static int scmi_perf_limits_set(const struct scmi_protocol_handle *ph,
if (!dom->set_limits)
return -EOPNOTSUPP;
if (PROTOCOL_REV_MAJOR(pi->version) >= 0x3 && !max_perf && !min_perf)
if (PROTOCOL_REV_MAJOR(ph->version) >= 0x3 && !max_perf && !min_perf)
return -EINVAL;
if (dom->level_indexing_mode) {
@ -1281,22 +1269,15 @@ static const struct scmi_protocol_events perf_protocol_events = {
static int scmi_perf_protocol_init(const struct scmi_protocol_handle *ph)
{
int domain, ret;
u32 version;
struct scmi_perf_info *pinfo;
ret = ph->xops->version_get(ph, &version);
if (ret)
return ret;
dev_dbg(ph->dev, "Performance Version %d.%d\n",
PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version));
PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version));
pinfo = devm_kzalloc(ph->dev, sizeof(*pinfo), GFP_KERNEL);
if (!pinfo)
return -ENOMEM;
pinfo->version = version;
ret = scmi_perf_attributes_get(ph, pinfo);
if (ret)
return ret;
@ -1311,8 +1292,8 @@ static int scmi_perf_protocol_init(const struct scmi_protocol_handle *ph)
dom->id = domain;
scmi_perf_domain_attributes_get(ph, dom, pinfo->notify_lim_cmd,
pinfo->notify_lvl_cmd, version);
scmi_perf_describe_levels_get(ph, dom, version);
pinfo->notify_lvl_cmd);
scmi_perf_describe_levels_get(ph, dom);
if (dom->perf_fastchannels)
scmi_perf_domain_init_fc(ph, dom);
@ -1322,7 +1303,7 @@ static int scmi_perf_protocol_init(const struct scmi_protocol_handle *ph)
if (ret)
return ret;
return ph->set_priv(ph, pinfo, version);
return ph->set_priv(ph, pinfo);
}
static const struct scmi_protocol scmi_perf = {

View File

@ -117,7 +117,6 @@ struct scmi_pin_info {
};
struct scmi_pinctrl_info {
u32 version;
int nr_groups;
int nr_functions;
int nr_pins;
@ -596,11 +595,19 @@ static int scmi_pinctrl_pin_free(const struct scmi_protocol_handle *ph, u32 pin)
}
static int scmi_pinctrl_get_group_info(const struct scmi_protocol_handle *ph,
u32 selector,
struct scmi_group_info *group)
u32 selector)
{
struct scmi_pinctrl_info *pi = ph->get_priv(ph);
struct scmi_group_info *group;
int ret;
if (selector >= pi->nr_groups)
return -EINVAL;
group = &pi->groups[selector];
if (group->present)
return 0;
ret = scmi_pinctrl_attributes(ph, GROUP_TYPE, selector, group->name,
&group->nr_pins);
if (ret)
@ -632,21 +639,14 @@ static int scmi_pinctrl_get_group_name(const struct scmi_protocol_handle *ph,
u32 selector, const char **name)
{
struct scmi_pinctrl_info *pi = ph->get_priv(ph);
int ret;
if (!name)
return -EINVAL;
if (selector >= pi->nr_groups || pi->nr_groups == 0)
return -EINVAL;
if (!pi->groups[selector].present) {
int ret;
ret = scmi_pinctrl_get_group_info(ph, selector,
&pi->groups[selector]);
if (ret)
return ret;
}
ret = scmi_pinctrl_get_group_info(ph, selector);
if (ret)
return ret;
*name = pi->groups[selector].name;
@ -658,21 +658,14 @@ static int scmi_pinctrl_group_pins_get(const struct scmi_protocol_handle *ph,
u32 *nr_pins)
{
struct scmi_pinctrl_info *pi = ph->get_priv(ph);
int ret;
if (!pins || !nr_pins)
return -EINVAL;
if (selector >= pi->nr_groups || pi->nr_groups == 0)
return -EINVAL;
if (!pi->groups[selector].present) {
int ret;
ret = scmi_pinctrl_get_group_info(ph, selector,
&pi->groups[selector]);
if (ret)
return ret;
}
ret = scmi_pinctrl_get_group_info(ph, selector);
if (ret)
return ret;
*pins = pi->groups[selector].group_pins;
*nr_pins = pi->groups[selector].nr_pins;
@ -681,11 +674,19 @@ static int scmi_pinctrl_group_pins_get(const struct scmi_protocol_handle *ph,
}
static int scmi_pinctrl_get_function_info(const struct scmi_protocol_handle *ph,
u32 selector,
struct scmi_function_info *func)
u32 selector)
{
struct scmi_pinctrl_info *pi = ph->get_priv(ph);
struct scmi_function_info *func;
int ret;
if (selector >= pi->nr_functions)
return -EINVAL;
func = &pi->functions[selector];
if (func->present)
return 0;
ret = scmi_pinctrl_attributes(ph, FUNCTION_TYPE, selector, func->name,
&func->nr_groups);
if (ret)
@ -716,21 +717,14 @@ static int scmi_pinctrl_get_function_name(const struct scmi_protocol_handle *ph,
u32 selector, const char **name)
{
struct scmi_pinctrl_info *pi = ph->get_priv(ph);
int ret;
if (!name)
return -EINVAL;
if (selector >= pi->nr_functions || pi->nr_functions == 0)
return -EINVAL;
if (!pi->functions[selector].present) {
int ret;
ret = scmi_pinctrl_get_function_info(ph, selector,
&pi->functions[selector]);
if (ret)
return ret;
}
ret = scmi_pinctrl_get_function_info(ph, selector);
if (ret)
return ret;
*name = pi->functions[selector].name;
return 0;
@ -742,21 +736,14 @@ scmi_pinctrl_function_groups_get(const struct scmi_protocol_handle *ph,
const u32 **groups)
{
struct scmi_pinctrl_info *pi = ph->get_priv(ph);
int ret;
if (!groups || !nr_groups)
return -EINVAL;
if (selector >= pi->nr_functions || pi->nr_functions == 0)
return -EINVAL;
if (!pi->functions[selector].present) {
int ret;
ret = scmi_pinctrl_get_function_info(ph, selector,
&pi->functions[selector]);
if (ret)
return ret;
}
ret = scmi_pinctrl_get_function_info(ph, selector);
if (ret)
return ret;
*groups = pi->functions[selector].groups;
*nr_groups = pi->functions[selector].nr_groups;
@ -771,13 +758,19 @@ static int scmi_pinctrl_mux_set(const struct scmi_protocol_handle *ph,
}
static int scmi_pinctrl_get_pin_info(const struct scmi_protocol_handle *ph,
u32 selector, struct scmi_pin_info *pin)
u32 selector)
{
struct scmi_pinctrl_info *pi = ph->get_priv(ph);
struct scmi_pin_info *pin;
int ret;
if (!pin)
if (selector >= pi->nr_pins)
return -EINVAL;
pin = &pi->pins[selector];
if (pin->present)
return 0;
ret = scmi_pinctrl_attributes(ph, PIN_TYPE, selector, pin->name, NULL);
if (ret)
return ret;
@ -790,20 +783,14 @@ static int scmi_pinctrl_get_pin_name(const struct scmi_protocol_handle *ph,
u32 selector, const char **name)
{
struct scmi_pinctrl_info *pi = ph->get_priv(ph);
int ret;
if (!name)
return -EINVAL;
if (selector >= pi->nr_pins)
return -EINVAL;
if (!pi->pins[selector].present) {
int ret;
ret = scmi_pinctrl_get_pin_info(ph, selector, &pi->pins[selector]);
if (ret)
return ret;
}
ret = scmi_pinctrl_get_pin_info(ph, selector);
if (ret)
return ret;
*name = pi->pins[selector].name;
@ -843,15 +830,10 @@ static const struct scmi_pinctrl_proto_ops pinctrl_proto_ops = {
static int scmi_pinctrl_protocol_init(const struct scmi_protocol_handle *ph)
{
int ret;
u32 version;
struct scmi_pinctrl_info *pinfo;
ret = ph->xops->version_get(ph, &version);
if (ret)
return ret;
dev_dbg(ph->dev, "Pinctrl Version %d.%d\n",
PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version));
PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version));
pinfo = devm_kzalloc(ph->dev, sizeof(*pinfo), GFP_KERNEL);
if (!pinfo)
@ -876,9 +858,7 @@ static int scmi_pinctrl_protocol_init(const struct scmi_protocol_handle *ph)
if (!pinfo->functions)
return -ENOMEM;
pinfo->version = version;
return ph->set_priv(ph, pinfo, version);
return ph->set_priv(ph, pinfo);
}
static int scmi_pinctrl_protocol_deinit(const struct scmi_protocol_handle *ph)

View File

@ -67,7 +67,6 @@ struct power_dom_info {
};
struct scmi_power_info {
u32 version;
bool notify_state_change_cmd;
int num_domains;
u64 stats_addr;
@ -109,7 +108,7 @@ static int scmi_power_attributes_get(const struct scmi_protocol_handle *ph,
static int
scmi_power_domain_attributes_get(const struct scmi_protocol_handle *ph,
u32 domain, struct power_dom_info *dom_info,
u32 version, bool notify_state_change_cmd)
bool notify_state_change_cmd)
{
int ret;
u32 flags;
@ -141,7 +140,7 @@ scmi_power_domain_attributes_get(const struct scmi_protocol_handle *ph,
* If supported overwrite short name with the extended one;
* on error just carry on and use already provided short name.
*/
if (!ret && PROTOCOL_REV_MAJOR(version) >= 0x3 &&
if (!ret && PROTOCOL_REV_MAJOR(ph->version) >= 0x3 &&
SUPPORTS_EXTENDED_NAMES(flags)) {
ph->hops->extended_name_get(ph, POWER_DOMAIN_NAME_GET,
domain, NULL, dom_info->name,
@ -323,15 +322,10 @@ static const struct scmi_protocol_events power_protocol_events = {
static int scmi_power_protocol_init(const struct scmi_protocol_handle *ph)
{
int domain, ret;
u32 version;
struct scmi_power_info *pinfo;
ret = ph->xops->version_get(ph, &version);
if (ret)
return ret;
dev_dbg(ph->dev, "Power Version %d.%d\n",
PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version));
PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version));
pinfo = devm_kzalloc(ph->dev, sizeof(*pinfo), GFP_KERNEL);
if (!pinfo)
@ -349,13 +343,11 @@ static int scmi_power_protocol_init(const struct scmi_protocol_handle *ph)
for (domain = 0; domain < pinfo->num_domains; domain++) {
struct power_dom_info *dom = pinfo->dom_info + domain;
scmi_power_domain_attributes_get(ph, domain, dom, version,
scmi_power_domain_attributes_get(ph, domain, dom,
pinfo->notify_state_change_cmd);
}
pinfo->version = version;
return ph->set_priv(ph, pinfo, version);
return ph->set_priv(ph, pinfo);
}
static const struct scmi_protocol scmi_power = {

View File

@ -122,7 +122,6 @@ struct scmi_powercap_state {
};
struct powercap_info {
u32 version;
int num_domains;
bool notify_cap_cmd;
bool notify_measurements_cmd;
@ -434,7 +433,7 @@ static int __scmi_powercap_cap_set(const struct scmi_protocol_handle *ph,
}
/* Save the last explicitly set non-zero powercap value */
if (PROTOCOL_REV_MAJOR(pi->version) >= 0x2 && !ret && power_cap)
if (PROTOCOL_REV_MAJOR(ph->version) >= 0x2 && !ret && power_cap)
pi->states[domain_id].last_pcap = power_cap;
return ret;
@ -454,7 +453,7 @@ static int scmi_powercap_cap_set(const struct scmi_protocol_handle *ph,
return -EINVAL;
/* Just log the last set request if acting on a disabled domain */
if (PROTOCOL_REV_MAJOR(pi->version) >= 0x2 &&
if (PROTOCOL_REV_MAJOR(ph->version) >= 0x2 &&
!pi->states[domain_id].enabled) {
pi->states[domain_id].last_pcap = power_cap;
return 0;
@ -635,7 +634,7 @@ static int scmi_powercap_cap_enable_set(const struct scmi_protocol_handle *ph,
u32 power_cap;
struct powercap_info *pi = ph->get_priv(ph);
if (PROTOCOL_REV_MAJOR(pi->version) < 0x2)
if (PROTOCOL_REV_MAJOR(ph->version) < 0x2)
return -EINVAL;
if (enable == pi->states[domain_id].enabled)
@ -676,7 +675,7 @@ static int scmi_powercap_cap_enable_get(const struct scmi_protocol_handle *ph,
struct powercap_info *pi = ph->get_priv(ph);
*enable = true;
if (PROTOCOL_REV_MAJOR(pi->version) < 0x2)
if (PROTOCOL_REV_MAJOR(ph->version) < 0x2)
return 0;
/*
@ -961,15 +960,10 @@ static int
scmi_powercap_protocol_init(const struct scmi_protocol_handle *ph)
{
int domain, ret;
u32 version;
struct powercap_info *pinfo;
ret = ph->xops->version_get(ph, &version);
if (ret)
return ret;
dev_dbg(ph->dev, "Powercap Version %d.%d\n",
PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version));
PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version));
pinfo = devm_kzalloc(ph->dev, sizeof(*pinfo), GFP_KERNEL);
if (!pinfo)
@ -1006,7 +1000,7 @@ scmi_powercap_protocol_init(const struct scmi_protocol_handle *ph)
&pinfo->powercaps[domain].fc_info);
/* Grab initial state when disable is supported. */
if (PROTOCOL_REV_MAJOR(version) >= 0x2) {
if (PROTOCOL_REV_MAJOR(ph->version) >= 0x2) {
ret = __scmi_powercap_cap_get(ph,
&pinfo->powercaps[domain],
&pinfo->states[domain].last_pcap);
@ -1018,8 +1012,7 @@ scmi_powercap_protocol_init(const struct scmi_protocol_handle *ph)
}
}
pinfo->version = version;
return ph->set_priv(ph, pinfo, version);
return ph->set_priv(ph, pinfo);
}
static const struct scmi_protocol scmi_powercap = {

View File

@ -159,6 +159,9 @@ struct scmi_proto_helpers_ops;
* struct scmi_protocol_handle - Reference to an initialized protocol instance
*
* @dev: A reference to the associated SCMI instance device (handle->dev).
* @version: The protocol version currently effectively in use by this
* initialized instance of the protocol as determined at the end of
* any possibly needed negotiations performed by the core.
* @xops: A reference to a struct holding refs to the core xfer operations that
* can be used by the protocol implementation to generate SCMI messages.
* @set_priv: A method to set protocol private data for this instance.
@ -177,10 +180,10 @@ struct scmi_proto_helpers_ops;
*/
struct scmi_protocol_handle {
struct device *dev;
unsigned int version;
const struct scmi_xfer_ops *xops;
const struct scmi_proto_helpers_ops *hops;
int (*set_priv)(const struct scmi_protocol_handle *ph, void *priv,
u32 version);
int (*set_priv)(const struct scmi_protocol_handle *ph, void *priv);
void *(*get_priv)(const struct scmi_protocol_handle *ph);
};
@ -287,7 +290,6 @@ struct scmi_proto_helpers_ops {
/**
* struct scmi_xfer_ops - References to the core SCMI xfer operations.
* @version_get: Get this version protocol.
* @xfer_get_init: Initialize one struct xfer if any xfer slot is free.
* @reset_rx_to_maxsz: Reset rx size to max transport size.
* @do_xfer: Do the SCMI transfer.
@ -300,7 +302,6 @@ struct scmi_proto_helpers_ops {
* another protocol.
*/
struct scmi_xfer_ops {
int (*version_get)(const struct scmi_protocol_handle *ph, u32 *version);
int (*xfer_get_init)(const struct scmi_protocol_handle *ph, u8 msg_id,
size_t tx_size, size_t rx_size,
struct scmi_xfer **p);

View File

@ -65,7 +65,6 @@ struct reset_dom_info {
};
struct scmi_reset_info {
u32 version;
int num_domains;
bool notify_reset_cmd;
struct reset_dom_info *dom_info;
@ -98,10 +97,20 @@ static int scmi_reset_attributes_get(const struct scmi_protocol_handle *ph,
return ret;
}
static struct reset_dom_info *
scmi_reset_domain_lookup(const struct scmi_protocol_handle *ph, u32 domain)
{
struct scmi_reset_info *pi = ph->get_priv(ph);
if (domain >= pi->num_domains)
return ERR_PTR(-EINVAL);
return pi->dom_info + domain;
}
static int
scmi_reset_domain_attributes_get(const struct scmi_protocol_handle *ph,
struct scmi_reset_info *pinfo,
u32 domain, u32 version)
struct scmi_reset_info *pinfo, u32 domain)
{
int ret;
u32 attributes;
@ -137,7 +146,7 @@ scmi_reset_domain_attributes_get(const struct scmi_protocol_handle *ph,
* If supported overwrite short name with the extended one;
* on error just carry on and use already provided short name.
*/
if (!ret && PROTOCOL_REV_MAJOR(version) >= 0x3 &&
if (!ret && PROTOCOL_REV_MAJOR(ph->version) >= 0x3 &&
SUPPORTS_EXTENDED_NAMES(attributes))
ph->hops->extended_name_get(ph, RESET_DOMAIN_NAME_GET, domain,
NULL, dom_info->name,
@ -156,20 +165,25 @@ static int scmi_reset_num_domains_get(const struct scmi_protocol_handle *ph)
static const char *
scmi_reset_name_get(const struct scmi_protocol_handle *ph, u32 domain)
{
struct scmi_reset_info *pi = ph->get_priv(ph);
struct reset_dom_info *dom_info;
struct reset_dom_info *dom = pi->dom_info + domain;
dom_info = scmi_reset_domain_lookup(ph, domain);
if (IS_ERR(dom_info))
return "unknown";
return dom->name;
return dom_info->name;
}
static int scmi_reset_latency_get(const struct scmi_protocol_handle *ph,
u32 domain)
{
struct scmi_reset_info *pi = ph->get_priv(ph);
struct reset_dom_info *dom = pi->dom_info + domain;
struct reset_dom_info *dom_info;
return dom->latency_us;
dom_info = scmi_reset_domain_lookup(ph, domain);
if (IS_ERR(dom_info))
return PTR_ERR(dom_info);
return dom_info->latency_us;
}
static int scmi_domain_reset(const struct scmi_protocol_handle *ph, u32 domain,
@ -178,14 +192,13 @@ static int scmi_domain_reset(const struct scmi_protocol_handle *ph, u32 domain,
int ret;
struct scmi_xfer *t;
struct scmi_msg_reset_domain_reset *dom;
struct scmi_reset_info *pi = ph->get_priv(ph);
struct reset_dom_info *rdom;
struct reset_dom_info *dom_info;
if (domain >= pi->num_domains)
return -EINVAL;
dom_info = scmi_reset_domain_lookup(ph, domain);
if (IS_ERR(dom_info))
return PTR_ERR(dom_info);
rdom = pi->dom_info + domain;
if (rdom->async_reset && flags & AUTONOMOUS_RESET)
if (dom_info->async_reset && flags & AUTONOMOUS_RESET)
flags |= ASYNCHRONOUS_RESET;
ret = ph->xops->xfer_get_init(ph, RESET, sizeof(*dom), 0, &t);
@ -238,15 +251,16 @@ static const struct scmi_reset_proto_ops reset_proto_ops = {
static bool scmi_reset_notify_supported(const struct scmi_protocol_handle *ph,
u8 evt_id, u32 src_id)
{
struct reset_dom_info *dom;
struct scmi_reset_info *pi = ph->get_priv(ph);
struct reset_dom_info *dom_info;
if (evt_id != SCMI_EVENT_RESET_ISSUED || src_id >= pi->num_domains)
if (evt_id != SCMI_EVENT_RESET_ISSUED)
return false;
dom = pi->dom_info + src_id;
dom_info = scmi_reset_domain_lookup(ph, src_id);
if (IS_ERR(dom_info))
return false;
return dom->reset_notify;
return dom_info->reset_notify;
}
static int scmi_reset_notify(const struct scmi_protocol_handle *ph,
@ -340,15 +354,10 @@ static const struct scmi_protocol_events reset_protocol_events = {
static int scmi_reset_protocol_init(const struct scmi_protocol_handle *ph)
{
int domain, ret;
u32 version;
struct scmi_reset_info *pinfo;
ret = ph->xops->version_get(ph, &version);
if (ret)
return ret;
dev_dbg(ph->dev, "Reset Version %d.%d\n",
PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version));
PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version));
pinfo = devm_kzalloc(ph->dev, sizeof(*pinfo), GFP_KERNEL);
if (!pinfo)
@ -364,10 +373,9 @@ static int scmi_reset_protocol_init(const struct scmi_protocol_handle *ph)
return -ENOMEM;
for (domain = 0; domain < pinfo->num_domains; domain++)
scmi_reset_domain_attributes_get(ph, pinfo, domain, version);
scmi_reset_domain_attributes_get(ph, pinfo, domain);
pinfo->version = version;
return ph->set_priv(ph, pinfo, version);
return ph->set_priv(ph, pinfo);
}
static const struct scmi_protocol scmi_reset = {

View File

@ -214,7 +214,6 @@ struct scmi_sensor_update_notify_payld {
};
struct sensors_info {
u32 version;
bool notify_trip_point_cmd;
bool notify_continuos_update_cmd;
int num_sensors;
@ -524,8 +523,7 @@ scmi_sensor_axis_extended_names_get(const struct scmi_protocol_handle *ph,
}
static int scmi_sensor_axis_description(const struct scmi_protocol_handle *ph,
struct scmi_sensor_info *s,
u32 version)
struct scmi_sensor_info *s)
{
int ret;
void *iter;
@ -555,7 +553,7 @@ static int scmi_sensor_axis_description(const struct scmi_protocol_handle *ph,
if (ret)
return ret;
if (PROTOCOL_REV_MAJOR(version) >= 0x3 &&
if (PROTOCOL_REV_MAJOR(ph->version) >= 0x3 &&
apriv.any_axes_support_extended_names)
ret = scmi_sensor_axis_extended_names_get(ph, s);
@ -621,7 +619,7 @@ iter_sens_descr_process_response(const struct scmi_protocol_handle *ph,
s->type = SENSOR_TYPE(attrh);
/* Use pre-allocated pool wherever possible */
s->intervals.desc = s->intervals.prealloc_pool;
if (si->version == SCMIv2_SENSOR_PROTOCOL) {
if (ph->version == SCMIv2_SENSOR_PROTOCOL) {
s->intervals.segmented = false;
s->intervals.count = 1;
/*
@ -659,7 +657,7 @@ iter_sens_descr_process_response(const struct scmi_protocol_handle *ph,
* one; on error just carry on and use already provided
* short name.
*/
if (PROTOCOL_REV_MAJOR(si->version) >= 0x3 &&
if (PROTOCOL_REV_MAJOR(ph->version) >= 0x3 &&
SUPPORTS_EXTENDED_NAMES(attrl))
ph->hops->extended_name_get(ph, SENSOR_NAME_GET, s->id,
NULL, s->name, SCMI_MAX_STR_SIZE);
@ -683,7 +681,7 @@ iter_sens_descr_process_response(const struct scmi_protocol_handle *ph,
}
if (s->num_axis > 0)
ret = scmi_sensor_axis_description(ph, s, si->version);
ret = scmi_sensor_axis_description(ph, s);
st->priv = ((u8 *)sdesc + dsize);
@ -1148,21 +1146,15 @@ static const struct scmi_protocol_events sensor_protocol_events = {
static int scmi_sensors_protocol_init(const struct scmi_protocol_handle *ph)
{
u32 version;
int ret;
struct sensors_info *sinfo;
ret = ph->xops->version_get(ph, &version);
if (ret)
return ret;
dev_dbg(ph->dev, "Sensor Version %d.%d\n",
PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version));
PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version));
sinfo = devm_kzalloc(ph->dev, sizeof(*sinfo), GFP_KERNEL);
if (!sinfo)
return -ENOMEM;
sinfo->version = version;
ret = scmi_sensor_attributes_get(ph, sinfo);
if (ret)
@ -1176,7 +1168,7 @@ static int scmi_sensors_protocol_init(const struct scmi_protocol_handle *ph)
if (ret)
return ret;
return ph->set_priv(ph, sinfo, version);
return ph->set_priv(ph, sinfo);
}
static const struct scmi_protocol scmi_sensors = {

View File

@ -196,7 +196,6 @@ static void __iomem *shmem_setup_iomap(struct scmi_chan_info *cinfo,
struct resource *res,
struct scmi_shmem_io_ops **ops)
{
struct device_node *shmem __free(device_node);
const char *desc = tx ? "Tx" : "Rx";
int ret, idx = tx ? 0 : 1;
struct device *cdev = cinfo->dev;
@ -205,7 +204,9 @@ static void __iomem *shmem_setup_iomap(struct scmi_chan_info *cinfo,
void __iomem *addr;
u32 reg_io_width;
shmem = of_parse_phandle(cdev->of_node, "shmem", idx);
struct device_node *shmem __free(device_node) = of_parse_phandle(cdev->of_node,
"shmem", idx);
if (!shmem)
return IOMEM_ERR_PTR(-ENODEV);

View File

@ -34,7 +34,6 @@ struct scmi_system_power_state_notifier_payld {
};
struct scmi_system_info {
u32 version;
bool graceful_timeout_supported;
bool power_state_notify_cmd;
};
@ -141,29 +140,22 @@ static const struct scmi_protocol_events system_protocol_events = {
static int scmi_system_protocol_init(const struct scmi_protocol_handle *ph)
{
int ret;
u32 version;
struct scmi_system_info *pinfo;
ret = ph->xops->version_get(ph, &version);
if (ret)
return ret;
dev_dbg(ph->dev, "System Power Version %d.%d\n",
PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version));
PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version));
pinfo = devm_kzalloc(ph->dev, sizeof(*pinfo), GFP_KERNEL);
if (!pinfo)
return -ENOMEM;
pinfo->version = version;
if (PROTOCOL_REV_MAJOR(pinfo->version) >= 0x2)
if (PROTOCOL_REV_MAJOR(ph->version) >= 0x2)
pinfo->graceful_timeout_supported = true;
if (!ph->hops->protocol_msg_check(ph, SYSTEM_POWER_STATE_NOTIFY, NULL))
pinfo->power_state_notify_cmd = true;
return ph->set_priv(ph, pinfo, version);
return ph->set_priv(ph, pinfo);
}
static const struct scmi_protocol scmi_system = {

View File

@ -48,7 +48,6 @@ enum scmi_imx_bbm_protocol_cmd {
#define SCMI_IMX_BBM_EVENT_RTC_MASK GENMASK(31, 24)
struct scmi_imx_bbm_info {
u32 version;
int nr_rtc;
int nr_gpr;
};
@ -345,16 +344,11 @@ static const struct scmi_imx_bbm_proto_ops scmi_imx_bbm_proto_ops = {
static int scmi_imx_bbm_protocol_init(const struct scmi_protocol_handle *ph)
{
u32 version;
int ret;
struct scmi_imx_bbm_info *binfo;
ret = ph->xops->version_get(ph, &version);
if (ret)
return ret;
dev_info(ph->dev, "NXP SM BBM Version %d.%d\n",
PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version));
PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version));
binfo = devm_kzalloc(ph->dev, sizeof(*binfo), GFP_KERNEL);
if (!binfo)
@ -364,7 +358,7 @@ static int scmi_imx_bbm_protocol_init(const struct scmi_protocol_handle *ph)
if (ret)
return ret;
return ph->set_priv(ph, binfo, version);
return ph->set_priv(ph, binfo);
}
static const struct scmi_protocol scmi_imx_bbm = {

View File

@ -233,15 +233,10 @@ static int scmi_imx_cpu_attributes_get(const struct scmi_protocol_handle *ph,
static int scmi_imx_cpu_protocol_init(const struct scmi_protocol_handle *ph)
{
struct scmi_imx_cpu_info *info;
u32 version;
int ret, i;
ret = ph->xops->version_get(ph, &version);
if (ret)
return ret;
dev_info(ph->dev, "NXP SM CPU Protocol Version %d.%d\n",
PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version));
PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version));
info = devm_kzalloc(ph->dev, sizeof(*info), GFP_KERNEL);
if (!info)
@ -257,7 +252,7 @@ static int scmi_imx_cpu_protocol_init(const struct scmi_protocol_handle *ph)
return ret;
}
return ph->set_priv(ph, info, version);
return ph->set_priv(ph, info);
}
static const struct scmi_protocol scmi_imx_cpu = {

View File

@ -226,15 +226,10 @@ static int scmi_imx_lmm_protocol_attributes_get(const struct scmi_protocol_handl
static int scmi_imx_lmm_protocol_init(const struct scmi_protocol_handle *ph)
{
struct scmi_imx_lmm_priv *info;
u32 version;
int ret;
ret = ph->xops->version_get(ph, &version);
if (ret)
return ret;
dev_info(ph->dev, "NXP SM LMM Version %d.%d\n",
PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version));
PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version));
info = devm_kzalloc(ph->dev, sizeof(*info), GFP_KERNEL);
if (!info)
@ -244,7 +239,7 @@ static int scmi_imx_lmm_protocol_init(const struct scmi_protocol_handle *ph)
if (ret)
return ret;
return ph->set_priv(ph, info, version);
return ph->set_priv(ph, info);
}
static const struct scmi_protocol scmi_imx_lmm = {

View File

@ -32,7 +32,6 @@ enum scmi_imx_misc_protocol_cmd {
};
struct scmi_imx_misc_info {
u32 version;
u32 nr_dev_ctrl;
u32 nr_brd_ctrl;
u32 nr_reason;
@ -380,15 +379,10 @@ static const struct scmi_imx_misc_proto_ops scmi_imx_misc_proto_ops = {
static int scmi_imx_misc_protocol_init(const struct scmi_protocol_handle *ph)
{
struct scmi_imx_misc_info *minfo;
u32 version;
int ret;
ret = ph->xops->version_get(ph, &version);
if (ret)
return ret;
dev_info(ph->dev, "NXP SM MISC Version %d.%d\n",
PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version));
PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version));
minfo = devm_kzalloc(ph->dev, sizeof(*minfo), GFP_KERNEL);
if (!minfo)
@ -410,7 +404,7 @@ static int scmi_imx_misc_protocol_init(const struct scmi_protocol_handle *ph)
if (ret && ret != -EOPNOTSUPP)
return ret;
return ph->set_priv(ph, minfo, version);
return ph->set_priv(ph, minfo);
}
static const struct scmi_protocol scmi_imx_misc = {

View File

@ -66,7 +66,6 @@ struct scmi_resp_voltage_level_set_complete {
};
struct voltage_info {
unsigned int version;
unsigned int num_domains;
struct scmi_voltage_info *domains;
};
@ -243,7 +242,7 @@ static int scmi_voltage_descriptors_get(const struct scmi_protocol_handle *ph,
* If supported overwrite short name with the extended one;
* on error just carry on and use already provided short name.
*/
if (PROTOCOL_REV_MAJOR(vinfo->version) >= 0x2) {
if (PROTOCOL_REV_MAJOR(ph->version) >= 0x2) {
if (SUPPORTS_EXTENDED_NAMES(attributes))
ph->hops->extended_name_get(ph,
VOLTAGE_DOMAIN_NAME_GET,
@ -405,20 +404,14 @@ static const struct scmi_voltage_proto_ops voltage_proto_ops = {
static int scmi_voltage_protocol_init(const struct scmi_protocol_handle *ph)
{
int ret;
u32 version;
struct voltage_info *vinfo;
ret = ph->xops->version_get(ph, &version);
if (ret)
return ret;
dev_dbg(ph->dev, "Voltage Version %d.%d\n",
PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version));
PROTOCOL_REV_MAJOR(ph->version), PROTOCOL_REV_MINOR(ph->version));
vinfo = devm_kzalloc(ph->dev, sizeof(*vinfo), GFP_KERNEL);
if (!vinfo)
return -ENOMEM;
vinfo->version = version;
ret = scmi_protocol_attributes_get(ph, vinfo);
if (ret)
@ -437,7 +430,7 @@ static int scmi_voltage_protocol_init(const struct scmi_protocol_handle *ph)
dev_warn(ph->dev, "No Voltage domains found.\n");
}
return ph->set_priv(ph, vinfo, version);
return ph->set_priv(ph, vinfo);
}
static const struct scmi_protocol scmi_voltage = {