xref: /linux/drivers/firmware/arm_scmi/notify.h (revision 32daa5d7899e03433429bedf9e20d7963179703a)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * System Control and Management Interface (SCMI) Message Protocol
4  * notification header file containing some definitions, structures
5  * and function prototypes related to SCMI Notification handling.
6  *
7  * Copyright (C) 2020 ARM Ltd.
8  */
9 #ifndef _SCMI_NOTIFY_H
10 #define _SCMI_NOTIFY_H
11 
12 #include <linux/device.h>
13 #include <linux/ktime.h>
14 #include <linux/types.h>
15 
16 #define SCMI_PROTO_QUEUE_SZ	4096
17 
18 /**
19  * struct scmi_event  - Describes an event to be supported
20  * @id: Event ID
21  * @max_payld_sz: Max possible size for the payload of a notification message
22  * @max_report_sz: Max possible size for the report of a notification message
23  *
24  * Each SCMI protocol, during its initialization phase, can describe the events
25  * it wishes to support in a few struct scmi_event and pass them to the core
26  * using scmi_register_protocol_events().
27  */
28 struct scmi_event {
29 	u8	id;
30 	size_t	max_payld_sz;
31 	size_t	max_report_sz;
32 };
33 
34 /**
35  * struct scmi_event_ops  - Protocol helpers called by the notification core.
36  * @set_notify_enabled: Enable/disable the required evt_id/src_id notifications
37  *			using the proper custom protocol commands.
38  *			Return 0 on Success
39  * @fill_custom_report: fills a custom event report from the provided
40  *			event message payld identifying the event
41  *			specific src_id.
42  *			Return NULL on failure otherwise @report now fully
43  *			populated
44  *
45  * Context: Helpers described in &struct scmi_event_ops are called only in
46  *	    process context.
47  */
48 struct scmi_event_ops {
49 	int (*set_notify_enabled)(const struct scmi_handle *handle,
50 				  u8 evt_id, u32 src_id, bool enabled);
51 	void *(*fill_custom_report)(const struct scmi_handle *handle,
52 				    u8 evt_id, ktime_t timestamp,
53 				    const void *payld, size_t payld_sz,
54 				    void *report, u32 *src_id);
55 };
56 
57 int scmi_notification_init(struct scmi_handle *handle);
58 void scmi_notification_exit(struct scmi_handle *handle);
59 
60 int scmi_register_protocol_events(const struct scmi_handle *handle,
61 				  u8 proto_id, size_t queue_sz,
62 				  const struct scmi_event_ops *ops,
63 				  const struct scmi_event *evt, int num_events,
64 				  int num_sources);
65 int scmi_notify(const struct scmi_handle *handle, u8 proto_id, u8 evt_id,
66 		const void *buf, size_t len, ktime_t ts);
67 
68 #endif /* _SCMI_NOTIFY_H */
69