diff options
author | Cristian Marussi <cristian.marussi@arm.com> | 2020-11-19 17:49:05 +0000 |
---|---|---|
committer | Sudeep Holla <sudeep.holla@arm.com> | 2020-11-22 18:00:25 +0000 |
commit | 7b83c5f41088987d04e24c3af0e1fb9f43b747b5 (patch) | |
tree | d32278fbf3502113f3fe2ae085b125aa14c9fcd4 /drivers/firmware | |
parent | e2083d36739168f7b612312160cf7bb45b251408 (diff) |
firmware: arm_scmi: Add SCMI v3.0 sensor configuration support
Add SCMI v3.0 sensor support for CONFIG_GET/CONFIG_SET commands.
Link: https://lore.kernel.org/r/20201119174906.43862-6-cristian.marussi@arm.com
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Diffstat (limited to 'drivers/firmware')
-rw-r--r-- | drivers/firmware/arm_scmi/sensors.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/drivers/firmware/arm_scmi/sensors.c b/drivers/firmware/arm_scmi/sensors.c index 2239af5f9e6e..10c271d430e7 100644 --- a/drivers/firmware/arm_scmi/sensors.c +++ b/drivers/firmware/arm_scmi/sensors.c @@ -23,6 +23,8 @@ enum scmi_sensor_protocol_cmd { SENSOR_READING_GET = 0x6, SENSOR_AXIS_DESCRIPTION_GET = 0x7, SENSOR_LIST_UPDATE_INTERVALS = 0x8, + SENSOR_CONFIG_GET = 0x9, + SENSOR_CONFIG_SET = 0xA, }; struct scmi_msg_resp_sensor_attributes { @@ -149,6 +151,11 @@ struct scmi_msg_set_sensor_trip_point { __le32 value_high; }; +struct scmi_msg_sensor_config_set { + __le32 id; + __le32 sensor_config; +}; + struct scmi_msg_sensor_reading_get { __le32 id; __le32 flags; @@ -592,6 +599,60 @@ scmi_sensor_trip_point_config(const struct scmi_handle *handle, u32 sensor_id, return ret; } +static int scmi_sensor_config_get(const struct scmi_handle *handle, + u32 sensor_id, u32 *sensor_config) +{ + int ret; + struct scmi_xfer *t; + + ret = scmi_xfer_get_init(handle, SENSOR_CONFIG_GET, + SCMI_PROTOCOL_SENSOR, sizeof(__le32), + sizeof(__le32), &t); + if (ret) + return ret; + + put_unaligned_le32(cpu_to_le32(sensor_id), t->tx.buf); + ret = scmi_do_xfer(handle, t); + if (!ret) { + struct sensors_info *si = handle->sensor_priv; + struct scmi_sensor_info *s = si->sensors + sensor_id; + + *sensor_config = get_unaligned_le64(t->rx.buf); + s->sensor_config = *sensor_config; + } + + scmi_xfer_put(handle, t); + return ret; +} + +static int scmi_sensor_config_set(const struct scmi_handle *handle, + u32 sensor_id, u32 sensor_config) +{ + int ret; + struct scmi_xfer *t; + struct scmi_msg_sensor_config_set *msg; + + ret = scmi_xfer_get_init(handle, SENSOR_CONFIG_SET, + SCMI_PROTOCOL_SENSOR, sizeof(*msg), 0, &t); + if (ret) + return ret; + + msg = t->tx.buf; + msg->id = cpu_to_le32(sensor_id); + msg->sensor_config = cpu_to_le32(sensor_config); + + ret = scmi_do_xfer(handle, t); + if (!ret) { + struct sensors_info *si = handle->sensor_priv; + struct scmi_sensor_info *s = si->sensors + sensor_id; + + s->sensor_config = sensor_config; + } + + scmi_xfer_put(handle, t); + return ret; +} + /** * scmi_sensor_reading_get - Read scalar sensor value * @handle: Platform handle @@ -745,6 +806,8 @@ static const struct scmi_sensor_ops sensor_ops = { .trip_point_config = scmi_sensor_trip_point_config, .reading_get = scmi_sensor_reading_get, .reading_get_timestamped = scmi_sensor_reading_get_timestamped, + .config_get = scmi_sensor_config_get, + .config_set = scmi_sensor_config_set, }; static int scmi_sensor_set_notify_enabled(const struct scmi_handle *handle, |