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

firmware: arm_scmi: Add notification callbacks-registration

Add the core SCMI notifications callbacks-registration support: allow
users to register their own callbacks against the desired events.

Whenever a registration request is issued against a still non existent
event, mark such request as pending for later processing, in order to
account for possible late initializations of SCMI Protocols associated
to loadable drivers.

Link: https://lore.kernel.org/r/20200701155348.52864-3-cristian.marussi@arm.comReviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: default avatarCristian Marussi <cristian.marussi@arm.com>
Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
parent 1fc2dd18
This diff is collapsed.
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#define _LINUX_SCMI_PROTOCOL_H #define _LINUX_SCMI_PROTOCOL_H
#include <linux/device.h> #include <linux/device.h>
#include <linux/notifier.h>
#include <linux/types.h> #include <linux/types.h>
#define SCMI_MAX_STR_SIZE 16 #define SCMI_MAX_STR_SIZE 16
...@@ -213,6 +214,49 @@ struct scmi_reset_ops { ...@@ -213,6 +214,49 @@ struct scmi_reset_ops {
int (*deassert)(const struct scmi_handle *handle, u32 domain); int (*deassert)(const struct scmi_handle *handle, u32 domain);
}; };
/**
* struct scmi_notify_ops - represents notifications' operations provided by
* SCMI core
* @register_event_notifier: Register a notifier_block for the requested event
* @unregister_event_notifier: Unregister a notifier_block for the requested
* event
*
* A user can register/unregister its own notifier_block against the wanted
* platform instance regarding the desired event identified by the
* tuple: (proto_id, evt_id, src_id) using the provided register/unregister
* interface where:
*
* @handle: The handle identifying the platform instance to use
* @proto_id: The protocol ID as in SCMI Specification
* @evt_id: The message ID of the desired event as in SCMI Specification
* @src_id: A pointer to the desired source ID if different sources are
* possible for the protocol (like domain_id, sensor_id...etc)
*
* @src_id can be provided as NULL if it simply does NOT make sense for
* the protocol at hand, OR if the user is explicitly interested in
* receiving notifications from ANY existent source associated to the
* specified proto_id / evt_id.
*
* Received notifications are finally delivered to the registered users,
* invoking the callback provided with the notifier_block *nb as follows:
*
* int user_cb(nb, evt_id, report)
*
* with:
*
* @nb: The notifier block provided by the user
* @evt_id: The message ID of the delivered event
* @report: A custom struct describing the specific event delivered
*/
struct scmi_notify_ops {
int (*register_event_notifier)(const struct scmi_handle *handle,
u8 proto_id, u8 evt_id, u32 *src_id,
struct notifier_block *nb);
int (*unregister_event_notifier)(const struct scmi_handle *handle,
u8 proto_id, u8 evt_id, u32 *src_id,
struct notifier_block *nb);
};
/** /**
* struct scmi_handle - Handle returned to ARM SCMI clients for usage. * struct scmi_handle - Handle returned to ARM SCMI clients for usage.
* *
...@@ -223,6 +267,7 @@ struct scmi_reset_ops { ...@@ -223,6 +267,7 @@ struct scmi_reset_ops {
* @clk_ops: pointer to set of clock protocol operations * @clk_ops: pointer to set of clock protocol operations
* @sensor_ops: pointer to set of sensor protocol operations * @sensor_ops: pointer to set of sensor protocol operations
* @reset_ops: pointer to set of reset protocol operations * @reset_ops: pointer to set of reset protocol operations
* @notify_ops: pointer to set of notifications related operations
* @perf_priv: pointer to private data structure specific to performance * @perf_priv: pointer to private data structure specific to performance
* protocol(for internal use only) * protocol(for internal use only)
* @clk_priv: pointer to private data structure specific to clock * @clk_priv: pointer to private data structure specific to clock
...@@ -244,6 +289,7 @@ struct scmi_handle { ...@@ -244,6 +289,7 @@ struct scmi_handle {
struct scmi_power_ops *power_ops; struct scmi_power_ops *power_ops;
struct scmi_sensor_ops *sensor_ops; struct scmi_sensor_ops *sensor_ops;
struct scmi_reset_ops *reset_ops; struct scmi_reset_ops *reset_ops;
struct scmi_notify_ops *notify_ops;
/* for protocol internal use */ /* for protocol internal use */
void *perf_priv; void *perf_priv;
void *clk_priv; void *clk_priv;
......
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