2 * Remote processor messaging
4 * Copyright(c) 2011 Texas Instruments. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name Texas Instruments nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef _LINUX_RPMSG_H
34 #define _LINUX_RPMSG_H
36 #include <linux/types.h>
37 #include <linux/device.h>
38 #include <linux/mod_devicetable.h>
40 /* The feature bitmap for virtio rpmsg */
41 #define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */
46 * ... keep documenting ...
63 char name
[RPMSG_NAME_SIZE
];
74 VPROC_STATIC_CHANNELS
,
77 #define RPMSG_ADDR_ANY 0xFFFFFFFF
82 * rpmsg_channel - rpmsg channels are the devices of the rpmsg bus
84 * @vrp: the remote processor this channel connects to
85 * @dev: underlying device
86 * @id: the device type identification (used to match an rpmsg driver)
87 * @src: local address of this channel
88 * @dst: destination address of the remote service
89 * @priv: private pointer for the driver's use.
90 * @ept: local rpmsg endpoint of this channel
91 * @announce: need to tell remoteproc about channel creation/removal
93 struct rpmsg_channel
{
94 struct virtproc_info
*vrp
;
96 struct rpmsg_device_id id
;
100 struct rpmsg_endpoint
*ept
;
104 struct rpmsg_channel_info
{
105 char name
[RPMSG_NAME_SIZE
];
111 * struct rpmsg_endpoint
115 * @src: local rpmsg address
118 struct rpmsg_endpoint
{
119 struct rpmsg_channel
*rpdev
;
120 void (*cb
)(struct rpmsg_channel
*, void *, int, void *, u32
);
126 * rpmsg_driver - operations for a rpmsg I/O driver
127 * @driver: underlying device driver (populate name and owner).
128 * @id_table: the ids serviced by this driver.
129 * @probe: the function to call when a device is found. Returns 0 or -errno.
130 * @remove: the function when a device is removed.
131 * @callback: invoked when a message is received on the channel
133 struct rpmsg_driver
{
134 struct device_driver drv
;
135 const struct rpmsg_device_id
*id_table
;
136 int (*probe
)(struct rpmsg_channel
*dev
);
137 void (*remove
)(struct rpmsg_channel
*dev
);
138 void (*callback
)(struct rpmsg_channel
*, void *, int, void *, u32
);
141 int register_rpmsg_device(struct rpmsg_channel
*dev
);
142 void unregister_rpmsg_device(struct rpmsg_channel
*dev
);
143 int register_rpmsg_driver(struct rpmsg_driver
*drv
);
144 void unregister_rpmsg_driver(struct rpmsg_driver
*drv
);
145 void rpmsg_destroy_ept(struct rpmsg_endpoint
*);
146 struct rpmsg_endpoint
*rpmsg_create_ept(struct rpmsg_channel
*,
147 void (*cb
)(struct rpmsg_channel
*, void *, int, void *, u32
),
148 void *priv
, u32 addr
);
151 rpmsg_send_offchannel_raw(struct rpmsg_channel
*, u32
, u32
, void *, int, bool);
154 int rpmsg_send_offchannel(struct rpmsg_channel
*rpdev
, u32 src
, u32 dst
,
157 return rpmsg_send_offchannel_raw(rpdev
, src
, dst
, data
, len
, true);
160 static inline int rpmsg_send(struct rpmsg_channel
*rpdev
, void *data
, int len
)
162 return rpmsg_send_offchannel(rpdev
, rpdev
->src
, rpdev
->dst
, data
, len
);
166 int rpmsg_sendto(struct rpmsg_channel
*rpdev
, void *data
, int len
, u32 dst
)
168 return rpmsg_send_offchannel(rpdev
, rpdev
->src
, dst
, data
, len
);
172 int rpmsg_trysend_offchannel(struct rpmsg_channel
*rpdev
, u32 src
, u32 dst
,
175 return rpmsg_send_offchannel_raw(rpdev
, src
, dst
, data
, len
, false);
179 int rpmsg_trysend(struct rpmsg_channel
*rpdev
, void *data
, int len
)
181 return rpmsg_trysend_offchannel(rpdev
, rpdev
->src
, rpdev
->dst
,
186 int rpmsg_trysendto(struct rpmsg_channel
*rpdev
, void *data
, int len
, u32 dst
)
188 return rpmsg_trysend_offchannel(rpdev
, rpdev
->src
, dst
, data
, len
);
191 #endif /* _LINUX_RPMSG_H */