Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1 | /* drivers/input/touchscreen/gt9xx.c |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 2 | * |
| 3 | * Copyright (c) 2013, The Linux Foundation. All rights reserved. |
| 4 | * |
| 5 | * Linux Foundation chooses to take subject only to the GPLv2 license |
| 6 | * terms, and distributes only under these terms. |
| 7 | * |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 8 | * 2010 - 2013 Goodix Technology. |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 9 | * |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 14 | * |
| 15 | * This program is distributed in the hope that it will be a reference |
| 16 | * to you, when you are integrating the GOODiX's CTP IC into your system, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 19 | * General Public License for more details. |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 20 | * |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 21 | * Version: 1.8 |
| 22 | * Authors: andrew@goodix.com, meta@goodix.com |
| 23 | * Release Date: 2013/04/25 |
| 24 | * Revision record: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 25 | * V1.0: |
| 26 | * first Release. By Andrew, 2012/08/31 |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 27 | * V1.2: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 28 | * modify gtp_reset_guitar,slot report,tracking_id & 0x0F. |
| 29 | * By Andrew, 2012/10/15 |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 30 | * V1.4: |
| 31 | * modify gt9xx_update.c. By Andrew, 2012/12/12 |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 32 | * V1.6: |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 33 | * 1. new heartbeat/esd_protect mechanism(add external watchdog) |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 34 | * 2. doze mode, sliding wakeup |
| 35 | * 3. 3 more cfg_group(GT9 Sensor_ID: 0~5) |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 36 | * 3. config length verification |
| 37 | * 4. names & comments |
| 38 | * By Meta, 2013/03/11 |
| 39 | * V1.8: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 40 | * 1. pen/stylus identification |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 41 | * 2. read double check & fixed config support |
| 42 | * 2. new esd & slide wakeup optimization |
| 43 | * By Meta, 2013/06/08 |
| 44 | */ |
| 45 | |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 46 | #include "gt9xx.h" |
| 47 | |
Bingzhe Cai | d036117 | 2013-07-18 19:22:11 +0800 | [diff] [blame^] | 48 | #include <linux/of_gpio.h> |
| 49 | |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 50 | #if GTP_ICS_SLOT_REPORT |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 51 | #include <linux/input/mt.h> |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 52 | #endif |
| 53 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 54 | #define GOODIX_DEV_NAME "Goodix Capacitive TouchScreen" |
| 55 | #define CFG_MAX_TOUCH_POINTS 5 |
| 56 | #define GOODIX_COORDS_ARR_SIZE 4 |
| 57 | #define MAX_BUTTONS 4 |
| 58 | |
| 59 | /* HIGH: 0x28/0x29, LOW: 0xBA/0xBB */ |
| 60 | #define GTP_I2C_ADDRESS_HIGH 0x14 |
| 61 | #define GTP_I2C_ADDRESS_LOW 0x5D |
| 62 | #define CFG_GROUP_LEN(p_cfg_grp) (sizeof(p_cfg_grp) / sizeof(p_cfg_grp[0])) |
| 63 | |
| 64 | #define RESET_DELAY_T3_US 200 /* T3: > 100us */ |
| 65 | #define RESET_DELAY_T4 20 /* T4: > 5ms */ |
| 66 | |
| 67 | #define PHY_BUF_SIZE 32 |
| 68 | |
| 69 | #define GTP_MAX_TOUCH 5 |
| 70 | #define GTP_ESD_CHECK_CIRCLE_MS 2000 |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 71 | |
| 72 | #if GTP_HAVE_TOUCH_KEY |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 73 | static const u16 touch_key_array[] = {KEY_MENU, KEY_HOMEPAGE, KEY_BACK}; |
| 74 | #define GTP_MAX_KEY_NUM (sizeof(touch_key_array)/sizeof(touch_key_array[0])) |
| 75 | |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 76 | #if GTP_DEBUG_ON |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 77 | static const int key_codes[] = { |
| 78 | KEY_HOME, KEY_BACK, KEY_MENU, KEY_SEARCH |
| 79 | }; |
| 80 | static const char *const key_names[] = { |
| 81 | "Key_Home", "Key_Back", "Key_Menu", "Key_Search" |
| 82 | }; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 83 | #endif |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 84 | #endif |
| 85 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 86 | static void gtp_reset_guitar(struct goodix_ts_data *ts, int ms); |
| 87 | static void gtp_int_sync(struct goodix_ts_data *ts, int ms); |
| 88 | static int gtp_i2c_test(struct i2c_client *client); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 89 | |
| 90 | #ifdef CONFIG_HAS_EARLYSUSPEND |
| 91 | static void goodix_ts_early_suspend(struct early_suspend *h); |
| 92 | static void goodix_ts_late_resume(struct early_suspend *h); |
| 93 | #endif |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 94 | |
| 95 | #if GTP_ESD_PROTECT |
| 96 | static struct delayed_work gtp_esd_check_work; |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 97 | static struct workqueue_struct *gtp_esd_check_workqueue; |
| 98 | static void gtp_esd_check_func(struct work_struct *work); |
| 99 | static int gtp_init_ext_watchdog(struct i2c_client *client); |
| 100 | struct i2c_client *i2c_connect_client; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 101 | #endif |
| 102 | |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 103 | #if GTP_SLIDE_WAKEUP |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 104 | enum doze_status { |
| 105 | DOZE_DISABLED = 0, |
| 106 | DOZE_ENABLED = 1, |
| 107 | DOZE_WAKEUP = 2, |
| 108 | }; |
| 109 | static enum doze_status = DOZE_DISABLED; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 110 | static s8 gtp_enter_doze(struct goodix_ts_data *ts); |
| 111 | #endif |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 112 | bool init_done; |
| 113 | static u8 chip_gt9xxs; /* true if ic is gt9xxs, like gt915s */ |
| 114 | u8 grp_cfg_version; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 115 | |
| 116 | /******************************************************* |
| 117 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 118 | Read data from the i2c slave device. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 119 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 120 | client: i2c device. |
| 121 | buf[0~1]: read start address. |
| 122 | buf[2~len-1]: read data buffer. |
| 123 | len: GTP_ADDR_LENGTH + read bytes count |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 124 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 125 | numbers of i2c_msgs to transfer: |
| 126 | 2: succeed, otherwise: failed |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 127 | *********************************************************/ |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 128 | int gtp_i2c_read(struct i2c_client *client, u8 *buf, int len) |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 129 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 130 | struct goodix_ts_data *ts = i2c_get_clientdata(client); |
| 131 | struct i2c_msg msgs[2]; |
| 132 | int ret = -EIO; |
| 133 | int retries = 0; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 134 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 135 | GTP_DEBUG_FUNC(); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 136 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 137 | msgs[0].flags = !I2C_M_RD; |
| 138 | msgs[0].addr = client->addr; |
| 139 | msgs[0].len = GTP_ADDR_LENGTH; |
| 140 | msgs[0].buf = &buf[0]; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 141 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 142 | msgs[1].flags = I2C_M_RD; |
| 143 | msgs[1].addr = client->addr; |
| 144 | msgs[1].len = len - GTP_ADDR_LENGTH; |
| 145 | msgs[1].buf = &buf[GTP_ADDR_LENGTH]; |
| 146 | |
| 147 | while (retries < 5) { |
| 148 | ret = i2c_transfer(client->adapter, msgs, 2); |
| 149 | if (ret == 2) |
| 150 | break; |
| 151 | retries++; |
| 152 | } |
| 153 | if (retries >= 5) { |
| 154 | #if GTP_SLIDE_WAKEUP |
| 155 | /* reset chip would quit doze mode */ |
| 156 | if (DOZE_ENABLED == doze_status) |
| 157 | return ret; |
| 158 | #endif |
| 159 | GTP_DEBUG("I2C communication timeout, resetting chip..."); |
| 160 | if (init_done) |
| 161 | gtp_reset_guitar(ts, 10); |
| 162 | else |
| 163 | dev_warn(&client->dev, |
| 164 | "<GTP> gtp_reset_guitar exit init_done=%d:\n", |
| 165 | init_done); |
| 166 | } |
| 167 | return ret; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | /******************************************************* |
| 171 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 172 | Write data to the i2c slave device. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 173 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 174 | client: i2c device. |
| 175 | buf[0~1]: write start address. |
| 176 | buf[2~len-1]: data buffer |
| 177 | len: GTP_ADDR_LENGTH + write bytes count |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 178 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 179 | numbers of i2c_msgs to transfer: |
| 180 | 1: succeed, otherwise: failed |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 181 | *********************************************************/ |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 182 | int gtp_i2c_write(struct i2c_client *client, u8 *buf, int len) |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 183 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 184 | struct goodix_ts_data *ts = i2c_get_clientdata(client); |
| 185 | struct i2c_msg msg; |
| 186 | int ret = -EIO; |
| 187 | int retries = 0; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 188 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 189 | GTP_DEBUG_FUNC(); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 190 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 191 | msg.flags = !I2C_M_RD; |
| 192 | msg.addr = client->addr; |
| 193 | msg.len = len; |
| 194 | msg.buf = buf; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 195 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 196 | while (retries < 5) { |
| 197 | ret = i2c_transfer(client->adapter, &msg, 1); |
| 198 | if (ret == 1) |
| 199 | break; |
| 200 | retries++; |
| 201 | } |
| 202 | if ((retries >= 5)) { |
| 203 | #if GTP_SLIDE_WAKEUP |
| 204 | if (DOZE_ENABLED == doze_status) |
| 205 | return ret; |
| 206 | #endif |
| 207 | GTP_DEBUG("I2C communication timeout, resetting chip..."); |
| 208 | if (init_done) |
| 209 | gtp_reset_guitar(ts, 10); |
| 210 | else |
| 211 | dev_warn(&client->dev, |
| 212 | "<GTP> gtp_reset_guitar exit init_done=%d:\n", |
| 213 | init_done); |
| 214 | } |
| 215 | return ret; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 216 | } |
| 217 | /******************************************************* |
| 218 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 219 | i2c read twice, compare the results |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 220 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 221 | client: i2c device |
| 222 | addr: operate address |
| 223 | rxbuf: read data to store, if compare successful |
| 224 | len: bytes to read |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 225 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 226 | FAIL: read failed |
| 227 | SUCCESS: read successful |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 228 | *********************************************************/ |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 229 | int gtp_i2c_read_dbl_check(struct i2c_client *client, |
| 230 | u16 addr, u8 *rxbuf, int len) |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 231 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 232 | u8 buf[16] = {0}; |
| 233 | u8 confirm_buf[16] = {0}; |
| 234 | u8 retry = 0; |
| 235 | |
| 236 | while (retry++ < 3) { |
| 237 | memset(buf, 0xAA, 16); |
| 238 | buf[0] = (u8)(addr >> 8); |
| 239 | buf[1] = (u8)(addr & 0xFF); |
| 240 | gtp_i2c_read(client, buf, len + 2); |
| 241 | |
| 242 | memset(confirm_buf, 0xAB, 16); |
| 243 | confirm_buf[0] = (u8)(addr >> 8); |
| 244 | confirm_buf[1] = (u8)(addr & 0xFF); |
| 245 | gtp_i2c_read(client, confirm_buf, len + 2); |
| 246 | |
| 247 | if (!memcmp(buf, confirm_buf, len + 2)) |
| 248 | break; |
| 249 | } |
| 250 | if (retry < 3) { |
| 251 | memcpy(rxbuf, confirm_buf + 2, len); |
| 252 | return SUCCESS; |
| 253 | } else { |
| 254 | dev_err(&client->dev, |
| 255 | "i2c read 0x%04X, %d bytes, double check failed!", |
| 256 | addr, len); |
| 257 | return FAIL; |
| 258 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | /******************************************************* |
| 262 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 263 | Send config data. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 264 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 265 | client: i2c device. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 266 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 267 | result of i2c write operation. |
| 268 | > 0: succeed, otherwise: failed |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 269 | *********************************************************/ |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 270 | static int gtp_send_cfg(struct goodix_ts_data *ts) |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 271 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 272 | int ret; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 273 | #if GTP_DRIVER_SEND_CFG |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 274 | int retry = 0; |
| 275 | |
| 276 | if (ts->fixed_cfg) { |
| 277 | dev_dbg(&ts->client->dev, |
| 278 | "Ic fixed config, no config sent!"); |
| 279 | ret = 2; |
| 280 | } else { |
| 281 | for (retry = 0; retry < 5; retry++) { |
| 282 | ret = gtp_i2c_write(ts->client, |
| 283 | ts->config_data, |
| 284 | GTP_CONFIG_MAX_LENGTH + GTP_ADDR_LENGTH); |
| 285 | if (ret > 0) |
| 286 | break; |
| 287 | } |
| 288 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 289 | #endif |
| 290 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 291 | return ret; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | /******************************************************* |
| 295 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 296 | Disable irq function |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 297 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 298 | ts: goodix i2c_client private data |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 299 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 300 | None. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 301 | *********************************************************/ |
| 302 | void gtp_irq_disable(struct goodix_ts_data *ts) |
| 303 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 304 | unsigned long irqflags; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 305 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 306 | GTP_DEBUG_FUNC(); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 307 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 308 | spin_lock_irqsave(&ts->irq_lock, irqflags); |
| 309 | if (!ts->irq_is_disabled) { |
| 310 | ts->irq_is_disabled = true; |
| 311 | disable_irq_nosync(ts->client->irq); |
| 312 | } |
| 313 | spin_unlock_irqrestore(&ts->irq_lock, irqflags); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | /******************************************************* |
| 317 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 318 | Enable irq function |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 319 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 320 | ts: goodix i2c_client private data |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 321 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 322 | None. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 323 | *********************************************************/ |
| 324 | void gtp_irq_enable(struct goodix_ts_data *ts) |
| 325 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 326 | unsigned long irqflags = 0; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 327 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 328 | GTP_DEBUG_FUNC(); |
| 329 | |
| 330 | spin_lock_irqsave(&ts->irq_lock, irqflags); |
| 331 | if (ts->irq_is_disabled) { |
| 332 | enable_irq(ts->client->irq); |
| 333 | ts->irq_is_disabled = false; |
| 334 | } |
| 335 | spin_unlock_irqrestore(&ts->irq_lock, irqflags); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 336 | } |
| 337 | |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 338 | /******************************************************* |
| 339 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 340 | Report touch point event |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 341 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 342 | ts: goodix i2c_client private data |
| 343 | id: trackId |
| 344 | x: input x coordinate |
| 345 | y: input y coordinate |
| 346 | w: input pressure |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 347 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 348 | None. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 349 | *********************************************************/ |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 350 | static void gtp_touch_down(struct goodix_ts_data *ts, int id, int x, int y, |
| 351 | int w) |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 352 | { |
| 353 | #if GTP_CHANGE_X2Y |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 354 | GTP_SWAP(x, y); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 355 | #endif |
| 356 | |
| 357 | #if GTP_ICS_SLOT_REPORT |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 358 | input_mt_slot(ts->input_dev, id); |
| 359 | input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, id); |
| 360 | input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x); |
| 361 | input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y); |
| 362 | input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, w); |
| 363 | input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, w); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 364 | #else |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 365 | input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x); |
| 366 | input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y); |
| 367 | input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, w); |
| 368 | input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, w); |
| 369 | input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, id); |
| 370 | input_mt_sync(ts->input_dev); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 371 | #endif |
| 372 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 373 | GTP_DEBUG("ID:%d, X:%d, Y:%d, W:%d", id, x, y, w); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | /******************************************************* |
| 377 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 378 | Report touch release event |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 379 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 380 | ts: goodix i2c_client private data |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 381 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 382 | None. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 383 | *********************************************************/ |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 384 | static void gtp_touch_up(struct goodix_ts_data *ts, int id) |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 385 | { |
| 386 | #if GTP_ICS_SLOT_REPORT |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 387 | input_mt_slot(ts->input_dev, id); |
| 388 | input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, -1); |
| 389 | GTP_DEBUG("Touch id[%2d] release!", id); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 390 | #else |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 391 | input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0); |
| 392 | input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0); |
| 393 | input_mt_sync(ts->input_dev); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 394 | #endif |
| 395 | } |
| 396 | |
| 397 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 398 | |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 399 | /******************************************************* |
| 400 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 401 | Goodix touchscreen work function |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 402 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 403 | work: work struct of goodix_workqueue |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 404 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 405 | None. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 406 | *********************************************************/ |
| 407 | static void goodix_ts_work_func(struct work_struct *work) |
| 408 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 409 | u8 end_cmd[3] = { GTP_READ_COOR_ADDR >> 8, |
| 410 | GTP_READ_COOR_ADDR & 0xFF, 0}; |
| 411 | u8 point_data[2 + 1 + 8 * GTP_MAX_TOUCH + 1] = { |
| 412 | GTP_READ_COOR_ADDR >> 8, |
| 413 | GTP_READ_COOR_ADDR & 0xFF}; |
| 414 | u8 touch_num = 0; |
| 415 | u8 finger = 0; |
| 416 | static u16 pre_touch; |
| 417 | static u8 pre_key; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 418 | #if GTP_WITH_PEN |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 419 | static u8 pre_pen; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 420 | #endif |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 421 | u8 key_value = 0; |
| 422 | u8 *coor_data = NULL; |
| 423 | s32 input_x = 0; |
| 424 | s32 input_y = 0; |
| 425 | s32 input_w = 0; |
| 426 | s32 id = 0; |
| 427 | s32 i = 0; |
| 428 | int ret = -1; |
| 429 | struct goodix_ts_data *ts = NULL; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 430 | |
| 431 | #if GTP_SLIDE_WAKEUP |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 432 | u8 doze_buf[3] = {0x81, 0x4B}; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 433 | #endif |
| 434 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 435 | GTP_DEBUG_FUNC(); |
| 436 | |
| 437 | ts = container_of(work, struct goodix_ts_data, work); |
| 438 | #ifdef CONFIG_GT9XX_TOUCHPANEL_UPDATE |
| 439 | if (ts->enter_update) |
| 440 | return; |
| 441 | #endif |
| 442 | |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 443 | #if GTP_SLIDE_WAKEUP |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 444 | if (DOZE_ENABLED == doze_status) { |
| 445 | ret = gtp_i2c_read(ts->client, doze_buf, 3); |
| 446 | GTP_DEBUG("0x814B = 0x%02X", doze_buf[2]); |
| 447 | if (ret > 0) { |
| 448 | if (doze_buf[2] == 0xAA) { |
| 449 | dev_dbg(&ts->client->dev, |
| 450 | "Slide(0xAA) To Light up the screen!"); |
| 451 | doze_status = DOZE_WAKEUP; |
| 452 | input_report_key( |
| 453 | ts->input_dev, KEY_POWER, 1); |
| 454 | input_sync(ts->input_dev); |
| 455 | input_report_key( |
| 456 | ts->input_dev, KEY_POWER, 0); |
| 457 | input_sync(ts->input_dev); |
| 458 | /* clear 0x814B */ |
| 459 | doze_buf[2] = 0x00; |
| 460 | gtp_i2c_write(ts->client, doze_buf, 3); |
| 461 | } else if (doze_buf[2] == 0xBB) { |
| 462 | dev_dbg(&ts->client->dev, |
| 463 | "Slide(0xBB) To Light up the screen!"); |
| 464 | doze_status = DOZE_WAKEUP; |
| 465 | input_report_key(ts->input_dev, KEY_POWER, 1); |
| 466 | input_sync(ts->input_dev); |
| 467 | input_report_key(ts->input_dev, KEY_POWER, 0); |
| 468 | input_sync(ts->input_dev); |
| 469 | /* clear 0x814B*/ |
| 470 | doze_buf[2] = 0x00; |
| 471 | gtp_i2c_write(ts->client, doze_buf, 3); |
| 472 | } else if (0xC0 == (doze_buf[2] & 0xC0)) { |
| 473 | dev_dbg(&ts->client->dev, |
| 474 | "double click to light up the screen!"); |
| 475 | doze_status = DOZE_WAKEUP; |
| 476 | input_report_key(ts->input_dev, KEY_POWER, 1); |
| 477 | input_sync(ts->input_dev); |
| 478 | input_report_key(ts->input_dev, KEY_POWER, 0); |
| 479 | input_sync(ts->input_dev); |
| 480 | /* clear 0x814B */ |
| 481 | doze_buf[2] = 0x00; |
| 482 | gtp_i2c_write(ts->client, doze_buf, 3); |
| 483 | } else { |
| 484 | gtp_enter_doze(ts); |
| 485 | } |
| 486 | } |
| 487 | if (ts->use_irq) |
| 488 | gtp_irq_enable(ts); |
| 489 | |
| 490 | return; |
| 491 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 492 | #endif |
| 493 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 494 | ret = gtp_i2c_read(ts->client, point_data, 12); |
| 495 | if (ret < 0) { |
| 496 | dev_err(&ts->client->dev, |
| 497 | "I2C transfer error. errno:%d\n ", ret); |
| 498 | goto exit_work_func; |
| 499 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 500 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 501 | finger = point_data[GTP_ADDR_LENGTH]; |
| 502 | if ((finger & 0x80) == 0) |
| 503 | goto exit_work_func; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 504 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 505 | touch_num = finger & 0x0f; |
| 506 | if (touch_num > GTP_MAX_TOUCH) |
| 507 | goto exit_work_func; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 508 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 509 | if (touch_num > 1) { |
| 510 | u8 buf[8 * GTP_MAX_TOUCH] = { (GTP_READ_COOR_ADDR + 10) >> 8, |
| 511 | (GTP_READ_COOR_ADDR + 10) & 0xff }; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 512 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 513 | ret = gtp_i2c_read(ts->client, buf, |
| 514 | 2 + 8 * (touch_num - 1)); |
| 515 | memcpy(&point_data[12], &buf[2], 8 * (touch_num - 1)); |
| 516 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 517 | |
| 518 | #if GTP_HAVE_TOUCH_KEY |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 519 | key_value = point_data[3 + 8 * touch_num]; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 520 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 521 | if (key_value || pre_key) { |
| 522 | for (i = 0; i < GTP_MAX_KEY_NUM; i++) { |
| 523 | #if GTP_DEBUG_ON |
| 524 | for (ret = 0; ret < 4; ++ret) { |
| 525 | if (key_codes[ret] == touch_key_array[i]) { |
| 526 | GTP_DEBUG("Key: %s %s", |
| 527 | key_names[ret], |
| 528 | (key_value & (0x01 << i)) |
| 529 | ? "Down" : "Up"); |
| 530 | break; |
| 531 | } |
| 532 | } |
| 533 | #endif |
| 534 | |
| 535 | input_report_key(ts->input_dev, |
| 536 | touch_key_array[i], key_value & (0x01<<i)); |
| 537 | } |
| 538 | touch_num = 0; |
| 539 | pre_touch = 0; |
| 540 | } |
| 541 | #endif |
| 542 | pre_key = key_value; |
| 543 | |
| 544 | GTP_DEBUG("pre_touch:%02x, finger:%02x.", pre_touch, finger); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 545 | |
| 546 | #if GTP_ICS_SLOT_REPORT |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 547 | #if GTP_WITH_PEN |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 548 | if (pre_pen && (touch_num == 0)) { |
| 549 | GTP_DEBUG("Pen touch UP(Slot)!"); |
| 550 | input_report_key(ts->input_dev, BTN_TOOL_PEN, 0); |
| 551 | input_mt_slot(ts->input_dev, 5); |
| 552 | input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, -1); |
| 553 | pre_pen = 0; |
| 554 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 555 | #endif |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 556 | if (pre_touch || touch_num) { |
| 557 | s32 pos = 0; |
| 558 | u16 touch_index = 0; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 559 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 560 | coor_data = &point_data[3]; |
| 561 | if (touch_num) { |
| 562 | id = coor_data[pos] & 0x0F; |
| 563 | #if GTP_WITH_PEN |
| 564 | id = coor_data[pos]; |
| 565 | if (id == 128) { |
| 566 | GTP_DEBUG("Pen touch DOWN(Slot)!"); |
| 567 | input_x = coor_data[pos + 1] |
| 568 | | (coor_data[pos + 2] << 8); |
| 569 | input_y = coor_data[pos + 3] |
| 570 | | (coor_data[pos + 4] << 8); |
| 571 | input_w = coor_data[pos + 5] |
| 572 | | (coor_data[pos + 6] << 8); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 573 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 574 | input_report_key(ts->input_dev, |
| 575 | BTN_TOOL_PEN, 1); |
| 576 | input_mt_slot(ts->input_dev, 5); |
| 577 | input_report_abs(ts->input_dev, |
| 578 | ABS_MT_TRACKING_ID, 5); |
| 579 | input_report_abs(ts->input_dev, |
| 580 | ABS_MT_POSITION_X, input_x); |
| 581 | input_report_abs(ts->input_dev, |
| 582 | ABS_MT_POSITION_Y, input_y); |
| 583 | input_report_abs(ts->input_dev, |
| 584 | ABS_MT_TOUCH_MAJOR, input_w); |
| 585 | GTP_DEBUG("Pen/Stylus: (%d, %d)[%d]", |
| 586 | input_x, input_y, input_w); |
| 587 | pre_pen = 1; |
| 588 | pre_touch = 0; |
| 589 | } |
| 590 | #endif |
| 591 | |
| 592 | touch_index |= (0x01<<id); |
| 593 | } |
| 594 | |
| 595 | GTP_DEBUG("id = %d,touch_index = 0x%x, pre_touch = 0x%x\n", |
| 596 | id, touch_index, pre_touch); |
| 597 | for (i = 0; i < GTP_MAX_TOUCH; i++) { |
| 598 | #if GTP_WITH_PEN |
| 599 | if (pre_pen == 1) |
| 600 | break; |
| 601 | #endif |
| 602 | if (touch_index & (0x01<<i)) { |
| 603 | input_x = coor_data[pos + 1] | |
| 604 | coor_data[pos + 2] << 8; |
| 605 | input_y = coor_data[pos + 3] | |
| 606 | coor_data[pos + 4] << 8; |
| 607 | input_w = coor_data[pos + 5] | |
| 608 | coor_data[pos + 6] << 8; |
| 609 | |
| 610 | gtp_touch_down(ts, id, |
| 611 | input_x, input_y, input_w); |
| 612 | pre_touch |= 0x01 << i; |
| 613 | |
| 614 | pos += 8; |
| 615 | id = coor_data[pos] & 0x0F; |
| 616 | touch_index |= (0x01<<id); |
| 617 | } else { |
| 618 | gtp_touch_up(ts, i); |
| 619 | pre_touch &= ~(0x01 << i); |
| 620 | } |
| 621 | } |
| 622 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 623 | #else |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 624 | input_report_key(ts->input_dev, BTN_TOUCH, (touch_num || key_value)); |
| 625 | if (touch_num) { |
| 626 | for (i = 0; i < touch_num; i++) { |
| 627 | coor_data = &point_data[i * 8 + 3]; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 628 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 629 | id = coor_data[0]; |
| 630 | input_x = coor_data[1] | coor_data[2] << 8; |
| 631 | input_y = coor_data[3] | coor_data[4] << 8; |
| 632 | input_w = coor_data[5] | coor_data[6] << 8; |
| 633 | #if GTP_WITH_PEN |
| 634 | if (id == 128) { |
| 635 | GTP_DEBUG("Pen touch DOWN!"); |
| 636 | input_report_key(ts->input_dev, |
| 637 | BTN_TOOL_PEN, 1); |
| 638 | pre_pen = 1; |
| 639 | id = 0; |
| 640 | } |
| 641 | #endif |
| 642 | gtp_touch_down(ts, id, input_x, input_y, input_w); |
| 643 | } |
| 644 | } else if (pre_touch) { |
| 645 | #if GTP_WITH_PEN |
| 646 | if (pre_pen == 1) { |
| 647 | GTP_DEBUG("Pen touch UP!"); |
| 648 | input_report_key(ts->input_dev, BTN_TOOL_PEN, 0); |
| 649 | pre_pen = 0; |
| 650 | } |
| 651 | #endif |
| 652 | GTP_DEBUG("Touch Released!"); |
| 653 | gtp_touch_up(ts, 0); |
| 654 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 655 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 656 | pre_touch = touch_num; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 657 | #endif |
| 658 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 659 | input_sync(ts->input_dev); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 660 | |
| 661 | exit_work_func: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 662 | if (!ts->gtp_rawdiff_mode) { |
| 663 | ret = gtp_i2c_write(ts->client, end_cmd, 3); |
| 664 | if (ret < 0) |
| 665 | dev_warn(&ts->client->dev, "I2C write end_cmd error!\n"); |
| 666 | |
| 667 | } |
| 668 | if (ts->use_irq) |
| 669 | gtp_irq_enable(ts); |
| 670 | |
| 671 | return; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | /******************************************************* |
| 675 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 676 | Timer interrupt service routine for polling mode. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 677 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 678 | timer: timer struct pointer |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 679 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 680 | Timer work mode. |
| 681 | HRTIMER_NORESTART: no restart mode |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 682 | *********************************************************/ |
| 683 | static enum hrtimer_restart goodix_ts_timer_handler(struct hrtimer *timer) |
| 684 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 685 | struct goodix_ts_data |
| 686 | *ts = container_of(timer, struct goodix_ts_data, timer); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 687 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 688 | GTP_DEBUG_FUNC(); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 689 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 690 | queue_work(ts->goodix_wq, &ts->work); |
| 691 | hrtimer_start(&ts->timer, ktime_set(0, (GTP_POLL_TIME + 6) * 1000000), |
| 692 | HRTIMER_MODE_REL); |
| 693 | return HRTIMER_NORESTART; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 694 | } |
| 695 | |
| 696 | /******************************************************* |
| 697 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 698 | External interrupt service routine for interrupt mode. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 699 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 700 | irq: interrupt number. |
| 701 | dev_id: private data pointer |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 702 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 703 | Handle Result. |
| 704 | IRQ_HANDLED: interrupt handled successfully |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 705 | *********************************************************/ |
| 706 | static irqreturn_t goodix_ts_irq_handler(int irq, void *dev_id) |
| 707 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 708 | struct goodix_ts_data *ts = dev_id; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 709 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 710 | GTP_DEBUG_FUNC(); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 711 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 712 | gtp_irq_disable(ts); |
| 713 | |
| 714 | queue_work(ts->goodix_wq, &ts->work); |
| 715 | |
| 716 | return IRQ_HANDLED; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 717 | } |
| 718 | /******************************************************* |
| 719 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 720 | Synchronization. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 721 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 722 | ms: synchronization time in millisecond. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 723 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 724 | None. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 725 | *******************************************************/ |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 726 | void gtp_int_sync(struct goodix_ts_data *ts, int ms) |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 727 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 728 | gpio_direction_output(ts->pdata->irq_gpio, 0); |
| 729 | msleep(ms); |
| 730 | gpio_direction_input(ts->pdata->irq_gpio); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 731 | } |
| 732 | |
| 733 | /******************************************************* |
| 734 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 735 | Reset chip. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 736 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 737 | ms: reset time in millisecond, must >10ms |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 738 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 739 | None. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 740 | *******************************************************/ |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 741 | static void gtp_reset_guitar(struct goodix_ts_data *ts, int ms) |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 742 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 743 | GTP_DEBUG_FUNC(); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 744 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 745 | /* This reset sequence will selcet I2C slave address */ |
| 746 | gpio_direction_output(ts->pdata->reset_gpio, 0); |
| 747 | msleep(ms); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 748 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 749 | if (ts->client->addr == GTP_I2C_ADDRESS_HIGH) |
| 750 | gpio_direction_output(ts->pdata->irq_gpio, 1); |
| 751 | else |
| 752 | gpio_direction_output(ts->pdata->irq_gpio, 0); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 753 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 754 | usleep(RESET_DELAY_T3_US); |
| 755 | gpio_direction_output(ts->pdata->reset_gpio, 1); |
| 756 | msleep(RESET_DELAY_T4); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 757 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 758 | gpio_direction_input(ts->pdata->reset_gpio); |
| 759 | |
| 760 | gtp_int_sync(ts, 50); |
| 761 | |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 762 | #if GTP_ESD_PROTECT |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 763 | gtp_init_ext_watchdog(ts->client); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 764 | #endif |
| 765 | } |
| 766 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 767 | #ifdef CONFIG_HAS_EARLYSUSPEND |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 768 | #if GTP_SLIDE_WAKEUP |
| 769 | /******************************************************* |
| 770 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 771 | Enter doze mode for sliding wakeup. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 772 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 773 | ts: goodix tp private data |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 774 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 775 | 1: succeed, otherwise failed |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 776 | *******************************************************/ |
| 777 | static s8 gtp_enter_doze(struct goodix_ts_data *ts) |
| 778 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 779 | int ret = -1; |
| 780 | s8 retry = 0; |
| 781 | u8 i2c_control_buf[3] = { |
| 782 | (u8)(GTP_REG_SLEEP >> 8), |
| 783 | (u8)GTP_REG_SLEEP, 8}; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 784 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 785 | GTP_DEBUG_FUNC(); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 786 | |
| 787 | #if GTP_DBL_CLK_WAKEUP |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 788 | i2c_control_buf[2] = 0x09; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 789 | #endif |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 790 | gtp_irq_disable(ts); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 791 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 792 | GTP_DEBUG("entering doze mode..."); |
| 793 | while (retry++ < 5) { |
| 794 | i2c_control_buf[0] = 0x80; |
| 795 | i2c_control_buf[1] = 0x46; |
| 796 | ret = gtp_i2c_write(ts->client, i2c_control_buf, 3); |
| 797 | if (ret < 0) { |
| 798 | GTP_DEBUG( |
| 799 | "failed to set doze flag into 0x8046, %d", |
| 800 | retry); |
| 801 | continue; |
| 802 | } |
| 803 | i2c_control_buf[0] = 0x80; |
| 804 | i2c_control_buf[1] = 0x40; |
| 805 | ret = gtp_i2c_write(ts->client, i2c_control_buf, 3); |
| 806 | if (ret > 0) { |
| 807 | doze_status = DOZE_ENABLED; |
| 808 | dev_dbg(&ts->client->dev, |
| 809 | "GTP has been working in doze mode!"); |
| 810 | gtp_irq_enable(ts); |
| 811 | return ret; |
| 812 | } |
| 813 | msleep(20); |
| 814 | } |
| 815 | dev_err(&ts->client->dev, "GTP send doze cmd failed.\n"); |
| 816 | gtp_irq_enable(ts); |
| 817 | return ret; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 818 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 819 | #else |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 820 | /******************************************************* |
| 821 | Function: |
| 822 | Enter sleep mode. |
| 823 | Input: |
| 824 | ts: private data. |
| 825 | Output: |
| 826 | Executive outcomes. |
| 827 | 1: succeed, otherwise failed. |
| 828 | *******************************************************/ |
| 829 | static s8 gtp_enter_sleep(struct goodix_ts_data *ts) |
| 830 | { |
| 831 | int ret = -1; |
| 832 | s8 retry = 0; |
| 833 | u8 i2c_control_buf[3] = { |
| 834 | (u8)(GTP_REG_SLEEP >> 8), |
| 835 | (u8)GTP_REG_SLEEP, 5}; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 836 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 837 | GTP_DEBUG_FUNC(); |
| 838 | |
| 839 | ret = gpio_direction_output(ts->pdata->irq_gpio, 0); |
| 840 | usleep(5000); |
| 841 | while (retry++ < 5) { |
| 842 | ret = gtp_i2c_write(ts->client, i2c_control_buf, 3); |
| 843 | if (ret > 0) { |
| 844 | dev_dbg(&ts->client->dev, |
| 845 | "GTP enter sleep!"); |
| 846 | return ret; |
| 847 | } |
| 848 | msleep(20); |
| 849 | } |
| 850 | dev_err(&ts->client->dev, "GTP send sleep cmd failed.\n"); |
| 851 | return ret; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 852 | } |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 853 | #endif |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 854 | |
| 855 | /******************************************************* |
| 856 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 857 | Wakeup from sleep. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 858 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 859 | ts: private data. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 860 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 861 | Executive outcomes. |
| 862 | >0: succeed, otherwise: failed. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 863 | *******************************************************/ |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 864 | static s8 gtp_wakeup_sleep(struct goodix_ts_data *ts) |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 865 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 866 | u8 retry = 0; |
| 867 | s8 ret = -1; |
| 868 | |
| 869 | GTP_DEBUG_FUNC(); |
| 870 | |
| 871 | #if GTP_POWER_CTRL_SLEEP |
| 872 | while (retry++ < 5) { |
| 873 | gtp_reset_guitar(ts, 20); |
| 874 | |
| 875 | ret = gtp_send_cfg(ts); |
| 876 | if (ret > 0) { |
| 877 | dev_dbg(&ts->client->dev, |
| 878 | "Wakeup sleep send config success."); |
| 879 | continue; |
| 880 | } |
| 881 | dev_dbg(&ts->client->dev, "GTP Wakeup!"); |
| 882 | return 1; |
| 883 | } |
| 884 | #else |
| 885 | while (retry++ < 10) { |
| 886 | #if GTP_SLIDE_WAKEUP |
| 887 | /* wakeup not by slide */ |
| 888 | if (DOZE_WAKEUP != doze_status) |
| 889 | gtp_reset_guitar(ts, 10); |
| 890 | else |
| 891 | /* wakeup by slide */ |
| 892 | doze_status = DOZE_DISABLED; |
| 893 | #else |
| 894 | if (chip_gt9xxs == 1) { |
| 895 | gtp_reset_guitar(ts, 10); |
| 896 | } else { |
| 897 | ret = gpio_direction_output(ts->pdata->irq_gpio, 1); |
| 898 | usleep(5000); |
| 899 | } |
| 900 | #endif |
| 901 | ret = gtp_i2c_test(ts->client); |
| 902 | if (ret > 0) { |
| 903 | dev_dbg(&ts->client->dev, "GTP wakeup sleep."); |
| 904 | #if (!GTP_SLIDE_WAKEUP) |
| 905 | if (chip_gt9xxs == 0) { |
| 906 | gtp_int_sync(ts, 25); |
| 907 | msleep(20); |
| 908 | #if GTP_ESD_PROTECT |
| 909 | gtp_init_ext_watchdog(ts->client); |
| 910 | #endif |
| 911 | } |
| 912 | #endif |
| 913 | return ret; |
| 914 | } |
| 915 | gtp_reset_guitar(ts, 20); |
| 916 | } |
| 917 | #endif |
| 918 | |
| 919 | dev_err(&ts->client->dev, "GTP wakeup sleep failed.\n"); |
| 920 | return ret; |
| 921 | } |
| 922 | #endif /* !CONFIG_HAS_EARLYSUSPEND */ |
| 923 | |
| 924 | /******************************************************* |
| 925 | Function: |
| 926 | Initialize gtp. |
| 927 | Input: |
| 928 | ts: goodix private data |
| 929 | Output: |
| 930 | Executive outcomes. |
| 931 | > =0: succeed, otherwise: failed |
| 932 | *******************************************************/ |
| 933 | static int gtp_init_panel(struct goodix_ts_data *ts) |
| 934 | { |
| 935 | struct i2c_client *client = ts->client; |
| 936 | unsigned char *config_data; |
| 937 | int ret = -EIO; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 938 | |
| 939 | #if GTP_DRIVER_SEND_CFG |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 940 | int i; |
| 941 | u8 check_sum = 0; |
| 942 | u8 opr_buf[16]; |
| 943 | u8 sensor_id = 0; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 944 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 945 | u8 cfg_info_group1[] = CTP_CFG_GROUP1; |
| 946 | u8 cfg_info_group2[] = CTP_CFG_GROUP2; |
| 947 | u8 cfg_info_group3[] = CTP_CFG_GROUP3; |
| 948 | u8 cfg_info_group4[] = CTP_CFG_GROUP4; |
| 949 | u8 cfg_info_group5[] = CTP_CFG_GROUP5; |
| 950 | u8 cfg_info_group6[] = CTP_CFG_GROUP6; |
| 951 | u8 *send_cfg_buf[] = {cfg_info_group1, cfg_info_group2, |
| 952 | cfg_info_group3, cfg_info_group4, |
| 953 | cfg_info_group5, cfg_info_group6}; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 954 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 955 | u8 cfg_info_len[] = {CFG_GROUP_LEN(cfg_info_group1), |
| 956 | CFG_GROUP_LEN(cfg_info_group2), |
| 957 | CFG_GROUP_LEN(cfg_info_group3), |
| 958 | CFG_GROUP_LEN(cfg_info_group4), |
| 959 | CFG_GROUP_LEN(cfg_info_group5), |
| 960 | CFG_GROUP_LEN(cfg_info_group6)}; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 961 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 962 | GTP_DEBUG("Config Groups\' Lengths: %d, %d, %d, %d, %d, %d", |
| 963 | cfg_info_len[0], cfg_info_len[1], cfg_info_len[2], |
| 964 | cfg_info_len[3], cfg_info_len[4], cfg_info_len[5]); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 965 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 966 | ret = gtp_i2c_read_dbl_check(ts->client, 0x41E4, opr_buf, 1); |
| 967 | if (SUCCESS == ret) { |
| 968 | if (opr_buf[0] != 0xBE) { |
| 969 | ts->fw_error = 1; |
| 970 | dev_err(&client->dev, |
| 971 | "Firmware error, no config sent!"); |
| 972 | return -EINVAL; |
| 973 | } |
| 974 | } |
| 975 | if ((!cfg_info_len[1]) && (!cfg_info_len[2]) && (!cfg_info_len[3]) |
| 976 | && (!cfg_info_len[4]) && (!cfg_info_len[5])) { |
| 977 | sensor_id = 0; |
| 978 | } else { |
| 979 | ret = gtp_i2c_read_dbl_check(ts->client, GTP_REG_SENSOR_ID, |
| 980 | &sensor_id, 1); |
| 981 | if (SUCCESS == ret) { |
| 982 | if (sensor_id >= 0x06) { |
| 983 | dev_err(&client->dev, |
| 984 | "Invalid sensor_id(0x%02X), No Config Sent!", |
| 985 | sensor_id); |
| 986 | return -EINVAL; |
| 987 | } |
| 988 | } else { |
| 989 | dev_err(&client->dev, |
| 990 | "Failed to get sensor_id, No config sent!"); |
| 991 | return -EINVAL; |
| 992 | } |
| 993 | } |
| 994 | GTP_DEBUG("Sensor_ID: %d", sensor_id); |
| 995 | |
| 996 | ts->gtp_cfg_len = cfg_info_len[sensor_id]; |
| 997 | |
| 998 | if (ts->gtp_cfg_len < GTP_CONFIG_MIN_LENGTH) { |
| 999 | dev_err(&client->dev, |
| 1000 | "Sensor_ID(%d) matches with NULL or INVALID CONFIG GROUP! NO Config Sent! You need to check you header file CFG_GROUP section!\n", |
| 1001 | sensor_id); |
| 1002 | return -EINVAL; |
| 1003 | } |
| 1004 | ret = gtp_i2c_read_dbl_check(ts->client, GTP_REG_CONFIG_DATA, |
| 1005 | &opr_buf[0], 1); |
| 1006 | |
| 1007 | if (ret == SUCCESS) { |
| 1008 | if (opr_buf[0] < 90) { |
| 1009 | /* backup group config version */ |
| 1010 | grp_cfg_version = send_cfg_buf[sensor_id][0]; |
| 1011 | send_cfg_buf[sensor_id][0] = 0x00; |
| 1012 | ts->fixed_cfg = 0; |
| 1013 | } else { |
| 1014 | /* treated as fixed config, not send config */ |
| 1015 | dev_warn(&client->dev, |
| 1016 | "Ic fixed config with config version(%d, 0x%02X)", |
| 1017 | opr_buf[0], opr_buf[0]); |
| 1018 | ts->fixed_cfg = 1; |
| 1019 | } |
| 1020 | } else { |
| 1021 | dev_err(&client->dev, |
| 1022 | "Failed to get ic config version!No config sent!"); |
| 1023 | return -EINVAL; |
| 1024 | } |
| 1025 | |
Bingzhe Cai | d036117 | 2013-07-18 19:22:11 +0800 | [diff] [blame^] | 1026 | if (ts->pdata->gtp_cfg_len) { |
| 1027 | config_data = ts->pdata->config_data; |
| 1028 | ts->config_data = ts->pdata->config_data; |
| 1029 | ts->gtp_cfg_len = ts->pdata->gtp_cfg_len; |
| 1030 | } else { |
| 1031 | config_data = devm_kzalloc(&client->dev, |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1032 | GTP_CONFIG_MAX_LENGTH + GTP_ADDR_LENGTH, |
Bingzhe Cai | d036117 | 2013-07-18 19:22:11 +0800 | [diff] [blame^] | 1033 | GFP_KERNEL); |
| 1034 | if (!config_data) { |
| 1035 | dev_err(&client->dev, |
| 1036 | "Not enough memory for panel config data\n"); |
| 1037 | return -ENOMEM; |
| 1038 | } |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1039 | |
Bingzhe Cai | d036117 | 2013-07-18 19:22:11 +0800 | [diff] [blame^] | 1040 | ts->config_data = config_data; |
| 1041 | config_data[0] = GTP_REG_CONFIG_DATA >> 8; |
| 1042 | config_data[1] = GTP_REG_CONFIG_DATA & 0xff; |
| 1043 | memset(&config_data[GTP_ADDR_LENGTH], 0, GTP_CONFIG_MAX_LENGTH); |
| 1044 | memcpy(&config_data[GTP_ADDR_LENGTH], send_cfg_buf[sensor_id], |
| 1045 | ts->gtp_cfg_len); |
| 1046 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1047 | |
| 1048 | #if GTP_CUSTOM_CFG |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1049 | config_data[RESOLUTION_LOC] = |
| 1050 | (unsigned char)(GTP_MAX_WIDTH && 0xFF); |
| 1051 | config_data[RESOLUTION_LOC + 1] = |
| 1052 | (unsigned char)(GTP_MAX_WIDTH >> 8); |
| 1053 | config_data[RESOLUTION_LOC + 2] = |
| 1054 | (unsigned char)(GTP_MAX_HEIGHT && 0xFF); |
| 1055 | config_data[RESOLUTION_LOC + 3] = |
| 1056 | (unsigned char)(GTP_MAX_HEIGHT >> 8); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1057 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1058 | if (GTP_INT_TRIGGER == 0) |
| 1059 | config_data[TRIGGER_LOC] &= 0xfe; |
| 1060 | else if (GTP_INT_TRIGGER == 1) |
| 1061 | config_data[TRIGGER_LOC] |= 0x01; |
| 1062 | #endif /* !GTP_CUSTOM_CFG */ |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1063 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1064 | check_sum = 0; |
| 1065 | for (i = GTP_ADDR_LENGTH; i < ts->gtp_cfg_len; i++) |
| 1066 | check_sum += config_data[i]; |
| 1067 | |
| 1068 | config_data[ts->gtp_cfg_len] = (~check_sum) + 1; |
| 1069 | |
| 1070 | #else /* DRIVER NOT SEND CONFIG */ |
| 1071 | ts->gtp_cfg_len = GTP_CONFIG_MAX_LENGTH; |
| 1072 | ret = gtp_i2c_read(ts->client, config_data, |
| 1073 | ts->gtp_cfg_len + GTP_ADDR_LENGTH); |
| 1074 | if (ret < 0) { |
| 1075 | dev_err(&client->dev, |
| 1076 | "Read Config Failed, Using DEFAULT Resolution & INT Trigger!\n"); |
| 1077 | ts->abs_x_max = GTP_MAX_WIDTH; |
| 1078 | ts->abs_y_max = GTP_MAX_HEIGHT; |
| 1079 | ts->int_trigger_type = GTP_INT_TRIGGER; |
| 1080 | } |
| 1081 | #endif /* !DRIVER NOT SEND CONFIG */ |
| 1082 | |
| 1083 | GTP_DEBUG_FUNC(); |
| 1084 | if ((ts->abs_x_max == 0) && (ts->abs_y_max == 0)) { |
| 1085 | ts->abs_x_max = (config_data[RESOLUTION_LOC + 1] << 8) |
| 1086 | + config_data[RESOLUTION_LOC]; |
| 1087 | ts->abs_y_max = (config_data[RESOLUTION_LOC + 3] << 8) |
| 1088 | + config_data[RESOLUTION_LOC + 2]; |
| 1089 | ts->int_trigger_type = (config_data[TRIGGER_LOC]) & 0x03; |
| 1090 | } |
| 1091 | ret = gtp_send_cfg(ts); |
| 1092 | if (ret < 0) |
| 1093 | dev_err(&client->dev, "%s: Send config error.\n", __func__); |
| 1094 | |
| 1095 | GTP_DEBUG("X_MAX = %d, Y_MAX = %d, TRIGGER = 0x%02x", |
| 1096 | ts->abs_x_max, ts->abs_y_max, |
| 1097 | ts->int_trigger_type); |
| 1098 | |
| 1099 | msleep(20); |
| 1100 | return ret; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1101 | } |
| 1102 | |
| 1103 | /******************************************************* |
| 1104 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1105 | Read chip version. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1106 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1107 | client: i2c device |
| 1108 | version: buffer to keep ic firmware version |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1109 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1110 | read operation return. |
| 1111 | 2: succeed, otherwise: failed |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1112 | *******************************************************/ |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1113 | int gtp_read_version(struct i2c_client *client, u16 *version) |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1114 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1115 | int ret = -EIO; |
| 1116 | u8 buf[8] = { GTP_REG_VERSION >> 8, GTP_REG_VERSION & 0xff }; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1117 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1118 | GTP_DEBUG_FUNC(); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1119 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1120 | ret = gtp_i2c_read(client, buf, sizeof(buf)); |
| 1121 | if (ret < 0) { |
| 1122 | dev_err(&client->dev, "GTP read version failed.\n"); |
| 1123 | return ret; |
| 1124 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1125 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1126 | if (version) |
| 1127 | *version = (buf[7] << 8) | buf[6]; |
| 1128 | |
| 1129 | if (buf[5] == 0x00) { |
| 1130 | dev_dbg(&client->dev, "IC Version: %c%c%c_%02x%02x\n", buf[2], |
| 1131 | buf[3], buf[4], buf[7], buf[6]); |
| 1132 | } else { |
| 1133 | if (buf[5] == 'S' || buf[5] == 's') |
| 1134 | chip_gt9xxs = 1; |
| 1135 | dev_dbg(&client->dev, "IC Version: %c%c%c%c_%02x%02x\n", buf[2], |
| 1136 | buf[3], buf[4], buf[5], buf[7], buf[6]); |
| 1137 | } |
| 1138 | return ret; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1139 | } |
| 1140 | |
| 1141 | /******************************************************* |
| 1142 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1143 | I2c test Function. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1144 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1145 | client:i2c client. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1146 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1147 | Executive outcomes. |
| 1148 | 2: succeed, otherwise failed. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1149 | *******************************************************/ |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1150 | static int gtp_i2c_test(struct i2c_client *client) |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1151 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1152 | u8 buf[3] = { GTP_REG_CONFIG_DATA >> 8, GTP_REG_CONFIG_DATA & 0xff }; |
| 1153 | int retry = 5; |
| 1154 | int ret = -EIO; |
| 1155 | |
| 1156 | GTP_DEBUG_FUNC(); |
| 1157 | |
| 1158 | while (retry--) { |
| 1159 | ret = gtp_i2c_read(client, buf, 3); |
| 1160 | if (ret > 0) |
| 1161 | return ret; |
| 1162 | dev_err(&client->dev, "GTP i2c test failed time %d.\n", retry); |
| 1163 | msleep(20); |
| 1164 | } |
| 1165 | return ret; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1166 | } |
| 1167 | |
| 1168 | /******************************************************* |
| 1169 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1170 | Request gpio(INT & RST) ports. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1171 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1172 | ts: private data. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1173 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1174 | Executive outcomes. |
| 1175 | = 0: succeed, != 0: failed |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1176 | *******************************************************/ |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1177 | static int gtp_request_io_port(struct goodix_ts_data *ts) |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1178 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1179 | struct i2c_client *client = ts->client; |
| 1180 | struct goodix_ts_platform_data *pdata = ts->pdata; |
| 1181 | int ret; |
| 1182 | if (gpio_is_valid(pdata->irq_gpio)) { |
| 1183 | ret = gpio_request(pdata->irq_gpio, "goodix_ts_irq_gpio"); |
| 1184 | if (ret) { |
| 1185 | dev_err(&client->dev, "irq gpio request failed\n"); |
| 1186 | goto pwr_off; |
| 1187 | } |
| 1188 | ret = gpio_direction_input(pdata->irq_gpio); |
| 1189 | if (ret) { |
| 1190 | dev_err(&client->dev, |
| 1191 | "set_direction for irq gpio failed\n"); |
| 1192 | goto free_irq_gpio; |
| 1193 | } |
| 1194 | } else { |
| 1195 | dev_err(&client->dev, "irq gpio is invalid!\n"); |
| 1196 | ret = -EINVAL; |
| 1197 | goto free_irq_gpio; |
| 1198 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1199 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1200 | if (gpio_is_valid(pdata->reset_gpio)) { |
| 1201 | ret = gpio_request(pdata->reset_gpio, "goodix_ts__reset_gpio"); |
| 1202 | if (ret) { |
| 1203 | dev_err(&client->dev, "reset gpio request failed\n"); |
| 1204 | goto free_irq_gpio; |
| 1205 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1206 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1207 | ret = gpio_direction_output(pdata->reset_gpio, 0); |
| 1208 | if (ret) { |
| 1209 | dev_err(&client->dev, |
| 1210 | "set_direction for reset gpio failed\n"); |
| 1211 | goto free_reset_gpio; |
| 1212 | } |
| 1213 | } else { |
| 1214 | dev_err(&client->dev, "reset gpio is invalid!\n"); |
| 1215 | ret = -EINVAL; |
| 1216 | goto free_reset_gpio; |
| 1217 | } |
| 1218 | gpio_direction_input(pdata->reset_gpio); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1219 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1220 | return ret; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1221 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1222 | free_reset_gpio: |
| 1223 | if (gpio_is_valid(pdata->reset_gpio)) |
| 1224 | gpio_free(pdata->reset_gpio); |
| 1225 | free_irq_gpio: |
| 1226 | if (gpio_is_valid(pdata->irq_gpio)) |
| 1227 | gpio_free(pdata->irq_gpio); |
| 1228 | pwr_off: |
| 1229 | return ret; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1230 | } |
| 1231 | |
| 1232 | /******************************************************* |
| 1233 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1234 | Request interrupt. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1235 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1236 | ts: private data. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1237 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1238 | Executive outcomes. |
| 1239 | 0: succeed, -1: failed. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1240 | *******************************************************/ |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1241 | static int gtp_request_irq(struct goodix_ts_data *ts) |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1242 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1243 | int ret; |
| 1244 | const u8 irq_table[] = GTP_IRQ_TAB; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1245 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1246 | GTP_DEBUG("INT trigger type:%x, irq=%d", ts->int_trigger_type, |
| 1247 | ts->client->irq); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1248 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1249 | ret = request_irq(ts->client->irq, goodix_ts_irq_handler, |
| 1250 | irq_table[ts->int_trigger_type], |
| 1251 | ts->client->name, ts); |
| 1252 | if (ret) { |
| 1253 | dev_err(&ts->client->dev, "Request IRQ failed!ERRNO:%d.\n", |
| 1254 | ret); |
| 1255 | gpio_direction_input(ts->pdata->irq_gpio); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1256 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1257 | hrtimer_init(&ts->timer, CLOCK_MONOTONIC, |
| 1258 | HRTIMER_MODE_REL); |
| 1259 | ts->timer.function = goodix_ts_timer_handler; |
| 1260 | hrtimer_start(&ts->timer, ktime_set(1, 0), |
| 1261 | HRTIMER_MODE_REL); |
| 1262 | ts->use_irq = false; |
| 1263 | return ret; |
| 1264 | } else { |
| 1265 | gtp_irq_disable(ts); |
| 1266 | ts->use_irq = true; |
| 1267 | return 0; |
| 1268 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1269 | } |
| 1270 | |
| 1271 | /******************************************************* |
| 1272 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1273 | Request input device Function. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1274 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1275 | ts:private data. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1276 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1277 | Executive outcomes. |
| 1278 | 0: succeed, otherwise: failed. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1279 | *******************************************************/ |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1280 | static int gtp_request_input_dev(struct goodix_ts_data *ts) |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1281 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1282 | int ret; |
| 1283 | char phys[PHY_BUF_SIZE]; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1284 | #if GTP_HAVE_TOUCH_KEY |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1285 | int index = 0; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1286 | #endif |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1287 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1288 | GTP_DEBUG_FUNC(); |
| 1289 | |
| 1290 | ts->input_dev = input_allocate_device(); |
| 1291 | if (ts->input_dev == NULL) { |
| 1292 | dev_err(&ts->client->dev, |
| 1293 | "Failed to allocate input device.\n"); |
| 1294 | return -ENOMEM; |
| 1295 | } |
| 1296 | |
| 1297 | ts->input_dev->evbit[0] = |
| 1298 | BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) ; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1299 | #if GTP_ICS_SLOT_REPORT |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1300 | __set_bit(INPUT_PROP_DIRECT, ts->input_dev->propbit); |
| 1301 | input_mt_init_slots(ts->input_dev, 10);/* in case of "out of memory" */ |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1302 | #else |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1303 | ts->input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1304 | #endif |
| 1305 | |
| 1306 | #if GTP_HAVE_TOUCH_KEY |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1307 | for (index = 0; index < GTP_MAX_KEY_NUM; index++) { |
| 1308 | input_set_capability(ts->input_dev, |
| 1309 | EV_KEY, touch_key_array[index]); |
| 1310 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1311 | #endif |
| 1312 | |
| 1313 | #if GTP_SLIDE_WAKEUP |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1314 | input_set_capability(ts->input_dev, EV_KEY, KEY_POWER); |
| 1315 | #endif |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1316 | |
| 1317 | #if GTP_WITH_PEN |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1318 | /* pen support */ |
| 1319 | __set_bit(BTN_TOOL_PEN, ts->input_dev->keybit); |
| 1320 | __set_bit(INPUT_PROP_DIRECT, ts->input_dev->propbit); |
| 1321 | __set_bit(INPUT_PROP_POINTER, ts->input_dev->propbit); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1322 | #endif |
| 1323 | |
| 1324 | #if GTP_CHANGE_X2Y |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1325 | GTP_SWAP(ts->abs_x_max, ts->abs_y_max); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1326 | #endif |
| 1327 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1328 | input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, |
| 1329 | 0, ts->abs_x_max, 0, 0); |
| 1330 | input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, |
| 1331 | 0, ts->abs_y_max, 0, 0); |
| 1332 | input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, |
| 1333 | 0, 255, 0, 0); |
| 1334 | input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, |
| 1335 | 0, 255, 0, 0); |
| 1336 | input_set_abs_params(ts->input_dev, ABS_MT_TRACKING_ID, |
| 1337 | 0, 255, 0, 0); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1338 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1339 | snprintf(phys, PHY_BUF_SIZE, "input/ts"); |
| 1340 | ts->input_dev->name = GOODIX_DEV_NAME; |
| 1341 | ts->input_dev->phys = phys; |
| 1342 | ts->input_dev->id.bustype = BUS_I2C; |
| 1343 | ts->input_dev->id.vendor = 0xDEAD; |
| 1344 | ts->input_dev->id.product = 0xBEEF; |
| 1345 | ts->input_dev->id.version = 10427; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1346 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1347 | ret = input_register_device(ts->input_dev); |
| 1348 | if (ret) { |
| 1349 | dev_err(&ts->client->dev, |
| 1350 | "Register %s input device failed.\n", |
| 1351 | ts->input_dev->name); |
| 1352 | goto exit_free_inputdev; |
| 1353 | } |
| 1354 | |
| 1355 | return 0; |
| 1356 | |
| 1357 | exit_free_inputdev: |
| 1358 | input_free_device(ts->input_dev); |
| 1359 | ts->input_dev = NULL; |
| 1360 | return ret; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1361 | } |
| 1362 | |
Bingzhe Cai | d036117 | 2013-07-18 19:22:11 +0800 | [diff] [blame^] | 1363 | static int goodix_ts_get_dt_coords(struct device *dev, char *name, |
| 1364 | struct goodix_ts_platform_data *pdata) |
| 1365 | { |
| 1366 | struct property *prop; |
| 1367 | struct device_node *np = dev->of_node; |
| 1368 | int rc; |
| 1369 | u32 coords[GOODIX_COORDS_ARR_SIZE]; |
| 1370 | |
| 1371 | prop = of_find_property(np, name, NULL); |
| 1372 | if (!prop) |
| 1373 | return -EINVAL; |
| 1374 | if (!prop->value) |
| 1375 | return -ENODATA; |
| 1376 | |
| 1377 | rc = of_property_read_u32_array(np, name, coords, |
| 1378 | GOODIX_COORDS_ARR_SIZE); |
| 1379 | if (rc && (rc != -EINVAL)) { |
| 1380 | dev_err(dev, "Unable to read %s\n", name); |
| 1381 | return rc; |
| 1382 | } |
| 1383 | |
| 1384 | if (!strcmp(name, "goodix,panel-coords")) { |
| 1385 | pdata->panel_minx = coords[0]; |
| 1386 | pdata->panel_miny = coords[1]; |
| 1387 | pdata->panel_maxx = coords[2]; |
| 1388 | pdata->panel_maxy = coords[3]; |
| 1389 | } else if (!strcmp(name, "goodix,display-coords")) { |
| 1390 | pdata->x_min = coords[0]; |
| 1391 | pdata->y_min = coords[1]; |
| 1392 | pdata->x_max = coords[2]; |
| 1393 | pdata->y_max = coords[3]; |
| 1394 | } else { |
| 1395 | dev_err(dev, "unsupported property %s\n", name); |
| 1396 | return -EINVAL; |
| 1397 | } |
| 1398 | |
| 1399 | return 0; |
| 1400 | } |
| 1401 | |
| 1402 | static int goodix_parse_dt(struct device *dev, |
| 1403 | struct goodix_ts_platform_data *pdata) |
| 1404 | { |
| 1405 | int rc; |
| 1406 | struct device_node *np = dev->of_node; |
| 1407 | struct property *prop; |
| 1408 | u32 temp_val, num_buttons; |
| 1409 | u32 button_map[MAX_BUTTONS]; |
| 1410 | |
| 1411 | rc = goodix_ts_get_dt_coords(dev, "goodix,panel-coords", pdata); |
| 1412 | if (rc && (rc != -EINVAL)) |
| 1413 | return rc; |
| 1414 | |
| 1415 | rc = goodix_ts_get_dt_coords(dev, "goodix,display-coords", pdata); |
| 1416 | if (rc) |
| 1417 | return rc; |
| 1418 | |
| 1419 | pdata->i2c_pull_up = of_property_read_bool(np, |
| 1420 | "goodix,i2c-pull-up"); |
| 1421 | |
| 1422 | pdata->no_force_update = of_property_read_bool(np, |
| 1423 | "goodix,no-force-update"); |
| 1424 | /* reset, irq gpio info */ |
| 1425 | pdata->reset_gpio = of_get_named_gpio_flags(np, "reset-gpios", |
| 1426 | 0, &pdata->reset_gpio_flags); |
| 1427 | if (pdata->reset_gpio < 0) |
| 1428 | return pdata->reset_gpio; |
| 1429 | |
| 1430 | pdata->irq_gpio = of_get_named_gpio_flags(np, "interrupt-gpios", |
| 1431 | 0, &pdata->irq_gpio_flags); |
| 1432 | if (pdata->irq_gpio < 0) |
| 1433 | return pdata->irq_gpio; |
| 1434 | |
| 1435 | rc = of_property_read_u32(np, "goodix,family-id", &temp_val); |
| 1436 | if (!rc) |
| 1437 | pdata->family_id = temp_val; |
| 1438 | else |
| 1439 | return rc; |
| 1440 | |
| 1441 | prop = of_find_property(np, "goodix,button-map", NULL); |
| 1442 | if (prop) { |
| 1443 | num_buttons = prop->length / sizeof(temp_val); |
| 1444 | if (num_buttons > MAX_BUTTONS) |
| 1445 | return -EINVAL; |
| 1446 | |
| 1447 | rc = of_property_read_u32_array(np, |
| 1448 | "goodix,button-map", button_map, |
| 1449 | num_buttons); |
| 1450 | if (rc) { |
| 1451 | dev_err(dev, "Unable to read key codes\n"); |
| 1452 | return rc; |
| 1453 | } |
| 1454 | } |
| 1455 | |
| 1456 | prop = of_find_property(np, "goodix,cfg-data", &pdata->gtp_cfg_len); |
| 1457 | if (prop && prop->value) { |
| 1458 | pdata->config_data = devm_kzalloc(dev, |
| 1459 | GTP_CONFIG_MAX_LENGTH + GTP_ADDR_LENGTH, GFP_KERNEL); |
| 1460 | if (!pdata->config_data) { |
| 1461 | dev_err(dev, "Not enough memory for panel config data\n"); |
| 1462 | return -ENOMEM; |
| 1463 | } |
| 1464 | |
| 1465 | pdata->config_data[0] = GTP_REG_CONFIG_DATA >> 8; |
| 1466 | pdata->config_data[1] = GTP_REG_CONFIG_DATA & 0xff; |
| 1467 | memset(&pdata->config_data[GTP_ADDR_LENGTH], 0, |
| 1468 | GTP_CONFIG_MAX_LENGTH); |
| 1469 | memcpy(&pdata->config_data[GTP_ADDR_LENGTH], |
| 1470 | prop->value, pdata->gtp_cfg_len); |
| 1471 | } else { |
| 1472 | dev_err(dev, |
| 1473 | "Unable to get configure data, default will be used.\n"); |
| 1474 | pdata->gtp_cfg_len = 0; |
| 1475 | } |
| 1476 | |
| 1477 | return 0; |
| 1478 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1479 | /******************************************************* |
| 1480 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1481 | I2c probe. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1482 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1483 | client: i2c device struct. |
| 1484 | id: device id. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1485 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1486 | Executive outcomes. |
| 1487 | 0: succeed. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1488 | *******************************************************/ |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1489 | |
| 1490 | static int goodix_ts_probe(struct i2c_client *client, |
| 1491 | const struct i2c_device_id *id) |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1492 | { |
Bingzhe Cai | d036117 | 2013-07-18 19:22:11 +0800 | [diff] [blame^] | 1493 | struct goodix_ts_platform_data *pdata; |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1494 | struct goodix_ts_data *ts; |
| 1495 | u16 version_info; |
| 1496 | int ret; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1497 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1498 | dev_dbg(&client->dev, "GTP I2C Address: 0x%02x\n", client->addr); |
Bingzhe Cai | d036117 | 2013-07-18 19:22:11 +0800 | [diff] [blame^] | 1499 | if (client->dev.of_node) { |
| 1500 | pdata = devm_kzalloc(&client->dev, |
| 1501 | sizeof(struct goodix_ts_platform_data), GFP_KERNEL); |
| 1502 | if (!pdata) { |
| 1503 | dev_err(&client->dev, |
| 1504 | "GTP Failed to allocate memory for pdata\n"); |
| 1505 | return -ENOMEM; |
| 1506 | } |
| 1507 | |
| 1508 | ret = goodix_parse_dt(&client->dev, pdata); |
| 1509 | if (ret) |
| 1510 | return ret; |
| 1511 | } else { |
| 1512 | pdata = client->dev.platform_data; |
| 1513 | } |
| 1514 | |
| 1515 | if (!pdata) { |
| 1516 | dev_err(&client->dev, "GTP invalid pdata\n"); |
| 1517 | return -EINVAL; |
| 1518 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1519 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1520 | #if GTP_ESD_PROTECT |
| 1521 | i2c_connect_client = client; |
| 1522 | #endif |
Bingzhe Cai | d036117 | 2013-07-18 19:22:11 +0800 | [diff] [blame^] | 1523 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1524 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { |
| 1525 | dev_err(&client->dev, "GTP I2C not supported\n"); |
| 1526 | return -ENODEV; |
| 1527 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1528 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1529 | ts = kzalloc(sizeof(*ts), GFP_KERNEL); |
| 1530 | if (!ts) { |
| 1531 | dev_err(&client->dev, "GTP not enough memory for ts\n"); |
| 1532 | return -ENOMEM; |
| 1533 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1534 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1535 | memset(ts, 0, sizeof(*ts)); |
| 1536 | ts->client = client; |
Bingzhe Cai | d036117 | 2013-07-18 19:22:11 +0800 | [diff] [blame^] | 1537 | ts->pdata = pdata; |
| 1538 | /* For 2.6.39 & later use spin_lock_init(&ts->irq_lock) |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1539 | * For 2.6.39 & before, use ts->irq_lock = SPIN_LOCK_UNLOCKED |
| 1540 | */ |
| 1541 | spin_lock_init(&ts->irq_lock); |
| 1542 | i2c_set_clientdata(client, ts); |
| 1543 | |
| 1544 | ts->gtp_rawdiff_mode = 0; |
| 1545 | |
| 1546 | ret = gtp_request_io_port(ts); |
| 1547 | if (ret) { |
| 1548 | dev_err(&client->dev, "GTP request IO port failed.\n"); |
| 1549 | goto exit_power_off; |
| 1550 | } |
| 1551 | |
| 1552 | gtp_reset_guitar(ts, 20); |
| 1553 | |
| 1554 | ret = gtp_i2c_test(client); |
| 1555 | if (ret != 2) { |
| 1556 | dev_err(&client->dev, "I2C communication ERROR!\n"); |
| 1557 | goto exit_free_io_port; |
| 1558 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1559 | |
| 1560 | #if GTP_AUTO_UPDATE |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1561 | ret = gup_init_update_proc(ts); |
| 1562 | if (ret < 0) { |
| 1563 | dev_err(&client->dev, |
| 1564 | "GTP Create firmware update thread error.\n"); |
| 1565 | goto exit_free_io_port; |
| 1566 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1567 | #endif |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1568 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1569 | ret = gtp_init_panel(ts); |
| 1570 | if (ret < 0) { |
| 1571 | dev_err(&client->dev, "GTP init panel failed.\n"); |
| 1572 | ts->abs_x_max = GTP_MAX_WIDTH; |
| 1573 | ts->abs_y_max = GTP_MAX_HEIGHT; |
| 1574 | ts->int_trigger_type = GTP_INT_TRIGGER; |
| 1575 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1576 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1577 | ret = gtp_request_input_dev(ts); |
| 1578 | if (ret) { |
| 1579 | dev_err(&client->dev, "GTP request input dev failed.\n"); |
| 1580 | goto exit_free_inputdev; |
| 1581 | } |
| 1582 | |
| 1583 | ts->goodix_wq = create_singlethread_workqueue("goodix_wq"); |
| 1584 | INIT_WORK(&ts->work, goodix_ts_work_func); |
| 1585 | |
| 1586 | ret = gtp_request_irq(ts); |
| 1587 | if (ret < 0) |
| 1588 | dev_info(&client->dev, "GTP works in polling mode.\n"); |
| 1589 | else |
| 1590 | dev_info(&client->dev, "GTP works in interrupt mode.\n"); |
| 1591 | |
| 1592 | ret = gtp_read_version(client, &version_info); |
| 1593 | if (ret != 2) { |
| 1594 | dev_err(&client->dev, "Read version failed.\n"); |
| 1595 | goto exit_free_irq; |
| 1596 | } |
| 1597 | if (ts->use_irq) |
| 1598 | gtp_irq_enable(ts); |
| 1599 | |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1600 | #if GTP_CREATE_WR_NODE |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1601 | init_wr_node(client); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1602 | #endif |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1603 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1604 | #if GTP_ESD_PROTECT |
| 1605 | gtp_esd_switch(client, SWITCH_ON); |
| 1606 | #endif |
| 1607 | init_done = true; |
| 1608 | return 0; |
| 1609 | exit_free_irq: |
| 1610 | if (ts->use_irq) |
| 1611 | free_irq(client->irq, ts); |
| 1612 | else |
| 1613 | hrtimer_cancel(&ts->timer); |
| 1614 | cancel_work_sync(&ts->work); |
| 1615 | flush_workqueue(ts->goodix_wq); |
| 1616 | destroy_workqueue(ts->goodix_wq); |
| 1617 | |
| 1618 | input_unregister_device(ts->input_dev); |
| 1619 | if (ts->input_dev) { |
| 1620 | input_free_device(ts->input_dev); |
| 1621 | ts->input_dev = NULL; |
| 1622 | } |
| 1623 | exit_free_inputdev: |
| 1624 | kfree(ts->config_data); |
| 1625 | exit_free_io_port: |
Bingzhe Cai | d036117 | 2013-07-18 19:22:11 +0800 | [diff] [blame^] | 1626 | if (gpio_is_valid(pdata->reset_gpio)) |
| 1627 | gpio_free(pdata->reset_gpio); |
| 1628 | if (gpio_is_valid(pdata->irq_gpio)) |
| 1629 | gpio_free(pdata->irq_gpio); |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1630 | exit_power_off: |
| 1631 | i2c_set_clientdata(client, NULL); |
| 1632 | kfree(ts); |
| 1633 | return ret; |
| 1634 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1635 | |
| 1636 | /******************************************************* |
| 1637 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1638 | Goodix touchscreen driver release function. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1639 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1640 | client: i2c device struct. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1641 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1642 | Executive outcomes. 0---succeed. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1643 | *******************************************************/ |
| 1644 | static int goodix_ts_remove(struct i2c_client *client) |
| 1645 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1646 | struct goodix_ts_data *ts = i2c_get_clientdata(client); |
| 1647 | |
| 1648 | GTP_DEBUG_FUNC(); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1649 | #ifdef CONFIG_HAS_EARLYSUSPEND |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1650 | unregister_early_suspend(&ts->early_suspend); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1651 | #endif |
| 1652 | |
| 1653 | #if GTP_CREATE_WR_NODE |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1654 | uninit_wr_node(); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1655 | #endif |
| 1656 | |
| 1657 | #if GTP_ESD_PROTECT |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1658 | cancel_work_sync(gtp_esd_check_workqueue); |
| 1659 | flush_workqueue(gtp_esd_check_workqueue); |
| 1660 | destroy_workqueue(gtp_esd_check_workqueue); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1661 | #endif |
| 1662 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1663 | if (ts) { |
| 1664 | if (ts->use_irq) |
| 1665 | free_irq(client->irq, ts); |
| 1666 | else |
| 1667 | hrtimer_cancel(&ts->timer); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1668 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1669 | cancel_work_sync(&ts->work); |
| 1670 | flush_workqueue(ts->goodix_wq); |
| 1671 | destroy_workqueue(ts->goodix_wq); |
| 1672 | |
| 1673 | input_unregister_device(ts->input_dev); |
| 1674 | if (ts->input_dev) { |
| 1675 | input_free_device(ts->input_dev); |
| 1676 | ts->input_dev = NULL; |
| 1677 | } |
| 1678 | kfree(ts->config_data); |
| 1679 | |
| 1680 | if (gpio_is_valid(ts->pdata->reset_gpio)) |
| 1681 | gpio_free(ts->pdata->reset_gpio); |
| 1682 | if (gpio_is_valid(ts->pdata->irq_gpio)) |
| 1683 | gpio_free(ts->pdata->irq_gpio); |
| 1684 | |
| 1685 | i2c_set_clientdata(client, NULL); |
| 1686 | kfree(ts); |
| 1687 | } |
| 1688 | |
| 1689 | return 0; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1690 | } |
| 1691 | |
| 1692 | #ifdef CONFIG_HAS_EARLYSUSPEND |
| 1693 | /******************************************************* |
| 1694 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1695 | Early suspend function. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1696 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1697 | h: early_suspend struct. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1698 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1699 | None. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1700 | *******************************************************/ |
| 1701 | static void goodix_ts_early_suspend(struct early_suspend *h) |
| 1702 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1703 | struct goodix_ts_data *ts; |
| 1704 | s8 ret = -1; |
| 1705 | ts = container_of(h, struct goodix_ts_data, early_suspend); |
| 1706 | |
| 1707 | GTP_DEBUG_FUNC(); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1708 | |
| 1709 | #if GTP_ESD_PROTECT |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1710 | ts->gtp_is_suspend = 1; |
| 1711 | gtp_esd_switch(ts->client, SWITCH_OFF); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1712 | #endif |
| 1713 | |
| 1714 | #if GTP_SLIDE_WAKEUP |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1715 | ret = gtp_enter_doze(ts); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1716 | #else |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1717 | if (ts->use_irq) |
| 1718 | gtp_irq_disable(ts); |
| 1719 | else |
| 1720 | hrtimer_cancel(&ts->timer); |
| 1721 | ret = gtp_enter_sleep(ts); |
| 1722 | #endif |
| 1723 | if (ret < 0) |
| 1724 | dev_err(&ts->client->dev, "GTP early suspend failed.\n"); |
| 1725 | /* to avoid waking up while not sleeping, |
| 1726 | * delay 48 + 10ms to ensure reliability |
| 1727 | */ |
| 1728 | msleep(58); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1729 | } |
| 1730 | |
| 1731 | /******************************************************* |
| 1732 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1733 | Late resume function. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1734 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1735 | h: early_suspend struct. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1736 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1737 | None. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1738 | *******************************************************/ |
| 1739 | static void goodix_ts_late_resume(struct early_suspend *h) |
| 1740 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1741 | struct goodix_ts_data *ts; |
| 1742 | s8 ret = -1; |
| 1743 | ts = container_of(h, struct goodix_ts_data, early_suspend); |
| 1744 | |
| 1745 | GTP_DEBUG_FUNC(); |
| 1746 | |
| 1747 | ret = gtp_wakeup_sleep(ts); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1748 | |
| 1749 | #if GTP_SLIDE_WAKEUP |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1750 | doze_status = DOZE_DISABLED; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1751 | #endif |
| 1752 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1753 | if (ret < 0) |
| 1754 | dev_err(&ts->client->dev, "GTP later resume failed.\n"); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1755 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1756 | if (ts->use_irq) |
| 1757 | gtp_irq_enable(ts); |
| 1758 | else |
| 1759 | hrtimer_start(&ts->timer, |
| 1760 | ktime_set(1, 0), HRTIMER_MODE_REL); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1761 | |
| 1762 | #if GTP_ESD_PROTECT |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1763 | ts->gtp_is_suspend = 0; |
| 1764 | gtp_esd_switch(ts->client, SWITCH_ON); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1765 | #endif |
| 1766 | } |
| 1767 | #endif |
| 1768 | |
| 1769 | #if GTP_ESD_PROTECT |
| 1770 | /******************************************************* |
| 1771 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1772 | switch on & off esd delayed work |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1773 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1774 | client: i2c device |
| 1775 | on: SWITCH_ON / SWITCH_OFF |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1776 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1777 | void |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1778 | *********************************************************/ |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1779 | void gtp_esd_switch(struct i2c_client *client, int on) |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1780 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1781 | struct goodix_ts_data *ts; |
| 1782 | |
| 1783 | ts = i2c_get_clientdata(client); |
| 1784 | if (SWITCH_ON == on) { |
| 1785 | /* switch on esd */ |
| 1786 | if (!ts->esd_running) { |
| 1787 | ts->esd_running = 1; |
| 1788 | dev_dbg(&client->dev, "Esd started\n"); |
| 1789 | queue_delayed_work(gtp_esd_check_workqueue, |
| 1790 | >p_esd_check_work, GTP_ESD_CHECK_CIRCLE); |
| 1791 | } |
| 1792 | } else { |
| 1793 | /* switch off esd */ |
| 1794 | if (ts->esd_running) { |
| 1795 | ts->esd_running = 0; |
| 1796 | dev_dbg(&client->dev, "Esd cancelled\n"); |
| 1797 | cancel_delayed_work_sync(>p_esd_check_work); |
| 1798 | } |
| 1799 | } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1800 | } |
| 1801 | |
| 1802 | /******************************************************* |
| 1803 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1804 | Initialize external watchdog for esd protect |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1805 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1806 | client: i2c device. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1807 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1808 | result of i2c write operation. |
| 1809 | 1: succeed, otherwise: failed |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1810 | *********************************************************/ |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1811 | static int gtp_init_ext_watchdog(struct i2c_client *client) |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1812 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1813 | /* in case of recursively reset by calling gtp_i2c_write*/ |
| 1814 | struct i2c_msg msg; |
| 1815 | u8 opr_buffer[4] = {0x80, 0x40, 0xAA, 0xAA}; |
| 1816 | int ret; |
| 1817 | int retries = 0; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1818 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1819 | GTP_DEBUG("Init external watchdog..."); |
| 1820 | GTP_DEBUG_FUNC(); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1821 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1822 | msg.flags = !I2C_M_RD; |
| 1823 | msg.addr = client->addr; |
| 1824 | msg.len = 4; |
| 1825 | msg.buf = opr_buffer; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1826 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1827 | while (retries < 5) { |
| 1828 | ret = i2c_transfer(client->adapter, &msg, 1); |
| 1829 | if (ret == 1) |
| 1830 | return 1; |
| 1831 | retries++; |
| 1832 | } |
| 1833 | if (retries >= 5) |
| 1834 | dev_err(&client->dev, "init external watchdog failed!"); |
| 1835 | return 0; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1836 | } |
| 1837 | |
| 1838 | /******************************************************* |
| 1839 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1840 | Esd protect function. |
| 1841 | Added external watchdog by meta, 2013/03/07 |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1842 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1843 | work: delayed work |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1844 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1845 | None. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1846 | *******************************************************/ |
| 1847 | static void gtp_esd_check_func(struct work_struct *work) |
| 1848 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1849 | s32 i; |
| 1850 | s32 ret = -1; |
| 1851 | struct goodix_ts_data *ts = NULL; |
| 1852 | u8 test[4] = {0x80, 0x40}; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1853 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1854 | GTP_DEBUG_FUNC(); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1855 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1856 | ts = i2c_get_clientdata(i2c_connect_client); |
| 1857 | |
| 1858 | if (ts->gtp_is_suspend) { |
| 1859 | dev_dbg(&ts->client->dev, "Esd terminated!\n"); |
| 1860 | ts->esd_running = 0; |
| 1861 | return; |
| 1862 | } |
| 1863 | #ifdef CONFIG_GT9XX_TOUCHPANEL_UPDATE |
| 1864 | if (ts->enter_update) |
| 1865 | return; |
| 1866 | #endif |
| 1867 | |
| 1868 | for (i = 0; i < 3; i++) { |
| 1869 | ret = gtp_i2c_read(ts->client, test, 4); |
| 1870 | |
| 1871 | GTP_DEBUG("0x8040 = 0x%02X, 0x8041 = 0x%02X", test[2], test[3]); |
| 1872 | if ((ret < 0)) { |
| 1873 | /* IC works abnormally..*/ |
| 1874 | continue; |
| 1875 | } else { |
| 1876 | if ((test[2] == 0xAA) || (test[3] != 0xAA)) { |
| 1877 | /* IC works abnormally..*/ |
| 1878 | i = 3; |
| 1879 | break; |
| 1880 | } else { |
| 1881 | /* IC works normally, Write 0x8040 0xAA*/ |
| 1882 | test[2] = 0xAA; |
| 1883 | gtp_i2c_write(ts->client, test, 3); |
| 1884 | break; |
| 1885 | } |
| 1886 | } |
| 1887 | } |
| 1888 | if (i >= 3) { |
| 1889 | dev_err(&ts->client->dev, |
| 1890 | "IC Working ABNORMALLY, Resetting Guitar...\n"); |
| 1891 | gtp_reset_guitar(ts, 50); |
| 1892 | } |
| 1893 | |
| 1894 | if (!ts->gtp_is_suspend) |
| 1895 | queue_delayed_work(gtp_esd_check_workqueue, |
| 1896 | >p_esd_check_work, GTP_ESD_CHECK_CIRCLE); |
| 1897 | else { |
| 1898 | dev_dbg(&ts->client->dev, "Esd terminated!\n"); |
| 1899 | ts->esd_running = 0; |
| 1900 | } |
| 1901 | |
| 1902 | return; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1903 | } |
| 1904 | #endif |
| 1905 | |
| 1906 | static const struct i2c_device_id goodix_ts_id[] = { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1907 | { GTP_I2C_NAME, 0 }, |
| 1908 | { } |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1909 | }; |
| 1910 | |
Bingzhe Cai | d036117 | 2013-07-18 19:22:11 +0800 | [diff] [blame^] | 1911 | static struct of_device_id goodix_match_table[] = { |
| 1912 | { .compatible = "goodix,gt9xx", }, |
| 1913 | { }, |
| 1914 | }; |
| 1915 | |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1916 | static struct i2c_driver goodix_ts_driver = { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1917 | .probe = goodix_ts_probe, |
| 1918 | .remove = goodix_ts_remove, |
| 1919 | #ifdef CONFIG_HAS_EARLYSUSPEND |
| 1920 | .suspend = goodix_ts_early_suspend, |
| 1921 | .resume = goodix_ts_late_resume, |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1922 | #endif |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1923 | .id_table = goodix_ts_id, |
| 1924 | .driver = { |
| 1925 | .name = GTP_I2C_NAME, |
| 1926 | .owner = THIS_MODULE, |
Bingzhe Cai | d036117 | 2013-07-18 19:22:11 +0800 | [diff] [blame^] | 1927 | .of_match_table = goodix_match_table, |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1928 | }, |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1929 | }; |
| 1930 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1931 | /******************************************************* |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1932 | Function: |
| 1933 | Driver Install function. |
| 1934 | Input: |
| 1935 | None. |
| 1936 | Output: |
| 1937 | Executive Outcomes. 0---succeed. |
| 1938 | ********************************************************/ |
| 1939 | static int __devinit goodix_ts_init(void) |
| 1940 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1941 | int ret; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1942 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1943 | GTP_DEBUG_FUNC(); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1944 | #if GTP_ESD_PROTECT |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1945 | INIT_DELAYED_WORK(>p_esd_check_work, gtp_esd_check_func); |
| 1946 | gtp_esd_check_workqueue = create_workqueue("gtp_esd_check"); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1947 | #endif |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1948 | ret = i2c_add_driver(&goodix_ts_driver); |
| 1949 | return ret; |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1950 | } |
| 1951 | |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1952 | /******************************************************* |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1953 | Function: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1954 | Driver uninstall function. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1955 | Input: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1956 | None. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1957 | Output: |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1958 | Executive Outcomes. 0---succeed. |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1959 | ********************************************************/ |
| 1960 | static void __exit goodix_ts_exit(void) |
| 1961 | { |
Bingzhe Cai | 83caeea | 2013-07-16 17:57:37 +0800 | [diff] [blame] | 1962 | GTP_DEBUG_FUNC(); |
| 1963 | i2c_del_driver(&goodix_ts_driver); |
Andrew Huang | ab45aab | 2013-06-27 10:06:56 +0000 | [diff] [blame] | 1964 | } |
| 1965 | |
| 1966 | late_initcall(goodix_ts_init); |
| 1967 | module_exit(goodix_ts_exit); |
| 1968 | |
| 1969 | MODULE_DESCRIPTION("GTP Series Driver"); |
| 1970 | MODULE_LICENSE("GPL"); |