4 #include <linux/device.h>
5 #include <linux/mod_devicetable.h>
8 struct qcom_smd_lookup;
9 struct qcom_smd_device;
14 enum smd_channel_state {
21 SMD_CHANNEL_RESET_OPENING
25 * struct qcom_smd_channel - smd channel struct
26 * @edge: qcom_smd_edge this channel is living on
27 * @qsdev: reference to a associated smd client device
28 * @name: name of the channel
29 * @state: local state of the channel
30 * @remote_state: remote state of the channel
31 * @info: byte aligned outgoing/incoming channel info
32 * @info_word: word aligned outgoing/incoming channel info
33 * @tx_lock: lock to make writes to the channel mutually exclusive
34 * @fblockread_event: wakeup event tied to tx fBLOCKREADINTR
35 * @tx_fifo: pointer to the outgoing ring buffer
36 * @rx_fifo: pointer to the incoming ring buffer
37 * @fifo_size: size of each ring buffer
38 * @bounce_buffer: bounce buffer for reading wrapped packets
39 * @cb: callback function registered for this channel
40 * @recv_lock: guard for rx info modifications and cb pointer
41 * @pkt_size: size of the currently handled packet
42 * @list: lite entry for @channels in qcom_smd_edge
45 struct qcom_smd_channel {
46 struct qcom_smd_edge *edge;
48 struct qcom_smd_device *qsdev;
51 enum smd_channel_state state;
52 enum smd_channel_state remote_state;
54 struct smd_channel_info_pair *info;
55 struct smd_channel_info_word_pair *info_word;
58 wait_queue_head_t fblockread_event;
71 struct list_head list;
72 struct list_head dev_list;
76 * struct qcom_smd_id - struct used for matching a smd device
77 * @name: name of the channel
84 * struct qcom_smd_device - smd device struct
85 * @dev: the device struct
86 * @channel: handle to the smd channel for this device
88 struct qcom_smd_device {
90 struct qcom_smd_channel *channel;
93 typedef int (*qcom_smd_cb_t)(struct qcom_smd_channel *, const void *, size_t);
96 * struct qcom_smd_driver - smd driver struct
97 * @driver: underlying device driver
98 * @smd_match_table: static channel match table
99 * @probe: invoked when the smd channel is found
100 * @remove: invoked when the smd channel is closed
101 * @callback: invoked when an inbound message is received on the channel,
102 * should return 0 on success or -EBUSY if the data cannot be
103 * consumed at this time
105 struct qcom_smd_driver {
106 struct device_driver driver;
107 const struct qcom_smd_id *smd_match_table;
109 int (*probe)(struct qcom_smd_device *dev);
110 void (*remove)(struct qcom_smd_device *dev);
111 qcom_smd_cb_t callback;
114 int qcom_smd_driver_register(struct qcom_smd_driver *drv);
115 void qcom_smd_driver_unregister(struct qcom_smd_driver *drv);
117 void *qcom_smd_get_drvdata(struct qcom_smd_channel *channel);
118 void qcom_smd_set_drvdata(struct qcom_smd_channel *channel, void *data);
120 #define module_qcom_smd_driver(__smd_driver) \
121 module_driver(__smd_driver, qcom_smd_driver_register, \
122 qcom_smd_driver_unregister)
124 int qcom_smd_send(struct qcom_smd_channel *channel, const void *data, int len);
126 struct qcom_smd_channel *qcom_smd_open_channel(struct qcom_smd_channel *channel,