2020-07-01 16:53:40 +01:00
/* SPDX-License-Identifier: GPL-2.0 */
/*
* System Control and Management Interface ( SCMI ) Message Protocol
* notification header file containing some definitions , structures
* and function prototypes related to SCMI Notification handling .
*
2021-03-16 12:48:31 +00:00
* Copyright ( C ) 2020 - 2021 ARM Ltd .
2020-07-01 16:53:40 +01:00
*/
# ifndef _SCMI_NOTIFY_H
# define _SCMI_NOTIFY_H
# include <linux/device.h>
2020-07-10 14:39:19 +01:00
# include <linux/ktime.h>
2020-07-01 16:53:40 +01:00
# include <linux/types.h>
# define SCMI_PROTO_QUEUE_SZ 4096
/**
* struct scmi_event - Describes an event to be supported
* @ id : Event ID
* @ max_payld_sz : Max possible size for the payload of a notification message
* @ max_report_sz : Max possible size for the report of a notification message
*
* Each SCMI protocol , during its initialization phase , can describe the events
* it wishes to support in a few struct scmi_event and pass them to the core
* using scmi_register_protocol_events ( ) .
*/
struct scmi_event {
u8 id ;
size_t max_payld_sz ;
size_t max_report_sz ;
} ;
2021-03-16 12:48:31 +00:00
struct scmi_protocol_handle ;
2020-07-01 16:53:40 +01:00
/**
* struct scmi_event_ops - Protocol helpers called by the notification core .
2021-03-16 12:48:31 +00:00
* @ get_num_sources : Returns the number of possible events ' sources for this
* protocol
2020-07-01 16:53:40 +01:00
* @ set_notify_enabled : Enable / disable the required evt_id / src_id notifications
* using the proper custom protocol commands .
* Return 0 on Success
2020-07-01 16:53:42 +01:00
* @ fill_custom_report : fills a custom event report from the provided
* event message payld identifying the event
* specific src_id .
* Return NULL on failure otherwise @ report now fully
* populated
2020-07-01 16:53:40 +01:00
*
* Context : Helpers described in & struct scmi_event_ops are called only in
* process context .
*/
struct scmi_event_ops {
2021-03-16 12:48:59 +00:00
int ( * get_num_sources ) ( const struct scmi_protocol_handle * ph ) ;
int ( * set_notify_enabled ) ( const struct scmi_protocol_handle * ph ,
2020-07-01 16:53:40 +01:00
u8 evt_id , u32 src_id , bool enabled ) ;
2021-03-16 12:48:59 +00:00
void * ( * fill_custom_report ) ( const struct scmi_protocol_handle * ph ,
2020-07-10 14:39:19 +01:00
u8 evt_id , ktime_t timestamp ,
const void * payld , size_t payld_sz ,
void * report , u32 * src_id ) ;
2020-07-01 16:53:40 +01:00
} ;
2021-03-16 12:48:31 +00:00
/**
* struct scmi_protocol_events - Per - protocol description of available events
* @ queue_sz : Size in bytes of the per - protocol queue to use .
* @ ops : Array of protocol - specific events operations .
* @ evts : Array of supported protocol ' s events .
* @ num_events : Number of supported protocol ' s events described in @ evts .
* @ num_sources : Number of protocol ' s sources , should be greater than 0 ; if not
* available at compile time , it will be provided at run - time via
* @ get_num_sources .
*/
struct scmi_protocol_events {
size_t queue_sz ;
const struct scmi_event_ops * ops ;
const struct scmi_event * evts ;
unsigned int num_events ;
unsigned int num_sources ;
} ;
2020-07-01 16:53:40 +01:00
int scmi_notification_init ( struct scmi_handle * handle ) ;
void scmi_notification_exit ( struct scmi_handle * handle ) ;
2021-03-16 12:48:31 +00:00
int scmi_register_protocol_events ( const struct scmi_handle * handle , u8 proto_id ,
2021-03-16 12:48:32 +00:00
const struct scmi_protocol_handle * ph ,
2021-03-16 12:48:31 +00:00
const struct scmi_protocol_events * ee ) ;
void scmi_deregister_protocol_events ( const struct scmi_handle * handle ,
u8 proto_id ) ;
2020-07-01 16:53:42 +01:00
int scmi_notify ( const struct scmi_handle * handle , u8 proto_id , u8 evt_id ,
2020-07-10 14:39:19 +01:00
const void * buf , size_t len , ktime_t ts ) ;
2020-07-01 16:53:40 +01:00
# endif /* _SCMI_NOTIFY_H */