xref: /OK3568_Linux_fs/kernel/drivers/input/touchscreen/gslx680_d708/rockchip_gslX680.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * drivers/input/touchscreen/gslX680.c
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Copyright (c) 2012 Shanghai Basewin
5*4882a593Smuzhiyun  *	Guan Yuwei<guanyuwei@basewin.com>
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  *  This program is free software; you can redistribute it and/or modify
8*4882a593Smuzhiyun  *  it under the terms of the GNU General Public License version 2 as
9*4882a593Smuzhiyun  *  published by the Free Software Foundation.
10*4882a593Smuzhiyun  */
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun #include <linux/module.h>
13*4882a593Smuzhiyun #include <linux/delay.h>
14*4882a593Smuzhiyun #include <linux/device.h>
15*4882a593Smuzhiyun #include <linux/hrtimer.h>
16*4882a593Smuzhiyun #include <linux/i2c.h>
17*4882a593Smuzhiyun #include <linux/input.h>
18*4882a593Smuzhiyun #include <linux/interrupt.h>
19*4882a593Smuzhiyun #include <linux/io.h>
20*4882a593Smuzhiyun #include <linux/platform_device.h>
21*4882a593Smuzhiyun #include <linux/async.h>
22*4882a593Smuzhiyun #include <linux/irq.h>
23*4882a593Smuzhiyun #include <linux/workqueue.h>
24*4882a593Smuzhiyun #include <linux/proc_fs.h>
25*4882a593Smuzhiyun #include <linux/input/mt.h>
26*4882a593Smuzhiyun #include <linux/gpio.h>
27*4882a593Smuzhiyun #include <linux/version.h>
28*4882a593Smuzhiyun #include <linux/slab.h>
29*4882a593Smuzhiyun #include <linux/of_gpio.h>
30*4882a593Smuzhiyun #include <linux/regulator/consumer.h>
31*4882a593Smuzhiyun #include "../tp_suspend.h"
32*4882a593Smuzhiyun #include "rockchip_gslX680_88v.h"
33*4882a593Smuzhiyun #include "rockchip_gsl3670.h"
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun #define REPORT_DATA_ANDROID_4_0
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun #define SLEEP_CLEAR_POINT
38*4882a593Smuzhiyun #ifdef FILTER_POINT
39*4882a593Smuzhiyun #define FILTER_MAX	9
40*4882a593Smuzhiyun #endif
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun #define GSLX680_I2C_NAME	"gslX680-d708"
43*4882a593Smuzhiyun #define GSLX680_I2C_ADDR	0x40
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun #define GSL_DATA_REG		0x80
46*4882a593Smuzhiyun #define GSL_STATUS_REG		0xe0
47*4882a593Smuzhiyun #define GSL_PAGE_REG		0xf0
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun #define PRESS_MAX		255
50*4882a593Smuzhiyun #define MAX_FINGERS		5
51*4882a593Smuzhiyun #define MAX_CONTACTS		10
52*4882a593Smuzhiyun #define DMA_TRANS_LEN		0x20
53*4882a593Smuzhiyun #ifdef GSL_MONITOR
54*4882a593Smuzhiyun static struct delayed_work gsl_monitor_work;
55*4882a593Smuzhiyun static struct workqueue_struct *gsl_monitor_workqueue;
56*4882a593Smuzhiyun static u8 int_1st[4] = {0};
57*4882a593Smuzhiyun static u8 int_2nd[4] = {0};
58*4882a593Smuzhiyun static char dac_counter;
59*4882a593Smuzhiyun static char b0_counter;
60*4882a593Smuzhiyun static char bc_counter;
61*4882a593Smuzhiyun static char i2c_lock_flag;
62*4882a593Smuzhiyun #endif
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun /* Will@20150707 + click tp can wake up lcd when lcd suspend. */
65*4882a593Smuzhiyun /* if define enable this function */
66*4882a593Smuzhiyun /* #define BND_GESTURE */
67*4882a593Smuzhiyun #ifdef BND_GESTURE
68*4882a593Smuzhiyun extern void rk_send_wakeup_key(void);
69*4882a593Smuzhiyun static int gsl_lcd_flag = -1;
70*4882a593Smuzhiyun static int gsl_gesture_flag = -1;
71*4882a593Smuzhiyun #endif
72*4882a593Smuzhiyun #define TPD_PROC_DEBUG
73*4882a593Smuzhiyun #ifdef TPD_PROC_DEBUG
74*4882a593Smuzhiyun #include <linux/proc_fs.h>
75*4882a593Smuzhiyun #include <linux/uaccess.h>
76*4882a593Smuzhiyun #define GSL_CONFIG_PROC_FILE "gsl_config"
77*4882a593Smuzhiyun #define CONFIG_LEN 31
78*4882a593Smuzhiyun static char gsl_read[CONFIG_LEN];
79*4882a593Smuzhiyun static u8 gsl_data_proc[8] = {0};
80*4882a593Smuzhiyun static u8 gsl_proc_flag;
81*4882a593Smuzhiyun #endif
82*4882a593Smuzhiyun 
83*4882a593Smuzhiyun static struct i2c_client *gsl_client;
84*4882a593Smuzhiyun int g_wake_pin;
85*4882a593Smuzhiyun /* EXPORT_SYNBOL(g_wake_pin); */
86*4882a593Smuzhiyun #ifdef HAVE_TOUCH_KEY
87*4882a593Smuzhiyun static u16 key;
88*4882a593Smuzhiyun static int key_state_flag;
89*4882a593Smuzhiyun struct key_data {
90*4882a593Smuzhiyun 	u16 key;
91*4882a593Smuzhiyun 	u16 x_min;
92*4882a593Smuzhiyun 	u16 x_max;
93*4882a593Smuzhiyun 	u16 y_min;
94*4882a593Smuzhiyun 	u16 y_max;
95*4882a593Smuzhiyun };
96*4882a593Smuzhiyun 
97*4882a593Smuzhiyun const u16 key_array[] = {
98*4882a593Smuzhiyun 				KEY_BACK,
99*4882a593Smuzhiyun 				KEY_HOME,
100*4882a593Smuzhiyun 				KEY_MENU,
101*4882a593Smuzhiyun 				KEY_SEARCH,
102*4882a593Smuzhiyun };
103*4882a593Smuzhiyun #define MAX_KEY_NUM     (sizeof(key_array)/sizeof(key_array[0]))
104*4882a593Smuzhiyun 
105*4882a593Smuzhiyun struct key_data gsl_key_data[MAX_KEY_NUM] = {
106*4882a593Smuzhiyun 	{KEY_BACK, 2048, 2048, 2048, 2048},
107*4882a593Smuzhiyun 	{KEY_HOME, 2048, 2048, 2048, 2048},
108*4882a593Smuzhiyun 	{KEY_MENU, 2048, 2048, 2048, 2048},
109*4882a593Smuzhiyun 	{KEY_SEARCH, 2048, 2048, 2048, 2048},
110*4882a593Smuzhiyun };
111*4882a593Smuzhiyun #endif
112*4882a593Smuzhiyun 
113*4882a593Smuzhiyun struct gsl_ts_data {
114*4882a593Smuzhiyun 	u8 x_index;
115*4882a593Smuzhiyun 	u8 y_index;
116*4882a593Smuzhiyun 	u8 z_index;
117*4882a593Smuzhiyun 	u8 id_index;
118*4882a593Smuzhiyun 	u8 touch_index;
119*4882a593Smuzhiyun 	u8 data_reg;
120*4882a593Smuzhiyun 	u8 status_reg;
121*4882a593Smuzhiyun 	u8 data_size;
122*4882a593Smuzhiyun 	u8 touch_bytes;
123*4882a593Smuzhiyun 	u8 update_data;
124*4882a593Smuzhiyun 	u8 touch_meta_data;
125*4882a593Smuzhiyun 	u8 finger_size;
126*4882a593Smuzhiyun };
127*4882a593Smuzhiyun 
128*4882a593Smuzhiyun static struct gsl_ts_data devices[] = {
129*4882a593Smuzhiyun 	{
130*4882a593Smuzhiyun 		.x_index = 6,
131*4882a593Smuzhiyun 		.y_index = 4,
132*4882a593Smuzhiyun 		.z_index = 5,
133*4882a593Smuzhiyun 		.id_index = 7,
134*4882a593Smuzhiyun 		.data_reg = GSL_DATA_REG,
135*4882a593Smuzhiyun 		.status_reg = GSL_STATUS_REG,
136*4882a593Smuzhiyun 		.update_data = 0x4,
137*4882a593Smuzhiyun 		.touch_bytes = 4,
138*4882a593Smuzhiyun 		.touch_meta_data = 4,
139*4882a593Smuzhiyun 		.finger_size = 70,
140*4882a593Smuzhiyun 	},
141*4882a593Smuzhiyun };
142*4882a593Smuzhiyun 
143*4882a593Smuzhiyun struct gsl_ts {
144*4882a593Smuzhiyun 	struct i2c_client *client;
145*4882a593Smuzhiyun 	struct input_dev *input;
146*4882a593Smuzhiyun 	struct work_struct work;
147*4882a593Smuzhiyun 	struct workqueue_struct *wq;
148*4882a593Smuzhiyun 	struct gsl_ts_data *dd;
149*4882a593Smuzhiyun 	u8 *touch_data;
150*4882a593Smuzhiyun 	u8 device_id;
151*4882a593Smuzhiyun 	int irq;
152*4882a593Smuzhiyun 	int irq_pin;
153*4882a593Smuzhiyun 	int wake_pin;
154*4882a593Smuzhiyun 	struct  tp_device  tp;
155*4882a593Smuzhiyun 	int screen_max_x;
156*4882a593Smuzhiyun 	int screen_max_y;
157*4882a593Smuzhiyun #if defined(CONFIG_HAS_EARLYSUSPEND)
158*4882a593Smuzhiyun 	struct early_suspend early_suspend;
159*4882a593Smuzhiyun #endif
160*4882a593Smuzhiyun 	struct regulator        *rst;
161*4882a593Smuzhiyun };
162*4882a593Smuzhiyun 
163*4882a593Smuzhiyun #ifdef GSL_DEBUG
164*4882a593Smuzhiyun #define print_info(fmt, args...)	\
165*4882a593Smuzhiyun 	do {				\
166*4882a593Smuzhiyun 		printk(fmt, ##args);	\
167*4882a593Smuzhiyun 	} while (0)
168*4882a593Smuzhiyun #else
169*4882a593Smuzhiyun #define print_info(fmt, args...)
170*4882a593Smuzhiyun #endif
171*4882a593Smuzhiyun 
172*4882a593Smuzhiyun static u32 id_sign[MAX_CONTACTS + 1] = {0};
173*4882a593Smuzhiyun static u8 id_state_flag[MAX_CONTACTS + 1] = {0};
174*4882a593Smuzhiyun static u8 id_state_old_flag[MAX_CONTACTS + 1] = {0};
175*4882a593Smuzhiyun static u16 x_old[MAX_CONTACTS + 1] = {0};
176*4882a593Smuzhiyun static u16 y_old[MAX_CONTACTS + 1] = {0};
177*4882a593Smuzhiyun static u16 x_new;
178*4882a593Smuzhiyun static u16 y_new;
179*4882a593Smuzhiyun static int revert_x;
180*4882a593Smuzhiyun static int revert_y = 1;
181*4882a593Smuzhiyun static int revert_xy = 1;
182*4882a593Smuzhiyun static u8 chip_type;
183*4882a593Smuzhiyun static u8 is_noid_version = 1;
184*4882a593Smuzhiyun 
185*4882a593Smuzhiyun int is_zet62xx;
186*4882a593Smuzhiyun 
gslX680_shutdown_low(void)187*4882a593Smuzhiyun static int gslX680_shutdown_low(void)
188*4882a593Smuzhiyun {
189*4882a593Smuzhiyun 	if (g_wake_pin != 0) {
190*4882a593Smuzhiyun 		gpio_direction_output(g_wake_pin, 0);
191*4882a593Smuzhiyun 	}
192*4882a593Smuzhiyun 
193*4882a593Smuzhiyun 	return 0;
194*4882a593Smuzhiyun }
195*4882a593Smuzhiyun 
196*4882a593Smuzhiyun 
gslX680_shutdown_high(void)197*4882a593Smuzhiyun static int gslX680_shutdown_high(void)
198*4882a593Smuzhiyun {
199*4882a593Smuzhiyun 	if (g_wake_pin != 0) {
200*4882a593Smuzhiyun 		gpio_direction_output(g_wake_pin, 1);
201*4882a593Smuzhiyun 	}
202*4882a593Smuzhiyun 
203*4882a593Smuzhiyun 	return 0;
204*4882a593Smuzhiyun }
205*4882a593Smuzhiyun 
join_bytes(u8 a,u8 b)206*4882a593Smuzhiyun static inline u16 join_bytes(u8 a, u8 b)
207*4882a593Smuzhiyun {
208*4882a593Smuzhiyun 	u16 ab = 0;
209*4882a593Smuzhiyun 	ab = ab | a;
210*4882a593Smuzhiyun 	ab = ab << 8 | b;
211*4882a593Smuzhiyun 	return ab;
212*4882a593Smuzhiyun }
213*4882a593Smuzhiyun 
gsl_write_interface(struct i2c_client * client,const u8 reg,u8 * buf,u32 num)214*4882a593Smuzhiyun static u32 gsl_write_interface(struct i2c_client *client, const u8 reg, u8 *buf, u32 num)
215*4882a593Smuzhiyun {
216*4882a593Smuzhiyun 	struct i2c_msg xfer_msg[1];
217*4882a593Smuzhiyun 
218*4882a593Smuzhiyun 	buf[0] = reg;
219*4882a593Smuzhiyun 
220*4882a593Smuzhiyun 	xfer_msg[0].addr = client->addr;
221*4882a593Smuzhiyun 	xfer_msg[0].len = num + 1;
222*4882a593Smuzhiyun 	xfer_msg[0].flags = client->flags & I2C_M_TEN;
223*4882a593Smuzhiyun 	xfer_msg[0].buf = buf;
224*4882a593Smuzhiyun 
225*4882a593Smuzhiyun 	return i2c_transfer(client->adapter, xfer_msg, 1) == 1 ? 0 : -EFAULT;
226*4882a593Smuzhiyun }
227*4882a593Smuzhiyun 
gsl_ts_write(struct i2c_client * client,u8 addr,u8 * pdata,int datalen)228*4882a593Smuzhiyun static int gsl_ts_write(struct i2c_client *client, u8 addr, u8 *pdata, int datalen)
229*4882a593Smuzhiyun {
230*4882a593Smuzhiyun 	int ret = 0;
231*4882a593Smuzhiyun 	u8 tmp_buf[128];
232*4882a593Smuzhiyun 	unsigned int bytelen = 0;
233*4882a593Smuzhiyun 	if (datalen > 125) {
234*4882a593Smuzhiyun 		printk("%s too big datalen = %d!\n", __func__, datalen);
235*4882a593Smuzhiyun 		return -1;
236*4882a593Smuzhiyun 	}
237*4882a593Smuzhiyun 
238*4882a593Smuzhiyun 	tmp_buf[0] = addr;
239*4882a593Smuzhiyun 	bytelen++;
240*4882a593Smuzhiyun 
241*4882a593Smuzhiyun 	if (datalen != 0 && pdata != NULL) {
242*4882a593Smuzhiyun 		memcpy(&tmp_buf[bytelen], pdata, datalen);
243*4882a593Smuzhiyun 		bytelen += datalen;
244*4882a593Smuzhiyun 	}
245*4882a593Smuzhiyun 
246*4882a593Smuzhiyun 	ret = i2c_master_send(client, tmp_buf, bytelen);
247*4882a593Smuzhiyun 	return ret;
248*4882a593Smuzhiyun }
249*4882a593Smuzhiyun 
gsl_ts_read(struct i2c_client * client,u8 addr,u8 * pdata,unsigned int datalen)250*4882a593Smuzhiyun static int gsl_ts_read(struct i2c_client *client, u8 addr, u8 *pdata, unsigned int datalen)
251*4882a593Smuzhiyun {
252*4882a593Smuzhiyun 	int ret = 0;
253*4882a593Smuzhiyun 
254*4882a593Smuzhiyun 	if (datalen > 126) {
255*4882a593Smuzhiyun 		printk("%s too big datalen = %d!\n", __func__, datalen);
256*4882a593Smuzhiyun 		return -1;
257*4882a593Smuzhiyun 	}
258*4882a593Smuzhiyun 
259*4882a593Smuzhiyun 	ret = gsl_ts_write(client, addr, NULL, 0);
260*4882a593Smuzhiyun 	if (ret < 0) {
261*4882a593Smuzhiyun 		printk("%s set data address fail!\n", __func__);
262*4882a593Smuzhiyun 		return ret;
263*4882a593Smuzhiyun 	}
264*4882a593Smuzhiyun 
265*4882a593Smuzhiyun 	return i2c_master_recv(client, pdata, datalen);
266*4882a593Smuzhiyun }
267*4882a593Smuzhiyun 
fw2buf(u8 * buf,const u32 * fw)268*4882a593Smuzhiyun static __inline__ void fw2buf(u8 *buf, const u32 *fw)
269*4882a593Smuzhiyun {
270*4882a593Smuzhiyun 	u32 *u32_buf = (int *)buf;
271*4882a593Smuzhiyun 	*u32_buf = *fw;
272*4882a593Smuzhiyun }
273*4882a593Smuzhiyun 
gsl_load_fw(struct i2c_client * client)274*4882a593Smuzhiyun static void gsl_load_fw(struct i2c_client *client)
275*4882a593Smuzhiyun {
276*4882a593Smuzhiyun 	u8 buf[DMA_TRANS_LEN*4 + 1] = {0};
277*4882a593Smuzhiyun 	u8 send_flag = 1;
278*4882a593Smuzhiyun 	u8 *cur = buf + 1;
279*4882a593Smuzhiyun 	u32 source_line = 0;
280*4882a593Smuzhiyun 	u32 source_len;
281*4882a593Smuzhiyun 	const struct fw_data *ptr_fw;
282*4882a593Smuzhiyun 	int ret = 0;
283*4882a593Smuzhiyun 	int error_count = 0;
284*4882a593Smuzhiyun 
285*4882a593Smuzhiyun 	printk("=============gsl_load_fw start==============\n");
286*4882a593Smuzhiyun 
287*4882a593Smuzhiyun 	printk(" Enter gsl1680f \n");
288*4882a593Smuzhiyun 	ptr_fw = GSL1680F_FW;
289*4882a593Smuzhiyun 	source_len = ARRAY_SIZE(GSL1680F_FW);
290*4882a593Smuzhiyun 
291*4882a593Smuzhiyun 	for (source_line = 0; source_line < source_len; source_line++) {
292*4882a593Smuzhiyun 		/* init page trans, set the page val */
293*4882a593Smuzhiyun 		if (GSL_PAGE_REG == ptr_fw[source_line].offset) {
294*4882a593Smuzhiyun 			fw2buf(cur, &ptr_fw[source_line].val);
295*4882a593Smuzhiyun 			ret = gsl_write_interface(client, GSL_PAGE_REG, buf, 4);
296*4882a593Smuzhiyun 			if (ret != 0) {
297*4882a593Smuzhiyun 				error_count++;
298*4882a593Smuzhiyun 			}
299*4882a593Smuzhiyun 			send_flag = 1;
300*4882a593Smuzhiyun 		} else {
301*4882a593Smuzhiyun 			if (1 == send_flag % (DMA_TRANS_LEN < 0x20 ? DMA_TRANS_LEN : 0x20))
302*4882a593Smuzhiyun 				buf[0] = (u8)ptr_fw[source_line].offset;
303*4882a593Smuzhiyun 
304*4882a593Smuzhiyun 			fw2buf(cur, &ptr_fw[source_line].val);
305*4882a593Smuzhiyun 			cur += 4;
306*4882a593Smuzhiyun 
307*4882a593Smuzhiyun 			if (0 == send_flag % (DMA_TRANS_LEN < 0x20 ? DMA_TRANS_LEN : 0x20)) {
308*4882a593Smuzhiyun 				ret = gsl_write_interface(client, buf[0], buf, cur - buf - 1);
309*4882a593Smuzhiyun 				if (ret != 0) {
310*4882a593Smuzhiyun 					error_count++;
311*4882a593Smuzhiyun 				}
312*4882a593Smuzhiyun 
313*4882a593Smuzhiyun 				cur = buf + 1;
314*4882a593Smuzhiyun 			}
315*4882a593Smuzhiyun 			if (error_count >= 20)
316*4882a593Smuzhiyun 				return;
317*4882a593Smuzhiyun 			send_flag++;
318*4882a593Smuzhiyun 		}
319*4882a593Smuzhiyun 	}
320*4882a593Smuzhiyun 
321*4882a593Smuzhiyun 	printk("=============gsl_load_fw end==============\n");
322*4882a593Smuzhiyun 
323*4882a593Smuzhiyun }
324*4882a593Smuzhiyun 
test_i2c(struct i2c_client * client)325*4882a593Smuzhiyun static int test_i2c(struct i2c_client *client)
326*4882a593Smuzhiyun {
327*4882a593Smuzhiyun 	u8 read_buf = 0;
328*4882a593Smuzhiyun 	u8 write_buf = 0x12;
329*4882a593Smuzhiyun 	int ret, rc = 1;
330*4882a593Smuzhiyun 
331*4882a593Smuzhiyun 	ret = gsl_ts_read(client, 0xf0, &read_buf, sizeof(read_buf));
332*4882a593Smuzhiyun 	if  (ret  < 0)
333*4882a593Smuzhiyun 		rc--;
334*4882a593Smuzhiyun 	else
335*4882a593Smuzhiyun 		printk("I read reg 0xf0 is %x\n", read_buf);
336*4882a593Smuzhiyun 
337*4882a593Smuzhiyun 	msleep(2);
338*4882a593Smuzhiyun 	ret = gsl_ts_write(client, 0xf0, &write_buf, sizeof(write_buf));
339*4882a593Smuzhiyun 	if (ret >= 0)
340*4882a593Smuzhiyun 		printk("I write reg 0xf0 0x12\n");
341*4882a593Smuzhiyun 
342*4882a593Smuzhiyun 	msleep(2);
343*4882a593Smuzhiyun 	ret = gsl_ts_read(client, 0xf0, &read_buf, sizeof(read_buf));
344*4882a593Smuzhiyun 	if (ret < 0)
345*4882a593Smuzhiyun 		rc--;
346*4882a593Smuzhiyun 	else
347*4882a593Smuzhiyun 		printk("I read reg 0xf0 is 0x%x\n", read_buf);
348*4882a593Smuzhiyun 
349*4882a593Smuzhiyun 	return rc;
350*4882a593Smuzhiyun }
351*4882a593Smuzhiyun 
startup_chip(struct i2c_client * client)352*4882a593Smuzhiyun static void startup_chip(struct i2c_client *client)
353*4882a593Smuzhiyun {
354*4882a593Smuzhiyun 	u8 tmp = 0x00;
355*4882a593Smuzhiyun 	if (2 == is_noid_version) {
356*4882a593Smuzhiyun 		gsl_DataInit(gsl_config_data_id_1680f);
357*4882a593Smuzhiyun 	}
358*4882a593Smuzhiyun 
359*4882a593Smuzhiyun 	if (1 == is_noid_version) {
360*4882a593Smuzhiyun 		gsl_DataInit(gsl_config_data_id);
361*4882a593Smuzhiyun 	}
362*4882a593Smuzhiyun 
363*4882a593Smuzhiyun 	gsl_ts_write(client, 0xe0, &tmp, 1);
364*4882a593Smuzhiyun 	msleep(10);
365*4882a593Smuzhiyun }
366*4882a593Smuzhiyun 
reset_chip(struct i2c_client * client)367*4882a593Smuzhiyun static void reset_chip(struct i2c_client *client)
368*4882a593Smuzhiyun {
369*4882a593Smuzhiyun 	u8 tmp = 0x88;
370*4882a593Smuzhiyun 	u8 buf[4] = {0x00};
371*4882a593Smuzhiyun 
372*4882a593Smuzhiyun 	gsl_ts_write(client, 0xe0, &tmp, sizeof(tmp));
373*4882a593Smuzhiyun 	msleep(20);
374*4882a593Smuzhiyun 	tmp = 0x04;
375*4882a593Smuzhiyun 	gsl_ts_write(client, 0xe4, &tmp, sizeof(tmp));
376*4882a593Smuzhiyun 	msleep(10);
377*4882a593Smuzhiyun 
378*4882a593Smuzhiyun 	gsl_ts_write(client, 0xbc, buf, sizeof(buf));
379*4882a593Smuzhiyun 	msleep(10);
380*4882a593Smuzhiyun }
381*4882a593Smuzhiyun 
clr_reg(struct i2c_client * client)382*4882a593Smuzhiyun static void clr_reg(struct i2c_client *client)
383*4882a593Smuzhiyun {
384*4882a593Smuzhiyun 	u8 write_buf[4] = {0};
385*4882a593Smuzhiyun 
386*4882a593Smuzhiyun 	write_buf[0] = 0x88;
387*4882a593Smuzhiyun 	gsl_ts_write(client, 0xe0, &write_buf[0], 1);
388*4882a593Smuzhiyun 	msleep(20);
389*4882a593Smuzhiyun 	write_buf[0] = 0x03;  /*jzx@20131109 for old tp ic control.*/
390*4882a593Smuzhiyun 	gsl_ts_write(client, 0x80, &write_buf[0], 1);
391*4882a593Smuzhiyun 	msleep(5);
392*4882a593Smuzhiyun 	write_buf[0] = 0x04;
393*4882a593Smuzhiyun 	gsl_ts_write(client, 0xe4, &write_buf[0], 1);
394*4882a593Smuzhiyun 	msleep(5);
395*4882a593Smuzhiyun 	write_buf[0] = 0x00;
396*4882a593Smuzhiyun 	gsl_ts_write(client, 0xe0, &write_buf[0], 1);
397*4882a593Smuzhiyun 	msleep(20);
398*4882a593Smuzhiyun }
399*4882a593Smuzhiyun 
init_chip(struct i2c_client * client)400*4882a593Smuzhiyun static void init_chip(struct i2c_client *client)
401*4882a593Smuzhiyun {
402*4882a593Smuzhiyun 	int rc;
403*4882a593Smuzhiyun 	gslX680_shutdown_low();
404*4882a593Smuzhiyun 	msleep(20);
405*4882a593Smuzhiyun 	gslX680_shutdown_high();
406*4882a593Smuzhiyun 	msleep(20);
407*4882a593Smuzhiyun 
408*4882a593Smuzhiyun 	rc = test_i2c(client);
409*4882a593Smuzhiyun 	if (rc < 0) {
410*4882a593Smuzhiyun 		printk("------ GslX680 test_i2c error, now touch id is Zet62xx ------\n");
411*4882a593Smuzhiyun 		is_zet62xx = 1;
412*4882a593Smuzhiyun 		return;
413*4882a593Smuzhiyun 	}
414*4882a593Smuzhiyun 	clr_reg(client);
415*4882a593Smuzhiyun 	reset_chip(client);
416*4882a593Smuzhiyun 	reset_chip(client);
417*4882a593Smuzhiyun 	clr_reg(client);
418*4882a593Smuzhiyun 	reset_chip(client);
419*4882a593Smuzhiyun 	gsl_load_fw(client);
420*4882a593Smuzhiyun 	startup_chip(client);
421*4882a593Smuzhiyun 	reset_chip(client);
422*4882a593Smuzhiyun 	startup_chip(client);
423*4882a593Smuzhiyun }
424*4882a593Smuzhiyun 
check_mem_data(struct i2c_client * client)425*4882a593Smuzhiyun static void check_mem_data(struct i2c_client *client)
426*4882a593Smuzhiyun {
427*4882a593Smuzhiyun 	u8 read_buf[4]  = {0};
428*4882a593Smuzhiyun 
429*4882a593Smuzhiyun 	msleep(30);
430*4882a593Smuzhiyun 	gsl_ts_read(client, 0xb0, read_buf, sizeof(read_buf));
431*4882a593Smuzhiyun 
432*4882a593Smuzhiyun 	if (read_buf[3] != 0x5a || read_buf[2] != 0x5a || read_buf[1] != 0x5a || read_buf[0] != 0x5a) {
433*4882a593Smuzhiyun 		print_info("#########check mem read 0xb0 = %x %x %x %x #########\n", read_buf[3], read_buf[2], read_buf[1], read_buf[0]);
434*4882a593Smuzhiyun 		init_chip(client);
435*4882a593Smuzhiyun 	}
436*4882a593Smuzhiyun }
437*4882a593Smuzhiyun #ifdef TPD_PROC_DEBUG
char_to_int(char ch)438*4882a593Smuzhiyun static int char_to_int(char ch)
439*4882a593Smuzhiyun {
440*4882a593Smuzhiyun 	if (ch >= '0' && ch <= '9')
441*4882a593Smuzhiyun 		return (ch - '0');
442*4882a593Smuzhiyun 	else
443*4882a593Smuzhiyun 		return (ch - 'a' + 10);
444*4882a593Smuzhiyun }
445*4882a593Smuzhiyun 
446*4882a593Smuzhiyun /* static int gsl_config_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data) */
gsl_config_read_proc(struct seq_file * m,void * v)447*4882a593Smuzhiyun static int gsl_config_read_proc(struct seq_file *m, void *v)
448*4882a593Smuzhiyun {
449*4882a593Smuzhiyun 	/* char *ptr = page; */
450*4882a593Smuzhiyun 	char temp_data[5] = {0};
451*4882a593Smuzhiyun 	unsigned int tmp = 0;
452*4882a593Smuzhiyun 
453*4882a593Smuzhiyun 	if ('v' == gsl_read[0] && 's' == gsl_read[1]) {
454*4882a593Smuzhiyun #ifdef GSL_NOID_VERSION
455*4882a593Smuzhiyun 		tmp = gsl_version_id();
456*4882a593Smuzhiyun #else
457*4882a593Smuzhiyun 		tmp = 0x20121215;
458*4882a593Smuzhiyun #endif
459*4882a593Smuzhiyun 		/* ptr += sprintf(ptr,"version:%x\n",tmp); */
460*4882a593Smuzhiyun 		seq_printf(m, "version:%x\n", tmp);
461*4882a593Smuzhiyun 	} else if ('r' == gsl_read[0] && 'e' == gsl_read[1]) {
462*4882a593Smuzhiyun 		if ('i' == gsl_read[3]) {
463*4882a593Smuzhiyun #ifdef GSL_NOID_VERSION
464*4882a593Smuzhiyun 			tmp = (gsl_data_proc[5] << 8) | gsl_data_proc[4];
465*4882a593Smuzhiyun 			/*ptr +=sprintf(ptr,"gsl_config_data_id[%d] = ",tmp);*/
466*4882a593Smuzhiyun 			seq_printf(m, "gsl_config_data_id[%d] = ", tmp);
467*4882a593Smuzhiyun 			if (tmp >= 0 && tmp < 512) {
468*4882a593Smuzhiyun 					/* ptr +=sprintf(ptr,"%d\n",gsl_config_data_id[tmp]); */
469*4882a593Smuzhiyun 					seq_printf(m, "%d\n", gsl_config_data_id[tmp]);
470*4882a593Smuzhiyun 			}
471*4882a593Smuzhiyun #endif
472*4882a593Smuzhiyun 		} else {
473*4882a593Smuzhiyun 			i2c_smbus_write_i2c_block_data(gsl_client, 0xf0, 4, &gsl_data_proc[4]);
474*4882a593Smuzhiyun 			if (gsl_data_proc[0] < 0x80)
475*4882a593Smuzhiyun 				i2c_smbus_read_i2c_block_data(gsl_client, gsl_data_proc[0], 4, temp_data);
476*4882a593Smuzhiyun 			i2c_smbus_read_i2c_block_data(gsl_client, gsl_data_proc[0], 4, temp_data);
477*4882a593Smuzhiyun 			/*
478*4882a593Smuzhiyun 			ptr +=sprintf(ptr,"offset : {0x%02x,0x",gsl_data_proc[0]);
479*4882a593Smuzhiyun 			ptr +=sprintf(ptr,"%02x",temp_data[3]);
480*4882a593Smuzhiyun 			ptr +=sprintf(ptr,"%02x",temp_data[2]);
481*4882a593Smuzhiyun 			ptr +=sprintf(ptr,"%02x",temp_data[1]);
482*4882a593Smuzhiyun 			ptr +=sprintf(ptr,"%02x};\n",temp_data[0]); */
483*4882a593Smuzhiyun 			seq_printf(m, "offset : {0x%02x,0x", gsl_data_proc[0]);
484*4882a593Smuzhiyun 			seq_printf(m, "%02x", temp_data[3]);
485*4882a593Smuzhiyun 			seq_printf(m, "%02x", temp_data[2]);
486*4882a593Smuzhiyun 			seq_printf(m, "%02x", temp_data[1]);
487*4882a593Smuzhiyun 			seq_printf(m, "%02x};\n", temp_data[0]);
488*4882a593Smuzhiyun 		}
489*4882a593Smuzhiyun 	}
490*4882a593Smuzhiyun 	/* *eof = 1;
491*4882a593Smuzhiyun 	return (ptr - page); */
492*4882a593Smuzhiyun 	return 0;
493*4882a593Smuzhiyun }
gsl_config_write_proc(struct file * file,const char * buffer,size_t count,loff_t * data)494*4882a593Smuzhiyun static int gsl_config_write_proc(struct file *file, const char *buffer, size_t count, loff_t *data)
495*4882a593Smuzhiyun {
496*4882a593Smuzhiyun 	u8 buf[8] = {0};
497*4882a593Smuzhiyun 	char temp_buf[CONFIG_LEN];
498*4882a593Smuzhiyun 	char *path_buf;
499*4882a593Smuzhiyun 	int tmp = 0;
500*4882a593Smuzhiyun 	int tmp1 = 0;
501*4882a593Smuzhiyun 	print_info("[tp-gsl][%s] \n", __func__);
502*4882a593Smuzhiyun 	if (count > 512) {
503*4882a593Smuzhiyun 		print_info("size not match [%d:%ld]\n", CONFIG_LEN, count);
504*4882a593Smuzhiyun 		return -EFAULT;
505*4882a593Smuzhiyun 	}
506*4882a593Smuzhiyun 	path_buf = kzalloc(count, GFP_KERNEL);
507*4882a593Smuzhiyun 	if (!path_buf) {
508*4882a593Smuzhiyun 		printk("alloc path_buf memory error \n");
509*4882a593Smuzhiyun 	}
510*4882a593Smuzhiyun 	if (copy_from_user(path_buf, buffer, count)) {
511*4882a593Smuzhiyun 		print_info("copy from user fail\n");
512*4882a593Smuzhiyun 		goto exit_write_proc_out;
513*4882a593Smuzhiyun 	}
514*4882a593Smuzhiyun 	memcpy(temp_buf, path_buf, (count < CONFIG_LEN ? count : CONFIG_LEN));
515*4882a593Smuzhiyun 	print_info("[tp-gsl][%s][%s]\n", __func__, temp_buf);
516*4882a593Smuzhiyun 
517*4882a593Smuzhiyun 	buf[3] = char_to_int(temp_buf[14]) << 4 | char_to_int(temp_buf[15]);
518*4882a593Smuzhiyun 	buf[2] = char_to_int(temp_buf[16]) << 4 | char_to_int(temp_buf[17]);
519*4882a593Smuzhiyun 	buf[1] = char_to_int(temp_buf[18]) << 4 | char_to_int(temp_buf[19]);
520*4882a593Smuzhiyun 	buf[0] = char_to_int(temp_buf[20]) << 4 | char_to_int(temp_buf[21]);
521*4882a593Smuzhiyun 
522*4882a593Smuzhiyun 	buf[7] = char_to_int(temp_buf[5]) << 4 | char_to_int(temp_buf[6]);
523*4882a593Smuzhiyun 	buf[6] = char_to_int(temp_buf[7]) << 4 | char_to_int(temp_buf[8]);
524*4882a593Smuzhiyun 	buf[5] = char_to_int(temp_buf[9]) << 4 | char_to_int(temp_buf[10]);
525*4882a593Smuzhiyun 	buf[4] = char_to_int(temp_buf[11]) << 4 | char_to_int(temp_buf[12]);
526*4882a593Smuzhiyun 	if ('v' == temp_buf[0] && 's' == temp_buf[1]) {
527*4882a593Smuzhiyun 		memcpy(gsl_read, temp_buf, 4);
528*4882a593Smuzhiyun 		printk("gsl version\n");
529*4882a593Smuzhiyun 	} else if ('s' == temp_buf[0] && 't' == temp_buf[1]) {
530*4882a593Smuzhiyun 		gsl_proc_flag = 1;
531*4882a593Smuzhiyun 		reset_chip(gsl_client);
532*4882a593Smuzhiyun 	} else if ('e' == temp_buf[0] && 'n' == temp_buf[1]) {
533*4882a593Smuzhiyun 		msleep(20);
534*4882a593Smuzhiyun 		reset_chip(gsl_client);
535*4882a593Smuzhiyun 		startup_chip(gsl_client);
536*4882a593Smuzhiyun 	#ifdef GSL_NOID_VERSION
537*4882a593Smuzhiyun 		gsl_DataInit(gsl_config_data_id);
538*4882a593Smuzhiyun 	#endif
539*4882a593Smuzhiyun 		gsl_proc_flag = 0;
540*4882a593Smuzhiyun 	} else if ('r' == temp_buf[0] && 'e' == temp_buf[1]) {
541*4882a593Smuzhiyun 		memcpy(gsl_read, temp_buf, 4);
542*4882a593Smuzhiyun 		memcpy(gsl_data_proc, buf, 8);
543*4882a593Smuzhiyun 	} else if ('w' == temp_buf[0] && 'r' == temp_buf[1]) {
544*4882a593Smuzhiyun 		gsl_ts_write(gsl_client, buf[4], buf, 4);
545*4882a593Smuzhiyun 	}
546*4882a593Smuzhiyun #ifdef GSL_NOID_VERSION
547*4882a593Smuzhiyun 	else if ('i' == temp_buf[0] && 'd' == temp_buf[1]) {
548*4882a593Smuzhiyun 		tmp1 = (buf[7] << 24) | (buf[6] << 16) | (buf[5] << 8) | buf[4];
549*4882a593Smuzhiyun 		tmp = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
550*4882a593Smuzhiyun 
551*4882a593Smuzhiyun 		if (tmp1 >= 0 && tmp1 < 512) {
552*4882a593Smuzhiyun 			gsl_config_data_id[tmp1] = tmp;
553*4882a593Smuzhiyun 		}
554*4882a593Smuzhiyun 	}
555*4882a593Smuzhiyun #endif
556*4882a593Smuzhiyun 
557*4882a593Smuzhiyun exit_write_proc_out:
558*4882a593Smuzhiyun 	kfree(path_buf);
559*4882a593Smuzhiyun 	return count;
560*4882a593Smuzhiyun }
561*4882a593Smuzhiyun 
gsl_server_list_open(struct inode * inode,struct file * file)562*4882a593Smuzhiyun static int gsl_server_list_open(struct inode *inode, struct file *file)
563*4882a593Smuzhiyun {
564*4882a593Smuzhiyun 	return single_open(file, gsl_config_read_proc, NULL);
565*4882a593Smuzhiyun }
566*4882a593Smuzhiyun 
567*4882a593Smuzhiyun static const struct file_operations gsl_seq_fops = {
568*4882a593Smuzhiyun 	.open = gsl_server_list_open,
569*4882a593Smuzhiyun 	.read = seq_read,
570*4882a593Smuzhiyun 	.release = single_release,
571*4882a593Smuzhiyun 	.write = gsl_config_write_proc,
572*4882a593Smuzhiyun 	.owner = THIS_MODULE,
573*4882a593Smuzhiyun };
574*4882a593Smuzhiyun #endif
575*4882a593Smuzhiyun /* Will@20130514 - */
576*4882a593Smuzhiyun 
577*4882a593Smuzhiyun #ifdef FILTER_POINT
filter_point(u16 x,u16 y,u8 id)578*4882a593Smuzhiyun static void filter_point(u16 x, u16 y, u8 id)
579*4882a593Smuzhiyun {
580*4882a593Smuzhiyun 	u16 x_err = 0;
581*4882a593Smuzhiyun 	u16 y_err = 0;
582*4882a593Smuzhiyun 	u16 filter_step_x = 0, filter_step_y = 0;
583*4882a593Smuzhiyun 
584*4882a593Smuzhiyun 	id_sign[id] = id_sign[id] + 1;
585*4882a593Smuzhiyun 	if (id_sign[id] == 1) {
586*4882a593Smuzhiyun 		x_old[id] = x;
587*4882a593Smuzhiyun 		y_old[id] = y;
588*4882a593Smuzhiyun 	}
589*4882a593Smuzhiyun 
590*4882a593Smuzhiyun 	x_err = x > x_old[id] ? (x - x_old[id]) : (x_old[id] - x);
591*4882a593Smuzhiyun 	y_err = y > y_old[id] ? (y - y_old[id]) : (y_old[id] - y);
592*4882a593Smuzhiyun 
593*4882a593Smuzhiyun 	if ((x_err > FILTER_MAX && y_err > FILTER_MAX / 3) || (x_err > FILTER_MAX / 3 && y_err > FILTER_MAX)) {
594*4882a593Smuzhiyun 		filter_step_x = x_err;
595*4882a593Smuzhiyun 		filter_step_y = y_err;
596*4882a593Smuzhiyun 	} else {
597*4882a593Smuzhiyun 		if (x_err > FILTER_MAX)
598*4882a593Smuzhiyun 			filter_step_x = x_err;
599*4882a593Smuzhiyun 		if (y_err > FILTER_MAX)
600*4882a593Smuzhiyun 			filter_step_y = y_err;
601*4882a593Smuzhiyun 	}
602*4882a593Smuzhiyun 
603*4882a593Smuzhiyun 	if (x_err <= 2 * FILTER_MAX && y_err <= 2 * FILTER_MAX) {
604*4882a593Smuzhiyun 		filter_step_x >>= 2;
605*4882a593Smuzhiyun 		filter_step_y >>= 2;
606*4882a593Smuzhiyun 	} else if (x_err <= 3 * FILTER_MAX && y_err <= 3 * FILTER_MAX) {
607*4882a593Smuzhiyun 		filter_step_x >>= 1;
608*4882a593Smuzhiyun 		filter_step_y >>= 1;
609*4882a593Smuzhiyun 	} else if (x_err <= 4 * FILTER_MAX && y_err <= 4 * FILTER_MAX) {
610*4882a593Smuzhiyun 		filter_step_x = filter_step_x * 3 / 4;
611*4882a593Smuzhiyun 		filter_step_y = filter_step_y * 3 / 4;
612*4882a593Smuzhiyun 	}
613*4882a593Smuzhiyun 
614*4882a593Smuzhiyun 	x_new = x > x_old[id] ? (x_old[id] + filter_step_x) : (x_old[id] - filter_step_x);
615*4882a593Smuzhiyun 	y_new = y > y_old[id] ? (y_old[id] + filter_step_y) : (y_old[id] - filter_step_y);
616*4882a593Smuzhiyun 
617*4882a593Smuzhiyun 	x_old[id] = x_new;
618*4882a593Smuzhiyun 	y_old[id] = y_new;
619*4882a593Smuzhiyun }
620*4882a593Smuzhiyun #else
record_point(u16 x,u16 y,u8 id)621*4882a593Smuzhiyun static void record_point(u16 x, u16 y, u8 id)
622*4882a593Smuzhiyun {
623*4882a593Smuzhiyun 	u16 x_err = 0;
624*4882a593Smuzhiyun 	u16 y_err = 0;
625*4882a593Smuzhiyun 
626*4882a593Smuzhiyun 	id_sign[id] = id_sign[id] + 1;
627*4882a593Smuzhiyun 
628*4882a593Smuzhiyun 	if (id_sign[id] == 1) {
629*4882a593Smuzhiyun 		x_old[id] = x;
630*4882a593Smuzhiyun 		y_old[id] = y;
631*4882a593Smuzhiyun 	}
632*4882a593Smuzhiyun 
633*4882a593Smuzhiyun 	x = (x_old[id] + x) / 2;
634*4882a593Smuzhiyun 	y = (y_old[id] + y) / 2;
635*4882a593Smuzhiyun 
636*4882a593Smuzhiyun 	if (x > x_old[id]) {
637*4882a593Smuzhiyun 		x_err = x - x_old[id];
638*4882a593Smuzhiyun 	} else {
639*4882a593Smuzhiyun 		x_err = x_old[id] - x;
640*4882a593Smuzhiyun 	}
641*4882a593Smuzhiyun 
642*4882a593Smuzhiyun 	if (y > y_old[id]) {
643*4882a593Smuzhiyun 		y_err = y - y_old[id];
644*4882a593Smuzhiyun 	} else {
645*4882a593Smuzhiyun 		y_err = y_old[id] - y;
646*4882a593Smuzhiyun 	}
647*4882a593Smuzhiyun 
648*4882a593Smuzhiyun 	if ((x_err > 3 && y_err > 1) || (x_err > 1 && y_err > 3)) {
649*4882a593Smuzhiyun 		x_new = x;
650*4882a593Smuzhiyun 		x_old[id] = x;
651*4882a593Smuzhiyun 		y_new = y;
652*4882a593Smuzhiyun 		y_old[id] = y;
653*4882a593Smuzhiyun 	} else {
654*4882a593Smuzhiyun 		if (x_err > 3) {
655*4882a593Smuzhiyun 			x_new = x;
656*4882a593Smuzhiyun 			x_old[id] = x;
657*4882a593Smuzhiyun 		} else
658*4882a593Smuzhiyun 			x_new = x_old[id];
659*4882a593Smuzhiyun 		if (y_err > 3) {
660*4882a593Smuzhiyun 			y_new = y;
661*4882a593Smuzhiyun 			y_old[id] = y;
662*4882a593Smuzhiyun 		} else
663*4882a593Smuzhiyun 			y_new = y_old[id];
664*4882a593Smuzhiyun 	}
665*4882a593Smuzhiyun 
666*4882a593Smuzhiyun 	if (id_sign[id] == 1) {
667*4882a593Smuzhiyun 		x_new = x_old[id];
668*4882a593Smuzhiyun 		y_new = y_old[id];
669*4882a593Smuzhiyun 	}
670*4882a593Smuzhiyun }
671*4882a593Smuzhiyun #endif
672*4882a593Smuzhiyun 
673*4882a593Smuzhiyun #ifdef HAVE_TOUCH_KEY
report_key(struct gsl_ts * ts,u16 x,u16 y)674*4882a593Smuzhiyun static void report_key(struct gsl_ts *ts, u16 x, u16 y)
675*4882a593Smuzhiyun {
676*4882a593Smuzhiyun 	u16 i = 0;
677*4882a593Smuzhiyun 
678*4882a593Smuzhiyun 	for (i = 0; i < MAX_KEY_NUM; i++) {
679*4882a593Smuzhiyun 		if ((gsl_key_data[i].x_min < x) && (x < gsl_key_data[i].x_max) && (gsl_key_data[i].y_min < y) && (y < gsl_key_data[i].y_max)) {
680*4882a593Smuzhiyun 			key = gsl_key_data[i].key;
681*4882a593Smuzhiyun 			input_report_key(ts->input, key, 1);
682*4882a593Smuzhiyun 			input_sync(ts->input);
683*4882a593Smuzhiyun 			key_state_flag = 1;
684*4882a593Smuzhiyun 			break;
685*4882a593Smuzhiyun 		}
686*4882a593Smuzhiyun 	}
687*4882a593Smuzhiyun }
688*4882a593Smuzhiyun #endif
689*4882a593Smuzhiyun 
report_data(struct gsl_ts * ts,u16 x,u16 y,u8 pressure,u8 id)690*4882a593Smuzhiyun static void report_data(struct gsl_ts *ts, u16 x, u16 y, u8 pressure, u8 id)
691*4882a593Smuzhiyun {
692*4882a593Smuzhiyun 	if (revert_xy)
693*4882a593Smuzhiyun 		swap(x, y);
694*4882a593Smuzhiyun 	if (revert_x)
695*4882a593Smuzhiyun 		x = ts->screen_max_x - x;
696*4882a593Smuzhiyun 	if (revert_y)
697*4882a593Smuzhiyun 		y = ts->screen_max_y - y;
698*4882a593Smuzhiyun 
699*4882a593Smuzhiyun 	print_info("#####id=%d,x=%d,y=%d######\n", id, x, y);
700*4882a593Smuzhiyun 	print_info("#####revert_xy=%d,revert_x=%d,revert_y=%d######\n", revert_xy, revert_x, revert_y);
701*4882a593Smuzhiyun 
702*4882a593Smuzhiyun 	if (x > ts->screen_max_x || y > ts->screen_max_y) {
703*4882a593Smuzhiyun 	#ifdef HAVE_TOUCH_KEY
704*4882a593Smuzhiyun 		report_key(ts, x, y);
705*4882a593Smuzhiyun 	#endif
706*4882a593Smuzhiyun 		return;
707*4882a593Smuzhiyun 	}
708*4882a593Smuzhiyun #ifdef BND_GESTURE
709*4882a593Smuzhiyun 	print_info("\n gsl_lcd_flag = %d ---- gsl_gesture_flag = %d \n\n", gsl_lcd_flag, gsl_gesture_flag);
710*4882a593Smuzhiyun 	if (1 == gsl_lcd_flag && 1 == gsl_gesture_flag) {
711*4882a593Smuzhiyun 		print_info("auto wake up lcd\n");
712*4882a593Smuzhiyun 		rk_send_wakeup_key();
713*4882a593Smuzhiyun 	} else {
714*4882a593Smuzhiyun 		gsl_gesture_flag = 0;
715*4882a593Smuzhiyun 	}
716*4882a593Smuzhiyun #endif
717*4882a593Smuzhiyun #ifdef REPORT_DATA_ANDROID_4_0
718*4882a593Smuzhiyun 	input_mt_slot(ts->input, id);
719*4882a593Smuzhiyun 	input_report_abs(ts->input, ABS_MT_TRACKING_ID, id);
720*4882a593Smuzhiyun 	input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, pressure);
721*4882a593Smuzhiyun 	input_report_abs(ts->input, ABS_MT_POSITION_X, x);
722*4882a593Smuzhiyun 	input_report_abs(ts->input, ABS_MT_POSITION_Y, y);
723*4882a593Smuzhiyun 	input_report_abs(ts->input, ABS_MT_WIDTH_MAJOR, 1);
724*4882a593Smuzhiyun #else
725*4882a593Smuzhiyun 	input_report_abs(ts->input, ABS_MT_TRACKING_ID, id);
726*4882a593Smuzhiyun 	input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, pressure);
727*4882a593Smuzhiyun 	input_report_abs(ts->input, ABS_MT_POSITION_X, x);
728*4882a593Smuzhiyun 	input_report_abs(ts->input, ABS_MT_POSITION_Y, y);
729*4882a593Smuzhiyun 	input_report_abs(ts->input, ABS_MT_WIDTH_MAJOR, 1);
730*4882a593Smuzhiyun 	input_mt_sync(ts->input);
731*4882a593Smuzhiyun #endif
732*4882a593Smuzhiyun }
733*4882a593Smuzhiyun 
gslX680_ts_worker(struct work_struct * work)734*4882a593Smuzhiyun static void gslX680_ts_worker(struct work_struct *work)
735*4882a593Smuzhiyun {
736*4882a593Smuzhiyun 
737*4882a593Smuzhiyun 	int rc, i;
738*4882a593Smuzhiyun 	u8 id, touches/*, read_buf[4] = {0}*/;
739*4882a593Smuzhiyun 	u16 x, y;
740*4882a593Smuzhiyun 
741*4882a593Smuzhiyun 	struct gsl_touch_info cinfo = { { 0 } };
742*4882a593Smuzhiyun 	u32 tmp1 = 0;
743*4882a593Smuzhiyun 	u8 buf[4] = {0};
744*4882a593Smuzhiyun 
745*4882a593Smuzhiyun 	struct gsl_ts *ts = container_of(work, struct gsl_ts, work);
746*4882a593Smuzhiyun 
747*4882a593Smuzhiyun 	print_info("=====gslX680_ts_worker=====\n");
748*4882a593Smuzhiyun 
749*4882a593Smuzhiyun #ifdef TPD_PROC_DEBUG
750*4882a593Smuzhiyun 	if (gsl_proc_flag == 1)
751*4882a593Smuzhiyun 		goto schedule;
752*4882a593Smuzhiyun #endif
753*4882a593Smuzhiyun #ifdef GSL_MONITOR
754*4882a593Smuzhiyun 	if (i2c_lock_flag != 0)
755*4882a593Smuzhiyun 		goto i2c_lock_schedule;
756*4882a593Smuzhiyun 	else
757*4882a593Smuzhiyun 		i2c_lock_flag = 1;
758*4882a593Smuzhiyun #endif
759*4882a593Smuzhiyun 
760*4882a593Smuzhiyun 	rc = gsl_ts_read(ts->client, 0x80, ts->touch_data, ts->dd->data_size);
761*4882a593Smuzhiyun 	if (rc < 0) {
762*4882a593Smuzhiyun 		dev_err(&ts->client->dev, "read failed\n");
763*4882a593Smuzhiyun 		goto schedule;
764*4882a593Smuzhiyun 	}
765*4882a593Smuzhiyun 
766*4882a593Smuzhiyun 	touches = ts->touch_data[ts->dd->touch_index];
767*4882a593Smuzhiyun 	print_info("-----touches: %d -----\n", touches);
768*4882a593Smuzhiyun 
769*4882a593Smuzhiyun 	if (is_noid_version) {
770*4882a593Smuzhiyun 		cinfo.finger_num = touches;
771*4882a593Smuzhiyun 		print_info("tp-gsl  finger_num = %d\n", cinfo.finger_num);
772*4882a593Smuzhiyun 		for (i = 0; i < (touches < MAX_CONTACTS ? touches : MAX_CONTACTS); i++) {
773*4882a593Smuzhiyun 			cinfo.x[i] = join_bytes((ts->touch_data[ts->dd->x_index  + 4 * i + 1] & 0xf),
774*4882a593Smuzhiyun 					ts->touch_data[ts->dd->x_index + 4 * i]);
775*4882a593Smuzhiyun 			cinfo.y[i] = join_bytes(ts->touch_data[ts->dd->y_index + 4 * i + 1],
776*4882a593Smuzhiyun 					ts->touch_data[ts->dd->y_index + 4 * i]);
777*4882a593Smuzhiyun 			print_info("tp-gsl  x = %d y = %d \n", cinfo.x[i], cinfo.y[i]);
778*4882a593Smuzhiyun 		}
779*4882a593Smuzhiyun 		cinfo.finger_num = (ts->touch_data[3] << 24) | (ts->touch_data[2] << 16)
780*4882a593Smuzhiyun 			| (ts->touch_data[1] << 8) | (ts->touch_data[0]);
781*4882a593Smuzhiyun 		gsl_alg_id_main(&cinfo);
782*4882a593Smuzhiyun 		tmp1 = gsl_mask_tiaoping();
783*4882a593Smuzhiyun 		print_info("[tp-gsl] tmp1=%x\n", tmp1);
784*4882a593Smuzhiyun 		if (tmp1 > 0 && tmp1 < 0xffffffff) {
785*4882a593Smuzhiyun 			buf[0] = 0xa;
786*4882a593Smuzhiyun 			buf[1] = 0;
787*4882a593Smuzhiyun 			buf[2] = 0;
788*4882a593Smuzhiyun 			buf[3] = 0;
789*4882a593Smuzhiyun 			gsl_ts_write(gsl_client, 0xf0, buf, 4);
790*4882a593Smuzhiyun 			buf[0] = (u8)(tmp1 & 0xff);
791*4882a593Smuzhiyun 			buf[1] = (u8)((tmp1>>8) & 0xff);
792*4882a593Smuzhiyun 			buf[2] = (u8)((tmp1>>16) & 0xff);
793*4882a593Smuzhiyun 			buf[3] = (u8)((tmp1>>24) & 0xff);
794*4882a593Smuzhiyun 			printk("tmp1=%08x,buf[0]=%02x,buf[1]=%02x,buf[2]=%02x,buf[3]=%02x\n",
795*4882a593Smuzhiyun 				tmp1, buf[0], buf[1], buf[2], buf[3]);
796*4882a593Smuzhiyun 			gsl_ts_write(gsl_client, 0x8, buf, 4);
797*4882a593Smuzhiyun 		}
798*4882a593Smuzhiyun 		touches = cinfo.finger_num;
799*4882a593Smuzhiyun 	}
800*4882a593Smuzhiyun 
801*4882a593Smuzhiyun 	for (i = 1; i <= MAX_CONTACTS; i++) {
802*4882a593Smuzhiyun 		if (touches == 0)
803*4882a593Smuzhiyun 			id_sign[i] = 0;
804*4882a593Smuzhiyun 		id_state_flag[i] = 0;
805*4882a593Smuzhiyun 	}
806*4882a593Smuzhiyun 	for (i = 0; i < (touches > MAX_FINGERS ? MAX_FINGERS : touches); i++) {
807*4882a593Smuzhiyun 		if (is_noid_version) {
808*4882a593Smuzhiyun 			id = cinfo.id[i];
809*4882a593Smuzhiyun 			x =  cinfo.x[i];
810*4882a593Smuzhiyun 			y =  cinfo.y[i];
811*4882a593Smuzhiyun 		} else {
812*4882a593Smuzhiyun 			x = join_bytes((ts->touch_data[ts->dd->x_index  + 4 * i + 1] & 0xf),
813*4882a593Smuzhiyun 					ts->touch_data[ts->dd->x_index + 4 * i]);
814*4882a593Smuzhiyun 			y = join_bytes(ts->touch_data[ts->dd->y_index + 4 * i + 1],
815*4882a593Smuzhiyun 					ts->touch_data[ts->dd->y_index + 4 * i]);
816*4882a593Smuzhiyun 			id = ts->touch_data[ts->dd->id_index + 4 * i] >> 4;
817*4882a593Smuzhiyun 		}
818*4882a593Smuzhiyun 
819*4882a593Smuzhiyun 		if (1 <= id && id <= MAX_CONTACTS) {
820*4882a593Smuzhiyun 		#ifdef FILTER_POINT
821*4882a593Smuzhiyun 			filter_point(x, y, id);
822*4882a593Smuzhiyun 		#else
823*4882a593Smuzhiyun 			record_point(x, y, id);
824*4882a593Smuzhiyun 		#endif
825*4882a593Smuzhiyun 			report_data(ts, x_new, y_new, 10, id);
826*4882a593Smuzhiyun 			id_state_flag[id] = 1;
827*4882a593Smuzhiyun 		}
828*4882a593Smuzhiyun 	}
829*4882a593Smuzhiyun 	for (i = 1; i <= MAX_CONTACTS; i++) {
830*4882a593Smuzhiyun 		if ((0 == touches) || ((0 != id_state_old_flag[i]) && (0 == id_state_flag[i]))) {
831*4882a593Smuzhiyun 		#ifdef REPORT_DATA_ANDROID_4_0
832*4882a593Smuzhiyun 			input_mt_slot(ts->input, i);
833*4882a593Smuzhiyun 			input_report_abs(ts->input, ABS_MT_TRACKING_ID, -1);
834*4882a593Smuzhiyun 			input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, false);
835*4882a593Smuzhiyun 		#endif
836*4882a593Smuzhiyun 			id_sign[i] = 0;
837*4882a593Smuzhiyun 		}
838*4882a593Smuzhiyun 		id_state_old_flag[i] = id_state_flag[i];
839*4882a593Smuzhiyun 	}
840*4882a593Smuzhiyun #ifndef REPORT_DATA_ANDROID_4_0
841*4882a593Smuzhiyun 	if (0 == touches) {
842*4882a593Smuzhiyun 		input_mt_sync(ts->input);
843*4882a593Smuzhiyun 	#ifdef HAVE_TOUCH_KEY
844*4882a593Smuzhiyun 		if (key_state_flag) {
845*4882a593Smuzhiyun 			input_report_key(ts->input, key, 0);
846*4882a593Smuzhiyun 			input_sync(ts->input);
847*4882a593Smuzhiyun 			key_state_flag = 0;
848*4882a593Smuzhiyun 		}
849*4882a593Smuzhiyun 	#endif
850*4882a593Smuzhiyun 	}
851*4882a593Smuzhiyun #endif
852*4882a593Smuzhiyun 	input_sync(ts->input);
853*4882a593Smuzhiyun 
854*4882a593Smuzhiyun schedule:
855*4882a593Smuzhiyun #ifdef GSL_MONITOR
856*4882a593Smuzhiyun 	i2c_lock_flag = 0;
857*4882a593Smuzhiyun i2c_lock_schedule:
858*4882a593Smuzhiyun #endif
859*4882a593Smuzhiyun 	enable_irq(ts->irq);
860*4882a593Smuzhiyun }
861*4882a593Smuzhiyun 
862*4882a593Smuzhiyun #ifdef GSL_MONITOR
gsl_monitor_worker(struct work_struct * work)863*4882a593Smuzhiyun static void gsl_monitor_worker(struct work_struct *work)
864*4882a593Smuzhiyun {
865*4882a593Smuzhiyun 	u8 write_buf[4] = {0};
866*4882a593Smuzhiyun 	u8 read_buf[4]  = {0};
867*4882a593Smuzhiyun 	char init_chip_flag = 0;
868*4882a593Smuzhiyun 
869*4882a593Smuzhiyun 	print_info("----------------gsl_monitor_worker-----------------\n");
870*4882a593Smuzhiyun 
871*4882a593Smuzhiyun #ifdef TPD_PROC_DEBUG
872*4882a593Smuzhiyun 	if (gsl_proc_flag == 1) {
873*4882a593Smuzhiyun 		return;
874*4882a593Smuzhiyun 	}
875*4882a593Smuzhiyun #endif
876*4882a593Smuzhiyun 
877*4882a593Smuzhiyun 	if (i2c_lock_flag != 0)
878*4882a593Smuzhiyun 		goto queue_monitor_work;
879*4882a593Smuzhiyun 	else
880*4882a593Smuzhiyun 		i2c_lock_flag = 1;
881*4882a593Smuzhiyun 
882*4882a593Smuzhiyun 	gsl_ts_read(gsl_client, 0xb0, read_buf, 4);
883*4882a593Smuzhiyun 	if (read_buf[3] != 0x5a || read_buf[2] != 0x5a || read_buf[1] != 0x5a || read_buf[0] != 0x5a)
884*4882a593Smuzhiyun 		b0_counter++;
885*4882a593Smuzhiyun 	else
886*4882a593Smuzhiyun 		b0_counter = 0;
887*4882a593Smuzhiyun 
888*4882a593Smuzhiyun 	if (b0_counter > 1) {
889*4882a593Smuzhiyun 		printk("======read 0xb0: %x %x %x %x ======\n", read_buf[3], read_buf[2], read_buf[1], read_buf[0]);
890*4882a593Smuzhiyun 		init_chip_flag = 1;
891*4882a593Smuzhiyun 		b0_counter = 0;
892*4882a593Smuzhiyun 		goto queue_monitor_init_chip;
893*4882a593Smuzhiyun 	}
894*4882a593Smuzhiyun 
895*4882a593Smuzhiyun 	gsl_ts_read(gsl_client, 0xb4, read_buf, 4);
896*4882a593Smuzhiyun 	int_2nd[3] = int_1st[3];
897*4882a593Smuzhiyun 	int_2nd[2] = int_1st[2];
898*4882a593Smuzhiyun 	int_2nd[1] = int_1st[1];
899*4882a593Smuzhiyun 	int_2nd[0] = int_1st[0];
900*4882a593Smuzhiyun 	int_1st[3] = read_buf[3];
901*4882a593Smuzhiyun 	int_1st[2] = read_buf[2];
902*4882a593Smuzhiyun 	int_1st[1] = read_buf[1];
903*4882a593Smuzhiyun 	int_1st[0] = read_buf[0];
904*4882a593Smuzhiyun 
905*4882a593Smuzhiyun 	if (int_1st[3] == int_2nd[3] && int_1st[2] == int_2nd[2] && int_1st[1] == int_2nd[1] && int_1st[0] == int_2nd[0]) {
906*4882a593Smuzhiyun 		printk("======int_1st: %x %x %x %x , int_2nd: %x %x %x %x ======\n", int_1st[3], int_1st[2], int_1st[1], int_1st[0], int_2nd[3], int_2nd[2], int_2nd[1], int_2nd[0]);
907*4882a593Smuzhiyun 		init_chip_flag = 1;
908*4882a593Smuzhiyun 		goto queue_monitor_init_chip;
909*4882a593Smuzhiyun 	}
910*4882a593Smuzhiyun 
911*4882a593Smuzhiyun #if 1
912*4882a593Smuzhiyun 	gsl_ts_read(gsl_client, 0xbc, read_buf, 4);
913*4882a593Smuzhiyun 	if (read_buf[3] != 0 || read_buf[2] != 0 || read_buf[1] != 0 || read_buf[0] != 0)
914*4882a593Smuzhiyun 		bc_counter++;
915*4882a593Smuzhiyun 	else
916*4882a593Smuzhiyun 		bc_counter = 0;
917*4882a593Smuzhiyun 	if (bc_counter > 1) {
918*4882a593Smuzhiyun 		printk("======read 0xbc: %x %x %x %x======\n", read_buf[3], read_buf[2], read_buf[1], read_buf[0]);
919*4882a593Smuzhiyun 		init_chip_flag = 1;
920*4882a593Smuzhiyun 		bc_counter = 0;
921*4882a593Smuzhiyun 	}
922*4882a593Smuzhiyun #else
923*4882a593Smuzhiyun 	write_buf[3] = 0x01;
924*4882a593Smuzhiyun 	write_buf[2] = 0xfe;
925*4882a593Smuzhiyun 	write_buf[1] = 0x10;
926*4882a593Smuzhiyun 	write_buf[0] = 0x00;
927*4882a593Smuzhiyun 	gsl_ts_write(gsl_client, 0xf0, write_buf, 4);
928*4882a593Smuzhiyun 	gsl_ts_read(gsl_client, 0x10, read_buf, 4);
929*4882a593Smuzhiyun 	gsl_ts_read(gsl_client, 0x10, read_buf, 4);
930*4882a593Smuzhiyun 
931*4882a593Smuzhiyun 	if (read_buf[3] < 10 && read_buf[2] < 10 && read_buf[1] < 10 && read_buf[0] < 10)
932*4882a593Smuzhiyun 		dac_counter++;
933*4882a593Smuzhiyun 	else
934*4882a593Smuzhiyun 		dac_counter = 0;
935*4882a593Smuzhiyun 
936*4882a593Smuzhiyun 	if (dac_counter > 1) {
937*4882a593Smuzhiyun 		printk("======read DAC1_0: %x %x %x %x ======\n", read_buf[3], read_buf[2], read_buf[1], read_buf[0]);
938*4882a593Smuzhiyun 		init_chip_flag = 1;
939*4882a593Smuzhiyun 		dac_counter = 0;
940*4882a593Smuzhiyun 	}
941*4882a593Smuzhiyun #endif
942*4882a593Smuzhiyun queue_monitor_init_chip:
943*4882a593Smuzhiyun 	if (init_chip_flag) {
944*4882a593Smuzhiyun 		#ifdef GSLX680_COMPATIBLE
945*4882a593Smuzhiyun 		judge_chip_type(gsl_client);
946*4882a593Smuzhiyun 		#endif
947*4882a593Smuzhiyun 		init_chip(gsl_client);
948*4882a593Smuzhiyun 		reset_chip(gsl_client);
949*4882a593Smuzhiyun 		startup_chip(gsl_client);
950*4882a593Smuzhiyun 		check_mem_data(gsl_client);
951*4882a593Smuzhiyun 	}
952*4882a593Smuzhiyun 
953*4882a593Smuzhiyun 	i2c_lock_flag = 0;
954*4882a593Smuzhiyun 
955*4882a593Smuzhiyun queue_monitor_work:
956*4882a593Smuzhiyun 	queue_delayed_work(gsl_monitor_workqueue, &gsl_monitor_work, 100);
957*4882a593Smuzhiyun }
958*4882a593Smuzhiyun #endif
959*4882a593Smuzhiyun 
gsl_ts_irq(int irq,void * dev_id)960*4882a593Smuzhiyun static irqreturn_t gsl_ts_irq(int irq, void *dev_id)
961*4882a593Smuzhiyun {
962*4882a593Smuzhiyun 	struct gsl_ts *ts = dev_id;
963*4882a593Smuzhiyun 
964*4882a593Smuzhiyun 	print_info("========gslX680 Interrupt=========\n");
965*4882a593Smuzhiyun #ifdef BND_GESTURE
966*4882a593Smuzhiyun 	if (1 == gsl_lcd_flag)
967*4882a593Smuzhiyun 		gsl_gesture_flag = 1;
968*4882a593Smuzhiyun #endif
969*4882a593Smuzhiyun 	disable_irq_nosync(ts->irq);
970*4882a593Smuzhiyun 
971*4882a593Smuzhiyun 	if (!work_pending(&ts->work)) {
972*4882a593Smuzhiyun 		queue_work(ts->wq, &ts->work);
973*4882a593Smuzhiyun 	}
974*4882a593Smuzhiyun 
975*4882a593Smuzhiyun 	return IRQ_HANDLED;
976*4882a593Smuzhiyun }
977*4882a593Smuzhiyun 
gsl_ts_init_ts(struct i2c_client * client,struct gsl_ts * ts)978*4882a593Smuzhiyun static int gsl_ts_init_ts(struct i2c_client *client, struct gsl_ts *ts)
979*4882a593Smuzhiyun {
980*4882a593Smuzhiyun 	struct input_dev *input_device;
981*4882a593Smuzhiyun 	int rc = 0;
982*4882a593Smuzhiyun 
983*4882a593Smuzhiyun 	printk("[GSLX680] Enter %s\n", __func__);
984*4882a593Smuzhiyun 
985*4882a593Smuzhiyun 	ts->dd = &devices[ts->device_id];
986*4882a593Smuzhiyun 
987*4882a593Smuzhiyun 	if (ts->device_id == 0) {
988*4882a593Smuzhiyun 		ts->dd->data_size = MAX_FINGERS * ts->dd->touch_bytes + ts->dd->touch_meta_data;
989*4882a593Smuzhiyun 		ts->dd->touch_index = 0;
990*4882a593Smuzhiyun 	}
991*4882a593Smuzhiyun 
992*4882a593Smuzhiyun 	ts->touch_data = devm_kzalloc(&client->dev, ts->dd->data_size, GFP_KERNEL);
993*4882a593Smuzhiyun 	if (!ts->touch_data) {
994*4882a593Smuzhiyun 		pr_err("%s: Unable to allocate memory\n", __func__);
995*4882a593Smuzhiyun 		return -ENOMEM;
996*4882a593Smuzhiyun 	}
997*4882a593Smuzhiyun 
998*4882a593Smuzhiyun 	input_device = input_allocate_device();
999*4882a593Smuzhiyun 	if (!input_device) {
1000*4882a593Smuzhiyun 		rc = -ENOMEM;
1001*4882a593Smuzhiyun 		goto error_alloc_dev;
1002*4882a593Smuzhiyun 	}
1003*4882a593Smuzhiyun 
1004*4882a593Smuzhiyun 	ts->input = input_device;
1005*4882a593Smuzhiyun 	input_device->name = GSLX680_I2C_NAME;
1006*4882a593Smuzhiyun 	input_device->id.bustype = BUS_I2C;
1007*4882a593Smuzhiyun 	input_device->dev.parent = &client->dev;
1008*4882a593Smuzhiyun 	input_set_drvdata(input_device, ts);
1009*4882a593Smuzhiyun 
1010*4882a593Smuzhiyun #ifdef REPORT_DATA_ANDROID_4_0
1011*4882a593Smuzhiyun 	__set_bit(EV_ABS, input_device->evbit);
1012*4882a593Smuzhiyun 	__set_bit(EV_KEY, input_device->evbit);
1013*4882a593Smuzhiyun 	__set_bit(EV_REP, input_device->evbit);
1014*4882a593Smuzhiyun 	__set_bit(INPUT_PROP_DIRECT, input_device->propbit);
1015*4882a593Smuzhiyun 	input_mt_init_slots(input_device, (MAX_CONTACTS+1), 0);
1016*4882a593Smuzhiyun #else
1017*4882a593Smuzhiyun 	input_set_abs_params(input_device, ABS_MT_TRACKING_ID, 0, (MAX_CONTACTS+1), 0, 0);
1018*4882a593Smuzhiyun 	set_bit(EV_ABS, input_device->evbit);
1019*4882a593Smuzhiyun 	set_bit(EV_KEY, input_device->evbit);
1020*4882a593Smuzhiyun 	__set_bit(INPUT_PROP_DIRECT, input_device->propbit);
1021*4882a593Smuzhiyun 	input_device->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
1022*4882a593Smuzhiyun #endif
1023*4882a593Smuzhiyun 
1024*4882a593Smuzhiyun #ifdef HAVE_TOUCH_KEY
1025*4882a593Smuzhiyun 	input_device->evbit[0] = BIT_MASK(EV_KEY);
1026*4882a593Smuzhiyun 	for (i = 0; i < MAX_KEY_NUM; i++)
1027*4882a593Smuzhiyun 		set_bit(key_array[i], input_device->keybit);
1028*4882a593Smuzhiyun #endif
1029*4882a593Smuzhiyun 
1030*4882a593Smuzhiyun 	set_bit(ABS_MT_POSITION_X, input_device->absbit);
1031*4882a593Smuzhiyun 	set_bit(ABS_MT_POSITION_Y, input_device->absbit);
1032*4882a593Smuzhiyun 	set_bit(ABS_MT_TOUCH_MAJOR, input_device->absbit);
1033*4882a593Smuzhiyun 	set_bit(ABS_MT_WIDTH_MAJOR, input_device->absbit);
1034*4882a593Smuzhiyun 
1035*4882a593Smuzhiyun 	input_set_abs_params(input_device, ABS_MT_POSITION_X, 0, ts->screen_max_x, 0, 0);
1036*4882a593Smuzhiyun 	input_set_abs_params(input_device, ABS_MT_POSITION_Y, 0, ts->screen_max_y, 0, 0);
1037*4882a593Smuzhiyun 	input_set_abs_params(input_device, ABS_MT_TOUCH_MAJOR, 0, PRESS_MAX, 0, 0);
1038*4882a593Smuzhiyun 	input_set_abs_params(input_device, ABS_MT_WIDTH_MAJOR, 0, 200, 0, 0);
1039*4882a593Smuzhiyun 
1040*4882a593Smuzhiyun 	ts->wq = create_singlethread_workqueue("kworkqueue_ts");
1041*4882a593Smuzhiyun 	if (!ts->wq) {
1042*4882a593Smuzhiyun 		dev_err(&client->dev, "Could not create workqueue\n");
1043*4882a593Smuzhiyun 		goto error_wq_create;
1044*4882a593Smuzhiyun 	}
1045*4882a593Smuzhiyun 	flush_workqueue(ts->wq);
1046*4882a593Smuzhiyun 
1047*4882a593Smuzhiyun 	INIT_WORK(&ts->work, gslX680_ts_worker);
1048*4882a593Smuzhiyun 
1049*4882a593Smuzhiyun 	rc = input_register_device(input_device);
1050*4882a593Smuzhiyun 	if (rc)
1051*4882a593Smuzhiyun 		goto error_unreg_device;
1052*4882a593Smuzhiyun 
1053*4882a593Smuzhiyun 	return 0;
1054*4882a593Smuzhiyun error_unreg_device:
1055*4882a593Smuzhiyun 	destroy_workqueue(ts->wq);
1056*4882a593Smuzhiyun error_wq_create:
1057*4882a593Smuzhiyun 	input_free_device(input_device);
1058*4882a593Smuzhiyun error_alloc_dev:
1059*4882a593Smuzhiyun 	return rc;
1060*4882a593Smuzhiyun }
1061*4882a593Smuzhiyun 
gsl_ts_suspend(struct device * dev)1062*4882a593Smuzhiyun static int gsl_ts_suspend(struct device *dev)
1063*4882a593Smuzhiyun {
1064*4882a593Smuzhiyun 	struct gsl_ts *ts = dev_get_drvdata(dev);
1065*4882a593Smuzhiyun 	int i;
1066*4882a593Smuzhiyun 	int tmp = 0;
1067*4882a593Smuzhiyun 
1068*4882a593Smuzhiyun #ifdef GSL_NOID_VERSION
1069*4882a593Smuzhiyun 	tmp = gsl_version_id();
1070*4882a593Smuzhiyun #endif
1071*4882a593Smuzhiyun 
1072*4882a593Smuzhiyun #ifdef TPD_PROC_DEBUG
1073*4882a593Smuzhiyun 	if (gsl_proc_flag == 1) {
1074*4882a593Smuzhiyun 		return -1;
1075*4882a593Smuzhiyun 	}
1076*4882a593Smuzhiyun #endif
1077*4882a593Smuzhiyun 
1078*4882a593Smuzhiyun #ifdef GSL_MONITOR
1079*4882a593Smuzhiyun 	cancel_delayed_work_sync(&gsl_monitor_work);
1080*4882a593Smuzhiyun #endif
1081*4882a593Smuzhiyun /*
1082*4882a593Smuzhiyun #ifdef BND_GESTURE
1083*4882a593Smuzhiyun //	disable_irq_nosync(ts->irq);
1084*4882a593Smuzhiyun #else
1085*4882a593Smuzhiyun 	disable_irq_nosync(ts->irq);
1086*4882a593Smuzhiyun #endif*/
1087*4882a593Smuzhiyun 
1088*4882a593Smuzhiyun #ifdef BND_GESTURE
1089*4882a593Smuzhiyun /*	gslX680_shutdown_low(); */
1090*4882a593Smuzhiyun #else
1091*4882a593Smuzhiyun 	gslX680_shutdown_low();
1092*4882a593Smuzhiyun #endif
1093*4882a593Smuzhiyun 
1094*4882a593Smuzhiyun #ifdef SLEEP_CLEAR_POINT
1095*4882a593Smuzhiyun 	msleep(10);
1096*4882a593Smuzhiyun 	#ifdef REPORT_DATA_ANDROID_4_0
1097*4882a593Smuzhiyun 	for (i = 1; i <= MAX_CONTACTS; i++) {
1098*4882a593Smuzhiyun 		input_mt_slot(ts->input, i);
1099*4882a593Smuzhiyun 		input_report_abs(ts->input, ABS_MT_TRACKING_ID, -1);
1100*4882a593Smuzhiyun 		input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, false);
1101*4882a593Smuzhiyun 	}
1102*4882a593Smuzhiyun 	#else
1103*4882a593Smuzhiyun 	input_mt_sync(ts->input);
1104*4882a593Smuzhiyun 	#endif
1105*4882a593Smuzhiyun 	input_sync(ts->input);
1106*4882a593Smuzhiyun 	msleep(10);
1107*4882a593Smuzhiyun 	report_data(ts, 1, 1, 10, 1);
1108*4882a593Smuzhiyun 	input_sync(ts->input);
1109*4882a593Smuzhiyun #endif
1110*4882a593Smuzhiyun 
1111*4882a593Smuzhiyun 	return 0;
1112*4882a593Smuzhiyun }
1113*4882a593Smuzhiyun 
gsl_ts_resume(struct device * dev)1114*4882a593Smuzhiyun static int gsl_ts_resume(struct device *dev)
1115*4882a593Smuzhiyun {
1116*4882a593Smuzhiyun 	struct gsl_ts *ts = dev_get_drvdata(dev);
1117*4882a593Smuzhiyun 	int i;
1118*4882a593Smuzhiyun 
1119*4882a593Smuzhiyun #ifdef TPD_PROC_DEBUG
1120*4882a593Smuzhiyun 	if (gsl_proc_flag == 1) {
1121*4882a593Smuzhiyun 		return -1;
1122*4882a593Smuzhiyun 	}
1123*4882a593Smuzhiyun #endif
1124*4882a593Smuzhiyun 
1125*4882a593Smuzhiyun 	if ((!IS_ERR(ts->rst)) && regulator_is_enabled(ts->rst) > 0)
1126*4882a593Smuzhiyun 		regulator_disable(ts->rst);
1127*4882a593Smuzhiyun 	gslX680_shutdown_high();
1128*4882a593Smuzhiyun 	msleep(20);
1129*4882a593Smuzhiyun 	reset_chip(ts->client);
1130*4882a593Smuzhiyun 	startup_chip(ts->client);
1131*4882a593Smuzhiyun 	check_mem_data(ts->client);
1132*4882a593Smuzhiyun 
1133*4882a593Smuzhiyun #ifdef SLEEP_CLEAR_POINT
1134*4882a593Smuzhiyun 	#ifdef REPORT_DATA_ANDROID_4_0
1135*4882a593Smuzhiyun 	for (i = 1 ; i <= MAX_CONTACTS; i++) {
1136*4882a593Smuzhiyun 		input_mt_slot(ts->input, i);
1137*4882a593Smuzhiyun 		input_report_abs(ts->input, ABS_MT_TRACKING_ID, -1);
1138*4882a593Smuzhiyun 		input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, false);
1139*4882a593Smuzhiyun 	}
1140*4882a593Smuzhiyun 	#else
1141*4882a593Smuzhiyun 	input_mt_sync(ts->input);
1142*4882a593Smuzhiyun 	#endif
1143*4882a593Smuzhiyun 	input_sync(ts->input);
1144*4882a593Smuzhiyun #endif
1145*4882a593Smuzhiyun #ifdef GSL_MONITOR
1146*4882a593Smuzhiyun 	queue_delayed_work(gsl_monitor_workqueue, &gsl_monitor_work, 300);
1147*4882a593Smuzhiyun #endif
1148*4882a593Smuzhiyun /*
1149*4882a593Smuzhiyun #ifdef BND_GESTURE
1150*4882a593Smuzhiyun 	enable_irq(ts->irq);
1151*4882a593Smuzhiyun #else
1152*4882a593Smuzhiyun 	enable_irq(ts->irq);
1153*4882a593Smuzhiyun #endif*/
1154*4882a593Smuzhiyun 
1155*4882a593Smuzhiyun 	return 0;
1156*4882a593Smuzhiyun }
1157*4882a593Smuzhiyun 
1158*4882a593Smuzhiyun #if 1
gsl_ts_early_suspend(struct tp_device * tp_d)1159*4882a593Smuzhiyun static int gsl_ts_early_suspend(struct tp_device *tp_d)
1160*4882a593Smuzhiyun {
1161*4882a593Smuzhiyun 	struct gsl_ts *ts = container_of(tp_d, struct gsl_ts, tp);
1162*4882a593Smuzhiyun #ifdef BND_GESTURE
1163*4882a593Smuzhiyun 	gsl_lcd_flag = 1;
1164*4882a593Smuzhiyun #endif
1165*4882a593Smuzhiyun 	return gsl_ts_suspend(&ts->client->dev);
1166*4882a593Smuzhiyun }
1167*4882a593Smuzhiyun 
gsl_ts_late_resume(struct tp_device * tp_d)1168*4882a593Smuzhiyun static int gsl_ts_late_resume(struct tp_device *tp_d)
1169*4882a593Smuzhiyun {
1170*4882a593Smuzhiyun 	struct gsl_ts *ts = container_of(tp_d, struct gsl_ts, tp);
1171*4882a593Smuzhiyun #ifdef BND_GESTURE
1172*4882a593Smuzhiyun 	gsl_lcd_flag = 0;
1173*4882a593Smuzhiyun 	gsl_gesture_flag = 0;
1174*4882a593Smuzhiyun #endif
1175*4882a593Smuzhiyun 	return gsl_ts_resume(&ts->client->dev);
1176*4882a593Smuzhiyun }
1177*4882a593Smuzhiyun #endif
1178*4882a593Smuzhiyun 
judge_chip_type(struct i2c_client * client)1179*4882a593Smuzhiyun void judge_chip_type(struct i2c_client *client)
1180*4882a593Smuzhiyun {
1181*4882a593Smuzhiyun 	u8 read_buf[4]  = {0};
1182*4882a593Smuzhiyun 	msleep(100);
1183*4882a593Smuzhiyun 	gsl_ts_read(client, 0xfc, read_buf, 4);
1184*4882a593Smuzhiyun 	printk("read 0xfc = %x %x %x %x\n", read_buf[3], read_buf[2], read_buf[1], read_buf[0]);
1185*4882a593Smuzhiyun 
1186*4882a593Smuzhiyun 	if (read_buf[2] != 0x91 && read_buf[2] != 0x88 && read_buf[2] != 0x82) {
1187*4882a593Smuzhiyun 		msleep(100);
1188*4882a593Smuzhiyun 		gsl_ts_read(client, 0xfc, read_buf, 4);
1189*4882a593Smuzhiyun 		printk("read 0xfc = %x %x %x %x\n", read_buf[3], read_buf[2], read_buf[1], read_buf[0]);
1190*4882a593Smuzhiyun 	}
1191*4882a593Smuzhiyun 
1192*4882a593Smuzhiyun 	if (read_buf[2] == 0x91)	 {
1193*4882a593Smuzhiyun 		chip_type = 2;
1194*4882a593Smuzhiyun 		is_noid_version = 1;
1195*4882a593Smuzhiyun 	}
1196*4882a593Smuzhiyun #ifdef GSL1680F_COMPATIBLE
1197*4882a593Smuzhiyun 	else if ((read_buf[3]&0xf0) == 0xb0 && read_buf[2] == 0x82) {
1198*4882a593Smuzhiyun 		chip_type = 3;
1199*4882a593Smuzhiyun 		is_noid_version = 2;
1200*4882a593Smuzhiyun 	}
1201*4882a593Smuzhiyun #endif
1202*4882a593Smuzhiyun #ifdef GSL1680E_COMPATIBLE
1203*4882a593Smuzhiyun 	else if (read_buf[2] == 0x82) {
1204*4882a593Smuzhiyun 		chip_type = 1;
1205*4882a593Smuzhiyun 		is_noid_version = 0;
1206*4882a593Smuzhiyun 	}
1207*4882a593Smuzhiyun #endif
1208*4882a593Smuzhiyun 	else {
1209*4882a593Smuzhiyun 		chip_type = 0;
1210*4882a593Smuzhiyun 		is_noid_version = 0;
1211*4882a593Smuzhiyun 	}
1212*4882a593Smuzhiyun }
gsl_ts_probe(struct i2c_client * client,const struct i2c_device_id * id)1213*4882a593Smuzhiyun static int  gsl_ts_probe(struct i2c_client *client,
1214*4882a593Smuzhiyun 			const struct i2c_device_id *id)
1215*4882a593Smuzhiyun {
1216*4882a593Smuzhiyun 	struct gsl_ts *ts;
1217*4882a593Smuzhiyun 	int rc;
1218*4882a593Smuzhiyun 	struct device_node *np = client->dev.of_node;
1219*4882a593Smuzhiyun 	enum of_gpio_flags wake_flags;
1220*4882a593Smuzhiyun 
1221*4882a593Smuzhiyun 	printk("GSLX680 Enter %s\n", __func__);
1222*4882a593Smuzhiyun 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
1223*4882a593Smuzhiyun 		dev_err(&client->dev, "I2C functionality not supported\n");
1224*4882a593Smuzhiyun 		return -ENODEV;
1225*4882a593Smuzhiyun 	}
1226*4882a593Smuzhiyun 
1227*4882a593Smuzhiyun 	ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL);
1228*4882a593Smuzhiyun 	if (!ts)
1229*4882a593Smuzhiyun 		return -ENOMEM;
1230*4882a593Smuzhiyun 
1231*4882a593Smuzhiyun 	ts->client = client;
1232*4882a593Smuzhiyun 	i2c_set_clientdata(client, ts);
1233*4882a593Smuzhiyun 	ts->device_id = id->driver_data;
1234*4882a593Smuzhiyun 
1235*4882a593Smuzhiyun 	of_property_read_u32(np, "screen_max_x", &(ts->screen_max_x));
1236*4882a593Smuzhiyun 	of_property_read_u32(np, "screen_max_y", &(ts->screen_max_y));
1237*4882a593Smuzhiyun 	of_property_read_u32(np, "revert_x", &revert_x);
1238*4882a593Smuzhiyun 	of_property_read_u32(np, "revert_y", &revert_y);
1239*4882a593Smuzhiyun 
1240*4882a593Smuzhiyun 	ts->irq_pin = of_get_named_gpio_flags(np, "touch-gpio", 0, NULL);
1241*4882a593Smuzhiyun 	ts->wake_pin = of_get_named_gpio_flags(np, "wake-gpio", 0, &wake_flags);
1242*4882a593Smuzhiyun 	if (gpio_is_valid(ts->wake_pin)) {
1243*4882a593Smuzhiyun 		rc = devm_gpio_request_one(&client->dev, ts->wake_pin, (wake_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH, "gslX680 wake pin");
1244*4882a593Smuzhiyun 		if (rc != 0) {
1245*4882a593Smuzhiyun 			dev_err(&client->dev, "gslX680 wake pin error\n");
1246*4882a593Smuzhiyun 			return -EIO;
1247*4882a593Smuzhiyun 		}
1248*4882a593Smuzhiyun 		g_wake_pin = ts->wake_pin;
1249*4882a593Smuzhiyun 	} else {
1250*4882a593Smuzhiyun 		dev_info(&client->dev, "wake pin invalid\n");
1251*4882a593Smuzhiyun 	}
1252*4882a593Smuzhiyun 	if (!gpio_is_valid(ts->irq_pin)) {
1253*4882a593Smuzhiyun 		dev_info(&client->dev, "irq pin invalid\n");
1254*4882a593Smuzhiyun 		goto error_mutex_destroy;
1255*4882a593Smuzhiyun 	}
1256*4882a593Smuzhiyun 
1257*4882a593Smuzhiyun 	ts->rst = devm_regulator_get(&client->dev, "rst");
1258*4882a593Smuzhiyun 	if (IS_ERR(ts->rst)) {
1259*4882a593Smuzhiyun 		dev_err(&client->dev, "failed to get regulator, %ld\n",
1260*4882a593Smuzhiyun 				PTR_ERR(ts->rst));
1261*4882a593Smuzhiyun 	}
1262*4882a593Smuzhiyun 
1263*4882a593Smuzhiyun 	rc = gsl_ts_init_ts(client, ts);
1264*4882a593Smuzhiyun 	if (rc < 0) {
1265*4882a593Smuzhiyun 		dev_err(&client->dev, "GSLX680 init failed\n");
1266*4882a593Smuzhiyun 		goto error_mutex_destroy;
1267*4882a593Smuzhiyun 	}
1268*4882a593Smuzhiyun 
1269*4882a593Smuzhiyun 	gsl_client = client;
1270*4882a593Smuzhiyun 
1271*4882a593Smuzhiyun /*	gslX680_init();
1272*4882a593Smuzhiyun 	gpio_set_value(ts->irq_pin,1);
1273*4882a593Smuzhiyun 	msleep(20); */
1274*4882a593Smuzhiyun 	gslX680_shutdown_low();
1275*4882a593Smuzhiyun 	msleep(20);
1276*4882a593Smuzhiyun 	gslX680_shutdown_high();
1277*4882a593Smuzhiyun 	msleep(20);
1278*4882a593Smuzhiyun 	judge_chip_type(ts->client);
1279*4882a593Smuzhiyun 
1280*4882a593Smuzhiyun 	init_chip(ts->client);
1281*4882a593Smuzhiyun 	check_mem_data(ts->client);
1282*4882a593Smuzhiyun 
1283*4882a593Smuzhiyun 	ts->irq = gpio_to_irq(ts->irq_pin);
1284*4882a593Smuzhiyun 	if (ts->irq) {
1285*4882a593Smuzhiyun 		rc = devm_request_threaded_irq(&client->dev, ts->irq, NULL, gsl_ts_irq, IRQF_TRIGGER_RISING | IRQF_ONESHOT, client->name, ts);
1286*4882a593Smuzhiyun 		if (rc != 0) {
1287*4882a593Smuzhiyun 			printk(KERN_ALERT "Cannot allocate ts INT!ERRNO:%d\n", rc);
1288*4882a593Smuzhiyun 			goto error_req_irq_fail;
1289*4882a593Smuzhiyun 		}
1290*4882a593Smuzhiyun 		disable_irq(ts->irq);
1291*4882a593Smuzhiyun 	} else {
1292*4882a593Smuzhiyun 		printk("gslx680 irq req fail\n");
1293*4882a593Smuzhiyun 		goto error_req_irq_fail;
1294*4882a593Smuzhiyun 	}
1295*4882a593Smuzhiyun 	enable_irq(ts->irq);
1296*4882a593Smuzhiyun 	/* create debug attribute */
1297*4882a593Smuzhiyun 	/* rc = device_create_file(&ts->input->dev, &dev_attr_debug_enable); */
1298*4882a593Smuzhiyun 	ts->tp.tp_resume = gsl_ts_late_resume;
1299*4882a593Smuzhiyun 	ts->tp.tp_suspend = gsl_ts_early_suspend;
1300*4882a593Smuzhiyun 	tp_register_fb(&ts->tp);
1301*4882a593Smuzhiyun 
1302*4882a593Smuzhiyun #ifdef CONFIG_HAS_EARLYSUSPEND
1303*4882a593Smuzhiyun 	ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
1304*4882a593Smuzhiyun 	ts->early_suspend.suspend = gsl_ts_early_suspend;
1305*4882a593Smuzhiyun 	ts->early_suspend.resume = gsl_ts_late_resume;
1306*4882a593Smuzhiyun 	register_early_suspend(&ts->early_suspend);
1307*4882a593Smuzhiyun #endif
1308*4882a593Smuzhiyun 
1309*4882a593Smuzhiyun #ifdef GSL_MONITOR
1310*4882a593Smuzhiyun 
1311*4882a593Smuzhiyun 	INIT_DELAYED_WORK(&gsl_monitor_work, gsl_monitor_worker);
1312*4882a593Smuzhiyun 	gsl_monitor_workqueue = create_singlethread_workqueue("gsl_monitor_workqueue");
1313*4882a593Smuzhiyun 	queue_delayed_work(gsl_monitor_workqueue, &gsl_monitor_work, 1000);
1314*4882a593Smuzhiyun #endif
1315*4882a593Smuzhiyun 
1316*4882a593Smuzhiyun #ifdef TPD_PROC_DEBUG
1317*4882a593Smuzhiyun 	proc_create(GSL_CONFIG_PROC_FILE, 0644, NULL, &gsl_seq_fops);
1318*4882a593Smuzhiyun 	gsl_proc_flag = 0;
1319*4882a593Smuzhiyun #endif
1320*4882a593Smuzhiyun 	if (1 == is_zet62xx) {
1321*4882a593Smuzhiyun 		printk(" touch id is zet62xx,so free gpio!\n");
1322*4882a593Smuzhiyun 		gpio_free(g_wake_pin);
1323*4882a593Smuzhiyun 		free_irq(ts->irq, ts);
1324*4882a593Smuzhiyun 	}
1325*4882a593Smuzhiyun 	printk("[GSLX680] End %s\n", __func__);
1326*4882a593Smuzhiyun 
1327*4882a593Smuzhiyun 	return 0;
1328*4882a593Smuzhiyun 
1329*4882a593Smuzhiyun error_req_irq_fail:
1330*4882a593Smuzhiyun     free_irq(ts->irq, ts);
1331*4882a593Smuzhiyun 
1332*4882a593Smuzhiyun error_mutex_destroy:
1333*4882a593Smuzhiyun 	input_free_device(ts->input);
1334*4882a593Smuzhiyun 	return rc;
1335*4882a593Smuzhiyun }
1336*4882a593Smuzhiyun 
gsl_ts_remove(struct i2c_client * client)1337*4882a593Smuzhiyun static int gsl_ts_remove(struct i2c_client *client)
1338*4882a593Smuzhiyun {
1339*4882a593Smuzhiyun 	struct gsl_ts *ts = i2c_get_clientdata(client);
1340*4882a593Smuzhiyun 
1341*4882a593Smuzhiyun #ifdef CONFIG_HAS_EARLYSUSPEND
1342*4882a593Smuzhiyun 	unregister_early_suspend(&ts->early_suspend);
1343*4882a593Smuzhiyun #endif
1344*4882a593Smuzhiyun 
1345*4882a593Smuzhiyun #ifdef GSL_MONITOR
1346*4882a593Smuzhiyun 	cancel_delayed_work_sync(&gsl_monitor_work);
1347*4882a593Smuzhiyun 	destroy_workqueue(gsl_monitor_workqueue);
1348*4882a593Smuzhiyun #endif
1349*4882a593Smuzhiyun 
1350*4882a593Smuzhiyun 	device_init_wakeup(&client->dev, 0);
1351*4882a593Smuzhiyun 	cancel_work_sync(&ts->work);
1352*4882a593Smuzhiyun 	free_irq(ts->irq, ts);
1353*4882a593Smuzhiyun 	destroy_workqueue(ts->wq);
1354*4882a593Smuzhiyun 	input_unregister_device(ts->input);
1355*4882a593Smuzhiyun 	return 0;
1356*4882a593Smuzhiyun }
1357*4882a593Smuzhiyun 
1358*4882a593Smuzhiyun static const struct i2c_device_id gsl_ts_id[] = {
1359*4882a593Smuzhiyun 	{GSLX680_I2C_NAME, 0},
1360*4882a593Smuzhiyun 	{}
1361*4882a593Smuzhiyun };
1362*4882a593Smuzhiyun MODULE_DEVICE_TABLE(i2c, gsl_ts_id);
1363*4882a593Smuzhiyun 
1364*4882a593Smuzhiyun static struct i2c_driver gsl_ts_driver = {
1365*4882a593Smuzhiyun 	.driver = {
1366*4882a593Smuzhiyun 		.name = GSLX680_I2C_NAME,
1367*4882a593Smuzhiyun 		.owner = THIS_MODULE,
1368*4882a593Smuzhiyun 	},
1369*4882a593Smuzhiyun 	.probe		= gsl_ts_probe,
1370*4882a593Smuzhiyun 	.remove		= gsl_ts_remove,
1371*4882a593Smuzhiyun 	.id_table	= gsl_ts_id,
1372*4882a593Smuzhiyun };
1373*4882a593Smuzhiyun 
gsl_ts_init(void)1374*4882a593Smuzhiyun static int __init gsl_ts_init(void)
1375*4882a593Smuzhiyun {
1376*4882a593Smuzhiyun 	int ret;
1377*4882a593Smuzhiyun 	ret = i2c_add_driver(&gsl_ts_driver);
1378*4882a593Smuzhiyun 	return ret;
1379*4882a593Smuzhiyun }
1380*4882a593Smuzhiyun 
gsl_ts_exit(void)1381*4882a593Smuzhiyun static void __exit gsl_ts_exit(void)
1382*4882a593Smuzhiyun {
1383*4882a593Smuzhiyun 	i2c_del_driver(&gsl_ts_driver);
1384*4882a593Smuzhiyun 	return;
1385*4882a593Smuzhiyun }
1386*4882a593Smuzhiyun 
1387*4882a593Smuzhiyun module_init(gsl_ts_init);
1388*4882a593Smuzhiyun module_exit(gsl_ts_exit);
1389*4882a593Smuzhiyun 
1390*4882a593Smuzhiyun MODULE_LICENSE("GPL");
1391*4882a593Smuzhiyun MODULE_DESCRIPTION("GSLX680 touchscreen controller driver");
1392*4882a593Smuzhiyun MODULE_AUTHOR("Guan Yuwei, guanyuwei@basewin.com");
1393*4882a593Smuzhiyun MODULE_ALIAS("platform:gsl_ts");
1394