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

firmware: arm_scmi: Port systempower protocol to new protocols interface

Convert internals of protocol implementation to use protocol handles and
expose a new protocol operations interface for SCMI driver using the new
get/put common operations.

Remove handle->system_priv now unused.

Link: https://lore.kernel.org/r/20210316124903.35011-28-cristian.marussi@arm.comTested-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarCristian Marussi <cristian.marussi@arm.com>
Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
parent f3690d97
...@@ -32,40 +32,40 @@ struct scmi_system_info { ...@@ -32,40 +32,40 @@ struct scmi_system_info {
u32 version; u32 version;
}; };
static int scmi_system_request_notify(const struct scmi_handle *handle, static int scmi_system_request_notify(const struct scmi_protocol_handle *ph,
bool enable) bool enable)
{ {
int ret; int ret;
struct scmi_xfer *t; struct scmi_xfer *t;
struct scmi_system_power_state_notify *notify; struct scmi_system_power_state_notify *notify;
ret = scmi_xfer_get_init(handle, SYSTEM_POWER_STATE_NOTIFY, ret = ph->xops->xfer_get_init(ph, SYSTEM_POWER_STATE_NOTIFY,
SCMI_PROTOCOL_SYSTEM, sizeof(*notify), 0, &t); sizeof(*notify), 0, &t);
if (ret) if (ret)
return ret; return ret;
notify = t->tx.buf; notify = t->tx.buf;
notify->notify_enable = enable ? cpu_to_le32(BIT(0)) : 0; notify->notify_enable = enable ? cpu_to_le32(BIT(0)) : 0;
ret = scmi_do_xfer(handle, t); ret = ph->xops->do_xfer(ph, t);
scmi_xfer_put(handle, t); ph->xops->xfer_put(ph, t);
return ret; return ret;
} }
static int scmi_system_set_notify_enabled(const void *handle, static int scmi_system_set_notify_enabled(const void *ph,
u8 evt_id, u32 src_id, bool enable) u8 evt_id, u32 src_id, bool enable)
{ {
int ret; int ret;
ret = scmi_system_request_notify(handle, enable); ret = scmi_system_request_notify(ph, enable);
if (ret) if (ret)
pr_debug("FAIL_ENABLE - evt[%X] - ret:%d\n", evt_id, ret); pr_debug("FAIL_ENABLE - evt[%X] - ret:%d\n", evt_id, ret);
return ret; return ret;
} }
static void *scmi_system_fill_custom_report(const void *handle, static void *scmi_system_fill_custom_report(const void *ph,
u8 evt_id, ktime_t timestamp, u8 evt_id, ktime_t timestamp,
const void *payld, size_t payld_sz, const void *payld, size_t payld_sz,
void *report, u32 *src_id) void *report, u32 *src_id)
...@@ -109,29 +109,27 @@ static const struct scmi_protocol_events system_protocol_events = { ...@@ -109,29 +109,27 @@ static const struct scmi_protocol_events system_protocol_events = {
.num_sources = SCMI_SYSTEM_NUM_SOURCES, .num_sources = SCMI_SYSTEM_NUM_SOURCES,
}; };
static int scmi_system_protocol_init(struct scmi_handle *handle) static int scmi_system_protocol_init(const struct scmi_protocol_handle *ph)
{ {
u32 version; u32 version;
struct scmi_system_info *pinfo; struct scmi_system_info *pinfo;
scmi_version_get(handle, SCMI_PROTOCOL_SYSTEM, &version); ph->xops->version_get(ph, &version);
dev_dbg(handle->dev, "System Power Version %d.%d\n", dev_dbg(ph->dev, "System Power Version %d.%d\n",
PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version));
pinfo = devm_kzalloc(handle->dev, sizeof(*pinfo), GFP_KERNEL); pinfo = devm_kzalloc(ph->dev, sizeof(*pinfo), GFP_KERNEL);
if (!pinfo) if (!pinfo)
return -ENOMEM; return -ENOMEM;
pinfo->version = version; pinfo->version = version;
handle->system_priv = pinfo; return ph->set_priv(ph, pinfo);
return 0;
} }
static const struct scmi_protocol scmi_system = { static const struct scmi_protocol scmi_system = {
.id = SCMI_PROTOCOL_SYSTEM, .id = SCMI_PROTOCOL_SYSTEM,
.init = &scmi_system_protocol_init, .instance_init = &scmi_system_protocol_init,
.ops = NULL, .ops = NULL,
.events = &system_protocol_events, .events = &system_protocol_events,
}; };
......
...@@ -629,7 +629,6 @@ struct scmi_handle { ...@@ -629,7 +629,6 @@ struct scmi_handle {
/* for protocol internal use */ /* for protocol internal use */
void *voltage_priv; void *voltage_priv;
void *notify_priv; void *notify_priv;
void *system_priv;
}; };
enum scmi_std_protocol { enum scmi_std_protocol {
......
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