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