diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-06 20:03:49 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-06 20:03:49 -0400 |
| commit | 521f3970853a4b2ff7f833763532bdba2ea11257 (patch) | |
| tree | 671b7ae7f048c8ae1a00ad1e491716563dc236cf /include | |
| parent | d880e5ad0df3c2e1d69bb356737a46abb5087d42 (diff) | |
| parent | 395317bbc200fbc164e65cc8ec31fa9d766aeaf1 (diff) | |
Merge tag 'rpmsg-v4.9' of git://github.com/andersson/remoteproc
Pull rpmsg updates from Bjorn Andersson:
"The bulk of these patches involve splitting the rpmsg implementation
into a framework/API part and a virtio specific backend part. It then
adds the Qualcomm Shared Memory Device (SMD) as an additional
supported wire format.
Also included is a set of code style cleanups that have been lingering
for a while"
* tag 'rpmsg-v4.9' of git://github.com/andersson/remoteproc: (26 commits)
rpmsg: smd: fix dependency on QCOM_SMD=n
rpmsg: Introduce Qualcomm SMD backend
rpmsg: Allow callback to return errors
rpmsg: Move virtio specifics from public header
rpmsg: virtio: Hide vrp pointer from the public API
rpmsg: Hide rpmsg indirection tables
rpmsg: Split rpmsg core and virtio backend
rpmsg: Split off generic tail of create_channel()
rpmsg: Move helper for finding rpmsg devices to core
rpmsg: Move endpoint related interface to rpmsg core
rpmsg: Indirection table for rpmsg_endpoint operations
rpmsg: Move rpmsg_device API to new file
rpmsg: Introduce indirection table for rpmsg_device operations
rpmsg: Clean up rpmsg device vs channel naming
rpmsg: Make rpmsg_create_ept() take channel_info struct
rpmsg: rpmsg_send() operations takes rpmsg_endpoint
rpmsg: Name rpmsg devices based on channel id
rpmsg: Enable matching devices with drivers based on DT
rpmsg: Drop prototypes for non-existing functions
samples/rpmsg: add support for multiple instances
...
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/rpmsg.h | 248 |
1 files changed, 35 insertions, 213 deletions
diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h index ada50ff36da0..452d393cc8dd 100644 --- a/include/linux/rpmsg.h +++ b/include/linux/rpmsg.h | |||
| @@ -41,65 +41,27 @@ | |||
| 41 | #include <linux/kref.h> | 41 | #include <linux/kref.h> |
| 42 | #include <linux/mutex.h> | 42 | #include <linux/mutex.h> |
| 43 | 43 | ||
| 44 | /* The feature bitmap for virtio rpmsg */ | 44 | #define RPMSG_ADDR_ANY 0xFFFFFFFF |
| 45 | #define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */ | 45 | |
| 46 | struct rpmsg_device; | ||
| 47 | struct rpmsg_endpoint; | ||
| 48 | struct rpmsg_device_ops; | ||
| 49 | struct rpmsg_endpoint_ops; | ||
| 46 | 50 | ||
| 47 | /** | 51 | /** |
| 48 | * struct rpmsg_hdr - common header for all rpmsg messages | 52 | * struct rpmsg_channel_info - channel info representation |
| 49 | * @src: source address | 53 | * @name: name of service |
| 54 | * @src: local address | ||
| 50 | * @dst: destination address | 55 | * @dst: destination address |
| 51 | * @reserved: reserved for future use | ||
| 52 | * @len: length of payload (in bytes) | ||
| 53 | * @flags: message flags | ||
| 54 | * @data: @len bytes of message payload data | ||
| 55 | * | ||
| 56 | * Every message sent(/received) on the rpmsg bus begins with this header. | ||
| 57 | */ | 56 | */ |
| 58 | struct rpmsg_hdr { | 57 | struct rpmsg_channel_info { |
| 58 | char name[RPMSG_NAME_SIZE]; | ||
| 59 | u32 src; | 59 | u32 src; |
| 60 | u32 dst; | 60 | u32 dst; |
| 61 | u32 reserved; | ||
| 62 | u16 len; | ||
| 63 | u16 flags; | ||
| 64 | u8 data[0]; | ||
| 65 | } __packed; | ||
| 66 | |||
| 67 | /** | ||
| 68 | * struct rpmsg_ns_msg - dynamic name service announcement message | ||
| 69 | * @name: name of remote service that is published | ||
| 70 | * @addr: address of remote service that is published | ||
| 71 | * @flags: indicates whether service is created or destroyed | ||
| 72 | * | ||
| 73 | * This message is sent across to publish a new service, or announce | ||
| 74 | * about its removal. When we receive these messages, an appropriate | ||
| 75 | * rpmsg channel (i.e device) is created/destroyed. In turn, the ->probe() | ||
| 76 | * or ->remove() handler of the appropriate rpmsg driver will be invoked | ||
| 77 | * (if/as-soon-as one is registered). | ||
| 78 | */ | ||
| 79 | struct rpmsg_ns_msg { | ||
| 80 | char name[RPMSG_NAME_SIZE]; | ||
| 81 | u32 addr; | ||
| 82 | u32 flags; | ||
| 83 | } __packed; | ||
| 84 | |||
| 85 | /** | ||
| 86 | * enum rpmsg_ns_flags - dynamic name service announcement flags | ||
| 87 | * | ||
| 88 | * @RPMSG_NS_CREATE: a new remote service was just created | ||
| 89 | * @RPMSG_NS_DESTROY: a known remote service was just destroyed | ||
| 90 | */ | ||
| 91 | enum rpmsg_ns_flags { | ||
| 92 | RPMSG_NS_CREATE = 0, | ||
| 93 | RPMSG_NS_DESTROY = 1, | ||
| 94 | }; | 61 | }; |
| 95 | 62 | ||
| 96 | #define RPMSG_ADDR_ANY 0xFFFFFFFF | ||
| 97 | |||
| 98 | struct virtproc_info; | ||
| 99 | |||
| 100 | /** | 63 | /** |
| 101 | * rpmsg_channel - devices that belong to the rpmsg bus are called channels | 64 | * rpmsg_device - device that belong to the rpmsg bus |
| 102 | * @vrp: the remote processor this channel belongs to | ||
| 103 | * @dev: the device struct | 65 | * @dev: the device struct |
| 104 | * @id: device id (used to match between rpmsg drivers and devices) | 66 | * @id: device id (used to match between rpmsg drivers and devices) |
| 105 | * @src: local address | 67 | * @src: local address |
| @@ -107,17 +69,18 @@ struct virtproc_info; | |||
| 107 | * @ept: the rpmsg endpoint of this channel | 69 | * @ept: the rpmsg endpoint of this channel |
| 108 | * @announce: if set, rpmsg will announce the creation/removal of this channel | 70 | * @announce: if set, rpmsg will announce the creation/removal of this channel |
| 109 | */ | 71 | */ |
| 110 | struct rpmsg_channel { | 72 | struct rpmsg_device { |
| 111 | struct virtproc_info *vrp; | ||
| 112 | struct device dev; | 73 | struct device dev; |
| 113 | struct rpmsg_device_id id; | 74 | struct rpmsg_device_id id; |
| 114 | u32 src; | 75 | u32 src; |
| 115 | u32 dst; | 76 | u32 dst; |
| 116 | struct rpmsg_endpoint *ept; | 77 | struct rpmsg_endpoint *ept; |
| 117 | bool announce; | 78 | bool announce; |
| 79 | |||
| 80 | const struct rpmsg_device_ops *ops; | ||
| 118 | }; | 81 | }; |
| 119 | 82 | ||
| 120 | typedef void (*rpmsg_rx_cb_t)(struct rpmsg_channel *, void *, int, void *, u32); | 83 | typedef int (*rpmsg_rx_cb_t)(struct rpmsg_device *, void *, int, void *, u32); |
| 121 | 84 | ||
| 122 | /** | 85 | /** |
| 123 | * struct rpmsg_endpoint - binds a local rpmsg address to its user | 86 | * struct rpmsg_endpoint - binds a local rpmsg address to its user |
| @@ -143,12 +106,14 @@ typedef void (*rpmsg_rx_cb_t)(struct rpmsg_channel *, void *, int, void *, u32); | |||
| 143 | * create additional endpoints by themselves (see rpmsg_create_ept()). | 106 | * create additional endpoints by themselves (see rpmsg_create_ept()). |
| 144 | */ | 107 | */ |
| 145 | struct rpmsg_endpoint { | 108 | struct rpmsg_endpoint { |
| 146 | struct rpmsg_channel *rpdev; | 109 | struct rpmsg_device *rpdev; |
| 147 | struct kref refcount; | 110 | struct kref refcount; |
| 148 | rpmsg_rx_cb_t cb; | 111 | rpmsg_rx_cb_t cb; |
| 149 | struct mutex cb_lock; | 112 | struct mutex cb_lock; |
| 150 | u32 addr; | 113 | u32 addr; |
| 151 | void *priv; | 114 | void *priv; |
| 115 | |||
| 116 | const struct rpmsg_endpoint_ops *ops; | ||
| 152 | }; | 117 | }; |
| 153 | 118 | ||
| 154 | /** | 119 | /** |
| @@ -162,20 +127,19 @@ struct rpmsg_endpoint { | |||
| 162 | struct rpmsg_driver { | 127 | struct rpmsg_driver { |
| 163 | struct device_driver drv; | 128 | struct device_driver drv; |
| 164 | const struct rpmsg_device_id *id_table; | 129 | const struct rpmsg_device_id *id_table; |
| 165 | int (*probe)(struct rpmsg_channel *dev); | 130 | int (*probe)(struct rpmsg_device *dev); |
| 166 | void (*remove)(struct rpmsg_channel *dev); | 131 | void (*remove)(struct rpmsg_device *dev); |
| 167 | void (*callback)(struct rpmsg_channel *, void *, int, void *, u32); | 132 | int (*callback)(struct rpmsg_device *, void *, int, void *, u32); |
| 168 | }; | 133 | }; |
| 169 | 134 | ||
| 170 | int register_rpmsg_device(struct rpmsg_channel *dev); | 135 | int register_rpmsg_device(struct rpmsg_device *dev); |
| 171 | void unregister_rpmsg_device(struct rpmsg_channel *dev); | 136 | void unregister_rpmsg_device(struct rpmsg_device *dev); |
| 172 | int __register_rpmsg_driver(struct rpmsg_driver *drv, struct module *owner); | 137 | int __register_rpmsg_driver(struct rpmsg_driver *drv, struct module *owner); |
| 173 | void unregister_rpmsg_driver(struct rpmsg_driver *drv); | 138 | void unregister_rpmsg_driver(struct rpmsg_driver *drv); |
| 174 | void rpmsg_destroy_ept(struct rpmsg_endpoint *); | 139 | void rpmsg_destroy_ept(struct rpmsg_endpoint *); |
| 175 | struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_channel *, | 140 | struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *, |
| 176 | rpmsg_rx_cb_t cb, void *priv, u32 addr); | 141 | rpmsg_rx_cb_t cb, void *priv, |
| 177 | int | 142 | struct rpmsg_channel_info chinfo); |
| 178 | rpmsg_send_offchannel_raw(struct rpmsg_channel *, u32, u32, void *, int, bool); | ||
| 179 | 143 | ||
| 180 | /* use a macro to avoid include chaining to get THIS_MODULE */ | 144 | /* use a macro to avoid include chaining to get THIS_MODULE */ |
| 181 | #define register_rpmsg_driver(drv) \ | 145 | #define register_rpmsg_driver(drv) \ |
| @@ -193,156 +157,14 @@ rpmsg_send_offchannel_raw(struct rpmsg_channel *, u32, u32, void *, int, bool); | |||
| 193 | module_driver(__rpmsg_driver, register_rpmsg_driver, \ | 157 | module_driver(__rpmsg_driver, register_rpmsg_driver, \ |
| 194 | unregister_rpmsg_driver) | 158 | unregister_rpmsg_driver) |
| 195 | 159 | ||
| 196 | /** | 160 | int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len); |
| 197 | * rpmsg_send() - send a message across to the remote processor | 161 | int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst); |
| 198 | * @rpdev: the rpmsg channel | 162 | int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, |
| 199 | * @data: payload of message | 163 | void *data, int len); |
| 200 | * @len: length of payload | ||
| 201 | * | ||
| 202 | * This function sends @data of length @len on the @rpdev channel. | ||
| 203 | * The message will be sent to the remote processor which the @rpdev | ||
| 204 | * channel belongs to, using @rpdev's source and destination addresses. | ||
| 205 | * In case there are no TX buffers available, the function will block until | ||
| 206 | * one becomes available, or a timeout of 15 seconds elapses. When the latter | ||
| 207 | * happens, -ERESTARTSYS is returned. | ||
| 208 | * | ||
| 209 | * Can only be called from process context (for now). | ||
| 210 | * | ||
| 211 | * Returns 0 on success and an appropriate error value on failure. | ||
| 212 | */ | ||
| 213 | static inline int rpmsg_send(struct rpmsg_channel *rpdev, void *data, int len) | ||
| 214 | { | ||
| 215 | u32 src = rpdev->src, dst = rpdev->dst; | ||
| 216 | |||
| 217 | return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, true); | ||
| 218 | } | ||
| 219 | |||
| 220 | /** | ||
| 221 | * rpmsg_sendto() - send a message across to the remote processor, specify dst | ||
| 222 | * @rpdev: the rpmsg channel | ||
| 223 | * @data: payload of message | ||
| 224 | * @len: length of payload | ||
| 225 | * @dst: destination address | ||
| 226 | * | ||
| 227 | * This function sends @data of length @len to the remote @dst address. | ||
| 228 | * The message will be sent to the remote processor which the @rpdev | ||
| 229 | * channel belongs to, using @rpdev's source address. | ||
| 230 | * In case there are no TX buffers available, the function will block until | ||
| 231 | * one becomes available, or a timeout of 15 seconds elapses. When the latter | ||
| 232 | * happens, -ERESTARTSYS is returned. | ||
| 233 | * | ||
| 234 | * Can only be called from process context (for now). | ||
| 235 | * | ||
| 236 | * Returns 0 on success and an appropriate error value on failure. | ||
| 237 | */ | ||
| 238 | static inline | ||
| 239 | int rpmsg_sendto(struct rpmsg_channel *rpdev, void *data, int len, u32 dst) | ||
| 240 | { | ||
| 241 | u32 src = rpdev->src; | ||
| 242 | |||
| 243 | return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, true); | ||
| 244 | } | ||
| 245 | |||
| 246 | /** | ||
| 247 | * rpmsg_send_offchannel() - send a message using explicit src/dst addresses | ||
| 248 | * @rpdev: the rpmsg channel | ||
| 249 | * @src: source address | ||
| 250 | * @dst: destination address | ||
| 251 | * @data: payload of message | ||
| 252 | * @len: length of payload | ||
| 253 | * | ||
| 254 | * This function sends @data of length @len to the remote @dst address, | ||
| 255 | * and uses @src as the source address. | ||
| 256 | * The message will be sent to the remote processor which the @rpdev | ||
| 257 | * channel belongs to. | ||
| 258 | * In case there are no TX buffers available, the function will block until | ||
| 259 | * one becomes available, or a timeout of 15 seconds elapses. When the latter | ||
| 260 | * happens, -ERESTARTSYS is returned. | ||
| 261 | * | ||
| 262 | * Can only be called from process context (for now). | ||
| 263 | * | ||
| 264 | * Returns 0 on success and an appropriate error value on failure. | ||
| 265 | */ | ||
| 266 | static inline | ||
| 267 | int rpmsg_send_offchannel(struct rpmsg_channel *rpdev, u32 src, u32 dst, | ||
| 268 | void *data, int len) | ||
| 269 | { | ||
| 270 | return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, true); | ||
| 271 | } | ||
| 272 | |||
| 273 | /** | ||
| 274 | * rpmsg_send() - send a message across to the remote processor | ||
| 275 | * @rpdev: the rpmsg channel | ||
| 276 | * @data: payload of message | ||
| 277 | * @len: length of payload | ||
| 278 | * | ||
| 279 | * This function sends @data of length @len on the @rpdev channel. | ||
| 280 | * The message will be sent to the remote processor which the @rpdev | ||
| 281 | * channel belongs to, using @rpdev's source and destination addresses. | ||
| 282 | * In case there are no TX buffers available, the function will immediately | ||
| 283 | * return -ENOMEM without waiting until one becomes available. | ||
| 284 | * | ||
| 285 | * Can only be called from process context (for now). | ||
| 286 | * | ||
| 287 | * Returns 0 on success and an appropriate error value on failure. | ||
| 288 | */ | ||
| 289 | static inline | ||
| 290 | int rpmsg_trysend(struct rpmsg_channel *rpdev, void *data, int len) | ||
| 291 | { | ||
| 292 | u32 src = rpdev->src, dst = rpdev->dst; | ||
| 293 | 164 | ||
| 294 | return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, false); | 165 | int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len); |
| 295 | } | 166 | int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst); |
| 296 | 167 | int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, | |
| 297 | /** | 168 | void *data, int len); |
| 298 | * rpmsg_sendto() - send a message across to the remote processor, specify dst | ||
| 299 | * @rpdev: the rpmsg channel | ||
| 300 | * @data: payload of message | ||
| 301 | * @len: length of payload | ||
| 302 | * @dst: destination address | ||
| 303 | * | ||
| 304 | * This function sends @data of length @len to the remote @dst address. | ||
| 305 | * The message will be sent to the remote processor which the @rpdev | ||
| 306 | * channel belongs to, using @rpdev's source address. | ||
| 307 | * In case there are no TX buffers available, the function will immediately | ||
| 308 | * return -ENOMEM without waiting until one becomes available. | ||
| 309 | * | ||
| 310 | * Can only be called from process context (for now). | ||
| 311 | * | ||
| 312 | * Returns 0 on success and an appropriate error value on failure. | ||
| 313 | */ | ||
| 314 | static inline | ||
| 315 | int rpmsg_trysendto(struct rpmsg_channel *rpdev, void *data, int len, u32 dst) | ||
| 316 | { | ||
| 317 | u32 src = rpdev->src; | ||
| 318 | |||
| 319 | return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, false); | ||
| 320 | } | ||
| 321 | |||
| 322 | /** | ||
| 323 | * rpmsg_send_offchannel() - send a message using explicit src/dst addresses | ||
| 324 | * @rpdev: the rpmsg channel | ||
| 325 | * @src: source address | ||
| 326 | * @dst: destination address | ||
| 327 | * @data: payload of message | ||
| 328 | * @len: length of payload | ||
| 329 | * | ||
| 330 | * This function sends @data of length @len to the remote @dst address, | ||
| 331 | * and uses @src as the source address. | ||
| 332 | * The message will be sent to the remote processor which the @rpdev | ||
| 333 | * channel belongs to. | ||
| 334 | * In case there are no TX buffers available, the function will immediately | ||
| 335 | * return -ENOMEM without waiting until one becomes available. | ||
| 336 | * | ||
| 337 | * Can only be called from process context (for now). | ||
| 338 | * | ||
| 339 | * Returns 0 on success and an appropriate error value on failure. | ||
| 340 | */ | ||
| 341 | static inline | ||
| 342 | int rpmsg_trysend_offchannel(struct rpmsg_channel *rpdev, u32 src, u32 dst, | ||
| 343 | void *data, int len) | ||
| 344 | { | ||
| 345 | return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, false); | ||
| 346 | } | ||
| 347 | 169 | ||
| 348 | #endif /* _LINUX_RPMSG_H */ | 170 | #endif /* _LINUX_RPMSG_H */ |
