Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * remote processor messaging bus internals
0004  *
0005  * Copyright (C) 2011 Texas Instruments, Inc.
0006  * Copyright (C) 2011 Google, Inc.
0007  *
0008  * Ohad Ben-Cohen <ohad@wizery.com>
0009  * Brian Swetland <swetland@google.com>
0010  */
0011 
0012 #ifndef __RPMSG_INTERNAL_H__
0013 #define __RPMSG_INTERNAL_H__
0014 
0015 #include <linux/rpmsg.h>
0016 #include <linux/poll.h>
0017 
0018 #define to_rpmsg_device(d) container_of(d, struct rpmsg_device, dev)
0019 #define to_rpmsg_driver(d) container_of(d, struct rpmsg_driver, drv)
0020 
0021 extern struct class *rpmsg_class;
0022 
0023 /**
0024  * struct rpmsg_device_ops - indirection table for the rpmsg_device operations
0025  * @create_channel: create backend-specific channel, optional
0026  * @release_channel:    release backend-specific channel, optional
0027  * @create_ept:     create backend-specific endpoint, required
0028  * @announce_create:    announce presence of new channel, optional
0029  * @announce_destroy:   announce destruction of channel, optional
0030  *
0031  * Indirection table for the operations that a rpmsg backend should implement.
0032  * @announce_create and @announce_destroy are optional as the backend might
0033  * advertise new channels implicitly by creating the endpoints.
0034  */
0035 struct rpmsg_device_ops {
0036     struct rpmsg_device *(*create_channel)(struct rpmsg_device *rpdev,
0037                            struct rpmsg_channel_info *chinfo);
0038     int (*release_channel)(struct rpmsg_device *rpdev,
0039                    struct rpmsg_channel_info *chinfo);
0040     struct rpmsg_endpoint *(*create_ept)(struct rpmsg_device *rpdev,
0041                         rpmsg_rx_cb_t cb, void *priv,
0042                         struct rpmsg_channel_info chinfo);
0043 
0044     int (*announce_create)(struct rpmsg_device *rpdev);
0045     int (*announce_destroy)(struct rpmsg_device *rpdev);
0046 };
0047 
0048 /**
0049  * struct rpmsg_endpoint_ops - indirection table for rpmsg_endpoint operations
0050  * @destroy_ept:    see @rpmsg_destroy_ept(), required
0051  * @send:       see @rpmsg_send(), required
0052  * @sendto:     see @rpmsg_sendto(), optional
0053  * @send_offchannel:    see @rpmsg_send_offchannel(), optional
0054  * @trysend:        see @rpmsg_trysend(), required
0055  * @trysendto:      see @rpmsg_trysendto(), optional
0056  * @trysend_offchannel: see @rpmsg_trysend_offchannel(), optional
0057  * @poll:       see @rpmsg_poll(), optional
0058  * @get_mtu:        see @rpmsg_get_mtu(), optional
0059  *
0060  * Indirection table for the operations that a rpmsg backend should implement.
0061  * In addition to @destroy_ept, the backend must at least implement @send and
0062  * @trysend, while the variants sending data off-channel are optional.
0063  */
0064 struct rpmsg_endpoint_ops {
0065     void (*destroy_ept)(struct rpmsg_endpoint *ept);
0066 
0067     int (*send)(struct rpmsg_endpoint *ept, void *data, int len);
0068     int (*sendto)(struct rpmsg_endpoint *ept, void *data, int len, u32 dst);
0069     int (*send_offchannel)(struct rpmsg_endpoint *ept, u32 src, u32 dst,
0070                   void *data, int len);
0071 
0072     int (*trysend)(struct rpmsg_endpoint *ept, void *data, int len);
0073     int (*trysendto)(struct rpmsg_endpoint *ept, void *data, int len, u32 dst);
0074     int (*trysend_offchannel)(struct rpmsg_endpoint *ept, u32 src, u32 dst,
0075                  void *data, int len);
0076     __poll_t (*poll)(struct rpmsg_endpoint *ept, struct file *filp,
0077                  poll_table *wait);
0078     ssize_t (*get_mtu)(struct rpmsg_endpoint *ept);
0079 };
0080 
0081 struct device *rpmsg_find_device(struct device *parent,
0082                  struct rpmsg_channel_info *chinfo);
0083 
0084 struct rpmsg_device *rpmsg_create_channel(struct rpmsg_device *rpdev,
0085                       struct rpmsg_channel_info *chinfo);
0086 int rpmsg_release_channel(struct rpmsg_device *rpdev,
0087               struct rpmsg_channel_info *chinfo);
0088 /**
0089  * rpmsg_ctrldev_register_device() - register a char device for control based on rpdev
0090  * @rpdev:  prepared rpdev to be used for creating endpoints
0091  *
0092  * This function wraps rpmsg_register_device() preparing the rpdev for use as
0093  * basis for the rpmsg chrdev.
0094  */
0095 static inline int rpmsg_ctrldev_register_device(struct rpmsg_device *rpdev)
0096 {
0097     return rpmsg_register_device_override(rpdev, "rpmsg_ctrl");
0098 }
0099 
0100 #endif