1
2
3
4
5
6#ifndef SCMI_SMT_H
7#define SCMI_SMT_H
8
9#include <asm/types.h>
10
11
12
13
14
15
16
17
18
19struct scmi_smt_header {
20 __le32 reserved;
21 __le32 channel_status;
22#define SCMI_SHMEM_CHAN_STAT_CHANNEL_ERROR BIT(1)
23#define SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE BIT(0)
24 __le32 reserved1[2];
25 __le32 flags;
26#define SCMI_SHMEM_FLAG_INTR_ENABLED BIT(0)
27 __le32 length;
28 __le32 msg_header;
29 u8 msg_payload[0];
30};
31
32
33
34
35
36
37
38struct scmi_smt_msg_header {
39 __le32 msg_header;
40 u8 msg_payload[0];
41};
42
43#define SMT_HEADER_TOKEN(token) (((token) << 18) & GENMASK(31, 18))
44#define SMT_HEADER_PROTOCOL_ID(proto) (((proto) << 10) & GENMASK(17, 10))
45#define SMT_HEADER_MESSAGE_TYPE(type) (((type) << 18) & GENMASK(9, 8))
46#define SMT_HEADER_MESSAGE_ID(id) ((id) & GENMASK(7, 0))
47
48
49
50
51
52
53struct scmi_smt {
54 u8 *buf;
55 size_t size;
56};
57
58static inline bool scmi_smt_channel_is_free(struct scmi_smt *smt)
59{
60 struct scmi_smt_header *hdr = (void *)smt->buf;
61
62 return hdr->channel_status & SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE;
63}
64
65static inline bool scmi_smt_channel_reports_error(struct scmi_smt *smt)
66{
67 struct scmi_smt_header *hdr = (void *)smt->buf;
68
69 return hdr->channel_status & SCMI_SHMEM_CHAN_STAT_CHANNEL_ERROR;
70}
71
72static inline void scmi_smt_get_channel(struct scmi_smt *smt)
73{
74 struct scmi_smt_header *hdr = (void *)smt->buf;
75
76 hdr->channel_status &= ~SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE;
77}
78
79static inline void scmi_smt_put_channel(struct scmi_smt *smt)
80{
81 struct scmi_smt_header *hdr = (void *)smt->buf;
82
83 hdr->channel_status |= SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE;
84 hdr->channel_status &= ~SCMI_SHMEM_CHAN_STAT_CHANNEL_ERROR;
85}
86
87int scmi_dt_get_smt_buffer(struct udevice *dev, struct scmi_smt *smt);
88
89
90
91
92
93
94
95int scmi_write_msg_to_smt(struct udevice *dev, struct scmi_smt *smt,
96 struct scmi_msg *msg);
97
98
99
100
101
102
103
104int scmi_read_resp_from_smt(struct udevice *dev, struct scmi_smt *smt,
105 struct scmi_msg *msg);
106
107void scmi_clear_smt_channel(struct scmi_smt *smt);
108
109
110
111
112
113
114
115
116int scmi_msg_to_smt_msg(struct udevice *dev, struct scmi_smt *smt,
117 struct scmi_msg *msg, size_t *buf_size);
118
119
120
121
122
123
124
125
126int scmi_msg_from_smt_msg(struct udevice *dev, struct scmi_smt *smt,
127 struct scmi_msg *msg, size_t buf_size);
128
129#endif
130