1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35#ifndef _LINUX_RPMSG_H
36#define _LINUX_RPMSG_H
37
38#include <linux/types.h>
39#include <linux/device.h>
40#include <linux/err.h>
41#include <linux/mod_devicetable.h>
42#include <linux/kref.h>
43#include <linux/mutex.h>
44#include <linux/poll.h>
45
46#define RPMSG_ADDR_ANY 0xFFFFFFFF
47
48struct rpmsg_device;
49struct rpmsg_endpoint;
50struct rpmsg_device_ops;
51struct rpmsg_endpoint_ops;
52
53
54
55
56
57
58
59struct rpmsg_channel_info {
60 char name[RPMSG_NAME_SIZE];
61 u32 src;
62 u32 dst;
63};
64
65
66
67
68
69
70
71
72
73
74
75struct rpmsg_device {
76 struct device dev;
77 struct rpmsg_device_id id;
78 char *driver_override;
79 u32 src;
80 u32 dst;
81 struct rpmsg_endpoint *ept;
82 bool announce;
83
84 const struct rpmsg_device_ops *ops;
85};
86
87typedef int (*rpmsg_rx_cb_t)(struct rpmsg_device *, void *, int, void *, u32);
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112struct rpmsg_endpoint {
113 struct rpmsg_device *rpdev;
114 struct kref refcount;
115 rpmsg_rx_cb_t cb;
116 struct mutex cb_lock;
117 u32 addr;
118 void *priv;
119
120 const struct rpmsg_endpoint_ops *ops;
121};
122
123
124
125
126
127
128
129
130
131struct rpmsg_driver {
132 struct device_driver drv;
133 const struct rpmsg_device_id *id_table;
134 int (*probe)(struct rpmsg_device *dev);
135 void (*remove)(struct rpmsg_device *dev);
136 int (*callback)(struct rpmsg_device *, void *, int, void *, u32);
137};
138
139#if IS_ENABLED(CONFIG_RPMSG)
140
141int register_rpmsg_device(struct rpmsg_device *dev);
142void unregister_rpmsg_device(struct rpmsg_device *dev);
143int __register_rpmsg_driver(struct rpmsg_driver *drv, struct module *owner);
144void unregister_rpmsg_driver(struct rpmsg_driver *drv);
145void rpmsg_destroy_ept(struct rpmsg_endpoint *);
146struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *,
147 rpmsg_rx_cb_t cb, void *priv,
148 struct rpmsg_channel_info chinfo);
149
150int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len);
151int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst);
152int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst,
153 void *data, int len);
154
155int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len);
156int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst);
157int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst,
158 void *data, int len);
159
160unsigned int rpmsg_poll(struct rpmsg_endpoint *ept, struct file *filp,
161 poll_table *wait);
162
163#else
164
165static inline int register_rpmsg_device(struct rpmsg_device *dev)
166{
167 return -ENXIO;
168}
169
170static inline void unregister_rpmsg_device(struct rpmsg_device *dev)
171{
172
173 WARN_ON(1);
174}
175
176static inline int __register_rpmsg_driver(struct rpmsg_driver *drv,
177 struct module *owner)
178{
179
180 WARN_ON(1);
181
182 return -ENXIO;
183}
184
185static inline void unregister_rpmsg_driver(struct rpmsg_driver *drv)
186{
187
188 WARN_ON(1);
189}
190
191static inline void rpmsg_destroy_ept(struct rpmsg_endpoint *ept)
192{
193
194 WARN_ON(1);
195}
196
197static inline struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *rpdev,
198 rpmsg_rx_cb_t cb,
199 void *priv,
200 struct rpmsg_channel_info chinfo)
201{
202
203 WARN_ON(1);
204
205 return ERR_PTR(-ENXIO);
206}
207
208static inline int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len)
209{
210
211 WARN_ON(1);
212
213 return -ENXIO;
214}
215
216static inline int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len,
217 u32 dst)
218{
219
220 WARN_ON(1);
221
222 return -ENXIO;
223
224}
225
226static inline int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src,
227 u32 dst, void *data, int len)
228{
229
230 WARN_ON(1);
231
232 return -ENXIO;
233}
234
235static inline int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len)
236{
237
238 WARN_ON(1);
239
240 return -ENXIO;
241}
242
243static inline int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data,
244 int len, u32 dst)
245{
246
247 WARN_ON(1);
248
249 return -ENXIO;
250}
251
252static inline int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src,
253 u32 dst, void *data, int len)
254{
255
256 WARN_ON(1);
257
258 return -ENXIO;
259}
260
261static inline unsigned int rpmsg_poll(struct rpmsg_endpoint *ept,
262 struct file *filp, poll_table *wait)
263{
264
265 WARN_ON(1);
266
267 return 0;
268}
269
270#endif
271
272
273#define register_rpmsg_driver(drv) \
274 __register_rpmsg_driver(drv, THIS_MODULE)
275
276
277
278
279
280
281
282
283
284#define module_rpmsg_driver(__rpmsg_driver) \
285 module_driver(__rpmsg_driver, register_rpmsg_driver, \
286 unregister_rpmsg_driver)
287
288#endif
289