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
|
/*
* Copyright (C) 2010, Imagis Technology Co. Ltd. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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.
*
*/
#ifndef __IST30XX_H__
#define __IST30XX_H__
/*
* Support F/W ver : IST3000 v2.2~v3.3 (included tag)
* Release : 2013.06.12 by Ian Bae
*/
#define I2C_BURST_MODE (1)
#define I2C_MONOPOLY_MODE (0)
#define IST30XX_EVENT_MODE (1)
#if IST30XX_EVENT_MODE
# define IST30XX_NOISE_MODE (1)
# define IST30XX_TRACKING_MODE (1)
#endif
#define IST30XX_DETECT_TA (1)
#define IST30XX_DETECT_TEMPER (0)
#define IST30XX_DETECT_CALLER (0)
#define IST30XX_USE_KEY (1)
#define IST30XX_DEBUG (1)
#define IST30XX_FACTORY_TEST (1)
#define IST30XX_DEV_NAME "IST30XX"
#define IST30XX_CHIP_ID (0x30003000)
#define IST30XXA_CHIP_ID (0x300a300a)
#define IST30XX_DEV_ID (0xA0 >> 1)
#define IST30XX_FW_DEV_ID (0xA4 >> 1)
#define IST30XX_ADDR_LEN (4)
#define IST30XX_DATA_LEN (4)
#define IST30XX_ISP_CMD_LEN (3)
#define IST30XX_MAX_MT_FINGERS (10)
#if (defined CONFIG_MACH_POCKET2) || (defined CONFIG_MACH_YOUNG2)
#define IST30XX_MAX_X (320)
#define IST30XX_MAX_Y (480)
#else
#define IST30XX_MAX_X (240)
#define IST30XX_MAX_Y (320)
#endif
#define IST30XX_MAX_Z (255)
#define IST30XX_MAX_W (15)
/* I2C Transfer msg number */
#define WRITE_CMD_MSG_LEN (1)
#define READ_CMD_MSG_LEN (2)
#define NORMAL_TEMPERATURE (0)
#define LOW_TEMPERATURE (1)
#define HIGH_TEMPERATURE (2)
/* Debug message */
#define DEV_ERR (1)
#define DEV_WARN (2)
#define DEV_INFO (3)
#define DEV_DEBUG (4)
#define DEV_VERB (5)
#define IST30XX_DEBUG_TAG "[ TSP ]"
#define IST30XX_DEBUG_LEVEL DEV_DEBUG
#define tsp_err(fmt, ...) tsp_printk(DEV_ERR, fmt, ## __VA_ARGS__)
#define tsp_warn(fmt, ...) tsp_printk(DEV_WARN, fmt, ## __VA_ARGS__)
#define tsp_info(fmt, ...) tsp_printk(DEV_INFO, fmt, ## __VA_ARGS__)
#define tsp_debug(fmt, ...) tsp_printk(DEV_DEBUG, fmt, ## __VA_ARGS__)
#define tsp_verb(fmt, ...) tsp_printk(DEV_VERB, fmt, ## __VA_ARGS__)
enum ist30xx_commands {
CMD_ENTER_UPDATE = 0x02,
CMD_EXIT_UPDATE = 0x03,
CMD_UPDATE_SENSOR = 0x04,
CMD_UPDATE_CONFIG = 0x05,
CMD_ENTER_REG_ACCESS = 0x07,
CMD_EXIT_REG_ACCESS = 0x08,
CMD_SET_TA_MODE = 0x0A,
CMD_START_SCAN = 0x0B,
CMD_ENTER_FW_UPDATE = 0x0C,
CMD_RUN_DEVICE = 0x0D,
CMD_SET_TEST_MODE = 0x0F,
CMD_CALIBRATE = 0x11,
CMD_USE_IDLE = 0x12,
CMD_USE_DEBUG = 0x13,
CMD_ZVALUE_MODE = 0x15,
CMD_CHECK_CALIB = 0x1A,
CMD_SET_TEMPER_MODE = 0x1B,
CMD_SET_CALL_MODE = 0x1C,
CMD_GET_COORD = 0x20,
CMD_GET_CHIP_ID = 0x30,
CMD_GET_FW_VER = 0x31,
CMD_GET_CHECKSUM = 0x32,
CMD_GET_LCD_RESOLUTION = 0x33,
CMD_GET_TSP_CHNUM1 = 0x34,
CMD_GET_PARAM_VER = 0x35,
CMD_GET_CALIB_RESULT = 0x37,
CMD_GET_TSP_SWAP_INFO = 0x38,
CMD_GET_KEY_INFO1 = 0x39,
CMD_GET_KEY_INFO2 = 0x3A,
CMD_GET_KEY_INFO3 = 0x3B,
CMD_GET_TSP_CHNUM2 = 0x3C,
CMD_GET_TSP_DIRECTION = 0x3D,
CMD_GET_TSP_VENDOR = 0x3E,
CMD_GET_TSP_PANNEL_TYPE = 0x40,
CMD_GET_CHECKSUM_ALL = 0x41,
};
#define CMD_FW_UPDATE_MAGIC (0x85FDAE8A)
typedef union {
struct {
u32 y : 10;
u32 w : 6;
u32 x : 10;
u32 id : 4;
u32 udmg : 2;
} bit_field;
u32 full_field;
} finger_info;
struct ist30xx_status {
int power;
int update;
int calib;
int calib_msg;
};
struct ist30xx_fw {
u32 pre_ver;
u32 ver;
u32 index;
u32 size;
u32 chksum;
};
#define IST30XX_TAG_MAGIC "ISTV1TAG"
struct ist30xx_tags {
char magic1[8];
u32 fw_addr;
u32 fw_size;
u32 flag_addr;
u32 flag_size;
u32 cfg_addr;
u32 cfg_size;
u32 sensor1_addr;
u32 sensor1_size;
u32 sensor2_addr;
u32 sensor2_size;
u32 chksum;
u32 reserved2;
char magic2[8];
};
#include <linux/earlysuspend.h>
struct ist30xx_data {
struct i2c_client * client;
struct input_dev * input_dev;
struct early_suspend early_suspend;
struct ist30xx_status status;
struct ist30xx_fw fw;
struct ist30xx_tags tags;
u32 chip_id;
u32 param_ver;
u32 num_fingers;
u32 num_keys;
u32 irq_enabled;
finger_info fingers[IST30XX_MAX_MT_FINGERS];
finger_info prev_fingers[IST30XX_MAX_MT_FINGERS];
finger_info prev_keys[IST30XX_MAX_MT_FINGERS];
};
struct tsp_dev_info{
int gpio;
};
extern struct mutex ist30xx_mutex;
extern int ist30xx_dbg_level;
void tsp_printk(int level, const char *fmt, ...);
void ist30xx_enable_irq(struct ist30xx_data *data);
void ist30xx_disable_irq(struct ist30xx_data *data);
void ist30xx_start(struct ist30xx_data *data);
int ist30xx_get_ver_info(struct ist30xx_data *data);
int ist30xx_init_touch_driver(struct ist30xx_data *data);
int ist30xx_get_position(struct i2c_client *client, u32 *buf, u16 len);
int ist30xx_read_cmd(struct i2c_client *client, u32 cmd, u32 *buf);
int ist30xx_write_cmd(struct i2c_client *client, u32 cmd, u32 val);
int ist30xx_cmd_run_device(struct i2c_client *client);
int ist30xx_cmd_start_scan(struct i2c_client *client);
int ist30xx_cmd_calibrate(struct i2c_client *client);
int ist30xx_cmd_check_calib(struct i2c_client *client);
int ist30xx_cmd_update(struct i2c_client *client, int cmd);
int ist30xx_cmd_reg(struct i2c_client *client, int cmd);
int ist30xx_power_on(void);
int ist30xx_power_off(void);
int ist30xx_reset(void);
void ts_power_enable(int en);
int ist30xx_internal_suspend(struct ist30xx_data *data);
int ist30xx_internal_resume(struct ist30xx_data *data);
int ist30xx_init_factory_sysfs(void);
int ist30xx_init_system(void);
#endif // __IST30XX_H__
|