4 #include <linux/device.h>
5 #include <linux/mod_devicetable.h>
8 struct qcom_smd_lookup;
9 struct qcom_smd_device;
11 typedef int (*qcom_smd_cb_t)(struct qcom_smd_device *, const void *, size_t);
16 enum smd_channel_state {
23 SMD_CHANNEL_RESET_OPENING
27 * struct qcom_smd_channel - smd channel struct
28 * @edge: qcom_smd_edge this channel is living on
29 * @qsdev: reference to a associated smd client device
30 * @name: name of the channel
31 * @state: local state of the channel
32 * @remote_state: remote state of the channel
33 * @info: byte aligned outgoing/incoming channel info
34 * @info_word: word aligned outgoing/incoming channel info
35 * @tx_lock: lock to make writes to the channel mutually exclusive
36 * @fblockread_event: wakeup event tied to tx fBLOCKREADINTR
37 * @tx_fifo: pointer to the outgoing ring buffer
38 * @rx_fifo: pointer to the incoming ring buffer
39 * @fifo_size: size of each ring buffer
40 * @bounce_buffer: bounce buffer for reading wrapped packets
41 * @cb: callback function registered for this channel
42 * @recv_lock: guard for rx info modifications and cb pointer
43 * @pkt_size: size of the currently handled packet
44 * @list: lite entry for @channels in qcom_smd_edge
47 struct qcom_smd_channel {
48 struct qcom_smd_edge *edge;
50 struct qcom_smd_device *qsdev;
53 enum smd_channel_state state;
54 enum smd_channel_state remote_state;
56 struct smd_channel_info_pair *info;
57 struct smd_channel_info_word_pair *info_word;
60 wait_queue_head_t fblockread_event;
73 struct list_head list;
77 * struct qcom_smd_id - struct used for matching a smd device
78 * @name: name of the channel
85 * struct qcom_smd_device - smd device struct
86 * @dev: the device struct
87 * @channel: handle to the smd channel for this device
89 struct qcom_smd_device {
91 struct qcom_smd_channel *channel;
95 * struct qcom_smd_driver - smd driver struct
96 * @driver: underlying device driver
97 * @smd_match_table: static channel match table
98 * @probe: invoked when the smd channel is found
99 * @remove: invoked when the smd channel is closed
100 * @callback: invoked when an inbound message is received on the channel,
101 * should return 0 on success or -EBUSY if the data cannot be
102 * consumed at this time
104 struct qcom_smd_driver {
105 struct device_driver driver;
106 const struct qcom_smd_id *smd_match_table;
108 int (*probe)(struct qcom_smd_device *dev);
109 void (*remove)(struct qcom_smd_device *dev);
110 qcom_smd_cb_t callback;
113 int qcom_smd_driver_register(struct qcom_smd_driver *drv);
114 void qcom_smd_driver_unregister(struct qcom_smd_driver *drv);
116 #define module_qcom_smd_driver(__smd_driver) \
117 module_driver(__smd_driver, qcom_smd_driver_register, \
118 qcom_smd_driver_unregister)
120 int qcom_smd_send(struct qcom_smd_channel *channel, const void *data, int len);