1
2
3
4
5
6
7#ifndef _RMI_BUS_H
8#define _RMI_BUS_H
9
10#include <linux/rmi.h>
11
12struct rmi_device;
13
14
15
16
17
18#define RMI_FN_MAX_IRQS 6
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36struct rmi_function {
37 struct rmi_function_descriptor fd;
38 struct rmi_device *rmi_dev;
39 struct device dev;
40 struct list_head node;
41
42 unsigned int num_of_irqs;
43 int irq[RMI_FN_MAX_IRQS];
44 unsigned int irq_pos;
45 unsigned long irq_mask[];
46};
47
48#define to_rmi_function(d) container_of(d, struct rmi_function, dev)
49
50bool rmi_is_function_device(struct device *dev);
51
52int __must_check rmi_register_function(struct rmi_function *);
53void rmi_unregister_function(struct rmi_function *);
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75struct rmi_function_handler {
76 struct device_driver driver;
77
78 u8 func;
79
80 int (*probe)(struct rmi_function *fn);
81 void (*remove)(struct rmi_function *fn);
82 int (*config)(struct rmi_function *fn);
83 int (*reset)(struct rmi_function *fn);
84 irqreturn_t (*attention)(int irq, void *ctx);
85 int (*suspend)(struct rmi_function *fn);
86 int (*resume)(struct rmi_function *fn);
87};
88
89#define to_rmi_function_handler(d) \
90 container_of(d, struct rmi_function_handler, driver)
91
92int __must_check __rmi_register_function_handler(struct rmi_function_handler *,
93 struct module *, const char *);
94#define rmi_register_function_handler(handler) \
95 __rmi_register_function_handler(handler, THIS_MODULE, KBUILD_MODNAME)
96
97void rmi_unregister_function_handler(struct rmi_function_handler *);
98
99#define to_rmi_driver(d) \
100 container_of(d, struct rmi_driver, driver)
101
102#define to_rmi_device(d) container_of(d, struct rmi_device, dev)
103
104static inline struct rmi_device_platform_data *
105rmi_get_platform_data(struct rmi_device *d)
106{
107 return &d->xport->pdata;
108}
109
110bool rmi_is_physical_device(struct device *dev);
111
112
113
114
115
116
117
118
119static inline int rmi_reset(struct rmi_device *d)
120{
121 return d->driver->reset_handler(d);
122}
123
124
125
126
127
128
129
130
131
132
133
134static inline int rmi_read(struct rmi_device *d, u16 addr, u8 *buf)
135{
136 return d->xport->ops->read_block(d->xport, addr, buf, 1);
137}
138
139
140
141
142
143
144
145
146
147
148
149
150static inline int rmi_read_block(struct rmi_device *d, u16 addr,
151 void *buf, size_t len)
152{
153 return d->xport->ops->read_block(d->xport, addr, buf, len);
154}
155
156
157
158
159
160
161
162
163
164
165static inline int rmi_write(struct rmi_device *d, u16 addr, u8 data)
166{
167 return d->xport->ops->write_block(d->xport, addr, &data, 1);
168}
169
170
171
172
173
174
175
176
177
178
179
180static inline int rmi_write_block(struct rmi_device *d, u16 addr,
181 const void *buf, size_t len)
182{
183 return d->xport->ops->write_block(d->xport, addr, buf, len);
184}
185
186int rmi_for_each_dev(void *data, int (*func)(struct device *dev, void *data));
187
188extern struct bus_type rmi_bus_type;
189
190int rmi_of_property_read_u32(struct device *dev, u32 *result,
191 const char *prop, bool optional);
192
193#define RMI_DEBUG_CORE BIT(0)
194#define RMI_DEBUG_XPORT BIT(1)
195#define RMI_DEBUG_FN BIT(2)
196#define RMI_DEBUG_2D_SENSOR BIT(3)
197
198void rmi_dbg(int flags, struct device *dev, const char *fmt, ...);
199#endif
200