.. | .. |
---|
1 | 1 | /* drivers/input/touchscreen/gt9xx.c |
---|
2 | | - * |
---|
3 | | - * 2010 - 2013 Goodix Technology. |
---|
4 | | - * |
---|
| 2 | + * |
---|
| 3 | + * 2010 - 2012 Goodix Technology. |
---|
| 4 | + * |
---|
5 | 5 | * This program is free software; you can redistribute it and/or modify |
---|
6 | 6 | * it under the terms of the GNU General Public License as published by |
---|
7 | 7 | * the Free Software Foundation; either version 2 of the License, or |
---|
8 | 8 | * (at your option) any later version. |
---|
9 | | - * |
---|
10 | | - * This program is distributed in the hope that it will be a reference |
---|
11 | | - * to you, when you are integrating the GOODiX's CTP IC into your system, |
---|
12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 9 | + * |
---|
| 10 | + * This program is distributed in the hope that it will be a reference |
---|
| 11 | + * to you, when you are integrating the GOODiX's CTP IC into your system, |
---|
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
14 | 14 | * General Public License for more details. |
---|
15 | | - * |
---|
16 | | - * Version: 2.2 |
---|
17 | | - * Authors: andrew@goodix.com, meta@goodix.com |
---|
18 | | - * Release Date: 2014/01/14 |
---|
| 15 | + * |
---|
| 16 | + * Version:1.4 |
---|
| 17 | + * Author:andrew@goodix.com |
---|
| 18 | + * Release Date:2012/12/12 |
---|
19 | 19 | * Revision record: |
---|
20 | | - * V1.0: |
---|
21 | | - * first Release. By Andrew, 2012/08/31 |
---|
22 | | - * V1.2: |
---|
23 | | - * modify gtp_reset_guitar,slot report,tracking_id & 0x0F. By Andrew, 2012/10/15 |
---|
24 | | - * V1.4: |
---|
25 | | - * modify gt9xx_update.c. By Andrew, 2012/12/12 |
---|
26 | | - * V1.6: |
---|
27 | | - * 1. new heartbeat/esd_protect mechanism(add external watchdog) |
---|
28 | | - * 2. doze mode, sliding wakeup |
---|
29 | | - * 3. 3 more cfg_group(GT9 Sensor_ID: 0~5) |
---|
30 | | - * 3. config length verification |
---|
31 | | - * 4. names & comments |
---|
32 | | - * By Meta, 2013/03/11 |
---|
33 | | - * V1.8: |
---|
34 | | - * 1. pen/stylus identification |
---|
35 | | - * 2. read double check & fixed config support |
---|
36 | | - * 3. new esd & slide wakeup optimization |
---|
37 | | - * By Meta, 2013/06/08 |
---|
38 | | - * V2.0: |
---|
39 | | - * 1. compatible with GT9XXF |
---|
40 | | - * 2. send config after resume |
---|
41 | | - * By Meta, 2013/08/06 |
---|
42 | | - * V2.2: |
---|
43 | | - * 1. gt9xx_config for debug |
---|
44 | | - * 2. gesture wakeup |
---|
45 | | - * 3. pen separate input device, active-pen button support |
---|
46 | | - * 4. coordinates & keys optimization |
---|
47 | | - * By Meta, 2014/01/14 |
---|
| 20 | + * V1.0:2012/08/31,first Release |
---|
| 21 | + * V1.2:2012/10/15,modify gtp_reset_guitar,slot report,tracking_id & 0x0F |
---|
| 22 | + * V1.4:2012/12/12,modify gt9xx_update.c |
---|
| 23 | + * |
---|
48 | 24 | */ |
---|
49 | 25 | |
---|
50 | 26 | #include <linux/irq.h> |
---|
51 | | -#include "gt9xx.h" |
---|
52 | | -#include <linux/pm_runtime.h> |
---|
53 | | - |
---|
54 | | -#ifdef CONFIG_PM |
---|
| 27 | +#include "gt9xx_ts.h" |
---|
55 | 28 | #include <linux/pm.h> |
---|
56 | | -#endif |
---|
57 | 29 | |
---|
58 | 30 | #if GTP_ICS_SLOT_REPORT |
---|
59 | | - #include <linux/input/mt.h> |
---|
| 31 | +#include <linux/input/mt.h> |
---|
60 | 32 | #endif |
---|
61 | 33 | |
---|
62 | | -// if use i2c detect, set 1 |
---|
63 | | -#define USE_DETECT 0 |
---|
64 | | -static int gUseDetect; |
---|
65 | | -static int startup(void); |
---|
66 | | - |
---|
67 | | -#define KEY_NUM 8 |
---|
68 | | -static const char *goodix_ts_name = "goodix-ts"; |
---|
| 34 | +static const char *goodix_ts_name = "gt9xx"; |
---|
69 | 35 | static struct workqueue_struct *goodix_wq; |
---|
70 | | -struct i2c_client *i2c_connect_client; |
---|
71 | | -u8 config[GTP_CONFIG_MAX_LENGTH + GTP_ADDR_LENGTH] |
---|
72 | | - = {GTP_REG_CONFIG_DATA >> 8, GTP_REG_CONFIG_DATA & 0xff}; |
---|
73 | | -unsigned int ctp_key_list[KEY_NUM] = {KEY_SWITCHVIDEOMODE, KEY_KBDILLUMTOGGLE, KEY_KBDILLUMDOWN, KEY_KBDILLUMUP, KEY_SEND, KEY_REPLY, KEY_FORWARDMAIL, KEY_SAVE}; |
---|
| 36 | +struct i2c_client * i2c_connect_client = NULL; |
---|
| 37 | +static u8 config[GTP_CONFIG_MAX_LENGTH + GTP_ADDR_LENGTH] |
---|
| 38 | += {GTP_REG_CONFIG_DATA >> 8, GTP_REG_CONFIG_DATA & 0xff}; |
---|
74 | 39 | |
---|
75 | 40 | #if GTP_HAVE_TOUCH_KEY |
---|
76 | | - static const u16 touch_key_array[] = GTP_KEY_TAB; |
---|
77 | | - #define GTP_MAX_KEY_NUM (sizeof(touch_key_array)/sizeof(touch_key_array[0])) |
---|
78 | | - |
---|
79 | | -#if GTP_DEBUG_ON |
---|
80 | | - static const int key_codes[] = {KEY_HOME, KEY_BACK, KEY_MENU, KEY_SEARCH}; |
---|
81 | | - static const char *key_names[] = {"Key_Home", "Key_Back", "Key_Menu", "Key_Search"}; |
---|
82 | | -#endif |
---|
83 | | - |
---|
| 41 | +static const u16 touch_key_array[] = GTP_KEY_TAB; |
---|
| 42 | +#define GTP_MAX_KEY_NUM (sizeof(touch_key_array)/sizeof(touch_key_array[0])) |
---|
84 | 43 | #endif |
---|
85 | 44 | |
---|
86 | 45 | static s8 gtp_i2c_test(struct i2c_client *client); |
---|
87 | 46 | void gtp_reset_guitar(struct i2c_client *client, s32 ms); |
---|
88 | | -s32 gtp_send_cfg(struct i2c_client *client); |
---|
89 | 47 | void gtp_int_sync(s32 ms); |
---|
90 | | - |
---|
91 | | -static ssize_t gt91xx_config_read_proc(struct file *, char __user *, size_t, loff_t *); |
---|
92 | | -static ssize_t gt91xx_config_write_proc(struct file *, const char __user *, size_t, loff_t *); |
---|
93 | | - |
---|
94 | | -static struct proc_dir_entry *gt91xx_config_proc; |
---|
95 | | -static const struct file_operations config_proc_ops = { |
---|
96 | | - .owner = THIS_MODULE, |
---|
97 | | - .read = gt91xx_config_read_proc, |
---|
98 | | - .write = gt91xx_config_write_proc, |
---|
99 | | -}; |
---|
100 | 48 | |
---|
101 | 49 | #ifdef CONFIG_HAS_EARLYSUSPEND |
---|
102 | 50 | static void goodix_ts_early_suspend(struct early_suspend *h); |
---|
.. | .. |
---|
104 | 52 | #endif |
---|
105 | 53 | |
---|
106 | 54 | #if GTP_CREATE_WR_NODE |
---|
107 | | -extern s32 init_wr_node(struct i2c_client *); |
---|
| 55 | + |
---|
| 56 | +extern s32 init_wr_node(struct i2c_client*); |
---|
108 | 57 | extern void uninit_wr_node(void); |
---|
109 | 58 | #endif |
---|
110 | 59 | |
---|
.. | .. |
---|
114 | 63 | |
---|
115 | 64 | #if GTP_ESD_PROTECT |
---|
116 | 65 | static struct delayed_work gtp_esd_check_work; |
---|
117 | | -static struct workqueue_struct *gtp_esd_check_workqueue; |
---|
| 66 | +static struct workqueue_struct * gtp_esd_check_workqueue = NULL; |
---|
118 | 67 | static void gtp_esd_check_func(struct work_struct *); |
---|
119 | | -static s32 gtp_init_ext_watchdog(struct i2c_client *client); |
---|
120 | | -void gtp_esd_switch(struct i2c_client *, s32); |
---|
| 68 | +s32 gtp_init_ext_watchdog(struct i2c_client *client); |
---|
121 | 69 | #endif |
---|
122 | 70 | |
---|
123 | | -/*********** For GT9XXF Start **********/ |
---|
124 | | -#if GTP_COMPATIBLE_MODE |
---|
125 | | -extern s32 i2c_read_bytes(struct i2c_client *client, u16 addr, u8 *buf, s32 len); |
---|
126 | | -extern s32 i2c_write_bytes(struct i2c_client *client, u16 addr, u8 *buf, s32 len); |
---|
127 | | -extern s32 gup_clk_calibration(void); |
---|
128 | | -extern s32 gup_fw_download_proc(void *dir, u8 dwn_mode); |
---|
129 | | -extern u8 gup_check_fs_mounted(char *path_name); |
---|
| 71 | +/////////////////////////////////////////////// |
---|
| 72 | +//specific tp related macro: need be configured for specific tp |
---|
130 | 73 | |
---|
131 | | -void gtp_recovery_reset(struct i2c_client *client); |
---|
132 | | -static s32 gtp_esd_recovery(struct i2c_client *client); |
---|
133 | | -s32 gtp_fw_startup(struct i2c_client *client); |
---|
134 | | -static s32 gtp_main_clk_proc(struct goodix_ts_data *ts); |
---|
135 | | -static s32 gtp_bak_ref_proc(struct goodix_ts_data *ts, u8 mode); |
---|
136 | | - |
---|
137 | | -#endif |
---|
138 | | -/********** For GT9XXF End **********/ |
---|
139 | | - |
---|
140 | | -/*#if GTP_GESTURE_WAKEUP*/ |
---|
141 | | -static bool gtp_gesture_wakeup; |
---|
142 | | -static bool gtp_power_ctrl_sleep; |
---|
143 | | -static bool g_suspend_flag; |
---|
144 | | - |
---|
145 | | -typedef enum { |
---|
146 | | - DOZE_DISABLED = 0, |
---|
147 | | - DOZE_ENABLED = 1, |
---|
148 | | - DOZE_WAKEUP = 2, |
---|
149 | | -} DOZE_T; |
---|
150 | | -static DOZE_T doze_status = DOZE_DISABLED; |
---|
151 | | -static s8 gtp_enter_doze(struct goodix_ts_data *ts); |
---|
152 | | -/*#endif*/ |
---|
153 | | - |
---|
154 | | -u8 grp_cfg_version = 0; |
---|
155 | | - |
---|
156 | | -/********************Add by zhongjian for sunxi tp***********************/ |
---|
157 | 74 | #define CTP_IRQ_NUMBER (config_info.int_number) |
---|
158 | 75 | #define CTP_IRQ_MODE (IRQF_TRIGGER_FALLING) |
---|
159 | | -#define CTP_NAME ("gt9xxnew_ts") |
---|
| 76 | +#define CTP_NAME ("gt9xx_ts") |
---|
160 | 77 | #define SCREEN_MAX_X (screen_max_x) |
---|
161 | 78 | #define SCREEN_MAX_Y (screen_max_y) |
---|
162 | 79 | #define PRESS_MAX (255) |
---|
163 | | -static int screen_max_x; |
---|
164 | | -static int screen_max_y; |
---|
165 | | -static int revert_x_flag; |
---|
166 | | -static int revert_y_flag; |
---|
167 | | -static int exchange_x_y_flag; |
---|
168 | | -static __u32 twi_id; |
---|
| 80 | + |
---|
| 81 | + |
---|
| 82 | +static int screen_max_x = 1024; |
---|
| 83 | +static int screen_max_y = 600; |
---|
| 84 | +static int revert_x_flag = 0; |
---|
| 85 | +static int revert_y_flag = 0; |
---|
| 86 | +static int exchange_x_y_flag = 0; |
---|
| 87 | +static __u32 twi_id = 0; |
---|
169 | 88 | static char irq_pin_name[8]; |
---|
170 | | -//static u32 debug_mask = 0x1; |
---|
171 | | -static u32 debug_mask; |
---|
172 | | -enum { |
---|
173 | | - DEBUG_INIT = 1U << 0, |
---|
| 89 | + |
---|
| 90 | +static u32 debug_mask = 0; |
---|
| 91 | + |
---|
| 92 | +enum{ |
---|
| 93 | + DEBUG_INIT = 1U << 0, |
---|
174 | 94 | DEBUG_SUSPEND = 1U << 1, |
---|
175 | 95 | DEBUG_INT_INFO = 1U << 2, |
---|
176 | 96 | DEBUG_X_Y_INFO = 1U << 3, |
---|
.. | .. |
---|
178 | 98 | DEBUG_WAKEUP_INFO = 1U << 5, |
---|
179 | 99 | DEBUG_OTHERS_INFO = 1U << 6, |
---|
180 | 100 | }; |
---|
181 | | -#define dprintk(level_mask, fmt, arg...) if(unlikely(debug_mask & level_mask)) \ |
---|
182 | | - printk("***CTP***"fmt, ## arg) |
---|
183 | | -module_param_named(debug_mask, debug_mask, int, S_IRUGO | S_IWUSR | S_IWGRP); |
---|
184 | | -static const unsigned short normal_i2c[3] = {0x14,0x5d, I2C_CLIENT_END}; |
---|
| 101 | + |
---|
| 102 | +#define dprintk(level_mask,fmt,arg...) if(unlikely(debug_mask & level_mask)) \ |
---|
| 103 | + printk("***CTP***"fmt, ## arg) |
---|
| 104 | +module_param_named(debug_mask,debug_mask,int,S_IRUGO | S_IWUSR | S_IWGRP); |
---|
| 105 | + |
---|
| 106 | +static const unsigned short normal_i2c[3] = {0x14, 0x5d, I2C_CLIENT_END}; |
---|
| 107 | +//static const int chip_id_value[3] = {57}; |
---|
| 108 | +//static uint8_t read_chip_value[3] = {GTP_REG_VERSION >> 8, GTP_REG_VERSION & 0xff,0}; |
---|
185 | 109 | struct ctp_config_info config_info = { |
---|
186 | 110 | .input_type = CTP_TYPE, |
---|
187 | 111 | .name = NULL, |
---|
188 | 112 | .int_number = 0, |
---|
189 | 113 | }; |
---|
190 | 114 | |
---|
| 115 | +//static void goodix_init_events(struct work_struct *work); |
---|
| 116 | +static void goodix_resume_events(struct work_struct *work); |
---|
| 117 | +static struct workqueue_struct *goodix_wq; |
---|
| 118 | +//static struct workqueue_struct *goodix_init_wq; |
---|
| 119 | +static struct workqueue_struct *goodix_resume_wq; |
---|
| 120 | +//static DECLARE_WORK(goodix_init_work, goodix_init_events); |
---|
| 121 | +static DECLARE_WORK(goodix_resume_work, goodix_resume_events); |
---|
| 122 | + |
---|
191 | 123 | /** |
---|
192 | 124 | * ctp_detect - Device detection callback for automatic device creation |
---|
193 | | - * return value: |
---|
| 125 | + * return value: |
---|
194 | 126 | * = 0; success; |
---|
195 | 127 | * < 0; err |
---|
196 | 128 | */ |
---|
197 | 129 | static int ctp_detect(struct i2c_client *client, struct i2c_board_info *info) |
---|
198 | 130 | { |
---|
199 | 131 | struct i2c_adapter *adapter = client->adapter; |
---|
200 | | - int ret = -1; |
---|
201 | | - printk("the adapter number is %d\n", adapter->nr); |
---|
| 132 | + int ret = -1; |
---|
202 | 133 | |
---|
203 | | - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { |
---|
| 134 | + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)){ |
---|
204 | 135 | printk("======return=====\n"); |
---|
205 | 136 | return -ENODEV; |
---|
206 | | - } |
---|
| 137 | + } |
---|
207 | 138 | |
---|
208 | | - if(twi_id == adapter->nr) { |
---|
209 | | - printk("%s: addr = %x\n", __func__, client->addr); |
---|
210 | | - ret = gtp_i2c_test(client); |
---|
| 139 | + if(twi_id == adapter->nr){ |
---|
| 140 | + dprintk(DEBUG_INIT,"%s: addr = %x\n", __func__, client->addr); |
---|
| 141 | + ret = gtp_i2c_test(client); |
---|
211 | 142 | printk("detect ret %d\n",ret); |
---|
212 | | - if(!ret) { |
---|
213 | | - printk("%s:I2C connection might be something wrong \n", __func__); |
---|
214 | | - return -ENODEV; |
---|
215 | | - } else { |
---|
| 143 | + if(!ret){ |
---|
| 144 | + printk("%s:I2C connection might be something wrong \n", __func__); |
---|
| 145 | + return -ENODEV; |
---|
| 146 | + }else{ |
---|
216 | 147 | strlcpy(info->type, CTP_NAME, I2C_NAME_SIZE); |
---|
217 | 148 | printk("======detect ok !=====\n"); |
---|
218 | | - return 0; |
---|
219 | | - } |
---|
220 | | - } else { |
---|
221 | | - return -ENODEV; |
---|
| 149 | + return 0; |
---|
| 150 | + } |
---|
| 151 | + }else{ |
---|
| 152 | + return -ENODEV; |
---|
222 | 153 | } |
---|
223 | 154 | } |
---|
224 | 155 | |
---|
.. | .. |
---|
229 | 160 | */ |
---|
230 | 161 | void ctp_print_info(struct ctp_config_info info,int debug_level) |
---|
231 | 162 | { |
---|
232 | | - if(debug_level == DEBUG_INIT) { |
---|
| 163 | + if(debug_level == DEBUG_INIT) |
---|
| 164 | + { |
---|
233 | 165 | dprintk(DEBUG_INIT,"info.ctp_used:%d\n",info.ctp_used); |
---|
234 | 166 | dprintk(DEBUG_INIT,"info.twi_id:%d\n",info.twi_id); |
---|
235 | 167 | dprintk(DEBUG_INIT,"info.screen_max_x:%d\n",info.screen_max_x); |
---|
.. | .. |
---|
276 | 208 | |
---|
277 | 209 | void gtp_set_int_value(int status) |
---|
278 | 210 | { |
---|
279 | | - long unsigned int config; |
---|
| 211 | + long unsigned int config; |
---|
280 | 212 | |
---|
281 | | - config = SUNXI_PINCFG_PACK(SUNXI_PINCFG_TYPE_FUNC,0xFFFF); |
---|
282 | | - pin_config_get(SUNXI_PINCTRL,irq_pin_name,&config); |
---|
| 213 | + config = SUNXI_PINCFG_PACK(SUNXI_PINCFG_TYPE_FUNC,0xFFFF); |
---|
| 214 | + pin_config_get(SUNXI_PINCTRL,irq_pin_name,&config); |
---|
283 | 215 | |
---|
284 | | - if (1 != SUNXI_PINCFG_UNPACK_VALUE(config)) { |
---|
285 | | - config = SUNXI_PINCFG_PACK(SUNXI_PINCFG_TYPE_FUNC,1); |
---|
286 | | - pin_config_set(SUNXI_PINCTRL,irq_pin_name,config);; |
---|
287 | | - } |
---|
| 216 | + if (1 != SUNXI_PINCFG_UNPACK_VALUE(config)){ |
---|
| 217 | + config = SUNXI_PINCFG_PACK(SUNXI_PINCFG_TYPE_FUNC,1); |
---|
| 218 | + pin_config_set(SUNXI_PINCTRL,irq_pin_name,config);; |
---|
| 219 | + } |
---|
288 | 220 | |
---|
289 | | - __gpio_set_value(CTP_IRQ_NUMBER, status); |
---|
| 221 | + __gpio_set_value(CTP_IRQ_NUMBER, status); |
---|
290 | 222 | } |
---|
291 | 223 | |
---|
292 | 224 | void gtp_set_io_int(void) |
---|
293 | 225 | { |
---|
294 | | - long unsigned int config; |
---|
295 | | - config = SUNXI_PINCFG_PACK(SUNXI_PINCFG_TYPE_FUNC,0xFFFF); |
---|
296 | | - pin_config_get(SUNXI_PINCTRL,irq_pin_name,&config); |
---|
| 226 | + long unsigned int config; |
---|
| 227 | + config = SUNXI_PINCFG_PACK(SUNXI_PINCFG_TYPE_FUNC,0xFFFF); |
---|
| 228 | + pin_config_get(SUNXI_PINCTRL,irq_pin_name,&config); |
---|
297 | 229 | |
---|
298 | | - if (6 != SUNXI_PINCFG_UNPACK_VALUE(config)) { |
---|
299 | | - config = SUNXI_PINCFG_PACK(SUNXI_PINCFG_TYPE_FUNC,6); |
---|
300 | | - pin_config_set(SUNXI_PINCTRL,irq_pin_name,config); |
---|
301 | | - } |
---|
| 230 | + if (6 != SUNXI_PINCFG_UNPACK_VALUE(config)) { |
---|
| 231 | + config = SUNXI_PINCFG_PACK(SUNXI_PINCFG_TYPE_FUNC, 6); |
---|
| 232 | + pin_config_set(SUNXI_PINCTRL, irq_pin_name, config); |
---|
| 233 | + } |
---|
302 | 234 | |
---|
303 | 235 | } |
---|
304 | 236 | |
---|
305 | 237 | void gtp_io_init(int ms) |
---|
306 | | -{ |
---|
| 238 | +{ |
---|
307 | 239 | ctp_wakeup(0, 0); |
---|
308 | 240 | msleep(ms); |
---|
| 241 | + |
---|
309 | 242 | gtp_set_int_value(0); |
---|
310 | 243 | msleep(2); |
---|
311 | 244 | |
---|
312 | 245 | ctp_wakeup(1, 0); |
---|
313 | 246 | msleep(6); |
---|
314 | | - gpio_direction_output(config_info.wakeup_gpio.gpio,1); |
---|
315 | | - gtp_int_sync(50); |
---|
| 247 | + |
---|
| 248 | + |
---|
| 249 | +#if GTP_ESD_PROTECT |
---|
| 250 | + // gtp_init_ext_watchdog(client); |
---|
| 251 | +#endif |
---|
| 252 | + |
---|
316 | 253 | } |
---|
317 | 254 | |
---|
318 | | -/*******************************************************************************/ |
---|
319 | | -static ssize_t gtp_gesture_enable_store(struct device *dev,struct device_attribute *attr,const char *buf, size_t count) |
---|
320 | | -{ |
---|
321 | | - unsigned long data; |
---|
322 | | - /*struct input_dev *input = dev_get_drvdata(dev);*/ |
---|
323 | | - /*struct goodix_ts_data *ts = container_of(&input, struct goodix_ts_data, input_dev);*/ |
---|
324 | | - data = simple_strtoul(buf, NULL, 10); |
---|
325 | | - dprintk(DEBUG_INIT,"%s g_suspend_flag=%d,gtp_gesture_wakeup=%d,enable=%ld\n",__func__,g_suspend_flag,gtp_gesture_wakeup,data); |
---|
326 | | - if (!g_suspend_flag) { |
---|
327 | | - if(data) { |
---|
328 | | - gtp_gesture_wakeup = 1; |
---|
329 | | - gtp_power_ctrl_sleep = 0; |
---|
330 | | - dprintk(DEBUG_INIT,"%s gtp_gesture_wakeup=%d,enable=%ld\n", __func__, gtp_gesture_wakeup,data); |
---|
331 | | - } else { |
---|
332 | | - gtp_gesture_wakeup = 0; |
---|
333 | | - gtp_power_ctrl_sleep = 1; |
---|
334 | | - dprintk(DEBUG_INIT,"%s gtp_gesture_wakeup=%d,enable=%ld\n", __func__, gtp_gesture_wakeup,data); |
---|
335 | | - } |
---|
336 | | - } |
---|
337 | | - else |
---|
338 | | - dprintk(DEBUG_INIT,"%s gtp is suspend!!!! gtp_gesture_wakeup cann't be set!! gtp_gesture_wakeup=%d,enable=%ld\n", __func__, gtp_gesture_wakeup, data); |
---|
339 | | - return count; |
---|
340 | | -} |
---|
341 | | -static ssize_t gtp_gesture_enable_show(struct device *dev, |
---|
342 | | - struct device_attribute *attr, char *buf) |
---|
343 | | -{ |
---|
344 | | - int enable; |
---|
345 | | - if(gtp_gesture_wakeup) |
---|
346 | | - enable = 1; |
---|
347 | | - else |
---|
348 | | - enable = 0; |
---|
349 | | - return sprintf(buf, "%d\n", enable); |
---|
350 | | -} |
---|
351 | | -static DEVICE_ATTR(enable, S_IRUGO|S_IWUSR|S_IWGRP, |
---|
352 | | - gtp_gesture_enable_show, gtp_gesture_enable_store); |
---|
353 | | -static struct attribute *gtp_attributes[] = { |
---|
354 | | - &dev_attr_enable.attr, |
---|
355 | | - NULL |
---|
356 | | -}; |
---|
357 | | -static struct attribute_group gtp_attribute_group = { |
---|
358 | | - .attrs = gtp_attributes |
---|
359 | | -}; |
---|
360 | | - |
---|
361 | | -/******************************************************* |
---|
| 255 | +/******************************************************* |
---|
362 | 256 | Function: |
---|
363 | | - Read data from the i2c slave device. |
---|
| 257 | +Read data from the i2c slave device. |
---|
| 258 | + |
---|
364 | 259 | Input: |
---|
365 | | - client: i2c device. |
---|
366 | | - buf[0~1]: read start address. |
---|
367 | | - buf[2~len-1]: read data buffer. |
---|
368 | | - len: GTP_ADDR_LENGTH + read bytes count |
---|
| 260 | +client: i2c device. |
---|
| 261 | +buf[0]:operate address. |
---|
| 262 | +buf[1]~buf[len]:read data buffer. |
---|
| 263 | +len:operate length. |
---|
| 264 | + |
---|
369 | 265 | Output: |
---|
370 | | - numbers of i2c_msgs to transfer: |
---|
371 | | - 2: succeed, otherwise: failed |
---|
372 | | -*********************************************************/ |
---|
| 266 | +numbers of i2c_msgs to transfer |
---|
| 267 | + *********************************************************/ |
---|
373 | 268 | s32 gtp_i2c_read(struct i2c_client *client, u8 *buf, s32 len) |
---|
374 | 269 | { |
---|
375 | | - struct i2c_msg msgs[2]; |
---|
376 | | - s32 ret=-1; |
---|
377 | | - s32 retries = 0; |
---|
| 270 | + struct i2c_msg msgs[2]; |
---|
| 271 | + s32 ret = -1; |
---|
| 272 | + s32 retries = 0; |
---|
378 | 273 | |
---|
379 | | - GTP_DEBUG_FUNC(); |
---|
| 274 | + msgs[0].flags = !I2C_M_RD; |
---|
| 275 | + msgs[0].addr = client->addr; |
---|
| 276 | + msgs[0].len = GTP_ADDR_LENGTH; |
---|
| 277 | + msgs[0].buf = &buf[0]; |
---|
380 | 278 | |
---|
381 | | - msgs[0].flags = !I2C_M_RD; |
---|
382 | | - msgs[0].addr = client->addr; |
---|
383 | | - msgs[0].len = GTP_ADDR_LENGTH; |
---|
384 | | - msgs[0].buf = &buf[0]; |
---|
385 | | - /*msgs[0].scl_rate = 300 * 1000;*/ /* for Rockchip, etc.*/ |
---|
| 279 | + msgs[1].flags = I2C_M_RD; |
---|
| 280 | + msgs[1].addr = client->addr; |
---|
| 281 | + msgs[1].len = len - GTP_ADDR_LENGTH; |
---|
| 282 | + msgs[1].buf = &buf[GTP_ADDR_LENGTH]; |
---|
386 | 283 | |
---|
387 | | - msgs[1].flags = I2C_M_RD; |
---|
388 | | - msgs[1].addr = client->addr; |
---|
389 | | - msgs[1].len = len - GTP_ADDR_LENGTH; |
---|
390 | | - msgs[1].buf = &buf[GTP_ADDR_LENGTH]; |
---|
391 | | - /*msgs[1].scl_rate = 300 * 1000;*/ |
---|
| 284 | + while(retries < 2) { |
---|
| 285 | + ret = i2c_transfer(client->adapter, msgs, 2); |
---|
| 286 | + if(ret == 2) |
---|
| 287 | + break; |
---|
| 288 | + retries++; |
---|
| 289 | + } |
---|
392 | 290 | |
---|
393 | | - while(retries < 5) |
---|
394 | | - { |
---|
395 | | - ret = i2c_transfer(client->adapter, msgs, 2); |
---|
396 | | - if(ret == 2)break; |
---|
397 | | - retries++; |
---|
398 | | - } |
---|
399 | | - if((retries >= 5)) |
---|
400 | | - { |
---|
401 | | - #if GTP_COMPATIBLE_MODE |
---|
402 | | - struct goodix_ts_data *ts = i2c_get_clientdata(client); |
---|
403 | | - #endif |
---|
404 | | - |
---|
405 | | - /*#if GTP_GESTURE_WAKEUP*/ |
---|
406 | | - if(gtp_gesture_wakeup){ |
---|
407 | | - /* reset chip would quit doze mode*/ |
---|
408 | | - if (DOZE_ENABLED == doze_status) |
---|
409 | | - { |
---|
410 | | - return ret; |
---|
411 | | - } |
---|
412 | | - } |
---|
413 | | - /* #endif*/ |
---|
414 | | - GTP_ERROR("I2C Read: 0x%04X, %d bytes failed, errcode: %d! Process reset.", (((u16)(buf[0] << 8)) | buf[1]), len-2, ret); |
---|
415 | | - #if GTP_COMPATIBLE_MODE |
---|
416 | | - if (CHIP_TYPE_GT9F == ts->chip_type) |
---|
417 | | - { |
---|
418 | | - gtp_recovery_reset(client); |
---|
419 | | - } |
---|
420 | | - else |
---|
421 | | - #endif |
---|
422 | | - { |
---|
423 | | - gtp_reset_guitar(client, 10); |
---|
424 | | - } |
---|
425 | | - } |
---|
426 | | - return ret; |
---|
| 291 | + if(retries >= 2) { |
---|
| 292 | + printk("%s:I2C retry timeout, reset chip.", __func__); |
---|
| 293 | + } |
---|
| 294 | + return ret; |
---|
427 | 295 | } |
---|
428 | 296 | |
---|
429 | | - |
---|
430 | | - |
---|
431 | | -/******************************************************* |
---|
| 297 | +/******************************************************* |
---|
432 | 298 | Function: |
---|
433 | | - Write data to the i2c slave device. |
---|
| 299 | +write data to the i2c slave device. |
---|
| 300 | + |
---|
434 | 301 | Input: |
---|
435 | | - client: i2c device. |
---|
436 | | - buf[0~1]: write start address. |
---|
437 | | - buf[2~len-1]: data buffer |
---|
438 | | - len: GTP_ADDR_LENGTH + write bytes count |
---|
| 302 | +client: i2c device. |
---|
| 303 | +buf[0]:operate address. |
---|
| 304 | +buf[1]~buf[len]:write data buffer. |
---|
| 305 | +len:operate length. |
---|
| 306 | + |
---|
439 | 307 | Output: |
---|
440 | | - numbers of i2c_msgs to transfer: |
---|
441 | | - 1: succeed, otherwise: failed |
---|
442 | | -*********************************************************/ |
---|
443 | | -s32 gtp_i2c_write(struct i2c_client *client, u8 *buf, s32 len) |
---|
| 308 | +numbers of i2c_msgs to transfer. |
---|
| 309 | + *********************************************************/ |
---|
| 310 | +s32 gtp_i2c_write(struct i2c_client *client,u8 *buf,s32 len) |
---|
444 | 311 | { |
---|
445 | | - struct i2c_msg msg; |
---|
446 | | - s32 ret = -1; |
---|
447 | | - s32 retries = 0; |
---|
| 312 | + struct i2c_msg msg; |
---|
| 313 | + s32 ret = -1; |
---|
| 314 | + s32 retries = 0; |
---|
448 | 315 | |
---|
449 | | - GTP_DEBUG_FUNC(); |
---|
| 316 | + msg.flags = !I2C_M_RD; |
---|
| 317 | + msg.addr = client->addr; |
---|
| 318 | + msg.len = len; |
---|
| 319 | + msg.buf = buf; |
---|
450 | 320 | |
---|
451 | | - msg.flags = !I2C_M_RD; |
---|
452 | | - msg.addr = client->addr; |
---|
453 | | - msg.len = len; |
---|
454 | | - msg.buf = buf; |
---|
455 | | - /*msg.scl_rate = 300 * 1000;*/ /* for Rockchip, etc*/ |
---|
| 321 | + while(retries < 2) { |
---|
| 322 | + ret = i2c_transfer(client->adapter, &msg, 1); |
---|
| 323 | + if (ret == 1) |
---|
| 324 | + break; |
---|
| 325 | + retries++; |
---|
| 326 | + } |
---|
456 | 327 | |
---|
457 | | - while(retries < 5) |
---|
458 | | - { |
---|
459 | | - ret = i2c_transfer(client->adapter, &msg, 1); |
---|
460 | | - if (ret == 1)break; |
---|
461 | | - retries++; |
---|
462 | | - } |
---|
463 | | - if((retries >= 5)) { |
---|
464 | | - #if GTP_COMPATIBLE_MODE |
---|
465 | | - struct goodix_ts_data *ts = i2c_get_clientdata(client); |
---|
466 | | - #endif |
---|
467 | | - |
---|
468 | | - /*#if GTP_GESTURE_WAKEUP*/ |
---|
469 | | - if(gtp_gesture_wakeup){ |
---|
470 | | - if (DOZE_ENABLED == doze_status) |
---|
471 | | - { |
---|
472 | | - return ret; |
---|
473 | | - } |
---|
474 | | - } |
---|
475 | | - /*#endif*/ |
---|
476 | | - GTP_ERROR("I2C Write: 0x%04X, %d bytes failed, errcode: %d! Process reset.", (((u16)(buf[0] << 8)) | buf[1]), len-2, ret); |
---|
477 | | - #if GTP_COMPATIBLE_MODE |
---|
478 | | - if (CHIP_TYPE_GT9F == ts->chip_type) |
---|
479 | | - { |
---|
480 | | - gtp_recovery_reset(client); |
---|
481 | | - } |
---|
482 | | - else |
---|
483 | | - #endif |
---|
484 | | - { |
---|
485 | | - gtp_reset_guitar(client, 10); |
---|
486 | | - } |
---|
487 | | - } |
---|
488 | | - return ret; |
---|
489 | | -} |
---|
490 | | - |
---|
491 | | - |
---|
492 | | -/******************************************************* |
---|
493 | | -Function: |
---|
494 | | - i2c read twice, compare the results |
---|
495 | | -Input: |
---|
496 | | - client: i2c device |
---|
497 | | - addr: operate address |
---|
498 | | - rxbuf: read data to store, if compare successful |
---|
499 | | - len: bytes to read |
---|
500 | | -Output: |
---|
501 | | - FAIL: read failed |
---|
502 | | - SUCCESS: read successful |
---|
503 | | -*********************************************************/ |
---|
504 | | -s32 gtp_i2c_read_dbl_check(struct i2c_client *client, u16 addr, u8 *rxbuf, int len) |
---|
505 | | -{ |
---|
506 | | - u8 buf[16] = {0}; |
---|
507 | | - u8 confirm_buf[16] = {0}; |
---|
508 | | - u8 retry = 0; |
---|
509 | | - |
---|
510 | | - while (retry++ < 3) |
---|
511 | | - { |
---|
512 | | - memset(buf, 0xAA, 16); |
---|
513 | | - buf[0] = (u8)(addr >> 8); |
---|
514 | | - buf[1] = (u8)(addr & 0xFF); |
---|
515 | | - gtp_i2c_read(client, buf, len + 2); |
---|
516 | | - |
---|
517 | | - memset(confirm_buf, 0xAB, 16); |
---|
518 | | - confirm_buf[0] = (u8)(addr >> 8); |
---|
519 | | - confirm_buf[1] = (u8)(addr & 0xFF); |
---|
520 | | - gtp_i2c_read(client, confirm_buf, len + 2); |
---|
521 | | - |
---|
522 | | - if (!memcmp(buf, confirm_buf, len+2)) |
---|
523 | | - { |
---|
524 | | - memcpy(rxbuf, confirm_buf+2, len); |
---|
525 | | - return SUCCESS; |
---|
526 | | - } |
---|
527 | | - } |
---|
528 | | - GTP_ERROR("I2C read 0x%04X, %d bytes, double check failed!", addr, len); |
---|
529 | | - return FAIL; |
---|
| 328 | + if(retries >= 2) { |
---|
| 329 | + printk("%s:I2C retry timeout, reset chip.", __func__); |
---|
| 330 | + } |
---|
| 331 | + return ret; |
---|
530 | 332 | } |
---|
531 | 333 | |
---|
532 | 334 | /******************************************************* |
---|
533 | 335 | Function: |
---|
534 | | - Send config. |
---|
535 | | -Input: |
---|
536 | | - client: i2c device. |
---|
537 | | -Output: |
---|
538 | | - result of i2c write operation. |
---|
539 | | - 1: succeed, otherwise: failed |
---|
540 | | -*********************************************************/ |
---|
| 336 | +Send config Function. |
---|
541 | 337 | |
---|
| 338 | +Input: |
---|
| 339 | +client: i2c client. |
---|
| 340 | + |
---|
| 341 | +Output: |
---|
| 342 | +Executive outcomes.0--success,non-0--fail. |
---|
| 343 | + *******************************************************/ |
---|
542 | 344 | s32 gtp_send_cfg(struct i2c_client *client) |
---|
543 | 345 | { |
---|
544 | | - s32 ret = 2; |
---|
| 346 | + s32 ret = 0; |
---|
545 | 347 | |
---|
546 | 348 | #if GTP_DRIVER_SEND_CFG |
---|
547 | | - s32 retry = 0; |
---|
548 | | - struct goodix_ts_data *ts = i2c_get_clientdata(client); |
---|
| 349 | + s32 retry = 0; |
---|
549 | 350 | |
---|
550 | | - if (ts->fixed_cfg) |
---|
551 | | - { |
---|
552 | | - GTP_INFO("Ic fixed config, no config sent!"); |
---|
553 | | - return 0; |
---|
554 | | - } |
---|
555 | | - else if (ts->pnl_init_error) |
---|
556 | | - { |
---|
557 | | - GTP_INFO("Error occured in init_panel, no config sent"); |
---|
558 | | - return 0; |
---|
559 | | - } |
---|
560 | | - |
---|
561 | | - GTP_INFO("Driver send config."); |
---|
562 | | - for (retry = 0; retry < 5; retry++) |
---|
563 | | - { |
---|
564 | | - ret = gtp_i2c_write(client, config , GTP_CONFIG_MAX_LENGTH + GTP_ADDR_LENGTH); |
---|
565 | | - if (ret > 0) |
---|
566 | | - { |
---|
567 | | - break; |
---|
568 | | - } |
---|
569 | | - } |
---|
| 351 | + for (retry = 0; retry < 5; retry++) |
---|
| 352 | + { |
---|
| 353 | + //ret = gtp_i2c_write(client, config , GTP_CONFIG_MAX_LENGTH + GTP_ADDR_LENGTH); |
---|
| 354 | + // if (ret > 0) |
---|
| 355 | + // { |
---|
| 356 | + // break; |
---|
| 357 | + // } |
---|
| 358 | + } |
---|
570 | 359 | #endif |
---|
571 | | - return ret; |
---|
| 360 | + |
---|
| 361 | + return ret; |
---|
572 | 362 | } |
---|
| 363 | + |
---|
573 | 364 | /******************************************************* |
---|
574 | 365 | Function: |
---|
575 | | - Disable irq function |
---|
| 366 | +Disable IRQ Function. |
---|
| 367 | + |
---|
576 | 368 | Input: |
---|
577 | | - ts: goodix i2c_client private data |
---|
| 369 | +ts: i2c client private struct. |
---|
| 370 | + |
---|
578 | 371 | Output: |
---|
579 | | - None. |
---|
580 | | -*********************************************************/ |
---|
| 372 | +None. |
---|
| 373 | + *******************************************************/ |
---|
581 | 374 | void gtp_irq_disable(struct goodix_ts_data *ts) |
---|
582 | 375 | { |
---|
583 | | - unsigned long irqflags; |
---|
| 376 | + unsigned long irqflags; |
---|
584 | 377 | int ret; |
---|
585 | 378 | |
---|
586 | | - GTP_DEBUG_FUNC(); |
---|
587 | | - |
---|
588 | | - dprintk(DEBUG_INT_INFO, "%s ---start!---\n", __func__); |
---|
589 | | - spin_lock_irqsave(&ts->irq_lock, irqflags); |
---|
590 | | - if (!ts->irq_is_disable) { |
---|
591 | | - ts->irq_is_disable = 1; |
---|
592 | | - ret = input_set_int_enable(&(config_info.input_type), 0); |
---|
593 | | - if (ret < 0) |
---|
594 | | - dprintk(DEBUG_OTHERS_INFO,"%s irq disable failed\n", goodix_ts_name); |
---|
595 | | - } |
---|
596 | | - spin_unlock_irqrestore(&ts->irq_lock, irqflags); |
---|
| 379 | + dprintk(DEBUG_INT_INFO, "%s ---start!---\n", __func__); |
---|
| 380 | + spin_lock_irqsave(&ts->irq_lock, irqflags); |
---|
| 381 | + if (!ts->irq_is_disable) { |
---|
| 382 | + ts->irq_is_disable = 1; |
---|
| 383 | + ret = input_set_int_enable(&(config_info.input_type), 0); |
---|
| 384 | + if (ret < 0) |
---|
| 385 | + dprintk(DEBUG_OTHERS_INFO,"%s irq disable failed\n", goodix_ts_name); |
---|
| 386 | + } |
---|
| 387 | + spin_unlock_irqrestore(&ts->irq_lock, irqflags); |
---|
597 | 388 | } |
---|
598 | 389 | |
---|
599 | 390 | /******************************************************* |
---|
600 | 391 | Function: |
---|
601 | | - Enable irq function |
---|
| 392 | +Disable IRQ Function. |
---|
| 393 | + |
---|
602 | 394 | Input: |
---|
603 | | - ts: goodix i2c_client private data |
---|
| 395 | +ts: i2c client private struct. |
---|
| 396 | + |
---|
604 | 397 | Output: |
---|
605 | | - None. |
---|
606 | | -*********************************************************/ |
---|
| 398 | +None. |
---|
| 399 | + *******************************************************/ |
---|
607 | 400 | void gtp_irq_enable(struct goodix_ts_data *ts) |
---|
608 | 401 | { |
---|
609 | | - unsigned long irqflags = 0; |
---|
610 | | - int ret; |
---|
| 402 | + unsigned long irqflags = 0; |
---|
| 403 | + int ret; |
---|
611 | 404 | |
---|
612 | | - GTP_DEBUG_FUNC(); |
---|
| 405 | + dprintk(DEBUG_INT_INFO, "%s ---start!---\n", __func__); |
---|
613 | 406 | |
---|
614 | | - spin_lock_irqsave(&ts->irq_lock, irqflags); |
---|
615 | | - if (ts->irq_is_disable) { |
---|
616 | | - ts->irq_is_disable = 0; |
---|
617 | | - ret = input_set_int_enable(&(config_info.input_type), 1); |
---|
618 | | - if (ret < 0) |
---|
619 | | - dprintk(DEBUG_OTHERS_INFO,"%s irq enable failed\n", goodix_ts_name); |
---|
620 | | - } |
---|
621 | | - spin_unlock_irqrestore(&ts->irq_lock, irqflags); |
---|
| 407 | + spin_lock_irqsave(&ts->irq_lock, irqflags); |
---|
| 408 | + if (ts->irq_is_disable) { |
---|
| 409 | + ts->irq_is_disable = 0; |
---|
| 410 | + ret = input_set_int_enable(&(config_info.input_type), 1); |
---|
| 411 | + if (ret < 0) |
---|
| 412 | + dprintk(DEBUG_OTHERS_INFO,"%s irq enable failed\n", goodix_ts_name); |
---|
| 413 | + } |
---|
| 414 | + spin_unlock_irqrestore(&ts->irq_lock, irqflags); |
---|
622 | 415 | } |
---|
623 | | - |
---|
624 | 416 | |
---|
625 | 417 | /******************************************************* |
---|
626 | 418 | Function: |
---|
627 | | - Report touch point event |
---|
| 419 | +Touch down report function. |
---|
| 420 | + |
---|
628 | 421 | Input: |
---|
629 | | - ts: goodix i2c_client private data |
---|
630 | | - id: trackId |
---|
631 | | - x: input x coordinate |
---|
632 | | - y: input y coordinate |
---|
633 | | - w: input pressure |
---|
| 422 | +ts:private data. |
---|
| 423 | +id:tracking id. |
---|
| 424 | +x:input x. |
---|
| 425 | +y:input y. |
---|
| 426 | +w:input weight. |
---|
| 427 | + |
---|
634 | 428 | Output: |
---|
635 | | - None. |
---|
636 | | -*********************************************************/ |
---|
| 429 | +None. |
---|
| 430 | + *******************************************************/ |
---|
637 | 431 | static void gtp_touch_down(struct goodix_ts_data* ts,s32 id,s32 x,s32 y,s32 w) |
---|
638 | 432 | { |
---|
639 | | - dprintk(DEBUG_X_Y_INFO, "source data:ID:%d, X:%d, Y:%d, W:%d\n", id, x, y, w); |
---|
640 | | - if(1 == exchange_x_y_flag){ |
---|
641 | | - swap(x, y); |
---|
642 | | - } |
---|
643 | | - if(1 == revert_x_flag){ |
---|
644 | | - x = SCREEN_MAX_X - x; |
---|
645 | | - } |
---|
646 | | - if(1 == revert_y_flag){ |
---|
647 | | - y = SCREEN_MAX_Y - y; |
---|
648 | | - } |
---|
649 | | - dprintk(DEBUG_X_Y_INFO,"report data:ID:%d, X:%d, Y:%d, W:%d\n", id, x, y, w); |
---|
| 433 | + dprintk(DEBUG_X_Y_INFO, "source data:ID:%d, X:%d, Y:%d, W:%d\n", id, x, y, w); |
---|
| 434 | + |
---|
| 435 | + //printk(KERN_ERR"revert_x_flag=%d, revert_y_flag=%d, GTP_ICS_SLOT_REPORT=%d V2 SCREEN_MAX_X:SCREEN_MAX_Y=%d:%d\n", revert_x_flag, revert_y_flag, GTP_ICS_SLOT_REPORT, SCREEN_MAX_X, SCREEN_MAX_Y); |
---|
| 436 | + |
---|
| 437 | + if(1 == exchange_x_y_flag){ |
---|
| 438 | + swap(x, y); |
---|
| 439 | + } |
---|
| 440 | + |
---|
| 441 | + if(1 == revert_x_flag){ |
---|
| 442 | + x = SCREEN_MAX_X - x; |
---|
| 443 | + } |
---|
| 444 | + |
---|
| 445 | + if(1 == revert_y_flag){ |
---|
| 446 | + y = SCREEN_MAX_Y - y; |
---|
| 447 | + } |
---|
| 448 | + |
---|
| 449 | + dprintk(DEBUG_X_Y_INFO,"report data:ID:%d, X:%d, Y:%d, W:%d\n", id, x, y, w); |
---|
650 | 450 | |
---|
651 | 451 | #if GTP_ICS_SLOT_REPORT |
---|
652 | | - input_mt_slot(ts->input_dev, id); |
---|
653 | | - input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, id); |
---|
654 | | - input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x); |
---|
655 | | - input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y); |
---|
656 | | - input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, w); |
---|
657 | | - input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, w); |
---|
| 452 | + input_mt_slot(ts->input_dev, id); |
---|
| 453 | + input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, id); |
---|
| 454 | + input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x); |
---|
| 455 | + input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y); |
---|
| 456 | + input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, w); |
---|
| 457 | + input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, w); |
---|
658 | 458 | #else |
---|
659 | | - input_report_key(ts->input_dev, BTN_TOUCH, 1); |
---|
660 | | - input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x); |
---|
661 | | - input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y); |
---|
662 | | - input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, w); |
---|
663 | | - input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, w); |
---|
664 | | - input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, id); |
---|
665 | | - input_mt_sync(ts->input_dev); |
---|
| 459 | + input_report_key(ts->input_dev, BTN_TOUCH, 1); |
---|
| 460 | + input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, id); |
---|
| 461 | + input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x); |
---|
| 462 | + input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y); |
---|
| 463 | + input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, w); |
---|
| 464 | + input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, w); |
---|
| 465 | + input_mt_sync(ts->input_dev); |
---|
666 | 466 | #endif |
---|
667 | 467 | |
---|
668 | | - GTP_DEBUG("ID:%d, X:%d, Y:%d, W:%d", id, x, y, w); |
---|
669 | 468 | } |
---|
670 | 469 | |
---|
671 | 470 | /******************************************************* |
---|
672 | 471 | Function: |
---|
673 | | - Report touch release event |
---|
| 472 | +Touch up report function. |
---|
| 473 | + |
---|
674 | 474 | Input: |
---|
675 | | - ts: goodix i2c_client private data |
---|
| 475 | +ts:private data. |
---|
| 476 | + |
---|
676 | 477 | Output: |
---|
677 | | - None. |
---|
678 | | -*********************************************************/ |
---|
| 478 | +None. |
---|
| 479 | + *******************************************************/ |
---|
679 | 480 | static void gtp_touch_up(struct goodix_ts_data* ts, s32 id) |
---|
680 | 481 | { |
---|
681 | 482 | #if GTP_ICS_SLOT_REPORT |
---|
682 | | - input_mt_slot(ts->input_dev, id); |
---|
683 | | - input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, -1); |
---|
684 | | - GTP_DEBUG("Touch id[%2d] release!", id); |
---|
| 483 | + input_mt_slot(ts->input_dev, id); |
---|
| 484 | + input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, -1); |
---|
| 485 | + dprintk(DEBUG_X_Y_INFO, "Touch id[%2d] release!", id); |
---|
685 | 486 | #else |
---|
686 | | - input_report_key(ts->input_dev, BTN_TOUCH, 0); |
---|
| 487 | + input_report_key(ts->input_dev, BTN_TOUCH, 0); |
---|
| 488 | + input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0); |
---|
| 489 | + input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0); |
---|
| 490 | + input_mt_sync(ts->input_dev); |
---|
687 | 491 | #endif |
---|
688 | 492 | } |
---|
689 | | - |
---|
690 | | -#if GTP_WITH_PEN |
---|
691 | | - |
---|
692 | | -static void gtp_pen_init(struct goodix_ts_data *ts) |
---|
693 | | -{ |
---|
694 | | - s32 ret = 0; |
---|
695 | | - |
---|
696 | | - GTP_INFO("Request input device for pen/stylus."); |
---|
697 | | - |
---|
698 | | - ts->pen_dev = input_allocate_device(); |
---|
699 | | - if (ts->pen_dev == NULL) |
---|
700 | | - { |
---|
701 | | - GTP_ERROR("Failed to allocate input device for pen/stylus."); |
---|
702 | | - return; |
---|
703 | | - } |
---|
704 | | - |
---|
705 | | - ts->pen_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) ; |
---|
706 | | - |
---|
707 | | -#if GTP_ICS_SLOT_REPORT |
---|
708 | | - input_mt_init_slots(ts->pen_dev, 16); // |
---|
709 | | -#else |
---|
710 | | - ts->pen_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
---|
711 | | -#endif |
---|
712 | | - |
---|
713 | | - set_bit(BTN_TOOL_PEN, ts->pen_dev->keybit); |
---|
714 | | - set_bit(INPUT_PROP_DIRECT, ts->pen_dev->propbit); |
---|
715 | | - //set_bit(INPUT_PROP_POINTER, ts->pen_dev->propbit); |
---|
716 | | - |
---|
717 | | -#if GTP_PEN_HAVE_BUTTON |
---|
718 | | - input_set_capability(ts->pen_dev, EV_KEY, BTN_STYLUS); |
---|
719 | | - input_set_capability(ts->pen_dev, EV_KEY, BTN_STYLUS2); |
---|
720 | | -#endif |
---|
721 | | - |
---|
722 | | - input_set_abs_params(ts->pen_dev, ABS_MT_POSITION_X, 0, ts->abs_x_max, 0, 0); |
---|
723 | | - input_set_abs_params(ts->pen_dev, ABS_MT_POSITION_Y, 0, ts->abs_y_max, 0, 0); |
---|
724 | | - input_set_abs_params(ts->pen_dev, ABS_MT_PRESSURE, 0, 255, 0, 0); |
---|
725 | | - input_set_abs_params(ts->pen_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); |
---|
726 | | - input_set_abs_params(ts->pen_dev, ABS_MT_TRACKING_ID, 0, 255, 0, 0); |
---|
727 | | - |
---|
728 | | - ts->pen_dev->name = "goodix-pen"; |
---|
729 | | - ts->pen_dev->id.bustype = BUS_I2C; |
---|
730 | | - |
---|
731 | | - ret = input_register_device(ts->pen_dev); |
---|
732 | | - if (ret) |
---|
733 | | - { |
---|
734 | | - GTP_ERROR("Register %s input device failed", ts->pen_dev->name); |
---|
735 | | - return; |
---|
736 | | - } |
---|
737 | | -} |
---|
738 | | - |
---|
739 | | -static void gtp_pen_down(s32 x, s32 y, s32 w, s32 id) |
---|
740 | | -{ |
---|
741 | | - struct goodix_ts_data *ts = i2c_get_clientdata(i2c_connect_client); |
---|
742 | | - |
---|
743 | | -#if GTP_CHANGE_X2Y |
---|
744 | | - GTP_SWAP(x, y); |
---|
745 | | -#endif |
---|
746 | | - |
---|
747 | | - input_report_key(ts->pen_dev, BTN_TOOL_PEN, 1); |
---|
748 | | -#if GTP_ICS_SLOT_REPORT |
---|
749 | | - input_mt_slot(ts->pen_dev, id); |
---|
750 | | - input_report_abs(ts->pen_dev, ABS_MT_TRACKING_ID, id); |
---|
751 | | - input_report_abs(ts->pen_dev, ABS_MT_POSITION_X, x); |
---|
752 | | - input_report_abs(ts->pen_dev, ABS_MT_POSITION_Y, y); |
---|
753 | | - input_report_abs(ts->pen_dev, ABS_MT_PRESSURE, w); |
---|
754 | | - input_report_abs(ts->pen_dev, ABS_MT_TOUCH_MAJOR, w); |
---|
755 | | -#else |
---|
756 | | - input_report_key(ts->pen_dev, BTN_TOUCH, 1); |
---|
757 | | - input_report_abs(ts->pen_dev, ABS_MT_POSITION_X, x); |
---|
758 | | - input_report_abs(ts->pen_dev, ABS_MT_POSITION_Y, y); |
---|
759 | | - input_report_abs(ts->pen_dev, ABS_MT_PRESSURE, w); |
---|
760 | | - input_report_abs(ts->pen_dev, ABS_MT_TOUCH_MAJOR, w); |
---|
761 | | - input_report_abs(ts->pen_dev, ABS_MT_TRACKING_ID, id); |
---|
762 | | - input_mt_sync(ts->pen_dev); |
---|
763 | | -#endif |
---|
764 | | - GTP_DEBUG("(%d)(%d, %d)[%d]", id, x, y, w); |
---|
765 | | -} |
---|
766 | | - |
---|
767 | | -static void gtp_pen_up(s32 id) |
---|
768 | | -{ |
---|
769 | | - struct goodix_ts_data *ts = i2c_get_clientdata(i2c_connect_client); |
---|
770 | | - |
---|
771 | | - input_report_key(ts->pen_dev, BTN_TOOL_PEN, 0); |
---|
772 | | - |
---|
773 | | -#if GTP_ICS_SLOT_REPORT |
---|
774 | | - input_mt_slot(ts->pen_dev, id); |
---|
775 | | - input_report_abs(ts->pen_dev, ABS_MT_TRACKING_ID, -1); |
---|
776 | | -#else |
---|
777 | | - |
---|
778 | | - input_report_key(ts->pen_dev, BTN_TOUCH, 0); |
---|
779 | | -#endif |
---|
780 | | - |
---|
781 | | -} |
---|
782 | | -#endif |
---|
783 | 493 | |
---|
784 | 494 | /******************************************************* |
---|
785 | 495 | Function: |
---|
786 | | - Goodix touchscreen work function |
---|
| 496 | +Goodix touchscreen work function. |
---|
| 497 | + |
---|
787 | 498 | Input: |
---|
788 | | - work: work struct of goodix_workqueue |
---|
| 499 | +work: work_struct of goodix_wq. |
---|
| 500 | + |
---|
789 | 501 | Output: |
---|
790 | | - None. |
---|
791 | | -*********************************************************/ |
---|
| 502 | +None. |
---|
| 503 | + *******************************************************/ |
---|
792 | 504 | static void goodix_ts_work_func(struct work_struct *work) |
---|
793 | 505 | { |
---|
794 | | - u8 end_cmd[3] = {GTP_READ_COOR_ADDR >> 8, GTP_READ_COOR_ADDR & 0xFF, 0}; |
---|
795 | | - u8 point_data[2 + 1 + 8 * GTP_MAX_TOUCH + 1]={GTP_READ_COOR_ADDR >> 8, GTP_READ_COOR_ADDR & 0xFF}; |
---|
796 | | - u8 touch_num = 0; |
---|
797 | | - u8 finger = 0; |
---|
798 | | - static u16 pre_touch = 0; |
---|
799 | | - static u8 pre_key = 0; |
---|
800 | | -#if GTP_WITH_PEN |
---|
801 | | - u8 pen_active = 0; |
---|
802 | | - static u8 pre_pen = 0; |
---|
803 | | -#endif |
---|
804 | | - u8 key_value = 0; |
---|
805 | | - u8* coor_data = NULL; |
---|
806 | | - s32 input_x = 0; |
---|
807 | | - s32 input_y = 0; |
---|
808 | | - s32 input_w = 0; |
---|
809 | | - s32 id = 0; |
---|
810 | | - s32 i = 0; |
---|
811 | | - s32 ret = -1; |
---|
812 | | - struct goodix_ts_data *ts = NULL; |
---|
| 506 | + u8 end_cmd[3] = {GTP_READ_COOR_ADDR >> 8, GTP_READ_COOR_ADDR & 0xFF, 0}; |
---|
| 507 | + u8 point_data[2 + 1 + 8 * GTP_MAX_TOUCH + 1]={GTP_READ_COOR_ADDR >> 8, GTP_READ_COOR_ADDR & 0xFF}; |
---|
| 508 | + u8 touch_num = 0; |
---|
| 509 | + u8 finger = 0; |
---|
| 510 | + static u16 pre_touch = 0; |
---|
| 511 | + static u8 pre_key = 0; |
---|
| 512 | + u8 key_value = 0; |
---|
| 513 | + u8* coor_data = NULL; |
---|
| 514 | + s32 input_x = 0; |
---|
| 515 | + s32 input_y = 0; |
---|
| 516 | + s32 input_w = 0; |
---|
| 517 | + s32 id = 0; |
---|
| 518 | + s32 i = 0; |
---|
| 519 | + int j = 0; |
---|
| 520 | + s32 ret = -1; |
---|
| 521 | + struct goodix_ts_data *ts = NULL; |
---|
813 | 522 | |
---|
814 | | -#if GTP_COMPATIBLE_MODE |
---|
815 | | - u8 rqst_buf[3] = {0x80, 0x43}; // for GT9XXF |
---|
816 | | -#endif |
---|
| 523 | + dprintk(DEBUG_X_Y_INFO,"===enter %s===\n",__func__); |
---|
817 | 524 | |
---|
818 | | -//#if GTP_GESTURE_WAKEUP |
---|
819 | | - u8 doze_buf[3] = {0x81, 0x4B}; |
---|
820 | | -//#endif |
---|
| 525 | + ts = container_of(work, struct goodix_ts_data, work); |
---|
| 526 | + if (ts->enter_update){ |
---|
| 527 | + return; |
---|
| 528 | + } |
---|
821 | 529 | |
---|
822 | | - GTP_DEBUG_FUNC(); |
---|
823 | | - dprintk(DEBUG_X_Y_INFO,"===enter %s===\n",__func__); |
---|
824 | | - ts = container_of(work, struct goodix_ts_data, work); |
---|
825 | | - if (ts->enter_update) |
---|
826 | | - { |
---|
827 | | - return; |
---|
828 | | - } |
---|
829 | | -//#if GTP_GESTURE_WAKEUP |
---|
830 | | -if(gtp_gesture_wakeup){ |
---|
831 | | - if (DOZE_ENABLED == doze_status) |
---|
832 | | - { |
---|
833 | | - ret = gtp_i2c_read(i2c_connect_client, doze_buf, 3); |
---|
834 | | - GTP_DEBUG("0x814B = 0x%02X", doze_buf[2]); |
---|
835 | | - if (ret > 0) |
---|
836 | | - { |
---|
837 | | - if ((doze_buf[2] == 'a') || (doze_buf[2] == 'b') || (doze_buf[2] == 'c') || |
---|
838 | | - (doze_buf[2] == 'd') || (doze_buf[2] == 'e') || (doze_buf[2] == 'g') || |
---|
839 | | - (doze_buf[2] == 'h') || (doze_buf[2] == 'm') || (doze_buf[2] == 'o') || |
---|
840 | | - (doze_buf[2] == 'q') || (doze_buf[2] == 's') || (doze_buf[2] == 'v') || |
---|
841 | | - (doze_buf[2] == 'w') || (doze_buf[2] == 'y') || (doze_buf[2] == 'z') || |
---|
842 | | - (doze_buf[2] == 0x5E) /* ^ */ |
---|
843 | | - ) |
---|
844 | | - { |
---|
845 | | - if (doze_buf[2] != 0x5E) |
---|
846 | | - { |
---|
847 | | - GTP_INFO("Wakeup by gesture(%c), light up the screen!", doze_buf[2]); |
---|
848 | | - } |
---|
849 | | - else |
---|
850 | | - { |
---|
851 | | - GTP_INFO("Wakeup by gesture(^), light up the screen!"); |
---|
852 | | - } |
---|
853 | | - doze_status = DOZE_WAKEUP; |
---|
854 | | - input_report_key(ts->input_dev, KEY_POWER, 1); |
---|
855 | | - input_sync(ts->input_dev); |
---|
856 | | - input_report_key(ts->input_dev, KEY_POWER, 0); |
---|
857 | | - input_sync(ts->input_dev); |
---|
858 | | - switch(doze_buf[2]) { |
---|
859 | | - case 'e': |
---|
860 | | - input_report_key(ts->input_dev, ctp_key_list[0], 1); |
---|
861 | | - input_sync(ts->input_dev); |
---|
862 | | - input_report_key(ts->input_dev, ctp_key_list[0], 0); |
---|
863 | | - input_sync(ts->input_dev); |
---|
864 | | - break; |
---|
865 | | - case 'o': |
---|
866 | | - input_report_key(ts->input_dev, ctp_key_list[1], 1); |
---|
867 | | - input_sync(ts->input_dev); |
---|
868 | | - input_report_key(ts->input_dev, ctp_key_list[1], 0); |
---|
869 | | - input_sync(ts->input_dev); |
---|
870 | | - break; |
---|
871 | | - case 'w': |
---|
872 | | - input_report_key(ts->input_dev, ctp_key_list[3], 1); |
---|
873 | | - input_sync(ts->input_dev); |
---|
874 | | - input_report_key(ts->input_dev, ctp_key_list[3], 0); |
---|
875 | | - input_sync(ts->input_dev); |
---|
876 | | - break; |
---|
877 | | - case 'c': |
---|
878 | | - input_report_key(ts->input_dev, ctp_key_list[2], 1); |
---|
879 | | - input_sync(ts->input_dev); |
---|
880 | | - input_report_key(ts->input_dev, ctp_key_list[2], 0); |
---|
881 | | - input_sync(ts->input_dev); |
---|
882 | | - break; |
---|
883 | | - default: |
---|
884 | | - break; |
---|
| 530 | + for(j=0; j<2;j++) |
---|
| 531 | + { |
---|
| 532 | + ret = gtp_i2c_read(ts->client, point_data, 12); |
---|
| 533 | + if (ret < 0){ |
---|
| 534 | + printk("I2C transfer error. errno:%d\n ", ret); |
---|
| 535 | + goto exit_work_func; |
---|
885 | 536 | } |
---|
886 | | - // clear 0x814B |
---|
887 | | - doze_buf[2] = 0x00; |
---|
888 | | - gtp_i2c_write(i2c_connect_client, doze_buf, 3); |
---|
889 | | - } |
---|
890 | | - else if ( (doze_buf[2] == 0xAA) || (doze_buf[2] == 0xBB) || |
---|
891 | | - (doze_buf[2] == 0xAB) || (doze_buf[2] == 0xBA) ) |
---|
892 | | - { |
---|
893 | | - char *direction[4] = {"Right", "Down", "Up", "Left"}; |
---|
894 | | - u8 type = ((doze_buf[2] & 0x0F) - 0x0A) + (((doze_buf[2] >> 4) & 0x0F) - 0x0A) * 2; |
---|
| 537 | + } |
---|
895 | 538 | |
---|
896 | | - GTP_INFO("%s slide to light up the screen!", direction[type]); |
---|
897 | | - doze_status = DOZE_WAKEUP; |
---|
898 | | - input_report_key(ts->input_dev, KEY_POWER, 1); |
---|
899 | | - input_sync(ts->input_dev); |
---|
900 | | - input_report_key(ts->input_dev, KEY_POWER, 0); |
---|
901 | | - input_sync(ts->input_dev); |
---|
902 | | - switch(type) { |
---|
903 | | - case 0: |
---|
904 | | - input_report_key(ts->input_dev, ctp_key_list[7], 1); |
---|
905 | | - input_sync(ts->input_dev); |
---|
906 | | - input_report_key(ts->input_dev, ctp_key_list[7], 0); |
---|
907 | | - input_sync(ts->input_dev); |
---|
908 | | - break; |
---|
909 | | - case 1: |
---|
910 | | - input_report_key(ts->input_dev, ctp_key_list[5], 1); |
---|
911 | | - input_sync(ts->input_dev); |
---|
912 | | - input_report_key(ts->input_dev, ctp_key_list[5], 0); |
---|
913 | | - input_sync(ts->input_dev); |
---|
914 | | - break; |
---|
915 | | - case 2: |
---|
916 | | - input_report_key(ts->input_dev, ctp_key_list[4], 1); |
---|
917 | | - input_sync(ts->input_dev); |
---|
918 | | - input_report_key(ts->input_dev, ctp_key_list[4], 0); |
---|
919 | | - input_sync(ts->input_dev); |
---|
920 | | - break; |
---|
921 | | - case 3: |
---|
922 | | - input_report_key(ts->input_dev, ctp_key_list[6], 1); |
---|
923 | | - input_sync(ts->input_dev); |
---|
924 | | - input_report_key(ts->input_dev, ctp_key_list[6], 0); |
---|
925 | | - input_sync(ts->input_dev); |
---|
926 | | - break; |
---|
927 | | - default: |
---|
928 | | - break; |
---|
929 | | - } |
---|
930 | | - // clear 0x814B |
---|
931 | | - doze_buf[2] = 0x00; |
---|
932 | | - gtp_i2c_write(i2c_connect_client, doze_buf, 3); |
---|
933 | | - } |
---|
934 | | - else if (0xCC == doze_buf[2]) |
---|
935 | | - { |
---|
936 | | - GTP_INFO("Double click to light up the screen!"); |
---|
937 | | - doze_status = DOZE_WAKEUP; |
---|
938 | | - input_report_key(ts->input_dev, KEY_POWER, 1); |
---|
939 | | - input_sync(ts->input_dev); |
---|
940 | | - input_report_key(ts->input_dev, KEY_POWER, 0); |
---|
941 | | - input_sync(ts->input_dev); |
---|
942 | | - // clear 0x814B |
---|
943 | | - doze_buf[2] = 0x00; |
---|
944 | | - gtp_i2c_write(i2c_connect_client, doze_buf, 3); |
---|
945 | | - } |
---|
946 | | - else |
---|
947 | | - { |
---|
948 | | - // clear 0x814B |
---|
949 | | - doze_buf[2] = 0x00; |
---|
950 | | - gtp_i2c_write(i2c_connect_client, doze_buf, 3); |
---|
951 | | - gtp_enter_doze(ts); |
---|
952 | | - } |
---|
953 | | - } |
---|
954 | | - if (ts->use_irq) |
---|
955 | | - { |
---|
956 | | - gtp_irq_enable(ts); |
---|
957 | | - } |
---|
958 | | - return; |
---|
959 | | - } |
---|
960 | | -} |
---|
961 | | -//#endif |
---|
| 539 | + finger = point_data[GTP_ADDR_LENGTH]; |
---|
| 540 | + if((finger & 0x80) == 0) { |
---|
| 541 | + goto exit_work_func; |
---|
| 542 | + } |
---|
962 | 543 | |
---|
963 | | - ret = gtp_i2c_read(ts->client, point_data, 12); |
---|
964 | | - if (ret < 0) |
---|
965 | | - { |
---|
966 | | - GTP_ERROR("I2C transfer error. errno:%d\n ", ret); |
---|
967 | | - if (ts->use_irq) |
---|
968 | | - { |
---|
969 | | - gtp_irq_enable(ts); |
---|
970 | | - } |
---|
971 | | - return; |
---|
972 | | - } |
---|
| 544 | + touch_num = finger & 0x0f; |
---|
| 545 | + if (touch_num > GTP_MAX_TOUCH) { |
---|
| 546 | + goto exit_work_func; |
---|
| 547 | + } |
---|
973 | 548 | |
---|
974 | | - finger = point_data[GTP_ADDR_LENGTH]; |
---|
| 549 | + if (touch_num > 1) { |
---|
| 550 | + u8 buf[8 * GTP_MAX_TOUCH] = {(GTP_READ_COOR_ADDR + 10) >> 8, (GTP_READ_COOR_ADDR + 10) & 0xff}; |
---|
975 | 551 | |
---|
976 | | -#if GTP_COMPATIBLE_MODE |
---|
977 | | - // GT9XXF |
---|
978 | | - if ((finger == 0x00) && (CHIP_TYPE_GT9F == ts->chip_type)) // request arrived |
---|
979 | | - { |
---|
980 | | - ret = gtp_i2c_read(ts->client, rqst_buf, 3); |
---|
981 | | - if (ret < 0) |
---|
982 | | - { |
---|
983 | | - GTP_ERROR("Read request status error!"); |
---|
984 | | - goto exit_work_func; |
---|
985 | | - } |
---|
| 552 | + ret = gtp_i2c_read(ts->client, buf, 2 + 8 * (touch_num - 1)); |
---|
| 553 | + memcpy(&point_data[12], &buf[2], 8 * (touch_num - 1)); |
---|
| 554 | + } |
---|
986 | 555 | |
---|
987 | | - switch (rqst_buf[2]) |
---|
988 | | - { |
---|
989 | | - case GTP_RQST_CONFIG: |
---|
990 | | - GTP_INFO("Request for config."); |
---|
991 | | - ret = gtp_send_cfg(ts->client); |
---|
992 | | - if (ret < 0) |
---|
993 | | - { |
---|
994 | | - GTP_ERROR("Request for config unresponded!"); |
---|
995 | | - } |
---|
996 | | - else |
---|
997 | | - { |
---|
998 | | - rqst_buf[2] = GTP_RQST_RESPONDED; |
---|
999 | | - gtp_i2c_write(ts->client, rqst_buf, 3); |
---|
1000 | | - GTP_INFO("Request for config responded!"); |
---|
1001 | | - } |
---|
1002 | | - break; |
---|
| 556 | +#if GTP_HAVE_TOUCH_KEY |
---|
| 557 | + key_value = point_data[3 + 8 * touch_num]; |
---|
1003 | 558 | |
---|
1004 | | - case GTP_RQST_BAK_REF: |
---|
1005 | | - GTP_INFO("Request for backup reference."); |
---|
1006 | | - ts->rqst_processing = 1; |
---|
1007 | | - ret = gtp_bak_ref_proc(ts, GTP_BAK_REF_SEND); |
---|
1008 | | - if (SUCCESS == ret) |
---|
1009 | | - { |
---|
1010 | | - rqst_buf[2] = GTP_RQST_RESPONDED; |
---|
1011 | | - gtp_i2c_write(ts->client, rqst_buf, 3); |
---|
1012 | | - ts->rqst_processing = 0; |
---|
1013 | | - GTP_INFO("Request for backup reference responded!"); |
---|
1014 | | - } |
---|
1015 | | - else |
---|
1016 | | - { |
---|
1017 | | - GTP_ERROR("Requeset for backup reference unresponed!"); |
---|
1018 | | - } |
---|
1019 | | - break; |
---|
1020 | | - |
---|
1021 | | - case GTP_RQST_RESET: |
---|
1022 | | - GTP_INFO("Request for reset."); |
---|
1023 | | - gtp_recovery_reset(ts->client); |
---|
1024 | | - break; |
---|
1025 | | - |
---|
1026 | | - case GTP_RQST_MAIN_CLOCK: |
---|
1027 | | - GTP_INFO("Request for main clock."); |
---|
1028 | | - ts->rqst_processing = 1; |
---|
1029 | | - ret = gtp_main_clk_proc(ts); |
---|
1030 | | - if (FAIL == ret) |
---|
1031 | | - { |
---|
1032 | | - GTP_ERROR("Request for main clock unresponded!"); |
---|
1033 | | - } |
---|
1034 | | - else |
---|
1035 | | - { |
---|
1036 | | - GTP_INFO("Request for main clock responded!"); |
---|
1037 | | - rqst_buf[2] = GTP_RQST_RESPONDED; |
---|
1038 | | - gtp_i2c_write(ts->client, rqst_buf, 3); |
---|
1039 | | - ts->rqst_processing = 0; |
---|
1040 | | - ts->clk_chk_fs_times = 0; |
---|
1041 | | - } |
---|
1042 | | - break; |
---|
1043 | | - |
---|
1044 | | - default: |
---|
1045 | | - GTP_INFO("Undefined request: 0x%02X", rqst_buf[2]); |
---|
1046 | | - rqst_buf[2] = GTP_RQST_RESPONDED; |
---|
1047 | | - gtp_i2c_write(ts->client, rqst_buf, 3); |
---|
1048 | | - break; |
---|
1049 | | - } |
---|
1050 | | - } |
---|
| 559 | + if(key_value || pre_key) { |
---|
| 560 | + for (i = 0; i < GTP_MAX_KEY_NUM; i++) { |
---|
| 561 | + input_report_key(ts->input_dev, touch_key_array[i], key_value & (0x01<<i)); |
---|
| 562 | + } |
---|
| 563 | + touch_num = 0; |
---|
| 564 | + pre_touch = 0; |
---|
| 565 | + } |
---|
1051 | 566 | #endif |
---|
1052 | | - if (finger == 0x00) |
---|
1053 | | - { |
---|
1054 | | - if (ts->use_irq) |
---|
1055 | | - { |
---|
1056 | | - gtp_irq_enable(ts); |
---|
1057 | | - } |
---|
1058 | | - return; |
---|
1059 | | - } |
---|
| 567 | + pre_key = key_value; |
---|
1060 | 568 | |
---|
1061 | | - if((finger & 0x80) == 0) |
---|
1062 | | - { |
---|
1063 | | - goto exit_work_func; |
---|
1064 | | - } |
---|
1065 | | - |
---|
1066 | | - touch_num = finger & 0x0f; |
---|
1067 | | - if (touch_num > GTP_MAX_TOUCH) |
---|
1068 | | - { |
---|
1069 | | - goto exit_work_func; |
---|
1070 | | - } |
---|
1071 | | - |
---|
1072 | | - if (touch_num > 1) |
---|
1073 | | - { |
---|
1074 | | - u8 buf[8 * GTP_MAX_TOUCH] = {(GTP_READ_COOR_ADDR + 10) >> 8, (GTP_READ_COOR_ADDR + 10) & 0xff}; |
---|
1075 | | - |
---|
1076 | | - ret = gtp_i2c_read(ts->client, buf, 2 + 8 * (touch_num - 1)); |
---|
1077 | | - memcpy(&point_data[12], &buf[2], 8 * (touch_num - 1)); |
---|
1078 | | - } |
---|
1079 | | - |
---|
1080 | | -#if (GTP_HAVE_TOUCH_KEY || GTP_PEN_HAVE_BUTTON) |
---|
1081 | | - key_value = point_data[3 + 8 * touch_num]; |
---|
1082 | | - |
---|
1083 | | - if(key_value || pre_key) |
---|
1084 | | - { |
---|
1085 | | - #if GTP_PEN_HAVE_BUTTON |
---|
1086 | | - if (key_value == 0x40) |
---|
1087 | | - { |
---|
1088 | | - GTP_DEBUG("BTN_STYLUS & BTN_STYLUS2 Down."); |
---|
1089 | | - input_report_key(ts->pen_dev, BTN_STYLUS, 1); |
---|
1090 | | - input_report_key(ts->pen_dev, BTN_STYLUS2, 1); |
---|
1091 | | - pen_active = 1; |
---|
1092 | | - } |
---|
1093 | | - else if (key_value == 0x10) |
---|
1094 | | - { |
---|
1095 | | - GTP_DEBUG("BTN_STYLUS Down, BTN_STYLUS2 Up."); |
---|
1096 | | - input_report_key(ts->pen_dev, BTN_STYLUS, 1); |
---|
1097 | | - input_report_key(ts->pen_dev, BTN_STYLUS2, 0); |
---|
1098 | | - pen_active = 1; |
---|
1099 | | - } |
---|
1100 | | - else if (key_value == 0x20) |
---|
1101 | | - { |
---|
1102 | | - GTP_DEBUG("BTN_STYLUS Up, BTN_STYLUS2 Down."); |
---|
1103 | | - input_report_key(ts->pen_dev, BTN_STYLUS, 0); |
---|
1104 | | - input_report_key(ts->pen_dev, BTN_STYLUS2, 1); |
---|
1105 | | - pen_active = 1; |
---|
1106 | | - } |
---|
1107 | | - else |
---|
1108 | | - { |
---|
1109 | | - GTP_DEBUG("BTN_STYLUS & BTN_STYLUS2 Up."); |
---|
1110 | | - input_report_key(ts->pen_dev, BTN_STYLUS, 0); |
---|
1111 | | - input_report_key(ts->pen_dev, BTN_STYLUS2, 0); |
---|
1112 | | - if ( (pre_key == 0x40) || (pre_key == 0x20) || |
---|
1113 | | - (pre_key == 0x10) |
---|
1114 | | - ) |
---|
1115 | | - { |
---|
1116 | | - pen_active = 1; |
---|
1117 | | - } |
---|
1118 | | - } |
---|
1119 | | - if (pen_active) |
---|
1120 | | - { |
---|
1121 | | - touch_num = 0; // shield pen point |
---|
1122 | | - //pre_touch = 0; // clear last pen status |
---|
1123 | | - } |
---|
1124 | | - #endif |
---|
1125 | | - |
---|
1126 | | - #if GTP_HAVE_TOUCH_KEY |
---|
1127 | | - if (!pre_touch) |
---|
1128 | | - { |
---|
1129 | | - for (i = 0; i < GTP_MAX_KEY_NUM; i++) |
---|
1130 | | - { |
---|
1131 | | - #if GTP_DEBUG_ON |
---|
1132 | | - for (ret = 0; ret < 4; ++ret) |
---|
1133 | | - { |
---|
1134 | | - if (key_codes[ret] == touch_key_array[i]) |
---|
1135 | | - { |
---|
1136 | | - GTP_DEBUG("Key: %s %s", key_names[ret], (key_value & (0x01 << i)) ? "Down" : "Up"); |
---|
1137 | | - break; |
---|
1138 | | - } |
---|
1139 | | - } |
---|
1140 | | - #endif |
---|
1141 | | - input_report_key(ts->input_dev, touch_key_array[i], key_value & (0x01<<i)); |
---|
1142 | | - } |
---|
1143 | | - touch_num = 0; // shield fingers |
---|
1144 | | - } |
---|
1145 | | - #endif |
---|
1146 | | - } |
---|
1147 | | -#endif |
---|
1148 | | - pre_key = key_value; |
---|
1149 | | - |
---|
1150 | | - GTP_DEBUG("pre_touch:%02x, finger:%02x.", pre_touch, finger); |
---|
| 569 | + dprintk(DEBUG_X_Y_INFO, "pre_touch:%02x, finger:%02x.", pre_touch, finger); |
---|
1151 | 570 | |
---|
1152 | 571 | #if GTP_ICS_SLOT_REPORT |
---|
| 572 | + if (pre_touch || touch_num) { |
---|
| 573 | + s32 pos = 0; |
---|
| 574 | + u16 touch_index = 0; |
---|
| 575 | + coor_data = &point_data[3]; |
---|
1153 | 576 | |
---|
1154 | | -#if GTP_WITH_PEN |
---|
1155 | | - if (pre_pen && (touch_num == 0)) |
---|
1156 | | - { |
---|
1157 | | - GTP_DEBUG("Pen touch UP(Slot)!"); |
---|
1158 | | - gtp_pen_up(0); |
---|
1159 | | - pen_active = 1; |
---|
1160 | | - pre_pen = 0; |
---|
1161 | | - } |
---|
1162 | | -#endif |
---|
1163 | | - if (pre_touch || touch_num) |
---|
1164 | | - { |
---|
1165 | | - s32 pos = 0; |
---|
1166 | | - u16 touch_index = 0; |
---|
1167 | | - u8 report_num = 0; |
---|
1168 | | - coor_data = &point_data[3]; |
---|
| 577 | + if(touch_num) { |
---|
| 578 | + id = coor_data[pos] & 0x0F; |
---|
| 579 | + touch_index |= (0x01<<id); |
---|
| 580 | + } |
---|
1169 | 581 | |
---|
1170 | | - if(touch_num) |
---|
1171 | | - { |
---|
1172 | | - id = coor_data[pos] & 0x0F; |
---|
| 582 | + dprintk(DEBUG_X_Y_INFO, |
---|
| 583 | + "id=%d, touch_index=0x%x, pre_touch=0x%x\n", id, touch_index, pre_touch); |
---|
1173 | 584 | |
---|
1174 | | - #if GTP_WITH_PEN |
---|
1175 | | - id = coor_data[pos]; |
---|
1176 | | - if ((id & 0x80)) |
---|
1177 | | - { |
---|
1178 | | - GTP_DEBUG("Pen touch DOWN(Slot)!"); |
---|
1179 | | - input_x = coor_data[pos + 1] | (coor_data[pos + 2] << 8); |
---|
1180 | | - input_y = coor_data[pos + 3] | (coor_data[pos + 4] << 8); |
---|
1181 | | - input_w = coor_data[pos + 5] | (coor_data[pos + 6] << 8); |
---|
| 585 | + for (i = 0; i < GTP_MAX_TOUCH; i++) { |
---|
| 586 | + if (touch_index & (0x01<<i)) { |
---|
| 587 | + input_x = coor_data[pos + 1] | coor_data[pos + 2] << 8; |
---|
| 588 | + input_y = coor_data[pos + 3] | coor_data[pos + 4] << 8; |
---|
| 589 | + input_w = coor_data[pos + 5] | coor_data[pos + 6] << 8; |
---|
1182 | 590 | |
---|
1183 | | - gtp_pen_down(input_x, input_y, input_w, 0); |
---|
1184 | | - pre_pen = 1; |
---|
1185 | | - pre_touch = 0; |
---|
1186 | | - pen_active = 1; |
---|
1187 | | - } |
---|
1188 | | - #endif |
---|
| 591 | + gtp_touch_down(ts, id, input_x, input_y, input_w); |
---|
| 592 | + pre_touch |= 0x01 << i; |
---|
1189 | 593 | |
---|
1190 | | - touch_index |= (0x01<<id); |
---|
1191 | | - } |
---|
| 594 | + pos += 8; |
---|
| 595 | + id = coor_data[pos] & 0x0F; |
---|
| 596 | + touch_index |= (0x01<<id); |
---|
| 597 | + }else {// if (pre_touch & (0x01 << i)) |
---|
1192 | 598 | |
---|
1193 | | - GTP_DEBUG("id = %d,touch_index = 0x%x, pre_touch = 0x%x\n",id, touch_index,pre_touch); |
---|
1194 | | - for (i = 0; i < GTP_MAX_TOUCH; i++) |
---|
1195 | | - { |
---|
1196 | | - #if GTP_WITH_PEN |
---|
1197 | | - if (pre_pen == 1) |
---|
1198 | | - { |
---|
1199 | | - break; |
---|
1200 | | - } |
---|
1201 | | - #endif |
---|
| 599 | + gtp_touch_up(ts, i); |
---|
| 600 | + pre_touch &= ~(0x01 << i); |
---|
| 601 | + } |
---|
| 602 | + } |
---|
| 603 | + } |
---|
1202 | 604 | |
---|
1203 | | - if ((touch_index & (0x01<<i))) |
---|
1204 | | - { |
---|
1205 | | - input_x = coor_data[pos + 1] | (coor_data[pos + 2] << 8); |
---|
1206 | | - input_y = coor_data[pos + 3] | (coor_data[pos + 4] << 8); |
---|
1207 | | - input_w = coor_data[pos + 5] | (coor_data[pos + 6] << 8); |
---|
1208 | | - |
---|
1209 | | - gtp_touch_down(ts, id, input_x, input_y, input_w); |
---|
1210 | | - pre_touch |= 0x01 << i; |
---|
1211 | | - |
---|
1212 | | - report_num++; |
---|
1213 | | - if (report_num < touch_num) |
---|
1214 | | - { |
---|
1215 | | - pos += 8; |
---|
1216 | | - id = coor_data[pos] & 0x0F; |
---|
1217 | | - touch_index |= (0x01<<id); |
---|
1218 | | - } |
---|
1219 | | - } |
---|
1220 | | - else |
---|
1221 | | - { |
---|
1222 | | - gtp_touch_up(ts, i); |
---|
1223 | | - pre_touch &= ~(0x01 << i); |
---|
1224 | | - } |
---|
1225 | | - } |
---|
1226 | | - } |
---|
1227 | 605 | #else |
---|
| 606 | + if (touch_num ) { |
---|
| 607 | + for (i = 0; i < touch_num; i++) { |
---|
| 608 | + coor_data = &point_data[i * 8 + 3]; |
---|
1228 | 609 | |
---|
1229 | | - if (touch_num) |
---|
1230 | | - { |
---|
1231 | | - for (i = 0; i < touch_num; i++) |
---|
1232 | | - { |
---|
1233 | | - coor_data = &point_data[i * 8 + 3]; |
---|
| 610 | + id = coor_data[0] & 0x0F; |
---|
| 611 | + input_x = coor_data[1] | coor_data[2] << 8; |
---|
| 612 | + input_y = coor_data[3] | coor_data[4] << 8; |
---|
| 613 | + input_w = coor_data[5] | coor_data[6] << 8; |
---|
1234 | 614 | |
---|
1235 | | - id = coor_data[0] & 0x0F; |
---|
1236 | | - input_x = coor_data[1] | (coor_data[2] << 8); |
---|
1237 | | - input_y = coor_data[3] | (coor_data[4] << 8); |
---|
1238 | | - input_w = coor_data[5] | (coor_data[6] << 8); |
---|
| 615 | + gtp_touch_down(ts, id, input_x, input_y, input_w); |
---|
| 616 | + } |
---|
| 617 | + }else if(pre_touch){ |
---|
| 618 | + dprintk(DEBUG_X_Y_INFO, "Touch Release!"); |
---|
| 619 | + gtp_touch_up(ts, 0); |
---|
| 620 | + } |
---|
1239 | 621 | |
---|
1240 | | - #if GTP_WITH_PEN |
---|
1241 | | - id = coor_data[0]; |
---|
1242 | | - if (id & 0x80) |
---|
1243 | | - { |
---|
1244 | | - GTP_DEBUG("Pen touch DOWN!"); |
---|
1245 | | - gtp_pen_down(input_x, input_y, input_w, 0); |
---|
1246 | | - pre_pen = 1; |
---|
1247 | | - pen_active = 1; |
---|
1248 | | - break; |
---|
1249 | | - } |
---|
1250 | | - else |
---|
1251 | | - #endif |
---|
1252 | | - { |
---|
1253 | | - gtp_touch_down(ts, id, input_x, input_y, input_w); |
---|
1254 | | - } |
---|
1255 | | - } |
---|
1256 | | - } |
---|
1257 | | - else if (pre_touch) |
---|
1258 | | - { |
---|
1259 | | - #if GTP_WITH_PEN |
---|
1260 | | - if (pre_pen == 1) |
---|
1261 | | - { |
---|
1262 | | - GTP_DEBUG("Pen touch UP!"); |
---|
1263 | | - gtp_pen_up(0); |
---|
1264 | | - pre_pen = 0; |
---|
1265 | | - pen_active = 1; |
---|
1266 | | - } |
---|
1267 | | - else |
---|
1268 | | - #endif |
---|
1269 | | - { |
---|
1270 | | - GTP_DEBUG("Touch Release!"); |
---|
1271 | | - gtp_touch_up(ts, 0); |
---|
1272 | | - } |
---|
1273 | | - } |
---|
| 622 | + pre_touch = touch_num; |
---|
1274 | 623 | |
---|
1275 | | - pre_touch = touch_num; |
---|
1276 | 624 | #endif |
---|
1277 | 625 | |
---|
1278 | | -#if GTP_WITH_PEN |
---|
1279 | | - if (pen_active) |
---|
1280 | | - { |
---|
1281 | | - pen_active = 0; |
---|
1282 | | - input_sync(ts->pen_dev); |
---|
1283 | | - } |
---|
1284 | | - else |
---|
1285 | | -#endif |
---|
1286 | | - { |
---|
1287 | | - input_sync(ts->input_dev); |
---|
1288 | | - } |
---|
| 626 | + input_sync(ts->input_dev); |
---|
1289 | 627 | |
---|
1290 | 628 | exit_work_func: |
---|
1291 | | - if(!ts->gtp_rawdiff_mode) |
---|
1292 | | - { |
---|
1293 | | - ret = gtp_i2c_write(ts->client, end_cmd, 3); |
---|
1294 | | - if (ret < 0) |
---|
1295 | | - { |
---|
1296 | | - GTP_INFO("I2C write end_cmd error!"); |
---|
1297 | | - } |
---|
1298 | | - } |
---|
1299 | | - if (ts->use_irq) |
---|
1300 | | - { |
---|
1301 | | - gtp_irq_enable(ts); |
---|
1302 | | - } |
---|
| 629 | + if(!ts->gtp_rawdiff_mode) { |
---|
| 630 | + ret = gtp_i2c_write(ts->client, end_cmd, 3); |
---|
| 631 | + if (ret < 0) { |
---|
| 632 | + printk("I2C write end_cmd error!"); |
---|
| 633 | + } |
---|
| 634 | + } |
---|
| 635 | + return ; |
---|
1303 | 636 | } |
---|
1304 | 637 | |
---|
1305 | 638 | /******************************************************* |
---|
1306 | 639 | Function: |
---|
1307 | | - Timer interrupt service routine for polling mode. |
---|
| 640 | +External interrupt service routine. |
---|
| 641 | + |
---|
1308 | 642 | Input: |
---|
1309 | | - timer: timer struct pointer |
---|
| 643 | +irq: interrupt number. |
---|
| 644 | +dev_id: private data pointer. |
---|
| 645 | + |
---|
1310 | 646 | Output: |
---|
1311 | | - Timer work mode. |
---|
1312 | | - HRTIMER_NORESTART: no restart mode |
---|
1313 | | -*********************************************************/ |
---|
1314 | | -static enum hrtimer_restart goodix_ts_timer_handler(struct hrtimer *timer) |
---|
1315 | | -{ |
---|
1316 | | - struct goodix_ts_data *ts = container_of(timer, struct goodix_ts_data, timer); |
---|
| 647 | +irq execute status. |
---|
| 648 | + *******************************************************/ |
---|
1317 | 649 | |
---|
1318 | | - GTP_DEBUG_FUNC(); |
---|
| 650 | +irqreturn_t goodix_ts_irq_handler(int irq, void *dev_id) |
---|
| 651 | +{ |
---|
| 652 | + struct goodix_ts_data *ts = (struct goodix_ts_data *)dev_id; |
---|
| 653 | + dprintk(DEBUG_INT_INFO, "==========------TS Interrupt-----============\n"); |
---|
1319 | 654 | |
---|
1320 | | - queue_work(goodix_wq, &ts->work); |
---|
1321 | | - hrtimer_start(&ts->timer, ktime_set(0, (GTP_POLL_TIME+6)*1000000), HRTIMER_MODE_REL); |
---|
1322 | | - return HRTIMER_NORESTART; |
---|
| 655 | + queue_work(goodix_wq, &ts->work); |
---|
| 656 | + return 0; |
---|
1323 | 657 | } |
---|
1324 | 658 | |
---|
1325 | | -/******************************************************* |
---|
1326 | | -Function: |
---|
1327 | | - External interrupt service routine for interrupt mode. |
---|
1328 | | -Input: |
---|
1329 | | - irq: interrupt number. |
---|
1330 | | - dev_id: private data pointer |
---|
1331 | | -Output: |
---|
1332 | | - Handle Result. |
---|
1333 | | - IRQ_HANDLED: interrupt handled successfully |
---|
1334 | | -*********************************************************/ |
---|
1335 | | -static irqreturn_t goodix_ts_irq_handler(int irq, void *dev_id) |
---|
1336 | | -{ |
---|
1337 | | - struct goodix_ts_data *ts = dev_id; |
---|
1338 | 659 | |
---|
1339 | | - GTP_DEBUG_FUNC(); |
---|
1340 | | - |
---|
1341 | | - gtp_irq_disable(ts); |
---|
1342 | | - |
---|
1343 | | - queue_work(goodix_wq, &ts->work); |
---|
1344 | | - |
---|
1345 | | - return IRQ_HANDLED; |
---|
1346 | | -} |
---|
1347 | | -/******************************************************* |
---|
1348 | | -Function: |
---|
1349 | | - Synchronization. |
---|
1350 | | -Input: |
---|
1351 | | - ms: synchronization time in millisecond. |
---|
1352 | | -Output: |
---|
1353 | | - None. |
---|
1354 | | -*******************************************************/ |
---|
1355 | | -void gtp_int_sync(s32 ms) |
---|
1356 | | -{ |
---|
1357 | | - gtp_set_int_value(0); |
---|
1358 | | - msleep(ms); |
---|
1359 | | - gtp_set_io_int(); |
---|
1360 | | -} |
---|
1361 | 660 | |
---|
1362 | 661 | |
---|
1363 | 662 | /******************************************************* |
---|
1364 | 663 | Function: |
---|
1365 | | - Reset chip. |
---|
| 664 | +Eter sleep function. |
---|
| 665 | + |
---|
1366 | 666 | Input: |
---|
1367 | | - ms: reset time in millisecond |
---|
| 667 | +ts:private data. |
---|
| 668 | + |
---|
1368 | 669 | Output: |
---|
1369 | | - None. |
---|
1370 | | -*******************************************************/ |
---|
1371 | | -void gtp_reset_guitar(struct i2c_client *client, s32 ms) |
---|
1372 | | -{ |
---|
1373 | | -#if GTP_COMPATIBLE_MODE |
---|
1374 | | - struct goodix_ts_data *ts = i2c_get_clientdata(client); |
---|
1375 | | -#endif |
---|
1376 | | - |
---|
1377 | | - GTP_DEBUG_FUNC(); |
---|
1378 | | - GTP_INFO("Guitar reset"); |
---|
1379 | | - __gpio_set_value(config_info.wakeup_gpio.gpio, 0); // begin select I2C slave addr |
---|
1380 | | - msleep(ms); // T2: > 10ms |
---|
1381 | | - // HIGH: 0x28/0x29, LOW: 0xBA/0xBB |
---|
1382 | | - if(client->addr == 0x14) |
---|
1383 | | - gtp_set_int_value(1); |
---|
1384 | | - else |
---|
1385 | | - gtp_set_int_value(0); |
---|
1386 | | - |
---|
1387 | | - msleep(2); // T3: > 100us |
---|
1388 | | - __gpio_set_value(config_info.wakeup_gpio.gpio, 1); |
---|
1389 | | - |
---|
1390 | | - msleep(6); // T4: > 5ms |
---|
1391 | | - |
---|
1392 | | -// gpio_direction_input(config_info.wakeup_gpio.gpio); // end select I2C slave addr |
---|
1393 | | - |
---|
1394 | | -#if GTP_COMPATIBLE_MODE |
---|
1395 | | - if (CHIP_TYPE_GT9F == ts->chip_type) |
---|
1396 | | - { |
---|
1397 | | - return; |
---|
1398 | | - } |
---|
1399 | | -#endif |
---|
1400 | | - |
---|
1401 | | - gtp_int_sync(50); |
---|
1402 | | -#if GTP_ESD_PROTECT |
---|
1403 | | - gtp_init_ext_watchdog(client); |
---|
1404 | | -#endif |
---|
1405 | | -} |
---|
1406 | | - |
---|
1407 | | -//#if GTP_GESTURE_WAKEUP |
---|
1408 | | -/******************************************************* |
---|
1409 | | -Function: |
---|
1410 | | - Enter doze mode for sliding wakeup. |
---|
1411 | | -Input: |
---|
1412 | | - ts: goodix tp private data |
---|
1413 | | -Output: |
---|
1414 | | - 1: succeed, otherwise failed |
---|
1415 | | -*******************************************************/ |
---|
1416 | | -static s8 gtp_enter_doze(struct goodix_ts_data *ts) |
---|
1417 | | -{ |
---|
1418 | | - s8 ret = -1; |
---|
1419 | | - s8 retry = 0; |
---|
1420 | | - u8 i2c_control_buf[3] = {(u8)(GTP_REG_SLEEP >> 8), (u8)GTP_REG_SLEEP, 8}; |
---|
1421 | | - |
---|
1422 | | - GTP_DEBUG_FUNC(); |
---|
1423 | | - |
---|
1424 | | - GTP_DEBUG("Entering gesture mode."); |
---|
1425 | | - while(retry++ < 5) |
---|
1426 | | - { |
---|
1427 | | - i2c_control_buf[0] = 0x80; |
---|
1428 | | - i2c_control_buf[1] = 0x46; |
---|
1429 | | - ret = gtp_i2c_write(ts->client, i2c_control_buf, 3); |
---|
1430 | | - if (ret < 0) |
---|
1431 | | - { |
---|
1432 | | - GTP_DEBUG("failed to set doze flag into 0x8046, %d", retry); |
---|
1433 | | - continue; |
---|
1434 | | - } |
---|
1435 | | - i2c_control_buf[0] = 0x80; |
---|
1436 | | - i2c_control_buf[1] = 0x40; |
---|
1437 | | - ret = gtp_i2c_write(ts->client, i2c_control_buf, 3); |
---|
1438 | | - if (ret > 0) |
---|
1439 | | - { |
---|
1440 | | - doze_status = DOZE_ENABLED; |
---|
1441 | | - GTP_INFO("Gesture mode enabled."); |
---|
1442 | | - return ret; |
---|
1443 | | - } |
---|
1444 | | - msleep(10); |
---|
1445 | | - } |
---|
1446 | | - GTP_ERROR("GTP send gesture cmd failed."); |
---|
1447 | | - return ret; |
---|
1448 | | -} |
---|
1449 | | -//#else |
---|
1450 | | -/******************************************************* |
---|
1451 | | -Function: |
---|
1452 | | - Enter sleep mode. |
---|
1453 | | -Input: |
---|
1454 | | - ts: private data. |
---|
1455 | | -Output: |
---|
1456 | | - Executive outcomes. |
---|
1457 | | - 1: succeed, otherwise failed. |
---|
1458 | | -*******************************************************/ |
---|
| 670 | +Executive outcomes.0--success,non-0--fail. |
---|
| 671 | + *******************************************************/ |
---|
| 672 | +#if defined(CONFIG_HAS_EARLYSUSPEND) | defined(CONFIG_PM) |
---|
1459 | 673 | static s8 gtp_enter_sleep(struct goodix_ts_data * ts) |
---|
1460 | 674 | { |
---|
1461 | | - s8 ret = -1; |
---|
1462 | | - s8 retry = 0; |
---|
1463 | | - u8 i2c_control_buf[3] = {(u8)(GTP_REG_SLEEP >> 8), (u8)GTP_REG_SLEEP, 5}; |
---|
| 675 | + s8 ret = -1; |
---|
| 676 | + s8 retry = 0; |
---|
| 677 | + u8 i2c_control_buf[3] = {(u8)(GTP_REG_SLEEP >> 8), (u8)GTP_REG_SLEEP, 5}; |
---|
1464 | 678 | |
---|
1465 | | -#if GTP_COMPATIBLE_MODE |
---|
1466 | | - u8 status_buf[3] = {0x80, 0x44}; |
---|
1467 | | -#endif |
---|
| 679 | + dprintk(DEBUG_SUSPEND, "%s start!\n", __func__); |
---|
1468 | 680 | |
---|
1469 | | - GTP_DEBUG_FUNC(); |
---|
| 681 | + gtp_set_int_value(0); |
---|
1470 | 682 | |
---|
1471 | | -#if GTP_COMPATIBLE_MODE |
---|
1472 | | - if (CHIP_TYPE_GT9F == ts->chip_type) |
---|
1473 | | - { |
---|
1474 | | - // GT9XXF: host interact with ic |
---|
1475 | | - ret = gtp_i2c_read(ts->client, status_buf, 3); |
---|
1476 | | - if (ret < 0) |
---|
1477 | | - { |
---|
1478 | | - GTP_ERROR("failed to get backup-reference status"); |
---|
1479 | | - } |
---|
| 683 | + while(retry++ < 2) { |
---|
| 684 | + ret = gtp_i2c_write(ts->client, i2c_control_buf, 3); |
---|
| 685 | + if (ret > 0) { |
---|
| 686 | + dprintk(DEBUG_SUSPEND, "GTP enter sleep!"); |
---|
| 687 | + return ret; |
---|
| 688 | + } |
---|
| 689 | + msleep(10); |
---|
| 690 | + } |
---|
| 691 | + dprintk(DEBUG_SUSPEND, "GTP send sleep cmd failed."); |
---|
1480 | 692 | |
---|
1481 | | - if (status_buf[2] & 0x80) |
---|
1482 | | - { |
---|
1483 | | - ret = gtp_bak_ref_proc(ts, GTP_BAK_REF_STORE); |
---|
1484 | | - if (FAIL == ret) |
---|
1485 | | - { |
---|
1486 | | - GTP_ERROR("failed to store bak_ref"); |
---|
1487 | | - } |
---|
1488 | | - } |
---|
1489 | | - } |
---|
1490 | | -#endif |
---|
1491 | | - |
---|
1492 | | - gtp_set_int_value(0); |
---|
1493 | | - msleep(5); |
---|
1494 | | - |
---|
1495 | | - while(retry++ < 5) |
---|
1496 | | - { |
---|
1497 | | - ret = gtp_i2c_write(ts->client, i2c_control_buf, 3); |
---|
1498 | | - if (ret > 0) |
---|
1499 | | - { |
---|
1500 | | - GTP_INFO("GTP enter sleep!"); |
---|
1501 | | - |
---|
1502 | | - return ret; |
---|
1503 | | - } |
---|
1504 | | - msleep(10); |
---|
1505 | | - } |
---|
1506 | | - GTP_ERROR("GTP send sleep cmd failed."); |
---|
1507 | | - return ret; |
---|
| 693 | + return ret; |
---|
1508 | 694 | } |
---|
1509 | | -//#endif |
---|
| 695 | +#endif |
---|
| 696 | + |
---|
1510 | 697 | /******************************************************* |
---|
1511 | 698 | Function: |
---|
1512 | | - Wakeup from sleep. |
---|
| 699 | +Wakeup from sleep mode Function. |
---|
| 700 | + |
---|
1513 | 701 | Input: |
---|
1514 | | - ts: private data. |
---|
| 702 | +ts: private data. |
---|
| 703 | + |
---|
1515 | 704 | Output: |
---|
1516 | | - Executive outcomes. |
---|
1517 | | - >0: succeed, otherwise: failed. |
---|
1518 | | -*******************************************************/ |
---|
| 705 | +Executive outcomes.0--success,non-0--fail. |
---|
| 706 | + *******************************************************/ |
---|
1519 | 707 | static s8 gtp_wakeup_sleep(struct goodix_ts_data * ts) |
---|
1520 | 708 | { |
---|
1521 | | - u8 retry = 0; |
---|
1522 | | - s8 ret = -1; |
---|
| 709 | + u8 retry = 0; |
---|
| 710 | + s8 ret = -1; |
---|
1523 | 711 | |
---|
1524 | | - GTP_DEBUG_FUNC(); |
---|
| 712 | + gtp_io_init(20); |
---|
| 713 | + gtp_set_io_int(); |
---|
1525 | 714 | |
---|
1526 | | -#if GTP_COMPATIBLE_MODE |
---|
1527 | | - if (CHIP_TYPE_GT9F == ts->chip_type) |
---|
1528 | | - { |
---|
1529 | | - u8 opr_buf[3] = {0x41, 0x80}; |
---|
1530 | | - |
---|
1531 | | - gtp_set_int_value(1); |
---|
1532 | | - msleep(5); |
---|
1533 | | - |
---|
1534 | | - for (retry = 0; retry < 10; ++retry) |
---|
1535 | | - { |
---|
1536 | | - // hold ss51 & dsp |
---|
1537 | | - opr_buf[2] = 0x0C; |
---|
1538 | | - ret = gtp_i2c_write(ts->client, opr_buf, 3); |
---|
1539 | | - if (FAIL == ret) |
---|
1540 | | - { |
---|
1541 | | - GTP_ERROR("failed to hold ss51 & dsp!"); |
---|
1542 | | - continue; |
---|
1543 | | - } |
---|
1544 | | - opr_buf[2] = 0x00; |
---|
1545 | | - ret = gtp_i2c_read(ts->client, opr_buf, 3); |
---|
1546 | | - if (FAIL == ret) |
---|
1547 | | - { |
---|
1548 | | - GTP_ERROR("failed to get ss51 & dsp status!"); |
---|
1549 | | - continue; |
---|
1550 | | - } |
---|
1551 | | - if (0x0C != opr_buf[2]) |
---|
1552 | | - { |
---|
1553 | | - GTP_DEBUG("ss51 & dsp not been hold, %d", retry+1); |
---|
1554 | | - continue; |
---|
1555 | | - } |
---|
1556 | | - GTP_DEBUG("ss51 & dsp confirmed hold"); |
---|
1557 | | - |
---|
1558 | | - ret = gtp_fw_startup(ts->client); |
---|
1559 | | - if (FAIL == ret) |
---|
1560 | | - { |
---|
1561 | | - GTP_ERROR("failed to startup GT9XXF, process recovery"); |
---|
1562 | | - gtp_esd_recovery(ts->client); |
---|
1563 | | - } |
---|
1564 | | - break; |
---|
1565 | | - } |
---|
1566 | | - if (retry >= 10) |
---|
1567 | | - { |
---|
1568 | | - GTP_ERROR("failed to wakeup, processing esd recovery"); |
---|
1569 | | - gtp_esd_recovery(ts->client); |
---|
1570 | | - } |
---|
1571 | | - else |
---|
1572 | | - { |
---|
1573 | | - GTP_INFO("GT9XXF gtp wakeup success"); |
---|
1574 | | - } |
---|
1575 | | - return ret; |
---|
1576 | | - } |
---|
1577 | | -#endif |
---|
1578 | | -//#if GTP_POWER_CTRL_SLEEP |
---|
1579 | | -if(gtp_power_ctrl_sleep) |
---|
1580 | | - while(retry++ < 5) |
---|
1581 | | - { |
---|
1582 | | - gtp_reset_guitar(ts->client, 20); |
---|
1583 | | - |
---|
1584 | | - GTP_INFO("GTP wakeup sleep."); |
---|
1585 | | - return 1; |
---|
1586 | | - } |
---|
1587 | | -//#else |
---|
1588 | | -else { |
---|
1589 | | - while(retry++ < 10) |
---|
1590 | | - { |
---|
1591 | | - //#if GTP_GESTURE_WAKEUP |
---|
1592 | | - if(gtp_gesture_wakeup){ |
---|
1593 | | - if (DOZE_WAKEUP != doze_status) |
---|
1594 | | - { |
---|
1595 | | - GTP_INFO("Powerkey wakeup."); |
---|
1596 | | - } |
---|
1597 | | - else |
---|
1598 | | - { |
---|
1599 | | - GTP_INFO("Gesture wakeup."); |
---|
1600 | | - } |
---|
1601 | | - doze_status = DOZE_DISABLED; |
---|
1602 | | - gtp_irq_disable(ts); |
---|
1603 | | - gtp_reset_guitar(ts->client, 10); |
---|
1604 | | - gtp_irq_enable(ts); |
---|
1605 | | - } |
---|
1606 | | - else { |
---|
1607 | | - //#else |
---|
1608 | | - gtp_set_int_value(1); |
---|
1609 | | - msleep(5); |
---|
1610 | | - //#endif |
---|
1611 | | - } |
---|
1612 | | - |
---|
1613 | | - ret = gtp_i2c_test(ts->client); |
---|
1614 | | - if (ret > 0) |
---|
1615 | | - { |
---|
1616 | | - GTP_INFO("GTP wakeup sleep."); |
---|
1617 | | - |
---|
1618 | | - // #if (!GTP_GESTURE_WAKEUP) |
---|
1619 | | - if(!gtp_gesture_wakeup){ |
---|
1620 | | - { |
---|
1621 | | - gtp_int_sync(25); |
---|
1622 | | - #if GTP_ESD_PROTECT |
---|
1623 | | - gtp_init_ext_watchdog(ts->client); |
---|
1624 | | - #endif |
---|
1625 | | - } |
---|
1626 | | - } |
---|
1627 | | - //#endif |
---|
1628 | | - |
---|
1629 | | - return ret; |
---|
1630 | | - } |
---|
1631 | | - gtp_reset_guitar(ts->client, 20); |
---|
1632 | | - } |
---|
1633 | | -} |
---|
1634 | | -//#endif |
---|
1635 | | - |
---|
1636 | | - GTP_ERROR("GTP wakeup sleep failed."); |
---|
1637 | | - return ret; |
---|
1638 | | -} |
---|
1639 | | - |
---|
1640 | | - |
---|
1641 | | -#if GTP_DRIVER_SEND_CFG |
---|
1642 | | -static s32 gtp_get_info(struct goodix_ts_data *ts) |
---|
1643 | | -{ |
---|
1644 | | - u8 opr_buf[6] = {0}; |
---|
1645 | | - s32 ret = 0; |
---|
1646 | | - |
---|
1647 | | - ts->abs_x_max = GTP_MAX_WIDTH; |
---|
1648 | | - ts->abs_y_max = GTP_MAX_HEIGHT; |
---|
1649 | | - ts->int_trigger_type = GTP_INT_TRIGGER; |
---|
1650 | | - |
---|
1651 | | - opr_buf[0] = (u8)((GTP_REG_CONFIG_DATA+1) >> 8); |
---|
1652 | | - opr_buf[1] = (u8)((GTP_REG_CONFIG_DATA+1) & 0xFF); |
---|
1653 | | - |
---|
1654 | | - ret = gtp_i2c_read(ts->client, opr_buf, 6); |
---|
1655 | | - if (ret < 0) |
---|
1656 | | - { |
---|
1657 | | - return FAIL; |
---|
1658 | | - } |
---|
1659 | | - |
---|
1660 | | - ts->abs_x_max = (opr_buf[3] << 8) + opr_buf[2]; |
---|
1661 | | - ts->abs_y_max = (opr_buf[5] << 8) + opr_buf[4]; |
---|
1662 | | - |
---|
1663 | | - opr_buf[0] = (u8)((GTP_REG_CONFIG_DATA+6) >> 8); |
---|
1664 | | - opr_buf[1] = (u8)((GTP_REG_CONFIG_DATA+6) & 0xFF); |
---|
1665 | | - |
---|
1666 | | - ret = gtp_i2c_read(ts->client, opr_buf, 3); |
---|
1667 | | - if (ret < 0) |
---|
1668 | | - { |
---|
1669 | | - return FAIL; |
---|
1670 | | - } |
---|
1671 | | - ts->int_trigger_type = opr_buf[2] & 0x03; |
---|
1672 | | - |
---|
1673 | | - GTP_INFO("X_MAX = %d, Y_MAX = %d, TRIGGER = 0x%02x", |
---|
1674 | | - ts->abs_x_max,ts->abs_y_max,ts->int_trigger_type); |
---|
1675 | | - |
---|
1676 | | - return SUCCESS; |
---|
1677 | | -} |
---|
1678 | | -#endif |
---|
1679 | | - |
---|
1680 | | -/******************************************************* |
---|
1681 | | -Function: |
---|
1682 | | - Initialize gtp. |
---|
1683 | | -Input: |
---|
1684 | | - ts: goodix private data |
---|
1685 | | -Output: |
---|
1686 | | - Executive outcomes. |
---|
1687 | | - 0: succeed, otherwise: failed |
---|
1688 | | -*******************************************************/ |
---|
1689 | | -static s32 gtp_init_panel(struct goodix_ts_data *ts) |
---|
1690 | | -{ |
---|
1691 | | - s32 ret = -1; |
---|
1692 | | - |
---|
1693 | | -#if GTP_DRIVER_SEND_CFG |
---|
1694 | | - s32 i = 0; |
---|
1695 | | - u8 check_sum = 0; |
---|
1696 | | - u8 opr_buf[16] = {0}; |
---|
1697 | | - u8 sensor_id = 0; |
---|
1698 | | - |
---|
1699 | | - u8 cfg_info_group1[] = CTP_CFG_GROUP1; |
---|
1700 | | - u8 cfg_info_group2[] = CTP_CFG_GROUP2; |
---|
1701 | | - u8 cfg_info_group3[] = CTP_CFG_GROUP3; |
---|
1702 | | - u8 cfg_info_group4[] = CTP_CFG_GROUP4; |
---|
1703 | | - u8 cfg_info_group5[] = CTP_CFG_GROUP5; |
---|
1704 | | - u8 cfg_info_group6[] = CTP_CFG_GROUP6; |
---|
1705 | | - u8 cfg_info_group7[] = CTP_CFG_GROUP7; |
---|
1706 | | - u8 cfg_info_group8[] = CTP_CFG_GROUP8; |
---|
1707 | | - |
---|
1708 | | - u8 *send_cfg_buf[] = {cfg_info_group1, cfg_info_group2, cfg_info_group3, |
---|
1709 | | - cfg_info_group4, cfg_info_group5, cfg_info_group6, |
---|
1710 | | - cfg_info_group7, cfg_info_group8}; |
---|
1711 | | - u8 cfg_info_len[] = { CFG_GROUP_LEN(cfg_info_group1), |
---|
1712 | | - CFG_GROUP_LEN(cfg_info_group2), |
---|
1713 | | - CFG_GROUP_LEN(cfg_info_group3), |
---|
1714 | | - CFG_GROUP_LEN(cfg_info_group4), |
---|
1715 | | - CFG_GROUP_LEN(cfg_info_group5), |
---|
1716 | | - CFG_GROUP_LEN(cfg_info_group6), |
---|
1717 | | - CFG_GROUP_LEN(cfg_info_group7), |
---|
1718 | | - CFG_GROUP_LEN(cfg_info_group8)}; |
---|
1719 | | - |
---|
1720 | | - dprintk(DEBUG_INIT,"Config Groups Lengths: %d, %d, %d, %d, %d, %d, %d, %d\n", |
---|
1721 | | - cfg_info_len[0], cfg_info_len[1], cfg_info_len[2], cfg_info_len[3], |
---|
1722 | | - cfg_info_len[4], cfg_info_len[5], cfg_info_len[6], cfg_info_len[7]); |
---|
1723 | | - |
---|
1724 | | -#if GTP_COMPATIBLE_MODE |
---|
1725 | | - if (CHIP_TYPE_GT9F == ts->chip_type) |
---|
1726 | | - { |
---|
1727 | | - ts->fw_error = 0; |
---|
1728 | | - } |
---|
1729 | | - else |
---|
1730 | | -#endif |
---|
1731 | | - { |
---|
1732 | | - ret = gtp_i2c_read_dbl_check(ts->client, 0x41E4, opr_buf, 1); |
---|
1733 | | - if (SUCCESS == ret) |
---|
1734 | | - { |
---|
1735 | | - if (opr_buf[0] != 0xBE) |
---|
1736 | | - { |
---|
1737 | | - ts->fw_error = 1; |
---|
1738 | | - printk("Firmware error, no config sent!\n"); |
---|
1739 | | - return -1; |
---|
1740 | | - } |
---|
1741 | | - } |
---|
1742 | | - } |
---|
1743 | | - |
---|
1744 | | - if ((!cfg_info_len[1]) && (!cfg_info_len[2]) && |
---|
1745 | | - (!cfg_info_len[3]) && (!cfg_info_len[4]) && |
---|
1746 | | - (!cfg_info_len[5]) && (!cfg_info_len[6]) && |
---|
1747 | | - (!cfg_info_len[7])) |
---|
1748 | | - { |
---|
1749 | | - sensor_id = 0; |
---|
1750 | | - } |
---|
1751 | | - else |
---|
1752 | | - { |
---|
1753 | | - #if GTP_COMPATIBLE_MODE |
---|
1754 | | - msleep(50); |
---|
1755 | | - #endif |
---|
1756 | | - // ret = gtp_i2c_read_dbl_check(ts->client, GTP_REG_SENSOR_ID, &sensor_id, 1); |
---|
1757 | | - dprintk(DEBUG_INIT,"CTP name : %s\n",config_info.name); |
---|
1758 | | - if (!strcmp(config_info.name,"gt9271_mb976a9")){ |
---|
1759 | | - sensor_id = 0; |
---|
1760 | | - dprintk(DEBUG_INIT,"gt9xx:sensor_id = %d\n",sensor_id); |
---|
1761 | | - |
---|
1762 | | - } else if (!strcmp(config_info.name,"gt9110_wt097")){ |
---|
1763 | | - sensor_id = 1; |
---|
1764 | | - dprintk(DEBUG_INIT,"gt9xx:sensor_id = %d\n",sensor_id); |
---|
1765 | | - |
---|
1766 | | - } else if (!strcmp(config_info.name,"gt9271_wt097")){ |
---|
1767 | | - sensor_id = 2; |
---|
1768 | | - dprintk(DEBUG_INIT,"gt9xx:sensor_id = %d\n",sensor_id); |
---|
1769 | | - |
---|
1770 | | - } else if (!strcmp(config_info.name,"gt9110_g200")){ |
---|
1771 | | - sensor_id = 3; |
---|
1772 | | - dprintk(DEBUG_INIT,"gt9xx:sensor_id = %d\n",sensor_id); |
---|
1773 | | - |
---|
1774 | | - } else if (!strcmp(config_info.name,"gt9271_noah")){ |
---|
1775 | | - sensor_id = 4; |
---|
1776 | | - dprintk(DEBUG_INIT,"gt9xx:sensor_id = %d\n",sensor_id); |
---|
1777 | | - } else if (!strcmp(config_info.name,"gt9271_p2")){ |
---|
1778 | | - sensor_id = 5; |
---|
1779 | | - dprintk(DEBUG_INIT,"gt9xx:sensor_id = %d\n",sensor_id); |
---|
1780 | | - } else if (!strcmp(config_info.name, "gt911_1060")) { |
---|
1781 | | - sensor_id = 6; |
---|
1782 | | - dprintk(DEBUG_INIT,"gt9xx:sensor_id = %d\n",sensor_id); |
---|
1783 | | - } else if (!strcmp(config_info.name, "gt911_784")) { |
---|
1784 | | - sensor_id = 7; |
---|
1785 | | - dprintk(DEBUG_INIT,"gt9xx:sensor_id = %d\n",sensor_id); |
---|
1786 | | - } else { |
---|
1787 | | - sensor_id = 0; |
---|
1788 | | - dprintk(DEBUG_INIT,"gt9xx:sensor_id = %d\n",sensor_id); |
---|
| 715 | +#if GTP_POWER_CTRL_SLEEP |
---|
| 716 | + while(retry++ < 5) |
---|
| 717 | + { |
---|
| 718 | + ret = gtp_send_cfg(ts->client); |
---|
| 719 | + if (ret > 0) |
---|
| 720 | + { |
---|
| 721 | + dprintk(DEBUG_SUSPEND, "Wakeup sleep send config success."); |
---|
| 722 | + return ret; |
---|
1789 | 723 | } |
---|
1790 | | - ret = SUCCESS; |
---|
1791 | | - if (SUCCESS == ret) |
---|
1792 | | - { |
---|
1793 | | - if (sensor_id >= 0x08) |
---|
1794 | | - { |
---|
1795 | | - printk("Invalid sensor_id(0x%02X), No Config Sent!\n", sensor_id); |
---|
1796 | | - ts->pnl_init_error = 1; |
---|
1797 | | - return -1; |
---|
1798 | | - } |
---|
1799 | | - } |
---|
1800 | | - else |
---|
1801 | | - { |
---|
1802 | | - printk("Failed to get sensor_id, No config sent!\n"); |
---|
1803 | | - ts->pnl_init_error = 1; |
---|
1804 | | - return -1; |
---|
1805 | | - } |
---|
1806 | | - dprintk(DEBUG_INIT,"Sensor_ID: %d", sensor_id); |
---|
1807 | | - } |
---|
1808 | | - ts->gtp_cfg_len = cfg_info_len[sensor_id]; |
---|
1809 | | - dprintk(DEBUG_INIT,"CTP_CONFIG_GROUP%d used, config length: %d\n", sensor_id + 1, ts->gtp_cfg_len); |
---|
| 724 | + } |
---|
1810 | 725 | |
---|
1811 | | - if (ts->gtp_cfg_len < GTP_CONFIG_MIN_LENGTH) |
---|
1812 | | - { |
---|
1813 | | - printk("Config Group%d is INVALID CONFIG GROUP(Len: %d)! NO Config Sent! You need to check you header file CFG_GROUP section!\n", sensor_id+1, ts->gtp_cfg_len); |
---|
1814 | | - ts->pnl_init_error = 1; |
---|
1815 | | - return -1; |
---|
1816 | | - } |
---|
1817 | | - |
---|
1818 | | -#if GTP_COMPATIBLE_MODE |
---|
1819 | | - if (CHIP_TYPE_GT9F == ts->chip_type) |
---|
1820 | | - { |
---|
1821 | | - ts->fixed_cfg = 0; |
---|
1822 | | - } |
---|
1823 | | - else |
---|
| 726 | + printk("GTP wakeup sleep failed."); |
---|
| 727 | + return ret; |
---|
1824 | 728 | #endif |
---|
1825 | | - { |
---|
1826 | | - ret = gtp_i2c_read_dbl_check(ts->client, GTP_REG_CONFIG_DATA, &opr_buf[0], 1); |
---|
1827 | 729 | |
---|
1828 | | - if (ret == SUCCESS) |
---|
1829 | | - { |
---|
1830 | | - dprintk(DEBUG_INIT,"CFG_GROUP%d Config Version: %d, 0x%02X; IC Config Version: %d, 0x%02X\n", sensor_id+1, |
---|
1831 | | - send_cfg_buf[sensor_id][0], send_cfg_buf[sensor_id][0], opr_buf[0], opr_buf[0]); |
---|
1832 | | - |
---|
1833 | | - if (opr_buf[0] < 155) |
---|
1834 | | - { |
---|
1835 | | - grp_cfg_version = send_cfg_buf[sensor_id][0]; // backup group config version |
---|
1836 | | - send_cfg_buf[sensor_id][0] = 0x00; |
---|
1837 | | - ts->fixed_cfg = 0; |
---|
1838 | | - } |
---|
1839 | | - else // treated as fixed config, not send config |
---|
1840 | | - { |
---|
1841 | | - dprintk(DEBUG_INIT,"Ic fixed config with config version(%d, 0x%02X)\n", opr_buf[0], opr_buf[0]); |
---|
1842 | | - ts->fixed_cfg = 1; |
---|
1843 | | - gtp_get_info(ts); |
---|
1844 | | - return 0; |
---|
1845 | | - } |
---|
1846 | | - } |
---|
1847 | | - else |
---|
1848 | | - { |
---|
1849 | | - printk("Failed to get ic config version!No config sent!\n"); |
---|
1850 | | - return -1; |
---|
1851 | | - } |
---|
1852 | | - } |
---|
1853 | | - |
---|
1854 | | - memset(&config[GTP_ADDR_LENGTH], 0, GTP_CONFIG_MAX_LENGTH); |
---|
1855 | | - memcpy(&config[GTP_ADDR_LENGTH], send_cfg_buf[sensor_id], ts->gtp_cfg_len); |
---|
1856 | | - |
---|
1857 | | -#if GTP_CUSTOM_CFG |
---|
1858 | | - config[RESOLUTION_LOC] = (u8)GTP_MAX_WIDTH; |
---|
1859 | | - config[RESOLUTION_LOC + 1] = (u8)(GTP_MAX_WIDTH>>8); |
---|
1860 | | - config[RESOLUTION_LOC + 2] = (u8)GTP_MAX_HEIGHT; |
---|
1861 | | - config[RESOLUTION_LOC + 3] = (u8)(GTP_MAX_HEIGHT>>8); |
---|
1862 | | - |
---|
1863 | | - if (GTP_INT_TRIGGER == 0) //RISING |
---|
1864 | | - { |
---|
1865 | | - config[TRIGGER_LOC] &= 0xfe; |
---|
1866 | | - } |
---|
1867 | | - else if (GTP_INT_TRIGGER == 1) //FALLING |
---|
1868 | | - { |
---|
1869 | | - config[TRIGGER_LOC] |= 0x01; |
---|
1870 | | - } |
---|
1871 | | -#endif // GTP_CUSTOM_CFG |
---|
1872 | | - |
---|
1873 | | - check_sum = 0; |
---|
1874 | | - for (i = GTP_ADDR_LENGTH; i < ts->gtp_cfg_len; i++) |
---|
1875 | | - { |
---|
1876 | | - check_sum += config[i]; |
---|
1877 | | - } |
---|
1878 | | - config[ts->gtp_cfg_len] = (~check_sum) + 1; |
---|
1879 | | - |
---|
1880 | | -#else // driver not send config |
---|
1881 | | - |
---|
1882 | | - ts->gtp_cfg_len = GTP_CONFIG_MAX_LENGTH; |
---|
1883 | | - ret = gtp_i2c_read(ts->client, config, ts->gtp_cfg_len + GTP_ADDR_LENGTH); |
---|
1884 | | - if (ret < 0) |
---|
1885 | | - { |
---|
1886 | | - GTP_ERROR("Read Config Failed, Using Default Resolution & INT Trigger!"); |
---|
1887 | | - ts->abs_x_max = GTP_MAX_WIDTH; |
---|
1888 | | - ts->abs_y_max = GTP_MAX_HEIGHT; |
---|
1889 | | - ts->int_trigger_type = GTP_INT_TRIGGER; |
---|
1890 | | - } |
---|
1891 | | - |
---|
1892 | | -#endif // GTP_DRIVER_SEND_CFG |
---|
1893 | | - |
---|
1894 | | - if ((ts->abs_x_max == 0) && (ts->abs_y_max == 0)) |
---|
1895 | | - { |
---|
1896 | | - ts->abs_x_max = (config[RESOLUTION_LOC + 1] << 8) + config[RESOLUTION_LOC]; |
---|
1897 | | - ts->abs_y_max = (config[RESOLUTION_LOC + 3] << 8) + config[RESOLUTION_LOC + 2]; |
---|
1898 | | - ts->int_trigger_type = (config[TRIGGER_LOC]) & 0x03; |
---|
1899 | | - } |
---|
1900 | | - |
---|
1901 | | -#if GTP_COMPATIBLE_MODE |
---|
1902 | | - if (CHIP_TYPE_GT9F == ts->chip_type) |
---|
1903 | | - { |
---|
1904 | | - u8 sensor_num = 0; |
---|
1905 | | - u8 driver_num = 0; |
---|
1906 | | - u8 have_key = 0; |
---|
1907 | | - |
---|
1908 | | - have_key = (config[GTP_REG_HAVE_KEY - GTP_REG_CONFIG_DATA + 2] & 0x01); |
---|
1909 | | - |
---|
1910 | | - if (1 == ts->is_950) |
---|
1911 | | - { |
---|
1912 | | - driver_num = config[GTP_REG_MATRIX_DRVNUM - GTP_REG_CONFIG_DATA + 2]; |
---|
1913 | | - sensor_num = config[GTP_REG_MATRIX_SENNUM - GTP_REG_CONFIG_DATA + 2]; |
---|
1914 | | - if (have_key) |
---|
1915 | | - { |
---|
1916 | | - driver_num--; |
---|
1917 | | - } |
---|
1918 | | - ts->bak_ref_len = (driver_num * (sensor_num - 1) + 2) * 2 * 6; |
---|
1919 | | - } |
---|
1920 | | - else |
---|
1921 | | - { |
---|
1922 | | - driver_num = (config[CFG_LOC_DRVA_NUM] & 0x1F) + (config[CFG_LOC_DRVB_NUM]&0x1F); |
---|
1923 | | - if (have_key) |
---|
1924 | | - { |
---|
1925 | | - driver_num--; |
---|
1926 | | - } |
---|
1927 | | - sensor_num = (config[CFG_LOC_SENS_NUM] & 0x0F) + ((config[CFG_LOC_SENS_NUM] >> 4) & 0x0F); |
---|
1928 | | - ts->bak_ref_len = (driver_num * (sensor_num - 2) + 2) * 2; |
---|
1929 | | - } |
---|
1930 | | - |
---|
1931 | | - GTP_INFO("Drv * Sen: %d * %d(key: %d), X_MAX: %d, Y_MAX: %d, TRIGGER: 0x%02x", |
---|
1932 | | - driver_num, sensor_num, have_key, ts->abs_x_max,ts->abs_y_max,ts->int_trigger_type); |
---|
1933 | | - return 0; |
---|
1934 | | - } |
---|
1935 | | - else |
---|
1936 | | -#endif |
---|
1937 | | - { |
---|
1938 | | - #if GTP_DRIVER_SEND_CFG |
---|
1939 | | - ret = gtp_send_cfg(ts->client); |
---|
1940 | | - if (ret < 0) |
---|
1941 | | - { |
---|
1942 | | - GTP_ERROR("Send config error."); |
---|
1943 | | - } |
---|
1944 | | - // set config version to CTP_CFG_GROUP, for resume to send config |
---|
1945 | | - config[GTP_ADDR_LENGTH] = grp_cfg_version; |
---|
1946 | | - check_sum = 0; |
---|
1947 | | - for (i = GTP_ADDR_LENGTH; i < ts->gtp_cfg_len; i++) |
---|
1948 | | - { |
---|
1949 | | - check_sum += config[i]; |
---|
1950 | | - } |
---|
1951 | | - config[ts->gtp_cfg_len] = (~check_sum) + 1; |
---|
1952 | | - #endif |
---|
1953 | | - GTP_INFO("X_MAX: %d, Y_MAX: %d, TRIGGER: 0x%02x", ts->abs_x_max,ts->abs_y_max,ts->int_trigger_type); |
---|
1954 | | - } |
---|
1955 | | - |
---|
1956 | | - msleep(10); |
---|
1957 | | - return 0; |
---|
1958 | 730 | } |
---|
1959 | 731 | |
---|
1960 | | - |
---|
1961 | | -static ssize_t gt91xx_config_read_proc(struct file *file, char __user *page, size_t size, loff_t *ppos) |
---|
1962 | | -{ |
---|
1963 | | - char *ptr = page; |
---|
1964 | | - char temp_data[GTP_CONFIG_MAX_LENGTH + 2] = {0x80, 0x47}; |
---|
1965 | | - int i; |
---|
1966 | | - |
---|
1967 | | - if (*ppos) |
---|
1968 | | - { |
---|
1969 | | - return 0; |
---|
1970 | | - } |
---|
1971 | | - ptr += sprintf(ptr, "==== GT9XX config init value====\n"); |
---|
1972 | | - |
---|
1973 | | - for (i = 0 ; i < GTP_CONFIG_MAX_LENGTH ; i++) |
---|
1974 | | - { |
---|
1975 | | - ptr += sprintf(ptr, "0x%02X ", config[i + 2]); |
---|
1976 | | - |
---|
1977 | | - if (i % 8 == 7) |
---|
1978 | | - ptr += sprintf(ptr, "\n"); |
---|
1979 | | - } |
---|
1980 | | - |
---|
1981 | | - ptr += sprintf(ptr, "\n"); |
---|
1982 | | - |
---|
1983 | | - ptr += sprintf(ptr, "==== GT9XX config real value====\n"); |
---|
1984 | | - gtp_i2c_read(i2c_connect_client, temp_data, GTP_CONFIG_MAX_LENGTH + 2); |
---|
1985 | | - for (i = 0 ; i < GTP_CONFIG_MAX_LENGTH ; i++) |
---|
1986 | | - { |
---|
1987 | | - ptr += sprintf(ptr, "0x%02X ", temp_data[i+2]); |
---|
1988 | | - |
---|
1989 | | - if (i % 8 == 7) |
---|
1990 | | - ptr += sprintf(ptr, "\n"); |
---|
1991 | | - } |
---|
1992 | | - *ppos += ptr - page; |
---|
1993 | | - return (ptr - page); |
---|
1994 | | -} |
---|
1995 | | - |
---|
1996 | | -static ssize_t gt91xx_config_write_proc(struct file *filp, const char __user *buffer, size_t count, loff_t *off) |
---|
1997 | | -{ |
---|
1998 | | - s32 ret = 0; |
---|
1999 | | - |
---|
2000 | | - GTP_DEBUG("write count %u\n", count); |
---|
2001 | | - |
---|
2002 | | - if (count > GTP_CONFIG_MAX_LENGTH) |
---|
2003 | | - { |
---|
2004 | | - GTP_ERROR("size not match [%d:%u]\n", GTP_CONFIG_MAX_LENGTH, count); |
---|
2005 | | - return -EFAULT; |
---|
2006 | | - } |
---|
2007 | | - |
---|
2008 | | - if (copy_from_user(&config[2], buffer, count)) |
---|
2009 | | - { |
---|
2010 | | - GTP_ERROR("copy from user fail\n"); |
---|
2011 | | - return -EFAULT; |
---|
2012 | | - } |
---|
2013 | | - |
---|
2014 | | - ret = gtp_send_cfg(i2c_connect_client); |
---|
2015 | | - |
---|
2016 | | - if (ret < 0) |
---|
2017 | | - { |
---|
2018 | | - GTP_ERROR("send config failed."); |
---|
2019 | | - } |
---|
2020 | | - |
---|
2021 | | - return count; |
---|
2022 | | -} |
---|
2023 | | -/******************************************************* |
---|
2024 | | -Function: |
---|
2025 | | - Read chip version. |
---|
2026 | | -Input: |
---|
2027 | | - client: i2c device |
---|
2028 | | - version: buffer to keep ic firmware version |
---|
2029 | | -Output: |
---|
2030 | | - read operation return. |
---|
2031 | | - 2: succeed, otherwise: failed |
---|
2032 | | -*******************************************************/ |
---|
2033 | | -s32 gtp_read_version(struct i2c_client *client, u16* version) |
---|
2034 | | -{ |
---|
2035 | | - s32 ret = -1; |
---|
2036 | | - u8 buf[8] = {GTP_REG_VERSION >> 8, GTP_REG_VERSION & 0xff}; |
---|
2037 | | - |
---|
2038 | | - GTP_DEBUG_FUNC(); |
---|
2039 | | - |
---|
2040 | | - ret = gtp_i2c_read(client, buf, sizeof(buf)); |
---|
2041 | | - if (ret < 0) |
---|
2042 | | - { |
---|
2043 | | - GTP_ERROR("GTP read version failed"); |
---|
2044 | | - return ret; |
---|
2045 | | - } |
---|
2046 | | - |
---|
2047 | | - if (version) |
---|
2048 | | - { |
---|
2049 | | - *version = (buf[7] << 8) | buf[6]; |
---|
2050 | | - } |
---|
2051 | | - if (buf[5] == 0x00) |
---|
2052 | | - { |
---|
2053 | | - GTP_INFO("IC Version: %c%c%c_%02x%02x", buf[2], buf[3], buf[4], buf[7], buf[6]); |
---|
2054 | | - } |
---|
2055 | | - else |
---|
2056 | | - { |
---|
2057 | | - GTP_INFO("IC Version: %c%c%c%c_%02x%02x", buf[2], buf[3], buf[4], buf[5], buf[7], buf[6]); |
---|
2058 | | - } |
---|
2059 | | - return ret; |
---|
2060 | | -} |
---|
2061 | 732 | |
---|
2062 | 733 | /******************************************************* |
---|
2063 | 734 | Function: |
---|
2064 | | - I2c test Function. |
---|
| 735 | +GTP initialize function. |
---|
| 736 | + |
---|
2065 | 737 | Input: |
---|
2066 | | - client:i2c client. |
---|
| 738 | +ts: i2c client private struct. |
---|
| 739 | + |
---|
2067 | 740 | Output: |
---|
2068 | | - Executive outcomes. |
---|
2069 | | - 2: succeed, otherwise failed. |
---|
2070 | | -*******************************************************/ |
---|
2071 | | -static s8 gtp_i2c_test(struct i2c_client *client) |
---|
2072 | | -{ |
---|
2073 | | - u8 test[3] = {GTP_REG_CONFIG_DATA >> 8, GTP_REG_CONFIG_DATA & 0xff}; |
---|
2074 | | - u8 retry = 0; |
---|
2075 | | - s8 ret = -1; |
---|
2076 | | - |
---|
2077 | | - GTP_DEBUG_FUNC(); |
---|
2078 | | - |
---|
2079 | | - while(retry++ < 5) |
---|
2080 | | - { |
---|
2081 | | - ret = gtp_i2c_read(client, test, 3); |
---|
2082 | | - if (ret > 0) |
---|
2083 | | - { |
---|
2084 | | - return ret; |
---|
2085 | | - } |
---|
2086 | | - GTP_ERROR("GTP i2c test failed time %d.",retry); |
---|
2087 | | - msleep(10); |
---|
2088 | | - } |
---|
2089 | | - return ret; |
---|
2090 | | -} |
---|
2091 | | - |
---|
2092 | | -/******************************************************* |
---|
2093 | | -Function: |
---|
2094 | | - Request interrupt. |
---|
2095 | | -Input: |
---|
2096 | | - ts: private data. |
---|
2097 | | -Output: |
---|
2098 | | - Executive outcomes. |
---|
2099 | | - 0: succeed, -1: failed. |
---|
2100 | | -*******************************************************/ |
---|
2101 | | -static s8 gtp_request_irq(struct goodix_ts_data *ts) |
---|
| 741 | +Executive outcomes.0---succeed. |
---|
| 742 | + *******************************************************/ |
---|
| 743 | +static s32 gtp_init_panel(struct goodix_ts_data *ts) |
---|
2102 | 744 | { |
---|
2103 | 745 | s32 ret = -1; |
---|
2104 | 746 | |
---|
2105 | | - ret = input_request_int(&(config_info.input_type), goodix_ts_irq_handler, CTP_IRQ_MODE, ts); |
---|
| 747 | +#if GTP_DRIVER_SEND_CFG |
---|
| 748 | + s32 i; |
---|
| 749 | + u8 check_sum = 0; |
---|
| 750 | + u8 rd_cfg_buf[16]; |
---|
| 751 | + int index =0; |
---|
2106 | 752 | |
---|
2107 | | - if (ret) { |
---|
2108 | | - GTP_ERROR("Request IRQ failed!ERRNO:%d.", ret); |
---|
2109 | | - gtp_set_int_value(0); |
---|
2110 | | - //input_free_int(&(config_info.input_type), ts); |
---|
| 753 | +#if 1 |
---|
| 754 | + u8 cfg_info_group1[] = CTP_CFG_GROUP1; |
---|
| 755 | + u8 cfg_info_group2[] = CTP_CFG_GROUP2; |
---|
| 756 | + u8 cfg_info_group3[] = CTP_CFG_GROUP3; |
---|
| 757 | + u8 cfg_info_group4[] = CTP_CFG_GROUP4; |
---|
| 758 | + u8 cfg_info_group5[] = CTP_CFG_GROUP5; |
---|
| 759 | + u8 cfg_info_group6[] = CTP_CFG_GROUP6; |
---|
| 760 | + // u8 cfg_info_group7[] = CTP_CFG_GROUP7; |
---|
| 761 | +#else |
---|
| 762 | + u8 cfg_info_group1[] = {}; |
---|
| 763 | + u8 cfg_info_group2[] = {}; |
---|
| 764 | + u8 cfg_info_group3[] = {}; |
---|
| 765 | + u8 cfg_info_group4[] = {}; |
---|
| 766 | + u8 cfg_info_group5[] = {}; |
---|
| 767 | + u8 cfg_info_group6[] = {}; |
---|
| 768 | + // u8 cfg_info_group7[] = {}; |
---|
| 769 | +#endif |
---|
2111 | 770 | |
---|
2112 | | - hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); |
---|
2113 | | - ts->timer.function = goodix_ts_timer_handler; |
---|
2114 | | - hrtimer_start(&ts->timer, ktime_set(1, 0), HRTIMER_MODE_REL); |
---|
2115 | | - return -1; |
---|
2116 | | - } else { |
---|
2117 | | - gtp_irq_disable(ts); |
---|
2118 | | - ts->use_irq = 1; |
---|
2119 | | - return 0; |
---|
| 771 | + u8 *send_cfg_buf[] = {cfg_info_group1,cfg_info_group2,cfg_info_group3,cfg_info_group4,cfg_info_group5,cfg_info_group6}; |
---|
| 772 | + u8 cfg_info_len[] = {sizeof(cfg_info_group1)/sizeof(cfg_info_group1[0]),\ |
---|
| 773 | + sizeof(cfg_info_group2)/sizeof(cfg_info_group2[0]),\ |
---|
| 774 | + sizeof(cfg_info_group3)/sizeof(cfg_info_group3[0]),\ |
---|
| 775 | + sizeof(cfg_info_group4)/sizeof(cfg_info_group4[0]),\ |
---|
| 776 | + sizeof(cfg_info_group5)/sizeof(cfg_info_group5[0]),\ |
---|
| 777 | + sizeof(cfg_info_group6)/sizeof(cfg_info_group6[0])}; |
---|
| 778 | + //sizeof(cfg_info_group7)/sizeof(cfg_info_group7[0])}; |
---|
| 779 | +#if 0 //gandy |
---|
| 780 | +for(i=0; i<3; i++) |
---|
| 781 | +{ |
---|
| 782 | + if(cfg_info_len[i] > ts->gtp_cfg_len) |
---|
| 783 | + { |
---|
| 784 | + ts->gtp_cfg_len = cfg_info_len[i]; |
---|
2120 | 785 | } |
---|
2121 | 786 | } |
---|
| 787 | +#endif |
---|
| 788 | + |
---|
| 789 | +GTP_DEBUG("len1=%d,len2=%d,len3=%d,send_len:%d",cfg_info_len[0],cfg_info_len[1],cfg_info_len[2],ts->gtp_cfg_len); |
---|
| 790 | +#if 0 |
---|
| 791 | +if ((!cfg_info_len[1]) && (!cfg_info_len[2])) |
---|
| 792 | +{ |
---|
| 793 | + rd_cfg_buf[GTP_ADDR_LENGTH] = 0; |
---|
| 794 | +} |
---|
| 795 | +else |
---|
| 796 | +#endif |
---|
| 797 | +printk("gtp_i2c_read GTP_REG_SENSOR_ID \n"); |
---|
| 798 | +{ |
---|
| 799 | + rd_cfg_buf[0] = GTP_REG_SENSOR_ID >> 8; |
---|
| 800 | + rd_cfg_buf[1] = GTP_REG_SENSOR_ID & 0xff; |
---|
| 801 | + ret = gtp_i2c_read(ts->client, rd_cfg_buf, 3); |
---|
| 802 | + if (ret < 0) |
---|
| 803 | + { |
---|
| 804 | + GTP_ERROR("Read SENSOR ID failed,default use group1 config!"); |
---|
| 805 | + rd_cfg_buf[GTP_ADDR_LENGTH] = 0; |
---|
| 806 | + } |
---|
| 807 | + rd_cfg_buf[GTP_ADDR_LENGTH] &= 0x07; |
---|
| 808 | +} |
---|
| 809 | + |
---|
| 810 | +#if 0 |
---|
| 811 | +if(screen_max_x == 800 && screen_max_y == 480) |
---|
| 812 | +{ |
---|
| 813 | + if(rd_cfg_buf[GTP_ADDR_LENGTH] == 3) |
---|
| 814 | + index = 0; |
---|
| 815 | + else if(rd_cfg_buf[GTP_ADDR_LENGTH] == 4) |
---|
| 816 | + index = 1; |
---|
| 817 | + else if(rd_cfg_buf[GTP_ADDR_LENGTH] == 5) |
---|
| 818 | + index = 3; |
---|
| 819 | + else if(rd_cfg_buf[GTP_ADDR_LENGTH] == 0) |
---|
| 820 | + index = 6; |
---|
| 821 | +} |
---|
| 822 | +else if(screen_max_x == 1024 && screen_max_y == 600) |
---|
| 823 | +{ |
---|
| 824 | + if(rd_cfg_buf[GTP_ADDR_LENGTH] == 0) |
---|
| 825 | + index = 5; |
---|
| 826 | + else if(rd_cfg_buf[GTP_ADDR_LENGTH] == 3) |
---|
| 827 | + index = 2; |
---|
| 828 | +} |
---|
| 829 | +#endif |
---|
| 830 | +GTP_DEBUG("CTP name : %s\n",config_info.name); |
---|
| 831 | +if (!strcmp(config_info.name,"gt911_805d5")){ |
---|
| 832 | + index = 0; |
---|
| 833 | + GTP_DEBUG("gt9xx:index = %d\n",index); |
---|
| 834 | + |
---|
| 835 | +} else if (!strcmp(config_info.name,"gt911_g912")){ |
---|
| 836 | + index = 2; |
---|
| 837 | + GTP_DEBUG("gt9xx:index = %d\n",index); |
---|
| 838 | + |
---|
| 839 | +} else if (!strcmp(config_info.name,"gt911_xw785")){ |
---|
| 840 | + index = 3; |
---|
| 841 | + GTP_DEBUG("gt9xx:index = %d\n",index); |
---|
| 842 | + |
---|
| 843 | +} else {//default gt9xx_ts |
---|
| 844 | + index = 1; //default p4 |
---|
| 845 | + GTP_DEBUG("gt9xx:index = %d\n",index); |
---|
| 846 | +} |
---|
| 847 | + |
---|
| 848 | +printk("config send_cfg_buf******** \n"); |
---|
| 849 | +//index = rd_cfg_buf[GTP_ADDR_LENGTH]; |
---|
| 850 | +ts->gtp_cfg_len = cfg_info_len[index]; |
---|
| 851 | +GTP_DEBUG("gandy---SENSOR ID:%d\n", rd_cfg_buf[GTP_ADDR_LENGTH]); |
---|
| 852 | +memset(&config[GTP_ADDR_LENGTH], 0, GTP_CONFIG_MAX_LENGTH); |
---|
| 853 | +memcpy(&config[GTP_ADDR_LENGTH], send_cfg_buf[index], ts->gtp_cfg_len); |
---|
| 854 | + |
---|
| 855 | +#if GTP_CUSTOM_CFG |
---|
| 856 | +config[RESOLUTION_LOC] = (u8)GTP_MAX_WIDTH; |
---|
| 857 | +config[RESOLUTION_LOC + 1] = (u8)(GTP_MAX_WIDTH>>8); |
---|
| 858 | +config[RESOLUTION_LOC + 2] = (u8)GTP_MAX_HEIGHT; |
---|
| 859 | +config[RESOLUTION_LOC + 3] = (u8)(GTP_MAX_HEIGHT>>8); |
---|
| 860 | + |
---|
| 861 | +if (GTP_INT_TRIGGER == 0) //RISING |
---|
| 862 | +{ |
---|
| 863 | + config[TRIGGER_LOC] &= 0xfe; |
---|
| 864 | +} |
---|
| 865 | +else if (GTP_INT_TRIGGER == 1) //FALLING |
---|
| 866 | +{ |
---|
| 867 | + config[TRIGGER_LOC] |= 0x01; |
---|
| 868 | +} |
---|
| 869 | +#endif //endif GTP_CUSTOM_CFG |
---|
| 870 | + |
---|
| 871 | +check_sum = 0; |
---|
| 872 | +for (i = GTP_ADDR_LENGTH; i < ts->gtp_cfg_len; i++) |
---|
| 873 | +{ |
---|
| 874 | + check_sum += config[i]; |
---|
| 875 | +} |
---|
| 876 | +config[ts->gtp_cfg_len] = (~check_sum) + 1; |
---|
| 877 | + |
---|
| 878 | +#else //else DRIVER NEED NOT SEND CONFIG |
---|
| 879 | + |
---|
| 880 | +if(ts->gtp_cfg_len == 0) |
---|
| 881 | +{ |
---|
| 882 | + ts->gtp_cfg_len = GTP_CONFIG_MAX_LENGTH; |
---|
| 883 | +} |
---|
| 884 | +ret = gtp_i2c_read(ts->client, config, ts->gtp_cfg_len + GTP_ADDR_LENGTH); |
---|
| 885 | +if (ret < 0) |
---|
| 886 | +{ |
---|
| 887 | + GTP_ERROR("GTP read resolution & max_touch_num failed, use default value!"); |
---|
| 888 | + ts->abs_x_max = GTP_MAX_WIDTH; |
---|
| 889 | + ts->abs_y_max = GTP_MAX_HEIGHT; |
---|
| 890 | + ts->int_trigger_type = GTP_INT_TRIGGER; |
---|
| 891 | +} |
---|
| 892 | +#endif //endif GTP_DRIVER_SEND_CFG |
---|
| 893 | + |
---|
| 894 | +GTP_DEBUG_FUNC(); |
---|
| 895 | + |
---|
| 896 | +ts->abs_x_max = (config[RESOLUTION_LOC + 1] << 8) + config[RESOLUTION_LOC]; |
---|
| 897 | +ts->abs_y_max = (config[RESOLUTION_LOC + 3] << 8) + config[RESOLUTION_LOC + 2]; |
---|
| 898 | +ts->int_trigger_type = (config[TRIGGER_LOC]) & 0x03; |
---|
| 899 | +if ((!ts->abs_x_max)||(!ts->abs_y_max)) |
---|
| 900 | +{ |
---|
| 901 | + GTP_ERROR("GTP resolution & max_touch_num invalid, use default value!"); |
---|
| 902 | + ts->abs_x_max = GTP_MAX_WIDTH; |
---|
| 903 | + ts->abs_y_max = GTP_MAX_HEIGHT; |
---|
| 904 | +} |
---|
| 905 | + |
---|
| 906 | +msleep(100); |
---|
| 907 | +ret = gtp_send_cfg(ts->client); |
---|
| 908 | +if (ret < 0) |
---|
| 909 | +{ |
---|
| 910 | + printk("\ngandy-----send config error.ret=%d\n",ret); |
---|
| 911 | + GTP_ERROR("Send config error."); |
---|
| 912 | +} |
---|
| 913 | +printk("X_MAX = %d,Y_MAX = %d,TRIGGER = 0x%02x", |
---|
| 914 | + ts->abs_x_max,ts->abs_y_max,ts->int_trigger_type); |
---|
| 915 | + |
---|
| 916 | +msleep(10); |
---|
| 917 | + |
---|
| 918 | +return 0; |
---|
| 919 | +} |
---|
2122 | 920 | |
---|
2123 | 921 | /******************************************************* |
---|
2124 | 922 | Function: |
---|
2125 | | - Request input device Function. |
---|
| 923 | +Read goodix touchscreen version function. |
---|
| 924 | + |
---|
2126 | 925 | Input: |
---|
2127 | | - ts:private data. |
---|
| 926 | +client: i2c client struct. |
---|
| 927 | +version:address to store version info |
---|
| 928 | + |
---|
2128 | 929 | Output: |
---|
2129 | | - Executive outcomes. |
---|
2130 | | - 0: succeed, otherwise: failed. |
---|
2131 | | -*******************************************************/ |
---|
| 930 | +Executive outcomes.0---succeed. |
---|
| 931 | + *******************************************************/ |
---|
| 932 | +s32 gtp_read_version(struct i2c_client *client, u16* version) |
---|
| 933 | +{ |
---|
| 934 | + s32 ret = -1; |
---|
| 935 | + u8 buf[8] = {GTP_REG_VERSION >> 8, GTP_REG_VERSION & 0xff}; |
---|
| 936 | + |
---|
| 937 | + dprintk(DEBUG_INIT, "%s ---start!.---\n", __func__); |
---|
| 938 | + |
---|
| 939 | + ret = gtp_i2c_read(client, buf, sizeof(buf)); |
---|
| 940 | + if (ret < 0) { |
---|
| 941 | + printk("GTP read version failed"); |
---|
| 942 | + return ret; |
---|
| 943 | + } |
---|
| 944 | + |
---|
| 945 | + if (version) { |
---|
| 946 | + *version = (buf[7] << 8) | buf[6]; |
---|
| 947 | + } |
---|
| 948 | + |
---|
| 949 | + if (buf[5] == 0x00) { |
---|
| 950 | + printk("IC Version: %c%c%c_%02x%02x", buf[2], buf[3], buf[4], buf[7], buf[6]); |
---|
| 951 | + } |
---|
| 952 | + else { |
---|
| 953 | + printk("IC Version: %c%c%c%c_%02x%02x", buf[2], buf[3], buf[4], buf[5], buf[7], buf[6]); |
---|
| 954 | + } |
---|
| 955 | + return ret; |
---|
| 956 | +} |
---|
| 957 | + |
---|
| 958 | +/******************************************************* |
---|
| 959 | +Function: |
---|
| 960 | +I2c test Function. |
---|
| 961 | + |
---|
| 962 | +Input: |
---|
| 963 | +client:i2c client. |
---|
| 964 | + |
---|
| 965 | +Output: |
---|
| 966 | +Executive outcomes.0--success,non-0--fail. |
---|
| 967 | + *******************************************************/ |
---|
| 968 | +static s8 gtp_i2c_test(struct i2c_client *client) |
---|
| 969 | +{ |
---|
| 970 | + u8 test[3] = {GTP_REG_CONFIG_DATA >> 8, GTP_REG_CONFIG_DATA & 0xff}; |
---|
| 971 | + u8 retry = 0; |
---|
| 972 | + s8 ret = -1; |
---|
| 973 | + |
---|
| 974 | + while(retry++ < 2) { |
---|
| 975 | + ret = gtp_i2c_read(client, test, 3); |
---|
| 976 | + if (ret > 0) { |
---|
| 977 | + return ret; |
---|
| 978 | + } |
---|
| 979 | + printk("GTP i2c test failed time %d.",retry); |
---|
| 980 | + msleep(10); |
---|
| 981 | + } |
---|
| 982 | + return ret; |
---|
| 983 | +} |
---|
| 984 | + |
---|
| 985 | + |
---|
| 986 | +/******************************************************* |
---|
| 987 | +Function: |
---|
| 988 | +Request input device Function. |
---|
| 989 | + |
---|
| 990 | +Input: |
---|
| 991 | +ts:private data. |
---|
| 992 | + |
---|
| 993 | +Output: |
---|
| 994 | +Executive outcomes.0--success,non-0--fail. |
---|
| 995 | + *******************************************************/ |
---|
2132 | 996 | static s8 gtp_request_input_dev(struct goodix_ts_data *ts) |
---|
2133 | 997 | { |
---|
2134 | | - s8 ret = -1; |
---|
2135 | | - s8 phys[32]; |
---|
2136 | | - u8 index = 0; |
---|
2137 | | - |
---|
2138 | | - GTP_DEBUG_FUNC(); |
---|
2139 | | - |
---|
2140 | | - ts->input_dev = input_allocate_device(); |
---|
2141 | | - if (ts->input_dev == NULL) |
---|
2142 | | - { |
---|
2143 | | - GTP_ERROR("Failed to allocate input device."); |
---|
2144 | | - return -ENOMEM; |
---|
2145 | | - } |
---|
2146 | | - |
---|
2147 | | - ts->input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) ; |
---|
2148 | | -#if GTP_ICS_SLOT_REPORT |
---|
2149 | | - input_mt_init_slots(ts->input_dev, 16); // in case of "out of memory" |
---|
2150 | | -#else |
---|
2151 | | - ts->input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
---|
| 998 | + s8 ret = -1; |
---|
| 999 | +#if GTP_HAVE_TOUCH_KEY |
---|
| 1000 | + u8 index = 0; |
---|
2152 | 1001 | #endif |
---|
2153 | | - __set_bit(INPUT_PROP_DIRECT, ts->input_dev->propbit); |
---|
| 1002 | + |
---|
| 1003 | + ts->input_dev = input_allocate_device(); |
---|
| 1004 | + if (ts->input_dev == NULL) { |
---|
| 1005 | + GTP_ERROR("Failed to allocate input device."); |
---|
| 1006 | + return -ENOMEM; |
---|
| 1007 | + } |
---|
| 1008 | + |
---|
| 1009 | + ts->input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) ; |
---|
| 1010 | +#if GTP_ICS_SLOT_REPORT |
---|
| 1011 | + __set_bit(INPUT_PROP_DIRECT, ts->input_dev->propbit); |
---|
| 1012 | + input_mt_init_slots(ts->input_dev, 255, 1); |
---|
| 1013 | +#else |
---|
| 1014 | + ts->input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
---|
| 1015 | +#endif |
---|
2154 | 1016 | |
---|
2155 | 1017 | #if GTP_HAVE_TOUCH_KEY |
---|
2156 | | - for (index = 0; index < GTP_MAX_KEY_NUM; index++) |
---|
2157 | | - { |
---|
2158 | | - input_set_capability(ts->input_dev, EV_KEY, touch_key_array[index]); |
---|
2159 | | - } |
---|
| 1018 | + for (index = 0; index < GTP_MAX_KEY_NUM; index++) { |
---|
| 1019 | + input_set_capability(ts->input_dev,EV_KEY,touch_key_array[index]); |
---|
| 1020 | + } |
---|
2160 | 1021 | #endif |
---|
2161 | 1022 | |
---|
2162 | | -//#if GTP_GESTURE_WAKEUP |
---|
2163 | | -if(gtp_gesture_wakeup) |
---|
2164 | | - input_set_capability(ts->input_dev, EV_KEY, KEY_POWER); |
---|
2165 | | - for (index = 0; index < KEY_NUM; index++) |
---|
2166 | | - { |
---|
2167 | | - input_set_capability(ts->input_dev, EV_KEY, ctp_key_list[index]); |
---|
2168 | | - } |
---|
2169 | | -//#endif |
---|
| 1023 | + //#if GTP_CHANGE_X2Y |
---|
| 1024 | + // GTP_SWAP(ts->abs_x_max, ts->abs_y_max); |
---|
| 1025 | + //#endif |
---|
2170 | 1026 | |
---|
2171 | | -if(1 == exchange_x_y_flag) |
---|
2172 | | - swap(ts->abs_x_max, ts->abs_y_max); |
---|
| 1027 | + set_bit(ABS_MT_POSITION_X, ts->input_dev->absbit); |
---|
| 1028 | + set_bit(ABS_MT_POSITION_Y, ts->input_dev->absbit); |
---|
| 1029 | + set_bit(ABS_MT_TOUCH_MAJOR, ts->input_dev->absbit); |
---|
| 1030 | + set_bit(ABS_MT_WIDTH_MAJOR, ts->input_dev->absbit); |
---|
2173 | 1031 | |
---|
2174 | 1032 | |
---|
2175 | | - input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 0, ts->abs_x_max, 0, 0); |
---|
2176 | | - input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, ts->abs_y_max, 0, 0); |
---|
2177 | | - input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0); |
---|
2178 | | - input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); |
---|
2179 | | - input_set_abs_params(ts->input_dev, ABS_MT_TRACKING_ID, 0, 255, 0, 0); |
---|
2180 | 1033 | |
---|
2181 | | - sprintf(phys, "input/ts"); |
---|
2182 | | - ts->input_dev->name = CTP_NAME; |
---|
2183 | | - ts->input_dev->phys = phys; |
---|
2184 | | - ts->input_dev->id.bustype = BUS_I2C; |
---|
2185 | | - ts->input_dev->id.vendor = 0xDEAD; |
---|
2186 | | - ts->input_dev->id.product = 0xBEEF; |
---|
2187 | | - ts->input_dev->id.version = 10427; |
---|
| 1034 | + input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 0, SCREEN_MAX_X, 0, 0); |
---|
| 1035 | + input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, SCREEN_MAX_Y, 0, 0); |
---|
| 1036 | + input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0); |
---|
| 1037 | + input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); |
---|
| 1038 | + input_set_abs_params(ts->input_dev, ABS_MT_TRACKING_ID, 0, 255, 0, 0); |
---|
| 1039 | + __set_bit(INPUT_PROP_DIRECT, ts->input_dev->propbit); |
---|
2188 | 1040 | |
---|
2189 | | - ret = input_register_device(ts->input_dev); |
---|
2190 | | - if (ret) |
---|
2191 | | - { |
---|
2192 | | - GTP_ERROR("Register %s input device failed", ts->input_dev->name); |
---|
2193 | | - return -ENODEV; |
---|
2194 | | - } |
---|
2195 | | - ret = sysfs_create_group(&ts->input_dev->dev.kobj, >p_attribute_group); |
---|
2196 | | - if(ret) { |
---|
2197 | | - GTP_ERROR("create sys failed\n"); |
---|
2198 | | - } |
---|
2199 | | - |
---|
| 1041 | + ts->input_dev->name = CTP_NAME; |
---|
| 1042 | + ts->input_dev->phys = "input/goodix-ts"; |
---|
| 1043 | + ts->input_dev->id.bustype = BUS_I2C; |
---|
| 1044 | + ts->input_dev->id.vendor = 0xDEAD; |
---|
| 1045 | + ts->input_dev->id.product = 0xBEEF; |
---|
| 1046 | + ts->input_dev->id.version = 10427; |
---|
| 1047 | + ret = input_register_device(ts->input_dev); |
---|
| 1048 | + if (ret) { |
---|
| 1049 | + printk("Register %s input device failed", ts->input_dev->name); |
---|
| 1050 | + return -ENODEV; |
---|
| 1051 | + } |
---|
2200 | 1052 | #ifdef CONFIG_HAS_EARLYSUSPEND |
---|
2201 | | - ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; |
---|
2202 | | - ts->early_suspend.suspend = goodix_ts_early_suspend; |
---|
2203 | | - ts->early_suspend.resume = goodix_ts_late_resume; |
---|
2204 | | - register_early_suspend(&ts->early_suspend); |
---|
| 1053 | + ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; |
---|
| 1054 | + ts->early_suspend.suspend = goodix_ts_early_suspend; |
---|
| 1055 | + ts->early_suspend.resume = goodix_ts_late_resume; |
---|
| 1056 | + register_early_suspend(&ts->early_suspend); |
---|
2205 | 1057 | #endif |
---|
2206 | | - |
---|
2207 | | -#if GTP_WITH_PEN |
---|
2208 | | - gtp_pen_init(ts); |
---|
2209 | | -#endif |
---|
2210 | | - |
---|
2211 | | - return 0; |
---|
| 1058 | + return 0; |
---|
2212 | 1059 | } |
---|
2213 | 1060 | |
---|
2214 | | -//************** For GT9XXF Start *************// |
---|
2215 | | -#if GTP_COMPATIBLE_MODE |
---|
2216 | | - |
---|
2217 | | -s32 gtp_fw_startup(struct i2c_client *client) |
---|
2218 | | -{ |
---|
2219 | | - u8 opr_buf[4]; |
---|
2220 | | - s32 ret = 0; |
---|
2221 | | - |
---|
2222 | | - //init sw WDT |
---|
2223 | | - opr_buf[0] = 0xAA; |
---|
2224 | | - ret = i2c_write_bytes(client, 0x8041, opr_buf, 1); |
---|
2225 | | - if (ret < 0) |
---|
2226 | | - { |
---|
2227 | | - return FAIL; |
---|
2228 | | - } |
---|
2229 | | - |
---|
2230 | | - //release SS51 & DSP |
---|
2231 | | - opr_buf[0] = 0x00; |
---|
2232 | | - ret = i2c_write_bytes(client, 0x4180, opr_buf, 1); |
---|
2233 | | - if (ret < 0) |
---|
2234 | | - { |
---|
2235 | | - return FAIL; |
---|
2236 | | - } |
---|
2237 | | - //int sync |
---|
2238 | | - gtp_int_sync(25); |
---|
2239 | | - |
---|
2240 | | - //check fw run status |
---|
2241 | | - ret = i2c_read_bytes(client, 0x8041, opr_buf, 1); |
---|
2242 | | - if (ret < 0) |
---|
2243 | | - { |
---|
2244 | | - return FAIL; |
---|
2245 | | - } |
---|
2246 | | - if(0xAA == opr_buf[0]) |
---|
2247 | | - { |
---|
2248 | | - GTP_ERROR("IC works abnormally,startup failed."); |
---|
2249 | | - return FAIL; |
---|
2250 | | - } |
---|
2251 | | - else |
---|
2252 | | - { |
---|
2253 | | - GTP_INFO("IC works normally, Startup success."); |
---|
2254 | | - opr_buf[0] = 0xAA; |
---|
2255 | | - i2c_write_bytes(client, 0x8041, opr_buf, 1); |
---|
2256 | | - return SUCCESS; |
---|
2257 | | - } |
---|
2258 | | -} |
---|
2259 | | - |
---|
2260 | | -static s32 gtp_esd_recovery(struct i2c_client *client) |
---|
2261 | | -{ |
---|
2262 | | - s32 retry = 0; |
---|
2263 | | - s32 ret = 0; |
---|
2264 | | - struct goodix_ts_data *ts; |
---|
2265 | | - |
---|
2266 | | - ts = i2c_get_clientdata(client); |
---|
2267 | | - |
---|
2268 | | - gtp_irq_disable(ts); |
---|
2269 | | - |
---|
2270 | | - GTP_INFO("GT9XXF esd recovery mode"); |
---|
2271 | | - for (retry = 0; retry < 5; retry++) |
---|
2272 | | - { |
---|
2273 | | - ret = gup_fw_download_proc(NULL, GTP_FL_ESD_RECOVERY); |
---|
2274 | | - if (FAIL == ret) |
---|
2275 | | - { |
---|
2276 | | - GTP_ERROR("esd recovery failed %d", retry+1); |
---|
2277 | | - continue; |
---|
2278 | | - } |
---|
2279 | | - ret = gtp_fw_startup(ts->client); |
---|
2280 | | - if (FAIL == ret) |
---|
2281 | | - { |
---|
2282 | | - GTP_ERROR("GT9XXF start up failed %d", retry+1); |
---|
2283 | | - continue; |
---|
2284 | | - } |
---|
2285 | | - break; |
---|
2286 | | - } |
---|
2287 | | - gtp_irq_enable(ts); |
---|
2288 | | - |
---|
2289 | | - if (retry >= 5) |
---|
2290 | | - { |
---|
2291 | | - GTP_ERROR("failed to esd recovery"); |
---|
2292 | | - return FAIL; |
---|
2293 | | - } |
---|
2294 | | - |
---|
2295 | | - GTP_INFO("Esd recovery successful"); |
---|
2296 | | - return SUCCESS; |
---|
2297 | | -} |
---|
2298 | | - |
---|
2299 | | -void gtp_recovery_reset(struct i2c_client *client) |
---|
2300 | | -{ |
---|
2301 | | -#if GTP_ESD_PROTECT |
---|
2302 | | - gtp_esd_switch(client, SWITCH_OFF); |
---|
2303 | | -#endif |
---|
2304 | | - GTP_DEBUG_FUNC(); |
---|
2305 | | - |
---|
2306 | | - gtp_esd_recovery(client); |
---|
2307 | | - |
---|
2308 | | -#if GTP_ESD_PROTECT |
---|
2309 | | - gtp_esd_switch(client, SWITCH_ON); |
---|
2310 | | -#endif |
---|
2311 | | -} |
---|
2312 | | - |
---|
2313 | | -static s32 gtp_bak_ref_proc(struct goodix_ts_data *ts, u8 mode) |
---|
2314 | | -{ |
---|
2315 | | - s32 ret = 0; |
---|
2316 | | - s32 i = 0; |
---|
2317 | | - s32 j = 0; |
---|
2318 | | - u16 ref_sum = 0; |
---|
2319 | | - u16 learn_cnt = 0; |
---|
2320 | | - u16 chksum = 0; |
---|
2321 | | - s32 ref_seg_len = 0; |
---|
2322 | | - s32 ref_grps = 0; |
---|
2323 | | - struct file *ref_filp = NULL; |
---|
2324 | | - u8 *p_bak_ref; |
---|
2325 | | - |
---|
2326 | | - ret = gup_check_fs_mounted("/data"); |
---|
2327 | | - if (FAIL == ret) |
---|
2328 | | - { |
---|
2329 | | - ts->ref_chk_fs_times++; |
---|
2330 | | - GTP_DEBUG("Ref check /data times/MAX_TIMES: %d / %d", ts->ref_chk_fs_times, GTP_CHK_FS_MNT_MAX); |
---|
2331 | | - if (ts->ref_chk_fs_times < GTP_CHK_FS_MNT_MAX) |
---|
2332 | | - { |
---|
2333 | | - msleep(50); |
---|
2334 | | - GTP_INFO("/data not mounted."); |
---|
2335 | | - return FAIL; |
---|
2336 | | - } |
---|
2337 | | - GTP_INFO("check /data mount timeout..."); |
---|
2338 | | - } |
---|
2339 | | - else |
---|
2340 | | - { |
---|
2341 | | - GTP_INFO("/data mounted!!!(%d/%d)", ts->ref_chk_fs_times, GTP_CHK_FS_MNT_MAX); |
---|
2342 | | - } |
---|
2343 | | - |
---|
2344 | | - p_bak_ref = (u8 *)kzalloc(ts->bak_ref_len, GFP_KERNEL); |
---|
2345 | | - |
---|
2346 | | - if (NULL == p_bak_ref) |
---|
2347 | | - { |
---|
2348 | | - GTP_ERROR("Allocate memory for p_bak_ref failed!"); |
---|
2349 | | - return FAIL; |
---|
2350 | | - } |
---|
2351 | | - |
---|
2352 | | - if (ts->is_950) |
---|
2353 | | - { |
---|
2354 | | - ref_seg_len = ts->bak_ref_len / 6; |
---|
2355 | | - ref_grps = 6; |
---|
2356 | | - } |
---|
2357 | | - else |
---|
2358 | | - { |
---|
2359 | | - ref_seg_len = ts->bak_ref_len; |
---|
2360 | | - ref_grps = 1; |
---|
2361 | | - } |
---|
2362 | | - ref_filp = filp_open(GTP_BAK_REF_PATH, O_RDWR | O_CREAT, 0666); |
---|
2363 | | - if (IS_ERR(ref_filp)) |
---|
2364 | | - { |
---|
2365 | | - GTP_ERROR("Failed to open/create %s.", GTP_BAK_REF_PATH); |
---|
2366 | | - if (GTP_BAK_REF_SEND == mode) |
---|
2367 | | - { |
---|
2368 | | - goto bak_ref_default; |
---|
2369 | | - } |
---|
2370 | | - else |
---|
2371 | | - { |
---|
2372 | | - goto bak_ref_exit; |
---|
2373 | | - } |
---|
2374 | | - } |
---|
2375 | | - |
---|
2376 | | - switch (mode) |
---|
2377 | | - { |
---|
2378 | | - case GTP_BAK_REF_SEND: |
---|
2379 | | - GTP_INFO("Send backup-reference"); |
---|
2380 | | - ref_filp->f_op->llseek(ref_filp, 0, SEEK_SET); |
---|
2381 | | - ret = ref_filp->f_op->read(ref_filp, (char*)p_bak_ref, ts->bak_ref_len, &ref_filp->f_pos); |
---|
2382 | | - if (ret < 0) |
---|
2383 | | - { |
---|
2384 | | - GTP_ERROR("failed to read bak_ref info from file, sending defualt bak_ref"); |
---|
2385 | | - goto bak_ref_default; |
---|
2386 | | - } |
---|
2387 | | - for (j = 0; j < ref_grps; ++j) |
---|
2388 | | - { |
---|
2389 | | - ref_sum = 0; |
---|
2390 | | - for (i = 0; i < (ref_seg_len); i += 2) |
---|
2391 | | - { |
---|
2392 | | - ref_sum += (p_bak_ref[i + j * ref_seg_len] << 8) + p_bak_ref[i+1 + j * ref_seg_len]; |
---|
2393 | | - } |
---|
2394 | | - learn_cnt = (p_bak_ref[j * ref_seg_len + ref_seg_len -4] << 8) + (p_bak_ref[j * ref_seg_len + ref_seg_len -3]); |
---|
2395 | | - chksum = (p_bak_ref[j * ref_seg_len + ref_seg_len -2] << 8) + (p_bak_ref[j * ref_seg_len + ref_seg_len -1]); |
---|
2396 | | - GTP_DEBUG("learn count = %d", learn_cnt); |
---|
2397 | | - GTP_DEBUG("chksum = %d", chksum); |
---|
2398 | | - GTP_DEBUG("ref_sum = 0x%04X", ref_sum & 0xFFFF); |
---|
2399 | | - // Sum(1~ref_seg_len) == 1 |
---|
2400 | | - if (1 != ref_sum) |
---|
2401 | | - { |
---|
2402 | | - GTP_INFO("wrong chksum for bak_ref, reset to 0x00 bak_ref"); |
---|
2403 | | - memset(&p_bak_ref[j * ref_seg_len], 0, ref_seg_len); |
---|
2404 | | - p_bak_ref[ref_seg_len + j * ref_seg_len - 1] = 0x01; |
---|
2405 | | - } |
---|
2406 | | - else |
---|
2407 | | - { |
---|
2408 | | - if (j == (ref_grps - 1)) |
---|
2409 | | - { |
---|
2410 | | - GTP_INFO("backup-reference data in %s used", GTP_BAK_REF_PATH); |
---|
2411 | | - } |
---|
2412 | | - } |
---|
2413 | | - } |
---|
2414 | | - ret = i2c_write_bytes(ts->client, GTP_REG_BAK_REF, p_bak_ref, ts->bak_ref_len); |
---|
2415 | | - if (FAIL == ret) |
---|
2416 | | - { |
---|
2417 | | - GTP_ERROR("failed to send bak_ref because of iic comm error"); |
---|
2418 | | - goto bak_ref_exit; |
---|
2419 | | - } |
---|
2420 | | - break; |
---|
2421 | | - |
---|
2422 | | - case GTP_BAK_REF_STORE: |
---|
2423 | | - GTP_INFO("Store backup-reference"); |
---|
2424 | | - ret = i2c_read_bytes(ts->client, GTP_REG_BAK_REF, p_bak_ref, ts->bak_ref_len); |
---|
2425 | | - if (ret < 0) |
---|
2426 | | - { |
---|
2427 | | - GTP_ERROR("failed to read bak_ref info, sending default back-reference"); |
---|
2428 | | - goto bak_ref_default; |
---|
2429 | | - } |
---|
2430 | | - ref_filp->f_op->llseek(ref_filp, 0, SEEK_SET); |
---|
2431 | | - ref_filp->f_op->write(ref_filp, (char*)p_bak_ref, ts->bak_ref_len, &ref_filp->f_pos); |
---|
2432 | | - break; |
---|
2433 | | - |
---|
2434 | | - default: |
---|
2435 | | - GTP_ERROR("invalid backup-reference request"); |
---|
2436 | | - break; |
---|
2437 | | - } |
---|
2438 | | - ret = SUCCESS; |
---|
2439 | | - goto bak_ref_exit; |
---|
2440 | | - |
---|
2441 | | -bak_ref_default: |
---|
2442 | | - |
---|
2443 | | - for (j = 0; j < ref_grps; ++j) |
---|
2444 | | - { |
---|
2445 | | - memset(&p_bak_ref[j * ref_seg_len], 0, ref_seg_len); |
---|
2446 | | - p_bak_ref[j * ref_seg_len + ref_seg_len - 1] = 0x01; // checksum = 1 |
---|
2447 | | - } |
---|
2448 | | - ret = i2c_write_bytes(ts->client, GTP_REG_BAK_REF, p_bak_ref, ts->bak_ref_len); |
---|
2449 | | - if (!IS_ERR(ref_filp)) |
---|
2450 | | - { |
---|
2451 | | - GTP_INFO("write backup-reference data into %s", GTP_BAK_REF_PATH); |
---|
2452 | | - ref_filp->f_op->llseek(ref_filp, 0, SEEK_SET); |
---|
2453 | | - ref_filp->f_op->write(ref_filp, (char*)p_bak_ref, ts->bak_ref_len, &ref_filp->f_pos); |
---|
2454 | | - } |
---|
2455 | | - if (ret == FAIL) |
---|
2456 | | - { |
---|
2457 | | - GTP_ERROR("failed to load the default backup reference"); |
---|
2458 | | - } |
---|
2459 | | - |
---|
2460 | | -bak_ref_exit: |
---|
2461 | | - |
---|
2462 | | - if (p_bak_ref) |
---|
2463 | | - { |
---|
2464 | | - kfree(p_bak_ref); |
---|
2465 | | - } |
---|
2466 | | - if (ref_filp && !IS_ERR(ref_filp)) |
---|
2467 | | - { |
---|
2468 | | - filp_close(ref_filp, NULL); |
---|
2469 | | - } |
---|
2470 | | - return ret; |
---|
2471 | | -} |
---|
2472 | | - |
---|
2473 | | - |
---|
2474 | | -static s32 gtp_verify_main_clk(u8 *p_main_clk) |
---|
2475 | | -{ |
---|
2476 | | - u8 chksum = 0; |
---|
2477 | | - u8 main_clock = p_main_clk[0]; |
---|
2478 | | - s32 i = 0; |
---|
2479 | | - |
---|
2480 | | - if (main_clock < 50 || main_clock > 120) |
---|
2481 | | - { |
---|
2482 | | - return FAIL; |
---|
2483 | | - } |
---|
2484 | | - |
---|
2485 | | - for (i = 0; i < 5; ++i) |
---|
2486 | | - { |
---|
2487 | | - if (main_clock != p_main_clk[i]) |
---|
2488 | | - { |
---|
2489 | | - return FAIL; |
---|
2490 | | - } |
---|
2491 | | - chksum += p_main_clk[i]; |
---|
2492 | | - } |
---|
2493 | | - chksum += p_main_clk[5]; |
---|
2494 | | - if ( (chksum) == 0) |
---|
2495 | | - { |
---|
2496 | | - return SUCCESS; |
---|
2497 | | - } |
---|
2498 | | - else |
---|
2499 | | - { |
---|
2500 | | - return FAIL; |
---|
2501 | | - } |
---|
2502 | | -} |
---|
2503 | | - |
---|
2504 | | -static s32 gtp_main_clk_proc(struct goodix_ts_data *ts) |
---|
2505 | | -{ |
---|
2506 | | - s32 ret = 0; |
---|
2507 | | - s32 i = 0; |
---|
2508 | | - s32 clk_chksum = 0; |
---|
2509 | | - struct file *clk_filp = NULL; |
---|
2510 | | - u8 p_main_clk[6] = {0}; |
---|
2511 | | - |
---|
2512 | | - ret = gup_check_fs_mounted("/data"); |
---|
2513 | | - if (FAIL == ret) |
---|
2514 | | - { |
---|
2515 | | - ts->clk_chk_fs_times++; |
---|
2516 | | - GTP_DEBUG("Clock check /data times/MAX_TIMES: %d / %d", ts->clk_chk_fs_times, GTP_CHK_FS_MNT_MAX); |
---|
2517 | | - if (ts->clk_chk_fs_times < GTP_CHK_FS_MNT_MAX) |
---|
2518 | | - { |
---|
2519 | | - msleep(50); |
---|
2520 | | - GTP_INFO("/data not mounted."); |
---|
2521 | | - return FAIL; |
---|
2522 | | - } |
---|
2523 | | - GTP_INFO("Check /data mount timeout!"); |
---|
2524 | | - } |
---|
2525 | | - else |
---|
2526 | | - { |
---|
2527 | | - GTP_INFO("/data mounted!!!(%d/%d)", ts->clk_chk_fs_times, GTP_CHK_FS_MNT_MAX); |
---|
2528 | | - } |
---|
2529 | | - |
---|
2530 | | - clk_filp = filp_open(GTP_MAIN_CLK_PATH, O_RDWR | O_CREAT, 0666); |
---|
2531 | | - if (IS_ERR(clk_filp)) |
---|
2532 | | - { |
---|
2533 | | - GTP_ERROR("%s is unavailable, calculate main clock", GTP_MAIN_CLK_PATH); |
---|
2534 | | - } |
---|
2535 | | - else |
---|
2536 | | - { |
---|
2537 | | - clk_filp->f_op->llseek(clk_filp, 0, SEEK_SET); |
---|
2538 | | - clk_filp->f_op->read(clk_filp, (char *)p_main_clk, 6, &clk_filp->f_pos); |
---|
2539 | | - |
---|
2540 | | - ret = gtp_verify_main_clk(p_main_clk); |
---|
2541 | | - if (FAIL == ret) |
---|
2542 | | - { |
---|
2543 | | - // recalculate main clock & rewrite main clock data to file |
---|
2544 | | - GTP_ERROR("main clock data in %s is wrong, recalculate main clock", GTP_MAIN_CLK_PATH); |
---|
2545 | | - } |
---|
2546 | | - else |
---|
2547 | | - { |
---|
2548 | | - GTP_INFO("main clock data in %s used, main clock freq: %d", GTP_MAIN_CLK_PATH, p_main_clk[0]); |
---|
2549 | | - filp_close(clk_filp, NULL); |
---|
2550 | | - goto update_main_clk; |
---|
2551 | | - } |
---|
2552 | | - } |
---|
2553 | | - |
---|
2554 | | -#if GTP_ESD_PROTECT |
---|
2555 | | - gtp_esd_switch(ts->client, SWITCH_OFF); |
---|
2556 | | -#endif |
---|
2557 | | - ret = gup_clk_calibration(); |
---|
2558 | | - gtp_esd_recovery(ts->client); |
---|
2559 | | - |
---|
2560 | | -#if GTP_ESD_PROTECT |
---|
2561 | | - gtp_esd_switch(ts->client, SWITCH_ON); |
---|
2562 | | -#endif |
---|
2563 | | - |
---|
2564 | | - GTP_INFO("calibrate main clock: %d", ret); |
---|
2565 | | - if (ret < 50 || ret > 120) |
---|
2566 | | - { |
---|
2567 | | - GTP_ERROR("wrong main clock: %d", ret); |
---|
2568 | | - goto exit_main_clk; |
---|
2569 | | - } |
---|
2570 | | - |
---|
2571 | | - // Sum{0x8020~0x8025} = 0 |
---|
2572 | | - for (i = 0; i < 5; ++i) |
---|
2573 | | - { |
---|
2574 | | - p_main_clk[i] = ret; |
---|
2575 | | - clk_chksum += p_main_clk[i]; |
---|
2576 | | - } |
---|
2577 | | - p_main_clk[5] = 0 - clk_chksum; |
---|
2578 | | - |
---|
2579 | | - if (!IS_ERR(clk_filp)) |
---|
2580 | | - { |
---|
2581 | | - GTP_DEBUG("write main clock data into %s", GTP_MAIN_CLK_PATH); |
---|
2582 | | - clk_filp->f_op->llseek(clk_filp, 0, SEEK_SET); |
---|
2583 | | - clk_filp->f_op->write(clk_filp, (char *)p_main_clk, 6, &clk_filp->f_pos); |
---|
2584 | | - filp_close(clk_filp, NULL); |
---|
2585 | | - } |
---|
2586 | | - |
---|
2587 | | -update_main_clk: |
---|
2588 | | - ret = i2c_write_bytes(ts->client, GTP_REG_MAIN_CLK, p_main_clk, 6); |
---|
2589 | | - if (FAIL == ret) |
---|
2590 | | - { |
---|
2591 | | - GTP_ERROR("update main clock failed!"); |
---|
2592 | | - return FAIL; |
---|
2593 | | - } |
---|
2594 | | - return SUCCESS; |
---|
2595 | | - |
---|
2596 | | -exit_main_clk: |
---|
2597 | | - if (!IS_ERR(clk_filp)) |
---|
2598 | | - { |
---|
2599 | | - filp_close(clk_filp, NULL); |
---|
2600 | | - } |
---|
2601 | | - return FAIL; |
---|
2602 | | -} |
---|
2603 | | - |
---|
2604 | | - |
---|
2605 | | -s32 gtp_gt9xxf_init(struct i2c_client *client) |
---|
2606 | | -{ |
---|
2607 | | - s32 ret = 0; |
---|
2608 | | - |
---|
2609 | | - ret = gup_fw_download_proc(NULL, GTP_FL_FW_BURN); |
---|
2610 | | - if (FAIL == ret) |
---|
2611 | | - { |
---|
2612 | | - return FAIL; |
---|
2613 | | - } |
---|
2614 | | - |
---|
2615 | | - ret = gtp_fw_startup(client); |
---|
2616 | | - if (FAIL == ret) |
---|
2617 | | - { |
---|
2618 | | - return FAIL; |
---|
2619 | | - } |
---|
2620 | | - return SUCCESS; |
---|
2621 | | -} |
---|
2622 | | - |
---|
2623 | | -void gtp_get_chip_type(struct goodix_ts_data *ts) |
---|
2624 | | -{ |
---|
2625 | | - u8 opr_buf[10] = {0x00}; |
---|
2626 | | - s32 ret = 0; |
---|
2627 | | - |
---|
2628 | | - msleep(10); |
---|
2629 | | - |
---|
2630 | | - ret = gtp_i2c_read_dbl_check(ts->client, GTP_REG_CHIP_TYPE, opr_buf, 10); |
---|
2631 | | - |
---|
2632 | | - if (FAIL == ret) |
---|
2633 | | - { |
---|
2634 | | - GTP_ERROR("Failed to get chip-type, set chip type default: GOODIX_GT9"); |
---|
2635 | | - ts->chip_type = CHIP_TYPE_GT9; |
---|
2636 | | - return; |
---|
2637 | | - } |
---|
2638 | | - |
---|
2639 | | - if (!memcmp(opr_buf, "GOODIX_GT9", 10)) |
---|
2640 | | - { |
---|
2641 | | - ts->chip_type = CHIP_TYPE_GT9; |
---|
2642 | | - } |
---|
2643 | | - else // GT9XXF |
---|
2644 | | - { |
---|
2645 | | - ts->chip_type = CHIP_TYPE_GT9F; |
---|
2646 | | - } |
---|
2647 | | - GTP_INFO("Chip Type: %s", (ts->chip_type == CHIP_TYPE_GT9) ? "GOODIX_GT9" : "GOODIX_GT9F"); |
---|
2648 | | -} |
---|
2649 | | - |
---|
2650 | | -#endif |
---|
2651 | | -//************* For GT9XXF End ************// |
---|
2652 | 1061 | |
---|
2653 | 1062 | /******************************************************* |
---|
2654 | 1063 | Function: |
---|
2655 | | - I2c probe. |
---|
| 1064 | +Goodix touchscreen probe function. |
---|
| 1065 | + |
---|
2656 | 1066 | Input: |
---|
2657 | | - client: i2c device struct. |
---|
2658 | | - id: device id. |
---|
| 1067 | +client: i2c device struct. |
---|
| 1068 | +id:device id. |
---|
| 1069 | + |
---|
2659 | 1070 | Output: |
---|
2660 | | - Executive outcomes. |
---|
2661 | | - 0: succeed. |
---|
2662 | | -*******************************************************/ |
---|
| 1071 | +Executive outcomes. 0---succeed. |
---|
| 1072 | + *******************************************************/ |
---|
2663 | 1073 | static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) |
---|
2664 | 1074 | { |
---|
2665 | | - s32 ret = -1; |
---|
2666 | | - struct goodix_ts_data *ts; |
---|
2667 | | - u16 version_info; |
---|
| 1075 | + s32 ret = -1; |
---|
| 1076 | + struct goodix_ts_data *ts; |
---|
| 1077 | + u16 version_info; |
---|
2668 | 1078 | |
---|
2669 | | - //do NOT remove these logs |
---|
2670 | | - dprintk(DEBUG_INIT,"GTP Driver Version: %s", GTP_DRIVER_VERSION); |
---|
2671 | | - dprintk(DEBUG_INIT,"GTP I2C Address: 0x%02x", client->addr); |
---|
2672 | | - config_info.probed = 0; |
---|
| 1079 | + dprintk(DEBUG_INIT, "GTP Driver Version:%s\n",GTP_DRIVER_VERSION); |
---|
| 1080 | + printk("GTP I2C Address:0x%02x\n", client->addr); |
---|
2673 | 1081 | |
---|
2674 | | - i2c_connect_client = client; |
---|
2675 | | - |
---|
| 1082 | + i2c_connect_client = client; |
---|
2676 | 1083 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { |
---|
2677 | 1084 | printk("I2C check functionality failed.\n"); |
---|
2678 | 1085 | return -ENODEV; |
---|
2679 | 1086 | } |
---|
2680 | | - if (config_info.dev == NULL) |
---|
2681 | | - config_info.dev = &client->dev; |
---|
2682 | 1087 | |
---|
2683 | | -#if !USE_DETECT |
---|
2684 | | - if (!gUseDetect && startup()) { |
---|
2685 | | - printk("can not startup device!\n"); |
---|
2686 | | - goto fail; |
---|
2687 | | - } |
---|
2688 | | -#endif |
---|
2689 | 1088 | ts = kzalloc(sizeof(*ts), GFP_KERNEL); |
---|
2690 | 1089 | if (ts == NULL) { |
---|
2691 | 1090 | printk("Alloc GFP_KERNEL memory failed.\n"); |
---|
2692 | | - goto fail; |
---|
| 1091 | + return -ENOMEM; |
---|
2693 | 1092 | } |
---|
2694 | 1093 | |
---|
2695 | | - memset(ts, 0, sizeof(*ts)); |
---|
2696 | | - INIT_WORK(&ts->work, goodix_ts_work_func); |
---|
2697 | | - ts->client = client; |
---|
2698 | | - spin_lock_init(&ts->irq_lock); // 2.6.39 later |
---|
2699 | | - // ts->irq_lock = SPIN_LOCK_UNLOCKED; // 2.6.39 & before |
---|
2700 | | -#if GTP_ESD_PROTECT |
---|
2701 | | - ts->clk_tick_cnt = 2 * HZ; // HZ: clock ticks in 1 second generated by system |
---|
2702 | | - GTP_DEBUG("Clock ticks for an esd cycle: %d", ts->clk_tick_cnt); |
---|
2703 | | - spin_lock_init(&ts->esd_lock); |
---|
2704 | | - // ts->esd_lock = SPIN_LOCK_UNLOCKED; |
---|
2705 | | -#endif |
---|
2706 | | - i2c_set_clientdata(client, ts); |
---|
| 1094 | + memset(ts, 0, sizeof(*ts)); |
---|
| 1095 | + INIT_WORK(&ts->work, goodix_ts_work_func); |
---|
| 1096 | + ts->client = client; |
---|
| 1097 | + i2c_set_clientdata(client, ts); |
---|
| 1098 | + //ts->irq_lock = SPIN_LOCK_UNLOCKED; |
---|
| 1099 | + ts->gtp_rawdiff_mode = 0; |
---|
2707 | 1100 | |
---|
2708 | | - ts->gtp_rawdiff_mode = 0; |
---|
2709 | | - ts->gtp_is_suspend = 0; |
---|
2710 | 1101 | |
---|
2711 | | -#if GTP_COMPATIBLE_MODE |
---|
2712 | | - gtp_get_chip_type(ts); |
---|
2713 | | - |
---|
2714 | | - if (CHIP_TYPE_GT9F == ts->chip_type) |
---|
2715 | | - { |
---|
2716 | | - ret = gtp_gt9xxf_init(ts->client); |
---|
2717 | | - if (FAIL == ret) |
---|
2718 | | - { |
---|
2719 | | - printk("Failed to init GT9XXF."); |
---|
2720 | | - } |
---|
2721 | | - } |
---|
2722 | | -#endif |
---|
2723 | | -#if GTP_I2C_TEST |
---|
2724 | | - ret = gtp_i2c_test(client); |
---|
2725 | | - if (ret < 0) |
---|
2726 | | - { |
---|
2727 | | - printk("I2C communication ERROR!"); |
---|
2728 | | - goto fail; |
---|
2729 | | - } |
---|
2730 | | -#endif |
---|
2731 | | - ret = gtp_read_version(client, &version_info); |
---|
2732 | | - if (ret < 0) { |
---|
2733 | | - printk("Read version failed."); |
---|
| 1102 | + ret = gtp_i2c_test(client); |
---|
| 1103 | + if (ret < 0){ |
---|
| 1104 | + printk("I2C communication ERROR!\n"); |
---|
| 1105 | + goto exit_device_detect; |
---|
2734 | 1106 | } |
---|
2735 | 1107 | |
---|
2736 | | - ret = gtp_init_panel(ts); |
---|
2737 | | - if (ret < 0) |
---|
2738 | | - { |
---|
2739 | | - printk("GTP init panel failed."); |
---|
2740 | | - } |
---|
| 1108 | + printk(KERN_ALERT "create_singlethread_workqueue goodix_resume.\n"); |
---|
| 1109 | + goodix_resume_wq = create_singlethread_workqueue("goodix_resume"); |
---|
| 1110 | + if (goodix_resume_wq == NULL) { |
---|
| 1111 | + printk("create goodix_resume_wq fail!\n"); |
---|
| 1112 | + return -ENOMEM; |
---|
| 1113 | + } |
---|
2741 | 1114 | |
---|
2742 | | - // Create proc file system |
---|
2743 | | - gt91xx_config_proc = proc_create(GT91XX_CONFIG_PROC_FILE, 0666, NULL, &config_proc_ops); |
---|
2744 | | - if (gt91xx_config_proc == NULL) |
---|
2745 | | - { |
---|
2746 | | - GTP_ERROR("create_proc_entry %s failed\n", GT91XX_CONFIG_PROC_FILE); |
---|
2747 | | - } |
---|
2748 | | - else |
---|
2749 | | - { |
---|
2750 | | - GTP_INFO("create proc entry %s success", GT91XX_CONFIG_PROC_FILE); |
---|
2751 | | - } |
---|
| 1115 | + printk(KERN_ALERT "create_singlethread_workqueue goodix_wq.\n"); |
---|
| 1116 | + |
---|
| 1117 | + goodix_wq = create_singlethread_workqueue("goodix_wq"); |
---|
| 1118 | + if (!goodix_wq) { |
---|
| 1119 | + printk(KERN_ALERT "Creat goodix_wq workqueue failed.\n"); |
---|
| 1120 | + return -ENOMEM; |
---|
| 1121 | + } |
---|
2752 | 1122 | |
---|
2753 | 1123 | #if GTP_AUTO_UPDATE |
---|
2754 | | - ret = gup_init_update_proc(ts); |
---|
2755 | | - if (ret < 0) |
---|
2756 | | - { |
---|
2757 | | - GTP_ERROR("Create update thread error."); |
---|
2758 | | - } |
---|
| 1124 | + //ret = gup_init_update_proc(ts); |
---|
| 1125 | + // if (ret < 0) { |
---|
| 1126 | + // printk("Create update thread error."); |
---|
| 1127 | + // } |
---|
2759 | 1128 | #endif |
---|
| 1129 | + ret = gtp_init_panel(ts); |
---|
| 1130 | + if (ret < 0) { |
---|
| 1131 | + printk("GTP init panel failed.\n"); |
---|
| 1132 | + } |
---|
| 1133 | + |
---|
2760 | 1134 | |
---|
2761 | 1135 | ret = gtp_request_input_dev(ts); |
---|
2762 | 1136 | if (ret < 0) { |
---|
2763 | | - GTP_ERROR("GTP request input dev failed"); |
---|
| 1137 | + printk("GTP request input dev failed\n"); |
---|
| 1138 | + goto exit_device_detect; |
---|
2764 | 1139 | } |
---|
2765 | 1140 | |
---|
2766 | | - ret = gtp_request_irq(ts); |
---|
2767 | | - if (ret < 0) |
---|
2768 | | - { |
---|
2769 | | - GTP_INFO("GTP works in polling mode."); |
---|
2770 | | - } |
---|
2771 | | - else |
---|
2772 | | - { |
---|
2773 | | - GTP_INFO("GTP works in interrupt mode."); |
---|
2774 | | - } |
---|
| 1141 | + ret = gtp_read_version(client, &version_info); |
---|
| 1142 | + if (ret < 0) { |
---|
| 1143 | + printk("Read version failed."); |
---|
| 1144 | + } |
---|
2775 | 1145 | |
---|
2776 | | - if (ts->use_irq) |
---|
2777 | | - { |
---|
2778 | | - gtp_irq_enable(ts); |
---|
2779 | | - } |
---|
| 1146 | + config_info.dev = &(ts->input_dev->dev); |
---|
| 1147 | + |
---|
| 1148 | + ret = input_request_int(&(config_info.input_type), goodix_ts_irq_handler,CTP_IRQ_MODE, ts); |
---|
| 1149 | + if (ret) { |
---|
| 1150 | + printk("Request irq fail!.\n"); |
---|
| 1151 | + } |
---|
| 1152 | + |
---|
| 1153 | + |
---|
| 1154 | + spin_lock_init(&ts->irq_lock); |
---|
2780 | 1155 | |
---|
2781 | 1156 | #if GTP_CREATE_WR_NODE |
---|
2782 | | - init_wr_node(client); |
---|
| 1157 | + init_wr_node(client); |
---|
2783 | 1158 | #endif |
---|
2784 | 1159 | |
---|
2785 | 1160 | #if GTP_ESD_PROTECT |
---|
2786 | | - gtp_esd_switch(client, SWITCH_ON); |
---|
| 1161 | + INIT_DELAYED_WORK(>p_esd_check_work, gtp_esd_check_func); |
---|
| 1162 | + gtp_esd_check_workqueue = create_workqueue("gtp_esd_check"); |
---|
| 1163 | + queue_delayed_work(gtp_esd_check_workqueue, >p_esd_check_work, GTP_ESD_CHECK_CIRCLE); |
---|
2787 | 1164 | #endif |
---|
2788 | | - |
---|
2789 | | - pm_runtime_set_active(&client->dev); |
---|
2790 | | - pm_runtime_get(&client->dev); |
---|
2791 | | - pm_runtime_enable(&client->dev); |
---|
2792 | | - config_info.probed = 1; |
---|
2793 | | - |
---|
2794 | | - return 0; |
---|
2795 | | - |
---|
2796 | | -fail: |
---|
2797 | | - input_sensor_free(&(config_info.input_type)); |
---|
2798 | | - return -1; |
---|
| 1165 | + dprintk(DEBUG_INIT, "gt9xx probe success!\n"); |
---|
| 1166 | + return 0; |
---|
| 1167 | +exit_device_detect: |
---|
| 1168 | + i2c_set_clientdata(client, NULL); |
---|
| 1169 | + kfree(ts); |
---|
| 1170 | + return ret; |
---|
2799 | 1171 | } |
---|
2800 | 1172 | |
---|
2801 | 1173 | |
---|
2802 | 1174 | /******************************************************* |
---|
2803 | 1175 | Function: |
---|
2804 | | - Goodix touchscreen driver release function. |
---|
| 1176 | +Goodix touchscreen driver release function. |
---|
| 1177 | + |
---|
2805 | 1178 | Input: |
---|
2806 | | - client: i2c device struct. |
---|
| 1179 | +client: i2c device struct. |
---|
| 1180 | + |
---|
2807 | 1181 | Output: |
---|
2808 | | - Executive outcomes. 0---succeed. |
---|
2809 | | -*******************************************************/ |
---|
| 1182 | +Executive outcomes. 0---succeed. |
---|
| 1183 | + *******************************************************/ |
---|
2810 | 1184 | static int goodix_ts_remove(struct i2c_client *client) |
---|
2811 | 1185 | { |
---|
2812 | | - struct goodix_ts_data *ts = i2c_get_clientdata(client); |
---|
| 1186 | + struct goodix_ts_data *ts = i2c_get_clientdata(client); |
---|
2813 | 1187 | |
---|
2814 | | - GTP_DEBUG_FUNC(); |
---|
2815 | | - |
---|
| 1188 | + dprintk(DEBUG_INIT,"%s start!\n", __func__); |
---|
2816 | 1189 | #ifdef CONFIG_HAS_EARLYSUSPEND |
---|
2817 | | - unregister_early_suspend(&ts->early_suspend); |
---|
| 1190 | + unregister_early_suspend(&ts->early_suspend); |
---|
2818 | 1191 | #endif |
---|
2819 | 1192 | |
---|
2820 | 1193 | #if GTP_CREATE_WR_NODE |
---|
2821 | | - uninit_wr_node(); |
---|
| 1194 | + uninit_wr_node(); |
---|
2822 | 1195 | #endif |
---|
2823 | 1196 | |
---|
2824 | 1197 | #if GTP_ESD_PROTECT |
---|
2825 | | - destroy_workqueue(gtp_esd_check_workqueue); |
---|
| 1198 | + flush_workqueue(gtp_esd_check_workqueue); |
---|
| 1199 | + if(gtp_esd_check_workqueue) |
---|
| 1200 | + destroy_workqueue(gtp_esd_check_workqueue); |
---|
2826 | 1201 | #endif |
---|
2827 | | - pm_runtime_disable(&client->dev); |
---|
2828 | | - pm_runtime_set_suspended(&client->dev); |
---|
2829 | | - remove_proc_entry(GT91XX_CONFIG_PROC_FILE,NULL); |
---|
2830 | | - sysfs_remove_group(&ts->input_dev->dev.kobj, >p_attribute_group); |
---|
2831 | | - |
---|
2832 | | - if (ts) |
---|
2833 | | - { |
---|
2834 | | - if (ts->use_irq) |
---|
2835 | | - { |
---|
2836 | | - gtp_set_int_value(0); |
---|
2837 | | - input_free_int(&(config_info.input_type), ts); |
---|
2838 | | - } |
---|
2839 | | - else |
---|
2840 | | - { |
---|
2841 | | - hrtimer_cancel(&ts->timer); |
---|
2842 | | - } |
---|
2843 | | - } |
---|
2844 | | - else { |
---|
2845 | | - printk("error!!! ts is null!\n"); |
---|
2846 | | - return -1; |
---|
2847 | | - } |
---|
2848 | | - |
---|
2849 | | - |
---|
2850 | | - GTP_INFO("GTP driver removing..."); |
---|
2851 | | - i2c_set_clientdata(client, NULL); |
---|
2852 | | - input_unregister_device(ts->input_dev); |
---|
2853 | | - kfree(ts); |
---|
2854 | | - |
---|
2855 | | - return 0; |
---|
2856 | | -} |
---|
2857 | | - |
---|
2858 | | -#ifdef CONFIG_PM |
---|
2859 | | -/******************************************************* |
---|
2860 | | -Function: |
---|
2861 | | - Early suspend function. |
---|
2862 | | -Input: |
---|
2863 | | - h: early_suspend struct. |
---|
2864 | | -Output: |
---|
2865 | | - None. |
---|
2866 | | -*******************************************************/ |
---|
2867 | | -static void goodix_ts_suspend(struct goodix_ts_data *ts) |
---|
2868 | | -{ |
---|
2869 | | - s8 ret = -1; |
---|
2870 | | - |
---|
2871 | | - GTP_DEBUG_FUNC(); |
---|
2872 | | - GTP_INFO("System suspend."); |
---|
2873 | | - |
---|
2874 | | - ts->gtp_is_suspend = 1; |
---|
2875 | | - g_suspend_flag = 1; |
---|
2876 | | - dprintk(DEBUG_INIT, "%s g_suspend_flag=%d\n", __func__, g_suspend_flag); |
---|
2877 | | - |
---|
2878 | | -#if GTP_ESD_PROTECT |
---|
2879 | | - gtp_esd_switch(ts->client, SWITCH_OFF); |
---|
2880 | | -#endif |
---|
2881 | | - |
---|
2882 | | - if (gtp_gesture_wakeup) |
---|
2883 | | - ret = gtp_enter_doze(ts); |
---|
2884 | | - else { |
---|
2885 | | - if (ts->use_irq) { |
---|
2886 | | - gtp_irq_disable(ts); |
---|
2887 | | - } |
---|
2888 | | - else { |
---|
2889 | | - hrtimer_cancel(&ts->timer); |
---|
2890 | | - } |
---|
2891 | | - ret = gtp_enter_sleep(ts); |
---|
2892 | | - } |
---|
2893 | | - if (ret < 0) { |
---|
2894 | | - GTP_ERROR("GTP suspend failed."); |
---|
2895 | | - } |
---|
2896 | | - /* to avoid waking up while not sleeping |
---|
2897 | | - delay 48 + 10ms to ensure reliability */ |
---|
2898 | | - msleep(58); |
---|
2899 | | - |
---|
2900 | | - if (!gtp_gesture_wakeup) { |
---|
2901 | | - printk("ctp power off suspend!!!\n"); |
---|
2902 | | - input_set_power_enable(&(config_info.input_type), 0); |
---|
2903 | | - __gpio_set_value(config_info.wakeup_gpio.gpio, 0); |
---|
2904 | | - } |
---|
2905 | | -} |
---|
2906 | | - |
---|
2907 | | -/******************************************************* |
---|
2908 | | -Function: |
---|
2909 | | - Late resume function. |
---|
2910 | | -Input: |
---|
2911 | | - h: early_suspend struct. |
---|
2912 | | -Output: |
---|
2913 | | - None. |
---|
2914 | | -*******************************************************/ |
---|
2915 | | -static void goodix_ts_resume(struct goodix_ts_data *ts) |
---|
2916 | | -{ |
---|
2917 | | - s8 ret = -1; |
---|
2918 | | - GTP_DEBUG_FUNC(); |
---|
2919 | | - |
---|
2920 | | - dprintk(DEBUG_SUSPEND, "System resume\n"); |
---|
2921 | | - if (!gtp_gesture_wakeup) { |
---|
2922 | | - __gpio_set_value(config_info.wakeup_gpio.gpio, 1); |
---|
2923 | | - dprintk(DEBUG_INIT, "ctp power on in goodix_ts_resume!!!\n"); |
---|
2924 | | - input_set_power_enable(&(config_info.input_type), 1); |
---|
2925 | | - msleep(10); |
---|
2926 | | - } |
---|
2927 | | - |
---|
2928 | | - ret = gtp_wakeup_sleep(ts); |
---|
2929 | | - if (gtp_gesture_wakeup) |
---|
2930 | | - doze_status = DOZE_DISABLED; |
---|
2931 | | - |
---|
2932 | | - if (ret < 0) { |
---|
2933 | | - dprintk(DEBUG_INIT, "GTP later resume failed."); |
---|
2934 | | - } |
---|
2935 | | -#if (GTP_COMPATIBLE_MODE) |
---|
2936 | | - if (CHIP_TYPE_GT9F == ts->chip_type) { |
---|
2937 | | - /* do nothing */ |
---|
2938 | | - } |
---|
2939 | | - else |
---|
2940 | | -#endif |
---|
2941 | | - { |
---|
2942 | | - gtp_send_cfg(ts->client); |
---|
2943 | | - } |
---|
2944 | | - printk("ts->use_irq=%d", ts->use_irq); |
---|
2945 | | - if (ts->use_irq) { |
---|
2946 | | - gtp_irq_enable(ts); |
---|
2947 | | - } |
---|
2948 | | - else { |
---|
2949 | | - hrtimer_start(&ts->timer, ktime_set(1, 0), HRTIMER_MODE_REL); |
---|
2950 | | - } |
---|
2951 | | - |
---|
2952 | | - ts->gtp_is_suspend = 0; |
---|
2953 | | - g_suspend_flag = 0; |
---|
2954 | | - dprintk(DEBUG_INIT, "%s g_suspend_flag=%d\n", __func__, g_suspend_flag); |
---|
2955 | | -#if GTP_ESD_PROTECT |
---|
2956 | | - gtp_esd_switch(ts->client, SWITCH_ON); |
---|
2957 | | -#endif |
---|
2958 | | -} |
---|
2959 | | - |
---|
2960 | | -static int gtp_pm_suspend(struct device *dev) |
---|
2961 | | -{ |
---|
2962 | | - struct goodix_ts_data *ts = dev_get_drvdata(dev); |
---|
2963 | | - dprintk(DEBUG_SUSPEND, "CONFIG_PM:enter gtp_pm_suspend. \n"); |
---|
2964 | | - if (pm_runtime_suspended(dev)) |
---|
2965 | | - return 0; |
---|
2966 | | - |
---|
2967 | | - if (ts) { |
---|
2968 | | - goodix_ts_suspend(ts); |
---|
2969 | | - } |
---|
2970 | | - |
---|
2971 | | - return 0; |
---|
2972 | | -} |
---|
2973 | | -static int gtp_pm_resume(struct device *dev) |
---|
2974 | | -{ |
---|
2975 | | - struct goodix_ts_data *ts = dev_get_drvdata(dev); |
---|
2976 | | - dprintk(DEBUG_SUSPEND, "CONFIG_PM:enter laterresume: goodix_ts_resume. \n"); |
---|
2977 | | - if (pm_runtime_suspended(dev)) |
---|
2978 | | - return 0; |
---|
2979 | | - |
---|
2980 | | - if (ts) { |
---|
2981 | | - goodix_ts_resume(ts); |
---|
2982 | | - } |
---|
| 1202 | + input_free_int(&(config_info.input_type), ts); |
---|
| 1203 | + flush_workqueue(goodix_wq); |
---|
| 1204 | + //cancel_work_sync(&goodix_init_work); |
---|
| 1205 | + cancel_work_sync(&goodix_resume_work); |
---|
| 1206 | + if(goodix_wq) |
---|
| 1207 | + destroy_workqueue(goodix_wq); |
---|
| 1208 | + //destroy_workqueue(goodix_init_wq); |
---|
| 1209 | + if(goodix_resume_wq) |
---|
| 1210 | + destroy_workqueue(goodix_resume_wq); |
---|
| 1211 | + i2c_set_clientdata(ts->client, NULL); |
---|
| 1212 | + input_unregister_device(ts->input_dev); |
---|
| 1213 | + kfree(ts); |
---|
2983 | 1214 | |
---|
2984 | 1215 | return 0; |
---|
2985 | 1216 | } |
---|
2986 | 1217 | |
---|
2987 | | -static struct dev_pm_ops gtp_pm_ops = { |
---|
2988 | | - .suspend = gtp_pm_suspend, |
---|
2989 | | - .resume = gtp_pm_resume, |
---|
2990 | | -}; |
---|
2991 | | -#endif |
---|
| 1218 | +static void goodix_resume_events (struct work_struct *work) |
---|
| 1219 | +{ |
---|
| 1220 | + int ret; |
---|
| 1221 | + struct goodix_ts_data *ts = i2c_get_clientdata(i2c_connect_client); |
---|
| 1222 | + |
---|
| 1223 | + ret = gtp_wakeup_sleep(ts); |
---|
| 1224 | + if (ret < 0) |
---|
| 1225 | + printk("resume power on failed\n"); |
---|
| 1226 | + gtp_irq_enable(ts); |
---|
| 1227 | +} |
---|
| 1228 | + |
---|
| 1229 | +/******************************************************* |
---|
| 1230 | +Function: |
---|
| 1231 | +Early suspend function. |
---|
| 1232 | + |
---|
| 1233 | +Input: |
---|
| 1234 | +h:early_suspend struct. |
---|
| 1235 | + |
---|
| 1236 | +Output: |
---|
| 1237 | +None. |
---|
| 1238 | + *******************************************************/ |
---|
2992 | 1239 | #ifdef CONFIG_HAS_EARLYSUSPEND |
---|
2993 | | -/******************************************************* |
---|
2994 | | -Function: |
---|
2995 | | - Early suspend function. |
---|
2996 | | -Input: |
---|
2997 | | - h: early_suspend struct. |
---|
2998 | | -Output: |
---|
2999 | | - None. |
---|
3000 | | -*******************************************************/ |
---|
3001 | 1240 | static void goodix_ts_early_suspend(struct early_suspend *h) |
---|
3002 | 1241 | { |
---|
3003 | | - struct goodix_ts_data *ts; |
---|
3004 | | - s8 ret = -1; |
---|
3005 | | - ts = container_of(h, struct goodix_ts_data, early_suspend); |
---|
| 1242 | + struct goodix_ts_data *ts; |
---|
| 1243 | + s8 ret = -1; |
---|
| 1244 | + ts = container_of(h, struct goodix_ts_data, early_suspend); |
---|
3006 | 1245 | |
---|
3007 | | - GTP_DEBUG_FUNC(); |
---|
3008 | | - |
---|
3009 | | - GTP_INFO("System suspend."); |
---|
3010 | | - |
---|
3011 | | - ts->gtp_is_suspend = 1; |
---|
3012 | | - g_suspend_flag = 1; |
---|
3013 | | - dprintk(DEBUG_INIT,"%s g_suspend_flag=%d\n",__func__,g_suspend_flag); |
---|
3014 | 1246 | #if GTP_ESD_PROTECT |
---|
3015 | | - gtp_esd_switch(ts->client, SWITCH_OFF); |
---|
| 1247 | + ts->gtp_is_suspend = 1; |
---|
| 1248 | + cancel_delayed_work_sync(>p_esd_check_work); |
---|
3016 | 1249 | #endif |
---|
3017 | 1250 | |
---|
3018 | | -//#if GTP_GESTURE_WAKEUP |
---|
3019 | | -if(gtp_gesture_wakeup) |
---|
3020 | | - ret = gtp_enter_doze(ts); |
---|
3021 | | -else { |
---|
3022 | | -//#else |
---|
3023 | | - if (ts->use_irq) |
---|
3024 | | - { |
---|
3025 | | - gtp_irq_disable(ts); |
---|
3026 | | - } |
---|
3027 | | - else |
---|
3028 | | - { |
---|
3029 | | - hrtimer_cancel(&ts->timer); |
---|
3030 | | - } |
---|
3031 | | - ret = gtp_enter_sleep(ts); |
---|
3032 | | -} |
---|
3033 | | -//#endif |
---|
3034 | | - if (ret < 0) |
---|
3035 | | - { |
---|
3036 | | - GTP_ERROR("GTP early suspend failed."); |
---|
3037 | | - } |
---|
3038 | | - // to avoid waking up while not sleeping |
---|
3039 | | - // delay 48 + 10ms to ensure reliability |
---|
3040 | | - msleep(58); |
---|
3041 | | -//#if (!GTP_GESTURE_WAKEUP) |
---|
3042 | | -if(!gtp_gesture_wakeup){ |
---|
3043 | | - printk("ctp power off in early suspend!!!\n"); |
---|
3044 | | - input_set_power_enable(&(config_info.input_type), 0); |
---|
3045 | | - __gpio_set_value(config_info.wakeup_gpio.gpio, 0); |
---|
3046 | | -//#endif |
---|
3047 | | -} |
---|
| 1251 | + gtp_irq_disable(ts); |
---|
| 1252 | + |
---|
| 1253 | + |
---|
| 1254 | + cancel_work_sync(&goodix_resume_work); |
---|
| 1255 | + flush_workqueue(goodix_resume_wq); |
---|
| 1256 | + ret = cancel_work_sync(&ts->work); |
---|
| 1257 | + flush_workqueue(goodix_wq); |
---|
| 1258 | + |
---|
| 1259 | + ret = gtp_enter_sleep(ts); |
---|
| 1260 | + if (ret < 0) { |
---|
| 1261 | + printk("GTP early suspend failed."); |
---|
| 1262 | + } |
---|
3048 | 1263 | } |
---|
3049 | 1264 | |
---|
3050 | 1265 | /******************************************************* |
---|
3051 | 1266 | Function: |
---|
3052 | | - Late resume function. |
---|
| 1267 | +Late resume function. |
---|
| 1268 | + |
---|
3053 | 1269 | Input: |
---|
3054 | | - h: early_suspend struct. |
---|
| 1270 | +h:early_suspend struct. |
---|
| 1271 | + |
---|
3055 | 1272 | Output: |
---|
3056 | | - None. |
---|
3057 | | -*******************************************************/ |
---|
| 1273 | +None. |
---|
| 1274 | + *******************************************************/ |
---|
3058 | 1275 | static void goodix_ts_late_resume(struct early_suspend *h) |
---|
3059 | 1276 | { |
---|
3060 | | - struct goodix_ts_data *ts; |
---|
3061 | | - s8 ret = -1; |
---|
3062 | | - ts = container_of(h, struct goodix_ts_data, early_suspend); |
---|
| 1277 | + struct goodix_ts_data *ts; |
---|
| 1278 | + ts = container_of(h, struct goodix_ts_data, early_suspend); |
---|
3063 | 1279 | |
---|
3064 | | - GTP_DEBUG_FUNC(); |
---|
3065 | | - |
---|
3066 | | - GTP_INFO("System resume."); |
---|
3067 | | -//#if (!GTP_GESTURE_WAKEUP) |
---|
3068 | | -if(!gtp_gesture_wakeup){ |
---|
3069 | | - __gpio_set_value(config_info.wakeup_gpio.gpio, 1); |
---|
3070 | | - printk("ctp power on in late resume!!!\n"); |
---|
3071 | | - input_set_power_enable(&(config_info.input_type), 1); |
---|
3072 | | - msleep(10); |
---|
3073 | | -} |
---|
3074 | | -//#endif |
---|
3075 | | - |
---|
3076 | | - ret = gtp_wakeup_sleep(ts); |
---|
3077 | | - |
---|
3078 | | -//#if GTP_GESTURE_WAKEUP |
---|
3079 | | -if(gtp_gesture_wakeup) |
---|
3080 | | - doze_status = DOZE_DISABLED; |
---|
3081 | | -//#endif |
---|
3082 | | - |
---|
3083 | | - if (ret < 0) |
---|
3084 | | - { |
---|
3085 | | - GTP_ERROR("GTP later resume failed."); |
---|
3086 | | - } |
---|
3087 | | -#if (GTP_COMPATIBLE_MODE) |
---|
3088 | | - if (CHIP_TYPE_GT9F == ts->chip_type) |
---|
3089 | | - { |
---|
3090 | | - // do nothing |
---|
3091 | | - } |
---|
3092 | | - else |
---|
3093 | | -#endif |
---|
3094 | | - { |
---|
3095 | | - gtp_send_cfg(ts->client); |
---|
3096 | | - } |
---|
3097 | | - |
---|
3098 | | - if (ts->use_irq) |
---|
3099 | | - { |
---|
3100 | | - gtp_irq_enable(ts); |
---|
3101 | | - } |
---|
3102 | | - else |
---|
3103 | | - { |
---|
3104 | | - hrtimer_start(&ts->timer, ktime_set(1, 0), HRTIMER_MODE_REL); |
---|
3105 | | - } |
---|
3106 | | - |
---|
3107 | | - ts->gtp_is_suspend = 0; |
---|
3108 | | - g_suspend_flag = 0; |
---|
3109 | | - dprintk(DEBUG_INIT,"%s g_suspend_flag=%d\n",__func__,g_suspend_flag); |
---|
3110 | | -#if GTP_ESD_PROTECT |
---|
3111 | | - gtp_esd_switch(ts->client, SWITCH_ON); |
---|
3112 | | -#endif |
---|
3113 | | -} |
---|
3114 | | -#endif |
---|
3115 | | - |
---|
| 1280 | + queue_work(goodix_resume_wq, &goodix_resume_work);//gandy |
---|
3116 | 1281 | |
---|
3117 | 1282 | #if GTP_ESD_PROTECT |
---|
3118 | | -s32 gtp_i2c_read_no_rst(struct i2c_client *client, u8 *buf, s32 len) |
---|
| 1283 | + ts->gtp_is_suspend = 0; |
---|
| 1284 | + queue_delayed_work(gtp_esd_check_workqueue, >p_esd_check_work, GTP_ESD_CHECK_CIRCLE); |
---|
| 1285 | +#endif |
---|
| 1286 | +} |
---|
| 1287 | +#else |
---|
| 1288 | +#ifdef CONFIG_PM |
---|
| 1289 | +static int goodix_ts_suspend(struct device *dev) |
---|
3119 | 1290 | { |
---|
3120 | | - struct i2c_msg msgs[2]; |
---|
3121 | | - s32 ret=-1; |
---|
3122 | | - s32 retries = 0; |
---|
| 1291 | + struct goodix_ts_data *ts = dev_get_drvdata(dev); |
---|
| 1292 | + s8 ret = -1; |
---|
3123 | 1293 | |
---|
3124 | | - GTP_DEBUG_FUNC(); |
---|
| 1294 | + printk("%s goodix_ts_suspend\n", goodix_ts_name); |
---|
| 1295 | +#if GTP_ESD_PROTECT |
---|
| 1296 | + ts->gtp_is_suspend = 1; |
---|
| 1297 | + cancel_delayed_work_sync(>p_esd_check_work); |
---|
| 1298 | +#endif |
---|
3125 | 1299 | |
---|
3126 | | - msgs[0].flags = !I2C_M_RD; |
---|
3127 | | - msgs[0].addr = client->addr; |
---|
3128 | | - msgs[0].len = GTP_ADDR_LENGTH; |
---|
3129 | | - msgs[0].buf = &buf[0]; |
---|
3130 | | - //msgs[0].scl_rate = 300 * 1000; // for Rockchip, etc. |
---|
| 1300 | + /* |
---|
| 1301 | + ret = input_set_int_enable(&(config_info.input_type), 0); |
---|
| 1302 | + if (ret < 0) |
---|
| 1303 | + dprintk(DEBUG_SUSPEND,"%s irq disable failed\n", goodix_ts_name); |
---|
| 1304 | + */ |
---|
| 1305 | + gtp_irq_disable(ts); |
---|
| 1306 | + cancel_work_sync(&goodix_resume_work); |
---|
| 1307 | + flush_workqueue(goodix_resume_wq); |
---|
| 1308 | + ret = cancel_work_sync(&ts->work); |
---|
| 1309 | + flush_workqueue(goodix_wq); |
---|
3131 | 1310 | |
---|
3132 | | - msgs[1].flags = I2C_M_RD; |
---|
3133 | | - msgs[1].addr = client->addr; |
---|
3134 | | - msgs[1].len = len - GTP_ADDR_LENGTH; |
---|
3135 | | - msgs[1].buf = &buf[GTP_ADDR_LENGTH]; |
---|
3136 | | - //msgs[1].scl_rate = 300 * 1000; |
---|
| 1311 | + ret = gtp_enter_sleep(ts); |
---|
| 1312 | + if (ret < 0) { |
---|
| 1313 | + printk("GTP suspend failed."); |
---|
| 1314 | + } |
---|
3137 | 1315 | |
---|
3138 | | - while(retries < 5) |
---|
3139 | | - { |
---|
3140 | | - ret = i2c_transfer(client->adapter, msgs, 2); |
---|
3141 | | - if(ret == 2)break; |
---|
3142 | | - retries++; |
---|
3143 | | - } |
---|
3144 | | - if ((retries >= 5)) |
---|
3145 | | - { |
---|
3146 | | - GTP_ERROR("I2C Read: 0x%04X, %d bytes failed, errcode: %d!", (((u16)(buf[0] << 8)) | buf[1]), len-2, ret); |
---|
3147 | | - } |
---|
3148 | | - return ret; |
---|
| 1316 | + msleep(58); |
---|
| 1317 | + |
---|
| 1318 | + input_set_power_enable(&(config_info.input_type), 0); |
---|
| 1319 | + __gpio_set_value(config_info.wakeup_gpio.gpio, 0); |
---|
| 1320 | + return 0; |
---|
3149 | 1321 | } |
---|
3150 | 1322 | |
---|
3151 | | -s32 gtp_i2c_write_no_rst(struct i2c_client *client,u8 *buf,s32 len) |
---|
| 1323 | +static int goodix_ts_resume(struct device *dev) |
---|
3152 | 1324 | { |
---|
3153 | | - struct i2c_msg msg; |
---|
3154 | | - s32 ret = -1; |
---|
3155 | | - s32 retries = 0; |
---|
| 1325 | + printk("%s goodix_ts_resume\n", goodix_ts_name); |
---|
| 1326 | + __gpio_set_value(config_info.wakeup_gpio.gpio, 1); |
---|
| 1327 | + input_set_power_enable(&(config_info.input_type), 1); |
---|
| 1328 | + msleep(10); |
---|
| 1329 | + queue_work(goodix_resume_wq, &goodix_resume_work);//gandy |
---|
3156 | 1330 | |
---|
3157 | | - GTP_DEBUG_FUNC(); |
---|
| 1331 | +#if GTP_ESD_PROTECT |
---|
| 1332 | + struct goodix_ts_data *ts = dev_get_drvdata(dev); |
---|
| 1333 | + ts->gtp_is_suspend = 0; |
---|
| 1334 | + queue_delayed_work(gtp_esd_check_workqueue, >p_esd_check_work, GTP_ESD_CHECK_CIRCLE); |
---|
| 1335 | +#endif |
---|
| 1336 | + return 0; |
---|
| 1337 | +} |
---|
| 1338 | +#endif |
---|
| 1339 | +#endif |
---|
3158 | 1340 | |
---|
3159 | | - msg.flags = !I2C_M_RD; |
---|
3160 | | - msg.addr = client->addr; |
---|
3161 | | - msg.len = len; |
---|
3162 | | - msg.buf = buf; |
---|
3163 | | - //msg.scl_rate = 300 * 1000; // for Rockchip, etc |
---|
3164 | | - |
---|
3165 | | - while(retries < 5) |
---|
3166 | | - { |
---|
3167 | | - ret = i2c_transfer(client->adapter, &msg, 1); |
---|
3168 | | - if (ret == 1)break; |
---|
3169 | | - retries++; |
---|
3170 | | - } |
---|
3171 | | - if((retries >= 5)) |
---|
3172 | | - { |
---|
3173 | | - GTP_ERROR("I2C Write: 0x%04X, %d bytes failed, errcode: %d!", (((u16)(buf[0] << 8)) | buf[1]), len-2, ret); |
---|
3174 | | - } |
---|
3175 | | - return ret; |
---|
| 1341 | +#if GTP_ESD_PROTECT |
---|
| 1342 | +/******************************************************* |
---|
| 1343 | +Function: |
---|
| 1344 | +Initialize external watchdog for esd protect |
---|
| 1345 | +Input: |
---|
| 1346 | +client: i2c device. |
---|
| 1347 | +Output: |
---|
| 1348 | +result of i2c write operation. |
---|
| 1349 | +1: succeed, otherwise: failed |
---|
| 1350 | + *********************************************************/ |
---|
| 1351 | +s32 gtp_init_ext_watchdog(struct i2c_client *client) |
---|
| 1352 | +{ |
---|
| 1353 | + u8 opr_buffer[4] = {0x80, 0x40, 0xAA, 0xAA}; |
---|
| 1354 | + dprintk(DEBUG_INIT, "Init external watchdog..."); |
---|
| 1355 | + return gtp_i2c_write(client, opr_buffer, 4); |
---|
3176 | 1356 | } |
---|
3177 | 1357 | /******************************************************* |
---|
3178 | 1358 | Function: |
---|
3179 | | - switch on & off esd delayed work |
---|
| 1359 | +Esd protect function. |
---|
| 1360 | +Added external watchdog by meta, 2013/03/07 |
---|
3180 | 1361 | Input: |
---|
3181 | | - client: i2c device |
---|
3182 | | - on: SWITCH_ON / SWITCH_OFF |
---|
| 1362 | +work: delayed work |
---|
3183 | 1363 | Output: |
---|
3184 | | - void |
---|
3185 | | -*********************************************************/ |
---|
3186 | | -void gtp_esd_switch(struct i2c_client *client, s32 on) |
---|
3187 | | -{ |
---|
3188 | | - struct goodix_ts_data *ts; |
---|
3189 | | - |
---|
3190 | | - ts = i2c_get_clientdata(client); |
---|
3191 | | - spin_lock(&ts->esd_lock); |
---|
3192 | | - |
---|
3193 | | - if (SWITCH_ON == on) // switch on esd |
---|
3194 | | - { |
---|
3195 | | - if (!ts->esd_running) |
---|
3196 | | - { |
---|
3197 | | - ts->esd_running = 1; |
---|
3198 | | - spin_unlock(&ts->esd_lock); |
---|
3199 | | - GTP_INFO("Esd started"); |
---|
3200 | | - queue_delayed_work(gtp_esd_check_workqueue, >p_esd_check_work, ts->clk_tick_cnt); |
---|
3201 | | - } |
---|
3202 | | - else |
---|
3203 | | - { |
---|
3204 | | - spin_unlock(&ts->esd_lock); |
---|
3205 | | - } |
---|
3206 | | - } |
---|
3207 | | - else // switch off esd |
---|
3208 | | - { |
---|
3209 | | - if (ts->esd_running) |
---|
3210 | | - { |
---|
3211 | | - ts->esd_running = 0; |
---|
3212 | | - spin_unlock(&ts->esd_lock); |
---|
3213 | | - GTP_INFO("Esd cancelled"); |
---|
3214 | | - cancel_delayed_work_sync(>p_esd_check_work); |
---|
3215 | | - } |
---|
3216 | | - else |
---|
3217 | | - { |
---|
3218 | | - spin_unlock(&ts->esd_lock); |
---|
3219 | | - } |
---|
3220 | | - } |
---|
3221 | | -} |
---|
3222 | | - |
---|
3223 | | -/******************************************************* |
---|
3224 | | -Function: |
---|
3225 | | - Initialize external watchdog for esd protect |
---|
3226 | | -Input: |
---|
3227 | | - client: i2c device. |
---|
3228 | | -Output: |
---|
3229 | | - result of i2c write operation. |
---|
3230 | | - 1: succeed, otherwise: failed |
---|
3231 | | -*********************************************************/ |
---|
3232 | | -static s32 gtp_init_ext_watchdog(struct i2c_client *client) |
---|
3233 | | -{ |
---|
3234 | | - u8 opr_buffer[3] = {0x80, 0x41, 0xAA}; |
---|
3235 | | - GTP_DEBUG("[Esd]Init external watchdog"); |
---|
3236 | | - return gtp_i2c_write_no_rst(client, opr_buffer, 3); |
---|
3237 | | -} |
---|
3238 | | - |
---|
3239 | | -/******************************************************* |
---|
3240 | | -Function: |
---|
3241 | | - Esd protect function. |
---|
3242 | | - External watchdog added by meta, 2013/03/07 |
---|
3243 | | -Input: |
---|
3244 | | - work: delayed work |
---|
3245 | | -Output: |
---|
3246 | | - None. |
---|
3247 | | -*******************************************************/ |
---|
| 1364 | +None. |
---|
| 1365 | + *******************************************************/ |
---|
3248 | 1366 | static void gtp_esd_check_func(struct work_struct *work) |
---|
3249 | 1367 | { |
---|
3250 | | - s32 i; |
---|
3251 | | - s32 ret = -1; |
---|
3252 | | - struct goodix_ts_data *ts = NULL; |
---|
3253 | | - u8 esd_buf[5] = {0x80, 0x40}; |
---|
| 1368 | + s32 i; |
---|
| 1369 | + s32 ret = -1; |
---|
| 1370 | + struct goodix_ts_data *ts = NULL; |
---|
| 1371 | + u8 test[4] = {0x80, 0x40}; |
---|
3254 | 1372 | |
---|
3255 | | - GTP_DEBUG_FUNC(); |
---|
| 1373 | + dprintk(DEBUG_INIT, "enter %s work!\n", __func__); |
---|
3256 | 1374 | |
---|
3257 | | - ts = i2c_get_clientdata(i2c_connect_client); |
---|
| 1375 | + ts = i2c_get_clientdata(i2c_connect_client); |
---|
3258 | 1376 | |
---|
3259 | | - if (ts->gtp_is_suspend) |
---|
3260 | | - { |
---|
3261 | | - GTP_INFO("Esd suspended!"); |
---|
3262 | | - return; |
---|
3263 | | - } |
---|
| 1377 | + if (ts->gtp_is_suspend || ts->enter_update) { |
---|
| 1378 | + return; |
---|
| 1379 | + } |
---|
3264 | 1380 | |
---|
3265 | | - for (i = 0; i < 3; i++) |
---|
3266 | | - { |
---|
3267 | | - ret = gtp_i2c_read_no_rst(ts->client, esd_buf, 4); |
---|
| 1381 | + for (i = 0; i < 3; i++) { |
---|
| 1382 | + ret = gtp_i2c_read(ts->client, test, 4); |
---|
3268 | 1383 | |
---|
3269 | | - GTP_DEBUG("[Esd]0x8040 = 0x%02X, 0x8041 = 0x%02X", esd_buf[2], esd_buf[3]); |
---|
3270 | | - if ((ret < 0)) |
---|
3271 | | - { |
---|
3272 | | - // IIC communication problem |
---|
3273 | | - continue; |
---|
3274 | | - } |
---|
3275 | | - else |
---|
3276 | | - { |
---|
3277 | | - if ((esd_buf[2] == 0xAA) || (esd_buf[3] != 0xAA)) |
---|
3278 | | - { |
---|
3279 | | - // IC works abnormally.. |
---|
3280 | | - u8 chk_buf[4] = {0x80, 0x40}; |
---|
| 1384 | + dprintk(DEBUG_INIT, "0x8040 = 0x%02X, 0x8041 = 0x%02X", test[2], test[3]); |
---|
| 1385 | + if ((ret < 0)) { |
---|
| 1386 | + // IC works abnormally.. |
---|
| 1387 | + continue; |
---|
| 1388 | + }else { |
---|
| 1389 | + if ((test[2] == 0xAA) || (test[3] != 0xAA)) { |
---|
| 1390 | + // IC works abnormally.. |
---|
| 1391 | + i = 3; |
---|
| 1392 | + break; |
---|
| 1393 | + }else { |
---|
| 1394 | + // IC works normally, Write 0x8040 0xAA |
---|
| 1395 | + test[2] = 0xAA; |
---|
| 1396 | + gtp_i2c_write(ts->client, test, 3); |
---|
| 1397 | + break; |
---|
| 1398 | + } |
---|
| 1399 | + } |
---|
| 1400 | + } |
---|
3281 | 1401 | |
---|
3282 | | - gtp_i2c_read_no_rst(ts->client, chk_buf, 4); |
---|
| 1402 | + if (i >= 3) { |
---|
| 1403 | + GTP_DEBUG("IC Working ABNORMALLY, Resetting Guitar..."); |
---|
| 1404 | + // gtp_reset_guitar(ts->client, 50); |
---|
| 1405 | + } |
---|
3283 | 1406 | |
---|
3284 | | - GTP_DEBUG("[Check]0x8040 = 0x%02X, 0x8041 = 0x%02X", chk_buf[2], chk_buf[3]); |
---|
| 1407 | + if(!ts->gtp_is_suspend) { |
---|
| 1408 | + queue_delayed_work(gtp_esd_check_workqueue, >p_esd_check_work, GTP_ESD_CHECK_CIRCLE); |
---|
| 1409 | + } |
---|
3285 | 1410 | |
---|
3286 | | - if ((chk_buf[2] == 0xAA) || (chk_buf[3] != 0xAA)) |
---|
3287 | | - { |
---|
3288 | | - i = 3; |
---|
3289 | | - break; |
---|
3290 | | - } |
---|
3291 | | - else |
---|
3292 | | - { |
---|
3293 | | - continue; |
---|
3294 | | - } |
---|
3295 | | - } |
---|
3296 | | - else |
---|
3297 | | - { |
---|
3298 | | - // IC works normally, Write 0x8040 0xAA, feed the dog |
---|
3299 | | - esd_buf[2] = 0xAA; |
---|
3300 | | - gtp_i2c_write_no_rst(ts->client, esd_buf, 3); |
---|
3301 | | - break; |
---|
3302 | | - } |
---|
3303 | | - } |
---|
3304 | | - } |
---|
3305 | | - if (i >= 3) |
---|
3306 | | - { |
---|
3307 | | - #if GTP_COMPATIBLE_MODE |
---|
3308 | | - if (CHIP_TYPE_GT9F == ts->chip_type) |
---|
3309 | | - { |
---|
3310 | | - if (ts->rqst_processing) |
---|
3311 | | - { |
---|
3312 | | - GTP_INFO("Request processing, no esd recovery"); |
---|
3313 | | - } |
---|
3314 | | - else |
---|
3315 | | - { |
---|
3316 | | - GTP_ERROR("IC working abnormally! Process esd recovery."); |
---|
3317 | | - esd_buf[0] = 0x42; |
---|
3318 | | - esd_buf[1] = 0x26; |
---|
3319 | | - esd_buf[2] = 0x01; |
---|
3320 | | - esd_buf[3] = 0x01; |
---|
3321 | | - esd_buf[4] = 0x01; |
---|
3322 | | - gtp_i2c_write_no_rst(ts->client, esd_buf, 5); |
---|
3323 | | - msleep(50); |
---|
3324 | | - gtp_esd_recovery(ts->client); |
---|
3325 | | - } |
---|
3326 | | - } |
---|
3327 | | - else |
---|
3328 | | - #endif |
---|
3329 | | - { |
---|
3330 | | - GTP_ERROR("IC working abnormally! Process reset guitar."); |
---|
3331 | | - esd_buf[0] = 0x42; |
---|
3332 | | - esd_buf[1] = 0x26; |
---|
3333 | | - esd_buf[2] = 0x01; |
---|
3334 | | - esd_buf[3] = 0x01; |
---|
3335 | | - esd_buf[4] = 0x01; |
---|
3336 | | - gtp_i2c_write_no_rst(ts->client, esd_buf, 5); |
---|
3337 | | - msleep(50); |
---|
3338 | | - gtp_reset_guitar(ts->client, 50); |
---|
3339 | | - msleep(50); |
---|
3340 | | - gtp_send_cfg(ts->client); |
---|
3341 | | - } |
---|
3342 | | - } |
---|
3343 | | - |
---|
3344 | | - if(!ts->gtp_is_suspend) |
---|
3345 | | - { |
---|
3346 | | - queue_delayed_work(gtp_esd_check_workqueue, >p_esd_check_work, ts->clk_tick_cnt); |
---|
3347 | | - } |
---|
3348 | | - else |
---|
3349 | | - { |
---|
3350 | | - GTP_INFO("Esd suspended!"); |
---|
3351 | | - } |
---|
3352 | | - return; |
---|
| 1411 | + return; |
---|
3353 | 1412 | } |
---|
3354 | 1413 | #endif |
---|
3355 | 1414 | |
---|
3356 | 1415 | static const struct i2c_device_id goodix_ts_id[] = { |
---|
3357 | | - { CTP_NAME, 0 }, |
---|
3358 | | - { } |
---|
| 1416 | + { CTP_NAME, 0 }, |
---|
| 1417 | + { } |
---|
3359 | 1418 | }; |
---|
3360 | 1419 | |
---|
3361 | | -#if !USE_DETECT |
---|
3362 | | -static const struct of_device_id goodix_of_match[] = { |
---|
3363 | | - {.compatible = "allwinner,goodix"}, |
---|
3364 | | - {}, |
---|
| 1420 | +#ifndef CONFIG_HAS_EARLYSUSPEND |
---|
| 1421 | +#ifdef CONFIG_PM |
---|
| 1422 | +static const struct dev_pm_ops gt9xx_pm_ops = { |
---|
| 1423 | + .suspend = goodix_ts_suspend, |
---|
| 1424 | + .resume = goodix_ts_resume, |
---|
3365 | 1425 | }; |
---|
| 1426 | + |
---|
| 1427 | +#define GT9XX_PM_OPS (>9xx_pm_ops) |
---|
| 1428 | +#endif |
---|
3366 | 1429 | #endif |
---|
3367 | 1430 | |
---|
3368 | 1431 | static struct i2c_driver goodix_ts_driver = { |
---|
3369 | | - .class = I2C_CLASS_HWMON, |
---|
3370 | | - .probe = goodix_ts_probe, |
---|
3371 | | - .remove = goodix_ts_remove, |
---|
3372 | | - .id_table = goodix_ts_id, |
---|
| 1432 | + .class = I2C_CLASS_HWMON, |
---|
| 1433 | + .probe = goodix_ts_probe, |
---|
| 1434 | + .remove = goodix_ts_remove, |
---|
| 1435 | + .id_table = goodix_ts_id, |
---|
3373 | 1436 | .driver = { |
---|
3374 | | -#if !USE_DETECT |
---|
3375 | | - .of_match_table = goodix_of_match, |
---|
3376 | | -#endif |
---|
3377 | 1437 | .name = CTP_NAME, |
---|
3378 | | - .owner = THIS_MODULE, |
---|
| 1438 | + .owner = THIS_MODULE, |
---|
3379 | 1439 | #ifndef CONFIG_HAS_EARLYSUSPEND |
---|
3380 | | -#if defined(CONFIG_PM) |
---|
3381 | | - .pm = >p_pm_ops, |
---|
| 1440 | +#ifdef CONFIG_PM |
---|
| 1441 | + .pm = GT9XX_PM_OPS, |
---|
3382 | 1442 | #endif |
---|
3383 | 1443 | #endif |
---|
3384 | 1444 | }, |
---|
3385 | 1445 | .address_list = normal_i2c, |
---|
3386 | | -#if USE_DETECT |
---|
3387 | | - .detect = ctp_detect, |
---|
3388 | | -#endif |
---|
3389 | 1446 | }; |
---|
3390 | 1447 | |
---|
3391 | 1448 | static int ctp_get_system_config(void) |
---|
3392 | | -{ |
---|
3393 | | - ctp_print_info(config_info,DEBUG_INIT); |
---|
3394 | | - twi_id = config_info.twi_id; |
---|
3395 | | - screen_max_x = config_info.screen_max_x; |
---|
3396 | | - screen_max_y = config_info.screen_max_y; |
---|
3397 | | - revert_x_flag = config_info.revert_x_flag; |
---|
3398 | | - revert_y_flag = config_info.revert_y_flag; |
---|
3399 | | - exchange_x_y_flag = config_info.exchange_x_y_flag; |
---|
3400 | | - if((screen_max_x == 0) || (screen_max_y == 0)){ |
---|
3401 | | - printk("%s:read config error!\n",__func__); |
---|
3402 | | - return 0; |
---|
3403 | | - } |
---|
3404 | | - return 1; |
---|
| 1449 | +{ |
---|
| 1450 | + ctp_print_info(config_info,DEBUG_INIT); |
---|
| 1451 | + twi_id = config_info.twi_id; |
---|
| 1452 | +#if LVDS_1024x600 |
---|
| 1453 | + screen_max_x = 1024; |
---|
| 1454 | + screen_max_y = 600; |
---|
| 1455 | + revert_x_flag = 0; |
---|
| 1456 | + revert_y_flag = 0; |
---|
| 1457 | + exchange_x_y_flag = 0; |
---|
| 1458 | +#else |
---|
| 1459 | + screen_max_x = config_info.screen_max_x; |
---|
| 1460 | + screen_max_y = config_info.screen_max_y; |
---|
| 1461 | + revert_x_flag = config_info.revert_x_flag; |
---|
| 1462 | + revert_y_flag = config_info.revert_y_flag; |
---|
| 1463 | + exchange_x_y_flag = config_info.exchange_x_y_flag; |
---|
| 1464 | +#endif |
---|
| 1465 | + if((screen_max_x == 0) || (screen_max_y == 0)){ |
---|
| 1466 | + printk("%s:read config error!\n",__func__); |
---|
| 1467 | + return 0; |
---|
| 1468 | + } |
---|
| 1469 | + return 1; |
---|
3405 | 1470 | } |
---|
3406 | 1471 | |
---|
3407 | | -static int startup(void) |
---|
| 1472 | +/******************************************************* |
---|
| 1473 | + * Function: |
---|
| 1474 | + * Driver Install function. |
---|
| 1475 | + * Input: |
---|
| 1476 | + * None. |
---|
| 1477 | + * Output: |
---|
| 1478 | + * Executive Outcomes. 0---succeed. |
---|
| 1479 | + * ********************************************************/ |
---|
| 1480 | +static int __init goodix_ts_init(void) |
---|
3408 | 1481 | { |
---|
3409 | 1482 | s32 ret = -1; |
---|
| 1483 | + int val = 0; |
---|
| 1484 | + struct device_node *np = NULL; |
---|
3410 | 1485 | |
---|
3411 | | - dprintk(DEBUG_INIT, "GTP driver init\n"); |
---|
| 1486 | + dprintk(DEBUG_INIT,"GTP driver init\n"); |
---|
3412 | 1487 | if (!input_sensor_startup(&(config_info.input_type))) { |
---|
3413 | 1488 | ret = input_sensor_init(&(config_info.input_type)); |
---|
3414 | 1489 | if (ret != 0) { |
---|
3415 | 1490 | pr_err("%s:ctp_ops.input_sensor_init err.\n", __func__); |
---|
3416 | | - return -1; |
---|
| 1491 | + return ret; |
---|
3417 | 1492 | } |
---|
3418 | 1493 | input_set_power_enable(&(config_info.input_type), 1); |
---|
3419 | 1494 | } else { |
---|
3420 | 1495 | pr_err("%s: input_ctp_startup err.\n", __func__); |
---|
3421 | | - return -1; |
---|
| 1496 | + return 0; |
---|
3422 | 1497 | } |
---|
3423 | | - if (config_info.ctp_used == 0) { |
---|
| 1498 | + if(config_info.ctp_used == 0){ |
---|
3424 | 1499 | printk("*** ctp_used set to 0 !\n"); |
---|
3425 | 1500 | printk("*** if use ctp,please put the sys_config.fex ctp_used set to 1. \n"); |
---|
3426 | | - return -1; |
---|
3427 | | - } |
---|
3428 | | - |
---|
3429 | | - if (config_info.ctp_gesture_wakeup == 1) { |
---|
3430 | | - gtp_gesture_wakeup = 1; |
---|
3431 | | - dprintk(DEBUG_INIT, "GTP driver gesture wakeup is used!\n"); |
---|
3432 | | - } |
---|
3433 | | - |
---|
3434 | | - if (!gtp_gesture_wakeup) |
---|
3435 | | - gtp_power_ctrl_sleep = 1; |
---|
3436 | | - |
---|
3437 | | - if (!ctp_get_system_config()) { |
---|
3438 | | - printk("%s:read config fail!\n", __func__); |
---|
3439 | | - return -1; |
---|
3440 | | - } |
---|
3441 | | - sunxi_gpio_to_name(CTP_IRQ_NUMBER, irq_pin_name); |
---|
3442 | | - gtp_io_init(20); |
---|
3443 | | - return 0; |
---|
3444 | | -} |
---|
3445 | | - |
---|
3446 | | -/******************************************************* |
---|
3447 | | -Function: |
---|
3448 | | - Driver Install function. |
---|
3449 | | -Input: |
---|
3450 | | - None. |
---|
3451 | | -Output: |
---|
3452 | | - Executive Outcomes. 0---succeed. |
---|
3453 | | -********************************************************/ |
---|
3454 | | -static int goodix_ts_init(void) |
---|
3455 | | -{ |
---|
3456 | | -#if !USE_DETECT |
---|
3457 | | - struct device_node *np = NULL; |
---|
3458 | | - char *p = NULL; |
---|
3459 | | -#endif |
---|
3460 | | - |
---|
3461 | | -#if USE_DETECT |
---|
3462 | | - if (startup() != 0) |
---|
3463 | 1501 | return 0; |
---|
3464 | | -#else |
---|
3465 | | - np = of_find_node_by_name(NULL, "ctp"); |
---|
3466 | | - if (np && np->parent) { |
---|
3467 | | - p = (char *) np->parent->name; |
---|
3468 | | - if (strncmp(p, "twi", 3) != 0) { |
---|
3469 | | - gUseDetect = 1; |
---|
3470 | | - if (startup() != 0) |
---|
3471 | | - return 0; |
---|
3472 | | - goodix_ts_driver.detect = ctp_detect; |
---|
3473 | | - } |
---|
3474 | 1502 | } |
---|
| 1503 | + |
---|
| 1504 | + np = of_find_node_by_name(NULL, "ctp"); |
---|
| 1505 | + if (!np) { |
---|
| 1506 | + pr_err("ERROR! get ctp node failed, func:%s, line:%d\n",__FUNCTION__, __LINE__); |
---|
| 1507 | + return -1; |
---|
| 1508 | + } |
---|
| 1509 | + |
---|
| 1510 | + ret = of_property_read_u32(np, "ctp_gesture_wakeup", &val); |
---|
| 1511 | + if (ret) { |
---|
| 1512 | + pr_err("get ctp_screen_max_x is fail, %d\n", ret); |
---|
| 1513 | + } |
---|
| 1514 | + msleep(10); |
---|
| 1515 | +#if 0 |
---|
| 1516 | + if(!ctp_get_system_config()){ |
---|
| 1517 | + printk("%s:read config fail!\n",__func__); |
---|
| 1518 | + return ret; |
---|
| 1519 | + } |
---|
| 1520 | +#else |
---|
| 1521 | + //ret = of_property_read_u32(np, "ctp_screen_max_x", &screen_max_x); |
---|
| 1522 | + //of_property_read_u32(np, "ctp_screen_max_y", &screen_max_y); |
---|
| 1523 | + //of_property_read_u32(np, "ctp_revert_x_flag", &revert_x_flag); |
---|
| 1524 | + //of_property_read_u32(np, "ctp_revert_y_flag", &revert_y_flag); |
---|
| 1525 | + //of_property_read_u32(np, "ctp_exchange_x_y_flag", &exchange_x_y_flag); |
---|
| 1526 | + printk(KERN_ERR"------------ screen_max_x=%d, screen_max_y=%d, revert_x_flag=%d, revert_y_flag=%d, exchange_x_y_flag=%d\n", screen_max_x, screen_max_y, revert_x_flag, revert_y_flag, exchange_x_y_flag); |
---|
3475 | 1527 | #endif |
---|
| 1528 | + sunxi_gpio_to_name(CTP_IRQ_NUMBER,irq_pin_name); |
---|
| 1529 | + gtp_io_init(20); |
---|
| 1530 | + |
---|
3476 | 1531 | goodix_wq = create_singlethread_workqueue("goodix_wq"); |
---|
3477 | | - if (!goodix_wq) { |
---|
| 1532 | + if (!goodix_wq) |
---|
| 1533 | + { |
---|
3478 | 1534 | GTP_ERROR("Creat workqueue failed."); |
---|
3479 | 1535 | return -ENOMEM; |
---|
3480 | 1536 | } |
---|
3481 | 1537 | #if GTP_ESD_PROTECT |
---|
3482 | | - INIT_DELAYED_WORK(>p_esd_check_work, gtp_esd_check_func); |
---|
3483 | | - gtp_esd_check_workqueue = create_workqueue("gtp_esd_check"); |
---|
| 1538 | + INIT_DELAYED_WORK(>p_esd_check_work, gtp_esd_check_func); |
---|
| 1539 | + gtp_esd_check_workqueue = create_workqueue("gtp_esd_check"); |
---|
3484 | 1540 | #endif |
---|
3485 | | - |
---|
3486 | | - i2c_add_driver(&goodix_ts_driver); |
---|
3487 | | - if (config_info.probed) |
---|
3488 | | - return 0; |
---|
3489 | | - else |
---|
3490 | | - return -1; |
---|
| 1541 | + goodix_ts_driver.detect = ctp_detect; |
---|
| 1542 | + ret = i2c_add_driver(&goodix_ts_driver); |
---|
| 1543 | + return ret; |
---|
3491 | 1544 | } |
---|
3492 | 1545 | |
---|
3493 | | -/******************************************************* |
---|
| 1546 | + |
---|
| 1547 | +/******************************************************* |
---|
3494 | 1548 | Function: |
---|
3495 | | - Driver uninstall function. |
---|
| 1549 | +Driver uninstall function. |
---|
3496 | 1550 | Input: |
---|
3497 | | - None. |
---|
| 1551 | +None. |
---|
3498 | 1552 | Output: |
---|
3499 | | - Executive Outcomes. 0---succeed. |
---|
3500 | | -********************************************************/ |
---|
| 1553 | +Executive Outcomes. 0---succeed. |
---|
| 1554 | + ********************************************************/ |
---|
3501 | 1555 | static void __exit goodix_ts_exit(void) |
---|
3502 | 1556 | { |
---|
3503 | | - dprintk(DEBUG_INIT,"GTP driver exited."); |
---|
| 1557 | + printk("GTP driver exited.\n"); |
---|
3504 | 1558 | i2c_del_driver(&goodix_ts_driver); |
---|
3505 | | - if (goodix_wq) |
---|
3506 | | - { |
---|
3507 | | - destroy_workqueue(goodix_wq); |
---|
3508 | | - } |
---|
3509 | | - input_set_power_enable(&(config_info.input_type), 0); |
---|
3510 | 1559 | input_sensor_free(&(config_info.input_type)); |
---|
3511 | 1560 | } |
---|
3512 | 1561 | |
---|
.. | .. |
---|
3515 | 1564 | |
---|
3516 | 1565 | MODULE_DESCRIPTION("GTP Series Driver"); |
---|
3517 | 1566 | MODULE_LICENSE("GPL"); |
---|
| 1567 | + |
---|