ARM: cpu topology: Add debugfs interface for cpu_power
[cmplus.git] / include / linux / rpmsg.h
blob1f7ba091c50bb1184424d07f91f3afc2f11604c1
1 /*
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
8 * are met:
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
15 * distribution.
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 */
43 /**
44 * struct rpmsg_hdr -
46 * ... keep documenting ...
48 struct rpmsg_hdr {
49 u16 len;
50 u16 flags;
51 u32 src;
52 u32 dst;
53 u32 unused;
54 u8 data[0];
55 } __packed;
57 enum rpmsg_ns_flags {
58 RPMSG_NS_CREATE = 0,
59 RPMSG_NS_DESTROY = 1,
62 struct rpmsg_ns_msg {
63 char name[RPMSG_NAME_SIZE];
64 u32 addr;
65 u32 flags;
66 } __packed;
68 /* driver requests */
69 enum {
70 VPROC_BUF_ADDR,
71 VPROC_BUF_NUM,
72 VPROC_BUF_SZ,
73 VPROC_SIM_BASE,
74 VPROC_STATIC_CHANNELS,
77 #define RPMSG_ADDR_ANY 0xFFFFFFFF
79 struct virtproc_info;
81 /**
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;
95 struct device dev;
96 struct rpmsg_device_id id;
97 u32 src;
98 u32 dst;
99 void *priv;
100 struct rpmsg_endpoint *ept;
101 bool announce;
104 struct rpmsg_channel_info {
105 char name[RPMSG_NAME_SIZE];
106 u32 src;
107 u32 dst;
111 * struct rpmsg_endpoint
113 * @rpdev:
114 * @cb:
115 * @src: local rpmsg address
116 * @priv:
118 struct rpmsg_endpoint {
119 struct rpmsg_channel *rpdev;
120 void (*cb)(struct rpmsg_channel *, void *, int, void *, u32);
121 u32 addr;
122 void *priv;
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);
153 static inline
154 int rpmsg_send_offchannel(struct rpmsg_channel *rpdev, u32 src, u32 dst,
155 void *data, int len)
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);
165 static inline
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);
171 static inline
172 int rpmsg_trysend_offchannel(struct rpmsg_channel *rpdev, u32 src, u32 dst,
173 void *data, int len)
175 return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, false);
178 static inline
179 int rpmsg_trysend(struct rpmsg_channel *rpdev, void *data, int len)
181 return rpmsg_trysend_offchannel(rpdev, rpdev->src, rpdev->dst,
182 data, len);
185 static inline
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 */