@@ -6,6 +6,7 @@
*/
#include "common.h"
+#include "notify.h"
enum scmi_sensor_protocol_cmd {
SENSOR_DESCRIPTION_GET = 0x3,
@@ -71,6 +72,12 @@ struct scmi_msg_sensor_reading_get {
#define SENSOR_READ_ASYNC BIT(0)
};
+struct scmi_sensor_trip_notify_payld {
+ __le32 agent_id;
+ __le32 sensor_id;
+ __le32 trip_point_desc;
+};
+
struct sensors_info {
u32 version;
int num_sensors;
@@ -276,6 +283,62 @@ static struct scmi_sensor_ops sensor_ops = {
.reading_get = scmi_sensor_reading_get,
};
+static bool scmi_sensor_set_notify_enabled(const struct scmi_handle *handle,
+ u8 evt_id, u32 src_id, bool enable)
+{
+ int ret;
+
+ ret = scmi_sensor_trip_point_notify(handle, src_id, enable);
+ if (ret)
+ pr_warn("SCMI Notifications - Proto:%X - FAIL_ENABLED - evt[%X] dom[%d] - ret:%d\n",
+ SCMI_PROTOCOL_SENSOR, evt_id, src_id, ret);
+
+ return !ret ? true : false;
+}
+
+static void *scmi_sensor_fill_custom_report(u8 evt_id, u64 timestamp,
+ const void *payld, size_t payld_sz,
+ void *report, u32 *src_id)
+{
+ void *rep = NULL;
+
+ switch (evt_id) {
+ case SENSOR_TRIP_POINT_EVENT:
+ {
+ const struct scmi_sensor_trip_notify_payld *p = payld;
+ struct scmi_sensor_trip_point_report *r = report;
+
+ if (sizeof(*p) != payld_sz)
+ break;
+
+ r->timestamp = timestamp;
+ r->agent_id = le32_to_cpu(p->agent_id);
+ r->sensor_id = le32_to_cpu(p->sensor_id);
+ r->trip_point_desc = le32_to_cpu(p->trip_point_desc);
+ *src_id = r->sensor_id;
+ rep = r;
+ break;
+ }
+ default:
+ break;
+ }
+
+ return rep;
+}
+
+static const struct scmi_event sensor_events[] = {
+ {
+ .evt_id = SENSOR_TRIP_POINT_EVENT,
+ .max_payld_sz = 12,
+ .max_report_sz = sizeof(struct scmi_sensor_trip_point_report),
+ },
+};
+
+static const struct scmi_protocol_event_ops sensor_event_ops = {
+ .set_notify_enabled = scmi_sensor_set_notify_enabled,
+ .fill_custom_report = scmi_sensor_fill_custom_report,
+};
+
static int scmi_sensors_protocol_init(struct scmi_handle *handle)
{
u32 version;
@@ -299,6 +362,12 @@ static int scmi_sensors_protocol_init(struct scmi_handle *handle)
scmi_sensor_description_get(handle, sinfo);
+ scmi_register_protocol_events(handle,
+ SCMI_PROTOCOL_SENSOR, PAGE_SIZE,
+ &sensor_event_ops, sensor_events,
+ ARRAY_SIZE(sensor_events),
+ sinfo->num_sensors);
+
sinfo->version = version;
handle->sensor_ops = &sensor_ops;
handle->sensor_priv = sinfo;
@@ -407,4 +407,11 @@ struct scmi_perf_level_report {
u32 performance_level;
};
+struct scmi_sensor_trip_point_report {
+ ktime_t timestamp;
+ u32 agent_id;
+ u32 sensor_id;
+ u32 trip_point_desc;
+};
+
#endif /* _LINUX_SCMI_PROTOCOL_H */
Make SCMI Sensor protocol register with the notification core. Signed-off-by: Cristian Marussi <cristian.marussi@arm.com> --- V2 --> V3 - added handle awareness V1 --> V2 - simplified .set_notify_enabled() implementation moving the ALL_SRCIDs logic out of protocol. ALL_SRCIDs logic is now in charge of the notification core, together with proper reference counting of enables - switched to devres protocol-registration --- drivers/firmware/arm_scmi/sensors.c | 69 +++++++++++++++++++++++++++++ include/linux/scmi_protocol.h | 7 +++ 2 files changed, 76 insertions(+)