diff options
author | Bjorn Andersson <bjorn.andersson@linaro.org> | 2016-09-01 18:27:59 -0400 |
---|---|---|
committer | Bjorn Andersson <bjorn.andersson@linaro.org> | 2016-09-09 01:15:21 -0400 |
commit | 026dad47a814cd32aad6174a8f1218b020a277b1 (patch) | |
tree | 3f315c34f6cb05e1ae6e4bfcec0fcd5a9a7e332c | |
parent | 36b72c7dca718717108120cdff7b56258a8862b4 (diff) |
rpmsg: Move rpmsg_device API to new file
Extract the now indirect rpmsg_create_ept() interface to a separate
file and start building up a rpmsg core.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
-rw-r--r-- | drivers/remoteproc/Kconfig | 4 | ||||
-rw-r--r-- | drivers/rpmsg/Kconfig | 4 | ||||
-rw-r--r-- | drivers/rpmsg/Makefile | 3 | ||||
-rw-r--r-- | drivers/rpmsg/rpmsg_core.c | 71 | ||||
-rw-r--r-- | drivers/rpmsg/virtio_rpmsg_bus.c | 48 |
5 files changed, 79 insertions, 51 deletions
diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index 1a8bf76a925f..70ec8130622d 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig | |||
@@ -17,7 +17,7 @@ config OMAP_REMOTEPROC | |||
17 | select REMOTEPROC | 17 | select REMOTEPROC |
18 | select MAILBOX | 18 | select MAILBOX |
19 | select OMAP2PLUS_MBOX | 19 | select OMAP2PLUS_MBOX |
20 | select RPMSG | 20 | select RPMSG_VIRTIO |
21 | help | 21 | help |
22 | Say y here to support OMAP's remote processors (dual M3 | 22 | Say y here to support OMAP's remote processors (dual M3 |
23 | and DSP on OMAP4) via the remote processor framework. | 23 | and DSP on OMAP4) via the remote processor framework. |
@@ -59,7 +59,7 @@ config DA8XX_REMOTEPROC | |||
59 | depends on ARCH_DAVINCI_DA8XX | 59 | depends on ARCH_DAVINCI_DA8XX |
60 | select CMA if MMU | 60 | select CMA if MMU |
61 | select REMOTEPROC | 61 | select REMOTEPROC |
62 | select RPMSG | 62 | select RPMSG_VIRTIO |
63 | help | 63 | help |
64 | Say y here to support DA8xx/OMAP-L13x remote processors via the | 64 | Say y here to support DA8xx/OMAP-L13x remote processors via the |
65 | remote processor framework. | 65 | remote processor framework. |
diff --git a/drivers/rpmsg/Kconfig b/drivers/rpmsg/Kconfig index 69a219387582..40614be88c97 100644 --- a/drivers/rpmsg/Kconfig +++ b/drivers/rpmsg/Kconfig | |||
@@ -3,6 +3,10 @@ menu "Rpmsg drivers" | |||
3 | # RPMSG always gets selected by whoever wants it | 3 | # RPMSG always gets selected by whoever wants it |
4 | config RPMSG | 4 | config RPMSG |
5 | tristate | 5 | tristate |
6 | |||
7 | config RPMSG_VIRTIO | ||
8 | tristate | ||
9 | select RPMSG | ||
6 | select VIRTIO | 10 | select VIRTIO |
7 | select VIRTUALIZATION | 11 | select VIRTUALIZATION |
8 | 12 | ||
diff --git a/drivers/rpmsg/Makefile b/drivers/rpmsg/Makefile index 7617fcb8259f..c48ea55ad380 100644 --- a/drivers/rpmsg/Makefile +++ b/drivers/rpmsg/Makefile | |||
@@ -1 +1,2 @@ | |||
1 | obj-$(CONFIG_RPMSG) += virtio_rpmsg_bus.o | 1 | obj-$(CONFIG_RPMSG) += rpmsg_core.o |
2 | obj-$(CONFIG_RPMSG_VIRTIO) += virtio_rpmsg_bus.o | ||
diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c new file mode 100644 index 000000000000..c511b5d64f89 --- /dev/null +++ b/drivers/rpmsg/rpmsg_core.c | |||
@@ -0,0 +1,71 @@ | |||
1 | /* | ||
2 | * remote processor messaging bus | ||
3 | * | ||
4 | * Copyright (C) 2011 Texas Instruments, Inc. | ||
5 | * Copyright (C) 2011 Google, Inc. | ||
6 | * | ||
7 | * Ohad Ben-Cohen <ohad@wizery.com> | ||
8 | * Brian Swetland <swetland@google.com> | ||
9 | * | ||
10 | * This software is licensed under the terms of the GNU General Public | ||
11 | * License version 2, as published by the Free Software Foundation, and | ||
12 | * may be copied, distributed, and modified under those terms. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | */ | ||
19 | |||
20 | #define pr_fmt(fmt) "%s: " fmt, __func__ | ||
21 | |||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/rpmsg.h> | ||
24 | |||
25 | /** | ||
26 | * rpmsg_create_ept() - create a new rpmsg_endpoint | ||
27 | * @rpdev: rpmsg channel device | ||
28 | * @cb: rx callback handler | ||
29 | * @priv: private data for the driver's use | ||
30 | * @chinfo: channel_info with the local rpmsg address to bind with @cb | ||
31 | * | ||
32 | * Every rpmsg address in the system is bound to an rx callback (so when | ||
33 | * inbound messages arrive, they are dispatched by the rpmsg bus using the | ||
34 | * appropriate callback handler) by means of an rpmsg_endpoint struct. | ||
35 | * | ||
36 | * This function allows drivers to create such an endpoint, and by that, | ||
37 | * bind a callback, and possibly some private data too, to an rpmsg address | ||
38 | * (either one that is known in advance, or one that will be dynamically | ||
39 | * assigned for them). | ||
40 | * | ||
41 | * Simple rpmsg drivers need not call rpmsg_create_ept, because an endpoint | ||
42 | * is already created for them when they are probed by the rpmsg bus | ||
43 | * (using the rx callback provided when they registered to the rpmsg bus). | ||
44 | * | ||
45 | * So things should just work for simple drivers: they already have an | ||
46 | * endpoint, their rx callback is bound to their rpmsg address, and when | ||
47 | * relevant inbound messages arrive (i.e. messages which their dst address | ||
48 | * equals to the src address of their rpmsg channel), the driver's handler | ||
49 | * is invoked to process it. | ||
50 | * | ||
51 | * That said, more complicated drivers might do need to allocate | ||
52 | * additional rpmsg addresses, and bind them to different rx callbacks. | ||
53 | * To accomplish that, those drivers need to call this function. | ||
54 | * | ||
55 | * Drivers should provide their @rpdev channel (so the new endpoint would belong | ||
56 | * to the same remote processor their channel belongs to), an rx callback | ||
57 | * function, an optional private data (which is provided back when the | ||
58 | * rx callback is invoked), and an address they want to bind with the | ||
59 | * callback. If @addr is RPMSG_ADDR_ANY, then rpmsg_create_ept will | ||
60 | * dynamically assign them an available rpmsg address (drivers should have | ||
61 | * a very good reason why not to always use RPMSG_ADDR_ANY here). | ||
62 | * | ||
63 | * Returns a pointer to the endpoint on success, or NULL on error. | ||
64 | */ | ||
65 | struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *rpdev, | ||
66 | rpmsg_rx_cb_t cb, void *priv, | ||
67 | struct rpmsg_channel_info chinfo) | ||
68 | { | ||
69 | return rpdev->ops->create_ept(rpdev, cb, priv, chinfo); | ||
70 | } | ||
71 | EXPORT_SYMBOL(rpmsg_create_ept); | ||
diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index 088203ed1df8..605e09c96d65 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c | |||
@@ -242,54 +242,6 @@ free_ept: | |||
242 | return NULL; | 242 | return NULL; |
243 | } | 243 | } |
244 | 244 | ||
245 | /** | ||
246 | * rpmsg_create_ept() - create a new rpmsg_endpoint | ||
247 | * @rpdev: rpmsg channel device | ||
248 | * @cb: rx callback handler | ||
249 | * @priv: private data for the driver's use | ||
250 | * @chinfo: channel_info with the local rpmsg address to bind with @cb | ||
251 | * | ||
252 | * Every rpmsg address in the system is bound to an rx callback (so when | ||
253 | * inbound messages arrive, they are dispatched by the rpmsg bus using the | ||
254 | * appropriate callback handler) by means of an rpmsg_endpoint struct. | ||
255 | * | ||
256 | * This function allows drivers to create such an endpoint, and by that, | ||
257 | * bind a callback, and possibly some private data too, to an rpmsg address | ||
258 | * (either one that is known in advance, or one that will be dynamically | ||
259 | * assigned for them). | ||
260 | * | ||
261 | * Simple rpmsg drivers need not call rpmsg_create_ept, because an endpoint | ||
262 | * is already created for them when they are probed by the rpmsg bus | ||
263 | * (using the rx callback provided when they registered to the rpmsg bus). | ||
264 | * | ||
265 | * So things should just work for simple drivers: they already have an | ||
266 | * endpoint, their rx callback is bound to their rpmsg address, and when | ||
267 | * relevant inbound messages arrive (i.e. messages which their dst address | ||
268 | * equals to the src address of their rpmsg channel), the driver's handler | ||
269 | * is invoked to process it. | ||
270 | * | ||
271 | * That said, more complicated drivers might do need to allocate | ||
272 | * additional rpmsg addresses, and bind them to different rx callbacks. | ||
273 | * To accomplish that, those drivers need to call this function. | ||
274 | * | ||
275 | * Drivers should provide their @rpdev channel (so the new endpoint would belong | ||
276 | * to the same remote processor their channel belongs to), an rx callback | ||
277 | * function, an optional private data (which is provided back when the | ||
278 | * rx callback is invoked), and an address they want to bind with the | ||
279 | * callback. If @addr is RPMSG_ADDR_ANY, then rpmsg_create_ept will | ||
280 | * dynamically assign them an available rpmsg address (drivers should have | ||
281 | * a very good reason why not to always use RPMSG_ADDR_ANY here). | ||
282 | * | ||
283 | * Returns a pointer to the endpoint on success, or NULL on error. | ||
284 | */ | ||
285 | struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *rpdev, | ||
286 | rpmsg_rx_cb_t cb, void *priv, | ||
287 | struct rpmsg_channel_info chinfo) | ||
288 | { | ||
289 | return rpdev->ops->create_ept(rpdev, cb, priv, chinfo); | ||
290 | } | ||
291 | EXPORT_SYMBOL(rpmsg_create_ept); | ||
292 | |||
293 | static struct rpmsg_endpoint *virtio_rpmsg_create_ept(struct rpmsg_device *rpdev, | 245 | static struct rpmsg_endpoint *virtio_rpmsg_create_ept(struct rpmsg_device *rpdev, |
294 | rpmsg_rx_cb_t cb, | 246 | rpmsg_rx_cb_t cb, |
295 | void *priv, | 247 | void *priv, |