blob: 012e68bb3ce02da4bed57e1a0202e71e30f2e5e7 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/*
2 * Atmel maXTouch header file
3 *
4 * Copyright (c) 2010 Atmel Corporation
5 * Copyright (C) 2010 Ulf Samuelsson (ulf@atmel.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 * See the file "COPYING" in the main directory of this archive
11 * for more details.
12 *
13 */
14
15#define MXT224_I2C_ADDR1 0x4A
16#define MXT224_I2C_ADDR2 0x4B
17#define MXT1386_I2C_ADDR1 0x4C
18#define MXT1386_I2C_ADDR2 0x4D
19#define MXT1386_I2C_ADDR3 0x5A
20#define MXT1386_I2C_ADDR4 0x5B
21
22/*
23 * Select this address from above depending on what maXTouch
24 * chip you have and how it's address pins are configured;
25 * see datasheet.
26 */
27
28#define MXT_I2C_ADDRESS MXT224_I2C_ADDR2
29
30#define MXT_BL_ADDRESS 0x25
31
32#define MXT224_FAMILYID 0x80
33#define MXT1386_FAMILYID 0xA0
34
35#define MXT224_CAL_VARIANTID 0x01
36#define MXT224_UNCAL_VARIANTID 0x00
37#define MXT1386_CAL_VARIANTID 0x00
38
39#define MXT_MAX_REPORTED_WIDTH 255
40#define MXT_MAX_REPORTED_PRESSURE 255
41#define MXT_MAX_TOUCH_SIZE 255
42#define MXT_MAX_NUM_TOUCHES 10
43
44/* Fixed addresses inside maXTouch device */
45#define MXT_ADDR_INFO_BLOCK 0
46#define MXT_ADDR_OBJECT_TABLE 7
47#define MXT_ID_BLOCK_SIZE 7
48#define MXT_OBJECT_TABLE_ELEMENT_SIZE 6
49
50/* Object types */
51#define MXT_DEBUG_DELTAS_T2 2
52#define MXT_DEBUG_REFERENCES_T3 3
53#define MXT_GEN_MESSAGEPROCESSOR_T5 5
54#define MXT_GEN_COMMANDPROCESSOR_T6 6
55#define MXT_GEN_POWERCONFIG_T7 7
56#define MXT_GEN_ACQUIRECONFIG_T8 8
57#define MXT_TOUCH_MULTITOUCHSCREEN_T9 9
58#define MXT_TOUCH_SINGLETOUCHSCREEN_T10 10
59#define MXT_TOUCH_XSLIDER_T11 11
60#define MXT_TOUCH_YSLIDER_T12 12
61#define MXT_TOUCH_XWHEEL_T13 13
62#define MXT_TOUCH_YWHEEL_T14 14
63#define MXT_TOUCH_KEYARRAY_T15 15
64#define MXT_SPT_GPIOPWM_T19 19
65#define MXT_PROCI_GRIPFACESUPPRESSION_T20 20
66#define MXT_PROCG_NOISESUPPRESSION_T22 22
67#define MXT_TOUCH_PROXIMITY_T23 23
68#define MXT_PROCI_ONETOUCHGESTUREPROCESSOR_T24 24
69#define MXT_SPT_SELFTEST_T25 25
70#define MXT_DEBUG_CTERANGE_T26 26
71#define MXT_PROCI_TWOTOUCHGESTUREPROCESSOR_T27 27
72#define MXT_SPT_CTECONFIG_T28 28
73#define MXT_TOUCH_KEYSET_T31 31
74#define MXT_TOUCH_XSLIDERSET_T32 32
75#define MXT_DEBUG_DIAGNOSTIC_T37 37
76#define MXT_USER_INFO_T38 38
77
78
79/*
80 * If a message is read from mXT when there's no new messages available,
81 * the report ID of the message will be 0xFF.
82 */
83#define MXT_END_OF_MESSAGES 0xFF
84
85
86/* GEN_COMMANDPROCESSOR_T6 Register offsets from T6 base address */
87#define MXT_ADR_T6_RESET 0x00
88#define MXT_ADR_T6_BACKUPNV 0x01
89#define MXT_ADR_T6_CALIBRATE 0x02
90#define MXT_ADR_T6_REPORTALL 0x03
91#define MXT_ADR_T6_RESERVED 0x04
92#define MXT_ADR_T6_DIAGNOSTIC 0x05
93
94/* T6 Debug Diagnostics Commands */
95#define MXT_CMD_T6_PAGE_UP 0x01
96#define MXT_CMD_T6_PAGE_DOWN 0x02
97#define MXT_CMD_T6_DELTAS_MODE 0x10
98#define MXT_CMD_T6_REFERENCES_MODE 0x11
99#define MXT_CMD_T6_CTE_MODE 0x31
100
101/* T6 Backup Command */
102#define MXT_CMD_T6_BACKUP 0x55
103
104/* SPT_DEBUG_DIAGNOSTIC_T37 Register offsets from T37 base address */
105#define MXT_ADR_T37_PAGE 0x01
106#define MXT_ADR_T37_DATA 0x02
107
108
109
110/************************************************************************
111 * MESSAGE OBJECTS ADDRESS FIELDS
112 *
113 ************************************************************************/
114#define MXT_MSG_REPORTID 0x00
115
116
117/* MXT_GEN_MESSAGEPROCESSOR_T5 Message address definitions */
118#define MXT_MSG_T5_REPORTID 0x00
119#define MXT_MSG_T5_MESSAGE 0x01
120#define MXT_MSG_T5_CHECKSUM 0x08
121
122/* MXT_GEN_COMMANDPROCESSOR_T6 Message address definitions */
123#define MXT_MSG_T6_STATUS 0x01
124#define MXT_MSGB_T6_COMSERR 0x04
125#define MXT_MSGB_T6_CFGERR 0x08
126#define MXT_MSGB_T6_CAL 0x10
127#define MXT_MSGB_T6_SIGERR 0x20
128#define MXT_MSGB_T6_OFL 0x40
129#define MXT_MSGB_T6_RESET 0x80
130/* Three bytes */
131#define MXT_MSG_T6_CHECKSUM 0x02
132
133/* MXT_GEN_POWERCONFIG_T7 NO Message address definitions */
134/* MXT_GEN_ACQUIRECONFIG_T8 Message address definitions */
135/* MXT_TOUCH_MULTITOUCHSCREEN_T9 Message address definitions */
136
137#define MXT_MSG_T9_STATUS 0x01
138/* Status bit field */
139#define MXT_MSGB_T9_SUPPRESS 0x02
140#define MXT_MSGB_T9_AMP 0x04
141#define MXT_MSGB_T9_VECTOR 0x08
142#define MXT_MSGB_T9_MOVE 0x10
143#define MXT_MSGB_T9_RELEASE 0x20
144#define MXT_MSGB_T9_PRESS 0x40
145#define MXT_MSGB_T9_DETECT 0x80
146
147#define MXT_MSG_T9_XPOSMSB 0x02
148#define MXT_MSG_T9_YPOSMSB 0x03
149#define MXT_MSG_T9_XYPOSLSB 0x04
150#define MXT_MSG_T9_TCHAREA 0x05
151#define MXT_MSG_T9_TCHAMPLITUDE 0x06
152#define MXT_MSG_T9_TCHVECTOR 0x07
153
154
155/* MXT_SPT_GPIOPWM_T19 Message address definitions */
156#define MXT_MSG_T19_STATUS 0x01
157
158/* MXT_PROCI_GRIPFACESUPPRESSION_T20 Message address definitions */
159#define MXT_MSG_T20_STATUS 0x01
160#define MXT_MSGB_T20_FACE_SUPPRESS 0x01
161/* MXT_PROCG_NOISESUPPRESSION_T22 Message address definitions */
162#define MXT_MSG_T22_STATUS 0x01
163#define MXT_MSGB_T22_FHCHG 0x01
164#define MXT_MSGB_T22_GCAFERR 0x04
165#define MXT_MSGB_T22_FHERR 0x08
166#define MXT_MSG_T22_GCAFDEPTH 0x02
167
168/* MXT_TOUCH_PROXIMITY_T23 Message address definitions */
169#define MXT_MSG_T23_STATUS 0x01
170#define MXT_MSGB_T23_FALL 0x20
171#define MXT_MSGB_T23_RISE 0x40
172#define MXT_MSGB_T23_DETECT 0x80
173/* 16 bit */
174#define MXT_MSG_T23_PROXDELTA 0x02
175
176/* MXT_PROCI_ONETOUCHGESTUREPROCESSOR_T24 Message address definitions */
177#define MXT_MSG_T24_STATUS 0x01
178#define MXT_MSG_T24_XPOSMSB 0x02
179#define MXT_MSG_T24_YPOSMSB 0x03
180#define MXT_MSG_T24_XYPOSLSB 0x04
181#define MXT_MSG_T24_DIR 0x05
182/* 16 bit */
183#define MXT_MSG_T24_DIST 0x06
184
185/* MXT_SPT_SELFTEST_T25 Message address definitions */
186#define MXT_MSG_T25_STATUS 0x01
187/* 5 Bytes */
188#define MXT_MSGR_T25_OK 0xFE
189#define MXT_MSGR_T25_INVALID_TEST 0xFD
190#define MXT_MSGR_T25_PIN_FAULT 0x11
191#define MXT_MSGR_T25_SIGNAL_LIMIT_FAULT 0x17
192#define MXT_MSGR_T25_GAIN_ERROR 0x20
193#define MXT_MSG_T25_INFO 0x02
194
195/* MXT_PROCI_TWOTOUCHGESTUREPROCESSOR_T27 Message address definitions */
196#define MXT_MSG_T27_STATUS 0x01
197#define MXT_MSGB_T27_ROTATEDIR 0x10
198#define MXT_MSGB_T27_PINCH 0x20
199#define MXT_MSGB_T27_ROTATE 0x40
200#define MXT_MSGB_T27_STRETCH 0x80
201#define MXT_MSG_T27_XPOSMSB 0x02
202#define MXT_MSG_T27_YPOSMSB 0x03
203#define MXT_MSG_T27_XYPOSLSB 0x04
204#define MXT_MSG_T27_ANGLE 0x05
205
206/* 16 bit */
207#define MXT_MSG_T27_SEPARATION 0x06
208
209/* MXT_SPT_CTECONFIG_T28 Message address definitions */
210#define MXT_MSG_T28_STATUS 0x01
211#define MXT_MSGB_T28_CHKERR 0x01
212
213
214/* One Touch Events */
215#define MXT_GESTURE_RESERVED 0x00
216#define MXT_GESTURE_PRESS 0x01
217#define MXT_GESTURE_RELEASE 0x02
218#define MXT_GESTURE_TAP 0x03
219#define MXT_GESTURE_DOUBLE_TAP 0x04
220#define MXT_GESTURE_FLICK 0x05
221#define MXT_GESTURE_DRAG 0x06
222#define MXT_GESTURE_SHORT_PRESS 0x07
223#define MXT_GESTURE_LONG_PRESS 0x08
224#define MXT_GESTURE_REPEAT_PRESS 0x09
225#define MXT_GESTURE_TAP_AND_PRESS 0x0a
226#define MXT_GESTURE_THROW 0x0b
227
228/* Two-touch events */
229#define MXT_GESTURE_STRETCH (1 << 7)
230#define MXT_GESTURE_ROTATE (1 << 6)
231#define MXT_GESTURE_PINCH (1 << 5)
232#define MXT_GESTURE_ROTATEDIR (1 << 4)
233
234
235
236/* Bootloader states */
237#define WAITING_BOOTLOAD_COMMAND 0xC0
238#define WAITING_FRAME_DATA 0x80
239#define APP_CRC_FAIL 0x40
240#define FRAME_CRC_CHECK 0x02
241#define FRAME_CRC_PASS 0x04
242#define FRAME_CRC_FAIL 0x03
243
244#define MXT_MAX_FRAME_SIZE 276
245
246/* Debug levels */
247#define DEBUG_INFO 1
248#define DEBUG_VERBOSE 2
249#define DEBUG_MESSAGES 5
250#define DEBUG_RAW 8
251#define DEBUG_TRACE 10
252
253/* IOCTL commands */
254/* TODO: get correct numbers! */
255#define MXT_SET_ADDRESS_IOCTL ('x' + 1) /* Sets the internal address pointer */
256#define MXT_RESET_IOCTL ('x' + 2) /* Resets the device */
257#define MXT_CALIBRATE_IOCTL ('x' + 3) /* Calibrates the device */
258/* Backups the current state of registers to NVM */
259#define MXT_BACKUP_IOCTL ('x' + 4)
260/*
261 * Only non-touch messages can be read from the message buffer
262 * (/dev/maXTouch_messages)
263 */
264#define MXT_NONTOUCH_MSG_IOCTL ('x' + 5)
265/* All messages can be read from the message buffer */
266#define MXT_ALL_MSG_IOCTL ('x' + 6)
267
268
269/* Message buffer size. This is a ring buffer, and when full, the oldest entry
270 will be overwritten. */
271#define MXT_MESSAGE_BUFFER_SIZE 128
272
273/* Routines for memory access within a 16 bit address space */
274
275/* TODO: - won't compile if functions aren't defined*/
276/* Bootloader specific function prototypes. */
277
278#if 0
279static int mxt_read_byte_bl(struct i2c_client *client, u8 *value);
280static int mxt_read_block_bl(struct i2c_client *client, u16 length, u8 *value);
281static int mxt_write_byte_bl(struct i2c_client *client, u8 value);
282static int mxt_write_block_bl(struct i2c_client *client, u16 length, u8 *value);
283#endif
284
285/**
Mohan Pallaka4e9a94e2011-11-23 16:34:21 +0530286 * struct maxtouch_platform_data - includes platform specific informatio
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700287 * related to Atmel maXTouch touchscreen controller.
288 *
289 * @numtouch: Number of simultaneous touches supported
290 * @init_platform_hw(): Initialization function, which can for example
291 * trigger a hardware reset by toggling a GPIO pin
292 * @exit_platform_hw(): Function to run when the driver is unloaded.
293 * @valid_interrupt(): Function that checks the validity of the interrupt -
294 * function that check the validity of a interrupt (by
295 * reading the changeline interrupt pin and checking that
296 * it really is low for example).
297 * @max_x: Reported X range
298 * @max_y: Reported Y range
299 */
300
Mohan Pallaka4e9a94e2011-11-23 16:34:21 +0530301struct maxtouch_platform_data {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700302 u8 numtouch; /* Number of touches to report */
303 int (*init_platform_hw)(struct i2c_client *client);
304 int (*exit_platform_hw)(struct i2c_client *client);
305 int display_res_x;
306 int display_res_y;
307 int min_x;
308 int min_y;
309 int max_x; /* The default reported X range */
310 int max_y; /* The default reported Y range */
311 u8 (*valid_interrupt) (void);
312 u8 (*read_chg) (void);
313 bool wakeup;
314 int (*power_on)(bool on);
315};
316
317void mxt_hw_reset(void);