Commit | Line | Data |
---|---|---|
6fa3eb70 S |
1 | #include "tpd.h" |
2 | #define GUP_FW_INFO | |
3 | #include "tpd_custom_gt9xx.h" | |
4 | ||
5 | #include "cust_gpio_usage.h" | |
6 | ||
7 | #ifdef TPD_PROXIMITY | |
8 | #include <linux/hwmsensor.h> | |
9 | #include <linux/hwmsen_dev.h> | |
10 | #include <linux/sensors_io.h> | |
11 | #endif | |
12 | ||
13 | #if GTP_SUPPORT_I2C_DMA | |
14 | #include <linux/dma-mapping.h> | |
15 | #endif | |
16 | #include <linux/proc_fs.h> /*proc*/ | |
17 | ||
18 | extern struct tpd_device *tpd; | |
19 | #ifdef VELOCITY_CUSTOM | |
20 | extern int tpd_v_magnify_x; | |
21 | extern int tpd_v_magnify_y; | |
22 | #endif | |
23 | static int tpd_flag = 0; | |
24 | int tpd_halt = 0; | |
25 | static int tpd_eint_mode=1; | |
26 | static struct task_struct *thread = NULL; | |
27 | static int tpd_polling_time=50; | |
28 | extern u8 load_fw_process; | |
29 | ||
30 | static DECLARE_WAIT_QUEUE_HEAD(waiter); | |
31 | DEFINE_MUTEX(i2c_access); | |
32 | ||
33 | #ifdef TPD_HAVE_BUTTON | |
34 | static int tpd_keys_local[TPD_KEY_COUNT] = TPD_KEYS; | |
35 | static int tpd_keys_dim_local[TPD_KEY_COUNT][4] = TPD_KEYS_DIM; | |
36 | #endif | |
37 | ||
38 | #if GTP_HAVE_TOUCH_KEY | |
39 | const u16 touch_key_array[] = TPD_KEYS; | |
40 | #define GTP_MAX_KEY_NUM ( sizeof( touch_key_array )/sizeof( touch_key_array[0] ) ) | |
41 | struct touch_vitual_key_map_t | |
42 | { | |
43 | int point_x; | |
44 | int point_y; | |
45 | }; | |
46 | static struct touch_vitual_key_map_t touch_key_point_maping_array[]=GTP_KEY_MAP_ARRAY; | |
47 | #endif | |
48 | ||
49 | #if GTP_SLIDE_WAKEUP | |
50 | typedef enum | |
51 | { | |
52 | DOZE_DISABLED = 0, | |
53 | DOZE_ENABLED = 1, | |
54 | DOZE_WAKEUP = 2, | |
55 | }DOZE_T; | |
56 | static DOZE_T doze_status = DOZE_DISABLED; | |
57 | static s8 gtp_enter_doze(struct i2c_client *client); | |
58 | #endif | |
59 | ||
60 | #if GTP_CHARGER_SWITCH | |
61 | extern kal_bool upmu_is_chr_det(void); | |
62 | static void gtp_charger_switch(s32 dir_update); | |
63 | #endif | |
64 | ||
65 | #if (defined(TPD_WARP_START) && defined(TPD_WARP_END)) | |
66 | static int tpd_wb_start_local[TPD_WARP_CNT] = TPD_WARP_START; | |
67 | static int tpd_wb_end_local[TPD_WARP_CNT] = TPD_WARP_END; | |
68 | #endif | |
69 | ||
70 | #if (defined(TPD_HAVE_CALIBRATION) && !defined(TPD_CUSTOM_CALIBRATION)) | |
71 | //static int tpd_calmat_local[8] = TPD_CALIBRATION_MATRIX; | |
72 | //static int tpd_def_calmat_local[8] = TPD_CALIBRATION_MATRIX; | |
73 | static int tpd_def_calmat_local_normal[8] = TPD_CALIBRATION_MATRIX_ROTATION_NORMAL; | |
74 | static int tpd_def_calmat_local_factory[8] = TPD_CALIBRATION_MATRIX_ROTATION_FACTORY; | |
75 | #endif | |
76 | ||
77 | #if GTP_SUPPORT_I2C_DMA | |
78 | s32 i2c_dma_write(struct i2c_client *client, u16 addr, u8 *txbuf, s32 len); | |
79 | s32 i2c_dma_read(struct i2c_client *client, u16 addr, u8 *rxbuf, s32 len); | |
80 | ||
81 | static u8 *gpDMABuf_va = NULL; | |
82 | static u32 gpDMABuf_pa = 0; | |
83 | #endif | |
84 | ||
85 | s32 gtp_send_cfg(struct i2c_client *client); | |
86 | void gtp_reset_guitar(struct i2c_client *client, s32 ms); | |
87 | static void tpd_eint_interrupt_handler(void); | |
88 | static int touch_event_handler(void *unused); | |
89 | static int tpd_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id); | |
90 | static int tpd_i2c_detect(struct i2c_client *client, struct i2c_board_info *info); | |
91 | static int tpd_i2c_remove(struct i2c_client *client); | |
92 | s32 gtp_i2c_read_dbl_check(struct i2c_client *client, u16 addr, u8 *rxbuf, int len); | |
93 | extern void mt_eint_unmask(unsigned int line); | |
94 | extern void mt_eint_mask(unsigned int line); | |
95 | static void tpd_on(void); | |
96 | static void tpd_off(void); | |
97 | ||
98 | #ifdef GTP_CHARGER_DETECT | |
99 | extern bool upmu_get_pchr_chrdet(void); | |
100 | #define TPD_CHARGER_CHECK_CIRCLE 50 | |
101 | static struct delayed_work gtp_charger_check_work; | |
102 | static struct workqueue_struct *gtp_charger_check_workqueue = NULL; | |
103 | static void gtp_charger_check_func(struct work_struct *); | |
104 | static u8 gtp_charger_mode = 0; | |
105 | #endif | |
106 | ||
107 | ||
108 | #if GTP_CREATE_WR_NODE | |
109 | extern s32 init_wr_node(struct i2c_client *); | |
110 | extern void uninit_wr_node(void); | |
111 | #endif | |
112 | ||
113 | #if (GTP_ESD_PROTECT || GTP_COMPATIBLE_MODE) | |
114 | void force_reset_guitar(void); | |
115 | #endif | |
116 | ||
117 | #if GTP_ESD_PROTECT | |
118 | static int clk_tick_cnt = 200; | |
119 | static struct delayed_work gtp_esd_check_work; | |
120 | static struct workqueue_struct *gtp_esd_check_workqueue = NULL; | |
121 | static s32 gtp_init_ext_watchdog(struct i2c_client *client); | |
122 | static void gtp_esd_check_func(struct work_struct *); | |
123 | void gtp_esd_switch(struct i2c_client *client, s32 on); | |
124 | u8 esd_running = 0; | |
125 | spinlock_t esd_lock; | |
126 | #endif | |
127 | ||
128 | #if HOTKNOT_BLOCK_RW | |
129 | u8 hotknot_paired_flag = 0; | |
130 | #endif | |
131 | ||
132 | #ifdef TPD_PROXIMITY | |
133 | #define TPD_PROXIMITY_VALID_REG 0x814E | |
134 | #define TPD_PROXIMITY_ENABLE_REG 0x8042 | |
135 | static u8 tpd_proximity_flag = 0; | |
136 | static u8 tpd_proximity_detect = 1;//0-->close ; 1--> far away | |
137 | #endif | |
138 | ||
139 | #ifndef GTP_REG_REFRESH_RATE | |
140 | #define GTP_REG_REFRESH_RATE 0x8056 | |
141 | #endif | |
142 | ||
143 | struct i2c_client *i2c_client_point = NULL; | |
144 | static const struct i2c_device_id tpd_i2c_id[] = {{"gt9xx", 0}, {}}; | |
145 | static unsigned short force[] = {0, 0xBA, I2C_CLIENT_END, I2C_CLIENT_END}; | |
146 | static const unsigned short *const forces[] = { force, NULL }; | |
147 | //static struct i2c_client_address_data addr_data = { .forces = forces,}; | |
148 | static struct i2c_board_info __initdata i2c_tpd = { I2C_BOARD_INFO("gt9xx", (0xBA >> 1))}; | |
149 | static struct i2c_driver tpd_i2c_driver = | |
150 | { | |
151 | .probe = tpd_i2c_probe, | |
152 | .remove = tpd_i2c_remove, | |
153 | .detect = tpd_i2c_detect, | |
154 | .driver.name = "gt9xx", | |
155 | .id_table = tpd_i2c_id, | |
156 | .address_list = (const unsigned short *) forces, | |
157 | }; | |
158 | ||
159 | ||
160 | static u8 config[GTP_CONFIG_MAX_LENGTH + GTP_ADDR_LENGTH] | |
161 | = {GTP_REG_CONFIG_DATA >> 8, GTP_REG_CONFIG_DATA & 0xff}; | |
162 | #ifdef GTP_CHARGER_DETECT | |
163 | static u8 config_charger[GTP_CONFIG_MAX_LENGTH + GTP_ADDR_LENGTH] | |
164 | = {GTP_REG_CONFIG_DATA >> 8, GTP_REG_CONFIG_DATA & 0xff}; | |
165 | #endif | |
166 | #pragma pack(1) | |
167 | typedef struct | |
168 | { | |
169 | u16 pid; //product id // | |
170 | u16 vid; //version id // | |
171 | } st_tpd_info; | |
172 | #pragma pack() | |
173 | ||
174 | st_tpd_info tpd_info; | |
175 | u8 int_type = 0; | |
176 | u32 abs_x_max = 0; | |
177 | u32 abs_y_max = 0; | |
178 | u8 gtp_rawdiff_mode = 0; | |
179 | u8 cfg_len = 0; | |
180 | u8 grp_cfg_version = 0; | |
181 | u8 fixed_config = 0; | |
182 | u8 pnl_init_error = 0; | |
183 | static u8 chip_gt9xxs = 0; // true if chip type is gt9xxs,like gt915s | |
184 | ||
185 | #if GTP_COMPATIBLE_MODE | |
186 | u8 driver_num = 0; | |
187 | u8 sensor_num = 0; | |
188 | u8 gtp_ref_retries = 0; | |
189 | u8 gtp_clk_retries = 0; | |
190 | CHIP_TYPE_T gtp_chip_type = CHIP_TYPE_GT9; | |
191 | u8 gtp_clk_buf[6]; | |
192 | u8 rqst_processing = 0; | |
193 | ||
194 | extern u8 gup_check_fs_mounted(char *path_name); | |
195 | extern u8 gup_clk_calibration(void); | |
196 | extern s32 gup_load_main_system(char *filepath); | |
197 | extern s32 gup_fw_download_proc(void *dir, u8 dwn_mode); | |
198 | void gtp_get_chip_type(struct i2c_client *client); | |
199 | u8 gtp_fw_startup(struct i2c_client *client); | |
200 | static u8 gtp_bak_ref_proc(struct i2c_client *client, u8 mode); | |
201 | static u8 gtp_main_clk_proc(struct i2c_client *client); | |
202 | static void gtp_recovery_reset(struct i2c_client *client); | |
203 | #endif | |
204 | ||
205 | #if (GTP_ESD_PROTECT || GTP_COMPATIBLE_MODE) | |
206 | u8 is_reseting = 0; | |
207 | #endif | |
208 | ||
209 | /* proc file system */ | |
210 | s32 i2c_read_bytes(struct i2c_client *client, u16 addr, u8 *rxbuf, int len); | |
211 | s32 i2c_write_bytes(struct i2c_client *client, u16 addr, u8 *txbuf, int len); | |
212 | static struct proc_dir_entry *gt91xx_config_proc = NULL; | |
213 | ||
214 | #ifdef TPD_REFRESH_RATE | |
215 | /******************************************************* | |
216 | Function: | |
217 | Write refresh rate | |
218 | ||
219 | Input: | |
220 | rate: refresh rate N (Duration=5+N ms, N=0~15) | |
221 | ||
222 | Output: | |
223 | Executive outcomes.0---succeed. | |
224 | *******************************************************/ | |
225 | static u8 gtp_set_refresh_rate(u8 rate) | |
226 | { | |
227 | u8 buf[3] = {GTP_REG_REFRESH_RATE>>8, GTP_REG_REFRESH_RATE& 0xff, rate}; | |
228 | ||
229 | if (rate > 0xf) | |
230 | { | |
231 | GTP_ERROR("Refresh rate is over range (%d)", rate); | |
232 | return FAIL; | |
233 | } | |
234 | ||
235 | GTP_INFO("Refresh rate change to %d", rate); | |
236 | return gtp_i2c_write(i2c_client_point, buf, sizeof(buf)); | |
237 | } | |
238 | ||
239 | /******************************************************* | |
240 | Function: | |
241 | Get refresh rate | |
242 | ||
243 | Output: | |
244 | Refresh rate or error code | |
245 | *******************************************************/ | |
246 | static u8 gtp_get_refresh_rate(void) | |
247 | { | |
248 | int ret; | |
249 | ||
250 | u8 buf[3] = {GTP_REG_REFRESH_RATE>>8, GTP_REG_REFRESH_RATE& 0xff}; | |
251 | ret = gtp_i2c_read(i2c_client_point, buf, sizeof(buf)); | |
252 | if (ret < 0) | |
253 | return ret; | |
254 | ||
255 | GTP_INFO("Refresh rate is %d", buf[GTP_ADDR_LENGTH]); | |
256 | return buf[GTP_ADDR_LENGTH]; | |
257 | } | |
258 | ||
259 | //============================================================= | |
260 | static ssize_t show_refresh_rate(struct device *dev,struct device_attribute *attr, char *buf) | |
261 | { | |
262 | int ret = gtp_get_refresh_rate(); | |
263 | if (ret < 0) | |
264 | return 0; | |
265 | else | |
266 | return sprintf(buf, "%d\n", ret); | |
267 | } | |
268 | static ssize_t store_refresh_rate(struct device *dev,struct device_attribute *attr, const char *buf, size_t size) | |
269 | { | |
270 | //u32 rate = 0; | |
271 | gtp_set_refresh_rate(simple_strtoul(buf, NULL, 16)); | |
272 | return size; | |
273 | } | |
274 | static DEVICE_ATTR(tpd_refresh_rate, 0664, show_refresh_rate, store_refresh_rate); | |
275 | ||
276 | static struct device_attribute *gt9xx_attrs[] = | |
277 | { | |
278 | &dev_attr_tpd_refresh_rate, | |
279 | }; | |
280 | #endif | |
281 | //============================================================= | |
282 | ||
283 | ||
284 | /* proc file system */ | |
285 | s32 i2c_read_bytes(struct i2c_client *client, u16 addr, u8 *rxbuf, int len); | |
286 | s32 i2c_write_bytes(struct i2c_client *client, u16 addr, u8 *txbuf, int len); | |
287 | ||
288 | static int tpd_i2c_detect(struct i2c_client *client, struct i2c_board_info *info) | |
289 | { | |
290 | strcpy(info->type, "mtk-tpd"); | |
291 | return 0; | |
292 | } | |
293 | ||
294 | #ifdef TPD_PROXIMITY | |
295 | static s32 tpd_get_ps_value(void) | |
296 | { | |
297 | return tpd_proximity_detect; | |
298 | } | |
299 | ||
300 | static s32 tpd_enable_ps(s32 enable) | |
301 | { | |
302 | u8 state; | |
303 | s32 ret = -1; | |
304 | ||
305 | if (enable) | |
306 | { | |
307 | state = 1; | |
308 | tpd_proximity_flag = 1; | |
309 | GTP_INFO("TPD proximity function to be on."); | |
310 | } | |
311 | else | |
312 | { | |
313 | state = 0; | |
314 | tpd_proximity_flag = 0; | |
315 | GTP_INFO("TPD proximity function to be off."); | |
316 | } | |
317 | ||
318 | ret = i2c_write_bytes(i2c_client_point, TPD_PROXIMITY_ENABLE_REG, &state, 1); | |
319 | ||
320 | if (ret < 0) | |
321 | { | |
322 | GTP_ERROR("TPD %s proximity cmd failed.", state ? "enable" : "disable"); | |
323 | return ret; | |
324 | } | |
325 | ||
326 | GTP_INFO("TPD proximity function %s success.", state ? "enable" : "disable"); | |
327 | return 0; | |
328 | } | |
329 | ||
330 | s32 tpd_ps_operate(void *self, u32 command, void *buff_in, s32 size_in, | |
331 | void *buff_out, s32 size_out, s32 *actualout) | |
332 | { | |
333 | s32 err = 0; | |
334 | s32 value; | |
335 | hwm_sensor_data *sensor_data; | |
336 | ||
337 | switch (command) | |
338 | { | |
339 | case SENSOR_DELAY: | |
340 | if ((buff_in == NULL) || (size_in < sizeof(int))) | |
341 | { | |
342 | GTP_ERROR("Set delay parameter error!"); | |
343 | err = -EINVAL; | |
344 | } | |
345 | ||
346 | // Do nothing | |
347 | break; | |
348 | ||
349 | case SENSOR_ENABLE: | |
350 | if ((buff_in == NULL) || (size_in < sizeof(int))) | |
351 | { | |
352 | GTP_ERROR("Enable sensor parameter error!"); | |
353 | err = -EINVAL; | |
354 | } | |
355 | else | |
356 | { | |
357 | value = *(int *)buff_in; | |
358 | err = tpd_enable_ps(value); | |
359 | } | |
360 | ||
361 | break; | |
362 | ||
363 | case SENSOR_GET_DATA: | |
364 | if ((buff_out == NULL) || (size_out < sizeof(hwm_sensor_data))) | |
365 | { | |
366 | GTP_ERROR("Get sensor data parameter error!"); | |
367 | err = -EINVAL; | |
368 | } | |
369 | else | |
370 | { | |
371 | sensor_data = (hwm_sensor_data *)buff_out; | |
372 | sensor_data->values[0] = tpd_get_ps_value(); | |
373 | sensor_data->value_divide = 1; | |
374 | sensor_data->status = SENSOR_STATUS_ACCURACY_MEDIUM; | |
375 | } | |
376 | ||
377 | break; | |
378 | ||
379 | default: | |
380 | GTP_ERROR("proxmy sensor operate function no this parameter %d!\n", command); | |
381 | err = -1; | |
382 | break; | |
383 | } | |
384 | ||
385 | return err; | |
386 | } | |
387 | #endif | |
388 | ||
389 | static int gt91xx_config_read_proc(struct file *file, char *buffer, size_t count, loff_t *ppos) | |
390 | { | |
391 | char *page = NULL; | |
392 | char *ptr = NULL; | |
393 | char temp_data[GTP_CONFIG_MAX_LENGTH + 2] = {0}; | |
394 | int i, len, err = -1; | |
395 | ||
396 | page = kmalloc(PAGE_SIZE, GFP_KERNEL); | |
397 | if (!page) | |
398 | { | |
399 | kfree(page); | |
400 | return -ENOMEM; | |
401 | } | |
402 | ||
403 | ptr = page; | |
404 | ptr += sprintf(ptr, "==== GT9XX config init value====\n"); | |
405 | ||
406 | for (i = 0 ; i < GTP_CONFIG_MAX_LENGTH ; i++) | |
407 | { | |
408 | ptr += sprintf(ptr, "0x%02X ", config[i + 2]); | |
409 | ||
410 | if (i % 8 == 7) | |
411 | ptr += sprintf(ptr, "\n"); | |
412 | } | |
413 | ||
414 | ptr += sprintf(ptr, "\n"); | |
415 | ||
416 | ptr += sprintf(ptr, "==== GT9XX config real value====\n"); | |
417 | i2c_read_bytes(i2c_client_point, GTP_REG_CONFIG_DATA, temp_data, GTP_CONFIG_MAX_LENGTH); | |
418 | ||
419 | for (i = 0 ; i < GTP_CONFIG_MAX_LENGTH ; i++) | |
420 | { | |
421 | ptr += sprintf(ptr, "0x%02X ", temp_data[i]); | |
422 | ||
423 | if (i % 8 == 7) | |
424 | ptr += sprintf(ptr, "\n"); | |
425 | } | |
426 | /* Touch PID & VID */ | |
427 | ptr += sprintf(ptr, "\n"); | |
428 | ptr += sprintf(ptr, "==== GT9XX Version ID ====\n"); | |
429 | i2c_read_bytes(i2c_client_point, GTP_REG_VERSION, temp_data, 6); | |
430 | ptr += sprintf(ptr, "Chip PID: %c%c%c VID: 0x%02X%02X\n", temp_data[0], temp_data[1], temp_data[2], temp_data[5], temp_data[4]); | |
431 | #if GTP_COMPATIBLE_MODE | |
432 | if (CHIP_TYPE_GT9F == gtp_chip_type) | |
433 | { | |
434 | ptr += sprintf(ptr, "Driver VID: 0x%02X%02X\n", gtp_default_FW_fl[12], gtp_default_FW_fl[13]); | |
435 | } | |
436 | else | |
437 | { | |
438 | ptr += sprintf(ptr, "Driver VID: 0x%02X%02X\n", gtp_default_FW[12], gtp_default_FW[13]); | |
439 | } | |
440 | #else | |
441 | ptr += sprintf(ptr, "Driver VID: 0x%02X%02X\n", gtp_default_FW[12], gtp_default_FW[13]); | |
442 | #endif | |
443 | i2c_read_bytes(i2c_client_point, 0x41E4, temp_data, 1); | |
444 | ptr += sprintf(ptr, "Boot status 0x%X\n", temp_data[0]); | |
445 | ||
446 | /* Touch Status and Clock Gate */ | |
447 | ptr += sprintf(ptr, "\n"); | |
448 | ptr += sprintf(ptr, "==== Touch Status and Clock Gate ====\n"); | |
449 | ptr += sprintf(ptr, "status: 1: on, 0 :off\n"); | |
450 | ptr += sprintf(ptr, "status:%d\n", (tpd_halt+1)&0x1); | |
451 | ||
452 | ||
453 | len = ptr - page; | |
454 | if(*ppos >= len) | |
455 | { | |
456 | kfree(page); | |
457 | return 0; | |
458 | } | |
459 | err = copy_to_user(buffer,(char *)page,len); | |
460 | *ppos += len; | |
461 | if(err) | |
462 | { | |
463 | kfree(page); | |
464 | return err; | |
465 | } | |
466 | kfree(page); | |
467 | return len; | |
468 | ||
469 | //return (ptr - page); | |
470 | } | |
471 | ||
472 | static int gt91xx_config_write_proc(struct file *file, const char *buffer, size_t count, loff_t *ppos) | |
473 | { | |
474 | s32 ret = 0; | |
475 | char temp[25] = {0}; // for store special format cmd | |
476 | char mode_str[15] = {0}; | |
477 | unsigned int mode; | |
478 | u8 buf[1]; | |
479 | ||
480 | GTP_DEBUG("write count %ld\n", (unsigned long)count); | |
481 | ||
482 | if (count > GTP_CONFIG_MAX_LENGTH) | |
483 | { | |
484 | GTP_ERROR("size not match [%d:%ld]", GTP_CONFIG_MAX_LENGTH, (unsigned long)count); | |
485 | return -EFAULT; | |
486 | } | |
487 | ||
488 | /**********************************************/ | |
489 | /* for store special format cmd */ | |
490 | if (copy_from_user(temp, buffer, sizeof(temp))) | |
491 | { | |
492 | GTP_ERROR("copy from user fail 2"); | |
493 | return -EFAULT; | |
494 | } | |
495 | sscanf(temp, "%s %d", (char *)&mode_str, &mode); | |
496 | ||
497 | /***********POLLING/EINT MODE switch****************/ | |
498 | if(strcmp(mode_str, "polling") == 0) | |
499 | { | |
500 | if(mode>=10&&mode<=200) | |
501 | { | |
502 | GTP_INFO("Switch to polling mode, polling time is %d",mode); | |
503 | tpd_eint_mode=0; | |
504 | tpd_polling_time=mode; | |
505 | tpd_flag = 1; | |
506 | wake_up_interruptible(&waiter); | |
507 | } | |
508 | else | |
509 | { | |
510 | GTP_INFO("Wrong polling time, please set between 10~200ms"); | |
511 | } | |
512 | return count; | |
513 | } | |
514 | if(strcmp(mode_str, "eint") == 0) | |
515 | { | |
516 | GTP_INFO("Switch to eint mode"); | |
517 | tpd_eint_mode=1; | |
518 | return count; | |
519 | } | |
520 | /**********************************************/ | |
521 | if(strcmp(mode_str, "switch") == 0) | |
522 | { | |
523 | if(mode == 0)// turn off | |
524 | tpd_off(); | |
525 | else if(mode == 1)//turn on | |
526 | tpd_on(); | |
527 | else | |
528 | GTP_ERROR("error mode :%d", mode); | |
529 | return count; | |
530 | } | |
531 | //force clear config | |
532 | if(strcmp(mode_str, "clear_config") == 0) | |
533 | { | |
534 | GTP_INFO("Force clear config"); | |
535 | buf[0] = 0x10; | |
536 | ret = i2c_write_bytes(i2c_client_point, GTP_REG_SLEEP, buf, 1); | |
537 | return count; | |
538 | } | |
539 | ||
540 | if (copy_from_user(&config[2], buffer, count)) | |
541 | { | |
542 | GTP_ERROR("copy from user fail\n"); | |
543 | return -EFAULT; | |
544 | } | |
545 | ||
546 | /***********clk operate reseved****************/ | |
547 | /**********************************************/ | |
548 | ret = gtp_send_cfg(i2c_client_point); | |
549 | abs_x_max = (config[RESOLUTION_LOC + 1] << 8) + config[RESOLUTION_LOC]; | |
550 | abs_y_max = (config[RESOLUTION_LOC + 3] << 8) + config[RESOLUTION_LOC + 2]; | |
551 | int_type = (config[TRIGGER_LOC]) & 0x03; | |
552 | ||
553 | if (ret < 0) | |
554 | { | |
555 | GTP_ERROR("send config failed."); | |
556 | } | |
557 | ||
558 | return count; | |
559 | } | |
560 | ||
561 | #if GTP_SUPPORT_I2C_DMA | |
562 | s32 i2c_dma_read(struct i2c_client *client, u16 addr, u8 *rxbuf, s32 len) | |
563 | { | |
564 | int ret; | |
565 | s32 retry = 0; | |
566 | u8 buffer[2]; | |
567 | ||
568 | struct i2c_msg msg[2] = | |
569 | { | |
570 | { | |
571 | .addr = (client->addr & I2C_MASK_FLAG), | |
572 | .flags = 0, | |
573 | .buf = buffer, | |
574 | .len = 2, | |
575 | .timing = I2C_MASTER_CLOCK | |
576 | }, | |
577 | { | |
578 | .addr = (client->addr & I2C_MASK_FLAG), | |
579 | .ext_flag = (client->ext_flag | I2C_ENEXT_FLAG | I2C_DMA_FLAG), | |
580 | .flags = I2C_M_RD, | |
581 | .buf = (u8*)gpDMABuf_pa, | |
582 | .len = len, | |
583 | .timing = I2C_MASTER_CLOCK | |
584 | }, | |
585 | }; | |
586 | ||
587 | buffer[0] = (addr >> 8) & 0xFF; | |
588 | buffer[1] = addr & 0xFF; | |
589 | ||
590 | if (rxbuf == NULL) | |
591 | return -1; | |
592 | ||
593 | //GTP_DEBUG("dma i2c read: 0x%04X, %d bytes(s)", addr, len); | |
594 | for (retry = 0; retry < 5; ++retry) | |
595 | { | |
596 | ret = i2c_transfer(client->adapter, &msg[0], 2); | |
597 | if (ret < 0) | |
598 | { | |
599 | continue; | |
600 | } | |
601 | memcpy(rxbuf, gpDMABuf_va, len); | |
602 | return 0; | |
603 | } | |
604 | GTP_ERROR("Dma I2C Read Error: 0x%04X, %d byte(s), err-code: %d", addr, len, ret); | |
605 | return ret; | |
606 | } | |
607 | ||
608 | ||
609 | s32 i2c_dma_write(struct i2c_client *client, u16 addr, u8 *txbuf, s32 len) | |
610 | { | |
611 | int ret; | |
612 | s32 retry = 0; | |
613 | u8 *wr_buf = gpDMABuf_va; | |
614 | ||
615 | struct i2c_msg msg = | |
616 | { | |
617 | .addr = (client->addr & I2C_MASK_FLAG), | |
618 | .ext_flag = (client->ext_flag | I2C_ENEXT_FLAG | I2C_DMA_FLAG), | |
619 | .flags = 0, | |
620 | .buf = (u8*)gpDMABuf_pa, | |
621 | .len = 2 + len, | |
622 | .timing = I2C_MASTER_CLOCK | |
623 | }; | |
624 | ||
625 | wr_buf[0] = (u8)((addr >> 8) & 0xFF); | |
626 | wr_buf[1] = (u8)(addr & 0xFF); | |
627 | ||
628 | if (txbuf == NULL) | |
629 | return -1; | |
630 | ||
631 | //GTP_DEBUG("dma i2c write: 0x%04X, %d bytes(s)", addr, len); | |
632 | memcpy(wr_buf+2, txbuf, len); | |
633 | for (retry = 0; retry < 5; ++retry) | |
634 | { | |
635 | ret = i2c_transfer(client->adapter, &msg, 1); | |
636 | if (ret < 0) | |
637 | { | |
638 | continue; | |
639 | } | |
640 | return 0; | |
641 | } | |
642 | GTP_ERROR("Dma I2C Write Error: 0x%04X, %d byte(s), err-code: %d", addr, len, ret); | |
643 | return ret; | |
644 | } | |
645 | ||
646 | s32 i2c_read_bytes_dma(struct i2c_client *client, u16 addr, u8 *rxbuf, s32 len) | |
647 | { | |
648 | s32 left = len; | |
649 | s32 read_len = 0; | |
650 | u8 *rd_buf = rxbuf; | |
651 | s32 ret = 0; | |
652 | ||
653 | //GTP_DEBUG("Read bytes dma: 0x%04X, %d byte(s)", addr, len); | |
654 | while (left > 0) | |
655 | { | |
656 | if (left > GTP_DMA_MAX_TRANSACTION_LENGTH) | |
657 | { | |
658 | read_len = GTP_DMA_MAX_TRANSACTION_LENGTH; | |
659 | } | |
660 | else | |
661 | { | |
662 | read_len = left; | |
663 | } | |
664 | ret = i2c_dma_read(client, addr, rd_buf, read_len); | |
665 | if (ret < 0) | |
666 | { | |
667 | GTP_ERROR("dma read failed"); | |
668 | return -1; | |
669 | } | |
670 | ||
671 | left -= read_len; | |
672 | addr += read_len; | |
673 | rd_buf += read_len; | |
674 | } | |
675 | return 0; | |
676 | } | |
677 | ||
678 | s32 i2c_write_bytes_dma(struct i2c_client *client, u16 addr, u8 *txbuf, s32 len) | |
679 | { | |
680 | ||
681 | s32 ret = 0; | |
682 | s32 write_len = 0; | |
683 | s32 left = len; | |
684 | u8 *wr_buf = txbuf; | |
685 | ||
686 | //GTP_DEBUG("Write bytes dma: 0x%04X, %d byte(s)", addr, len); | |
687 | while (left > 0) | |
688 | { | |
689 | if (left > GTP_DMA_MAX_I2C_TRANSFER_SIZE) | |
690 | { | |
691 | write_len = GTP_DMA_MAX_I2C_TRANSFER_SIZE; | |
692 | } | |
693 | else | |
694 | { | |
695 | write_len = left; | |
696 | } | |
697 | ret = i2c_dma_write(client, addr, wr_buf, write_len); | |
698 | ||
699 | if (ret < 0) | |
700 | { | |
701 | GTP_ERROR("dma i2c write failed!"); | |
702 | return -1; | |
703 | } | |
704 | ||
705 | left -= write_len; | |
706 | addr += write_len; | |
707 | wr_buf += write_len; | |
708 | } | |
709 | return 0; | |
710 | } | |
711 | #endif | |
712 | ||
713 | ||
714 | int i2c_read_bytes_non_dma(struct i2c_client *client, u16 addr, u8 *rxbuf, int len) | |
715 | { | |
716 | u8 buffer[GTP_ADDR_LENGTH]; | |
717 | u8 retry; | |
718 | u16 left = len; | |
719 | u16 offset = 0; | |
720 | ||
721 | struct i2c_msg msg[2] = | |
722 | { | |
723 | { | |
724 | .addr = ((client->addr &I2C_MASK_FLAG) | (I2C_ENEXT_FLAG)), | |
725 | //.addr = ((client->addr &I2C_MASK_FLAG) | (I2C_PUSHPULL_FLAG)), | |
726 | .flags = 0, | |
727 | .buf = buffer, | |
728 | .len = GTP_ADDR_LENGTH, | |
729 | .timing = I2C_MASTER_CLOCK | |
730 | }, | |
731 | { | |
732 | .addr = ((client->addr &I2C_MASK_FLAG) | (I2C_ENEXT_FLAG)), | |
733 | //.addr = ((client->addr &I2C_MASK_FLAG) | (I2C_PUSHPULL_FLAG)), | |
734 | .flags = I2C_M_RD, | |
735 | .timing = I2C_MASTER_CLOCK | |
736 | }, | |
737 | }; | |
738 | ||
739 | if (rxbuf == NULL) | |
740 | return -1; | |
741 | ||
742 | GTP_DEBUG("i2c_read_bytes to device %02X address %04X len %d", client->addr, addr, len); | |
743 | ||
744 | while (left > 0) | |
745 | { | |
746 | buffer[0] = ((addr + offset) >> 8) & 0xFF; | |
747 | buffer[1] = (addr + offset) & 0xFF; | |
748 | ||
749 | msg[1].buf = &rxbuf[offset]; | |
750 | ||
751 | if (left > MAX_TRANSACTION_LENGTH) | |
752 | { | |
753 | msg[1].len = MAX_TRANSACTION_LENGTH; | |
754 | left -= MAX_TRANSACTION_LENGTH; | |
755 | offset += MAX_TRANSACTION_LENGTH; | |
756 | } | |
757 | else | |
758 | { | |
759 | msg[1].len = left; | |
760 | left = 0; | |
761 | } | |
762 | ||
763 | retry = 0; | |
764 | ||
765 | while (i2c_transfer(client->adapter, &msg[0], 2) != 2) | |
766 | { | |
767 | retry++; | |
768 | ||
769 | if (retry == 5) | |
770 | { | |
771 | GTP_ERROR("I2C read 0x%X length=%d failed\n", addr + offset, len); | |
772 | return -1; | |
773 | } | |
774 | } | |
775 | } | |
776 | ||
777 | return 0; | |
778 | } | |
779 | ||
780 | ||
781 | int i2c_read_bytes(struct i2c_client *client, u16 addr, u8 *rxbuf, int len) | |
782 | { | |
783 | #if GTP_SUPPORT_I2C_DMA | |
784 | return i2c_read_bytes_dma(client, addr, rxbuf, len); | |
785 | #else | |
786 | return i2c_read_bytes_non_dma(client, addr, rxbuf, len); | |
787 | #endif | |
788 | } | |
789 | ||
790 | s32 gtp_i2c_read(struct i2c_client *client, u8 *buf, s32 len) | |
791 | { | |
792 | s32 ret = -1; | |
793 | u16 addr = (buf[0] << 8) + buf[1]; | |
794 | ||
795 | ret = i2c_read_bytes_non_dma(client, addr, &buf[2], len - 2); | |
796 | ||
797 | if (!ret) | |
798 | { | |
799 | return 2; | |
800 | } | |
801 | else | |
802 | { | |
803 | #if GTP_SLIDE_WAKEUP | |
804 | if (DOZE_ENABLED == doze_status) | |
805 | { | |
806 | return ret; | |
807 | } | |
808 | #endif | |
809 | #if GTP_COMPATIBLE_MODE | |
810 | if (CHIP_TYPE_GT9F == gtp_chip_type) | |
811 | { | |
812 | gtp_recovery_reset(client); | |
813 | } | |
814 | else | |
815 | #endif | |
816 | { | |
817 | gtp_reset_guitar(client, 20); | |
818 | } | |
819 | return ret; | |
820 | } | |
821 | } | |
822 | ||
823 | ||
824 | s32 gtp_i2c_read_dbl_check(struct i2c_client *client, u16 addr, u8 *rxbuf, int len) | |
825 | { | |
826 | u8 buf[16] = {0}; | |
827 | u8 confirm_buf[16] = {0}; | |
828 | u8 retry = 0; | |
829 | ||
830 | while (retry++ < 3) | |
831 | { | |
832 | memset(buf, 0xAA, 16); | |
833 | buf[0] = (u8)(addr >> 8); | |
834 | buf[1] = (u8)(addr & 0xFF); | |
835 | gtp_i2c_read(client, buf, len + 2); | |
836 | ||
837 | memset(confirm_buf, 0xAB, 16); | |
838 | confirm_buf[0] = (u8)(addr >> 8); | |
839 | confirm_buf[1] = (u8)(addr & 0xFF); | |
840 | gtp_i2c_read(client, confirm_buf, len + 2); | |
841 | ||
842 | if (!memcmp(buf, confirm_buf, len+2)) | |
843 | { | |
844 | memcpy(rxbuf, confirm_buf+2, len); | |
845 | return SUCCESS; | |
846 | } | |
847 | } | |
848 | GTP_ERROR("i2c read 0x%04X, %d bytes, double check failed!", addr, len); | |
849 | return FAIL; | |
850 | } | |
851 | ||
852 | int i2c_write_bytes_non_dma(struct i2c_client *client, u16 addr, u8 *txbuf, int len) | |
853 | { | |
854 | u8 buffer[MAX_TRANSACTION_LENGTH]; | |
855 | u16 left = len; | |
856 | u16 offset = 0; | |
857 | u8 retry = 0; | |
858 | ||
859 | struct i2c_msg msg = | |
860 | { | |
861 | .addr = ((client->addr &I2C_MASK_FLAG) | (I2C_ENEXT_FLAG)), | |
862 | //.addr = ((client->addr &I2C_MASK_FLAG) | (I2C_PUSHPULL_FLAG)), | |
863 | .flags = 0, | |
864 | .buf = buffer, | |
865 | .timing = I2C_MASTER_CLOCK, | |
866 | }; | |
867 | ||
868 | ||
869 | if (txbuf == NULL) | |
870 | return -1; | |
871 | ||
872 | GTP_DEBUG("i2c_write_bytes to device %02X address %04X len %d", client->addr, addr, len); | |
873 | ||
874 | while (left > 0) | |
875 | { | |
876 | retry = 0; | |
877 | ||
878 | buffer[0] = ((addr + offset) >> 8) & 0xFF; | |
879 | buffer[1] = (addr + offset) & 0xFF; | |
880 | ||
881 | if (left > MAX_I2C_TRANSFER_SIZE) | |
882 | { | |
883 | memcpy(&buffer[GTP_ADDR_LENGTH], &txbuf[offset], MAX_I2C_TRANSFER_SIZE); | |
884 | msg.len = MAX_TRANSACTION_LENGTH; | |
885 | left -= MAX_I2C_TRANSFER_SIZE; | |
886 | offset += MAX_I2C_TRANSFER_SIZE; | |
887 | } | |
888 | else | |
889 | { | |
890 | memcpy(&buffer[GTP_ADDR_LENGTH], &txbuf[offset], left); | |
891 | msg.len = left + GTP_ADDR_LENGTH; | |
892 | left = 0; | |
893 | } | |
894 | ||
895 | //GTP_DEBUG("byte left %d offset %d\n", left, offset); | |
896 | ||
897 | while (i2c_transfer(client->adapter, &msg, 1) != 1) | |
898 | { | |
899 | retry++; | |
900 | ||
901 | if (retry == 5) | |
902 | { | |
903 | GTP_ERROR("I2C write 0x%X%X length=%d failed\n", buffer[0], buffer[1], len); | |
904 | return -1; | |
905 | } | |
906 | } | |
907 | } | |
908 | ||
909 | return 0; | |
910 | } | |
911 | ||
912 | int i2c_write_bytes(struct i2c_client *client, u16 addr, u8 *txbuf, int len) | |
913 | { | |
914 | #if GTP_SUPPORT_I2C_DMA | |
915 | return i2c_write_bytes_dma(client, addr, txbuf, len); | |
916 | #else | |
917 | return i2c_write_bytes_non_dma(client, addr, txbuf, len); | |
918 | #endif | |
919 | } | |
920 | ||
921 | s32 gtp_i2c_write(struct i2c_client *client, u8 *buf, s32 len) | |
922 | { | |
923 | s32 ret = -1; | |
924 | u16 addr = (buf[0] << 8) + buf[1]; | |
925 | ||
926 | ret = i2c_write_bytes_non_dma(client, addr, &buf[2], len - 2); | |
927 | ||
928 | if (!ret) | |
929 | { | |
930 | return 1; | |
931 | } | |
932 | else | |
933 | { | |
934 | #if GTP_SLIDE_WAKEUP | |
935 | if (DOZE_ENABLED == doze_status) | |
936 | { | |
937 | return ret; | |
938 | } | |
939 | #endif | |
940 | #if GTP_COMPATIBLE_MODE | |
941 | if (CHIP_TYPE_GT9F == gtp_chip_type) | |
942 | { | |
943 | gtp_recovery_reset(client); | |
944 | } | |
945 | else | |
946 | #endif | |
947 | { | |
948 | gtp_reset_guitar(client, 20); | |
949 | } | |
950 | return ret; | |
951 | } | |
952 | } | |
953 | ||
954 | ||
955 | ||
956 | /******************************************************* | |
957 | Function: | |
958 | Send config Function. | |
959 | ||
960 | Input: | |
961 | client: i2c client. | |
962 | ||
963 | Output: | |
964 | Executive outcomes.0--success,non-0--fail. | |
965 | *******************************************************/ | |
966 | s32 gtp_send_cfg(struct i2c_client *client) | |
967 | { | |
968 | s32 ret = 1; | |
969 | ||
970 | #if GTP_DRIVER_SEND_CFG | |
971 | s32 retry = 0; | |
972 | if (fixed_config) | |
973 | { | |
974 | GTP_INFO("Ic fixed config, no config sent!"); | |
975 | return 0; | |
976 | } | |
977 | else if (pnl_init_error) | |
978 | { | |
979 | GTP_INFO("Error occurred in init_panel, no config sent!"); | |
980 | return 0; | |
981 | } | |
982 | ||
983 | GTP_DEBUG("Driver Send Config"); | |
984 | for (retry = 0; retry < 5; retry++) | |
985 | { | |
986 | ret = gtp_i2c_write(client, config, GTP_CONFIG_MAX_LENGTH + GTP_ADDR_LENGTH); | |
987 | ||
988 | if (ret > 0) | |
989 | { | |
990 | break; | |
991 | } | |
992 | } | |
993 | #endif | |
994 | return ret; | |
995 | } | |
996 | ||
997 | ||
998 | /******************************************************* | |
999 | Function: | |
1000 | Read goodix touchscreen version function. | |
1001 | ||
1002 | Input: | |
1003 | client: i2c client struct. | |
1004 | version:address to store version info | |
1005 | ||
1006 | Output: | |
1007 | Executive outcomes.0---succeed. | |
1008 | *******************************************************/ | |
1009 | s32 gtp_read_version(struct i2c_client *client, u16 *version) | |
1010 | { | |
1011 | s32 ret = -1; | |
1012 | s32 i; | |
1013 | u8 buf[8] = {GTP_REG_VERSION >> 8, GTP_REG_VERSION & 0xff}; | |
1014 | ||
1015 | GTP_DEBUG_FUNC(); | |
1016 | ||
1017 | ret = gtp_i2c_read(client, buf, sizeof(buf)); | |
1018 | ||
1019 | if (ret < 0) | |
1020 | { | |
1021 | GTP_ERROR("GTP read version failed"); | |
1022 | return ret; | |
1023 | } | |
1024 | ||
1025 | if (version) | |
1026 | { | |
1027 | *version = (buf[7] << 8) | buf[6]; | |
1028 | } | |
1029 | ||
1030 | tpd_info.vid = *version; | |
1031 | tpd_info.pid = 0x00; | |
1032 | ||
1033 | for (i = 0; i < 4; i++) | |
1034 | { | |
1035 | if (buf[i + 2] < 0x30)break; | |
1036 | ||
1037 | tpd_info.pid |= ((buf[i + 2] - 0x30) << ((3 - i) * 4)); | |
1038 | } | |
1039 | ||
1040 | if (buf[5] == 0x00) | |
1041 | { | |
1042 | GTP_INFO("IC VERSION: %c%c%c_%02x%02x", | |
1043 | buf[2], buf[3], buf[4], buf[7], buf[6]); | |
1044 | } | |
1045 | else | |
1046 | { | |
1047 | if (buf[5] == 'S' || buf[5] == 's') | |
1048 | { | |
1049 | chip_gt9xxs = 1; | |
1050 | } | |
1051 | GTP_INFO("IC VERSION:%c%c%c%c_%02x%02x", | |
1052 | buf[2], buf[3], buf[4], buf[5], buf[7], buf[6]); | |
1053 | } | |
1054 | return ret; | |
1055 | } | |
1056 | ||
1057 | #if GTP_DRIVER_SEND_CFG | |
1058 | /******************************************************* | |
1059 | Function: | |
1060 | Get information from ic, such as resolution and | |
1061 | int trigger type | |
1062 | Input: | |
1063 | client: i2c client private struct. | |
1064 | ||
1065 | Output: | |
1066 | FAIL: i2c failed, SUCCESS: i2c ok | |
1067 | *******************************************************/ | |
1068 | static s32 gtp_get_info(struct i2c_client *client) | |
1069 | { | |
1070 | u8 opr_buf[6] = {0}; | |
1071 | s32 ret = 0; | |
1072 | ||
1073 | opr_buf[0] = (u8)((GTP_REG_CONFIG_DATA+1) >> 8); | |
1074 | opr_buf[1] = (u8)((GTP_REG_CONFIG_DATA+1) & 0xFF); | |
1075 | ||
1076 | ret = gtp_i2c_read(client, opr_buf, 6); | |
1077 | if (ret < 0) | |
1078 | { | |
1079 | return FAIL; | |
1080 | } | |
1081 | ||
1082 | abs_x_max = (opr_buf[3] << 8) + opr_buf[2]; | |
1083 | abs_y_max = (opr_buf[5] << 8) + opr_buf[4]; | |
1084 | ||
1085 | opr_buf[0] = (u8)((GTP_REG_CONFIG_DATA+6) >> 8); | |
1086 | opr_buf[1] = (u8)((GTP_REG_CONFIG_DATA+6) & 0xFF); | |
1087 | ||
1088 | ret = gtp_i2c_read(client, opr_buf, 3); | |
1089 | if (ret < 0) | |
1090 | { | |
1091 | return FAIL; | |
1092 | } | |
1093 | int_type = opr_buf[2] & 0x03; | |
1094 | ||
1095 | GTP_INFO("X_MAX = %d, Y_MAX = %d, TRIGGER = 0x%02x", | |
1096 | abs_x_max,abs_y_max, int_type); | |
1097 | ||
1098 | return SUCCESS; | |
1099 | } | |
1100 | #endif | |
1101 | ||
1102 | ||
1103 | /******************************************************* | |
1104 | Function: | |
1105 | GTP initialize function. | |
1106 | ||
1107 | Input: | |
1108 | client: i2c client private struct. | |
1109 | ||
1110 | Output: | |
1111 | Executive outcomes.0---succeed. | |
1112 | *******************************************************/ | |
1113 | static s32 gtp_init_panel(struct i2c_client *client) | |
1114 | { | |
1115 | s32 ret = 0; | |
1116 | ||
1117 | #if GTP_DRIVER_SEND_CFG | |
1118 | s32 i; | |
1119 | u8 check_sum = 0; | |
1120 | u8 opr_buf[16]; | |
1121 | u8 sensor_id = 0; | |
1122 | ||
1123 | u8 cfg_info_group1[] = CTP_CFG_GROUP1; | |
1124 | u8 cfg_info_group2[] = CTP_CFG_GROUP2; | |
1125 | u8 cfg_info_group3[] = CTP_CFG_GROUP3; | |
1126 | u8 cfg_info_group4[] = CTP_CFG_GROUP4; | |
1127 | u8 cfg_info_group5[] = CTP_CFG_GROUP5; | |
1128 | u8 cfg_info_group6[] = CTP_CFG_GROUP6; | |
1129 | u8 *send_cfg_buf[] = {cfg_info_group1, cfg_info_group2, cfg_info_group3, | |
1130 | cfg_info_group4, cfg_info_group5, cfg_info_group6}; | |
1131 | u8 cfg_info_len[] = { CFG_GROUP_LEN(cfg_info_group1), | |
1132 | CFG_GROUP_LEN(cfg_info_group2), | |
1133 | CFG_GROUP_LEN(cfg_info_group3), | |
1134 | CFG_GROUP_LEN(cfg_info_group4), | |
1135 | CFG_GROUP_LEN(cfg_info_group5), | |
1136 | CFG_GROUP_LEN(cfg_info_group6)}; | |
1137 | ||
1138 | GTP_DEBUG("Config Groups\' Lengths: %d, %d, %d, %d, %d, %d", | |
1139 | cfg_info_len[0], cfg_info_len[1], cfg_info_len[2], cfg_info_len[3], | |
1140 | cfg_info_len[4], cfg_info_len[5]); | |
1141 | ||
1142 | if ((!cfg_info_len[1]) && (!cfg_info_len[2]) && | |
1143 | (!cfg_info_len[3]) && (!cfg_info_len[4]) && | |
1144 | (!cfg_info_len[5])) | |
1145 | { | |
1146 | sensor_id = 0; | |
1147 | } | |
1148 | else | |
1149 | { | |
1150 | #if GTP_COMPATIBLE_MODE | |
1151 | if (CHIP_TYPE_GT9F == gtp_chip_type) | |
1152 | { | |
1153 | msleep(50); | |
1154 | } | |
1155 | #endif | |
1156 | ret = gtp_i2c_read_dbl_check(client, GTP_REG_SENSOR_ID, &sensor_id, 1); | |
1157 | if (SUCCESS == ret) | |
1158 | { | |
1159 | if (sensor_id >= 0x06) | |
1160 | { | |
1161 | GTP_ERROR("Invalid sensor_id(0x%02X), No Config Sent!", sensor_id); | |
1162 | pnl_init_error = 1; | |
1163 | ||
1164 | #if GTP_COMPATIBLE_MODE | |
1165 | if (CHIP_TYPE_GT9F == gtp_chip_type) | |
1166 | { | |
1167 | // do nothing; | |
1168 | } | |
1169 | else | |
1170 | #endif | |
1171 | { | |
1172 | gtp_get_info(client); | |
1173 | } | |
1174 | return -1; | |
1175 | } | |
1176 | } | |
1177 | else | |
1178 | { | |
1179 | GTP_ERROR("Failed to get sensor_id, No config sent!"); | |
1180 | pnl_init_error = 1; | |
1181 | return -1; | |
1182 | } | |
1183 | GTP_INFO("Sensor_ID: %d", sensor_id); | |
1184 | } | |
1185 | ||
1186 | cfg_len = cfg_info_len[sensor_id]; | |
1187 | ||
1188 | GTP_INFO("CTP_CONFIG_GROUP%d used, config length: %d", sensor_id + 1, cfg_len); | |
1189 | ||
1190 | if (cfg_len < GTP_CONFIG_MIN_LENGTH) | |
1191 | { | |
1192 | GTP_ERROR("CTP_CONFIG_GROUP%d is INVALID CONFIG GROUP! NO Config Sent! You need to check you header file CFG_GROUP section!", sensor_id+1); | |
1193 | pnl_init_error = 1; | |
1194 | return -1; | |
1195 | } | |
1196 | ||
1197 | #if GTP_COMPATIBLE_MODE | |
1198 | if (CHIP_TYPE_GT9F == gtp_chip_type) | |
1199 | { | |
1200 | fixed_config = 0; | |
1201 | } | |
1202 | else | |
1203 | #endif | |
1204 | { | |
1205 | ret = gtp_i2c_read_dbl_check(client, GTP_REG_CONFIG_DATA, &opr_buf[0], 1); | |
1206 | ||
1207 | if (ret == SUCCESS) | |
1208 | { | |
1209 | GTP_DEBUG("CFG_CONFIG_GROUP%d Config Version: %d, 0x%02X; IC Config Version: %d, 0x%02X", sensor_id+1, | |
1210 | send_cfg_buf[sensor_id][0], send_cfg_buf[sensor_id][0], opr_buf[0], opr_buf[0]); | |
1211 | ||
1212 | if (opr_buf[0] < 90) | |
1213 | { | |
1214 | grp_cfg_version = send_cfg_buf[sensor_id][0]; // backup group config version | |
1215 | send_cfg_buf[sensor_id][0] = 0x00; | |
1216 | fixed_config = 0; | |
1217 | } | |
1218 | else // treated as fixed config, not send config | |
1219 | { | |
1220 | GTP_INFO("Ic fixed config with config version(%d)", opr_buf[0]); | |
1221 | fixed_config = 1; | |
1222 | } | |
1223 | } | |
1224 | else | |
1225 | { | |
1226 | GTP_ERROR("Failed to get ic config version!No config sent!"); | |
1227 | return -1; | |
1228 | } | |
1229 | } | |
1230 | ||
1231 | memset(&config[GTP_ADDR_LENGTH], 0, GTP_CONFIG_MAX_LENGTH); | |
1232 | memcpy(&config[GTP_ADDR_LENGTH], send_cfg_buf[sensor_id], cfg_len); | |
1233 | ||
1234 | #if GTP_CUSTOM_CFG | |
1235 | config[RESOLUTION_LOC] = (u8)GTP_MAX_WIDTH; | |
1236 | config[RESOLUTION_LOC + 1] = (u8)(GTP_MAX_WIDTH>>8); | |
1237 | config[RESOLUTION_LOC + 2] = (u8)GTP_MAX_HEIGHT; | |
1238 | config[RESOLUTION_LOC + 3] = (u8)(GTP_MAX_HEIGHT>>8); | |
1239 | ||
1240 | if (GTP_INT_TRIGGER == 0) //RISING | |
1241 | { | |
1242 | config[TRIGGER_LOC] &= 0xfe; | |
1243 | } | |
1244 | else if (GTP_INT_TRIGGER == 1) //FALLING | |
1245 | { | |
1246 | config[TRIGGER_LOC] |= 0x01; | |
1247 | } | |
1248 | #endif // GTP_CUSTOM_CFG | |
1249 | ||
1250 | check_sum = 0; | |
1251 | for (i = GTP_ADDR_LENGTH; i < cfg_len; i++) | |
1252 | { | |
1253 | check_sum += config[i]; | |
1254 | } | |
1255 | config[cfg_len] = (~check_sum) + 1; | |
1256 | ||
1257 | #else // DRIVER NOT SEND CONFIG | |
1258 | cfg_len = GTP_CONFIG_MAX_LENGTH; | |
1259 | ret = gtp_i2c_read(client, config, cfg_len + GTP_ADDR_LENGTH); | |
1260 | if (ret < 0) | |
1261 | { | |
1262 | GTP_ERROR("Read Config Failed, Using DEFAULT Resolution & INT Trigger!"); | |
1263 | abs_x_max = GTP_MAX_WIDTH; | |
1264 | abs_y_max = GTP_MAX_HEIGHT; | |
1265 | int_type = GTP_INT_TRIGGER; | |
1266 | } | |
1267 | #endif // GTP_DRIVER_SEND_CFG | |
1268 | ||
1269 | GTP_DEBUG_FUNC(); | |
1270 | if ((abs_x_max == 0) && (abs_y_max == 0)) | |
1271 | { | |
1272 | abs_x_max = (config[RESOLUTION_LOC + 1] << 8) + config[RESOLUTION_LOC]; | |
1273 | abs_y_max = (config[RESOLUTION_LOC + 3] << 8) + config[RESOLUTION_LOC + 2]; | |
1274 | int_type = (config[TRIGGER_LOC]) & 0x03; | |
1275 | } | |
1276 | ||
1277 | #if GTP_COMPATIBLE_MODE | |
1278 | if (CHIP_TYPE_GT9F == gtp_chip_type) | |
1279 | { | |
1280 | u8 have_key = 0; | |
1281 | if (!memcmp(>p_default_FW_fl[4], "950", 3)) | |
1282 | { | |
1283 | driver_num = config[GTP_REG_MATRIX_DRVNUM - GTP_REG_CONFIG_DATA + 2]; | |
1284 | sensor_num = config[GTP_REG_MATRIX_SENNUM - GTP_REG_CONFIG_DATA + 2]; | |
1285 | } | |
1286 | else | |
1287 | { | |
1288 | driver_num = (config[CFG_LOC_DRVA_NUM]&0x1F) + (config[CFG_LOC_DRVB_NUM]&0x1F); | |
1289 | sensor_num = (config[CFG_LOC_SENS_NUM]&0x0F) + ((config[CFG_LOC_SENS_NUM]>>4)&0x0F); | |
1290 | } | |
1291 | ||
1292 | have_key = config[GTP_REG_HAVE_KEY - GTP_REG_CONFIG_DATA + 2] & 0x01; // have key or not | |
1293 | if (1 == have_key) | |
1294 | { | |
1295 | driver_num--; | |
1296 | } | |
1297 | ||
1298 | GTP_INFO("Driver * Sensor: %d * %d(Key: %d), X_MAX = %d, Y_MAX = %d, TRIGGER = 0x%02x", | |
1299 | driver_num, sensor_num, have_key, abs_x_max,abs_y_max,int_type); | |
1300 | } | |
1301 | else | |
1302 | #endif | |
1303 | { | |
1304 | #if GTP_DRIVER_SEND_CFG | |
1305 | ret = gtp_send_cfg(client); | |
1306 | if (ret < 0) | |
1307 | { | |
1308 | GTP_ERROR("Send config error."); | |
1309 | } | |
1310 | // set config version to CTP_CFG_GROUP | |
1311 | // for resume to send config | |
1312 | config[GTP_ADDR_LENGTH] = grp_cfg_version; | |
1313 | check_sum = 0; | |
1314 | for (i = GTP_ADDR_LENGTH; i < cfg_len; i++) | |
1315 | { | |
1316 | check_sum += config[i]; | |
1317 | } | |
1318 | config[cfg_len] = (~check_sum) + 1; | |
1319 | #endif | |
1320 | GTP_INFO("X_MAX = %d, Y_MAX = %d, TRIGGER = 0x%02x", | |
1321 | abs_x_max,abs_y_max,int_type); | |
1322 | } | |
1323 | ||
1324 | msleep(10); | |
1325 | return 0; | |
1326 | } | |
1327 | ||
1328 | static s8 gtp_i2c_test(struct i2c_client *client) | |
1329 | { | |
1330 | ||
1331 | u8 retry = 0; | |
1332 | s8 ret = -1; | |
1333 | u32 hw_info = 0; | |
1334 | ||
1335 | GTP_DEBUG_FUNC(); | |
1336 | ||
1337 | while (retry++ < 5) | |
1338 | { | |
1339 | ret = i2c_read_bytes(client, GTP_REG_HW_INFO, (u8 *)&hw_info, sizeof(hw_info)); | |
1340 | ||
1341 | if ((!ret) && (hw_info == 0x00900600)) //20121212 | |
1342 | { | |
1343 | return ret; | |
1344 | } | |
1345 | ||
1346 | GTP_ERROR("GTP_REG_HW_INFO : %08X", hw_info); | |
1347 | GTP_ERROR("GTP i2c test failed time %d.", retry); | |
1348 | msleep(10); | |
1349 | } | |
1350 | ||
1351 | return -1; | |
1352 | } | |
1353 | ||
1354 | ||
1355 | ||
1356 | /******************************************************* | |
1357 | Function: | |
1358 | Set INT pin as input for FW sync. | |
1359 | ||
1360 | Note: | |
1361 | If the INT is high, It means there is pull up resistor attached on the INT pin. | |
1362 | Pull low the INT pin manaully for FW sync. | |
1363 | *******************************************************/ | |
1364 | void gtp_int_sync(s32 ms) | |
1365 | { | |
1366 | GTP_GPIO_OUTPUT(GTP_INT_PORT, 0); | |
1367 | msleep(ms); | |
1368 | GTP_GPIO_AS_INT(GTP_INT_PORT); | |
1369 | } | |
1370 | ||
1371 | void gtp_reset_guitar(struct i2c_client *client, s32 ms) | |
1372 | { | |
1373 | GTP_INFO("GTP RESET!\n"); | |
1374 | GTP_GPIO_OUTPUT(GTP_RST_PORT, 0); | |
1375 | msleep(ms); | |
1376 | GTP_GPIO_OUTPUT(GTP_INT_PORT, client->addr == 0x14); | |
1377 | ||
1378 | msleep(2); | |
1379 | GTP_GPIO_OUTPUT(GTP_RST_PORT, 1); | |
1380 | ||
1381 | msleep(6); //must >= 6ms | |
1382 | ||
1383 | #if GTP_COMPATIBLE_MODE | |
1384 | if (CHIP_TYPE_GT9F == gtp_chip_type) | |
1385 | { | |
1386 | return; | |
1387 | } | |
1388 | #endif | |
1389 | ||
1390 | gtp_int_sync(100); // for dbl-system | |
1391 | #if GTP_ESD_PROTECT | |
1392 | gtp_init_ext_watchdog(i2c_client_point); | |
1393 | #endif | |
1394 | } | |
1395 | ||
1396 | static int tpd_power_on(struct i2c_client *client) | |
1397 | { | |
1398 | int ret = 0; | |
1399 | int reset_count = 0; | |
1400 | ||
1401 | reset_proc: | |
1402 | GTP_GPIO_OUTPUT(GTP_RST_PORT, 0); | |
1403 | GTP_GPIO_OUTPUT(GTP_INT_PORT, 0); | |
1404 | msleep(10); | |
1405 | ||
1406 | #ifdef TPD_POWER_SOURCE_CUSTOM | |
1407 | hwPowerOn(TPD_POWER_SOURCE_CUSTOM, VOL_2800, "TP"); | |
1408 | #else | |
1409 | hwPowerOn(MT65XX_POWER_LDO_VGP2, VOL_2800, "TP"); | |
1410 | #endif | |
1411 | #ifdef TPD_POWER_SOURCE_1800 | |
1412 | hwPowerOn(TPD_POWER_SOURCE_1800, VOL_1800, "TP"); | |
1413 | #endif | |
1414 | ||
1415 | gtp_reset_guitar(client, 20); | |
1416 | ||
1417 | #if GTP_COMPATIBLE_MODE | |
1418 | gtp_get_chip_type(client); | |
1419 | ||
1420 | if (CHIP_TYPE_GT9F == gtp_chip_type) | |
1421 | { | |
1422 | ret = (int)gup_load_main_system(NULL); | |
1423 | if(FAIL == ret) | |
1424 | { | |
1425 | GTP_ERROR("[tpd_power_on]Download fw failed."); | |
1426 | if(reset_count++ < TPD_MAX_RESET_COUNT) | |
1427 | { | |
1428 | goto reset_proc; | |
1429 | } | |
1430 | else | |
1431 | { | |
1432 | return ret; | |
1433 | } | |
1434 | } | |
1435 | } | |
1436 | else | |
1437 | #endif | |
1438 | { | |
1439 | ret = gtp_i2c_test(client); | |
1440 | ||
1441 | if (ret < 0) | |
1442 | { | |
1443 | GTP_ERROR("I2C communication ERROR!"); | |
1444 | ||
1445 | if (reset_count < TPD_MAX_RESET_COUNT) | |
1446 | { | |
1447 | reset_count++; | |
1448 | goto reset_proc; | |
1449 | } | |
1450 | } | |
1451 | } | |
1452 | ||
1453 | return ret; | |
1454 | } | |
1455 | ||
1456 | //**************** For GT9XXF Start ********************// | |
1457 | #if GTP_COMPATIBLE_MODE | |
1458 | ||
1459 | void gtp_get_chip_type(struct i2c_client *client) | |
1460 | { | |
1461 | u8 opr_buf[10] = {0x00}; | |
1462 | s32 ret = 0; | |
1463 | ||
1464 | msleep(10); | |
1465 | ||
1466 | ret = gtp_i2c_read_dbl_check(client, GTP_REG_CHIP_TYPE, opr_buf, 10); | |
1467 | ||
1468 | if (FAIL == ret) | |
1469 | { | |
1470 | GTP_ERROR("Failed to get chip-type, set chip type default: GOODIX_GT9"); | |
1471 | gtp_chip_type = CHIP_TYPE_GT9; | |
1472 | return; | |
1473 | } | |
1474 | ||
1475 | if (!memcmp(opr_buf, "GOODIX_GT9", 10)) | |
1476 | { | |
1477 | GTP_INFO("Chip Type: %s", (gtp_chip_type == CHIP_TYPE_GT9) ? "GOODIX_GT9" : "GOODIX_GT9F"); | |
1478 | gtp_chip_type = CHIP_TYPE_GT9; | |
1479 | } | |
1480 | else // GT9XXF | |
1481 | { | |
1482 | gtp_chip_type = CHIP_TYPE_GT9F; | |
1483 | GTP_INFO("Chip Type: %s", (gtp_chip_type == CHIP_TYPE_GT9) ? "GOODIX_GT9" : "GOODIX_GT9F"); | |
1484 | } | |
1485 | gtp_chip_type = CHIP_TYPE_GT9; // for test | |
1486 | GTP_INFO("Chip Type: %s", (gtp_chip_type == CHIP_TYPE_GT9) ? "GOODIX_GT9" : "GOODIX_GT9F"); | |
1487 | } | |
1488 | ||
1489 | static u8 gtp_bak_ref_proc(struct i2c_client *client, u8 mode) | |
1490 | { | |
1491 | s32 i = 0; | |
1492 | s32 j = 0; | |
1493 | s32 ret = 0; | |
1494 | struct file *flp = NULL; | |
1495 | u8 *refp = NULL; | |
1496 | u32 ref_len = 0; | |
1497 | u32 ref_seg_len = 0; | |
1498 | s32 ref_grps = 0; | |
1499 | s32 ref_chksum = 0; | |
1500 | u16 tmp = 0; | |
1501 | ||
1502 | GTP_DEBUG("[gtp_bak_ref_proc]Driver:%d,Sensor:%d.", driver_num, sensor_num); | |
1503 | ||
1504 | //check file-system mounted | |
1505 | GTP_DEBUG("[gtp_bak_ref_proc]Waiting for FS %d", gtp_ref_retries); | |
1506 | if (gup_check_fs_mounted("/data") == FAIL) | |
1507 | { | |
1508 | GTP_DEBUG("[gtp_bak_ref_proc]/data not mounted"); | |
1509 | if(gtp_ref_retries++ < GTP_CHK_FS_MNT_MAX) | |
1510 | { | |
1511 | return FAIL; | |
1512 | } | |
1513 | } | |
1514 | else | |
1515 | { | |
1516 | GTP_DEBUG("[gtp_bak_ref_proc]/data mounted !!!!"); | |
1517 | } | |
1518 | ||
1519 | if (!memcmp(>p_default_FW_fl[4], "950", 3)) | |
1520 | { | |
1521 | ref_seg_len = (driver_num * (sensor_num - 1) + 2) * 2; | |
1522 | ref_grps = 6; | |
1523 | ref_len = ref_seg_len * 6; // for GT950, backup-reference for six segments | |
1524 | } | |
1525 | else | |
1526 | { | |
1527 | ref_len = driver_num*(sensor_num-2)*2 + 4; | |
1528 | ref_seg_len = ref_len; | |
1529 | ref_grps = 1; | |
1530 | } | |
1531 | ||
1532 | refp = (u8 *)kzalloc(ref_len, GFP_KERNEL); | |
1533 | if(refp == NULL) | |
1534 | { | |
1535 | GTP_ERROR("[gtp_bak_ref_proc]Alloc memory for ref failed.use default ref"); | |
1536 | return FAIL; | |
1537 | } | |
1538 | memset(refp, 0, ref_len); | |
1539 | if(gtp_ref_retries >= GTP_CHK_FS_MNT_MAX) | |
1540 | { | |
1541 | for (j = 0; j < ref_grps; ++j) | |
1542 | { | |
1543 | refp[ref_seg_len + j * ref_seg_len -1] = 0x01; | |
1544 | } | |
1545 | ret = i2c_write_bytes(client, 0x99D0, refp, ref_len); | |
1546 | if(-1 == ret) | |
1547 | { | |
1548 | GTP_ERROR("[gtp_bak_ref_proc]Write ref i2c error."); | |
1549 | ret = FAIL; | |
1550 | } | |
1551 | ||
1552 | GTP_ERROR("[gtp_bak_ref_proc]Bak file or path is not exist,send default ref."); | |
1553 | ret = SUCCESS; | |
1554 | goto exit_ref_proc; | |
1555 | } | |
1556 | ||
1557 | //get ref file data | |
1558 | flp = filp_open(GTP_BAK_REF_PATH, O_RDWR | O_CREAT, 0660); | |
1559 | if (IS_ERR(flp)) | |
1560 | { | |
1561 | GTP_ERROR("[gtp_bak_ref_proc]Ref File not found!Creat ref file."); | |
1562 | //flp->f_op->llseek(flp, 0, SEEK_SET); | |
1563 | //flp->f_op->write(flp, (char *)refp, ref_len, &flp->f_pos); | |
1564 | gtp_ref_retries++; | |
1565 | ret = FAIL; | |
1566 | goto exit_ref_proc; | |
1567 | } | |
1568 | else if(GTP_BAK_REF_SEND == mode) | |
1569 | { | |
1570 | flp->f_op->llseek(flp, 0, SEEK_SET); | |
1571 | ret = flp->f_op->read(flp, (char *)refp, ref_len, &flp->f_pos); | |
1572 | if(ret < 0) | |
1573 | { | |
1574 | GTP_ERROR("[gtp_bak_ref_proc]Read ref file failed."); | |
1575 | memset(refp, 0, ref_len); | |
1576 | } | |
1577 | } | |
1578 | ||
1579 | if(GTP_BAK_REF_STORE == mode) | |
1580 | { | |
1581 | ret = i2c_read_bytes(client, 0x99D0, refp, ref_len); | |
1582 | if(-1 == ret) | |
1583 | { | |
1584 | GTP_ERROR("[gtp_bak_ref_proc]Read ref i2c error."); | |
1585 | ret = FAIL; | |
1586 | goto exit_ref_proc; | |
1587 | } | |
1588 | flp->f_op->llseek(flp, 0, SEEK_SET); | |
1589 | flp->f_op->write(flp, (char *)refp, ref_len, &flp->f_pos); | |
1590 | } | |
1591 | else | |
1592 | { | |
1593 | //checksum ref file | |
1594 | for (j = 0; j < ref_grps; ++j) | |
1595 | { | |
1596 | ref_chksum = 0; | |
1597 | for(i=0; i<ref_seg_len-2; i+=2) | |
1598 | { | |
1599 | ref_chksum += ((refp[i + j * ref_seg_len]<<8) + refp[i + 1 + j * ref_seg_len]); | |
1600 | } | |
1601 | ||
1602 | GTP_DEBUG("[gtp_bak_ref_proc]Calc ref chksum:0x%04X", ref_chksum&0xFF); | |
1603 | tmp = ref_chksum + (refp[ref_seg_len + j * ref_seg_len -2]<<8) + refp[ref_seg_len + j * ref_seg_len -1]; | |
1604 | if(1 != tmp) | |
1605 | { | |
1606 | GTP_DEBUG("[gtp_bak_ref_proc]Ref file chksum error,use default ref"); | |
1607 | memset(&refp[j * ref_seg_len], 0, ref_seg_len); | |
1608 | refp[ref_seg_len - 1 + j * ref_seg_len] = 0x01; | |
1609 | } | |
1610 | else | |
1611 | { | |
1612 | if (j == (ref_grps - 1)) | |
1613 | { | |
1614 | GTP_DEBUG("[gtp_bak_ref_proc]Ref file chksum success."); | |
1615 | } | |
1616 | } | |
1617 | ||
1618 | } | |
1619 | ||
1620 | ret = i2c_write_bytes(client, 0x99D0, refp, ref_len); | |
1621 | if(-1 == ret) | |
1622 | { | |
1623 | GTP_ERROR("[gtp_bak_ref_proc]Write ref i2c error."); | |
1624 | ret = FAIL; | |
1625 | goto exit_ref_proc; | |
1626 | } | |
1627 | } | |
1628 | ||
1629 | ret = SUCCESS; | |
1630 | ||
1631 | exit_ref_proc: | |
1632 | if(refp) | |
1633 | { | |
1634 | kfree(refp); | |
1635 | } | |
1636 | if (flp && !IS_ERR(flp)) | |
1637 | { | |
1638 | filp_close(flp, NULL); | |
1639 | } | |
1640 | return ret; | |
1641 | } | |
1642 | ||
1643 | u8 gtp_fw_startup(struct i2c_client *client) | |
1644 | { | |
1645 | u8 wr_buf[4]; | |
1646 | s32 ret = 0; | |
1647 | ||
1648 | //init sw WDT | |
1649 | wr_buf[0] = 0xAA; | |
1650 | ret = i2c_write_bytes(client, 0x8041, wr_buf, 1); | |
1651 | if (ret < 0) | |
1652 | { | |
1653 | GTP_ERROR("I2C error to firmware startup."); | |
1654 | return FAIL; | |
1655 | } | |
1656 | //release SS51 & DSP | |
1657 | wr_buf[0] = 0x00; | |
1658 | i2c_write_bytes(client, 0x4180, wr_buf, 1); | |
1659 | ||
1660 | //int sync | |
1661 | gtp_int_sync(20); | |
1662 | ||
1663 | //check fw run status | |
1664 | i2c_read_bytes(client, 0x8041, wr_buf, 1); | |
1665 | if(0xAA == wr_buf[0]) | |
1666 | { | |
1667 | GTP_ERROR("IC works abnormally,startup failed."); | |
1668 | return FAIL; | |
1669 | } | |
1670 | else | |
1671 | { | |
1672 | GTP_DEBUG("IC works normally,Startup success."); | |
1673 | wr_buf[0] = 0xAA; | |
1674 | i2c_write_bytes(client, 0x8041, wr_buf, 1); | |
1675 | return SUCCESS; | |
1676 | } | |
1677 | } | |
1678 | ||
1679 | static void gtp_recovery_reset(struct i2c_client *client) | |
1680 | { | |
1681 | mutex_lock(&i2c_access); | |
1682 | if(tpd_halt == 0) | |
1683 | { | |
1684 | #if GTP_ESD_PROTECT | |
1685 | gtp_esd_switch(client, SWITCH_OFF); | |
1686 | #endif | |
1687 | force_reset_guitar(); | |
1688 | #if GTP_ESD_PROTECT | |
1689 | gtp_esd_switch(client, SWITCH_ON); | |
1690 | #endif | |
1691 | } | |
1692 | mutex_unlock(&i2c_access); | |
1693 | } | |
1694 | ||
1695 | static u8 gtp_check_clk_legality(void) | |
1696 | { | |
1697 | u8 i = 0; | |
1698 | u8 clk_chksum = gtp_clk_buf[5]; | |
1699 | ||
1700 | for(i = 0; i < 5; i++) | |
1701 | { | |
1702 | if((gtp_clk_buf[i] < 50) || (gtp_clk_buf[i] > 120) || | |
1703 | (gtp_clk_buf[i] != gtp_clk_buf[0])) | |
1704 | { | |
1705 | break; | |
1706 | } | |
1707 | clk_chksum += gtp_clk_buf[i]; | |
1708 | } | |
1709 | ||
1710 | if((i == 5) && (clk_chksum == 0)) | |
1711 | { | |
1712 | GTP_INFO("Clk ram legality check success"); | |
1713 | return SUCCESS; | |
1714 | } | |
1715 | GTP_ERROR("main clock freq in clock buf is wrong"); | |
1716 | return FAIL; | |
1717 | } | |
1718 | ||
1719 | static u8 gtp_main_clk_proc(struct i2c_client *client) | |
1720 | { | |
1721 | s32 ret = 0; | |
1722 | u8 i = 0; | |
1723 | u8 clk_cal_result = 0; | |
1724 | u8 clk_chksum = 0; | |
1725 | struct file *flp = NULL; | |
1726 | ||
1727 | //check clk legality | |
1728 | ret = gtp_check_clk_legality(); | |
1729 | if(SUCCESS == ret) | |
1730 | { | |
1731 | goto send_main_clk; | |
1732 | } | |
1733 | ||
1734 | GTP_DEBUG("[gtp_main_clk_proc]Waiting for FS %d", gtp_ref_retries); | |
1735 | if (gup_check_fs_mounted("/data") == FAIL) | |
1736 | { | |
1737 | GTP_DEBUG("[gtp_main_clk_proc]/data not mounted"); | |
1738 | if(gtp_clk_retries++ < GTP_CHK_FS_MNT_MAX) | |
1739 | { | |
1740 | return FAIL; | |
1741 | } | |
1742 | else | |
1743 | { | |
1744 | GTP_ERROR("[gtp_main_clk_proc]Wait for file system timeout,need cal clk"); | |
1745 | } | |
1746 | } | |
1747 | else | |
1748 | { | |
1749 | GTP_DEBUG("[gtp_main_clk_proc]/data mounted !!!!"); | |
1750 | flp = filp_open(GTP_MAIN_CLK_PATH, O_RDWR | O_CREAT, 0660); | |
1751 | if (!IS_ERR(flp)) | |
1752 | { | |
1753 | flp->f_op->llseek(flp, 0, SEEK_SET); | |
1754 | ret = flp->f_op->read(flp, (char *)gtp_clk_buf, 6, &flp->f_pos); | |
1755 | if(ret > 0) | |
1756 | { | |
1757 | ret = gtp_check_clk_legality(); | |
1758 | if(SUCCESS == ret) | |
1759 | { | |
1760 | GTP_DEBUG("[gtp_main_clk_proc]Open & read & check clk file success."); | |
1761 | goto send_main_clk; | |
1762 | } | |
1763 | } | |
1764 | } | |
1765 | GTP_ERROR("[gtp_main_clk_proc]Check clk file failed,need cal clk"); | |
1766 | } | |
1767 | ||
1768 | //cal clk | |
1769 | #if GTP_ESD_PROTECT | |
1770 | gtp_esd_switch(client, SWITCH_OFF); | |
1771 | #endif | |
1772 | clk_cal_result = gup_clk_calibration(); | |
1773 | force_reset_guitar(); | |
1774 | GTP_DEBUG("&&&&&&&&&&clk cal result:%d", clk_cal_result); | |
1775 | ||
1776 | #if GTP_ESD_PROTECT | |
1777 | gtp_esd_switch(client, SWITCH_ON); | |
1778 | #endif | |
1779 | ||
1780 | if(clk_cal_result < 50 || clk_cal_result > 120) | |
1781 | { | |
1782 | GTP_ERROR("[gtp_main_clk_proc]cal clk result is illegitimate"); | |
1783 | ret = FAIL; | |
1784 | goto exit_clk_proc; | |
1785 | } | |
1786 | ||
1787 | for(i = 0;i < 5; i++) | |
1788 | { | |
1789 | gtp_clk_buf[i] = clk_cal_result; | |
1790 | clk_chksum += gtp_clk_buf[i]; | |
1791 | } | |
1792 | gtp_clk_buf[5] = 0 - clk_chksum; | |
1793 | ||
1794 | if (IS_ERR(flp)) | |
1795 | { | |
1796 | flp = filp_open(GTP_MAIN_CLK_PATH, O_RDWR | O_CREAT, 0660); | |
1797 | } | |
1798 | else | |
1799 | { | |
1800 | flp->f_op->llseek(flp, 0, SEEK_SET); | |
1801 | flp->f_op->write(flp, (char *)gtp_clk_buf, 6, &flp->f_pos); | |
1802 | } | |
1803 | ||
1804 | ||
1805 | send_main_clk: | |
1806 | ||
1807 | ret = i2c_write_bytes(client, 0x8020, gtp_clk_buf, 6); | |
1808 | if(-1 == ret) | |
1809 | { | |
1810 | GTP_ERROR("[gtp_main_clk_proc]send main clk i2c error!"); | |
1811 | ret = FAIL; | |
1812 | goto exit_clk_proc; | |
1813 | } | |
1814 | ||
1815 | ret = SUCCESS; | |
1816 | ||
1817 | exit_clk_proc: | |
1818 | if (flp && !IS_ERR(flp)) | |
1819 | { | |
1820 | filp_close(flp, NULL); | |
1821 | } | |
1822 | return ret; | |
1823 | } | |
1824 | ||
1825 | #endif | |
1826 | //************* For GT9XXF End **********************// | |
1827 | ||
1828 | static const struct file_operations gt_upgrade_proc_fops = { | |
1829 | .write = gt91xx_config_write_proc, | |
1830 | .read = gt91xx_config_read_proc | |
1831 | }; | |
1832 | ||
1833 | static s32 tpd_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) | |
1834 | { | |
1835 | s32 err = 0; | |
1836 | s32 ret = 0; | |
1837 | ||
1838 | u16 version_info; | |
1839 | #if GTP_HAVE_TOUCH_KEY | |
1840 | s32 idx = 0; | |
1841 | #endif | |
1842 | #ifdef TPD_PROXIMITY | |
1843 | struct hwmsen_object obj_ps; | |
1844 | #endif | |
1845 | ||
1846 | i2c_client_point = client; | |
1847 | ret = tpd_power_on(client); | |
1848 | ||
1849 | if (ret < 0) | |
1850 | { | |
1851 | GTP_ERROR("I2C communication ERROR!"); | |
1852 | } | |
1853 | ||
1854 | //#ifdef VELOCITY_CUSTOM | |
1855 | #if 0 | |
1856 | ||
1857 | if ((err = misc_register(&tpd_misc_device))) | |
1858 | { | |
1859 | printk("mtk_tpd: tpd_misc_device register failed\n"); | |
1860 | } | |
1861 | ||
1862 | #endif | |
1863 | #ifdef VELOCITY_CUSTOM | |
1864 | tpd_v_magnify_x = TPD_VELOCITY_CUSTOM_X; | |
1865 | tpd_v_magnify_y = TPD_VELOCITY_CUSTOM_Y; | |
1866 | ||
1867 | #endif | |
1868 | ||
1869 | ret = gtp_read_version(client, &version_info); | |
1870 | ||
1871 | if (ret < 0) | |
1872 | { | |
1873 | GTP_ERROR("Read version failed."); | |
1874 | } | |
1875 | ||
1876 | ret = gtp_init_panel(client); | |
1877 | ||
1878 | if (ret < 0) | |
1879 | { | |
1880 | GTP_ERROR("GTP init panel failed."); | |
1881 | } | |
1882 | ||
1883 | // Create proc file system | |
1884 | gt91xx_config_proc = proc_create(GT91XX_CONFIG_PROC_FILE, 0660, NULL, >_upgrade_proc_fops); | |
1885 | if (gt91xx_config_proc == NULL) | |
1886 | { | |
1887 | GTP_ERROR("create_proc_entry %s failed\n", GT91XX_CONFIG_PROC_FILE); | |
1888 | } | |
1889 | ||
1890 | ||
1891 | #if GTP_CREATE_WR_NODE | |
1892 | init_wr_node(client); | |
1893 | #endif | |
1894 | ||
1895 | thread = kthread_run(touch_event_handler, 0, TPD_DEVICE); | |
1896 | ||
1897 | if (IS_ERR(thread)) | |
1898 | { | |
1899 | err = PTR_ERR(thread); | |
1900 | GTP_INFO(TPD_DEVICE " failed to create kernel thread: %d\n", err); | |
1901 | } | |
1902 | ||
1903 | ||
1904 | #if GTP_HAVE_TOUCH_KEY | |
1905 | ||
1906 | for (idx = 0; idx < GTP_MAX_KEY_NUM; idx++) | |
1907 | { | |
1908 | input_set_capability(tpd->dev, EV_KEY, touch_key_array[idx]); | |
1909 | } | |
1910 | ||
1911 | #endif | |
1912 | #if GTP_SLIDE_WAKEUP | |
1913 | input_set_capability(tpd->dev, EV_KEY, KEY_POWER); | |
1914 | #endif | |
1915 | ||
1916 | #if GTP_WITH_PEN | |
1917 | // pen support | |
1918 | __set_bit(BTN_TOOL_PEN, tpd->dev->keybit); | |
1919 | __set_bit(INPUT_PROP_DIRECT, tpd->dev->propbit); | |
1920 | //__set_bit(INPUT_PROP_POINTER, tpd->dev->propbit); // 20130722 | |
1921 | #endif | |
1922 | // set INT mode | |
1923 | mt_set_gpio_mode(GPIO_CTP_EINT_PIN, GPIO_CTP_EINT_PIN_M_EINT); | |
1924 | mt_set_gpio_dir(GPIO_CTP_EINT_PIN, GPIO_DIR_IN); | |
1925 | mt_set_gpio_pull_enable(GPIO_CTP_EINT_PIN, GPIO_PULL_DISABLE); | |
1926 | ||
1927 | msleep(50); | |
1928 | ||
1929 | if (!int_type) //EINTF_TRIGGER | |
1930 | { | |
1931 | mt_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, EINTF_TRIGGER_RISING, tpd_eint_interrupt_handler, 1); | |
1932 | } | |
1933 | else | |
1934 | { | |
1935 | mt_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, EINTF_TRIGGER_FALLING, tpd_eint_interrupt_handler, 1); | |
1936 | } | |
1937 | ||
1938 | mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); | |
1939 | ||
1940 | #if GTP_AUTO_UPDATE | |
1941 | ret = gup_init_update_proc(client); | |
1942 | ||
1943 | if (ret < 0) | |
1944 | { | |
1945 | GTP_ERROR("Create update thread error."); | |
1946 | } | |
1947 | #endif | |
1948 | ||
1949 | #ifdef TPD_PROXIMITY | |
1950 | //obj_ps.self = cm3623_obj; | |
1951 | obj_ps.polling = 0; //0--interrupt mode;1--polling mode; | |
1952 | obj_ps.sensor_operate = tpd_ps_operate; | |
1953 | ||
1954 | if ((err = hwmsen_attach(ID_PROXIMITY, &obj_ps))) | |
1955 | { | |
1956 | GTP_ERROR("hwmsen attach fail, return:%d.", err); | |
1957 | } | |
1958 | ||
1959 | #endif | |
1960 | ||
1961 | #if GTP_ESD_PROTECT | |
1962 | gtp_esd_switch(client, SWITCH_ON); | |
1963 | #endif | |
1964 | ||
1965 | tpd_load_status = 1; | |
1966 | ||
1967 | return 0; | |
1968 | } | |
1969 | ||
1970 | static void tpd_eint_interrupt_handler(void) | |
1971 | { | |
1972 | TPD_DEBUG_PRINT_INT; | |
1973 | ||
1974 | tpd_flag = 1; | |
1975 | ||
1976 | wake_up_interruptible(&waiter); | |
1977 | } | |
1978 | static int tpd_i2c_remove(struct i2c_client *client) | |
1979 | { | |
1980 | #if GTP_CREATE_WR_NODE | |
1981 | uninit_wr_node(); | |
1982 | #endif | |
1983 | ||
1984 | #if GTP_ESD_PROTECT | |
1985 | destroy_workqueue(gtp_esd_check_workqueue); | |
1986 | #endif | |
1987 | ||
1988 | return 0; | |
1989 | } | |
1990 | #if (GTP_ESD_PROTECT || GTP_COMPATIBLE_MODE) | |
1991 | void force_reset_guitar(void) | |
1992 | { | |
1993 | s32 i = 0; | |
1994 | s32 ret = 0; | |
1995 | //static u8 is_reseting = 0; | |
1996 | ||
1997 | if(is_reseting || (load_fw_process == 1)) | |
1998 | { | |
1999 | return; | |
2000 | } | |
2001 | GTP_INFO("force_reset_guitar"); | |
2002 | is_reseting = 1; | |
2003 | mt_eint_mask(CUST_EINT_TOUCH_PANEL_NUM); | |
2004 | ||
2005 | GTP_GPIO_OUTPUT(GTP_RST_PORT, 0); | |
2006 | GTP_GPIO_OUTPUT(GTP_INT_PORT, 0); | |
2007 | ||
2008 | // Power off TP | |
2009 | #ifdef TPD_POWER_SOURCE_CUSTOM | |
2010 | hwPowerDown(TPD_POWER_SOURCE_CUSTOM, "TP"); | |
2011 | #else | |
2012 | hwPowerDown(MT65XX_POWER_LDO_VGP2, "TP"); | |
2013 | #endif | |
2014 | #ifdef TPD_POWER_SOURCE_1800 | |
2015 | hwPowerDown(TPD_POWER_SOURCE_1800, "TP"); | |
2016 | #endif | |
2017 | msleep(30); | |
2018 | ||
2019 | // Power on TP | |
2020 | #ifdef TPD_POWER_SOURCE_CUSTOM | |
2021 | hwPowerOn(TPD_POWER_SOURCE_CUSTOM, VOL_2800, "TP"); | |
2022 | #else | |
2023 | hwPowerOn(MT65XX_POWER_LDO_VGP2, VOL_2800, "TP"); | |
2024 | #endif | |
2025 | msleep(30); | |
2026 | ||
2027 | mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); | |
2028 | ||
2029 | for (i = 0; i < 5; i++) | |
2030 | { | |
2031 | //Reset Guitar | |
2032 | gtp_reset_guitar(i2c_client_point, 20); | |
2033 | ||
2034 | #if GTP_COMPATIBLE_MODE | |
2035 | if (CHIP_TYPE_GT9F == gtp_chip_type) | |
2036 | { | |
2037 | //check code ram | |
2038 | ret = gup_load_main_system(NULL); | |
2039 | if(FAIL == ret) | |
2040 | { | |
2041 | GTP_ERROR("[force_reset_guitar]Check & repair fw failed."); | |
2042 | continue; | |
2043 | } | |
2044 | } | |
2045 | else | |
2046 | #endif | |
2047 | { | |
2048 | //Send config | |
2049 | ret = gtp_send_cfg(i2c_client_point); | |
2050 | ||
2051 | if (ret < 0) | |
2052 | { | |
2053 | continue; | |
2054 | } | |
2055 | } | |
2056 | break; | |
2057 | } | |
2058 | is_reseting = 0; | |
2059 | ||
2060 | } | |
2061 | #endif | |
2062 | ||
2063 | #if GTP_ESD_PROTECT | |
2064 | static s32 gtp_init_ext_watchdog(struct i2c_client *client) | |
2065 | { | |
2066 | u8 opr_buffer[2] = {0xAA}; | |
2067 | GTP_DEBUG("Init external watchdog."); | |
2068 | return i2c_write_bytes(client, 0x8041, opr_buffer, 1); | |
2069 | } | |
2070 | ||
2071 | void gtp_esd_switch(struct i2c_client *client, s32 on) | |
2072 | { | |
2073 | spin_lock(&esd_lock); | |
2074 | if (SWITCH_ON == on) // switch on esd | |
2075 | { | |
2076 | if (!esd_running) | |
2077 | { | |
2078 | esd_running = 1; | |
2079 | spin_unlock(&esd_lock); | |
2080 | GTP_INFO("Esd started"); | |
2081 | queue_delayed_work(gtp_esd_check_workqueue, >p_esd_check_work, clk_tick_cnt); | |
2082 | } | |
2083 | else | |
2084 | { | |
2085 | spin_unlock(&esd_lock); | |
2086 | } | |
2087 | } | |
2088 | else // switch off esd | |
2089 | { | |
2090 | if (esd_running) | |
2091 | { | |
2092 | esd_running = 0; | |
2093 | spin_unlock(&esd_lock); | |
2094 | GTP_INFO("Esd cancelled"); | |
2095 | cancel_delayed_work(>p_esd_check_work); | |
2096 | } | |
2097 | else | |
2098 | { | |
2099 | spin_unlock(&esd_lock); | |
2100 | } | |
2101 | } | |
2102 | } | |
2103 | ||
2104 | ||
2105 | static void gtp_esd_check_func(struct work_struct *work) | |
2106 | { | |
2107 | s32 i = 0; | |
2108 | s32 ret = -1; | |
2109 | u8 esd_buf[2] = {0x00}; | |
2110 | ||
2111 | if (tpd_halt) | |
2112 | { | |
2113 | GTP_INFO("Esd suspended!"); | |
2114 | return; | |
2115 | } | |
2116 | if(1 == load_fw_process) | |
2117 | { | |
2118 | GTP_INFO("Load FW process is runing"); | |
2119 | return; | |
2120 | } | |
2121 | for (i = 0; i < 3; i++) | |
2122 | { | |
2123 | ret = i2c_read_bytes_non_dma(i2c_client_point, 0x8040, esd_buf, 2); | |
2124 | ||
2125 | GTP_DEBUG("[Esd]0x8040 = 0x%02X, 0x8041 = 0x%02X", esd_buf[0], esd_buf[1]); | |
2126 | if (ret < 0) | |
2127 | { | |
2128 | // IIC communication problem | |
2129 | continue; | |
2130 | } | |
2131 | else | |
2132 | { | |
2133 | if ((esd_buf[0] == 0xAA) || (esd_buf[1] != 0xAA)) | |
2134 | { | |
2135 | u8 chk_buf[2] = {0x00}; | |
2136 | i2c_read_bytes_non_dma(i2c_client_point, 0x8040, chk_buf, 2); | |
2137 | ||
2138 | GTP_DEBUG("[Check]0x8040 = 0x%02X, 0x8041 = 0x%02X", chk_buf[0], chk_buf[1]); | |
2139 | ||
2140 | if ( (chk_buf[0] == 0xAA) || (chk_buf[1] != 0xAA) ) | |
2141 | { | |
2142 | i = 3; // jump to reset guitar | |
2143 | break; | |
2144 | } | |
2145 | else | |
2146 | { | |
2147 | continue; | |
2148 | } | |
2149 | } | |
2150 | else | |
2151 | { | |
2152 | // IC works normally, Write 0x8040 0xAA, feed the watchdog | |
2153 | esd_buf[0] = 0xAA; | |
2154 | i2c_write_bytes_non_dma(i2c_client_point, 0x8040, esd_buf, 1); | |
2155 | ||
2156 | break; | |
2157 | } | |
2158 | } | |
2159 | } | |
2160 | ||
2161 | if (i >= 3) | |
2162 | { | |
2163 | #if GTP_COMPATIBLE_MODE | |
2164 | if ((CHIP_TYPE_GT9F == gtp_chip_type) && (1 == rqst_processing)) | |
2165 | { | |
2166 | GTP_INFO("Request Processing, no reset guitar."); | |
2167 | } | |
2168 | else | |
2169 | #endif | |
2170 | { | |
2171 | GTP_INFO("IC works abnormally! Process reset guitar."); | |
2172 | memset(esd_buf, 0x01, sizeof(esd_buf)); | |
2173 | i2c_write_bytes(i2c_client_point, 0x4226, esd_buf, sizeof(esd_buf)); | |
2174 | msleep(50); | |
2175 | force_reset_guitar(); | |
2176 | } | |
2177 | } | |
2178 | ||
2179 | #if FLASHLESS_FLASH_WORKROUND | |
2180 | { | |
2181 | u8 versionBuff[6]; | |
2182 | int retry = 0; | |
2183 | u8 temp = 0; | |
2184 | ||
2185 | while(retry++ < 3) | |
2186 | { | |
2187 | ret = i2c_read_bytes_non_dma(i2c_client_point, 0x8140, versionBuff, sizeof(versionBuff)); | |
2188 | if(ret < 0) | |
2189 | { | |
2190 | continue; | |
2191 | } | |
2192 | //match pid | |
2193 | if( memcmp(versionBuff, >p_default_FW_fl[4], 4) !=0 ) | |
2194 | { | |
2195 | continue; | |
2196 | } | |
2197 | temp = versionBuff[5]; | |
2198 | versionBuff[5] = versionBuff[4]; | |
2199 | versionBuff[4] = temp; | |
2200 | //match vid | |
2201 | if( memcmp(&versionBuff[4], >p_default_FW_fl[12], 2) !=0 ) | |
2202 | { | |
2203 | continue; | |
2204 | } | |
2205 | break; | |
2206 | } | |
2207 | if(retry>=3) | |
2208 | { | |
2209 | GTP_INFO("IC version error., force reset!"); | |
2210 | force_reset_guitar(); | |
2211 | } | |
2212 | } | |
2213 | #endif | |
2214 | ||
2215 | if (!tpd_halt) | |
2216 | { | |
2217 | queue_delayed_work(gtp_esd_check_workqueue, >p_esd_check_work, clk_tick_cnt); | |
2218 | } | |
2219 | else | |
2220 | { | |
2221 | GTP_INFO("Esd suspended!"); | |
2222 | } | |
2223 | ||
2224 | return; | |
2225 | } | |
2226 | #endif | |
2227 | static int tpd_history_x=0, tpd_history_y=0; | |
2228 | static void tpd_down(s32 x, s32 y, s32 size, s32 id) | |
2229 | { | |
2230 | if ((!size) && (!id)) | |
2231 | { | |
2232 | input_report_abs(tpd->dev, ABS_MT_PRESSURE, 100); | |
2233 | input_report_abs(tpd->dev, ABS_MT_TOUCH_MAJOR, 100); | |
2234 | } | |
2235 | else | |
2236 | { | |
2237 | input_report_abs(tpd->dev, ABS_MT_PRESSURE, size); | |
2238 | input_report_abs(tpd->dev, ABS_MT_TOUCH_MAJOR, size); | |
2239 | /* track id Start 0 */ | |
2240 | input_report_abs(tpd->dev, ABS_MT_TRACKING_ID, id); | |
2241 | } | |
2242 | ||
2243 | input_report_key(tpd->dev, BTN_TOUCH, 1); | |
2244 | input_report_abs(tpd->dev, ABS_MT_POSITION_X, x); | |
2245 | input_report_abs(tpd->dev, ABS_MT_POSITION_Y, y); | |
2246 | input_mt_sync(tpd->dev); | |
2247 | TPD_DEBUG_SET_TIME; | |
2248 | TPD_EM_PRINT(x, y, x, y, id, 1); | |
2249 | tpd_history_x=x; | |
2250 | tpd_history_y=y; | |
2251 | ||
2252 | //MMProfileLogEx(MMP_TouchPanelEvent, MMProfileFlagPulse, 1, x+y); | |
2253 | #ifdef TPD_HAVE_BUTTON | |
2254 | ||
2255 | if (FACTORY_BOOT == get_boot_mode() || RECOVERY_BOOT == get_boot_mode()) | |
2256 | { | |
2257 | tpd_button(x, y, 1); | |
2258 | } | |
2259 | ||
2260 | #endif | |
2261 | } | |
2262 | ||
2263 | static void tpd_up(s32 x, s32 y, s32 id) | |
2264 | { | |
2265 | //input_report_abs(tpd->dev, ABS_MT_PRESSURE, 0); | |
2266 | input_report_key(tpd->dev, BTN_TOUCH, 0); | |
2267 | //input_report_abs(tpd->dev, ABS_MT_TOUCH_MAJOR, 0); | |
2268 | input_mt_sync(tpd->dev); | |
2269 | TPD_DEBUG_SET_TIME; | |
2270 | TPD_EM_PRINT(tpd_history_x, tpd_history_y, tpd_history_x, tpd_history_y, id, 0); | |
2271 | tpd_history_x=0; | |
2272 | tpd_history_y=0; | |
2273 | //MMProfileLogEx(MMP_TouchPanelEvent, MMProfileFlagPulse, 0, x+y); | |
2274 | ||
2275 | #ifdef TPD_HAVE_BUTTON | |
2276 | ||
2277 | if (FACTORY_BOOT == get_boot_mode() || RECOVERY_BOOT == get_boot_mode()) | |
2278 | { | |
2279 | tpd_button(x, y, 0); | |
2280 | } | |
2281 | ||
2282 | #endif | |
2283 | } | |
2284 | #if GTP_CHARGER_SWITCH | |
2285 | static void gtp_charger_switch(s32 dir_update) | |
2286 | { | |
2287 | u32 chr_status = 0; | |
2288 | u8 chr_cmd[3] = {0x80, 0x40}; | |
2289 | static u8 chr_pluggedin = 0; | |
2290 | int ret = 0; | |
2291 | ||
2292 | chr_status = upmu_is_chr_det(); | |
2293 | ||
2294 | if (chr_status) // charger plugged in | |
2295 | { | |
2296 | if (!chr_pluggedin || dir_update) | |
2297 | { | |
2298 | chr_cmd[2] = 6; | |
2299 | ret = gtp_i2c_write(i2c_client_point, chr_cmd, 3); | |
2300 | if (ret > 0) | |
2301 | { | |
2302 | GTP_INFO("Update status for Charger Plugin"); | |
2303 | } | |
2304 | chr_pluggedin = 1; | |
2305 | } | |
2306 | } | |
2307 | else // charger plugged out | |
2308 | { | |
2309 | if (chr_pluggedin || dir_update) | |
2310 | { | |
2311 | chr_cmd[2] = 7; | |
2312 | ret = gtp_i2c_write(i2c_client_point, chr_cmd, 3); | |
2313 | if (ret > 0) | |
2314 | { | |
2315 | GTP_INFO("Update status for Charger Plugout"); | |
2316 | } | |
2317 | chr_pluggedin = 0; | |
2318 | } | |
2319 | } | |
2320 | } | |
2321 | #endif | |
2322 | ||
2323 | /*Coordination mapping*/ | |
2324 | static void tpd_calibrate_driver(int *x, int *y) | |
2325 | { | |
2326 | int tx; | |
2327 | ||
2328 | GTP_DEBUG("Call tpd_calibrate of this driver ..\n"); | |
2329 | ||
2330 | tx = ( (tpd_def_calmat[0] * (*x)) + (tpd_def_calmat[1] * (*y)) + (tpd_def_calmat[2]) ) >> 12; | |
2331 | *y = ( (tpd_def_calmat[3] * (*x)) + (tpd_def_calmat[4] * (*y)) + (tpd_def_calmat[5]) ) >> 12; | |
2332 | *x = tx; | |
2333 | } | |
2334 | ||
2335 | static int touch_event_handler(void *unused) | |
2336 | { | |
2337 | struct sched_param param = { .sched_priority = RTPM_PRIO_TPD }; | |
2338 | u8 end_cmd[3] = {GTP_READ_COOR_ADDR >> 8, GTP_READ_COOR_ADDR & 0xFF, 0}; | |
2339 | u8 point_data[2 + 1 + 8 * GTP_MAX_TOUCH + 1] = {GTP_READ_COOR_ADDR >> 8, GTP_READ_COOR_ADDR & 0xFF}; | |
2340 | u8 touch_num = 0; | |
2341 | u8 finger = 0; | |
2342 | static u8 pre_touch = 0; | |
2343 | static u8 pre_key = 0; | |
2344 | #if GTP_WITH_PEN | |
2345 | static u8 pre_pen = 0; | |
2346 | #endif | |
2347 | u8 key_value = 0; | |
2348 | u8 *coor_data = NULL; | |
2349 | s32 input_x = 0; | |
2350 | s32 input_y = 0; | |
2351 | s32 input_w = 0; | |
2352 | s32 id = 0; | |
2353 | s32 i = 0; | |
2354 | s32 ret = -1; | |
2355 | ||
2356 | #if GTP_COMPATIBLE_MODE | |
2357 | u8 rqst_data[3] = {(u8)(GTP_REG_RQST >> 8), (u8)(GTP_REG_RQST & 0xFF), 0}; | |
2358 | #endif | |
2359 | ||
2360 | #if HOTKNOT_BLOCK_RW | |
2361 | u8 hn_pxy_state = 0; | |
2362 | u8 hn_pxy_state_bak = 0; | |
2363 | u8 hn_paired_cnt = 0; | |
2364 | u8 hn_state_buf[10] = {(u8)(GTP_REG_HN_STATE>> 8), (u8)(GTP_REG_HN_STATE & 0xFF), 0}; | |
2365 | #endif | |
2366 | ||
2367 | #ifdef TPD_PROXIMITY | |
2368 | s32 err = 0; | |
2369 | hwm_sensor_data sensor_data; | |
2370 | u8 proximity_status; | |
2371 | #endif | |
2372 | ||
2373 | #if GTP_SLIDE_WAKEUP | |
2374 | u8 doze_buf[3] = {0x81, 0x4B}; | |
2375 | #endif | |
2376 | ||
2377 | sched_setscheduler(current, SCHED_RR, ¶m); | |
2378 | do | |
2379 | { | |
2380 | set_current_state(TASK_INTERRUPTIBLE); | |
2381 | if(tpd_eint_mode) | |
2382 | { | |
2383 | wait_event_interruptible(waiter, tpd_flag != 0); | |
2384 | tpd_flag = 0; | |
2385 | } | |
2386 | else | |
2387 | { | |
2388 | msleep(tpd_polling_time); | |
2389 | } | |
2390 | ||
2391 | set_current_state(TASK_RUNNING); | |
2392 | mutex_lock(&i2c_access); | |
2393 | #if GTP_CHARGER_SWITCH | |
2394 | gtp_charger_switch(0); | |
2395 | #endif | |
2396 | ||
2397 | #if GTP_SLIDE_WAKEUP | |
2398 | if (DOZE_ENABLED == doze_status) | |
2399 | { | |
2400 | ret = gtp_i2c_read(i2c_client_point, doze_buf, 3); | |
2401 | GTP_DEBUG("0x814B = 0x%02X", doze_buf[2]); | |
2402 | if (ret > 0) | |
2403 | { | |
2404 | if (0xAA == doze_buf[2]) | |
2405 | { | |
2406 | GTP_INFO("Forward slide to light up the screen!"); | |
2407 | doze_status = DOZE_WAKEUP; | |
2408 | input_report_key(tpd->dev, KEY_POWER, 1); | |
2409 | input_sync(tpd->dev); | |
2410 | input_report_key(tpd->dev, KEY_POWER, 0); | |
2411 | input_sync(tpd->dev); | |
2412 | // clear 0x814B | |
2413 | doze_buf[2] = 0x00; | |
2414 | gtp_i2c_write(i2c_client_point, doze_buf, 3); | |
2415 | } | |
2416 | else if (0xBB == doze_buf[2]) | |
2417 | { | |
2418 | GTP_INFO("Backward slide to light up the screen!"); | |
2419 | doze_status = DOZE_WAKEUP; | |
2420 | input_report_key(tpd->dev, KEY_POWER, 1); | |
2421 | input_sync(tpd->dev); | |
2422 | input_report_key(tpd->dev, KEY_POWER, 0); | |
2423 | input_sync(tpd->dev); | |
2424 | // clear 0x814B | |
2425 | doze_buf[2] = 0x00; | |
2426 | gtp_i2c_write(i2c_client_point, doze_buf, 3); | |
2427 | ||
2428 | } | |
2429 | else if (0xC0 == (doze_buf[2] & 0xC0)) // double click wakeup | |
2430 | { | |
2431 | GTP_INFO("Double click to light up the screen!"); | |
2432 | doze_status = DOZE_WAKEUP; | |
2433 | input_report_key(tpd->dev, KEY_POWER, 1); | |
2434 | input_sync(tpd->dev); | |
2435 | input_report_key(tpd->dev, KEY_POWER, 0); | |
2436 | input_sync(tpd->dev); | |
2437 | // clear 0x814B | |
2438 | doze_buf[2] = 0x00; | |
2439 | gtp_i2c_write(i2c_client_point, doze_buf, 3); | |
2440 | } | |
2441 | else | |
2442 | { | |
2443 | gtp_enter_doze(i2c_client_point); | |
2444 | } | |
2445 | } | |
2446 | continue; | |
2447 | } | |
2448 | #endif | |
2449 | if(tpd_halt||(is_reseting == 1) || (load_fw_process == 1)) | |
2450 | { | |
2451 | mutex_unlock(&i2c_access); | |
2452 | GTP_DEBUG("return for interrupt after suspend... "); | |
2453 | continue; | |
2454 | } | |
2455 | ret = gtp_i2c_read(i2c_client_point, point_data, 12); | |
2456 | if (ret < 0) | |
2457 | { | |
2458 | GTP_ERROR("I2C transfer error. errno:%d\n ", ret); | |
2459 | goto exit_work_func; | |
2460 | } | |
2461 | finger = point_data[GTP_ADDR_LENGTH]; | |
2462 | ||
2463 | #if GTP_COMPATIBLE_MODE | |
2464 | if ((finger == 0x00) && (CHIP_TYPE_GT9F == gtp_chip_type)) | |
2465 | { | |
2466 | ret = gtp_i2c_read(i2c_client_point, rqst_data, 3); | |
2467 | ||
2468 | if(ret < 0) | |
2469 | { | |
2470 | GTP_ERROR("I2C transfer error. errno:%d\n ", ret); | |
2471 | goto exit_work_func; | |
2472 | } | |
2473 | switch(rqst_data[2]&0x0F) | |
2474 | { | |
2475 | case GTP_RQST_BAK_REF: | |
2476 | GTP_INFO("Request Ref."); | |
2477 | ret = gtp_bak_ref_proc(i2c_client_point, GTP_BAK_REF_SEND); | |
2478 | if(SUCCESS == ret) | |
2479 | { | |
2480 | GTP_INFO("Send ref success."); | |
2481 | rqst_data[2] = GTP_RQST_RESPONDED; | |
2482 | gtp_i2c_write(i2c_client_point, rqst_data, 3); | |
2483 | } | |
2484 | goto exit_work_func; | |
2485 | case GTP_RQST_CONFIG: | |
2486 | GTP_INFO("Request Config."); | |
2487 | ret = gtp_send_cfg(i2c_client_point); | |
2488 | if (ret < 0) | |
2489 | { | |
2490 | GTP_ERROR("Send config error."); | |
2491 | } | |
2492 | else | |
2493 | { | |
2494 | GTP_INFO("Send config success."); | |
2495 | rqst_data[2] = GTP_RQST_RESPONDED; | |
2496 | gtp_i2c_write(i2c_client_point, rqst_data, 3); | |
2497 | } | |
2498 | goto exit_work_func; | |
2499 | case GTP_RQST_MAIN_CLOCK: | |
2500 | GTP_INFO("Request main clock."); | |
2501 | rqst_processing = 1; | |
2502 | ret = gtp_main_clk_proc(i2c_client_point); | |
2503 | if(SUCCESS == ret) | |
2504 | { | |
2505 | GTP_INFO("Send main clk success."); | |
2506 | rqst_data[2] = GTP_RQST_RESPONDED; | |
2507 | gtp_i2c_write(i2c_client_point, rqst_data, 3); | |
2508 | rqst_processing = 0; | |
2509 | } | |
2510 | goto exit_work_func; | |
2511 | case GTP_RQST_RESET: | |
2512 | GTP_INFO("Request Reset."); | |
2513 | gtp_recovery_reset(i2c_client_point); | |
2514 | goto exit_work_func; | |
2515 | case GTP_RQST_HOTKNOT_CODE: | |
2516 | GTP_INFO("Request HotKnot Code."); | |
2517 | gup_load_hotknot_system(); | |
2518 | goto exit_work_func; | |
2519 | default: | |
2520 | break; | |
2521 | } | |
2522 | } | |
2523 | #endif | |
2524 | ||
2525 | if ((finger & 0x80) == 0) | |
2526 | { | |
2527 | #if HOTKNOT_BLOCK_RW | |
2528 | if(!hotknot_paired_flag) | |
2529 | #endif | |
2530 | { | |
2531 | mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); | |
2532 | mutex_unlock(&i2c_access); | |
2533 | GTP_ERROR("buffer not ready"); | |
2534 | continue; | |
2535 | } | |
2536 | } | |
2537 | ||
2538 | #if HOTKNOT_BLOCK_RW | |
2539 | if(!hotknot_paired_flag && (finger&0x0F)) | |
2540 | { | |
2541 | id = point_data[GTP_ADDR_LENGTH+1]; | |
2542 | hn_pxy_state = point_data[GTP_ADDR_LENGTH+2]&0x80; | |
2543 | hn_pxy_state_bak = point_data[GTP_ADDR_LENGTH+3]&0x80; | |
2544 | if((32 == id) && (0x80 == hn_pxy_state) && (0x80 == hn_pxy_state_bak)) | |
2545 | { | |
2546 | #ifdef HN_DBLCFM_PAIRED | |
2547 | if(hn_paired_cnt++ < 2) | |
2548 | { | |
2549 | goto exit_work_func; | |
2550 | } | |
2551 | #endif | |
2552 | GTP_DEBUG("HotKnot paired!"); | |
2553 | if(wait_hotknot_state & HN_DEVICE_PAIRED) | |
2554 | { | |
2555 | GTP_DEBUG("INT wakeup HN_DEVICE_PAIRED block polling waiter"); | |
2556 | got_hotknot_state |= HN_DEVICE_PAIRED; | |
2557 | wake_up_interruptible(&bp_waiter); | |
2558 | } | |
2559 | hotknot_paired_flag = 1; | |
2560 | goto exit_work_func; | |
2561 | } | |
2562 | else | |
2563 | { | |
2564 | got_hotknot_state &= (~HN_DEVICE_PAIRED); | |
2565 | hn_paired_cnt = 0; | |
2566 | } | |
2567 | ||
2568 | } | |
2569 | ||
2570 | if(hotknot_paired_flag) | |
2571 | { | |
2572 | ret = gtp_i2c_read(i2c_client_point, hn_state_buf, 6); | |
2573 | ||
2574 | if(ret < 0) | |
2575 | { | |
2576 | GTP_ERROR("I2C transfer error. errno:%d\n ", ret); | |
2577 | goto exit_work_func; | |
2578 | } | |
2579 | ||
2580 | got_hotknot_state = 0; | |
2581 | ||
2582 | GTP_DEBUG("[0xAB10~0xAB13]=0x%x,0x%x,0x%x,0x%x", hn_state_buf[GTP_ADDR_LENGTH], | |
2583 | hn_state_buf[GTP_ADDR_LENGTH+1], | |
2584 | hn_state_buf[GTP_ADDR_LENGTH+2], | |
2585 | hn_state_buf[GTP_ADDR_LENGTH+3]); | |
2586 | ||
2587 | if(wait_hotknot_state & HN_MASTER_SEND) | |
2588 | { | |
2589 | if((0x03 == hn_state_buf[GTP_ADDR_LENGTH]) || | |
2590 | (0x04 == hn_state_buf[GTP_ADDR_LENGTH]) || | |
2591 | (0x07 == hn_state_buf[GTP_ADDR_LENGTH])) | |
2592 | { | |
2593 | GTP_DEBUG("Wakeup HN_MASTER_SEND block polling waiter"); | |
2594 | got_hotknot_state |= HN_MASTER_SEND; | |
2595 | got_hotknot_extra_state = hn_state_buf[GTP_ADDR_LENGTH]; | |
2596 | wake_up_interruptible(&bp_waiter); | |
2597 | } | |
2598 | } | |
2599 | else if(wait_hotknot_state & HN_SLAVE_RECEIVED) | |
2600 | { | |
2601 | if((0x03 == hn_state_buf[GTP_ADDR_LENGTH+1]) || | |
2602 | (0x04 == hn_state_buf[GTP_ADDR_LENGTH+1]) || | |
2603 | (0x07 == hn_state_buf[GTP_ADDR_LENGTH+1])) | |
2604 | { | |
2605 | GTP_DEBUG("Wakeup HN_SLAVE_RECEIVED block polling waiter:0x%x", hn_state_buf[GTP_ADDR_LENGTH+1]); | |
2606 | got_hotknot_state |= HN_SLAVE_RECEIVED; | |
2607 | got_hotknot_extra_state = hn_state_buf[GTP_ADDR_LENGTH+1]; | |
2608 | wake_up_interruptible(&bp_waiter); | |
2609 | } | |
2610 | } | |
2611 | else if(wait_hotknot_state & HN_MASTER_DEPARTED) | |
2612 | { | |
2613 | if(0x07 == hn_state_buf[GTP_ADDR_LENGTH]) | |
2614 | { | |
2615 | GTP_DEBUG("Wakeup HN_MASTER_DEPARTED block polling waiter"); | |
2616 | got_hotknot_state |= HN_MASTER_DEPARTED; | |
2617 | wake_up_interruptible(&bp_waiter); | |
2618 | } | |
2619 | } | |
2620 | else if(wait_hotknot_state & HN_SLAVE_DEPARTED) | |
2621 | { | |
2622 | if(0x07 == hn_state_buf[GTP_ADDR_LENGTH+1]) | |
2623 | { | |
2624 | GTP_DEBUG("Wakeup HN_SLAVE_DEPARTED block polling waiter"); | |
2625 | got_hotknot_state |= HN_SLAVE_DEPARTED; | |
2626 | wake_up_interruptible(&bp_waiter); | |
2627 | } | |
2628 | } | |
2629 | } | |
2630 | ||
2631 | #endif | |
2632 | ||
2633 | #ifdef TPD_PROXIMITY | |
2634 | if (tpd_proximity_flag == 1) | |
2635 | { | |
2636 | proximity_status = point_data[GTP_ADDR_LENGTH]; | |
2637 | GTP_DEBUG("REG INDEX[0x814E]:0x%02X\n", proximity_status); | |
2638 | ||
2639 | if (proximity_status & 0x60) //proximity or large touch detect,enable hwm_sensor. | |
2640 | { | |
2641 | tpd_proximity_detect = 0; | |
2642 | //sensor_data.values[0] = 0; | |
2643 | } | |
2644 | else | |
2645 | { | |
2646 | tpd_proximity_detect = 1; | |
2647 | //sensor_data.values[0] = 1; | |
2648 | } | |
2649 | ||
2650 | //get raw data | |
2651 | GTP_DEBUG(" ps change\n"); | |
2652 | GTP_DEBUG("PROXIMITY STATUS:0x%02X\n", tpd_proximity_detect); | |
2653 | //map and store data to hwm_sensor_data | |
2654 | sensor_data.values[0] = tpd_get_ps_value(); | |
2655 | sensor_data.value_divide = 1; | |
2656 | sensor_data.status = SENSOR_STATUS_ACCURACY_MEDIUM; | |
2657 | //report to the up-layer | |
2658 | ret = hwmsen_get_interrupt_data(ID_PROXIMITY, &sensor_data); | |
2659 | ||
2660 | if (ret) | |
2661 | { | |
2662 | GTP_ERROR("Call hwmsen_get_interrupt_data fail = %d\n", err); | |
2663 | } | |
2664 | } | |
2665 | ||
2666 | #endif | |
2667 | ||
2668 | touch_num = finger & 0x0f; | |
2669 | ||
2670 | if (touch_num > GTP_MAX_TOUCH) | |
2671 | { | |
2672 | GTP_ERROR("Bad number of fingers!"); | |
2673 | goto exit_work_func; | |
2674 | } | |
2675 | ||
2676 | if (touch_num > 1) | |
2677 | { | |
2678 | u8 buf[8 * GTP_MAX_TOUCH] = {(GTP_READ_COOR_ADDR + 10) >> 8, (GTP_READ_COOR_ADDR + 10) & 0xff}; | |
2679 | ||
2680 | ret = gtp_i2c_read(i2c_client_point, buf, 2 + 8 * (touch_num - 1)); | |
2681 | memcpy(&point_data[12], &buf[2], 8 * (touch_num - 1)); | |
2682 | } | |
2683 | ||
2684 | #if GTP_HAVE_TOUCH_KEY | |
2685 | key_value = point_data[3 + 8 * touch_num]; | |
2686 | ||
2687 | if (key_value || pre_key) | |
2688 | { | |
2689 | for (i = 0; i < TPD_KEY_COUNT; i++) | |
2690 | { | |
2691 | //input_report_key(tpd->dev, touch_key_array[i], key_value & (0x01 << i)); | |
2692 | if( key_value&(0x01<<i) ) //key=1 menu ;key=2 home; key =4 back; | |
2693 | { | |
2694 | input_x =touch_key_point_maping_array[i].point_x; | |
2695 | input_y = touch_key_point_maping_array[i].point_y; | |
2696 | GTP_DEBUG("button =%d %d",input_x,input_y); | |
2697 | ||
2698 | tpd_down( input_x, input_y, 0, 0); | |
2699 | } | |
2700 | } | |
2701 | ||
2702 | if((pre_key!=0)&&(key_value ==0)) | |
2703 | { | |
2704 | tpd_up( 0, 0, 0); | |
2705 | } | |
2706 | ||
2707 | touch_num = 0; | |
2708 | pre_touch = 0; | |
2709 | } | |
2710 | ||
2711 | #endif | |
2712 | pre_key = key_value; | |
2713 | ||
2714 | GTP_DEBUG("pre_touch:%02x, finger:%02x.", pre_touch, finger); | |
2715 | ||
2716 | if (touch_num) | |
2717 | { | |
2718 | for (i = 0; i < touch_num; i++) | |
2719 | { | |
2720 | coor_data = &point_data[i * 8 + 3]; | |
2721 | ||
2722 | id = coor_data[0] & 0x0F; | |
2723 | input_x = coor_data[1] | coor_data[2] << 8; | |
2724 | input_y = coor_data[3] | coor_data[4] << 8; | |
2725 | input_w = coor_data[5] | coor_data[6] << 8; | |
2726 | ||
2727 | GTP_DEBUG("Original touch point : [X:%04d, Y:%04d]", input_x, input_y); | |
2728 | ||
2729 | input_x = TPD_WARP_X(abs_x_max, input_x); | |
2730 | input_y = TPD_WARP_Y(abs_y_max, input_y); | |
2731 | tpd_calibrate_driver(&input_x, &input_y); | |
2732 | ||
2733 | GTP_DEBUG("Touch point after calibration: [X:%04d, Y:%04d]", input_x, input_y); | |
2734 | ||
2735 | #if GTP_WITH_PEN | |
2736 | id = coor_data[0]; | |
2737 | if ((id & 0x80)) // pen/stylus is activated | |
2738 | { | |
2739 | GTP_DEBUG("Pen touch DOWN!"); | |
2740 | input_report_key(tpd->dev, BTN_TOOL_PEN, 1); | |
2741 | pre_pen = 1; | |
2742 | id = 0; | |
2743 | } | |
2744 | #endif | |
2745 | GTP_DEBUG(" %d)(%d, %d)[%d]", id, input_x, input_y, input_w); | |
2746 | tpd_down(input_x, input_y, input_w, id); | |
2747 | } | |
2748 | } | |
2749 | else if (pre_touch) | |
2750 | { | |
2751 | #if GTP_WITH_PEN | |
2752 | if (pre_pen) | |
2753 | { | |
2754 | GTP_DEBUG("Pen touch UP!"); | |
2755 | input_report_key(tpd->dev, BTN_TOOL_PEN, 0); | |
2756 | pre_pen = 0; | |
2757 | } | |
2758 | #endif | |
2759 | GTP_DEBUG("Touch Release!"); | |
2760 | tpd_up(0, 0, 0); | |
2761 | } | |
2762 | else | |
2763 | { | |
2764 | GTP_DEBUG("Additional Eint!"); | |
2765 | } | |
2766 | pre_touch = touch_num; | |
2767 | ||
2768 | if (tpd != NULL && tpd->dev != NULL) | |
2769 | { | |
2770 | input_sync(tpd->dev); | |
2771 | } | |
2772 | ||
2773 | exit_work_func: | |
2774 | ||
2775 | if (!gtp_rawdiff_mode) | |
2776 | { | |
2777 | ret = gtp_i2c_write(i2c_client_point, end_cmd, 3); | |
2778 | ||
2779 | if (ret < 0) | |
2780 | { | |
2781 | GTP_INFO("I2C write end_cmd error!"); | |
2782 | } | |
2783 | } | |
2784 | mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); | |
2785 | mutex_unlock(&i2c_access); | |
2786 | ||
2787 | } while (!kthread_should_stop()); | |
2788 | ||
2789 | return 0; | |
2790 | } | |
2791 | ||
2792 | static int tpd_local_init(void) | |
2793 | { | |
2794 | #if GTP_ESD_PROTECT | |
2795 | clk_tick_cnt = 2 * HZ; // HZ: clock ticks in 1 second generated by system | |
2796 | GTP_DEBUG("Clock ticks for an esd cycle: %d", clk_tick_cnt); | |
2797 | INIT_DELAYED_WORK(>p_esd_check_work, gtp_esd_check_func); | |
2798 | gtp_esd_check_workqueue = create_workqueue("gtp_esd_check"); | |
2799 | spin_lock_init(&esd_lock); // 2.6.39 & later | |
2800 | // esd_lock = SPIN_LOCK_UNLOCKED; // 2.6.39 & before | |
2801 | #endif | |
2802 | ||
2803 | #if GTP_SUPPORT_I2C_DMA | |
2804 | gpDMABuf_va = (u8 *)dma_alloc_coherent(NULL, GTP_DMA_MAX_TRANSACTION_LENGTH, &gpDMABuf_pa, GFP_KERNEL); | |
2805 | if(!gpDMABuf_va){ | |
2806 | GTP_INFO("[Error] Allocate DMA I2C Buffer failed!\n"); | |
2807 | } | |
2808 | memset(gpDMABuf_va, 0, GTP_DMA_MAX_TRANSACTION_LENGTH); | |
2809 | #endif | |
2810 | if (i2c_add_driver(&tpd_i2c_driver) != 0) | |
2811 | { | |
2812 | GTP_INFO("unable to add i2c driver.\n"); | |
2813 | return -1; | |
2814 | } | |
2815 | ||
2816 | if (tpd_load_status == 0) //if(tpd_load_status == 0) // disable auto load touch driver for linux3.0 porting | |
2817 | { | |
2818 | GTP_INFO("add error touch panel driver.\n"); | |
2819 | i2c_del_driver(&tpd_i2c_driver); | |
2820 | return -1; | |
2821 | } | |
2822 | input_set_abs_params(tpd->dev, ABS_MT_TRACKING_ID, 0, (GTP_MAX_TOUCH-1), 0, 0); | |
2823 | #ifdef TPD_HAVE_BUTTON | |
2824 | tpd_button_setting(TPD_KEY_COUNT, tpd_keys_local, tpd_keys_dim_local);// initialize tpd button data | |
2825 | #endif | |
2826 | ||
2827 | #if (defined(TPD_WARP_START) && defined(TPD_WARP_END)) | |
2828 | TPD_DO_WARP = 1; | |
2829 | memcpy(tpd_wb_start, tpd_wb_start_local, TPD_WARP_CNT * 4); | |
2830 | memcpy(tpd_wb_end, tpd_wb_start_local, TPD_WARP_CNT * 4); | |
2831 | #endif | |
2832 | ||
2833 | #if (defined(TPD_HAVE_CALIBRATION) && !defined(TPD_CUSTOM_CALIBRATION)) | |
2834 | //memcpy(tpd_calmat, tpd_def_calmat_local, 8 * 4); | |
2835 | //memcpy(tpd_def_calmat, tpd_def_calmat_local, 8 * 4); | |
2836 | if (FACTORY_BOOT == get_boot_mode()) | |
2837 | { | |
2838 | TPD_DEBUG("Factory mode is detected! \n"); | |
2839 | memcpy(tpd_calmat, tpd_def_calmat_local_factory, 8 * 4); | |
2840 | memcpy(tpd_def_calmat, tpd_def_calmat_local_factory, 8 * 4); | |
2841 | } | |
2842 | else | |
2843 | { | |
2844 | TPD_DEBUG("Normal mode is detected! \n"); | |
2845 | memcpy(tpd_calmat, tpd_def_calmat_local_normal, 8 * 4); | |
2846 | memcpy(tpd_def_calmat, tpd_def_calmat_local_normal, 8 * 4); | |
2847 | } | |
2848 | #endif | |
2849 | ||
2850 | // set vendor string | |
2851 | tpd->dev->id.vendor = 0x00; | |
2852 | tpd->dev->id.product = tpd_info.pid; | |
2853 | tpd->dev->id.version = tpd_info.vid; | |
2854 | ||
2855 | GTP_INFO("end %s, %d\n", __FUNCTION__, __LINE__); | |
2856 | tpd_type_cap = 1; | |
2857 | ||
2858 | return 0; | |
2859 | } | |
2860 | ||
2861 | #if GTP_SLIDE_WAKEUP | |
2862 | static s8 gtp_enter_doze(struct i2c_client *client) | |
2863 | { | |
2864 | s8 ret = -1; | |
2865 | s8 retry = 0; | |
2866 | u8 i2c_control_buf[3] = {(u8)(GTP_REG_SLEEP >> 8), (u8)GTP_REG_SLEEP, 8}; | |
2867 | ||
2868 | GTP_DEBUG_FUNC(); | |
2869 | #if GTP_DBL_CLK_WAKEUP | |
2870 | i2c_control_buf[2] = 0x09; | |
2871 | #endif | |
2872 | ||
2873 | GTP_DEBUG("entering doze mode..."); | |
2874 | while(retry++ < 5) | |
2875 | { | |
2876 | i2c_control_buf[0] = 0x80; | |
2877 | i2c_control_buf[1] = 0x46; | |
2878 | ret = gtp_i2c_write(client, i2c_control_buf, 3); | |
2879 | if (ret < 0) | |
2880 | { | |
2881 | GTP_DEBUG("failed to set doze flag into 0x8046, %d", retry); | |
2882 | continue; | |
2883 | } | |
2884 | i2c_control_buf[0] = 0x80; | |
2885 | i2c_control_buf[1] = 0x40; | |
2886 | ret = gtp_i2c_write(client, i2c_control_buf, 3); | |
2887 | if (ret > 0) | |
2888 | { | |
2889 | doze_status = DOZE_ENABLED; | |
2890 | GTP_DEBUG("GTP has been working in doze mode!"); | |
2891 | return ret; | |
2892 | } | |
2893 | msleep(10); | |
2894 | } | |
2895 | GTP_ERROR("GTP send doze cmd failed."); | |
2896 | return ret; | |
2897 | } | |
2898 | ||
2899 | #else | |
2900 | /******************************************************* | |
2901 | Function: | |
2902 | Eter sleep function. | |
2903 | ||
2904 | Input: | |
2905 | client:i2c_client. | |
2906 | ||
2907 | Output: | |
2908 | Executive outcomes.0--success,non-0--fail. | |
2909 | *******************************************************/ | |
2910 | static s8 gtp_enter_sleep(struct i2c_client *client) | |
2911 | { | |
2912 | #if GTP_COMPATIBLE_MODE | |
2913 | if (CHIP_TYPE_GT9F == gtp_chip_type) | |
2914 | { | |
2915 | u8 i2c_status_buf[3] = {0x80, 0x44, 0x00}; | |
2916 | s32 ret = 0; | |
2917 | ||
2918 | ret = gtp_i2c_read(client, i2c_status_buf, 3); | |
2919 | if(ret <= 0) | |
2920 | { | |
2921 | GTP_ERROR("[gtp_enter_sleep]Read ref status reg error."); | |
2922 | } | |
2923 | ||
2924 | if (i2c_status_buf[2] & 0x80) | |
2925 | { | |
2926 | //Store bak ref | |
2927 | ret = gtp_bak_ref_proc(client, GTP_BAK_REF_STORE); | |
2928 | if(FAIL == ret) | |
2929 | { | |
2930 | GTP_ERROR("[gtp_enter_sleep]Store bak ref failed."); | |
2931 | } | |
2932 | } | |
2933 | } | |
2934 | #endif | |
2935 | ||
2936 | #if GTP_POWER_CTRL_SLEEP | |
2937 | ||
2938 | GTP_GPIO_OUTPUT(GTP_RST_PORT, 0); | |
2939 | GTP_GPIO_OUTPUT(GTP_INT_PORT, 0); | |
2940 | msleep(10); | |
2941 | ||
2942 | #ifdef TPD_POWER_SOURCE_1800 | |
2943 | hwPowerDown(TPD_POWER_SOURCE_1800, "TP"); | |
2944 | #endif | |
2945 | ||
2946 | #ifdef TPD_POWER_SOURCE_CUSTOM | |
2947 | hwPowerDown(TPD_POWER_SOURCE_CUSTOM, "TP"); | |
2948 | #else | |
2949 | hwPowerDown(MT65XX_POWER_LDO_VGP2, "TP"); | |
2950 | #endif | |
2951 | ||
2952 | GTP_INFO("GTP enter sleep by poweroff!"); | |
2953 | return 0; | |
2954 | ||
2955 | #else | |
2956 | { | |
2957 | s8 ret = -1; | |
2958 | s8 retry = 0; | |
2959 | u8 i2c_control_buf[3] = {(u8)(GTP_REG_SLEEP >> 8), (u8)GTP_REG_SLEEP, 5}; | |
2960 | ||
2961 | ||
2962 | GTP_GPIO_OUTPUT(GTP_INT_PORT, 0); | |
2963 | msleep(5); | |
2964 | ||
2965 | while (retry++ < 5) | |
2966 | { | |
2967 | ret = gtp_i2c_write(client, i2c_control_buf, 3); | |
2968 | ||
2969 | if (ret > 0) | |
2970 | { | |
2971 | GTP_INFO("GTP enter sleep!"); | |
2972 | ||
2973 | return ret; | |
2974 | } | |
2975 | ||
2976 | msleep(10); | |
2977 | } | |
2978 | ||
2979 | GTP_ERROR("GTP send sleep cmd failed."); | |
2980 | return ret; | |
2981 | } | |
2982 | #endif | |
2983 | } | |
2984 | #endif | |
2985 | ||
2986 | /******************************************************* | |
2987 | Function: | |
2988 | Wakeup from sleep mode Function. | |
2989 | ||
2990 | Input: | |
2991 | client:i2c_client. | |
2992 | ||
2993 | Output: | |
2994 | Executive outcomes.0--success,non-0--fail. | |
2995 | *******************************************************/ | |
2996 | static s8 gtp_wakeup_sleep(struct i2c_client *client) | |
2997 | { | |
2998 | u8 retry = 0; | |
2999 | s8 ret = -1; | |
3000 | ||
3001 | GTP_DEBUG("GTP wakeup begin."); | |
3002 | ||
3003 | #if (GTP_POWER_CTRL_SLEEP) | |
3004 | ||
3005 | #if GTP_COMPATIBLE_MODE | |
3006 | if (CHIP_TYPE_GT9F == gtp_chip_type) | |
3007 | { | |
3008 | force_reset_guitar(); | |
3009 | GTP_INFO("Esd recovery wakeup."); | |
3010 | return 0; | |
3011 | } | |
3012 | #endif | |
3013 | ||
3014 | while (retry++ < 5) | |
3015 | { | |
3016 | ret = tpd_power_on(client); | |
3017 | ||
3018 | if (ret < 0) | |
3019 | { | |
3020 | GTP_ERROR("I2C Power on ERROR!"); | |
3021 | continue; | |
3022 | } | |
3023 | GTP_INFO("Ic wakeup by poweron"); | |
3024 | return 0; | |
3025 | } | |
3026 | #else | |
3027 | ||
3028 | #if GTP_COMPATIBLE_MODE | |
3029 | if (CHIP_TYPE_GT9F == gtp_chip_type) | |
3030 | { | |
3031 | u8 opr_buf[2] = {0}; | |
3032 | ||
3033 | while (retry++ < 10) | |
3034 | { | |
3035 | GTP_GPIO_OUTPUT(GTP_INT_PORT, 1); | |
3036 | msleep(5); | |
3037 | ||
3038 | ret = gtp_i2c_test(client); | |
3039 | ||
3040 | if (ret >= 0) | |
3041 | { | |
3042 | // Hold ss51 & dsp | |
3043 | opr_buf[0] = 0x0C; | |
3044 | ret = i2c_write_bytes(client, 0x4180, opr_buf, 1); | |
3045 | if (ret < 0) | |
3046 | { | |
3047 | GTP_DEBUG("Hold ss51 & dsp I2C error,retry:%d", retry); | |
3048 | continue; | |
3049 | } | |
3050 | ||
3051 | // Confirm hold | |
3052 | opr_buf[0] = 0x00; | |
3053 | ret = i2c_read_bytes(client, 0x4180, opr_buf, 1); | |
3054 | if (ret < 0) | |
3055 | { | |
3056 | GTP_DEBUG("confirm ss51 & dsp hold, I2C error,retry:%d", retry); | |
3057 | continue; | |
3058 | } | |
3059 | if (0x0C != opr_buf[0]) | |
3060 | { | |
3061 | GTP_DEBUG("ss51 & dsp not hold, val: %d, retry: %d", opr_buf[0], retry); | |
3062 | continue; | |
3063 | } | |
3064 | GTP_DEBUG("ss51 & dsp has been hold"); | |
3065 | ||
3066 | ret = gtp_fw_startup(client); | |
3067 | if (FAIL == ret) | |
3068 | { | |
3069 | GTP_ERROR("[gtp_wakeup_sleep]Startup fw failed."); | |
3070 | continue; | |
3071 | } | |
3072 | GTP_INFO("flashless wakeup sleep success"); | |
3073 | return ret; | |
3074 | } | |
3075 | force_reset_guitar(); | |
3076 | } | |
3077 | if (retry >= 10) | |
3078 | { | |
3079 | GTP_ERROR("wakeup retry timeout, process esd reset"); | |
3080 | force_reset_guitar(); | |
3081 | } | |
3082 | GTP_ERROR("GTP wakeup sleep failed."); | |
3083 | return ret; | |
3084 | } | |
3085 | #endif | |
3086 | while (retry++ < 10) | |
3087 | { | |
3088 | #if GTP_SLIDE_WAKEUP | |
3089 | if (DOZE_WAKEUP != doze_status) | |
3090 | { | |
3091 | GTP_DEBUG("power wakeup, reset guitar"); | |
3092 | doze_status = DOZE_DISABLED; | |
3093 | ||
3094 | mt_eint_mask(CUST_EINT_TOUCH_PANEL_NUM); | |
3095 | gtp_reset_guitar(client, 20); | |
3096 | mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); | |
3097 | } | |
3098 | else | |
3099 | { | |
3100 | GTP_DEBUG("slide(double click) wakeup, no reset guitar"); | |
3101 | doze_status = DOZE_DISABLED; | |
3102 | #if GTP_ESD_PROTECT | |
3103 | gtp_init_ext_watchdog(client); | |
3104 | #endif | |
3105 | } | |
3106 | #else | |
3107 | // if (chip_gt9xxs == 1) | |
3108 | // { | |
3109 | // gtp_reset_guitar(client, 10); | |
3110 | // } | |
3111 | // else | |
3112 | // { | |
3113 | // GTP_GPIO_OUTPUT(GTP_INT_PORT, 1); | |
3114 | // msleep(5); | |
3115 | // } | |
3116 | ||
3117 | //GTP_GPIO_AS_INT(GTP_INT_PORT); | |
3118 | gtp_reset_guitar(client, 20); // for double-system, reset to default system | |
3119 | ||
3120 | return 2; | |
3121 | #endif | |
3122 | ||
3123 | ret = gtp_i2c_test(client); | |
3124 | ||
3125 | if (ret >= 0) | |
3126 | { | |
3127 | GTP_INFO("GTP wakeup sleep."); | |
3128 | #if (!GTP_SLIDE_WAKEUP) | |
3129 | if (chip_gt9xxs == 0) | |
3130 | { | |
3131 | gtp_int_sync(25); | |
3132 | #if GTP_ESD_PROTECT | |
3133 | gtp_init_ext_watchdog(client); | |
3134 | #endif | |
3135 | } | |
3136 | #endif | |
3137 | ||
3138 | return ret; | |
3139 | } | |
3140 | gtp_reset_guitar(client, 20); | |
3141 | } | |
3142 | #endif | |
3143 | GTP_ERROR("GTP wakeup sleep failed."); | |
3144 | return ret; | |
3145 | } | |
3146 | ||
3147 | /* Function to manage low power suspend */ | |
3148 | static void tpd_suspend(struct early_suspend *h) | |
3149 | { | |
3150 | s32 ret = -1; | |
3151 | u8 buf[3] = {0x81, 0xaa, 0}; | |
3152 | ||
3153 | #ifdef TPD_PROXIMITY | |
3154 | if (tpd_proximity_flag == 1) | |
3155 | { | |
3156 | return ; | |
3157 | } | |
3158 | #endif | |
3159 | ||
3160 | #if HOTKNOT_BLOCK_RW | |
3161 | if(hotknot_paired_flag) | |
3162 | { | |
3163 | return; | |
3164 | } | |
3165 | #endif | |
3166 | ||
3167 | mutex_lock(&i2c_access); | |
3168 | ||
3169 | gtp_i2c_read(i2c_client_point,buf,sizeof(buf)); | |
3170 | if(buf[2] == 0x55) | |
3171 | { | |
3172 | mutex_unlock(&i2c_access); | |
3173 | GTP_INFO("GTP early suspend pair sucess"); | |
3174 | return; | |
3175 | } | |
3176 | tpd_halt = 1; | |
3177 | ||
3178 | mutex_unlock(&i2c_access); | |
3179 | #if GTP_ESD_PROTECT | |
3180 | cancel_delayed_work_sync(>p_esd_check_work); | |
3181 | #endif | |
3182 | ||
3183 | #ifdef GTP_CHARGER_DETECT | |
3184 | cancel_delayed_work_sync(>p_charger_check_work); | |
3185 | #endif | |
3186 | mutex_lock(&i2c_access); | |
3187 | ||
3188 | #if GTP_SLIDE_WAKEUP | |
3189 | ret = gtp_enter_doze(i2c_client_point); | |
3190 | #else | |
3191 | mt_eint_mask(CUST_EINT_TOUCH_PANEL_NUM); | |
3192 | ret = gtp_enter_sleep(i2c_client_point); | |
3193 | if (ret < 0) | |
3194 | { | |
3195 | GTP_ERROR("GTP early suspend failed."); | |
3196 | } | |
3197 | #endif | |
3198 | mutex_unlock(&i2c_access); | |
3199 | ||
3200 | msleep(58); | |
3201 | } | |
3202 | ||
3203 | /* Function to manage power-on resume */ | |
3204 | static void tpd_resume(struct early_suspend *h) | |
3205 | { | |
3206 | s32 ret = -1; | |
3207 | ||
3208 | printk("mtk-tpd: %s start\n", __FUNCTION__); | |
3209 | #ifdef TPD_PROXIMITY | |
3210 | ||
3211 | if (tpd_proximity_flag == 1) | |
3212 | { | |
3213 | return ; | |
3214 | } | |
3215 | ||
3216 | #endif | |
3217 | #if HOTKNOT_BLOCK_RW | |
3218 | if(hotknot_paired_flag) | |
3219 | { | |
3220 | return; | |
3221 | } | |
3222 | #endif | |
3223 | if(load_fw_process == 0) | |
3224 | { | |
3225 | ret = gtp_wakeup_sleep(i2c_client_point); | |
3226 | ||
3227 | if (ret < 0) | |
3228 | { | |
3229 | GTP_ERROR("GTP later resume failed."); | |
3230 | } | |
3231 | } | |
3232 | ||
3233 | #if GTP_COMPATIBLE_MODE | |
3234 | if (CHIP_TYPE_GT9F == gtp_chip_type) | |
3235 | { | |
3236 | // do nothing | |
3237 | } | |
3238 | else | |
3239 | #endif | |
3240 | { | |
3241 | //gtp_send_cfg(i2c_client_point); | |
3242 | } | |
3243 | ||
3244 | #if GTP_CHARGER_SWITCH | |
3245 | gtp_charger_switch(1); // force update | |
3246 | #endif | |
3247 | ||
3248 | #if GTP_SLIDE_WAKEUP | |
3249 | doze_status = DOZE_DISABLED; | |
3250 | #else | |
3251 | mutex_lock(&i2c_access); | |
3252 | tpd_halt = 0; | |
3253 | mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); | |
3254 | mutex_unlock(&i2c_access); | |
3255 | #endif | |
3256 | ||
3257 | #if GTP_ESD_PROTECT | |
3258 | queue_delayed_work(gtp_esd_check_workqueue, >p_esd_check_work, clk_tick_cnt); | |
3259 | #endif | |
3260 | ||
3261 | #ifdef GTP_CHARGER_DETECT | |
3262 | queue_delayed_work(gtp_charger_check_workqueue, >p_charger_check_work, clk_tick_cnt); | |
3263 | #endif | |
3264 | printk("mtk-tpd: %s end\n", __FUNCTION__); | |
3265 | } | |
3266 | ||
3267 | static struct tpd_driver_t tpd_device_driver = | |
3268 | { | |
3269 | .tpd_device_name = "gt9xx", | |
3270 | .tpd_local_init = tpd_local_init, | |
3271 | .suspend = tpd_suspend, | |
3272 | .resume = tpd_resume, | |
3273 | #ifdef TPD_HAVE_BUTTON | |
3274 | .tpd_have_button = 1, | |
3275 | #else | |
3276 | .tpd_have_button = 0, | |
3277 | #endif | |
3278 | }; | |
3279 | ||
3280 | static void tpd_off(void) | |
3281 | { | |
3282 | ||
3283 | #ifdef TPD_POWER_SOURCE_CUSTOM | |
3284 | hwPowerDown(TPD_POWER_SOURCE_CUSTOM, "TP"); | |
3285 | #else | |
3286 | hwPowerDown(MT65XX_POWER_LDO_VGP2, "TP"); | |
3287 | #endif | |
3288 | #ifdef TPD_POWER_SOURCE_1800 | |
3289 | hwPowerDown(TPD_POWER_SOURCE_1800, "TP"); | |
3290 | #endif | |
3291 | GTP_INFO("GTP enter sleep!"); | |
3292 | ||
3293 | tpd_halt = 1; | |
3294 | mt_eint_mask(CUST_EINT_TOUCH_PANEL_NUM); | |
3295 | } | |
3296 | ||
3297 | static void tpd_on(void) | |
3298 | { | |
3299 | s32 ret = -1, retry = 0; | |
3300 | ||
3301 | while (retry++ < 5) | |
3302 | { | |
3303 | ret = tpd_power_on(i2c_client_point); | |
3304 | ||
3305 | if (ret < 0) | |
3306 | { | |
3307 | GTP_ERROR("I2C Power on ERROR!"); | |
3308 | } | |
3309 | ||
3310 | ret = gtp_send_cfg(i2c_client_point); | |
3311 | ||
3312 | if (ret > 0) | |
3313 | { | |
3314 | GTP_DEBUG("Wakeup sleep send config success."); | |
3315 | } | |
3316 | } | |
3317 | if (ret < 0) | |
3318 | { | |
3319 | GTP_ERROR("GTP later resume failed."); | |
3320 | } | |
3321 | ||
3322 | mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); | |
3323 | tpd_halt = 0; | |
3324 | } | |
3325 | ||
3326 | /* called when loaded into kernel */ | |
3327 | static int __init tpd_driver_init(void) | |
3328 | { | |
3329 | GTP_INFO("MediaTek gt91xx touch panel driver init\n"); | |
3330 | #if defined(TPD_I2C_NUMBER) | |
3331 | i2c_register_board_info(TPD_I2C_NUMBER, &i2c_tpd, 1); | |
3332 | #else | |
3333 | i2c_register_board_info(0, &i2c_tpd, 1); | |
3334 | #endif | |
3335 | if (tpd_driver_add(&tpd_device_driver) < 0) | |
3336 | GTP_INFO("add generic driver failed\n"); | |
3337 | ||
3338 | return 0; | |
3339 | } | |
3340 | ||
3341 | /* should never be called */ | |
3342 | static void __exit tpd_driver_exit(void) | |
3343 | { | |
3344 | GTP_INFO("MediaTek gt91xx touch panel driver exit\n"); | |
3345 | tpd_driver_remove(&tpd_device_driver); | |
3346 | } | |
3347 | ||
3348 | module_init(tpd_driver_init); | |
3349 | module_exit(tpd_driver_exit); | |
3350 |