1 /*
2  * Arm SCP/MCP Software
3  * Copyright (c) 2022-2023, Linaro Limited and Contributors. All rights
4  * reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  * Description:
9  *     msg buffer device driver.
10  */
11 
12 #ifndef MOD_MSG_SMT_H
13 #define MOD_MSG_SMT_H
14 
15 #include <stddef.h>
16 #include <stdint.h>
17 #include <fwk_id.h>
18 
19 /*!
20  * \brief Channel type
21  *
22  * \details Defines the role of an entity in a channel
23  */
24 enum mod_msg_smt_channel_type {
25     /*! Requester channel */
26     MOD_MSG_SMT_CHANNEL_TYPE_REQUESTER,
27 
28     /*! Completer channel */
29     MOD_MSG_SMT_CHANNEL_TYPE_COMPLETER,
30 
31     /*! Channel type count */
32     MOD_MSG_SMT_CHANNEL_TYPE_COUNT,
33 };
34 
35 /*!
36  * \brief Channel config.
37  */
38 struct mod_msg_smt_channel_config {
39     /*! Channel role (requester or completer) */
40     enum mod_msg_smt_channel_type type;
41 
42     /*! Shared mailbox size in bytes */
43     size_t mailbox_size;
44 
45     /*! Identifier of the driver */
46     fwk_id_t driver_id;
47 
48     /*! Identifier of the driver API to bind to */
49     fwk_id_t driver_api_id;
50 };
51 
52 /*!
53  * \brief Driver input API (Implemented by SMT)
54  *
55  * \details Interface used for driver -> SMT communication.
56  */
57 struct mod_msg_smt_driver_input_api {
58     /*!
59      * \brief Signal an incoming message in the mailbox
60      *
61      * \param device_id Channel identifier
62      *
63      * \retval FWK_SUCCESS The operation succeeded.
64      * \return One of the standard error codes for implementation-defined
65      * errors.
66      */
67     int (*signal_message)(fwk_id_t channel_id, void *msg_in, size_t in_len, void *msg_out, size_t out_len);
68 };
69 
70 /*!
71  * \brief Driver output API (Implemented by MHU)
72  *
73  * \details Interface used for SMT -> driver communication.
74  */
75 struct mod_msg_smt_driver_ouput_api {
76     /*!
77      * \brief Signal an incoming message in the mailbox
78      *
79      * \param device_id Channel identifier
80      *
81      * \retval FWK_SUCCESS The operation succeeded.
82      * \return One of the standard error codes for implementation-defined
83      * errors.
84      */
85     int (*raise_notification)(fwk_id_t channel_id, size_t size);
86 };
87 
88 /*!
89  * \brief Type of the interfaces exposed by the power domain module.
90  */
91 enum mod_msg_smt_api_idx {
92     MOD_MSG_SMT_API_IDX_SCMI_TRANSPORT,
93     MOD_MSG_SMT_API_IDX_DRIVER_INPUT,
94     MOD_MSG_SMT_API_IDX_COUNT,
95 };
96 
97 #endif /* MOD_MSG_SMT_H */
98