/* SPDX-License-Identifier: GPL-2.0 */1/*2* System Control and Management Interface (SCMI) Message Protocol3* notification header file containing some definitions, structures4* and function prototypes related to SCMI Notification handling.5*6* Copyright (C) 2020-2021 ARM Ltd.7*/8#ifndef _SCMI_NOTIFY_H9#define _SCMI_NOTIFY_H1011#include <linux/device.h>12#include <linux/ktime.h>13#include <linux/types.h>1415#define SCMI_PROTO_QUEUE_SZ 40961617/**18* struct scmi_event - Describes an event to be supported19* @id: Event ID20* @max_payld_sz: Max possible size for the payload of a notification message21* @max_report_sz: Max possible size for the report of a notification message22*23* Each SCMI protocol, during its initialization phase, can describe the events24* it wishes to support in a few struct scmi_event and pass them to the core25* using scmi_register_protocol_events().26*/27struct scmi_event {28u8 id;29size_t max_payld_sz;30size_t max_report_sz;31};3233struct scmi_protocol_handle;3435/**36* struct scmi_event_ops - Protocol helpers called by the notification core.37* @is_notify_supported: Return 0 if the specified notification for the38* specified resource (src_id) is supported.39* @get_num_sources: Returns the number of possible events' sources for this40* protocol41* @set_notify_enabled: Enable/disable the required evt_id/src_id notifications42* using the proper custom protocol commands.43* Return 0 on Success44* @fill_custom_report: fills a custom event report from the provided45* event message payld identifying the event46* specific src_id.47* Return NULL on failure otherwise @report now fully48* populated49*50* Context: Helpers described in &struct scmi_event_ops are called only in51* process context.52*/53struct scmi_event_ops {54bool (*is_notify_supported)(const struct scmi_protocol_handle *ph,55u8 evt_id, u32 src_id);56int (*get_num_sources)(const struct scmi_protocol_handle *ph);57int (*set_notify_enabled)(const struct scmi_protocol_handle *ph,58u8 evt_id, u32 src_id, bool enabled);59void *(*fill_custom_report)(const struct scmi_protocol_handle *ph,60u8 evt_id, ktime_t timestamp,61const void *payld, size_t payld_sz,62void *report, u32 *src_id);63};6465/**66* struct scmi_protocol_events - Per-protocol description of available events67* @queue_sz: Size in bytes of the per-protocol queue to use.68* @ops: Array of protocol-specific events operations.69* @evts: Array of supported protocol's events.70* @num_events: Number of supported protocol's events described in @evts.71* @num_sources: Number of protocol's sources, should be greater than 0; if not72* available at compile time, it will be provided at run-time via73* @get_num_sources.74*/75struct scmi_protocol_events {76size_t queue_sz;77const struct scmi_event_ops *ops;78const struct scmi_event *evts;79unsigned int num_events;80unsigned int num_sources;81};8283int scmi_notification_init(struct scmi_handle *handle);84void scmi_notification_exit(struct scmi_handle *handle);85int scmi_register_protocol_events(const struct scmi_handle *handle, u8 proto_id,86const struct scmi_protocol_handle *ph,87const struct scmi_protocol_events *ee);88void scmi_deregister_protocol_events(const struct scmi_handle *handle,89u8 proto_id);90int scmi_notify(const struct scmi_handle *handle, u8 proto_id, u8 evt_id,91const void *buf, size_t len, ktime_t ts);9293#endif /* _SCMI_NOTIFY_H */949596