Merge remote-tracking branch 'mmc-uh/next'
[deliverable/linux.git] / include / linux / soc / qcom / smd.h
CommitLineData
f2ab3298
BA
1#ifndef __QCOM_SMD_H__
2#define __QCOM_SMD_H__
3
4#include <linux/device.h>
5#include <linux/mod_devicetable.h>
6
7struct qcom_smd;
8struct qcom_smd_channel;
9struct qcom_smd_lookup;
10
1a7caca2
BA
11/**
12 * struct qcom_smd_id - struct used for matching a smd device
13 * @name: name of the channel
14 */
15struct qcom_smd_id {
16 char name[20];
17};
18
f2ab3298
BA
19/**
20 * struct qcom_smd_device - smd device struct
21 * @dev: the device struct
22 * @channel: handle to the smd channel for this device
23 */
24struct qcom_smd_device {
25 struct device dev;
26 struct qcom_smd_channel *channel;
27};
28
b853cb96 29typedef int (*qcom_smd_cb_t)(struct qcom_smd_channel *, const void *, size_t);
39f0db29 30
f2ab3298
BA
31/**
32 * struct qcom_smd_driver - smd driver struct
33 * @driver: underlying device driver
1a7caca2 34 * @smd_match_table: static channel match table
f2ab3298
BA
35 * @probe: invoked when the smd channel is found
36 * @remove: invoked when the smd channel is closed
37 * @callback: invoked when an inbound message is received on the channel,
38 * should return 0 on success or -EBUSY if the data cannot be
39 * consumed at this time
40 */
41struct qcom_smd_driver {
42 struct device_driver driver;
1a7caca2
BA
43 const struct qcom_smd_id *smd_match_table;
44
f2ab3298
BA
45 int (*probe)(struct qcom_smd_device *dev);
46 void (*remove)(struct qcom_smd_device *dev);
39f0db29 47 qcom_smd_cb_t callback;
f2ab3298
BA
48};
49
43315f31
BA
50#if IS_ENABLED(CONFIG_QCOM_SMD)
51
f2ab3298
BA
52int qcom_smd_driver_register(struct qcom_smd_driver *drv);
53void qcom_smd_driver_unregister(struct qcom_smd_driver *drv);
54
f79a917e
BA
55struct qcom_smd_channel *qcom_smd_open_channel(struct qcom_smd_channel *channel,
56 const char *name,
57 qcom_smd_cb_t cb);
0a0c08ca 58void qcom_smd_close_channel(struct qcom_smd_channel *channel);
b853cb96
BA
59void *qcom_smd_get_drvdata(struct qcom_smd_channel *channel);
60void qcom_smd_set_drvdata(struct qcom_smd_channel *channel, void *data);
43315f31
BA
61int qcom_smd_send(struct qcom_smd_channel *channel, const void *data, int len);
62
f79a917e 63
da057302
BA
64struct qcom_smd_edge *qcom_smd_register_edge(struct device *parent,
65 struct device_node *node);
66int qcom_smd_unregister_edge(struct qcom_smd_edge *edge);
67
43315f31
BA
68#else
69
70static inline int qcom_smd_driver_register(struct qcom_smd_driver *drv)
71{
72 return -ENXIO;
73}
74
75static inline void qcom_smd_driver_unregister(struct qcom_smd_driver *drv)
76{
77 /* This shouldn't be possible */
78 WARN_ON(1);
79}
80
f79a917e
BA
81static inline struct qcom_smd_channel *
82qcom_smd_open_channel(struct qcom_smd_channel *channel,
83 const char *name,
84 qcom_smd_cb_t cb)
85{
86 /* This shouldn't be possible */
87 WARN_ON(1);
88 return NULL;
89}
90
0a0c08ca
BA
91static inline void qcom_smd_close_channel(struct qcom_smd_channel *channel)
92{
93 /* This shouldn't be possible */
94 WARN_ON(1);
95}
96
3a128184 97static inline void *qcom_smd_get_drvdata(struct qcom_smd_channel *channel)
f79a917e
BA
98{
99 /* This shouldn't be possible */
100 WARN_ON(1);
101 return NULL;
102}
103
3a128184 104static inline void qcom_smd_set_drvdata(struct qcom_smd_channel *channel, void *data)
f79a917e
BA
105{
106 /* This shouldn't be possible */
107 WARN_ON(1);
108}
109
43315f31
BA
110static inline int qcom_smd_send(struct qcom_smd_channel *channel,
111 const void *data, int len)
112{
113 /* This shouldn't be possible */
114 WARN_ON(1);
115 return -ENXIO;
116}
117
da057302
BA
118static inline struct qcom_smd_edge *
119qcom_smd_register_edge(struct device *parent,
120 struct device_node *node)
121{
122 return ERR_PTR(-ENXIO);
123}
124
125static inline int qcom_smd_unregister_edge(struct qcom_smd_edge *edge)
126{
127 /* This shouldn't be possible */
128 WARN_ON(1);
129 return -ENXIO;
130}
131
43315f31
BA
132#endif
133
f2ab3298
BA
134#define module_qcom_smd_driver(__smd_driver) \
135 module_driver(__smd_driver, qcom_smd_driver_register, \
136 qcom_smd_driver_unregister)
137
f2ab3298
BA
138
139#endif
This page took 0.113139 seconds and 5 git commands to generate.