1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
|
/* BEGIN PN:DTS2013051703879 ,Added by l00184147, 2013/5/17*/
//add Touch driver for G610-T11
/* BEGIN PN:DTS2013012601133 ,Modified by l00184147, 2013/1/26*/
/* BEGIN PN:DTS2013011401860 ,Modified by l00184147, 2013/1/14*/
/* BEGIN PN:SPBB-1218 ,Added by l00184147, 2012/12/20*/
/*
* cyttsp4_bus.h
* Cypress TrueTouch(TM) Standard Product V4 Bus Driver.
* For use with Cypress Txx4xx parts.
* Supported parts include:
* TMA4XX
* TMA1036
*
* Copyright (C) 2012 Cypress Semiconductor
* Copyright (C) 2011 Sony Ericsson Mobile Communications AB.
*
* Author: Aleksej Makarov <aleksej.makarov@sonyericsson.com>
* Modified by: Cypress Semiconductor to add device functions
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2, and only version 2, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contact Cypress Semiconductor at www.cypress.com <ttdrivers@cypress.com>
*
*/
#ifndef _LINUX_CYTTSP4_BUS_H
#define _LINUX_CYTTSP4_BUS_H
#include <linux/device.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/limits.h>
extern struct bus_type cyttsp4_bus_type;
struct cyttsp4_driver;
struct cyttsp4_device;
struct cyttsp4_adapter;
enum cyttsp4_atten_type {
CY_ATTEN_IRQ,
CY_ATTEN_STARTUP,
CY_ATTEN_EXCLUSIVE,
CY_ATTEN_NUM_ATTEN,
};
typedef int (*cyttsp4_atten_func) (struct cyttsp4_device *);
struct cyttsp4_ops {
int (*write)(struct cyttsp4_adapter *dev, u8 addr,
const void *buf, int size);
int (*read)(struct cyttsp4_adapter *dev, u8 addr, void *buf, int size);
};
struct cyttsp4_adapter {
struct list_head node;
char id[NAME_MAX];
struct device *dev;
int (*write)(struct cyttsp4_adapter *dev, u8 addr,
const void *buf, int size);
int (*read)(struct cyttsp4_adapter *dev, u8 addr, void *buf, int size);
};
#define to_cyttsp4_adapter(d) container_of(d, struct cyttsp4_adapter, dev)
struct cyttsp4_core_info {
char const *name;
char const *id;
char const *adap_id;
void *platform_data;
};
struct cyttsp4_core {
struct list_head node;
char const *name;
char const *id;
char const *adap_id;
struct device dev;
struct cyttsp4_adapter *adap;
};
#define to_cyttsp4_core(d) container_of(d, struct cyttsp4_core, dev)
struct cyttsp4_device_info {
char const *name;
char const *core_id;
void *platform_data;
};
struct cyttsp4_device {
struct list_head node;
char const *name;
char const *core_id;
struct device dev;
struct cyttsp4_core *core;
};
#define to_cyttsp4_device(d) container_of(d, struct cyttsp4_device, dev)
struct cyttsp4_core_driver {
struct device_driver driver;
int (*probe)(struct cyttsp4_core *core);
int (*remove)(struct cyttsp4_core *core);
int (*subscribe_attention)(struct cyttsp4_device *ttsp,
enum cyttsp4_atten_type type,
cyttsp4_atten_func func,
int flags);
int (*unsubscribe_attention)(struct cyttsp4_device *ttsp,
enum cyttsp4_atten_type type,
cyttsp4_atten_func func,
int flags);
int (*request_exclusive)(struct cyttsp4_device *ttsp, int timeout_ms);
int (*release_exclusive)(struct cyttsp4_device *ttsp);
int (*request_reset)(struct cyttsp4_device *ttsp);
int (*request_restart)(struct cyttsp4_device *ttsp, bool wait);
int (*request_set_mode)(struct cyttsp4_device *ttsp, int mode);
struct cyttsp4_sysinfo *(*request_sysinfo)(struct cyttsp4_device *ttsp);
struct cyttsp4_loader_platform_data
*(*request_loader_pdata)(struct cyttsp4_device *ttsp);
int (*request_handshake)(struct cyttsp4_device *ttsp, u8 mode);
int (*request_exec_cmd)(struct cyttsp4_device *ttsp, u8 mode,
u8 *cmd_buf, size_t cmd_size, u8 *return_buf,
size_t return_buf_size, int timeout_ms);
int (*request_stop_wd)(struct cyttsp4_device *ttsp);
int (*request_toggle_lowpower)(struct cyttsp4_device *ttsp, u8 mode);
int (*request_write_config)(struct cyttsp4_device *ttsp, u8 ebid,
u16 offset, u8 *data, u16 length);
int (*write)(struct cyttsp4_device *ttsp, int mode,
u8 addr, const void *buf, int size);
int (*read)(struct cyttsp4_device *ttsp, int mode,
u8 addr, void *buf, int size);
};
#define to_cyttsp4_core_driver(d) \
container_of(d, struct cyttsp4_core_driver, driver)
struct cyttsp4_driver {
struct device_driver driver;
int (*probe)(struct cyttsp4_device *dev);
int (*remove)(struct cyttsp4_device *fev);
};
#define to_cyttsp4_driver(d) container_of(d, struct cyttsp4_driver, driver)
extern int cyttsp4_register_driver(struct cyttsp4_driver *drv);
extern void cyttsp4_unregister_driver(struct cyttsp4_driver *drv);
extern int cyttsp4_register_core_driver(struct cyttsp4_core_driver *drv);
extern void cyttsp4_unregister_core_driver(struct cyttsp4_core_driver *drv);
extern int cyttsp4_register_device(struct cyttsp4_device_info const *dev_info);
extern int cyttsp4_unregister_device(char const *name, char const *core_id);
extern int cyttsp4_register_core_device(
struct cyttsp4_core_info const *core_info);
extern int cyttsp4_add_adapter(char const *id, struct cyttsp4_ops const *ops,
struct device *parent);
extern int cyttsp4_del_adapter(char const *id);
static inline int cyttsp4_read(struct cyttsp4_device *ttsp, int mode, u8 addr,
void *buf, int size)
{
struct cyttsp4_core *cd = ttsp->core;
struct cyttsp4_core_driver *d = to_cyttsp4_core_driver(cd->dev.driver);
return d->read(ttsp, mode, addr, buf, size);
}
static inline int cyttsp4_write(struct cyttsp4_device *ttsp, int mode, u8 addr,
const void *buf, int size)
{
struct cyttsp4_core *cd = ttsp->core;
struct cyttsp4_core_driver *d = to_cyttsp4_core_driver(cd->dev.driver);
return d->write(ttsp, mode, addr, buf, size);
}
static inline int cyttsp4_adap_read(struct cyttsp4_adapter *adap, u8 addr,
void *buf, int size)
{
return adap->read(adap, addr, buf, size);
}
static inline int cyttsp4_adap_write(struct cyttsp4_adapter *adap, u8 addr,
const void *buf, int size)
{
return adap->write(adap, addr, buf, size);
}
static inline int cyttsp4_subscribe_attention(struct cyttsp4_device *ttsp,
enum cyttsp4_atten_type type, cyttsp4_atten_func func,
int flags)
{
struct cyttsp4_core *cd = ttsp->core;
struct cyttsp4_core_driver *d = to_cyttsp4_core_driver(cd->dev.driver);
return d->subscribe_attention(ttsp, type, func, flags);
}
static inline int cyttsp4_unsubscribe_attention(struct cyttsp4_device *ttsp,
enum cyttsp4_atten_type type, cyttsp4_atten_func func,
int flags)
{
struct cyttsp4_core *cd = ttsp->core;
struct cyttsp4_core_driver *d = to_cyttsp4_core_driver(cd->dev.driver);
return d->unsubscribe_attention(ttsp, type, func, flags);
}
static inline int cyttsp4_request_exclusive(struct cyttsp4_device *ttsp,
int timeout_ms)
{
struct cyttsp4_core *cd = ttsp->core;
struct cyttsp4_core_driver *d = to_cyttsp4_core_driver(cd->dev.driver);
return d->request_exclusive(ttsp, timeout_ms);
}
static inline int cyttsp4_release_exclusive(struct cyttsp4_device *ttsp)
{
struct cyttsp4_core *cd = ttsp->core;
struct cyttsp4_core_driver *d = to_cyttsp4_core_driver(cd->dev.driver);
return d->release_exclusive(ttsp);
}
static inline int cyttsp4_request_reset(struct cyttsp4_device *ttsp)
{
struct cyttsp4_core *cd = ttsp->core;
struct cyttsp4_core_driver *d = to_cyttsp4_core_driver(cd->dev.driver);
return d->request_reset(ttsp);
}
static inline int cyttsp4_request_restart(struct cyttsp4_device *ttsp,
bool wait)
{
struct cyttsp4_core *cd = ttsp->core;
struct cyttsp4_core_driver *d = to_cyttsp4_core_driver(cd->dev.driver);
return d->request_restart(ttsp, wait);
}
static inline int cyttsp4_request_set_mode(struct cyttsp4_device *ttsp,
int mode)
{
struct cyttsp4_core *cd = ttsp->core;
struct cyttsp4_core_driver *d = to_cyttsp4_core_driver(cd->dev.driver);
return d->request_set_mode(ttsp, mode);
}
static inline struct cyttsp4_sysinfo *cyttsp4_request_sysinfo(
struct cyttsp4_device *ttsp)
{
struct cyttsp4_core *cd = ttsp->core;
struct cyttsp4_core_driver *d = to_cyttsp4_core_driver(cd->dev.driver);
return d->request_sysinfo(ttsp);
}
static inline struct cyttsp4_loader_platform_data *cyttsp4_request_loader_pdata(
struct cyttsp4_device *ttsp)
{
struct cyttsp4_core *cd = ttsp->core;
struct cyttsp4_core_driver *d = to_cyttsp4_core_driver(cd->dev.driver);
return d->request_loader_pdata(ttsp);
}
static inline int cyttsp4_request_handshake(struct cyttsp4_device *ttsp,
u8 mode)
{
struct cyttsp4_core *cd = ttsp->core;
struct cyttsp4_core_driver *d = to_cyttsp4_core_driver(cd->dev.driver);
return d->request_handshake(ttsp, mode);
}
static inline int cyttsp4_request_exec_cmd(struct cyttsp4_device *ttsp,
u8 mode, u8 *cmd_buf, size_t cmd_size, u8 *return_buf,
size_t return_buf_size, int timeout_ms)
{
struct cyttsp4_core *cd = ttsp->core;
struct cyttsp4_core_driver *d = to_cyttsp4_core_driver(cd->dev.driver);
return d->request_exec_cmd(ttsp, mode, cmd_buf, cmd_size, return_buf,
return_buf_size, timeout_ms);
}
static inline int cyttsp4_request_stop_wd(struct cyttsp4_device *ttsp)
{
struct cyttsp4_core *cd = ttsp->core;
struct cyttsp4_core_driver *d = to_cyttsp4_core_driver(cd->dev.driver);
return d->request_stop_wd(ttsp);
}
static inline int cyttsp4_request_toggle_lowpower(struct cyttsp4_device *ttsp,
u8 mode)
{
struct cyttsp4_core *cd = ttsp->core;
struct cyttsp4_core_driver *d = to_cyttsp4_core_driver(cd->dev.driver);
return d->request_toggle_lowpower(ttsp, mode);
}
static inline int cyttsp4_request_write_config(struct cyttsp4_device *ttsp,
u8 ebid, u16 offset, u8 *data, u16 length)
{
struct cyttsp4_core *cd = ttsp->core;
struct cyttsp4_core_driver *d = to_cyttsp4_core_driver(cd->dev.driver);
return d->request_write_config(ttsp, ebid, offset, data, length);
}
#endif /* _LINUX_CYTTSP4_BUS_H */
/* END PN:SPBB-1218 ,Added by l00184147, 2012/12/20*/
/* END PN:DTS2013011401860 ,Modified by l00184147, 2013/1/14*/
/* END PN:DTS2013012601133 ,Modified by l00184147, 2013/1/26*/
/* END PN:DTS2013051703879 ,Added by l00184147, 2013/5/17*/
|