gt1x_tpd.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206
  1. /* drivers/input/touchscreen/gt1x_tpd.c
  2. *
  3. * 2010 - 2014 Goodix Technology.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be a reference
  11. * to you, when you are integrating the GOODiX's CTP IC into your system,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * Version: 1.0
  17. * Revision Record:
  18. * V1.0: first release. 2014/09/28.
  19. *
  20. */
  21. #include "include/gt1x_tpd_common.h"
  22. #if TPD_SUPPORT_I2C_DMA
  23. #include <linux/dma-mapping.h>
  24. #endif
  25. #ifdef CONFIG_GTP_ICS_SLOT_REPORT
  26. #include <linux/input/mt.h>
  27. #endif
  28. #include <linux/regulator/consumer.h>
  29. #include <linux/of.h>
  30. #include <linux/of_irq.h>
  31. /*1 enable,0 disable,touch_panel_eint default status, need to confirm after register eint*/
  32. int irq_flag = 1;
  33. static spinlock_t irq_flag_lock;
  34. /*0 power off,default, 1 power on*/
  35. static int power_flag;
  36. static int tpd_flag;
  37. int tpd_halt = 0;
  38. static int tpd_eint_mode = 1;
  39. static struct task_struct *thread;
  40. static int tpd_tui_flag;
  41. static int tpd_tui_low_power_skipped;
  42. DEFINE_MUTEX(tui_lock);
  43. static struct task_struct *probe_thread;
  44. static int tpd_polling_time = 50;
  45. static DECLARE_WAIT_QUEUE_HEAD(waiter);
  46. static bool gtp_suspend;
  47. DECLARE_WAIT_QUEUE_HEAD(init_waiter);
  48. DEFINE_MUTEX(i2c_access);
  49. unsigned int touch_irq = 0;
  50. u8 int_type = 0;
  51. #if (defined(TPD_WARP_START) && defined(TPD_WARP_END))
  52. static int tpd_wb_start_local[TPD_WARP_CNT] = TPD_WARP_START;
  53. static int tpd_wb_end_local[TPD_WARP_CNT] = TPD_WARP_END;
  54. #endif
  55. #if (defined(TPD_HAVE_CALIBRATION) && !defined(TPD_CUSTOM_CALIBRATION))
  56. static int tpd_def_calmat_local[8] = TPD_CALIBRATION_MATRIX;
  57. #endif
  58. static int tpd_event_handler(void *unused);
  59. static int tpd_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id);
  60. static int tpd_i2c_detect(struct i2c_client *client, struct i2c_board_info *info);
  61. static int tpd_i2c_remove(struct i2c_client *client);
  62. static irqreturn_t tpd_eint_interrupt_handler(unsigned irq, struct irq_desc *desc);
  63. #define GTP_DRIVER_NAME "gt1x"
  64. static const struct i2c_device_id tpd_i2c_id[] = { {GTP_DRIVER_NAME, 0}, {} };
  65. static unsigned short force[] = { 0, GTP_I2C_ADDRESS, I2C_CLIENT_END, I2C_CLIENT_END };
  66. static const unsigned short *const forces[] = { force, NULL };
  67. static const struct of_device_id tpd_of_match[] = {
  68. {.compatible = "mediatek,cap_touch"},
  69. {},
  70. };
  71. static struct i2c_driver tpd_i2c_driver = {
  72. .probe = tpd_i2c_probe,
  73. .remove = tpd_i2c_remove,
  74. .detect = tpd_i2c_detect,
  75. .driver.name = GTP_DRIVER_NAME,
  76. .driver = {
  77. .name = GTP_DRIVER_NAME,
  78. .of_match_table = tpd_of_match,
  79. },
  80. .id_table = tpd_i2c_id,
  81. .address_list = (const unsigned short *)forces,
  82. };
  83. #if TPD_SUPPORT_I2C_DMA
  84. static u8 *gpDMABuf_va;
  85. static dma_addr_t gpDMABuf_pa;
  86. struct mutex dma_mutex;
  87. DEFINE_MUTEX(dma_mutex);
  88. static s32 i2c_dma_write_mtk(u16 addr, u8 *buffer, s32 len)
  89. {
  90. s32 ret = 0;
  91. s32 pos = 0;
  92. s32 transfer_length;
  93. u16 address = addr;
  94. struct i2c_msg msg = {
  95. .flags = !I2C_M_RD,
  96. .ext_flag = (gt1x_i2c_client->ext_flag | I2C_ENEXT_FLAG | I2C_DMA_FLAG),
  97. .addr = (gt1x_i2c_client->addr & I2C_MASK_FLAG),
  98. .timing = I2C_MASTER_CLOCK,
  99. .buf = (u8 *)(uintptr_t)gpDMABuf_pa,
  100. };
  101. mutex_lock(&dma_mutex);
  102. while (pos != len) {
  103. if (len - pos > (IIC_DMA_MAX_TRANSFER_SIZE - GTP_ADDR_LENGTH))
  104. transfer_length = IIC_DMA_MAX_TRANSFER_SIZE - GTP_ADDR_LENGTH;
  105. else
  106. transfer_length = len - pos;
  107. gpDMABuf_va[0] = (address >> 8) & 0xFF;
  108. gpDMABuf_va[1] = address & 0xFF;
  109. memcpy(&gpDMABuf_va[GTP_ADDR_LENGTH], &buffer[pos], transfer_length);
  110. msg.len = transfer_length + GTP_ADDR_LENGTH;
  111. if (!gtp_suspend) {/*workround log too much*/
  112. ret = i2c_transfer(gt1x_i2c_client->adapter, &msg, 1);
  113. if (ret != 1) {
  114. GTP_INFO("I2c Transfer error! (%d)", ret);
  115. ret = ERROR_IIC;
  116. break;
  117. }
  118. } else {
  119. ret = ERROR_IIC;
  120. break;
  121. }
  122. ret = 0;
  123. pos += transfer_length;
  124. address += transfer_length;
  125. }
  126. mutex_unlock(&dma_mutex);
  127. return ret;
  128. }
  129. static s32 i2c_dma_read_mtk(u16 addr, u8 *buffer, s32 len)
  130. {
  131. s32 ret = ERROR;
  132. s32 pos = 0;
  133. s32 transfer_length;
  134. u16 address = addr;
  135. u8 addr_buf[GTP_ADDR_LENGTH] = { 0 };
  136. struct i2c_msg msgs[2] = {
  137. {
  138. .flags = 0, /*!I2C_M_RD,*/
  139. .addr = (gt1x_i2c_client->addr & I2C_MASK_FLAG),
  140. .timing = I2C_MASTER_CLOCK,
  141. .len = GTP_ADDR_LENGTH,
  142. .buf = addr_buf,
  143. },
  144. {
  145. .flags = I2C_M_RD,
  146. .ext_flag = (gt1x_i2c_client->ext_flag | I2C_ENEXT_FLAG | I2C_DMA_FLAG),
  147. .addr = (gt1x_i2c_client->addr & I2C_MASK_FLAG),
  148. .timing = I2C_MASTER_CLOCK,
  149. .buf = (u8 *)(uintptr_t)gpDMABuf_pa,
  150. },
  151. };
  152. mutex_lock(&dma_mutex);
  153. while (pos != len) {
  154. if (len - pos > IIC_DMA_MAX_TRANSFER_SIZE)
  155. transfer_length = IIC_DMA_MAX_TRANSFER_SIZE;
  156. else
  157. transfer_length = len - pos;
  158. msgs[0].buf[0] = (address >> 8) & 0xFF;
  159. msgs[0].buf[1] = address & 0xFF;
  160. msgs[1].len = transfer_length;
  161. ret = i2c_transfer(gt1x_i2c_client->adapter, msgs, 2);
  162. if (ret != 2) {
  163. GTP_ERROR("I2C Transfer error! (%d)", ret);
  164. ret = ERROR_IIC;
  165. break;
  166. }
  167. ret = 0;
  168. memcpy(&buffer[pos], gpDMABuf_va, transfer_length);
  169. pos += transfer_length;
  170. address += transfer_length;
  171. };
  172. mutex_unlock(&dma_mutex);
  173. return ret;
  174. }
  175. #else
  176. static s32 i2c_write_mtk(u16 addr, u8 *buffer, s32 len)
  177. {
  178. s32 ret;
  179. struct i2c_msg msg = {
  180. .flags = 0,
  181. #ifdef CONFIG_MTK_I2C_EXTENSION
  182. .addr = (gt1x_i2c_client->addr & I2C_MASK_FLAG) | (I2C_ENEXT_FLAG), /*remain*/
  183. .timing = I2C_MASTER_CLOCK,
  184. #else
  185. .addr = gt1x_i2c_client->addr, /*remain*/
  186. #endif
  187. };
  188. ret = _do_i2c_write(&msg, addr, buffer, len);
  189. return ret;
  190. }
  191. static s32 i2c_read_mtk(u16 addr, u8 *buffer, s32 len)
  192. {
  193. int ret;
  194. u8 addr_buf[GTP_ADDR_LENGTH] = { (addr >> 8) & 0xFF, addr & 0xFF };
  195. struct i2c_msg msgs[2] = {
  196. {
  197. #ifdef CONFIG_MTK_I2C_EXTENSION
  198. .addr = ((gt1x_i2c_client->addr & I2C_MASK_FLAG) | (I2C_ENEXT_FLAG)),
  199. .timing = I2C_MASTER_CLOCK,
  200. #else
  201. .addr = gt1x_i2c_client->addr,
  202. #endif
  203. .flags = 0,
  204. .buf = addr_buf,
  205. .len = GTP_ADDR_LENGTH,
  206. },
  207. {
  208. #ifdef CONFIG_MTK_I2C_EXTENSION
  209. .addr = ((gt1x_i2c_client->addr & I2C_MASK_FLAG) | (I2C_ENEXT_FLAG)),
  210. .timing = I2C_MASTER_CLOCK,
  211. #else
  212. .addr = gt1x_i2c_client->addr,
  213. #endif
  214. .flags = I2C_M_RD,
  215. },
  216. };
  217. ret = _do_i2c_read(msgs, addr, buffer, len);
  218. return ret;
  219. }
  220. #endif/* TPD_SUPPORT_I2C_DMA */
  221. /**
  222. * @return: return 0 if success, otherwise return a negative number
  223. * which contains the error code.
  224. */
  225. s32 gt1x_i2c_read(u16 addr, u8 *buffer, s32 len)
  226. {
  227. #if TPD_SUPPORT_I2C_DMA
  228. return i2c_dma_read_mtk(addr, buffer, len);
  229. #else
  230. return i2c_read_mtk(addr, buffer, len);
  231. #endif
  232. }
  233. /**
  234. * @return: return 0 if success, otherwise return a negative number
  235. * which contains the error code.
  236. */
  237. s32 gt1x_i2c_write(u16 addr, u8 *buffer, s32 len)
  238. {
  239. #if TPD_SUPPORT_I2C_DMA
  240. return i2c_dma_write_mtk(addr, buffer, len);
  241. #else
  242. return i2c_write_mtk(addr, buffer, len);
  243. #endif
  244. }
  245. #ifdef TPD_REFRESH_RATE
  246. /*******************************************************
  247. Function:
  248. Write refresh rate
  249. Input:
  250. rate: refresh rate N (Duration=5+N ms, N=0~15)
  251. Output:
  252. Executive outcomes.0---succeed.
  253. *******************************************************/
  254. static u8 gt1x_set_refresh_rate(u8 rate)
  255. {
  256. u8 buf[1] = { rate };
  257. if (rate > 0xf) {
  258. GTP_ERROR("Refresh rate is over range (%d)", rate);
  259. return ERROR_VALUE;
  260. }
  261. GTP_INFO("Refresh rate change to %d", rate);
  262. return gt1x_i2c_write(GTP_REG_REFRESH_RATE, buf, sizeof(buf));
  263. }
  264. /*******************************************************
  265. Function:
  266. Get refresh rate
  267. Output:
  268. Refresh rate or error code
  269. *******************************************************/
  270. static u8 gt1x_get_refresh_rate(void)
  271. {
  272. int ret;
  273. u8 buf[1] = { 0x00 };
  274. ret = gt1x_i2c_read(GTP_REG_REFRESH_RATE, buf, sizeof(buf));
  275. if (ret < 0)
  276. return ret;
  277. GTP_INFO("Refresh rate is %d", buf[0]);
  278. return buf[0];
  279. }
  280. /*=============================================================*/
  281. static ssize_t show_refresh_rate(struct device *dev, struct device_attribute *attr, char *buf)
  282. {
  283. int ret = gt1x_get_refresh_rate();
  284. if (ret < 0)
  285. return 0;
  286. else
  287. return sprintf(buf, "%d\n", ret);
  288. }
  289. static ssize_t store_refresh_rate(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
  290. {
  291. unsigned long rate;
  292. int ret;
  293. ret = kstrtoul(buf, 0, &rate);
  294. gt1x_set_refresh_rate(rate);
  295. return size;
  296. }
  297. static DEVICE_ATTR(tpd_refresh_rate, 0664, show_refresh_rate, store_refresh_rate);
  298. static struct device_attribute *gt9xx_attrs[] = {
  299. &dev_attr_tpd_refresh_rate,
  300. };
  301. #endif
  302. /*=============================================================*/
  303. static int tpd_i2c_detect(struct i2c_client *client, struct i2c_board_info *info)
  304. {
  305. strcpy(info->type, "mtk-tpd");
  306. return 0;
  307. }
  308. static int tpd_power_on(void)
  309. {
  310. gt1x_power_switch(SWITCH_ON);
  311. gt1x_select_addr();
  312. msleep(20);
  313. if (gt1x_get_chip_type() != 0)
  314. return -1;
  315. if (gt1x_reset_guitar() != 0)
  316. return -1;
  317. return 0;
  318. }
  319. void gt1x_irq_enable(void)
  320. {
  321. unsigned long flags;
  322. spin_lock_irqsave(&irq_flag_lock, flags);
  323. if (irq_flag == 0) {
  324. irq_flag = 1;
  325. spin_unlock_irqrestore(&irq_flag_lock, flags);
  326. enable_irq(touch_irq);
  327. } else if (irq_flag == 1) {
  328. spin_unlock_irqrestore(&irq_flag_lock, flags);
  329. GTP_INFO("Touch Eint already enabled!");
  330. } else {
  331. spin_unlock_irqrestore(&irq_flag_lock, flags);
  332. GTP_ERROR("Invalid irq_flag %d!", irq_flag);
  333. }
  334. /*GTP_INFO("Enable irq_flag=%d",irq_flag);*/
  335. }
  336. void gt1x_irq_disable(void)
  337. {
  338. unsigned long flags;
  339. spin_lock_irqsave(&irq_flag_lock, flags);
  340. if (irq_flag == 1) {
  341. irq_flag = 0;
  342. spin_unlock_irqrestore(&irq_flag_lock, flags);
  343. disable_irq(touch_irq);
  344. } else if (irq_flag == 0) {
  345. spin_unlock_irqrestore(&irq_flag_lock, flags);
  346. GTP_INFO("Touch Eint already disabled!");
  347. } else {
  348. spin_unlock_irqrestore(&irq_flag_lock, flags);
  349. GTP_ERROR("Invalid irq_flag %d!", irq_flag);
  350. }
  351. /*GTP_INFO("Disable irq_flag=%d",irq_flag);*/
  352. }
  353. void gt1x_power_switch(s32 state)
  354. {
  355. #if !defined(CONFIG_MTK_LEGACY) || defined(CONFIG_ARCH_MT6580)
  356. int ret = 0;
  357. #endif
  358. GTP_GPIO_OUTPUT(GTP_RST_PORT, 0);
  359. GTP_GPIO_OUTPUT(GTP_INT_PORT, 0);
  360. msleep(20);
  361. switch (state) {
  362. case SWITCH_ON:
  363. if (power_flag == 0) {
  364. GTP_DEBUG("Power switch on!");
  365. #if !defined(CONFIG_MTK_LEGACY)
  366. ret = regulator_enable(tpd->reg); /*enable regulator*/
  367. if (ret)
  368. GTP_ERROR("regulator_enable() failed!\n");
  369. #else
  370. #ifdef TPD_POWER_SOURCE_CUSTOM
  371. #ifdef CONFIG_ARCH_MT6580
  372. ret = regulator_set_voltage(tpd->reg, 2800000, 2800000); /*set 2.8v*/
  373. if (ret)
  374. GTP_DEBUG("regulator_set_voltage() failed!\n");
  375. ret = regulator_enable(tpd->reg); /*enable regulator*/
  376. if (ret)
  377. GTP_DEBUG("regulator_enable() failed!\n");
  378. #else
  379. hwPowerOn(TPD_POWER_SOURCE_CUSTOM, VOL_2800, "TP");
  380. #endif
  381. #endif
  382. #endif
  383. power_flag = 1;
  384. } else {
  385. /*GTP_DEBUG("Power already is on!");*/
  386. }
  387. break;
  388. case SWITCH_OFF:
  389. if (power_flag == 1) {
  390. GTP_DEBUG("Power switch off!");
  391. #if !defined(CONFIG_MTK_LEGACY)
  392. ret = regulator_disable(tpd->reg); /*disable regulator*/
  393. if (ret)
  394. GTP_ERROR("regulator_disable() failed!\n");
  395. #else
  396. #ifdef TPD_POWER_SOURCE_CUSTOM
  397. #ifdef CONFIG_ARCH_MT6580
  398. ret = regulator_disable(tpd->reg); /*disable regulator*/
  399. if (ret)
  400. GTP_DEBUG("regulator_disable() failed!\n");
  401. #else
  402. hwPowerDown(TPD_POWER_SOURCE_CUSTOM, "TP");
  403. #endif
  404. #endif
  405. #endif
  406. power_flag = 0;
  407. } else {
  408. /*GTP_DEBUG("Power already is off!");*/
  409. }
  410. break;
  411. default:
  412. GTP_ERROR("Invalid power switch command!");
  413. break;
  414. }
  415. }
  416. int gt1x_is_tpd_halt(void)
  417. {
  418. return tpd_halt;
  419. }
  420. static int tpd_irq_registration(void)
  421. {
  422. struct device_node *node = NULL;
  423. int ret = 0;
  424. u32 ints[2] = { 0, 0 };
  425. GTP_INFO("Device Tree Tpd_irq_registration!");
  426. node = of_find_matching_node(node, touch_of_match);
  427. if (node) {
  428. of_property_read_u32_array(node, "debounce", ints, ARRAY_SIZE(ints));
  429. gpio_set_debounce(ints[0], ints[1]);
  430. touch_irq = irq_of_parse_and_map(node, 0);
  431. GTP_INFO("Device gt1x_int_type = %d!", gt1x_int_type);
  432. if (!gt1x_int_type) {/*EINTF_TRIGGER*/
  433. ret =
  434. request_irq(touch_irq, (irq_handler_t) tpd_eint_interrupt_handler, IRQF_TRIGGER_RISING,
  435. "TOUCH_PANEL-eint", NULL);
  436. if (ret > 0) {
  437. ret = -1;
  438. GTP_ERROR("tpd request_irq IRQ LINE NOT AVAILABLE!.");
  439. }
  440. } else {
  441. ret =
  442. request_irq(touch_irq, (irq_handler_t) tpd_eint_interrupt_handler, IRQF_TRIGGER_FALLING,
  443. "TOUCH_PANEL-eint", NULL);
  444. if (ret > 0) {
  445. ret = -1;
  446. GTP_ERROR("tpd request_irq IRQ LINE NOT AVAILABLE!.");
  447. }
  448. }
  449. } else {
  450. GTP_ERROR("tpd request_irq can not find touch eint device node!.");
  451. ret = -1;
  452. }
  453. GTP_INFO("[%s]irq:%d, debounce:%d-%d:", __func__, touch_irq, ints[0], ints[1]);
  454. return ret;
  455. }
  456. int tpd_reregister_from_tui(void)
  457. {
  458. int ret = 0;
  459. free_irq(touch_irq, NULL);
  460. ret = tpd_irq_registration();
  461. if (ret < 0) {
  462. ret = -1;
  463. GTP_ERROR("tpd request_irq IRQ LINE NOT AVAILABLE!.");
  464. }
  465. return ret;
  466. }
  467. static int tpd_registration(void *client)
  468. {
  469. s32 err = 0;
  470. s32 idx = 0;
  471. gt1x_i2c_client = client;
  472. if (gt1x_init()) {
  473. /* TP resolution == LCD resolution, no need to match resolution when initialized fail */
  474. gt1x_abs_x_max = 0;
  475. gt1x_abs_y_max = 0;
  476. }
  477. thread = kthread_run(tpd_event_handler, 0, TPD_DEVICE);
  478. if (IS_ERR(thread)) {
  479. err = PTR_ERR(thread);
  480. GTP_INFO(TPD_DEVICE " failed to create kernel thread: %d\n", err);
  481. }
  482. if (tpd_dts_data.use_tpd_button) {
  483. for (idx = 0; idx < tpd_dts_data.tpd_key_num; idx++)
  484. input_set_capability(tpd->dev, EV_KEY, tpd_dts_data.tpd_key_local[idx]);
  485. }
  486. #ifdef CONFIG_GTP_GESTURE_WAKEUP
  487. input_set_capability(tpd->dev, EV_KEY, KEY_GESTURE);
  488. #endif
  489. GTP_GPIO_AS_INT(GTP_INT_PORT);
  490. msleep(50);
  491. /* EINT device tree, default EINT enable */
  492. tpd_irq_registration();
  493. #ifdef CONFIG_GTP_ESD_PROTECT
  494. /* must before auto update */
  495. gt1x_init_esd_protect();
  496. gt1x_esd_switch(SWITCH_ON);
  497. #endif
  498. #ifdef CONFIG_GTP_AUTO_UPDATE
  499. thread = kthread_run(gt1x_auto_update_proc, (void *)NULL, "gt1x_auto_update");
  500. if (IS_ERR(thread)) {
  501. err = PTR_ERR(thread);
  502. GTP_INFO(TPD_DEVICE " failed to create auto-update thread: %d\n", err);
  503. }
  504. #endif
  505. return 0;
  506. }
  507. static s32 tpd_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
  508. {
  509. int err = 0;
  510. /*int count = 0;*/
  511. GTP_INFO("tpd_i2c_probe start.");
  512. #ifdef CONFIG_MTK_BOOT
  513. if (RECOVERY_BOOT == get_boot_mode())
  514. return 0;
  515. #endif
  516. probe_thread = kthread_run(tpd_registration, (void *)client, "tpd_probe");
  517. if (IS_ERR(probe_thread)) {
  518. err = PTR_ERR(probe_thread);
  519. GTP_INFO(TPD_DEVICE " failed to create probe thread: %d\n", err);
  520. return err;
  521. }
  522. GTP_INFO("tpd_i2c_probe start.wait_event_interruptible");
  523. wait_event_interruptible_timeout(init_waiter, check_flag == true, 5 * HZ);
  524. GTP_INFO("tpd_i2c_probe end.wait_event_interruptible");
  525. /*
  526. do {
  527. GTP_INFO("ZH tpd_i2c_probe A count = %d", count);
  528. msleep(20);
  529. GTP_INFO("ZH tpd_i2c_probe B count = %d", count);
  530. count++;
  531. if (check_flag == true)
  532. break;
  533. } while (count < 300);
  534. GTP_INFO("tpd_i2c_probe done.count = %d, flag = %d", count, tpd_load_status);
  535. */
  536. return 0;
  537. }
  538. static irqreturn_t tpd_eint_interrupt_handler(unsigned irq, struct irq_desc *desc)
  539. {
  540. unsigned long flags;
  541. TPD_DEBUG_PRINT_INT;
  542. tpd_flag = 1;
  543. spin_lock_irqsave(&irq_flag_lock, flags);
  544. if (irq_flag == 0) {
  545. spin_unlock_irqrestore(&irq_flag_lock, flags);
  546. return IRQ_HANDLED;
  547. }
  548. /* enter EINT handler disable INT, make sure INT is disable when handle touch event including top/bottom half */
  549. /* use _nosync to avoid deadlock */
  550. irq_flag = 0;
  551. spin_unlock_irqrestore(&irq_flag_lock, flags);
  552. disable_irq_nosync(touch_irq);
  553. /*GTP_INFO("disable irq_flag=%d",irq_flag);*/
  554. wake_up_interruptible(&waiter);
  555. return IRQ_HANDLED;
  556. }
  557. static int tpd_history_x, tpd_history_y;
  558. void gt1x_touch_down(s32 x, s32 y, s32 size, s32 id)
  559. {
  560. #ifdef CONFIG_GTP_CHANGE_X2Y
  561. GTP_SWAP(x, y);
  562. #endif
  563. #ifdef CONFIG_CUSTOM_LCM_X
  564. unsigned long lcm_x = 0, lcm_y = 0;
  565. int ret;
  566. #endif
  567. #ifdef CONFIG_GTP_ICS_SLOT_REPORT
  568. input_mt_slot(tpd->dev, id);
  569. input_report_abs(tpd->dev, ABS_MT_PRESSURE, size);
  570. input_report_abs(tpd->dev, ABS_MT_TOUCH_MAJOR, size);
  571. input_report_abs(tpd->dev, ABS_MT_TRACKING_ID, id);
  572. input_report_abs(tpd->dev, ABS_MT_POSITION_X, x);
  573. input_report_abs(tpd->dev, ABS_MT_POSITION_Y, y);
  574. #else
  575. input_report_key(tpd->dev, BTN_TOUCH, 1);
  576. if ((!size) && (!id)) {
  577. /* for virtual button */
  578. input_report_abs(tpd->dev, ABS_MT_PRESSURE, 100);
  579. input_report_abs(tpd->dev, ABS_MT_TOUCH_MAJOR, 100);
  580. } else {
  581. input_report_abs(tpd->dev, ABS_MT_PRESSURE, size);
  582. input_report_abs(tpd->dev, ABS_MT_TOUCH_MAJOR, size);
  583. input_report_abs(tpd->dev, ABS_MT_TRACKING_ID, id);
  584. }
  585. #ifdef CONFIG_CUSTOM_LCM_X
  586. ret = kstrtoul(CONFIG_CUSTOM_LCM_X, 0, &lcm_x);
  587. if (ret)
  588. GTP_ERROR("Touch down get lcm_x failed");
  589. ret = kstrtoul(CONFIG_CUSTOM_LCM_Y, 0, &lcm_y);
  590. if (ret)
  591. GTP_ERROR("Touch down get lcm_y failed");
  592. if (x < lcm_x)
  593. x = 0;
  594. else
  595. x = x - lcm_x;
  596. if (y < lcm_y)
  597. y = 0;
  598. else
  599. y = y - lcm_y;
  600. GTP_DEBUG("x:%d, y:%d, lcm_x:%lu, lcm_y:%lu", x, y, lcm_x, lcm_y);
  601. #endif
  602. input_report_abs(tpd->dev, ABS_MT_POSITION_X, x);
  603. input_report_abs(tpd->dev, ABS_MT_POSITION_Y, y);
  604. input_mt_sync(tpd->dev);
  605. #endif
  606. TPD_DEBUG_SET_TIME;
  607. TPD_EM_PRINT(x, y, x, y, id, 1);
  608. tpd_history_x = x;
  609. tpd_history_y = y;
  610. #ifdef CONFIG_MTK_BOOT
  611. if (tpd_dts_data.use_tpd_button) {
  612. if (FACTORY_BOOT == get_boot_mode() || RECOVERY_BOOT == get_boot_mode())
  613. tpd_button(x, y, 1);
  614. }
  615. #endif
  616. }
  617. void gt1x_touch_up(s32 id)
  618. {
  619. #ifdef CONFIG_GTP_ICS_SLOT_REPORT
  620. input_mt_slot(tpd->dev, id);
  621. input_report_abs(tpd->dev, ABS_MT_TRACKING_ID, -1);
  622. #else
  623. input_report_key(tpd->dev, BTN_TOUCH, 0);
  624. input_mt_sync(tpd->dev);
  625. #endif
  626. TPD_DEBUG_SET_TIME;
  627. TPD_EM_PRINT(tpd_history_x, tpd_history_y, tpd_history_x, tpd_history_y, id, 0);
  628. tpd_history_x = 0;
  629. tpd_history_y = 0;
  630. #ifdef CONFIG_MTK_BOOT
  631. if (tpd_dts_data.use_tpd_button) {
  632. if (FACTORY_BOOT == get_boot_mode() || RECOVERY_BOOT == get_boot_mode())
  633. tpd_button(0, 0, 0);
  634. }
  635. #endif
  636. }
  637. #ifdef CONFIG_GTP_CHARGER_SWITCH
  638. u32 gt1x_get_charger_status(void)
  639. {
  640. u32 chr_status = 0;
  641. #ifdef MT6573
  642. chr_status = *(volatile u32 *)CHR_CON0;
  643. chr_status &= (1 << 13);
  644. #else /* ( defined(MT6575) || defined(MT6577) || defined(MT6589) ) */
  645. chr_status = upmu_is_chr_det();
  646. #endif
  647. return chr_status;
  648. }
  649. #endif
  650. static int tpd_event_handler(void *unused)
  651. {
  652. u8 finger = 0;
  653. u8 end_cmd = 0;
  654. s32 ret = 0;
  655. u8 point_data[11] = { 0 };
  656. struct sched_param param = {.sched_priority = 4};
  657. sched_setscheduler(current, SCHED_RR, &param);
  658. do {
  659. set_current_state(TASK_INTERRUPTIBLE);
  660. if (tpd_eint_mode) {
  661. wait_event_interruptible(waiter, tpd_flag != 0);
  662. tpd_flag = 0;
  663. } else {
  664. GTP_DEBUG("Polling coordinate mode!");
  665. msleep(tpd_polling_time);
  666. }
  667. set_current_state(TASK_RUNNING);
  668. mutex_lock(&i2c_access);
  669. /* don't reset before "if (tpd_halt..." */
  670. #ifdef CONFIG_GTP_GESTURE_WAKEUP
  671. ret = gesture_event_handler(tpd->dev);
  672. if (ret >= 0) {
  673. gt1x_irq_enable();
  674. mutex_unlock(&i2c_access);
  675. continue;
  676. }
  677. #endif
  678. if (tpd_halt) {
  679. mutex_unlock(&i2c_access);
  680. GTP_DEBUG("return for interrupt after suspend... ");
  681. continue;
  682. }
  683. /* read coordinates */
  684. ret = gt1x_i2c_read(GTP_READ_COOR_ADDR, point_data, sizeof(point_data));
  685. if (ret < 0) {
  686. GTP_ERROR("I2C transfer error!");
  687. #ifndef CONFIG_GTP_ESD_PROTECT
  688. gt1x_power_reset();
  689. #endif
  690. goto exit_work_func;
  691. }
  692. finger = point_data[0];
  693. /* response to a ic request */
  694. if (finger == 0x00)
  695. gt1x_request_event_handler();
  696. if ((finger & 0x80) == 0) {
  697. #ifdef CONFIG_HOTKNOT_BLOCK_RW
  698. if (!hotknot_paired_flag) {
  699. #endif
  700. gt1x_irq_enable();
  701. mutex_unlock(&i2c_access);
  702. continue;
  703. }
  704. #ifdef CONFIG_HOTKNOT_BLOCK_RW
  705. }
  706. ret = hotknot_event_handler(point_data);
  707. if (!ret)
  708. goto exit_work_func;
  709. #endif
  710. #ifdef CONFIG_GTP_PROXIMITY
  711. ret = gt1x_prox_event_handler(point_data);
  712. if (ret > 0)
  713. goto exit_work_func;
  714. #endif
  715. #ifdef CONFIG_GTP_WITH_STYLUS
  716. ret = gt1x_touch_event_handler(point_data, tpd->dev, pen_dev);
  717. #else
  718. ret = gt1x_touch_event_handler(point_data, tpd->dev, NULL);
  719. #endif
  720. if (ret) {
  721. gt1x_irq_enable();
  722. mutex_unlock(&i2c_access);
  723. continue;
  724. }
  725. exit_work_func:
  726. if (!gt1x_rawdiff_mode) {
  727. ret = gt1x_i2c_write(GTP_READ_COOR_ADDR, &end_cmd, 1);
  728. if (ret < 0)
  729. GTP_INFO("I2C write end_cmd error!");
  730. }
  731. gt1x_irq_enable();
  732. mutex_unlock(&i2c_access);
  733. } while (!kthread_should_stop());
  734. return 0;
  735. }
  736. int gt1x_debug_proc(u8 *buf, int count)
  737. {
  738. char mode_str[50] = { 0 };
  739. int mode;
  740. int ret;
  741. ret = sscanf(buf, "%s %d", (char *)&mode_str, &mode);
  742. if (ret < 0) {
  743. GTP_ERROR("gt1x_debug_proc sscanf failed");
  744. return ret;
  745. }
  746. /***********POLLING/EINT MODE switch****************/
  747. if (strcmp(mode_str, "polling") == 0) {
  748. if (mode >= 10 && mode <= 200) {
  749. GTP_INFO("Switch to polling mode, polling time is %d", mode);
  750. tpd_eint_mode = 0;
  751. tpd_polling_time = mode;
  752. tpd_flag = 1;
  753. wake_up_interruptible(&waiter);
  754. } else {
  755. GTP_INFO("Wrong polling time, please set between 10~200ms");
  756. }
  757. return count;
  758. }
  759. if (strcmp(mode_str, "eint") == 0) {
  760. GTP_INFO("Switch to eint mode");
  761. tpd_eint_mode = 1;
  762. return count;
  763. }
  764. /**********************************************/
  765. if (strcmp(mode_str, "switch") == 0) {
  766. if (mode == 0) /*turn off*/
  767. tpd_off();
  768. else if (mode == 1) /*turn on*/
  769. tpd_on();
  770. else
  771. GTP_ERROR("error mode :%d", mode);
  772. return count;
  773. } else if (strcmp(mode_str, "enable_irq") == 0) {
  774. if (mode == 0) {
  775. GTP_ERROR("enable_irq 0, touch_irq = %d, irq_flag = %d",
  776. (int)touch_irq, irq_flag);
  777. disable_irq(touch_irq);
  778. } else if (mode == 1) {
  779. GTP_ERROR("enable_irq 1, touch_irq = %d, irq_flag = %d",
  780. (int)touch_irq, irq_flag);
  781. enable_irq(touch_irq);
  782. } else
  783. GTP_ERROR("error mode :%d", mode);
  784. } else if (strcmp(mode_str, "rerequest_irq") == 0) {
  785. int ret;
  786. GTP_ERROR("rerequest_irq, touch_irq = %d, irq_flag = %d",
  787. (int)touch_irq, irq_flag);
  788. free_irq(touch_irq, NULL);
  789. ret = tpd_irq_registration();
  790. if (ret < 0)
  791. GTP_ERROR("rerequest_irq fail, %d!", ret);
  792. } else if (strcmp(mode_str, "eint_dump_status") == 0) {
  793. GTP_ERROR("eint_dump_status, %u", touch_irq);
  794. /*mt_eint_dump_status(1);*/
  795. }
  796. return -1;
  797. }
  798. static u16 convert_productname(u8 *name)
  799. {
  800. int i;
  801. u16 product = 0;
  802. for (i = 0; i < 4; i++) {
  803. product <<= 4;
  804. if (name[i] < '0' || name[i] > '9')
  805. product += '*';
  806. else
  807. product += name[i] - '0';
  808. }
  809. return product;
  810. }
  811. static int tpd_i2c_remove(struct i2c_client *client)
  812. {
  813. gt1x_deinit();
  814. return 0;
  815. }
  816. static int tpd_local_init(void)
  817. {
  818. #if !defined CONFIG_MTK_LEGACY
  819. int ret;
  820. GTP_INFO("Device Tree get regulator!");
  821. tpd->reg = regulator_get(tpd->tpd_dev, "vtouch");
  822. ret = regulator_set_voltage(tpd->reg, 2800000, 2800000); /*set 2.8v*/
  823. if (ret) {
  824. GTP_ERROR("regulator_set_voltage(%d) failed!\n", ret);
  825. return -1;
  826. }
  827. #endif
  828. #ifdef TPD_POWER_SOURCE_CUSTOM
  829. #ifdef CONFIG_ARCH_MT6580
  830. tpd->reg = regulator_get(tpd->tpd_dev, "VGP1"); /*get pointer to regulator structure*/
  831. if (IS_ERR(tpd->reg))
  832. GTP_ERROR("regulator_get() failed!\n");
  833. #endif
  834. #endif
  835. #if TPD_SUPPORT_I2C_DMA
  836. tpd->dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
  837. gpDMABuf_va = (u8 *) dma_alloc_coherent(&tpd->dev->dev, IIC_DMA_MAX_TRANSFER_SIZE,
  838. &gpDMABuf_pa, GFP_KERNEL);
  839. if (!gpDMABuf_va) {
  840. GTP_ERROR("Allocate DMA I2C Buffer failed!");
  841. return -1;
  842. }
  843. memset(gpDMABuf_va, 0, IIC_DMA_MAX_TRANSFER_SIZE);
  844. #endif
  845. spin_lock_init(&irq_flag_lock);
  846. if (i2c_add_driver(&tpd_i2c_driver) != 0) {
  847. GTP_ERROR("unable to add i2c driver.");
  848. return -1;
  849. }
  850. if (tpd_load_status == 0) { /*disable auto load touch driver for linux3.0 porting*/
  851. GTP_ERROR("add error touch panel driver.");
  852. i2c_del_driver(&tpd_i2c_driver);
  853. return -1;
  854. }
  855. input_set_abs_params(tpd->dev, ABS_MT_TRACKING_ID, 0, (GTP_MAX_TOUCH - 1), 0, 0);
  856. if (tpd_dts_data.use_tpd_button) {
  857. /*initialize tpd button data*/
  858. tpd_button_setting(tpd_dts_data.tpd_key_num, tpd_dts_data.tpd_key_local,
  859. tpd_dts_data.tpd_key_dim_local);
  860. }
  861. #if (defined(TPD_WARP_START) && defined(TPD_WARP_END))
  862. TPD_DO_WARP = 1;
  863. memcpy(tpd_wb_start, tpd_wb_start_local, TPD_WARP_CNT * 4);
  864. memcpy(tpd_wb_end, tpd_wb_start_local, TPD_WARP_CNT * 4);
  865. #endif
  866. #if (defined(TPD_HAVE_CALIBRATION) && !defined(TPD_CUSTOM_CALIBRATION))
  867. memcpy(tpd_calmat, tpd_def_calmat_local, 8 * 4);
  868. memcpy(tpd_def_calmat, tpd_def_calmat_local, 8 * 4);
  869. #endif
  870. /*set vendor string*/
  871. tpd->dev->id.vendor = 0x00;
  872. tpd->dev->id.product = convert_productname(gt1x_version.product_id);
  873. tpd->dev->id.version = (gt1x_version.patch_id >> 8);
  874. GTP_INFO("end %s, %d\n", __func__, __LINE__);
  875. tpd_type_cap = 1;
  876. return 0;
  877. }
  878. /* Function to manage low power suspend */
  879. static void tpd_suspend(struct device *h)
  880. {
  881. s32 ret = -1;
  882. #if defined(CONFIG_GTP_HOTKNOT)
  883. #ifndef CONFIG_HOTKNOT_BLOCK_RW
  884. u8 buf[1] = { 0 };
  885. #endif
  886. #endif
  887. GTP_INFO("TPD suspend start...");
  888. mutex_lock(&tui_lock);
  889. if (tpd_tui_flag) {
  890. GTP_INFO("[TPD] skip tpd_suspend due to TUI in used\n");
  891. tpd_tui_low_power_skipped = 1;
  892. mutex_unlock(&tui_lock);
  893. return;
  894. }
  895. mutex_unlock(&tui_lock);
  896. #ifdef CONFIG_GTP_PROXIMITY
  897. if (gt1x_proximity_flag == 1) {
  898. GTP_INFO("Suspend: proximity is detected!");
  899. return;
  900. }
  901. #endif
  902. #ifdef CONFIG_GTP_HOTKNOT
  903. if (hotknot_enabled) {
  904. #ifdef CONFIG_HOTKNOT_BLOCK_RW
  905. if (hotknot_paired_flag) {
  906. GTP_INFO("Suspend: hotknot is paired!");
  907. return;
  908. }
  909. #else
  910. gt1x_i2c_read(GTP_REG_HN_PAIRED, buf, sizeof(buf));
  911. GTP_DEBUG("0x81AA: 0x%02X", buf[0]);
  912. if (buf[0] == 0x55) {
  913. GTP_INFO("Suspend: hotknot is paired!");
  914. return;
  915. }
  916. #endif
  917. }
  918. #endif
  919. tpd_halt = 1;
  920. #ifdef CONFIG_GTP_ESD_PROTECT
  921. gt1x_esd_switch(SWITCH_OFF);
  922. #endif
  923. #ifdef CONFIG_GTP_CHARGER_SWITCH
  924. gt1x_charger_switch(SWITCH_OFF);
  925. #endif
  926. mutex_lock(&i2c_access);
  927. #ifdef CONFIG_GTP_GESTURE_WAKEUP
  928. gesture_clear_wakeup_data();
  929. if (gesture_enabled) {
  930. gesture_enter_doze();
  931. } else
  932. #endif
  933. {
  934. gt1x_irq_disable();
  935. ret = gt1x_enter_sleep();
  936. if (ret < 0)
  937. GTP_ERROR("GTP early suspend failed.");
  938. else
  939. gtp_suspend = true;
  940. }
  941. mutex_unlock(&i2c_access);
  942. msleep(58);
  943. }
  944. /* Function to manage power-on resume */
  945. static void tpd_resume(struct device *h)
  946. {
  947. s32 ret = -1;
  948. GTP_INFO("TPD resume start...");
  949. gtp_suspend = false;
  950. #ifdef CONFIG_GTP_PROXIMITY
  951. if (gt1x_proximity_flag == 1) {
  952. GTP_INFO("Resume: proximity is on!");
  953. return;
  954. }
  955. #endif
  956. #ifdef CONFIG_GTP_HOTKNOT
  957. if (hotknot_enabled) {
  958. #ifdef CONFIG_HOTKNOT_BLOCK_RW
  959. if (hotknot_paired_flag) {
  960. hotknot_paired_flag = 0;
  961. GTP_INFO("Resume: hotknot is paired!");
  962. return;
  963. }
  964. #endif
  965. }
  966. #endif
  967. ret = gt1x_wakeup_sleep();
  968. if (ret < 0)
  969. GTP_ERROR("GTP later resume failed.");
  970. #ifdef CONFIG_GTP_HOTKNOT
  971. if (!hotknot_enabled)
  972. gt1x_send_cmd(GTP_CMD_HN_EXIT_SLAVE, 0);
  973. #endif
  974. #ifdef CONFIG_GTP_CHARGER_SWITCH
  975. gt1x_charger_config(0);
  976. gt1x_charger_switch(SWITCH_ON);
  977. #endif
  978. tpd_halt = 0;
  979. gt1x_irq_enable();
  980. #ifdef CONFIG_GTP_ESD_PROTECT
  981. gt1x_esd_switch(SWITCH_ON);
  982. #endif
  983. GTP_DEBUG("tpd resume end.");
  984. }
  985. static struct tpd_driver_t tpd_device_driver = {
  986. .tpd_device_name = "gt9xx",
  987. .tpd_local_init = tpd_local_init,
  988. .suspend = tpd_suspend,
  989. .resume = tpd_resume,
  990. };
  991. int tpd_enter_tui(void)
  992. {
  993. int ret = 0;
  994. tpd_tui_flag = 1;
  995. mt_eint_set_deint(10, 187);
  996. GTP_INFO("[%s] enter tui", __func__);
  997. return ret;
  998. }
  999. int tpd_exit_tui(void)
  1000. {
  1001. int ret = 0;
  1002. GTP_INFO("[%s] exit TUI+", __func__);
  1003. mutex_lock(&tui_lock);
  1004. tpd_tui_flag = 0;
  1005. mutex_unlock(&tui_lock);
  1006. if (tpd_tui_low_power_skipped) {
  1007. tpd_tui_low_power_skipped = 0;
  1008. GTP_INFO("[%s] do low power again+", __func__);
  1009. tpd_suspend(NULL);
  1010. GTP_INFO("[%s] do low power again-", __func__);
  1011. }
  1012. mt_eint_clr_deint(10);
  1013. tpd_reregister_from_tui();
  1014. GTP_INFO("[%s] exit TUI-", __func__);
  1015. return ret;
  1016. }
  1017. void tpd_off(void)
  1018. {
  1019. gt1x_power_switch(SWITCH_OFF);
  1020. tpd_halt = 1;
  1021. gt1x_irq_disable();
  1022. }
  1023. void tpd_on(void)
  1024. {
  1025. s32 ret = -1, retry = 0;
  1026. while (retry++ < 5) {
  1027. ret = tpd_power_on();
  1028. if (ret < 0)
  1029. GTP_ERROR("I2C Power on ERROR!");
  1030. ret = gt1x_send_cfg(gt1x_config, gt1x_cfg_length);
  1031. if (ret == 0) {
  1032. GTP_DEBUG("Wakeup sleep send gt1x_config success.");
  1033. break;
  1034. }
  1035. }
  1036. if (ret < 0)
  1037. GTP_ERROR("GTP later resume failed.");
  1038. tpd_halt = 0;
  1039. }
  1040. /* called when loaded into kernel */
  1041. static int __init tpd_driver_init(void)
  1042. {
  1043. GTP_INFO("Goodix touch panel driver init.");
  1044. tpd_get_dts_info();
  1045. if (tpd_driver_add(&tpd_device_driver) < 0)
  1046. GTP_INFO("add generic driver failed\n");
  1047. return 0;
  1048. }
  1049. /* should never be called */
  1050. static void __exit tpd_driver_exit(void)
  1051. {
  1052. GTP_INFO("MediaTek gt91xx touch panel driver exit\n");
  1053. tpd_driver_remove(&tpd_device_driver);
  1054. }
  1055. module_init(tpd_driver_init);
  1056. module_exit(tpd_driver_exit);