Lines Matching +full:rpmsg +full:- +full:in
1 // SPDX-License-Identifier: GPL-2.0
8 * Ohad Ben-Cohen <ohad@wizery.com>
16 #include <linux/rpmsg.h>
24 .name = "rpmsg",
29 * rpmsg_create_channel() - create a new rpmsg channel
31 * @rpdev: rpmsg device
34 * Return: a pointer to the new rpmsg device on success, or NULL on error.
41 if (!rpdev->ops || !rpdev->ops->create_channel) { in rpmsg_create_channel()
42 dev_err(&rpdev->dev, "no create_channel ops found\n"); in rpmsg_create_channel()
46 return rpdev->ops->create_channel(rpdev, chinfo); in rpmsg_create_channel()
51 * rpmsg_release_channel() - release a rpmsg channel
53 * @rpdev: rpmsg device
62 return -EINVAL; in rpmsg_release_channel()
63 if (!rpdev->ops || !rpdev->ops->release_channel) { in rpmsg_release_channel()
64 dev_err(&rpdev->dev, "no release_channel ops found\n"); in rpmsg_release_channel()
65 return -ENXIO; in rpmsg_release_channel()
68 return rpdev->ops->release_channel(rpdev, chinfo); in rpmsg_release_channel()
73 * rpmsg_create_ept() - create a new rpmsg_endpoint
74 * @rpdev: rpmsg channel device
77 * @chinfo: channel_info with the local rpmsg address to bind with @cb
79 * Every rpmsg address in the system is bound to an rx callback (so when
80 * inbound messages arrive, they are dispatched by the rpmsg bus using the
84 * bind a callback, and possibly some private data too, to an rpmsg address
85 * (either one that is known in advance, or one that will be dynamically
88 * Simple rpmsg drivers need not call rpmsg_create_ept, because an endpoint
89 * is already created for them when they are probed by the rpmsg bus
90 * (using the rx callback provided when they registered to the rpmsg bus).
93 * endpoint, their rx callback is bound to their rpmsg address, and when
95 * equals to the src address of their rpmsg channel), the driver's handler
99 * additional rpmsg addresses, and bind them to different rx callbacks.
107 * dynamically assign them an available rpmsg address (drivers should have
119 return rpdev->ops->create_ept(rpdev, cb, priv, chinfo); in rpmsg_create_ept()
124 * rpmsg_destroy_ept() - destroy an existing rpmsg endpoint
127 * Should be used by drivers to destroy an rpmsg endpoint previously
133 if (ept && ept->ops) in rpmsg_destroy_ept()
134 ept->ops->destroy_ept(ept); in rpmsg_destroy_ept()
139 * rpmsg_send() - send a message across to the remote processor
140 * @ept: the rpmsg endpoint
146 * endpoint belongs to, using @ept's address and its associated rpmsg
148 * In case there are no TX buffers available, the function will block until
150 * happens, -ERESTARTSYS is returned.
159 return -EINVAL; in rpmsg_send()
160 if (!ept->ops->send) in rpmsg_send()
161 return -ENXIO; in rpmsg_send()
163 return ept->ops->send(ept, data, len); in rpmsg_send()
168 * rpmsg_sendto() - send a message across to the remote processor, specify dst
169 * @ept: the rpmsg endpoint
177 * In case there are no TX buffers available, the function will block until
179 * happens, -ERESTARTSYS is returned.
188 return -EINVAL; in rpmsg_sendto()
189 if (!ept->ops->sendto) in rpmsg_sendto()
190 return -ENXIO; in rpmsg_sendto()
192 return ept->ops->sendto(ept, data, len, dst); in rpmsg_sendto()
197 * rpmsg_send_offchannel() - send a message using explicit src/dst addresses
198 * @ept: the rpmsg endpoint
208 * In case there are no TX buffers available, the function will block until
210 * happens, -ERESTARTSYS is returned.
220 return -EINVAL; in rpmsg_send_offchannel()
221 if (!ept->ops->send_offchannel) in rpmsg_send_offchannel()
222 return -ENXIO; in rpmsg_send_offchannel()
224 return ept->ops->send_offchannel(ept, src, dst, data, len); in rpmsg_send_offchannel()
229 * rpmsg_trysend() - send a message across to the remote processor
230 * @ept: the rpmsg endpoint
238 * In case there are no TX buffers available, the function will immediately
239 * return -ENOMEM without waiting until one becomes available.
248 return -EINVAL; in rpmsg_trysend()
249 if (!ept->ops->trysend) in rpmsg_trysend()
250 return -ENXIO; in rpmsg_trysend()
252 return ept->ops->trysend(ept, data, len); in rpmsg_trysend()
257 * rpmsg_trysendto() - send a message across to the remote processor, specify dst
258 * @ept: the rpmsg endpoint
266 * In case there are no TX buffers available, the function will immediately
267 * return -ENOMEM without waiting until one becomes available.
276 return -EINVAL; in rpmsg_trysendto()
277 if (!ept->ops->trysendto) in rpmsg_trysendto()
278 return -ENXIO; in rpmsg_trysendto()
280 return ept->ops->trysendto(ept, data, len, dst); in rpmsg_trysendto()
285 * rpmsg_poll() - poll the endpoint's send buffers
286 * @ept: the rpmsg endpoint
297 if (!ept->ops->poll) in rpmsg_poll()
300 return ept->ops->poll(ept, filp, wait); in rpmsg_poll()
305 * rpmsg_trysend_offchannel() - send a message using explicit src/dst addresses
306 * @ept: the rpmsg endpoint
316 * In case there are no TX buffers available, the function will immediately
317 * return -ENOMEM without waiting until one becomes available.
327 return -EINVAL; in rpmsg_trysend_offchannel()
328 if (!ept->ops->trysend_offchannel) in rpmsg_trysend_offchannel()
329 return -ENXIO; in rpmsg_trysend_offchannel()
331 return ept->ops->trysend_offchannel(ept, src, dst, data, len); in rpmsg_trysend_offchannel()
336 * rpmsg_set_flow_control() - request remote to pause/resume transmission
337 * @ept: the rpmsg endpoint
346 return -EINVAL; in rpmsg_set_flow_control()
347 if (!ept->ops->set_flow_control) in rpmsg_set_flow_control()
348 return -EOPNOTSUPP; in rpmsg_set_flow_control()
350 return ept->ops->set_flow_control(ept, pause, dst); in rpmsg_set_flow_control()
355 * rpmsg_get_mtu() - get maximum transmission buffer size for sending message.
356 * @ept: the rpmsg endpoint
367 return -EINVAL; in rpmsg_get_mtu()
368 if (!ept->ops->get_mtu) in rpmsg_get_mtu()
369 return -ENOTSUPP; in rpmsg_get_mtu()
371 return ept->ops->get_mtu(ept); in rpmsg_get_mtu()
376 * match a rpmsg channel with a channel info struct.
377 * this is used to make sure we're not creating rpmsg devices for channels
385 if (chinfo->src != RPMSG_ADDR_ANY && chinfo->src != rpdev->src) in rpmsg_device_match()
388 if (chinfo->dst != RPMSG_ADDR_ANY && chinfo->dst != rpdev->dst) in rpmsg_device_match()
391 if (strncmp(chinfo->name, rpdev->id.name, RPMSG_NAME_SIZE)) in rpmsg_device_match()
414 return sprintf(buf, format_string, rpdev->path); \
429 return -ENOMEM; \
433 old = rpdev->member; \
435 rpdev->member = new; \
438 rpdev->member = NULL; \
452 return sprintf(buf, "%s\n", rpdev->member); \
456 /* for more info, see Documentation/ABI/testing/sysfs-bus-rpmsg */
470 if (len != -ENODEV) in modalias_show()
473 return sprintf(buf, RPMSG_DEVICE_MODALIAS_FMT "\n", rpdev->id.name); in modalias_show()
488 /* rpmsg devices and drivers are matched using the service name */
492 return strncmp(id->name, rpdev->id.name, RPMSG_NAME_SIZE) == 0; in rpmsg_id_match()
495 /* match rpmsg channel and rpmsg driver */
500 const struct rpmsg_device_id *ids = rpdrv->id_table; in rpmsg_dev_match()
503 if (rpdev->driver_override) in rpmsg_dev_match()
504 return !strcmp(rpdev->driver_override, drv->name); in rpmsg_dev_match()
509 rpdev->id.driver_data = ids[i].driver_data; in rpmsg_dev_match()
522 if (ret != -ENODEV) in rpmsg_uevent()
526 rpdev->id.name); in rpmsg_uevent()
530 * when an rpmsg driver is probed with a channel, we seamlessly create
531 * it an endpoint, binding its rx callback to a unique local rpmsg
535 * processor (needed in case the driver is exposing an rpmsg service).
540 struct rpmsg_driver *rpdrv = to_rpmsg_driver(rpdev->dev.driver); in rpmsg_dev_probe()
549 if (rpdrv->callback) { in rpmsg_dev_probe()
550 strscpy(chinfo.name, rpdev->id.name, sizeof(chinfo.name)); in rpmsg_dev_probe()
551 chinfo.src = rpdev->src; in rpmsg_dev_probe()
554 ept = rpmsg_create_ept(rpdev, rpdrv->callback, NULL, chinfo); in rpmsg_dev_probe()
557 err = -ENOMEM; in rpmsg_dev_probe()
561 rpdev->ept = ept; in rpmsg_dev_probe()
562 rpdev->src = ept->addr; in rpmsg_dev_probe()
564 ept->flow_cb = rpdrv->flowcontrol; in rpmsg_dev_probe()
567 err = rpdrv->probe(rpdev); in rpmsg_dev_probe()
573 if (ept && rpdev->ops->announce_create) { in rpmsg_dev_probe()
574 err = rpdev->ops->announce_create(rpdev); in rpmsg_dev_probe()
584 if (rpdrv->remove) in rpmsg_dev_probe()
585 rpdrv->remove(rpdev); in rpmsg_dev_probe()
596 struct rpmsg_driver *rpdrv = to_rpmsg_driver(rpdev->dev.driver); in rpmsg_dev_remove()
598 if (rpdev->ops->announce_destroy) in rpmsg_dev_remove()
599 rpdev->ops->announce_destroy(rpdev); in rpmsg_dev_remove()
601 if (rpdrv->remove) in rpmsg_dev_remove()
602 rpdrv->remove(rpdev); in rpmsg_dev_remove()
606 if (rpdev->ept) in rpmsg_dev_remove()
607 rpmsg_destroy_ept(rpdev->ept); in rpmsg_dev_remove()
611 .name = "rpmsg",
620 * A helper for registering rpmsg device with driver override and name.
626 struct device *dev = &rpdev->dev; in rpmsg_register_device_override()
630 strscpy_pad(rpdev->id.name, driver_override, RPMSG_NAME_SIZE); in rpmsg_register_device_override()
632 dev_set_name(dev, "%s.%s.%d.%d", dev_name(dev->parent), in rpmsg_register_device_override()
633 rpdev->id.name, rpdev->src, rpdev->dst); in rpmsg_register_device_override()
635 dev->bus = &rpmsg_bus; in rpmsg_register_device_override()
639 ret = driver_set_override(dev, &rpdev->driver_override, in rpmsg_register_device_override()
652 kfree(rpdev->driver_override); in rpmsg_register_device_override()
653 rpdev->driver_override = NULL; in rpmsg_register_device_override()
678 return -EINVAL; in rpmsg_unregister_device()
689 * __register_rpmsg_driver() - register an rpmsg driver with the rpmsg bus
697 rpdrv->drv.bus = &rpmsg_bus; in __register_rpmsg_driver()
698 rpdrv->drv.owner = owner; in __register_rpmsg_driver()
699 return driver_register(&rpdrv->drv); in __register_rpmsg_driver()
704 * unregister_rpmsg_driver() - unregister an rpmsg driver from the rpmsg bus
711 driver_unregister(&rpdrv->drv); in unregister_rpmsg_driver()
722 pr_err("failed to register rpmsg class\n"); in rpmsg_init()
728 pr_err("failed to register rpmsg bus: %d\n", ret); in rpmsg_init()