Advertisement
Guest User

Untitled

a guest
Dec 1st, 2011
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 126.93 KB | None | 0 0
  1. diff --git a/arch/arm/mach-omap2/board-evt-peripherals.c b/arch/arm/mach-omap2/board-evt-peripherals.c
  2. index 3132b64..6078c32 100644
  3. --- a/arch/arm/mach-omap2/board-evt-peripherals.c
  4. +++ b/arch/arm/mach-omap2/board-evt-peripherals.c
  5. @@ -38,12 +38,37 @@
  6.  #include "mmc-twl4030.h"
  7.  #include "mux.h"
  8.  #include "twl4030.h"
  9. -#include <linux/cyttsp.h>
  10. +#include <linux/delay.h>
  11. +#include <linux/input/cyttsp.h>
  12.  #include <linux/ft5x06.h>
  13.  
  14.  #include <linux/kxtf9.h>
  15.  #include <linux/max17042.h>
  16.  
  17. +char expansionboard_name[] = CY_I2C_NAME;
  18. +
  19. +#define CY_GEN3        3
  20. +
  21. +#define CY_SPI_VKEY_NAME "virtualkeys.cyttsp-spi" /* must match SPI name */
  22. +#define CY_I2C_VKEY_NAME "virtualkeys.cyttsp-i2c" /* must match I2C name */
  23. +#define CY_MAXX            600//1000
  24. +#define CY_MAXY            (1024)//1000    /* leave room for vkeys */
  25. +#define CY_VK_SZ_X     60
  26. +#define CY_VK_SZ_Y     80
  27. +#define CY_VK_CNTR_X1      (CY_VK_SZ_X*0)+(CY_VK_SZ_X/2)
  28. +#define CY_VK_CNTR_X2      (CY_VK_SZ_X*1)+(CY_VK_SZ_X/2)
  29. +#define CY_VK_CNTR_X3      (CY_VK_SZ_X*2)+(CY_VK_SZ_X/2)
  30. +#define CY_VK_CNTR_X4      (CY_VK_SZ_X*3)+(CY_VK_SZ_X/2)
  31. +#define CY_VK_CNTR_Y1      CY_MAXY+(CY_VK_SZ_Y/2)
  32. +#define CY_VK_CNTR_Y2      CY_MAXY+(CY_VK_SZ_Y/2)
  33. +#define CY_VK_CNTR_Y3      CY_MAXY+(CY_VK_SZ_Y/2)
  34. +#define CY_VK_CNTR_Y4      CY_MAXY+(CY_VK_SZ_Y/2)
  35. +
  36. +#define CY_VK1_POS     ":95:770:190:60"
  37. +#define CY_VK2_POS         ":285:770:190:60"
  38. +#define CY_VK3_POS     ":475:770:190:60"
  39. +#define CY_VK4_POS         ":665:770:190:60"
  40. +
  41.  #define KXTF9_DEVICE_ID                 "kxtf9"
  42.  #define KXTF9_I2C_SLAVE_ADDRESS         0x0F
  43.  #define KXTF9_GPIO_FOR_PWR              34
  44. @@ -112,62 +137,132 @@ static struct ft5x06_platform_data ft5x06_platform_data = {
  45.      .use_gestures = 1,
  46.  };
  47.  
  48. +/*virtual key support */
  49. +static ssize_t cyttsp_vkeys_show(struct kobject *kobj,
  50. +                        struct kobj_attribute *attr, char *buf)
  51. +{
  52. +   return sprintf(buf,
  53. +   __stringify(EV_KEY) ":" __stringify(KEY_BACK) CY_VK1_POS
  54. +   ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) CY_VK2_POS
  55. +   ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) CY_VK3_POS
  56. +   ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) CY_VK4_POS
  57. +   "\n");
  58. +}
  59. +
  60. +static struct kobj_attribute cyttsp_vkeys_attr = {
  61. +        .attr = {
  62. +                .mode = S_IRUGO,
  63. +        },
  64. +        .show = &cyttsp_vkeys_show,
  65. +};
  66. +
  67. +static struct attribute *cyttsp_properties_attrs[] = {
  68. +        &cyttsp_vkeys_attr.attr,
  69. +        NULL
  70. +};
  71. +
  72. +static struct attribute_group cyttsp_properties_attr_group = {
  73. +        .attrs = cyttsp_properties_attrs,
  74. +};
  75. +
  76. +static int cyttsp_vkey_init(const char *name)
  77. + {
  78. +   struct kobject *properties_kobj;
  79. +   int rc;
  80. +   char buf[160];
  81. +
  82. +   printk("%s: init virtual keys\n", __func__);
  83. +
  84. +   cyttsp_vkeys_attr.attr.name = name;
  85. +   properties_kobj = kobject_create_and_add("board_properties", NULL);
  86. +   rc = 0;
  87. +   if (properties_kobj)
  88. +       rc = sysfs_create_group(properties_kobj,
  89. +           &cyttsp_properties_attr_group);
  90. +
  91. +   if (!properties_kobj)
  92. +       printk("%s: "
  93. +           "setup cyttsp virtual keys fail nobj \n",
  94. +           __func__);
  95. +   if (rc)
  96. +       printk("%s: "
  97. +           "setup cyttsp virtual keys fail rc=%d \n",
  98. +           __func__, rc);
  99. +
  100. +   if (!properties_kobj || rc)
  101. +       printk("%s: failed to create board_properties\n",
  102. +           __func__);
  103. +   else {
  104. +       printk("%s: "
  105. +           "setup cyttsp virtual keys ok name=%s\n",
  106. +           __func__, cyttsp_vkeys_attr.attr.name);
  107. +       cyttsp_vkeys_show(properties_kobj, &cyttsp_vkeys_attr, buf);
  108. +       printk("%s: " "%s""\n", __func__, buf);
  109. +   }
  110. +   return rc;
  111. +}
  112. +
  113. +
  114. +#define CY_I2C_IRQ_GPIO    OMAP_CYTTSP_GPIO
  115. +#define CY_I2C_ADR CYTTSP_I2C_SLAVEADDRESS
  116.  
  117. -int  cyttsp_dev_init(int resource)
  118. +static int cyttsp_i2c_init(void)
  119. +{
  120. +   int ret;
  121. +
  122. +   ret = cyttsp_vkey_init(CY_I2C_VKEY_NAME);
  123. +
  124. +   if (gpio_request(OMAP_CYTTSP_RESET_GPIO, "tma340_reset") < 0) {
  125. +       printk(KERN_ERR "can't get tma340 xreset GPIO\n");
  126. +       return -1;
  127. +   }
  128. +
  129. +   if (gpio_request(OMAP_CYTTSP_GPIO, "cyttsp_touch") < 0) {
  130. +       printk(KERN_ERR "can't get cyttsp interrupt GPIO\n");
  131. +       return -1;
  132. +   }
  133. +
  134. +   gpio_direction_input(OMAP_CYTTSP_GPIO);
  135. +   omap_set_gpio_debounce(OMAP_CYTTSP_GPIO, 0);
  136. +
  137. +   mdelay(100);
  138. +   printk("Reseting TMA340\n");
  139. +   gpio_direction_output(OMAP_CYTTSP_RESET_GPIO, 0);
  140. +   mdelay(10);
  141. +   gpio_direction_output(OMAP_CYTTSP_RESET_GPIO, 1);
  142. +   mdelay(100);
  143. +
  144. +   return 0;
  145. +}
  146. +
  147. +static int cyttsp_i2c_wakeup(void)
  148.  {
  149. -        if (resource)
  150. -        {
  151. -                if (gpio_request(OMAP_CYTTSP_RESET_GPIO, "tma340_reset") < 0) {
  152. -                        printk(KERN_ERR "can't get tma340 xreset GPIO\n");
  153. -                        return -1;
  154. -                }
  155. -
  156. -                if (gpio_request(OMAP_CYTTSP_GPIO, "cyttsp_touch") < 0) {
  157. -                        printk(KERN_ERR "can't get cyttsp interrupt GPIO\n");
  158. -                        return -1;
  159. -                }
  160. -
  161. -                gpio_direction_input(OMAP_CYTTSP_GPIO);
  162. -                omap_set_gpio_debounce(OMAP_CYTTSP_GPIO, 0);
  163. -        }
  164. -        else
  165. -        {
  166. -                gpio_free(OMAP_CYTTSP_GPIO);
  167. -                gpio_free(OMAP_CYTTSP_RESET_GPIO);
  168. -        }
  169.      return 0;
  170.  }
  171.  
  172. -static struct cyttsp_platform_data cyttsp_platform_data = {
  173. -        .maxx = 480,
  174. -        .maxy = 800,
  175. -        .flags = 0,
  176. -        .gen = CY_GEN3,
  177. -        .use_st = CY_USE_ST,
  178. -        .use_mt = CY_USE_MT,
  179. -        .use_hndshk = CY_SEND_HNDSHK,
  180. -        .use_trk_id = CY_USE_TRACKING_ID,
  181. -        .use_sleep = CY_USE_SLEEP,
  182. -        .use_gestures = 0,
  183. -        /* activate up to 4 groups
  184. -         * and set active distance
  185. -         */
  186. -        .gest_set = 0,
  187. -        /* change act_intrvl to customize the Active power state
  188. -         * scanning/processing refresh interval for Operating mode
  189. -         */
  190. -        .act_intrvl = CY_ACT_INTRVL_DFLT,
  191. -        /* change tch_tmout to customize the touch timeout for the
  192. -         * Active power state for Operating mode
  193. -         */
  194. -        .tch_tmout = CY_TCH_TMOUT_DFLT,
  195. -        /* change lp_intrvl to customize the Low Power power state
  196. -         * scanning/processing refresh interval for Operating mode
  197. -         */
  198. -        .lp_intrvl = CY_LP_INTRVL_DFLT,
  199. +static struct cyttsp_platform_data cyttsp_i2c_platform_data = {
  200. +   .wakeup = cyttsp_i2c_wakeup,
  201. +   .init = cyttsp_i2c_init,
  202. +   .maxx = CY_MAXX,
  203. +   .maxy = CY_MAXY,
  204. +   .use_hndshk = 0 /*CY_SEND_HNDSHK*/,
  205. +   .use_sleep = 0 /*CY_USE_SLEEP*/,
  206. +   /* change act_intrvl to customize the Active power state
  207. +    * scanning/processing refresh interval for Operating mode
  208. +    */
  209. +   .act_intrvl = CY_ACT_INTRVL_DFLT,
  210. +   /* change tch_tmout to customize the touch timeout for the
  211. +    * Active power state for Operating mode
  212. +    */
  213. +   .tch_tmout = CY_TCH_TMOUT_DFLT,
  214. +   /* change lp_intrvl to customize the Low Power power state
  215. +    * scanning/processing refresh interval for Operating mode
  216. +    */
  217. +   .lp_intrvl = CY_LP_INTRVL_DFLT,
  218. +   .name = CY_I2C_NAME,
  219. +   .irq_gpio = CY_I2C_IRQ_GPIO,
  220.  };
  221.  
  222. -
  223.  static void kxtf9_dev_init(void)
  224.  {
  225.     printk("board-3621_evt1a.c: kxtf9_dev_init ...\n");
  226. @@ -550,9 +645,9 @@ static void max17042_dev_init(void)
  227.  static struct i2c_board_info __initdata evt_i2c_bus2_info[] = {
  228.     {
  229.         I2C_BOARD_INFO(CY_I2C_NAME, CYTTSP_I2C_SLAVEADDRESS),
  230. -       .platform_data = &cyttsp_platform_data,
  231. +       .platform_data = &cyttsp_i2c_platform_data,
  232.         .irq = OMAP_GPIO_IRQ(OMAP_CYTTSP_GPIO),
  233. -   },
  234. +   }
  235.      {
  236.          I2C_BOARD_INFO(FT_I2C_NAME, FT5x06_I2C_SLAVEADDRESS),
  237.          .platform_data = &ft5x06_platform_data,
  238. diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
  239. index 5881c4f..1ed00e1 100644
  240. --- a/arch/arm/plat-omap/mcbsp.c
  241. +++ b/arch/arm/plat-omap/mcbsp.c
  242. @@ -1292,7 +1292,11 @@ static inline void __devexit omap_additional_remove(struct device *dev)
  243.  
  244.  static inline void __devinit omap34xx_device_init(struct omap_mcbsp *mcbsp)
  245.  {
  246. +#ifdef CONFIG_MACH_OMAP3621_EVT1A
  247. +   mcbsp->dma_op_mode = MCBSP_DMA_MODE_THRESHOLD;
  248. +#else
  249.     mcbsp->dma_op_mode = MCBSP_DMA_MODE_ELEMENT;
  250. +#endif
  251.     if (cpu_is_omap34xx()) {
  252.         /*
  253.          * Initially configure the maximum thresholds to a safe value.
  254. diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
  255. index 8615fbf..5d42e80 100644
  256. --- a/drivers/input/touchscreen/Kconfig
  257. +++ b/drivers/input/touchscreen/Kconfig
  258. @@ -557,14 +557,6 @@ config TOUCHSCREEN_SYNTM12XX
  259.           To compile this driver as module, choose M here: the
  260.           module will be called syntm12xx
  261.  
  262. -config TOUCHSCREEN_CYTTSP_I2C
  263. -    tristate "Cypress TTSP based touchscreens"
  264. -    depends on I2C
  265. -    help
  266. -      Say Y here if you a Cypress TTSP based touchscreen.
  267. -
  268. -      If unsure, say N.
  269. -
  270.  config TOUCHSCREEN_FT5x06_I2C
  271.      tristate "Focal tech 5x06 based touchscreens"
  272.      depends on I2C
  273. @@ -574,4 +566,33 @@ config TOUCHSCREEN_FT5x06_I2C
  274.        If unsure, say N.
  275.  endif
  276.  
  277. +config TOUCHSCREEN_CYTTSP_CORE
  278. +   tristate "Cypress TTSP touchscreen core"
  279. +   help
  280. +     Always activated for Cypress TTSP touchscreen
  281. +
  282. +config TOUCHSCREEN_CYTTSP_I2C
  283. +   tristate "Cypress TTSP i2c touchscreen"
  284. +   depends on I2C && TOUCHSCREEN_CYTTSP_CORE
  285. +   help
  286. +     Say Y here if you have a Cypress TTSP touchscreen
  287. +     connected to your system with an I2C interface.
  288. +
  289. +     If unsure, say N.
  290. +
  291. +     To compile this driver as a module, choose M here: the
  292. +     module will be called cyttsp-i2c.
  293. +
  294. +config TOUCHSCREEN_CYTTSP_SPI
  295. +   tristate "Cypress TTSP spi touchscreen"
  296. +   depends on SPI_MASTER && TOUCHSCREEN_CYTTSP_CORE
  297. +   help
  298. +     Say Y here if you have a Cypress TTSP touchscreen
  299. +     connected to your  with an SPI interface.
  300. +
  301. +     If unsure, say N.
  302. +
  303. +     To compile this driver as a module, choose M here: the
  304. +     module will be called cyttsp-spi.
  305. +
  306.  
  307. diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
  308. index 3a21fdb..a495c3c 100644
  309. --- a/drivers/input/touchscreen/Makefile
  310. +++ b/drivers/input/touchscreen/Makefile
  311. @@ -45,5 +45,8 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE) += zylonite-wm97xx.o
  312.  obj-$(CONFIG_TOUCHSCREEN_W90X900)  += w90p910_ts.o
  313.  obj-$(CONFIG_TOUCHSCREEN_PCAP)     += pcap_ts.o
  314.  obj-$(CONFIG_TOUCHSCREEN_SYNTM12XX)    += syntm12xx.o
  315. -obj-$(CONFIG_TOUCHSCREEN_CYTTSP_I2C)    += cyttsp-i2c.o
  316.  obj-$(CONFIG_TOUCHSCREEN_FT5x06_I2C) += ft5x06-i2c.o
  317. +obj-$(CONFIG_TOUCHSCREEN_CYTTSP_CORE)   += cyttsp_core.o
  318. +obj-$(CONFIG_TOUCHSCREEN_CYTTSP_I2C)    += cyttsp_i2c.o
  319. +obj-$(CONFIG_TOUCHSCREEN_CYTTSP_SPI)    += cyttsp_spi.o
  320. +
  321. diff --git a/drivers/input/touchscreen/cyttsp-i2c.c b/drivers/input/touchscreen/cyttsp-i2c.c
  322. deleted file mode 100644
  323. index 30206e9..0000000
  324. --- a/drivers/input/touchscreen/cyttsp-i2c.c
  325. +++ /dev/null
  326. @@ -1,3273 +0,0 @@
  327. -/* Source for:
  328. - * Cypress TrueTouch(TM) Standard Product I2C touchscreen driver.
  329. - * drivers/input/touchscreen/cyttsp-i2c.c
  330. - *
  331. - * Copyright (C) 2009, 2010 Cypress Semiconductor, Inc.
  332. - *
  333. - * Copyright (c) 2010 Barnes & Noble.
  334. - *
  335. - * This program is free software; you can redistribute it and/or
  336. - * modify it under the terms of the GNU General Public License
  337. - * version 2, and only version 2, as published by the
  338. - * Free Software Foundation.
  339. - *
  340. - * This program is distributed in the hope that it will be useful,
  341. - * but WITHOUT ANY WARRANTY; without even the implied warranty of
  342. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  343. - * GNU General Public License for more details.
  344. - *
  345. - * You should have received a copy of the GNU General Public License along
  346. - * with this program; if not, write to the Free Software Foundation, Inc.,
  347. - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  348. - *
  349. - * Cypress reserves the right to make changes without further notice
  350. - * to the materials described herein. Cypress does not assume any
  351. - * liability arising out of the application described herein.
  352. - *
  353. - * Contact Cypress Semiconductor at www.cypress.com
  354. - *
  355. - */
  356. -
  357. -#include <linux/delay.h>
  358. -#include <linux/init.h>
  359. -#include <linux/module.h>
  360. -#include <linux/i2c.h>
  361. -#include <linux/input.h>
  362. -#include <linux/slab.h>
  363. -#include <linux/gpio.h>
  364. -#include <linux/irq.h>
  365. -#include <linux/interrupt.h>
  366. -#include <linux/timer.h>
  367. -#include <linux/workqueue.h>
  368. -#include <linux/byteorder/generic.h>
  369. -#include <linux/bitops.h>
  370. -
  371. -#ifdef CONFIG_HAS_EARLYSUSPEND
  372. -#include <linux/earlysuspend.h>
  373. -#endif /* CONFIG_HAS_EARLYSUSPEND */
  374. -#include <linux/regulator/consumer.h>
  375. -
  376. -#define OMAP_CYTTSP_RESET_GPIO 46
  377. -
  378. -#define CY_DECLARE_GLOBALS
  379. -
  380. -// Empirically tested to work, revisit when Cypress gives us the real timings
  381. -#define CYTTSP_MDELAY 125
  382. -
  383. -#include <linux/cyttsp.h>
  384. -
  385. -uint32_t cyttsp_tsdebug1 = 0xff;
  386. -module_param_named(tsdebug1, cyttsp_tsdebug1, uint, 0664);
  387. -
  388. -#include <mach/gpio.h>
  389. -
  390. -int  cyttsp_dev_init(int resource);
  391. -
  392. -/* CY TTSP I2C Driver private data */
  393. -struct cyttsp {
  394. -   struct i2c_client *client;
  395. -   struct input_dev *input;
  396. -   struct work_struct work;
  397. -   struct work_struct init_work;
  398. -   struct work_struct update_work;
  399. -   struct timer_list timer;
  400. -   char phys[32];
  401. -   struct cyttsp_platform_data *platform_data;
  402. -   u8 num_prv_st_tch;
  403. -   u16 act_trk[CY_NUM_TRK_ID];
  404. -   u16 prv_st_tch[CY_NUM_ST_TCH_ID];
  405. -   u16 prv_mt_tch[CY_NUM_MT_TCH_ID];
  406. -   u16 prv_mt_pos[CY_NUM_TRK_ID][2];
  407. -   atomic_t irq_enabled;
  408. -#ifdef CONFIG_HAS_EARLYSUSPEND
  409. -   struct early_suspend early_suspend;
  410. -#endif /* CONFIG_HAS_EARLYSUSPEND */
  411. -   struct regulator *reg;
  412. -};
  413. -static u8 irq_cnt;     /* comparison counter with register valuw */
  414. -static u32 irq_cnt_total;  /* total interrupts */
  415. -static u32 irq_err_cnt;        /* count number of touch interrupts with err */
  416. -static u8 fw_update_flag = 0;   /* fw update state tracking flag */
  417. -#define CY_IRQ_CNT_MASK    0x000000FF  /* mapped for sizeof count in reg */
  418. -#define CY_IRQ_CNT_REG 0x00        /* tt_undef[0]=reg 0x1B - Gen3 only */
  419. -
  420. -#ifdef CONFIG_HAS_EARLYSUSPEND
  421. -static void cyttsp_early_suspend(struct early_suspend *handler);
  422. -static void cyttsp_late_resume(struct early_suspend *handler);
  423. -#endif /* CONFIG_HAS_EARLYSUSPEND */
  424. -
  425. -static struct workqueue_struct *cyttsp_ts_wq;
  426. -static u8 initiate_tpcal = 0;
  427. -static DEFINE_MUTEX(thread_mutex);
  428. -/* ****************************************************************************
  429. - * Prototypes for static functions
  430. - * ************************************************************************** */
  431. -static int cyttsp_power_on(struct cyttsp *ts);
  432. -static int cyttsp_calibrate(struct cyttsp *ts);
  433. -static int cyttsp_bootload_app(struct cyttsp *ts);
  434. -static void cyttsp_init_worker(struct work_struct * work);
  435. -static void cyttsp_update_worker(struct work_struct * work);
  436. -static void cyttsp_xy_worker(struct work_struct *work);
  437. -static irqreturn_t cyttsp_irq(int irq, void *handle);
  438. -static int cyttsp_inlist(u16 prev_track[],
  439. -           u8 cur_trk_id, u8 *prev_loc, u8 num_touches);
  440. -static int cyttsp_next_avail_inlist(u16 cur_trk[],
  441. -           u8 *new_loc, u8 num_touches);
  442. -static int cyttsp_putbl(struct cyttsp *ts, int show,
  443. -           int show_status, int show_version, int show_cid);
  444. -static int __devinit cyttsp_probe(struct i2c_client *client,
  445. -           const struct i2c_device_id *id);
  446. -static int __devexit cyttsp_remove(struct i2c_client *client);
  447. -static int cyttsp_resume(struct i2c_client *client);
  448. -static int cyttsp_suspend(struct i2c_client *client, pm_message_t message);
  449. -
  450. -/* Static variables */
  451. -static struct cyttsp_gen3_xydata_t g_xy_data;
  452. -static u8 g_test_data[500];
  453. -static struct cyttsp_bootloader_data_t g_bl_data;
  454. -static struct cyttsp_sysinfo_data_t g_sysinfo_data;
  455. -static const struct i2c_device_id cyttsp_id[] = {
  456. -   { CY_I2C_NAME, 0 },  { }
  457. -};
  458. -static u8 bl_cmd[] = {
  459. -   CY_BL_FILE0, CY_BL_CMD, CY_BL_EXIT,
  460. -   CY_BL_KEY0, CY_BL_KEY1, CY_BL_KEY2,
  461. -   CY_BL_KEY3, CY_BL_KEY4, CY_BL_KEY5,
  462. -   CY_BL_KEY6, CY_BL_KEY7};
  463. -
  464. -MODULE_DEVICE_TABLE(i2c, cyttsp_id);
  465. -
  466. -static struct i2c_driver cyttsp_driver = {
  467. -   .driver = {
  468. -       .name = CY_I2C_NAME,
  469. -       .owner = THIS_MODULE,
  470. -   },
  471. -   .probe = cyttsp_probe,
  472. -   .remove = __devexit_p(cyttsp_remove),
  473. -#ifndef CONFIG_HAS_EARLYSUSPEND
  474. -   .suspend = cyttsp_suspend,
  475. -   .resume = cyttsp_resume,
  476. -#endif
  477. -   .id_table = cyttsp_id,
  478. -};
  479. -
  480. -MODULE_LICENSE("GPL");
  481. -MODULE_DESCRIPTION("Cypress TrueTouch(R) Standard touchscreen driver");
  482. -MODULE_AUTHOR("Cypress");
  483. -
  484. -static ssize_t cyttsp_irq_status(struct device *dev,
  485. -               struct device_attribute *attr, char *buf)
  486. -{
  487. -   struct i2c_client *client = container_of(dev, struct i2c_client, dev);
  488. -   struct cyttsp *ts = i2c_get_clientdata(client);
  489. -   return sprintf(buf, "%u\n", atomic_read(&ts->irq_enabled));
  490. -}
  491. -
  492. -static ssize_t cyttsp_irq_enable(struct device *dev,
  493. -               struct device_attribute *attr,
  494. -               const char *buf, size_t size)
  495. -{
  496. -   struct i2c_client *client = container_of(dev, struct i2c_client, dev);
  497. -   struct cyttsp *ts = i2c_get_clientdata(client);
  498. -   int err = 0;
  499. -   unsigned long value;
  500. -
  501. -   if (size > 2)
  502. -       return -EINVAL;
  503. -
  504. -   err = strict_strtoul(buf, 10, &value);
  505. -   if (err != 0)
  506. -       return err;
  507. -
  508. -   switch (value) {
  509. -   case 0:
  510. -       if (atomic_cmpxchg(&ts->irq_enabled, 1, 0)) {
  511. -           pr_info("touch irq disabled!\n");
  512. -           disable_irq(ts->client->irq);
  513. -       }
  514. -       err = size;
  515. -       break;
  516. -   case 1:
  517. -       if (!atomic_cmpxchg(&ts->irq_enabled, 0, 1)) {
  518. -           pr_info("touch irq enabled!\n");
  519. -           enable_irq(ts->client->irq);
  520. -       }
  521. -       err = size;
  522. -       break;
  523. -   default:
  524. -       pr_info("cyttsp_irq_enable failed -> irq_enabled = %d\n",
  525. -       atomic_read(&ts->irq_enabled));
  526. -       err = -EINVAL;
  527. -       break;
  528. -   }
  529. -
  530. -   return err;
  531. -}
  532. -
  533. -static DEVICE_ATTR(irq_enable, 0777, cyttsp_irq_status, cyttsp_irq_enable);
  534. -
  535. -void cyttsp_update_worker(struct work_struct * work)
  536. -{
  537. -    struct cyttsp *ts = container_of(work, struct cyttsp, update_work);
  538. -    u8  regval = 0x00;
  539. -    int retval = CY_OK;
  540. -    int tries  = 0;
  541. -
  542. -
  543. -    mutex_lock(&thread_mutex);
  544. -
  545. -    dev_info(&ts->client->dev, "%s() - Performing touch panel Firmware Update.\n", __FUNCTION__);
  546. -
  547. -    /* enter bootloader to load new app into TTSP Device */
  548. -    if (0 > cyttsp_bootload_app(ts))
  549. -    {
  550. -        dev_err(&ts->client->dev, "%s() - ERROR: Could not load the new firmware on the device.\n", __FUNCTION__);
  551. -        goto error_return;
  552. -    }
  553. -
  554. -    dev_info(&ts->client->dev, "%s() - Updated touch panel Firmware to version %02X%02X\n", __FUNCTION__, cyttsp_app_verh(), cyttsp_app_verl());
  555. -
  556. -    /* take TTSP device out of bootloader mode;
  557. -     * switch back to TrueTouch operational mode */
  558. -    if (0 != i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE, sizeof(bl_cmd), bl_cmd))
  559. -    {
  560. -        dev_err(&ts->client->dev, "%s() - ERROR: Could not put the touch panel back in Operational Mode.\n", __FUNCTION__);
  561. -        goto error_return;
  562. -    }
  563. -
  564. -    msleep(CYTTSP_MDELAY);
  565. -
  566. -    regval = CY_OP_MODE;
  567. -    for (tries = 0; tries < 10; tries++)
  568. -    {
  569. -        retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE, sizeof(regval), &regval);
  570. -        if (0 != retval)
  571. -        {
  572. -            msleep(100);
  573. -        }
  574. -        else
  575. -        {
  576. -            break;
  577. -        }
  578. -    }
  579. -
  580. -    if (0 != retval)
  581. -    {
  582. -        dev_err(&ts->client->dev, "%s() - ERROR: Could not set the Host Mode register to 0x%02X.\n", __FUNCTION__, CY_OP_MODE);
  583. -        goto error_return;
  584. -    }
  585. -
  586. -    msleep(CYTTSP_MDELAY);
  587. -
  588. -    dev_info(&ts->client->dev, "%s() - Configuring Gesture Setup.\n", __FUNCTION__);
  589. -    regval = ts->platform_data->gest_set;
  590. -    retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_GEST_SET, sizeof(regval), &regval);
  591. -    if (0 != retval)
  592. -    {
  593. -        dev_err(&ts->client->dev, "%s() - ERROR: Could not write the Gesture Configuration to the Gesture Setup register.\n", __FUNCTION__);
  594. -        ts->platform_data->power_state = CY_IDLE_STATE;
  595. -    }
  596. -    else
  597. -    {
  598. -        ts->platform_data->power_state = CY_ACTIVE_STATE;
  599. -    }
  600. -
  601. -    dev_info(&ts->client->dev, "%s() - Power state is %s\n", __FUNCTION__, ((ts->platform_data->power_state == CY_ACTIVE_STATE) ? "ACTIVE" : "IDLE"));
  602. -
  603. -error_return:
  604. -    mutex_unlock(&thread_mutex);
  605. -
  606. -    fw_update_flag = 0;
  607. -    return;
  608. -}
  609. -
  610. -void cyttsp_init_worker(struct work_struct *work)
  611. -{
  612. -    struct cyttsp *ts = container_of(work, struct cyttsp, init_work);
  613. -
  614. -    int retval = CY_OK;
  615. -    u16 chip_ttspver = (g_bl_data.ttspver_hi << 8) | g_bl_data.ttspver_lo;
  616. -    u16 kern_ttspver = (cyttsp_tts_verh() << 8) | cyttsp_tts_verl();
  617. -
  618. -    u16 chip_appid   = (g_bl_data.appid_hi << 8) | g_bl_data.appid_lo;
  619. -    u16 kern_appid   = (cyttsp_app_idh() << 8) | cyttsp_app_idl();
  620. -
  621. -    u16 chip_appver  = (g_bl_data.appver_hi << 8) | g_bl_data.appver_lo;
  622. -    u16 kern_appver  = (cyttsp_app_verh() <<8) | cyttsp_app_verl();
  623. -
  624. -
  625. -    cyttsp_debug("\nchip_ttspver=%X; kern_ttspver=%X", chip_ttspver, kern_ttspver);
  626. -    cyttsp_debug("\nchip_appid=%X; kern_appid=%X", chip_appid, kern_appid);
  627. -    cyttsp_debug("\nchip_appver=%X; kern_appver=%X\n", chip_appver, kern_appver);
  628. -
  629. -    retval = cyttsp_power_on(ts);
  630. -
  631. -    if (retval != 0)
  632. -    {
  633. -        cyttsp_error(" ERROR:  could not power up the TS controller\n");
  634. -        /* Disable IRQ if this fails */
  635. -        disable_irq(ts->client->irq);
  636. -    }
  637. -
  638. -    /* init gesture setup;
  639. -     * this is required even if not using gestures
  640. -     * in order to set the active distance */
  641. -    if (!(retval < CY_OK))
  642. -    {
  643. -        u8 gesture_setup;
  644. -
  645. -        cyttsp_debug("init gesture setup \n");
  646. -        gesture_setup = ts->platform_data->gest_set;
  647. -        retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_GEST_SET, sizeof(gesture_setup), &gesture_setup);
  648. -        mdelay(CY_DLY_DFLT);
  649. -    }
  650. -
  651. -    if (!(retval < CY_OK))
  652. -        ts->platform_data->power_state = CY_ACTIVE_STATE;
  653. -    else
  654. -        ts->platform_data->power_state = CY_IDLE_STATE;
  655. -
  656. -    cyttsp_debug("Retval=%d Power state is %s\n", retval, ts->platform_data->power_state == CY_ACTIVE_STATE ? "ACTIVE" : "IDLE");
  657. -
  658. -    irq_cnt = 0;
  659. -    irq_cnt_total = 0;
  660. -    irq_err_cnt = 0;
  661. -
  662. -    if (mutex_is_locked(&thread_mutex))
  663. -    {
  664. -        mutex_unlock(&thread_mutex);
  665. -    }
  666. -
  667. -    return;
  668. -}
  669. -
  670. -
  671. -/* The cyttsp_xy_worker function reads the XY coordinates and sends them to
  672. - * the input layer.  It is scheduled from the interrupt (or timer).
  673. - */
  674. -void cyttsp_xy_worker(struct work_struct *work)
  675. -{
  676. -   struct cyttsp *ts = container_of(work, struct cyttsp, work);
  677. -   u8 id, tilt, rev_x, rev_y;
  678. -   u8 i, loc;
  679. -   u8 prv_tch;     /* number of previous touches */
  680. -   u8 cur_tch; /* number of current touches */
  681. -   u16 tmp_trk[CY_NUM_TRK_ID];
  682. -   u16 snd_trk[CY_NUM_TRK_ID];
  683. -   u16 cur_trk[CY_NUM_TRK_ID];
  684. -   u16 cur_st_tch[CY_NUM_ST_TCH_ID];
  685. -   u16 cur_mt_tch[CY_NUM_MT_TCH_ID];
  686. -   /* if NOT CY_USE_TRACKING_ID then
  687. -    * only uses CY_NUM_MT_TCH_ID positions */
  688. -   u16 cur_mt_pos[CY_NUM_TRK_ID][2];
  689. -   /* if NOT CY_USE_TRACKING_ID then
  690. -    * only uses CY_NUM_MT_TCH_ID positions */
  691. -   u8 cur_mt_z[CY_NUM_TRK_ID];
  692. -   u8 curr_tool_width;
  693. -   u16 st_x1, st_y1;
  694. -   u8 st_z1;
  695. -   u16 st_x2, st_y2;
  696. -   u8 st_z2;
  697. -   s32 retval;
  698. -
  699. -   cyttsp_xdebug("TTSP worker start 1:\n");
  700. -   mutex_lock(&thread_mutex);
  701. -
  702. -   /* get event data from CYTTSP device */
  703. -   i = CY_NUM_RETRY;
  704. -   do {
  705. -       retval = i2c_smbus_read_i2c_block_data(ts->client,
  706. -           CY_REG_BASE,
  707. -           sizeof(struct cyttsp_gen3_xydata_t), (u8 *)&g_xy_data);
  708. -   } while ((retval < CY_OK) && --i);
  709. -
  710. -   if (retval < CY_OK) {
  711. -       /* return immediately on
  712. -        * failure to read device on the i2c bus */
  713. -       goto exit_xy_worker;
  714. -   }
  715. -
  716. -   cyttsp_xdebug("TTSP worker start 2:\n");
  717. -
  718. -   /* compare own irq counter with the device irq counter */
  719. -   if (ts->client->irq) {
  720. -       u8 host_reg;
  721. -       u8 cur_cnt;
  722. -       if (ts->platform_data->use_hndshk) {
  723. -
  724. -           host_reg = g_xy_data.hst_mode & CY_HNDSHK_BIT ?
  725. -               g_xy_data.hst_mode & ~CY_HNDSHK_BIT :
  726. -               g_xy_data.hst_mode | CY_HNDSHK_BIT;
  727. -           retval = i2c_smbus_write_i2c_block_data(ts->client,
  728. -               CY_REG_BASE, sizeof(host_reg), &host_reg);
  729. -       }
  730. -       cur_cnt = g_xy_data.tt_undef[CY_IRQ_CNT_REG];
  731. -       irq_cnt_total++;
  732. -       irq_cnt++;
  733. -       if (irq_cnt != cur_cnt) {
  734. -           irq_err_cnt++;
  735. -           cyttsp_debug("i_c_ER: dv=%d fw=%d hm=%02X t=%lu te=%lu\n", \
  736. -               irq_cnt, \
  737. -               cur_cnt, g_xy_data.hst_mode, \
  738. -               (unsigned long)irq_cnt_total, \
  739. -               (unsigned long)irq_err_cnt);
  740. -       } else {
  741. -           cyttsp_debug("i_c_ok: dv=%d fw=%d hm=%02X t=%lu te=%lu\n", \
  742. -               irq_cnt, \
  743. -               cur_cnt, g_xy_data.hst_mode, \
  744. -               (unsigned long)irq_cnt_total, \
  745. -               (unsigned long)irq_err_cnt);
  746. -       }
  747. -       irq_cnt = cur_cnt;
  748. -   }
  749. -
  750. -   /* Get the current num touches and return if there are no touches */
  751. -   if ((GET_BOOTLOADERMODE(g_xy_data.tt_mode) == 1) ||
  752. -       (GET_HSTMODE(g_xy_data.hst_mode) != CY_OK)) {
  753. -       u8 host_reg, tries;
  754. -       /* the TTSP device has suffered spurious reset or mode switch */
  755. -       cyttsp_debug( \
  756. -           "Spurious err opmode (tt_mode=%02X hst_mode=%02X)\n", \
  757. -           g_xy_data.tt_mode, g_xy_data.hst_mode);
  758. -       cyttsp_debug("Reset TTSP Device; Terminating active tracks\n");
  759. -       /* terminate all active tracks */
  760. -       cur_tch = CY_NTCH;
  761. -       /* reset TTSP part and take it back out of Bootloader mode */
  762. -       host_reg = CY_SOFT_RESET_MODE;
  763. -       retval = i2c_smbus_write_i2c_block_data(ts->client,
  764. -           CY_REG_BASE,
  765. -           sizeof(host_reg), &host_reg);
  766. -       tries = 0;
  767. -       do {
  768. -           msleep(1000);
  769. -
  770. -           /* set arg2 to non-0 to activate */
  771. -           retval = cyttsp_putbl(ts, 1, false, false, false);
  772. -       } while (!(retval < CY_OK) &&
  773. -           !GET_BOOTLOADERMODE(g_bl_data.bl_status) &&
  774. -           !(g_bl_data.bl_file ==
  775. -           CY_OP_MODE + CY_LOW_PWR_MODE) &&
  776. -           tries++ < 10);
  777. -       /* switch back to operational mode */
  778. -       if (GET_BOOTLOADERMODE(g_bl_data.bl_status)) {
  779. -           retval = i2c_smbus_write_i2c_block_data(ts->client,
  780. -               CY_REG_BASE,
  781. -               sizeof(bl_cmd), bl_cmd);
  782. -           tries = 0;
  783. -           do {
  784. -               msleep(1000);
  785. -               cyttsp_putbl(ts, 1, false, false, false);
  786. -           } while (GET_BOOTLOADERMODE(g_bl_data.bl_status) &&
  787. -               tries++ < 10);
  788. -       }
  789. -       if (!(retval < CY_OK)) {
  790. -           host_reg = CY_OP_MODE
  791. -               /* + CY_LOW_PWR_MODE */;
  792. -           retval = i2c_smbus_write_i2c_block_data(ts->client,
  793. -               CY_REG_BASE,
  794. -               sizeof(host_reg), &host_reg);
  795. -           /* wait for TTSP Device to complete switch to Op mode */
  796. -           msleep(1000);
  797. -       }
  798. -       goto exit_xy_worker;
  799. -   } else {
  800. -       cur_tch = GET_NUM_TOUCHES(g_xy_data.tt_stat);
  801. -       if (IS_LARGE_AREA(g_xy_data.tt_stat)) {
  802. -           /* terminate all active tracks */
  803. -           cur_tch = CY_NTCH;
  804. -           cyttsp_debug("Large obj detect (tt_stat=0x%02X). Terminate act trks\n", \
  805. -               g_xy_data.tt_stat);
  806. -       } else if (cur_tch > CY_NUM_MT_TCH_ID) {
  807. -           /* if the number of fingers on the touch surface
  808. -            * is more than the maximum then
  809. -            * there will be no new track information
  810. -            * even for the original touches.
  811. -            * Therefore, terminate all active tracks.
  812. -            */
  813. -           cur_tch = CY_NTCH;
  814. -           cyttsp_debug("Num touch err (tt_stat=0x%02X). Terminate act trks\n", \
  815. -               g_xy_data.tt_stat);
  816. -       }
  817. -   }
  818. -
  819. -   /* set tool size */
  820. -   curr_tool_width = CY_SMALL_TOOL_WIDTH;
  821. -
  822. -   /* translate Gen2 interface data into comparable Gen3 data */
  823. -   if (ts->platform_data->gen == CY_GEN2) {
  824. -       struct cyttsp_gen2_xydata_t *pxy_gen2_data;
  825. -       pxy_gen2_data = (struct cyttsp_gen2_xydata_t *)(&g_xy_data);
  826. -
  827. -       /* use test data? */
  828. -       cyttsp_testdat(&g_xy_data, &tt_gen2_testray, \
  829. -           sizeof(struct cyttsp_gen3_xydata_t));
  830. -
  831. -       if (pxy_gen2_data->evnt_idx == CY_GEN2_NOTOUCH) {
  832. -           cur_tch = 0;
  833. -       } else if (cur_tch == CY_GEN2_GHOST) {
  834. -           cur_tch = 0;
  835. -       } else if (cur_tch == CY_GEN2_2TOUCH) {
  836. -           /* stuff artificial track ID1 and ID2 */
  837. -           g_xy_data.touch12_id = 0x12;
  838. -           g_xy_data.z1 = CY_MAXZ;
  839. -           g_xy_data.z2 = CY_MAXZ;
  840. -           cur_tch--;          /* 2 touches */
  841. -       } else if (cur_tch == CY_GEN2_1TOUCH) {
  842. -           /* stuff artificial track ID1 and ID2 */
  843. -           g_xy_data.touch12_id = 0x12;
  844. -           g_xy_data.z1 = CY_MAXZ;
  845. -           g_xy_data.z2 = CY_NTCH;
  846. -           if (pxy_gen2_data->evnt_idx == CY_GEN2_TOUCH2) {
  847. -               /* push touch 2 data into touch1
  848. -                * (first finger up; second finger down) */
  849. -               /* stuff artificial track ID1 for touch2 info */
  850. -               g_xy_data.touch12_id = 0x20;
  851. -               /* stuff touch 1 with touch 2 coordinate data */
  852. -               g_xy_data.x1 = g_xy_data.x2;
  853. -               g_xy_data.y1 = g_xy_data.y2;
  854. -           }
  855. -       } else {
  856. -           cur_tch = 0;
  857. -       }
  858. -   } else {
  859. -       /* use test data? */
  860. -       cyttsp_testdat(&g_xy_data, &tt_gen3_testray, \
  861. -           sizeof(struct cyttsp_gen3_xydata_t));
  862. -   }
  863. -
  864. -
  865. -
  866. -   /* clear current active track ID array and count previous touches */
  867. -   for (id = 0, prv_tch = CY_NTCH;
  868. -       id < CY_NUM_TRK_ID; id++) {
  869. -       cur_trk[id] = CY_NTCH;
  870. -       prv_tch += ts->act_trk[id];
  871. -   }
  872. -
  873. -   /* send no events if no previous touches and no new touches */
  874. -   if ((prv_tch == CY_NTCH) &&
  875. -       ((cur_tch == CY_NTCH) ||
  876. -       (cur_tch > CY_NUM_MT_TCH_ID))) {
  877. -       goto exit_xy_worker;
  878. -   }
  879. -
  880. -   cyttsp_debug("prev=%d  curr=%d\n", prv_tch, cur_tch);
  881. -
  882. -   for (id = 0; id < CY_NUM_ST_TCH_ID; id++) {
  883. -       /* clear current single touches array */
  884. -       cur_st_tch[id] = CY_IGNR_TCH;
  885. -   }
  886. -
  887. -   /* clear single touch positions */
  888. -   st_x1 = CY_NTCH;
  889. -   st_y1 = CY_NTCH;
  890. -   st_z1 = CY_NTCH;
  891. -   st_x2 = CY_NTCH;
  892. -   st_y2 = CY_NTCH;
  893. -   st_z2 = CY_NTCH;
  894. -
  895. -   for (id = 0; id < CY_NUM_MT_TCH_ID; id++) {
  896. -       /* clear current multi-touches array and
  897. -        * multi-touch positions/z */
  898. -       cur_mt_tch[id] = CY_IGNR_TCH;
  899. -   }
  900. -
  901. -   if (ts->platform_data->use_trk_id) {
  902. -       for (id = 0; id < CY_NUM_MT_TCH_ID; id++) {
  903. -           cur_mt_pos[id][CY_XPOS] = 0;
  904. -           cur_mt_pos[id][CY_YPOS] = 0;
  905. -           cur_mt_z[id] = 0;
  906. -       }
  907. -   } else {
  908. -       for (id = 0; id < CY_NUM_TRK_ID; id++) {
  909. -           cur_mt_pos[id][CY_XPOS] = 0;
  910. -           cur_mt_pos[id][CY_YPOS] = 0;
  911. -           cur_mt_z[id] = 0;
  912. -       }
  913. -   }
  914. -
  915. -   /* Determine if display is tilted */
  916. -   if (FLIP_DATA(ts->platform_data->flags))
  917. -       tilt = true;
  918. -   else
  919. -       tilt = false;
  920. -
  921. -   /* Check for switch in origin */
  922. -   if (REVERSE_X(ts->platform_data->flags))
  923. -       rev_x = true;
  924. -   else
  925. -       rev_x = false;
  926. -
  927. -   if (REVERSE_Y(ts->platform_data->flags))
  928. -       rev_y = true;
  929. -   else
  930. -       rev_y = false;
  931. -
  932. -
  933. -   if (cur_tch) {
  934. -       struct cyttsp_gen2_xydata_t *pxy_gen2_data;
  935. -       struct cyttsp_gen3_xydata_t *pxy_gen3_data;
  936. -       switch (ts->platform_data->gen) {
  937. -       case CY_GEN2: {
  938. -           pxy_gen2_data =
  939. -               (struct cyttsp_gen2_xydata_t *)(&g_xy_data);
  940. -           cyttsp_xdebug("TTSP Gen2 report:\n");
  941. -           cyttsp_xdebug("%02X %02X %02X\n", \
  942. -               pxy_gen2_data->hst_mode, \
  943. -               pxy_gen2_data->tt_mode, \
  944. -               pxy_gen2_data->tt_stat);
  945. -           cyttsp_xdebug("%04X %04X %02X  %02X\n", \
  946. -               pxy_gen2_data->x1, \
  947. -               pxy_gen2_data->y1, \
  948. -               pxy_gen2_data->z1, \
  949. -               pxy_gen2_data->evnt_idx);
  950. -           cyttsp_xdebug("%04X %04X %02X\n", \
  951. -               pxy_gen2_data->x2, \
  952. -               pxy_gen2_data->y2, \
  953. -               pxy_gen2_data->tt_undef1);
  954. -           cyttsp_xdebug("%02X %02X %02X\n", \
  955. -               pxy_gen2_data->gest_cnt, \
  956. -               pxy_gen2_data->gest_id, \
  957. -               pxy_gen2_data->gest_set);
  958. -           break;
  959. -       }
  960. -       case CY_GEN3:
  961. -       default: {
  962. -           pxy_gen3_data =
  963. -               (struct cyttsp_gen3_xydata_t *)(&g_xy_data);
  964. -           cyttsp_xdebug("TTSP Gen3 report:\n");
  965. -           cyttsp_xdebug("%02X %02X %02X\n", \
  966. -               pxy_gen3_data->hst_mode,
  967. -               pxy_gen3_data->tt_mode,
  968. -               pxy_gen3_data->tt_stat);
  969. -           cyttsp_xdebug("%04X %04X %02X  %02X", \
  970. -               pxy_gen3_data->x1,
  971. -               pxy_gen3_data->y1,
  972. -               pxy_gen3_data->z1, \
  973. -               pxy_gen3_data->touch12_id);
  974. -           cyttsp_xdebug("%04X %04X %02X\n", \
  975. -               pxy_gen3_data->x2, \
  976. -               pxy_gen3_data->y2, \
  977. -               pxy_gen3_data->z2);
  978. -           cyttsp_xdebug("%02X %02X %02X\n", \
  979. -               pxy_gen3_data->gest_cnt, \
  980. -               pxy_gen3_data->gest_id, \
  981. -               pxy_gen3_data->gest_set);
  982. -           cyttsp_xdebug("%04X %04X %02X  %02X\n", \
  983. -               pxy_gen3_data->x3, \
  984. -               pxy_gen3_data->y3, \
  985. -               pxy_gen3_data->z3, \
  986. -               pxy_gen3_data->touch34_id);
  987. -           cyttsp_xdebug("%04X %04X %02X\n", \
  988. -               pxy_gen3_data->x4, \
  989. -               pxy_gen3_data->y4, \
  990. -               pxy_gen3_data->z4);
  991. -           break;
  992. -       }
  993. -       }
  994. -   }
  995. -
  996. -   /* process the touches */
  997. -   switch (cur_tch) {
  998. -   case 4: {
  999. -       g_xy_data.x4 = be16_to_cpu(g_xy_data.x4);
  1000. -       g_xy_data.y4 = be16_to_cpu(g_xy_data.y4);
  1001. -       if (tilt)
  1002. -           FLIP_XY(g_xy_data.x4, g_xy_data.y4);
  1003. -
  1004. -       if (rev_x) {
  1005. -           g_xy_data.x4 =
  1006. -               INVERT_X(g_xy_data.x4, ts->platform_data->maxx);
  1007. -       }
  1008. -       if (rev_y) {
  1009. -           g_xy_data.y4 =
  1010. -               INVERT_X(g_xy_data.y4, ts->platform_data->maxy);
  1011. -       }
  1012. -        if (tilt)
  1013. -                        FLIP_XY(g_xy_data.x4, g_xy_data.y4);
  1014. -
  1015. -       if(g_xy_data.x4 <= 5) g_xy_data.x4 = 5;
  1016. -       if(g_xy_data.x4 >= ts->platform_data->maxx -5) g_xy_data.x4 = ts->platform_data->maxx - 5;
  1017. -       if(g_xy_data.y4 <= 5) g_xy_data.y4 = 5;
  1018. -       if(g_xy_data.y4 >= ts->platform_data->maxy -5) g_xy_data.y4 = ts->platform_data->maxy - 5;
  1019. -
  1020. -       id = GET_TOUCH4_ID(g_xy_data.touch34_id);
  1021. -       if (ts->platform_data->use_trk_id) {
  1022. -           cur_mt_pos[CY_MT_TCH4_IDX][CY_XPOS] =
  1023. -               g_xy_data.x4;
  1024. -           cur_mt_pos[CY_MT_TCH4_IDX][CY_YPOS] =
  1025. -               g_xy_data.y4;
  1026. -           cur_mt_z[CY_MT_TCH4_IDX] = g_xy_data.z4;
  1027. -       } else {
  1028. -           cur_mt_pos[id][CY_XPOS] = g_xy_data.x4;
  1029. -           cur_mt_pos[id][CY_YPOS] = g_xy_data.y4;
  1030. -           cur_mt_z[id] = g_xy_data.z4;
  1031. -       }
  1032. -       cur_mt_tch[CY_MT_TCH4_IDX] = id;
  1033. -       cur_trk[id] = CY_TCH;
  1034. -       if (ts->prv_st_tch[CY_ST_FNGR1_IDX] <
  1035. -           CY_NUM_TRK_ID) {
  1036. -           if (ts->prv_st_tch[CY_ST_FNGR1_IDX] == id) {
  1037. -               st_x1 = g_xy_data.x4;
  1038. -               st_y1 = g_xy_data.y4;
  1039. -               st_z1 = g_xy_data.z4;
  1040. -               cur_st_tch[CY_ST_FNGR1_IDX] = id;
  1041. -           } else if (ts->prv_st_tch[CY_ST_FNGR2_IDX] == id) {
  1042. -               st_x2 = g_xy_data.x4;
  1043. -               st_y2 = g_xy_data.y4;
  1044. -               st_z2 = g_xy_data.z4;
  1045. -               cur_st_tch[CY_ST_FNGR2_IDX] = id;
  1046. -           }
  1047. -       }
  1048. -       cyttsp_xdebug("4th XYZ:% 3d,% 3d,% 3d  ID:% 2d\n\n", \
  1049. -           g_xy_data.x4, g_xy_data.y4, g_xy_data.z4, \
  1050. -           (g_xy_data.touch34_id & 0x0F));
  1051. -       /* do not break */
  1052. -   }
  1053. -   case 3: {
  1054. -       g_xy_data.x3 = be16_to_cpu(g_xy_data.x3);
  1055. -       g_xy_data.y3 = be16_to_cpu(g_xy_data.y3);
  1056. -       if (tilt)
  1057. -           FLIP_XY(g_xy_data.x3, g_xy_data.y3);
  1058. -
  1059. -       if (rev_x) {
  1060. -           g_xy_data.x3 =
  1061. -               INVERT_X(g_xy_data.x3, ts->platform_data->maxx);
  1062. -       }
  1063. -       if (rev_y) {
  1064. -           g_xy_data.y3 =
  1065. -               INVERT_X(g_xy_data.y3, ts->platform_data->maxy);
  1066. -       }
  1067. -
  1068. -       if(g_xy_data.x3 <= 5) g_xy_data.x3 = 5;
  1069. -       if(g_xy_data.x3 >= ts->platform_data->maxx -5) g_xy_data.x3 = ts->platform_data->maxx - 5;
  1070. -       if(g_xy_data.y3 <= 5) g_xy_data.y3 = 5;
  1071. -       if(g_xy_data.y3 >= ts->platform_data->maxy -5) g_xy_data.y3 = ts->platform_data->maxy - 5;
  1072. -
  1073. -       id = GET_TOUCH3_ID(g_xy_data.touch34_id);
  1074. -       if (ts->platform_data->use_trk_id) {
  1075. -           cur_mt_pos[CY_MT_TCH3_IDX][CY_XPOS] =
  1076. -               g_xy_data.x3;
  1077. -           cur_mt_pos[CY_MT_TCH3_IDX][CY_YPOS] =
  1078. -               g_xy_data.y3;
  1079. -           cur_mt_z[CY_MT_TCH3_IDX] = g_xy_data.z3;
  1080. -       } else {
  1081. -           cur_mt_pos[id][CY_XPOS] = g_xy_data.x3;
  1082. -           cur_mt_pos[id][CY_YPOS] = g_xy_data.y3;
  1083. -           cur_mt_z[id] = g_xy_data.z3;
  1084. -       }
  1085. -       cur_mt_tch[CY_MT_TCH3_IDX] = id;
  1086. -       cur_trk[id] = CY_TCH;
  1087. -       if (ts->prv_st_tch[CY_ST_FNGR1_IDX] <
  1088. -           CY_NUM_TRK_ID) {
  1089. -           if (ts->prv_st_tch[CY_ST_FNGR1_IDX] == id) {
  1090. -               st_x1 = g_xy_data.x3;
  1091. -               st_y1 = g_xy_data.y3;
  1092. -               st_z1 = g_xy_data.z3;
  1093. -               cur_st_tch[CY_ST_FNGR1_IDX] = id;
  1094. -           } else if (ts->prv_st_tch[CY_ST_FNGR2_IDX] == id) {
  1095. -               st_x2 = g_xy_data.x3;
  1096. -               st_y2 = g_xy_data.y3;
  1097. -               st_z2 = g_xy_data.z3;
  1098. -               cur_st_tch[CY_ST_FNGR2_IDX] = id;
  1099. -           }
  1100. -       }
  1101. -       cyttsp_xdebug("3rd XYZ:% 3d,% 3d,% 3d  ID:% 2d\n", \
  1102. -           g_xy_data.x3, g_xy_data.y3, g_xy_data.z3, \
  1103. -           ((g_xy_data.touch34_id >> 4) & 0x0F));
  1104. -       /* do not break */
  1105. -   }
  1106. -   case 2: {
  1107. -       g_xy_data.x2 = be16_to_cpu(g_xy_data.x2);
  1108. -       g_xy_data.y2 = be16_to_cpu(g_xy_data.y2);
  1109. -       if (tilt)
  1110. -           FLIP_XY(g_xy_data.x2, g_xy_data.y2);
  1111. -
  1112. -       if (rev_x) {
  1113. -           g_xy_data.x2 =
  1114. -               INVERT_X(g_xy_data.x2, ts->platform_data->maxx);
  1115. -       }
  1116. -       if (rev_y) {
  1117. -           g_xy_data.y2 =
  1118. -               INVERT_X(g_xy_data.y2, ts->platform_data->maxy);
  1119. -       }
  1120. -
  1121. -       if(g_xy_data.x2 <= 5) g_xy_data.x2 = 5;
  1122. -       if(g_xy_data.x2 >= ts->platform_data->maxx -5) g_xy_data.x2 = ts->platform_data->maxx - 5;
  1123. -       if(g_xy_data.y2 <= 5) g_xy_data.y2 = 5;
  1124. -       if(g_xy_data.y2 >= ts->platform_data->maxy -5) g_xy_data.y2 = ts->platform_data->maxy - 5;
  1125. -
  1126. -       id = GET_TOUCH2_ID(g_xy_data.touch12_id);
  1127. -       if (ts->platform_data->use_trk_id) {
  1128. -           cur_mt_pos[CY_MT_TCH2_IDX][CY_XPOS] =
  1129. -               g_xy_data.x2;
  1130. -           cur_mt_pos[CY_MT_TCH2_IDX][CY_YPOS] =
  1131. -               g_xy_data.y2;
  1132. -           cur_mt_z[CY_MT_TCH2_IDX] = g_xy_data.z2;
  1133. -       } else {
  1134. -           cur_mt_pos[id][CY_XPOS] = g_xy_data.x2;
  1135. -           cur_mt_pos[id][CY_YPOS] = g_xy_data.y2;
  1136. -           cur_mt_z[id] = g_xy_data.z2;
  1137. -       }
  1138. -       cur_mt_tch[CY_MT_TCH2_IDX] = id;
  1139. -       cur_trk[id] = CY_TCH;
  1140. -       if (ts->prv_st_tch[CY_ST_FNGR1_IDX] <
  1141. -           CY_NUM_TRK_ID) {
  1142. -           if (ts->prv_st_tch[CY_ST_FNGR1_IDX] == id) {
  1143. -               st_x1 = g_xy_data.x2;
  1144. -               st_y1 = g_xy_data.y2;
  1145. -               st_z1 = g_xy_data.z2;
  1146. -               cur_st_tch[CY_ST_FNGR1_IDX] = id;
  1147. -           } else if (ts->prv_st_tch[CY_ST_FNGR2_IDX] == id) {
  1148. -               st_x2 = g_xy_data.x2;
  1149. -               st_y2 = g_xy_data.y2;
  1150. -               st_z2 = g_xy_data.z2;
  1151. -               cur_st_tch[CY_ST_FNGR2_IDX] = id;
  1152. -           }
  1153. -       }
  1154. -       cyttsp_xdebug("2nd XYZ:% 3d,% 3d,% 3d  ID:% 2d\n", \
  1155. -           g_xy_data.x2, g_xy_data.y2, g_xy_data.z2, \
  1156. -           (g_xy_data.touch12_id & 0x0F));
  1157. -       /* do not break */
  1158. -   }
  1159. -   case 1: {
  1160. -       g_xy_data.x1 = be16_to_cpu(g_xy_data.x1);
  1161. -       g_xy_data.y1 = be16_to_cpu(g_xy_data.y1);
  1162. -       if (tilt)
  1163. -           FLIP_XY(g_xy_data.x1, g_xy_data.y1);
  1164. -
  1165. -       if (rev_x) {
  1166. -           g_xy_data.x1 =
  1167. -               INVERT_X(g_xy_data.x1, ts->platform_data->maxx);
  1168. -       }
  1169. -       if (rev_y) {
  1170. -           g_xy_data.y1 =
  1171. -               INVERT_X(g_xy_data.y1, ts->platform_data->maxy);
  1172. -       }
  1173. -
  1174. -       if(g_xy_data.x1 <= 5) g_xy_data.x1 = 5;
  1175. -       if(g_xy_data.x1 >= ts->platform_data->maxx -5) g_xy_data.x1 = ts->platform_data->maxx - 5;
  1176. -       if(g_xy_data.y1 <= 5) g_xy_data.y1 = 5;
  1177. -       if(g_xy_data.y1 >= ts->platform_data->maxy -5) g_xy_data.y1 = ts->platform_data->maxy - 5;
  1178. -
  1179. -       id = GET_TOUCH1_ID(g_xy_data.touch12_id);
  1180. -       if (ts->platform_data->use_trk_id) {
  1181. -           cur_mt_pos[CY_MT_TCH1_IDX][CY_XPOS] =
  1182. -               g_xy_data.x1;
  1183. -           cur_mt_pos[CY_MT_TCH1_IDX][CY_YPOS] =
  1184. -               g_xy_data.y1;
  1185. -           cur_mt_z[CY_MT_TCH1_IDX] = g_xy_data.z1;
  1186. -       } else {
  1187. -           cur_mt_pos[id][CY_XPOS] = g_xy_data.x1;
  1188. -           cur_mt_pos[id][CY_YPOS] = g_xy_data.y1;
  1189. -           cur_mt_z[id] = g_xy_data.z1;
  1190. -       }
  1191. -       cur_mt_tch[CY_MT_TCH1_IDX] = id;
  1192. -       cur_trk[id] = CY_TCH;
  1193. -       if (ts->prv_st_tch[CY_ST_FNGR1_IDX] <
  1194. -           CY_NUM_TRK_ID) {
  1195. -           if (ts->prv_st_tch[CY_ST_FNGR1_IDX] == id) {
  1196. -               st_x1 = g_xy_data.x1;
  1197. -               st_y1 = g_xy_data.y1;
  1198. -               st_z1 = g_xy_data.z1;
  1199. -               cur_st_tch[CY_ST_FNGR1_IDX] = id;
  1200. -           } else if (ts->prv_st_tch[CY_ST_FNGR2_IDX] == id) {
  1201. -               st_x2 = g_xy_data.x1;
  1202. -               st_y2 = g_xy_data.y1;
  1203. -               st_z2 = g_xy_data.z1;
  1204. -               cur_st_tch[CY_ST_FNGR2_IDX] = id;
  1205. -           }
  1206. -       }
  1207. -       cyttsp_xdebug("1st XYZ:% 3d,% 3d,% 3d  ID:% 2d\n", \
  1208. -           g_xy_data.x1, g_xy_data.y1, g_xy_data.z1, \
  1209. -           ((g_xy_data.touch12_id >> 4) & 0x0F));
  1210. -       break;
  1211. -   }
  1212. -   case 0:
  1213. -   default:{
  1214. -       break;
  1215. -   }
  1216. -   }
  1217. -
  1218. -   /* handle Single Touch signals */
  1219. -   if (ts->platform_data->use_st) {
  1220. -       cyttsp_xdebug("ST STEP 0 - ST1 ID=%d  ST2 ID=%d\n", \
  1221. -           cur_st_tch[CY_ST_FNGR1_IDX], \
  1222. -           cur_st_tch[CY_ST_FNGR2_IDX]);
  1223. -       if (cur_st_tch[CY_ST_FNGR1_IDX] > CY_NUM_TRK_ID) {
  1224. -           /* reassign finger 1 and 2 positions to new tracks */
  1225. -           if (cur_tch > 0) {
  1226. -               /* reassign st finger1 */
  1227. -               if (ts->platform_data->use_trk_id) {
  1228. -                   id = CY_MT_TCH1_IDX;
  1229. -                   cur_st_tch[CY_ST_FNGR1_IDX] = cur_mt_tch[id];
  1230. -               } else {
  1231. -                   id = GET_TOUCH1_ID(g_xy_data.touch12_id);
  1232. -                   cur_st_tch[CY_ST_FNGR1_IDX] = id;
  1233. -               }
  1234. -               st_x1 = cur_mt_pos[id][CY_XPOS];
  1235. -               st_y1 = cur_mt_pos[id][CY_YPOS];
  1236. -               st_z1 = cur_mt_z[id];
  1237. -               cyttsp_xdebug("ST STEP 1 - ST1 ID=%3d\n", \
  1238. -                   cur_st_tch[CY_ST_FNGR1_IDX]);
  1239. -               if ((cur_tch > 1) &&
  1240. -                   (cur_st_tch[CY_ST_FNGR2_IDX] >
  1241. -                   CY_NUM_TRK_ID)) {
  1242. -                   /* reassign st finger2 */
  1243. -                   if (cur_tch > 1) {
  1244. -                       if (ts->platform_data->use_trk_id) {
  1245. -                           id = CY_MT_TCH2_IDX;
  1246. -                           cur_st_tch[CY_ST_FNGR2_IDX] = cur_mt_tch[id];
  1247. -                       } else {
  1248. -                           id = GET_TOUCH2_ID(g_xy_data.touch12_id);
  1249. -                           cur_st_tch[CY_ST_FNGR2_IDX] = id;
  1250. -                       }
  1251. -                       st_x2 = cur_mt_pos[id][CY_XPOS];
  1252. -                       st_y2 = cur_mt_pos[id][CY_YPOS];
  1253. -                       st_z2 = cur_mt_z[id];
  1254. -                       cyttsp_xdebug("ST STEP 2 - ST2 ID=%3d\n", \
  1255. -                           cur_st_tch[CY_ST_FNGR2_IDX]);
  1256. -                   }
  1257. -               }
  1258. -           }
  1259. -       } else if (cur_st_tch[CY_ST_FNGR2_IDX] > CY_NUM_TRK_ID) {
  1260. -           if (cur_tch > 1) {
  1261. -               /* reassign st finger2 */
  1262. -               if (ts->platform_data->use_trk_id) {
  1263. -                   /* reassign st finger2 */
  1264. -                   id = CY_MT_TCH2_IDX;
  1265. -                   cur_st_tch[CY_ST_FNGR2_IDX] =
  1266. -                       cur_mt_tch[id];
  1267. -               } else {
  1268. -                   /* reassign st finger2 */
  1269. -                   id = GET_TOUCH2_ID(g_xy_data.touch12_id);
  1270. -                   cur_st_tch[CY_ST_FNGR2_IDX] = id;
  1271. -               }
  1272. -               st_x2 = cur_mt_pos[id][CY_XPOS];
  1273. -               st_y2 = cur_mt_pos[id][CY_YPOS];
  1274. -               st_z2 = cur_mt_z[id];
  1275. -               cyttsp_xdebug("ST STEP 3 - ST2 ID=%3d\n", \
  1276. -                   cur_st_tch[CY_ST_FNGR2_IDX]);
  1277. -           }
  1278. -       }
  1279. -       /* if the 1st touch is missing and there is a 2nd touch,
  1280. -        * then set the 1st touch to 2nd touch and terminate 2nd touch
  1281. -        */
  1282. -       if ((cur_st_tch[CY_ST_FNGR1_IDX] > CY_NUM_TRK_ID) &&
  1283. -           (cur_st_tch[CY_ST_FNGR2_IDX] < CY_NUM_TRK_ID)) {
  1284. -           st_x1 = st_x2;
  1285. -           st_y1 = st_y2;
  1286. -           st_z1 = st_z2;
  1287. -           cur_st_tch[CY_ST_FNGR1_IDX] =
  1288. -               cur_st_tch[CY_ST_FNGR2_IDX];
  1289. -           cur_st_tch[CY_ST_FNGR2_IDX] =
  1290. -               CY_IGNR_TCH;
  1291. -       }
  1292. -       /* if the 2nd touch ends up equal to the 1st touch,
  1293. -        * then just report a single touch */
  1294. -       if (cur_st_tch[CY_ST_FNGR1_IDX] ==
  1295. -           cur_st_tch[CY_ST_FNGR2_IDX]) {
  1296. -           cur_st_tch[CY_ST_FNGR2_IDX] =
  1297. -               CY_IGNR_TCH;
  1298. -       }
  1299. -       /* set Single Touch current event signals */
  1300. -       if (cur_st_tch[CY_ST_FNGR1_IDX] < CY_NUM_TRK_ID) {
  1301. -           input_report_abs(ts->input,
  1302. -               ABS_X, st_x1);
  1303. -           input_report_abs(ts->input,
  1304. -               ABS_Y, st_y1);
  1305. -           input_report_abs(ts->input,
  1306. -               ABS_PRESSURE, st_z1);
  1307. -           input_report_key(ts->input,
  1308. -               BTN_TOUCH,
  1309. -               CY_TCH);
  1310. -           input_report_abs(ts->input,
  1311. -               ABS_TOOL_WIDTH,
  1312. -               curr_tool_width);
  1313. -           cyttsp_debug("ST->F1:%3d X:%3d Y:%3d Z:%3d\n", \
  1314. -               cur_st_tch[CY_ST_FNGR1_IDX], \
  1315. -               st_x1, st_y1, st_z1);
  1316. -           if (cur_st_tch[CY_ST_FNGR2_IDX] < CY_NUM_TRK_ID) {
  1317. -               input_report_key(ts->input, BTN_2, CY_TCH);
  1318. -               input_report_abs(ts->input, ABS_HAT0X, st_x2);
  1319. -               input_report_abs(ts->input, ABS_HAT0Y, st_y2);
  1320. -               cyttsp_debug("ST->F2:%3d X:%3d Y:%3d Z:%3d\n", \
  1321. -                   cur_st_tch[CY_ST_FNGR2_IDX],
  1322. -                   st_x2, st_y2, st_z2);
  1323. -           } else {
  1324. -               input_report_key(ts->input,
  1325. -                   BTN_2,
  1326. -                   CY_NTCH);
  1327. -           }
  1328. -       } else {
  1329. -           input_report_abs(ts->input, ABS_PRESSURE, CY_NTCH);
  1330. -           input_report_key(ts->input, BTN_TOUCH, CY_NTCH);
  1331. -           input_report_key(ts->input, BTN_2, CY_NTCH);
  1332. -       }
  1333. -       /* update platform data for the current single touch info */
  1334. -       ts->prv_st_tch[CY_ST_FNGR1_IDX] = cur_st_tch[CY_ST_FNGR1_IDX];
  1335. -       ts->prv_st_tch[CY_ST_FNGR2_IDX] = cur_st_tch[CY_ST_FNGR2_IDX];
  1336. -
  1337. -   }
  1338. -
  1339. -   /* handle Multi-touch signals */
  1340. -   if (ts->platform_data->use_mt) {
  1341. -       if (ts->platform_data->use_trk_id) {
  1342. -           /* terminate any previous touch where the track
  1343. -            * is missing from the current event */
  1344. -           for (id = 0; id < CY_NUM_TRK_ID; id++) {
  1345. -               if ((ts->act_trk[id] != CY_NTCH) &&
  1346. -                   (cur_trk[id] == CY_NTCH)) {
  1347. -                   input_report_abs(ts->input,
  1348. -                       ABS_MT_TRACKING_ID,
  1349. -                       id);
  1350. -                   input_report_abs(ts->input,
  1351. -                       ABS_MT_TOUCH_MAJOR,
  1352. -                       CY_NTCH);
  1353. -                   input_report_abs(ts->input,
  1354. -                       ABS_MT_WIDTH_MAJOR,
  1355. -                       curr_tool_width);
  1356. -                   input_report_abs(ts->input,
  1357. -                       ABS_MT_POSITION_X,
  1358. -                       ts->prv_mt_pos[id][CY_XPOS]);
  1359. -                   input_report_abs(ts->input,
  1360. -                       ABS_MT_POSITION_Y,
  1361. -                       ts->prv_mt_pos[id][CY_YPOS]);
  1362. -                   CY_MT_SYNC(ts->input);
  1363. -                   ts->act_trk[id] = CY_NTCH;
  1364. -                   ts->prv_mt_pos[id][CY_XPOS] = 0;
  1365. -                   ts->prv_mt_pos[id][CY_YPOS] = 0;
  1366. -               }
  1367. -           }
  1368. -           /* set Multi-Touch current event signals */
  1369. -           for (id = 0; id < CY_NUM_MT_TCH_ID; id++) {
  1370. -               if (cur_mt_tch[id] < CY_NUM_TRK_ID) {
  1371. -                   input_report_abs(ts->input,
  1372. -                       ABS_MT_TRACKING_ID,
  1373. -                       cur_mt_tch[id]);
  1374. -                   input_report_abs(ts->input,
  1375. -                       ABS_MT_TOUCH_MAJOR,
  1376. -                       cur_mt_z[id]);
  1377. -                   input_report_abs(ts->input,
  1378. -                       ABS_MT_WIDTH_MAJOR,
  1379. -                       curr_tool_width);
  1380. -                   input_report_abs(ts->input,
  1381. -                       ABS_MT_POSITION_X,
  1382. -                       cur_mt_pos[id][CY_XPOS]);
  1383. -                   input_report_abs(ts->input,
  1384. -                       ABS_MT_POSITION_Y,
  1385. -                       cur_mt_pos[id][CY_YPOS]);
  1386. -                   CY_MT_SYNC(ts->input);
  1387. -                   ts->act_trk[id] = CY_TCH;
  1388. -                   ts->prv_mt_pos[id][CY_XPOS] =
  1389. -                       cur_mt_pos[id][CY_XPOS];
  1390. -                   ts->prv_mt_pos[id][CY_YPOS] =
  1391. -                       cur_mt_pos[id][CY_YPOS];
  1392. -               }
  1393. -           }
  1394. -       } else {
  1395. -           /* set temporary track array elements to voids */
  1396. -           for (id = 0; id < CY_NUM_MT_TCH_ID; id++) {
  1397. -               tmp_trk[id] = CY_IGNR_TCH;
  1398. -               snd_trk[id] = CY_IGNR_TCH;
  1399. -           }
  1400. -
  1401. -           /* get what is currently active */
  1402. -           for (i = 0, id = 0;
  1403. -               id < CY_NUM_TRK_ID && i < CY_NUM_MT_TCH_ID;
  1404. -               id++) {
  1405. -               if (cur_trk[id] == CY_TCH) {
  1406. -                   /* only incr counter if track found */
  1407. -                   tmp_trk[i] = id;
  1408. -                   i++;
  1409. -               }
  1410. -           }
  1411. -           cyttsp_xdebug("T1: t0=%d, t1=%d, t2=%d, t3=%d\n", \
  1412. -               tmp_trk[0], tmp_trk[1], tmp_trk[2], \
  1413. -               tmp_trk[3]);
  1414. -           cyttsp_xdebug("T1: p0=%d, p1=%d, p2=%d, p3=%d\n", \
  1415. -               ts->prv_mt_tch[0], ts->prv_mt_tch[1], \
  1416. -               ts->prv_mt_tch[2], ts->prv_mt_tch[3]);
  1417. -
  1418. -           /* pack in still active previous touches */
  1419. -           for (id = 0, prv_tch = 0;
  1420. -               id < CY_NUM_MT_TCH_ID; id++) {
  1421. -               if (tmp_trk[id] < CY_NUM_TRK_ID) {
  1422. -                   if (cyttsp_inlist(ts->prv_mt_tch,
  1423. -                       tmp_trk[id], &loc,
  1424. -                       CY_NUM_MT_TCH_ID)) {
  1425. -                       loc &= CY_NUM_MT_TCH_ID - 1;
  1426. -                       snd_trk[loc] = tmp_trk[id];
  1427. -                       prv_tch++;
  1428. -                       cyttsp_xdebug("inlist s[%d]=%d t[%d]=%d l=%d p=%d\n", \
  1429. -                           loc, snd_trk[loc], \
  1430. -                           id, tmp_trk[id], \
  1431. -                           loc, prv_tch);
  1432. -                   } else {
  1433. -                       cyttsp_xdebug("not inlist s[%d]=%d t[%d]=%d l=%d \n", \
  1434. -                           id, snd_trk[id], \
  1435. -                           id, tmp_trk[id], \
  1436. -                           loc);
  1437. -                   }
  1438. -               }
  1439. -           }
  1440. -           cyttsp_xdebug("S1: s0=%d, s1=%d, s2=%d, s3=%d p=%d\n", \
  1441. -               snd_trk[0], snd_trk[1], snd_trk[2], \
  1442. -               snd_trk[3], prv_tch);
  1443. -
  1444. -           /* pack in new touches */
  1445. -           for (id = 0; id < CY_NUM_MT_TCH_ID; id++) {
  1446. -               if (tmp_trk[id] < CY_NUM_TRK_ID) {
  1447. -                   if (!cyttsp_inlist(snd_trk, tmp_trk[id], &loc, CY_NUM_MT_TCH_ID)) {
  1448. -                       cyttsp_xdebug("not inlist t[%d]=%d l=%d\n", \
  1449. -                           id, tmp_trk[id], loc);
  1450. -                       if (cyttsp_next_avail_inlist(snd_trk, &loc, CY_NUM_MT_TCH_ID)) {
  1451. -                           loc &= CY_NUM_MT_TCH_ID - 1;
  1452. -                           snd_trk[loc] = tmp_trk[id];
  1453. -                           cyttsp_xdebug("put inlist s[%d]=%d t[%d]=%d\n",
  1454. -                               loc, snd_trk[loc], id, tmp_trk[id]);
  1455. -                       }
  1456. -                   } else {
  1457. -                       cyttsp_xdebug("is in list s[%d]=%d t[%d]=%d loc=%d\n", \
  1458. -                           id, snd_trk[id], id, tmp_trk[id], loc);
  1459. -                   }
  1460. -               }
  1461. -           }
  1462. -           cyttsp_xdebug("S2: s0=%d, s1=%d, s2=%d, s3=%d\n", \
  1463. -               snd_trk[0], snd_trk[1],
  1464. -               snd_trk[2], snd_trk[3]);
  1465. -
  1466. -           /* sync motion event signals for each current touch */
  1467. -           for (id = 0; id < CY_NUM_MT_TCH_ID; id++) {
  1468. -               /* z will either be 0 (NOTOUCH) or
  1469. -                * some pressure (TOUCH) */
  1470. -               cyttsp_xdebug("MT0 prev[%d]=%d temp[%d]=%d send[%d]=%d\n", \
  1471. -                   id, ts->prv_mt_tch[id], \
  1472. -                   id, tmp_trk[id], \
  1473. -                   id, snd_trk[id]);
  1474. -               if (snd_trk[id] < CY_NUM_TRK_ID) {
  1475. -                   input_report_abs(ts->input,
  1476. -                       ABS_MT_TOUCH_MAJOR,
  1477. -                       cur_mt_z[snd_trk[id]]);
  1478. -                   input_report_abs(ts->input,
  1479. -                       ABS_MT_WIDTH_MAJOR,
  1480. -                       curr_tool_width);
  1481. -                   input_report_abs(ts->input,
  1482. -                       ABS_MT_POSITION_X,
  1483. -                       cur_mt_pos[snd_trk[id]][CY_XPOS]);
  1484. -                   input_report_abs(ts->input,
  1485. -                       ABS_MT_POSITION_Y,
  1486. -                       cur_mt_pos[snd_trk[id]][CY_YPOS]);
  1487. -                   CY_MT_SYNC(ts->input);
  1488. -                   cyttsp_debug("MT1->TID:%2d X:%3d Y:%3d Z:%3d touch-sent\n", \
  1489. -                       snd_trk[id], \
  1490. -                       cur_mt_pos[snd_trk[id]][CY_XPOS], \
  1491. -                       cur_mt_pos[snd_trk[id]][CY_YPOS], \
  1492. -                       cur_mt_z[snd_trk[id]]);
  1493. -               } else if (ts->prv_mt_tch[id] < CY_NUM_TRK_ID) {
  1494. -                   /* void out this touch */
  1495. -                   input_report_abs(ts->input,
  1496. -                       ABS_MT_TOUCH_MAJOR,
  1497. -                       CY_NTCH);
  1498. -                   input_report_abs(ts->input,
  1499. -                       ABS_MT_WIDTH_MAJOR,
  1500. -                       curr_tool_width);
  1501. -                   input_report_abs(ts->input,
  1502. -                       ABS_MT_POSITION_X,
  1503. -                       ts->prv_mt_pos[ts->prv_mt_tch[id]][CY_XPOS]);
  1504. -                   input_report_abs(ts->input,
  1505. -                       ABS_MT_POSITION_Y,
  1506. -                       ts->prv_mt_pos[ts->prv_mt_tch[id]][CY_YPOS]);
  1507. -                   CY_MT_SYNC(ts->input);
  1508. -                   cyttsp_debug("MT2->TID:%2d X:%3d Y:%3d Z:%3d lift off-sent\n", \
  1509. -                       ts->prv_mt_tch[id], \
  1510. -                       ts->prv_mt_pos[ts->prv_mt_tch[id]][CY_XPOS], \
  1511. -                       ts->prv_mt_pos[ts->prv_mt_tch[id]][CY_YPOS], \
  1512. -                       CY_NTCH);
  1513. -               } else {
  1514. -                   /* do not stuff any signals for this
  1515. -                    * previously and currently
  1516. -                    * void touches */
  1517. -                   cyttsp_xdebug("MT3->send[%d]=%d - No touch - NOT sent\n", \
  1518. -                           id, snd_trk[id]);
  1519. -               }
  1520. -           }
  1521. -
  1522. -           /* save current posted tracks to
  1523. -            * previous track memory */
  1524. -           for (id = 0; id < CY_NUM_MT_TCH_ID; id++) {
  1525. -               if (snd_trk[id] < CY_NUM_TRK_ID) {
  1526. -                   ts->prv_mt_tch[id] = snd_trk[id];
  1527. -                   ts->prv_mt_pos[snd_trk[id]][CY_XPOS] =
  1528. -                       cur_mt_pos[snd_trk[id]][CY_XPOS];
  1529. -                   ts->prv_mt_pos[snd_trk[id]][CY_YPOS] =
  1530. -                       cur_mt_pos[snd_trk[id]][CY_YPOS];
  1531. -                   cyttsp_xdebug("MT4->TID:%2d X:%3d Y:%3d Z:%3d save for previous\n", \
  1532. -                       snd_trk[id], \
  1533. -                       ts->prv_mt_pos[snd_trk[id]][CY_XPOS], \
  1534. -                       ts->prv_mt_pos[snd_trk[id]][CY_YPOS], \
  1535. -                       CY_NTCH);
  1536. -               }
  1537. -           }
  1538. -           for (id = 0; id < CY_NUM_TRK_ID; id++)
  1539. -               ts->act_trk[id] = CY_NTCH;
  1540. -           for (id = 0; id < CY_NUM_MT_TCH_ID; id++) {
  1541. -               if (snd_trk[id] < CY_NUM_TRK_ID)
  1542. -                   ts->act_trk[snd_trk[id]] = CY_TCH;
  1543. -           }
  1544. -       }
  1545. -   }
  1546. -
  1547. -   /* handle gestures */
  1548. -   if (ts->platform_data->use_gestures) {
  1549. -       if (g_xy_data.gest_id) {
  1550. -           input_report_key(ts->input,
  1551. -               BTN_3, CY_TCH);
  1552. -           input_report_abs(ts->input,
  1553. -               ABS_HAT1X, g_xy_data.gest_id);
  1554. -           input_report_abs(ts->input,
  1555. -               ABS_HAT2X, GET_NUM_TOUCHES(g_xy_data.tt_stat));
  1556. -           input_report_abs(ts->input,
  1557. -               ABS_HAT2Y, g_xy_data.gest_cnt);
  1558. -       }
  1559. -   }
  1560. -
  1561. -   /* signal the view motion event */
  1562. -   input_sync(ts->input);
  1563. -
  1564. -   for (id = 0; id < CY_NUM_TRK_ID; id++) {
  1565. -       /* update platform data for the current MT information */
  1566. -       ts->act_trk[id] = cur_trk[id];
  1567. -   }
  1568. -
  1569. -exit_xy_worker:
  1570. -   if (cyttsp_disable_touch) {
  1571. -       /* Turn off the touch interrupts */
  1572. -       cyttsp_debug("Not enabling touch\n");
  1573. -   } else {
  1574. -       if (ts->client->irq == 0) {
  1575. -           /* restart event timer */
  1576. -           mod_timer(&ts->timer, jiffies + TOUCHSCREEN_TIMEOUT);
  1577. -       } else {
  1578. -           /* re-enable the interrupt after processing */
  1579. -           enable_irq(ts->client->irq);
  1580. -       }
  1581. -   }
  1582. -   mutex_unlock(&thread_mutex);
  1583. -   return;
  1584. -}
  1585. -
  1586. -static int cyttsp_inlist(u16 prev_track[], u8 cur_trk_id,
  1587. -           u8 *prev_loc, u8 num_touches)
  1588. -{
  1589. -   u8 id = 0;
  1590. -
  1591. -   *prev_loc = CY_IGNR_TCH;
  1592. -
  1593. -       cyttsp_xdebug("IN p[%d]=%d c=%d n=%d loc=%d\n", \
  1594. -           id, prev_track[id], cur_trk_id, \
  1595. -           num_touches, *prev_loc);
  1596. -   for (id = 0, *prev_loc = CY_IGNR_TCH;
  1597. -       (id < num_touches); id++) {
  1598. -       cyttsp_xdebug("p[%d]=%d c=%d n=%d loc=%d\n", \
  1599. -           id, prev_track[id], cur_trk_id, \
  1600. -           num_touches, *prev_loc);
  1601. -       if (prev_track[id] == cur_trk_id) {
  1602. -           *prev_loc = id;
  1603. -           break;
  1604. -       }
  1605. -   }
  1606. -   cyttsp_xdebug("OUT p[%d]=%d c=%d n=%d loc=%d\n", \
  1607. -       id, prev_track[id], cur_trk_id, num_touches, *prev_loc);
  1608. -
  1609. -   return ((*prev_loc < CY_NUM_TRK_ID) ? true : false);
  1610. -}
  1611. -
  1612. -static int cyttsp_next_avail_inlist(u16 cur_trk[],
  1613. -           u8 *new_loc, u8 num_touches)
  1614. -{
  1615. -   u8 id;
  1616. -
  1617. -   for (id = 0, *new_loc = CY_IGNR_TCH;
  1618. -       (id < num_touches); id++) {
  1619. -       if (cur_trk[id] > CY_NUM_TRK_ID) {
  1620. -           *new_loc = id;
  1621. -           break;
  1622. -       }
  1623. -   }
  1624. -
  1625. -   return ((*new_loc < CY_NUM_TRK_ID) ? true : false);
  1626. -}
  1627. -
  1628. -/* Timer function used as dummy interrupt driver */
  1629. -static void cyttsp_timer(unsigned long handle)
  1630. -{
  1631. -   struct cyttsp *ts = (struct cyttsp *) handle;
  1632. -
  1633. -   cyttsp_xdebug("TTSP Device timer event\n");
  1634. -
  1635. -   /* schedule motion signal handling */
  1636. -   queue_work(cyttsp_ts_wq, &ts->work);
  1637. -
  1638. -   return;
  1639. -}
  1640. -
  1641. -
  1642. -
  1643. -/* ************************************************************************
  1644. - * ISR function. This function is general, initialized in drivers init
  1645. - * function
  1646. - * ************************************************************************ */
  1647. -static irqreturn_t cyttsp_irq(int irq, void *handle)
  1648. -{
  1649. -   struct cyttsp *ts = (struct cyttsp *) handle;
  1650. -   cyttsp_xdebug("%s: Got IRQ\n", CY_I2C_NAME);
  1651. -   /* disable further interrupts until this interrupt is processed */
  1652. -   disable_irq_nosync(ts->client->irq);
  1653. -   /* schedule motion signal handling */
  1654. -   queue_work(cyttsp_ts_wq, &ts->work);
  1655. -
  1656. -   return IRQ_HANDLED;
  1657. -}
  1658. -
  1659. -/* ************************************************************************
  1660. - * Probe initialization functions
  1661. - * ************************************************************************ */
  1662. -static int cyttsp_wait_for_i2c(struct cyttsp *ts)
  1663. -{
  1664. -   int retval = 0;
  1665. -   u8 data = 99;
  1666. -   u8 tries = 0;
  1667. -
  1668. -   do {
  1669. -       tries++;
  1670. -       retval = i2c_smbus_read_i2c_block_data(ts->client,
  1671. -                           CY_REG_BASE,
  1672. -                           1,
  1673. -                           (u8 *)&data);
  1674. -       if (retval > 0 ){
  1675. -           break;
  1676. -       } else {
  1677. -           if(tries > 20 ){
  1678. -               retval = -99;
  1679. -               break;
  1680. -           } else {
  1681. -               msleep(100);
  1682. -           }
  1683. -       }
  1684. -
  1685. -   }while(1);
  1686. -
  1687. -   return retval;
  1688. -}
  1689. -
  1690. -static int cyttsp_putbl(struct cyttsp *ts, int show,
  1691. -           int show_status, int show_version, int show_cid)
  1692. -{
  1693. -   int retval = CY_OK;
  1694. -
  1695. -   int num_bytes = (show_status * 3) + (show_version * 6) + (show_cid * 3);
  1696. -
  1697. -   if (show_cid)
  1698. -       num_bytes = sizeof(struct cyttsp_bootloader_data_t);
  1699. -   else if (show_version)
  1700. -       num_bytes = sizeof(struct cyttsp_bootloader_data_t) - 3;
  1701. -   else
  1702. -       num_bytes = sizeof(struct cyttsp_bootloader_data_t) - 9;
  1703. -
  1704. -   if (show) {
  1705. -       retval = i2c_smbus_read_i2c_block_data(ts->client,
  1706. -           CY_REG_BASE, num_bytes, (u8 *)&g_bl_data);
  1707. -       if (show_status) {
  1708. -           cyttsp_debug("BL%d: f=%02X s=%02X err=%02X bl=%02X%02X bld=%02X%02X\n", \
  1709. -               show, \
  1710. -               g_bl_data.bl_file, \
  1711. -               g_bl_data.bl_status, \
  1712. -               g_bl_data.bl_error, \
  1713. -               g_bl_data.blver_hi, g_bl_data.blver_lo, \
  1714. -               g_bl_data.bld_blver_hi, g_bl_data.bld_blver_lo);
  1715. -       }
  1716. -       if (show_version) {
  1717. -           cyttsp_debug("BL%d: ttspver=0x%02X%02X appid=0x%02X%02X appver=0x%02X%02X\n", \
  1718. -               show, \
  1719. -               g_bl_data.ttspver_hi, g_bl_data.ttspver_lo, \
  1720. -               g_bl_data.appid_hi, g_bl_data.appid_lo, \
  1721. -               g_bl_data.appver_hi, g_bl_data.appver_lo);
  1722. -       }
  1723. -       if (show_cid) {
  1724. -           cyttsp_debug("BL%d: cid=0x%02X%02X%02X\n", \
  1725. -               show, \
  1726. -               g_bl_data.cid_0, \
  1727. -               g_bl_data.cid_1, \
  1728. -               g_bl_data.cid_2);
  1729. -       }
  1730. -       msleep(CY_DLY_DFLT);
  1731. -   }
  1732. -
  1733. -   return retval;
  1734. -}
  1735. -
  1736. -#define CY_MAX_I2C_LEN 256
  1737. -#define CY_MAX_TRY     10
  1738. -#define CY_BL_PAGE_SIZE    16
  1739. -#define CY_BL_NUM_PAGES    5
  1740. -#define SI_COMMAND_COMPLETED    0x02
  1741. -#define SI_COMMAND_PASS         0x80
  1742. -static int cyttsp_calibrate(struct cyttsp *ts)
  1743. -{
  1744. -    u8  gesture_setup = 0x00;
  1745. -    u8  host_reg  = CY_SYSINFO_MODE;
  1746. -    u8  host_mode = 0x00;
  1747. -    int ret_val   = CY_OK;
  1748. -    int tries     = 0;
  1749. -
  1750. -
  1751. -    atomic_set(&ts->irq_enabled, 0);
  1752. -    disable_irq(ts->client->irq);
  1753. -    dev_info(&ts->client->dev, "%s() - Starting Touch panel Calibration: Switch to System Information mode.\n", __FUNCTION__);
  1754. -
  1755. -    msleep(100);
  1756. -
  1757. -    for (tries = 0; tries < 10; tries++)
  1758. -    {
  1759. -        ret_val = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE, sizeof(host_reg), &host_reg);
  1760. -        if (0 == ret_val)
  1761. -        {
  1762. -            break;
  1763. -        }
  1764. -
  1765. -        msleep(100);
  1766. -    }
  1767. -
  1768. -    if (0 != ret_val)
  1769. -    {
  1770. -        dev_err(&ts->client->dev, "%s() - ERROR: Could not put the Touch Panel in System Information mode.\n", __FUNCTION__);
  1771. -        goto error_return;
  1772. -    }
  1773. -
  1774. -    msleep(100);
  1775. -
  1776. -    for (tries = 0; tries < 10; tries++)
  1777. -    {
  1778. -        ret_val = i2c_smbus_read_i2c_block_data(ts->client, CY_REG_BASE, sizeof(host_mode), (u8 *)&host_mode);
  1779. -
  1780. -        if ((0 <= ret_val) && (CY_SYSINFO_MODE == (host_mode & 0x70)))
  1781. -        {
  1782. -            break;
  1783. -        }
  1784. -
  1785. -        msleep(100);
  1786. -    }
  1787. -
  1788. -    if (0 > ret_val)
  1789. -    {
  1790. -        dev_err(&ts->client->dev, "%s() - ERROR: Could not read from the Host Mode register.\n", __FUNCTION__);
  1791. -        goto error_restore_mode;
  1792. -    }
  1793. -
  1794. -    if (10 == tries)
  1795. -    {
  1796. -        dev_err(&ts->client->dev, "%s() - ERROR: Timed Out when trying to read from the Host Mode register.\n", __FUNCTION__);
  1797. -        goto error_restore_mode;
  1798. -    }
  1799. -
  1800. -   dev_info(&ts->client->dev, "%s() - Touch Panel is now in System Information Mode.\n", __FUNCTION__);
  1801. -
  1802. -    ret_val = i2c_smbus_read_i2c_block_data( ts->client, CY_REG_BASE, sizeof(g_sysinfo_data), (u8*)&g_sysinfo_data);
  1803. -    if (0 > ret_val)
  1804. -    {
  1805. -        dev_err(&ts->client->dev, "%s() - ERROR: Could not read System information data.\n", __FUNCTION__);
  1806. -        goto error_restore_mode;
  1807. -    }
  1808. -
  1809. -    host_reg = 0x00;
  1810. -    ret_val = i2c_smbus_write_i2c_block_data(ts->client, 0x03, sizeof(host_reg), &host_reg);
  1811. -    if (0 > ret_val)
  1812. -    {
  1813. -        dev_err(&ts->client->dev, "%s() - ERROR: Could not set Calibration Flags.\n", __FUNCTION__);
  1814. -        goto error_restore_mode;
  1815. -    }
  1816. -
  1817. -    host_reg = 0x20;
  1818. -    ret_val = i2c_smbus_write_i2c_block_data(ts->client, 0x02, sizeof(host_reg), &host_reg);
  1819. -    if (0 > ret_val)
  1820. -    {
  1821. -        dev_err(&ts->client->dev, "%s() - ERROR: Could not write the Calibration Command to the MFG Command register.\n", __FUNCTION__);
  1822. -        goto error_restore_mode;
  1823. -    }
  1824. -
  1825. -    for (tries = 0; tries < 40; tries++)
  1826. -    {
  1827. -        ret_val = i2c_smbus_read_i2c_block_data(ts->client, CY_REG_BASE, sizeof(g_sysinfo_data), (u8 *)&g_sysinfo_data);
  1828. -
  1829. -        if (0 <= ret_val)
  1830. -        {
  1831. -            dev_dbg(&ts->client->dev, "%s() - MFG Command Register = 0x%02X\n", __FUNCTION__, g_sysinfo_data.mfg_cmd);
  1832. -
  1833. -            if (0 != (g_sysinfo_data.mfg_cmd & (SI_COMMAND_COMPLETED | SI_COMMAND_PASS)))
  1834. -            {
  1835. -                break;
  1836. -            }
  1837. -        }
  1838. -
  1839. -        msleep(250);
  1840. -    }
  1841. -
  1842. -    if (0 > ret_val)
  1843. -    {
  1844. -        dev_err(&ts->client->dev, "%s() - ERROR: Could not read from the System Information registers.\n", __FUNCTION__);
  1845. -        goto error_restore_mode;
  1846. -    }
  1847. -
  1848. -    if (40 == tries)
  1849. -    {
  1850. -        dev_err(&ts->client->dev, "%s() - ERROR: Timed Out when trying to read from the System Information registers.\n", __FUNCTION__);
  1851. -        goto error_restore_mode;
  1852. -    }
  1853. -
  1854. -   dev_info(&ts->client->dev, "%s() - Touch Panel Calibration was successful.\n", __FUNCTION__);
  1855. -
  1856. -    ret_val = regulator_disable(ts->reg);
  1857. -    if (0 != ret_val)
  1858. -    {
  1859. -        dev_err(&ts->client->dev, "%s() - ERROR: Could not disable the regulator.\n", __FUNCTION__);
  1860. -        goto error_restore_mode;
  1861. -    }
  1862. -
  1863. -    msleep(100);
  1864. -
  1865. -    ret_val = regulator_enable(ts->reg);
  1866. -    if (0 != ret_val)
  1867. -    {
  1868. -        dev_err(&ts->client->dev, "%s() - ERROR: Could not re-enable the regulator.\n", __FUNCTION__);
  1869. -        goto error_restore_mode;
  1870. -    }
  1871. -
  1872. -error_restore_mode:
  1873. -    dev_info(&ts->client->dev, "%s() - Returning to Operational mode.\n", __FUNCTION__);
  1874. -    host_reg = CY_OP_MODE;
  1875. -    for (tries = 0; tries < 10; tries++)
  1876. -    {
  1877. -        ret_val = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE, sizeof(host_reg), &host_reg);
  1878. -        if (0 > ret_val)
  1879. -        {
  1880. -            msleep(100);
  1881. -        }
  1882. -        else
  1883. -        {
  1884. -            break;
  1885. -        }
  1886. -    }
  1887. -
  1888. -    if (0 > ret_val)
  1889. -    {
  1890. -        dev_err(&ts->client->dev, "%s() - ERROR: Could not put the Touch Panel in Operational mode.\n", __FUNCTION__);
  1891. -        goto error_return;
  1892. -    }
  1893. -
  1894. -    mdelay(CYTTSP_MDELAY);
  1895. -
  1896. -    dev_info(&ts->client->dev, "%s() - Initializing Gesture Setup.\n", __FUNCTION__);
  1897. -
  1898. -    gesture_setup = ts->platform_data->gest_set;
  1899. -
  1900. -    ret_val = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_GEST_SET, sizeof(gesture_setup), &gesture_setup);
  1901. -    if (0 > ret_val)
  1902. -    {
  1903. -        dev_err(&ts->client->dev, "%s() - ERROR: Could not write the Gesture Configuration to the Gesture Setup register.\n", __FUNCTION__);
  1904. -        ts->platform_data->power_state = CY_IDLE_STATE;
  1905. -    }
  1906. -    else
  1907. -    {
  1908. -        ts->platform_data->power_state = CY_ACTIVE_STATE;
  1909. -    }
  1910. -
  1911. -    dev_info(&ts->client->dev, "%s() - Power state is %s\n", __FUNCTION__, ((ts->platform_data->power_state == CY_ACTIVE_STATE) ? "ACTIVE" : "IDLE"));
  1912. -
  1913. -error_return:
  1914. -    msleep(CY_DLY_DFLT);
  1915. -    enable_irq(ts->client->irq);
  1916. -    atomic_set(&ts->irq_enabled, 1);
  1917. -   return ret_val;
  1918. -}
  1919. -
  1920. -static int cyttsp_i2c_wr_blk_chunks(struct cyttsp *ts, u8 command,
  1921. -   u8 length, const u8 *values)
  1922. -{
  1923. -   int retval = CY_OK;
  1924. -   int block = 1;
  1925. -
  1926. -   u8 dataray[CY_MAX_I2C_LEN];
  1927. -
  1928. -   /* first page already includes the bl page offset */
  1929. -   retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE,
  1930. -       CY_BL_PAGE_SIZE+1, values);
  1931. -   values += CY_BL_PAGE_SIZE+1;
  1932. -   length -= CY_BL_PAGE_SIZE+1;
  1933. -
  1934. -   /* rem blocks require bl page offset stuffing */
  1935. -   while (length &&
  1936. -       (block < CY_BL_NUM_PAGES) &&
  1937. -       !(retval < CY_OK)) {
  1938. -       udelay(43*2);   /* TRM * 2 */
  1939. -       dataray[0] = CY_BL_PAGE_SIZE*block;
  1940. -       memcpy(&dataray[1], values,
  1941. -           length >= CY_BL_PAGE_SIZE ?
  1942. -           CY_BL_PAGE_SIZE : length);
  1943. -       retval = i2c_smbus_write_i2c_block_data(ts->client,
  1944. -           CY_REG_BASE,
  1945. -           length >= CY_BL_PAGE_SIZE ?
  1946. -           CY_BL_PAGE_SIZE + 1 : length+1, dataray);
  1947. -       values += CY_BL_PAGE_SIZE;
  1948. -       length = length >= CY_BL_PAGE_SIZE ?
  1949. -           length - CY_BL_PAGE_SIZE : 0;
  1950. -       block++;
  1951. -   }
  1952. -
  1953. -   return retval;
  1954. -}
  1955. -
  1956. -
  1957. -static int cyttsp_tpbl_is_ready(void)
  1958. -{
  1959. -    return (CYTTSP_BLSTATUS_READY == (CYTTSP_BLSTATUS_MASK & g_bl_data.bl_status));
  1960. -}
  1961. -
  1962. -static int cyttsp_tpbl_cmd_succeeded(int checking_write_block_or_verify_block_cmd)
  1963. -{
  1964. -    u8 success_pattern = CYTTSP_BLERROR_SUCCESS;
  1965. -
  1966. -    if (checking_write_block_or_verify_block_cmd)
  1967. -    {
  1968. -        /* We are checking for errors following a Write Block or Verify Block command,
  1969. -         * and it is thus acceptible for the CYTTSP_BLERROR_BOOTLOADING bit to be set.
  1970. -         */
  1971. -        success_pattern = (CYTTSP_BLERROR_SUCCESS | CYTTSP_BLERROR_BOOTLOADING);
  1972. -    }
  1973. -
  1974. -    return (success_pattern == (CYTTSP_BLERROR_MASK & g_bl_data.bl_error));
  1975. -}
  1976. -
  1977. -static void cyttsp_tpbl_display_error(struct device * pdev, int checking_write_block_or_verify_block_cmd)
  1978. -{
  1979. -    if (cyttsp_tpbl_cmd_succeeded(checking_write_block_or_verify_block_cmd))
  1980. -    {
  1981. -        dev_err(pdev, "%s() - Touch Panel Bootloader Error: None\n", __FUNCTION__);
  1982. -    }
  1983. -    else
  1984. -    {
  1985. -        if (g_bl_data.bl_error & CYTTSP_BLERROR_INVALID_COMMAND)
  1986. -        {
  1987. -            dev_err(pdev, "%s() - Touch Panel Bootloader Error: Invalid Command\n", __FUNCTION__);
  1988. -        }
  1989. -
  1990. -        if (g_bl_data.bl_error & CYTTSP_BLERROR_INVALID_SECURITY_KEY)
  1991. -        {
  1992. -            dev_err(pdev, "%s() - Touch Panel Bootloader Error: Invalid Security Key\n", __FUNCTION__);
  1993. -        }
  1994. -
  1995. -        if (g_bl_data.bl_error & CYTTSP_BLERROR_BOOTLOADING)
  1996. -        {
  1997. -            dev_err(pdev, "%s() - Touch Panel Bootloader Error: Bootloading\n", __FUNCTION__);
  1998. -        }
  1999. -
  2000. -        if (g_bl_data.bl_error & CYTTSP_BLERROR_COMMAND_CHECKSUM_ERROR)
  2001. -        {
  2002. -            dev_err(pdev, "%s() - Touch Panel Bootloader Error: Command Checksum Error\n", __FUNCTION__);
  2003. -        }
  2004. -
  2005. -        if (g_bl_data.bl_error & CYTTSP_BLERROR_FLASH_PROTECTION_ERROR)
  2006. -        {
  2007. -            dev_err(pdev, "%s() - Touch Panel Bootloader Error: Flash Protection Error\n", __FUNCTION__);
  2008. -        }
  2009. -
  2010. -        if (g_bl_data.bl_error & CYTTSP_BLERROR_FLASH_CHECKSUM_ERROR)
  2011. -        {
  2012. -            dev_err(pdev, "%s() - Touch Panel Bootloader Error: Flash Checksum Error\n", __FUNCTION__);
  2013. -        }
  2014. -
  2015. -        if (g_bl_data.bl_error & CYTTSP_BLERROR_IMAGE_VERIFICATION_ERROR)
  2016. -        {
  2017. -            dev_err(pdev, "%s() - Touch Panel Bootloader Error: Image Verification Error\n", __FUNCTION__);
  2018. -        }
  2019. -    }
  2020. -}
  2021. -
  2022. -static int cyttsp_bootload_app(struct cyttsp * ts)
  2023. -{
  2024. -    int retval = CY_OK;
  2025. -    int tries  = 0;
  2026. -    int i      = 0;
  2027. -    u8  host_reg = 0x00;
  2028. -
  2029. -
  2030. -    dev_info(&ts->client->dev, "%s() - Putting the Touch Panel in Bootloader Mode...\n", __FUNCTION__);
  2031. -
  2032. -    host_reg = CY_SOFT_RESET_MODE;
  2033. -    retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE, sizeof(host_reg), &host_reg);
  2034. -    if (0 != retval)
  2035. -    {
  2036. -        dev_err(&ts->client->dev, "%s() - ERROR: Could not send the Enter Bootloader Mode command.\n", __FUNCTION__);
  2037. -        goto error_return;
  2038. -    }
  2039. -
  2040. -    dev_info(&ts->client->dev, "%s() - Confirming that the Touch Panel is in Bootloader Mode...\n", __FUNCTION__);
  2041. -
  2042. -    for (tries = 0; tries < 100; tries++)
  2043. -    {
  2044. -        msleep(5);
  2045. -
  2046. -        cyttsp_putbl(ts, 3, false, false, false);
  2047. -
  2048. -        if (cyttsp_tpbl_is_ready())
  2049. -        {
  2050. -            break;
  2051. -        }
  2052. -    }
  2053. -
  2054. -    if (!cyttsp_tpbl_is_ready())
  2055. -    {
  2056. -        dev_err(&ts->client->dev, "%s() - ERROR: Could not put the Touch Panel in Bootloader Mode.\n", __FUNCTION__);
  2057. -        dev_err(&ts->client->dev, "%s() - Bootloader Status = 0x%02X\n", __FUNCTION__, g_bl_data.bl_status);
  2058. -        retval = -1;
  2059. -        goto error_return;
  2060. -    }
  2061. -
  2062. -    dev_dbg(&ts->client->dev, "%s() - load file - tts_ver = 0x%02X%02X, app_id = 0x%02X%02X, app_ver = 0x%02X%02X\n",
  2063. -            __FUNCTION__,
  2064. -            cyttsp_fw_tts_verh,
  2065. -            cyttsp_fw_tts_verl,
  2066. -            cyttsp_fw_app_idh,
  2067. -            cyttsp_fw_app_idl,
  2068. -            cyttsp_fw_app_verh,
  2069. -            cyttsp_fw_app_verl);
  2070. -
  2071. -    /* Upload new TTSP Application to the Bootloader */
  2072. -    i = 0;
  2073. -
  2074. -    if (CY_BL_INIT_LOAD == cyttsp_fw[i].Command)
  2075. -    {
  2076. -        g_bl_data.bl_file   = 0x00;
  2077. -        g_bl_data.bl_status = 0x00;
  2078. -        g_bl_data.bl_error  = 0x00;
  2079. -
  2080. -        dev_info(&ts->client->dev, "%s() - Uploading new Firmware to the Touch Panel...\n", __FUNCTION__);
  2081. -
  2082. -        retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE, cyttsp_fw[i].Length, cyttsp_fw[i].Block);
  2083. -        if (0 != retval)
  2084. -        {
  2085. -            dev_err(&ts->client->dev, "%s() - ERROR: Could not send the Initiate Bootload command.\n", __FUNCTION__);
  2086. -            goto error_return;
  2087. -        }
  2088. -
  2089. -        /* delay to allow bl to get ready for block writes */
  2090. -        i++;
  2091. -
  2092. -        for (tries = 0; tries < 100; tries++)
  2093. -        {
  2094. -            msleep(100);
  2095. -            cyttsp_putbl(ts, 4, false, false, false);
  2096. -
  2097. -            if (cyttsp_tpbl_cmd_succeeded(true))
  2098. -            {
  2099. -                break;
  2100. -            }
  2101. -        }
  2102. -
  2103. -        if (!cyttsp_tpbl_cmd_succeeded(true))
  2104. -        {
  2105. -            dev_err(&ts->client->dev, "%s() - ERROR: Could not initiate the bootload process.\n", __FUNCTION__);
  2106. -            cyttsp_tpbl_display_error(&ts->client->dev, false);
  2107. -            retval = -2;
  2108. -            goto error_return;
  2109. -        }
  2110. -
  2111. -        dev_dbg(&ts->client->dev, "%s() - wait init: f=0x%02X, s=0x%02X, e=0x%02X t=%d\n", __FUNCTION__, g_bl_data.bl_file, g_bl_data.bl_status, g_bl_data.bl_error, tries);
  2112. -
  2113. -        /* send bootload firmware load blocks */
  2114. -        while (CY_BL_WRITE_BLK == cyttsp_fw[i].Command)
  2115. -        {
  2116. -            dev_dbg(&ts->client->dev, "%s() - BL UPLD Rec=%3d Len=%3d Addr=0x%04X\n",
  2117. -                    __FUNCTION__,
  2118. -                    cyttsp_fw[i].Record,
  2119. -                    cyttsp_fw[i].Length,
  2120. -                    cyttsp_fw[i].Address);
  2121. -
  2122. -            retval = cyttsp_i2c_wr_blk_chunks(ts, CY_REG_BASE, cyttsp_fw[i].Length, cyttsp_fw[i].Block);
  2123. -            if (0 != retval)
  2124. -            {
  2125. -                dev_err(&ts->client->dev, "%s() - ERROR: Data Block write failed.\n", __FUNCTION__);
  2126. -                goto error_return;
  2127. -            }
  2128. -
  2129. -            i++;
  2130. -
  2131. -            for (tries = 0; tries < 100; tries++)
  2132. -            {
  2133. -                msleep(1);
  2134. -                cyttsp_putbl(ts, 5, false, false, false);
  2135. -
  2136. -                if (cyttsp_tpbl_cmd_succeeded(true))
  2137. -                {
  2138. -                    break;
  2139. -                }
  2140. -            }
  2141. -
  2142. -            if (!cyttsp_tpbl_cmd_succeeded(true))
  2143. -            {
  2144. -                dev_err(&ts->client->dev, "%s() - ERROR: Could not process the Block Write.\n", __FUNCTION__);
  2145. -                cyttsp_tpbl_display_error(&ts->client->dev, true);
  2146. -                retval = -3;
  2147. -                goto error_return;
  2148. -            }
  2149. -        }
  2150. -
  2151. -        while (i < cyttsp_fw_records)
  2152. -        {
  2153. -            retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE, cyttsp_fw[i].Length, cyttsp_fw[i].Block);
  2154. -            if (0 != retval)
  2155. -            {
  2156. -                dev_err(&ts->client->dev, "%s() - ERROR: Record write failed.\n", __FUNCTION__);
  2157. -                goto error_return;
  2158. -            }
  2159. -
  2160. -            i++;
  2161. -
  2162. -            for (tries = 0; tries < 100; tries++)
  2163. -            {
  2164. -                msleep(100);
  2165. -                cyttsp_putbl(ts, 6, true, false, false);
  2166. -
  2167. -                if (cyttsp_tpbl_cmd_succeeded(false))
  2168. -                {
  2169. -                    break;
  2170. -                }
  2171. -            }
  2172. -
  2173. -            if (!cyttsp_tpbl_cmd_succeeded(false))
  2174. -            {
  2175. -                dev_err(&ts->client->dev, "%s() - ERROR: Could not process the Record.\n", __FUNCTION__);
  2176. -                cyttsp_tpbl_display_error(&ts->client->dev, false);
  2177. -                retval = -4;
  2178. -                goto error_return;
  2179. -            }
  2180. -
  2181. -            dev_dbg(&ts->client->dev, "%s() - wait term: f=0x%02X, s=0x%02X, e=0x%02X t=%d\n",
  2182. -                    __FUNCTION__,
  2183. -                    g_bl_data.bl_file,
  2184. -                    g_bl_data.bl_status,
  2185. -                    g_bl_data.bl_error,
  2186. -                    tries);
  2187. -        }
  2188. -    }
  2189. -
  2190. -    dev_info(&ts->client->dev, "%s() - Putting the Touch Panel back in Bootloader Mode...\n", __FUNCTION__);
  2191. -
  2192. -    host_reg = CY_SOFT_RESET_MODE;
  2193. -    retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE, sizeof(host_reg), &host_reg);
  2194. -    if (0 != retval)
  2195. -    {
  2196. -        dev_err(&ts->client->dev, "%s() - ERROR: Could not write the Soft Reset command to the Host Mode register.\n", __FUNCTION__);
  2197. -        goto error_return;
  2198. -    }
  2199. -
  2200. -    dev_info(&ts->client->dev, "%s() - Confirming that the Touch Panel is in Bootloader Mode...\n", __FUNCTION__);
  2201. -
  2202. -    for (tries = 0; tries < 100; tries++)
  2203. -    {
  2204. -        msleep(1);
  2205. -        cyttsp_putbl(ts, 3, false, false, false);
  2206. -
  2207. -        if (cyttsp_tpbl_is_ready())
  2208. -        {
  2209. -            break;
  2210. -        }
  2211. -    }
  2212. -
  2213. -    if (!cyttsp_tpbl_is_ready())
  2214. -    {
  2215. -        dev_err(&ts->client->dev, "%s() - ERROR: The Touch Panel did not return to Bootloader Mode.\n", __FUNCTION__);
  2216. -        dev_err(&ts->client->dev, "%s() - Bootloader Status = 0x%02X\n", __FUNCTION__, g_bl_data.bl_status);
  2217. -        retval = -5;
  2218. -        goto error_return;
  2219. -    }
  2220. -
  2221. -   /* set arg2 to non-0 to activate */
  2222. -   retval = cyttsp_putbl(ts, 8, true, true, true);
  2223. -
  2224. -error_return:
  2225. -    return retval;
  2226. -}
  2227. -
  2228. -#define CYTTSP_TST_MDELAY 125
  2229. -#define SENSOR_SIZE 247
  2230. -static int cyttsp_bn_testdata_get(struct cyttsp *ts, u8 testmode)
  2231. -{
  2232. -   int retval = CY_OK;
  2233. -   u8 host_reg;
  2234. -   int i ;
  2235. -   disable_irq(ts->client->irq);
  2236. -   //del_timer(&ts->timer);
  2237. -
  2238. -   cyttsp_debug("switch to test test mode:%d \n", testmode);
  2239. -   host_reg = testmode;
  2240. -   retval = i2c_smbus_write_i2c_block_data(ts->client,
  2241. -       CY_REG_BASE, sizeof(host_reg), &host_reg);
  2242. -   /* wait for TTSP Device to complete switch to SysInfo mode */
  2243. -   mdelay(CYTTSP_TST_MDELAY);
  2244. -    if (retval >= CY_OK)
  2245. -    {
  2246. -       int banknum;
  2247. -       i       = 0;
  2248. -       banknum = 0;
  2249. -       for( i=0; i < SENSOR_SIZE; i+=32, banknum++ )
  2250. -       {
  2251. -               retval = i2c_smbus_read_i2c_block_data(ts->client,
  2252. -                       (CY_REG_BASE + 32*banknum),
  2253. -                       32, /* TODO handle reminder */
  2254. -                       (u8 *)(&g_test_data[i]) );
  2255. -               printk("bank: %d, %X\n", banknum, (unsigned int)(&g_test_data+ i ) );
  2256. -
  2257. -       }
  2258. -
  2259. -       for( i=0; i< SENSOR_SIZE; i++)
  2260. -       {
  2261. -               printk("%i, ", g_test_data[i]);
  2262. -       }
  2263. -       printk("\n");
  2264. -   }
  2265. -   else
  2266. -   {
  2267. -       printk("i2c_smbus_write_i2c_block_data() call failed\n");
  2268. -   }
  2269. -
  2270. -   /* switch back to Operational mode */
  2271. -   cyttsp_debug("switch back to operational mode \n");
  2272. -   {
  2273. -       host_reg = CY_OP_MODE/* + CY_LOW_PWR_MODE*/;
  2274. -       retval = i2c_smbus_write_i2c_block_data(ts->client,
  2275. -           CY_REG_BASE,
  2276. -           sizeof(host_reg), &host_reg);
  2277. -       if (retval < CY_OK)
  2278. -       {
  2279. -           printk("%s: failed to return to Operation mode\n", __FUNCTION__);
  2280. -           goto lDone;
  2281. -       }
  2282. -       /* wait for TTSP Device to complete
  2283. -        * switch to Operational mode */
  2284. -       mdelay(CYTTSP_TST_MDELAY);
  2285. -   }
  2286. -lDone:
  2287. -   enable_irq(ts->client->irq);
  2288. -   return retval;
  2289. -}
  2290. -
  2291. -static int get_host_mode_reg(struct cyttsp *ts, u8 * p_data)
  2292. -{
  2293. -    const int poll_count_limit = 100;
  2294. -    const int poll_delay = 50;
  2295. -    int poll_count = 0;
  2296. -    int retval = CY_OK;
  2297. -
  2298. -    if (NULL == p_data)
  2299. -    {
  2300. -        printk(KERN_ERR "%s() - ERROR: Data Byte pointer is NULL.\n", __FUNCTION__);
  2301. -        retval = -1;
  2302. -        goto done;
  2303. -    }
  2304. -
  2305. -    do
  2306. -    {
  2307. -        retval = i2c_smbus_read_i2c_block_data(ts->client, CY_REG_BASE, 1, p_data);
  2308. -
  2309. -        if (CY_OK > retval)
  2310. -        {
  2311. -            msleep(poll_delay);
  2312. -        }
  2313. -    } while ((CY_OK > retval) && (poll_count_limit > poll_count++));
  2314. -
  2315. -    if (CY_OK > retval)
  2316. -    {
  2317. -        printk(KERN_ERR "%s() - ERROR: Could not update Touchscreen Bootloader Mode Status.\n", __FUNCTION__);
  2318. -        goto done;
  2319. -    }
  2320. -
  2321. -    printk(KERN_INFO "%s() - Host Mode Register: 0x%02X\n", __FUNCTION__, *p_data);
  2322. -
  2323. -done:
  2324. -    return retval;
  2325. -}
  2326. -
  2327. -static int get_host_mode(struct cyttsp *ts, u8 * p_data)
  2328. -{
  2329. -    int retval = get_host_mode_reg(ts, p_data);
  2330. -
  2331. -    if (CY_OK <= retval)
  2332. -    {
  2333. -        /* Mask off the bits we don't care about */
  2334. -        *p_data = (*p_data & 0x70);
  2335. -    }
  2336. -
  2337. -    return retval;
  2338. -}
  2339. -
  2340. -static int set_host_mode_reg(struct cyttsp *ts, u8 host_mode_reg_val)
  2341. -{
  2342. -    const int poll_count_limit = 100;
  2343. -    const int poll_delay = 50;
  2344. -    int poll_count = 0;
  2345. -    int retval = CY_OK;
  2346. -
  2347. -    do
  2348. -    {
  2349. -        retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE, sizeof(host_mode_reg_val), &host_mode_reg_val);
  2350. -        if (CY_OK > retval)
  2351. -        {
  2352. -            msleep(poll_delay);
  2353. -        }
  2354. -    } while ((CY_OK > retval) && (poll_count_limit > poll_count++));
  2355. -
  2356. -    if (CY_OK > retval)
  2357. -    {
  2358. -        printk(KERN_ERR "%s() - ERROR: Could not write 0x%02X to the Host Mode Register.\n", __FUNCTION__, host_mode_reg_val);
  2359. -        goto done;
  2360. -    }
  2361. -
  2362. -    msleep(CYTTSP_MDELAY);
  2363. -    retval = cyttsp_wait_for_i2c(ts);
  2364. -
  2365. -    if (CY_OK > retval)
  2366. -    {
  2367. -        printk(KERN_ERR "%s() - ERROR: Wait for I2C Bus Readiness failed.\n", __FUNCTION__);
  2368. -        goto done;
  2369. -    }
  2370. -
  2371. -done:
  2372. -    return retval;
  2373. -}
  2374. -
  2375. -static int set_host_mode(struct cyttsp *ts, u8 requested_host_mode)
  2376. -{
  2377. -    int retval    = CY_OK;
  2378. -    u8  host_mode = 0xFF;
  2379. -
  2380. -    switch (requested_host_mode)
  2381. -    {
  2382. -        case CY_OP_MODE:
  2383. -        case CY_SYSINFO_MODE:
  2384. -        case CY_RAW_MODE:
  2385. -        case CY_SIG_MODE:
  2386. -        case CY_IDAC_MODE:
  2387. -        case CY_RAWBASE_MODE:
  2388. -            /* Mode supported by this function */
  2389. -            break;
  2390. -
  2391. -        default:
  2392. -            /* Mode not supported by this function */
  2393. -            printk(KERN_ERR "%s() - ERROR: Requested mode 0x%02X is not supported by this function.\n", __FUNCTION__, requested_host_mode);
  2394. -            retval = -EINVAL;
  2395. -            goto done;
  2396. -    }
  2397. -
  2398. -    /* Determine the current mode */
  2399. -    retval = get_host_mode(ts, &host_mode);
  2400. -    if (CY_OK > retval)
  2401. -    {
  2402. -        printk(KERN_ERR "%s() - ERROR: Could not determine current Touchscreen Mode.\n", __FUNCTION__);
  2403. -        goto done;
  2404. -    }
  2405. -
  2406. -    if (requested_host_mode == host_mode)
  2407. -    {
  2408. -        printk(KERN_INFO "%s() - Touchscreen is already in the requested Host Mode (0x%02X).\n", __FUNCTION__, requested_host_mode);
  2409. -        goto done;
  2410. -    }
  2411. -
  2412. -    printk(KERN_INFO "%s() - Touchscreen Host Mode: 0x%02X -> 0x%02X\n", __FUNCTION__, host_mode, requested_host_mode);
  2413. -
  2414. -    retval = set_host_mode_reg(ts, requested_host_mode);
  2415. -    if (CY_OK > retval)
  2416. -    {
  2417. -        printk(KERN_ERR "%s() - ERROR: Could not put Touchscreen in the requested Host Mode.\n", __FUNCTION__);
  2418. -        goto done;
  2419. -    }
  2420. -
  2421. -done:
  2422. -    return retval;
  2423. -}
  2424. -
  2425. -
  2426. -/* sysfs */
  2427. -static ssize_t ttsp_sig_show(struct device *dev,
  2428. -               struct device_attribute *attr, char *buf)
  2429. -{
  2430. -   int i, cnt = 0;
  2431. -   struct i2c_client *client = container_of(dev, struct i2c_client, dev);
  2432. -   struct cyttsp *ts = i2c_get_clientdata(client);
  2433. -
  2434. -   cyttsp_info("%s: \n", __FUNCTION__);
  2435. -   cnt = cyttsp_bn_testdata_get(ts, CY_SIG_MODE);
  2436. -   if( cnt < 0 ){
  2437. -       cnt = 0;
  2438. -       goto lEnd;
  2439. -   }
  2440. -
  2441. -   for( i=7; i<247; i++)
  2442. -   {
  2443. -       cnt = cnt + sprintf(&buf[cnt], "%d ", g_test_data[i] );
  2444. -   }
  2445. -   buf[cnt--] = 0;
  2446. -   cyttsp_info("%s: %s \n", __FUNCTION__, buf);
  2447. -
  2448. -lEnd:
  2449. -   return cnt;
  2450. -}
  2451. -
  2452. -static ssize_t ttsp_sig_store(struct device *dev,
  2453. -                   struct device_attribute *attr,
  2454. -                       const char *buf, size_t count)
  2455. -{
  2456. -   /* place holder for future use */
  2457. -   return -1;
  2458. -}
  2459. -
  2460. -
  2461. -static ssize_t ttsp_idac_show(struct device *dev,
  2462. -               struct device_attribute *attr, char *buf)
  2463. -{
  2464. -   int i, j, cnt = 0, retval;
  2465. -   struct i2c_client *client = container_of(dev, struct i2c_client, dev);
  2466. -   struct cyttsp *ts = i2c_get_clientdata(client);
  2467. -
  2468. -   cyttsp_info("%s: \n", __FUNCTION__);
  2469. -
  2470. -   for(j=0; j<6; j++){
  2471. -       retval = cyttsp_bn_testdata_get(ts, CY_IDAC_MODE);
  2472. -       // Check if data is valid and frame type
  2473. -       if( g_test_data[1]&0x20 || retval<0 ){
  2474. -           printk("%s: invalid buffer or get data failed \n", __FUNCTION__);
  2475. -           continue; // Frame is invalid
  2476. -       }
  2477. -       if( ((g_test_data[1]>>6)%2) == 0 )
  2478. -       {
  2479. -           //Lidac (even)
  2480. -           printk("%s: got lidac!!!!(%d)\n", __FUNCTION__, (unsigned int)j);
  2481. -           for( i=7; i<247; i++)
  2482. -           {
  2483. -               cnt = cnt + sprintf(&buf[cnt], "%d ", g_test_data[i] );
  2484. -           }
  2485. -           cnt = cnt + sprintf(&buf[cnt], "\n");
  2486. -           break;
  2487. -       }
  2488. -       j++;
  2489. -   }
  2490. -   if( j > 6 )
  2491. -       goto lEnd;
  2492. -
  2493. -   for(j=0; j<6; j++){
  2494. -       retval = cyttsp_bn_testdata_get(ts, CY_IDAC_MODE);
  2495. -       // Check if data is valid and frame type
  2496. -       if( g_test_data[1]&0x20 || retval<0 ){
  2497. -           printk("%s: invalid buffer or get data failed \n", __FUNCTION__);
  2498. -           continue; // Frame is invalid
  2499. -       }
  2500. -
  2501. -       if((g_test_data[1]>>6)%2)
  2502. -       {
  2503. -           //Gidac (odd fields)
  2504. -           printk("%s: got lidac!!!!(%d)\n", __FUNCTION__, (unsigned int)j);
  2505. -           #define NUM_GLOBAL_IDAC 36
  2506. -           #define TM_GLOBAL_IDAC_OFF 8
  2507. -           for( i=TM_GLOBAL_IDAC_OFF; i<(TM_GLOBAL_IDAC_OFF+NUM_GLOBAL_IDAC); i++)
  2508. -           {
  2509. -               cnt = cnt + sprintf(&buf[cnt], "%d ", g_test_data[i] );
  2510. -           }
  2511. -           cnt = cnt + sprintf(&buf[cnt], "\n");
  2512. -           break;
  2513. -       }
  2514. -       j++;
  2515. -   }
  2516. -   if( j > 6 )
  2517. -       goto lEnd;
  2518. -  
  2519. -   cyttsp_info("%s: %s \n", __FUNCTION__, buf);
  2520. -lEnd:
  2521. -   return cnt;
  2522. -}
  2523. -
  2524. -static ssize_t ttsp_idac_store(struct device *dev,
  2525. -                   struct device_attribute *attr,
  2526. -                       const char *buf, size_t count)
  2527. -{
  2528. -   /* place holder for future use */
  2529. -   return -1;
  2530. -}
  2531. -
  2532. -
  2533. -static ssize_t ttsp_rawbase_show(struct device *dev,
  2534. -               struct device_attribute *attr, char *buf)
  2535. -{
  2536. -   int i, j, cnt = 0, retval;
  2537. -   struct i2c_client *client = container_of(dev, struct i2c_client, dev);
  2538. -   struct cyttsp *ts = i2c_get_clientdata(client);
  2539. -
  2540. -   cyttsp_info("%s: \n", __FUNCTION__);
  2541. -   for(j=0; j<6; j++){
  2542. -       retval = cyttsp_bn_testdata_get(ts, CY_RAWBASE_MODE);
  2543. -       // Check if data is valid and frame type
  2544. -       if( g_test_data[1]&0x20 || retval<0 ){
  2545. -           printk("%s: invalid buffer or get data failed \n", __FUNCTION__);
  2546. -           continue; // Frame is invalid
  2547. -       }
  2548. -
  2549. -       if((g_test_data[1]>>6)%2)
  2550. -       {
  2551. -           //raw (odd fields)
  2552. -           printk("%s: got lidac!!!!(%d)\n", __FUNCTION__, (unsigned int)j);
  2553. -           for( i=7; i<247; i++)
  2554. -           {
  2555. -               cnt = cnt + sprintf(&buf[cnt], "%d ", g_test_data[i] );
  2556. -           }
  2557. -           cnt = cnt + sprintf(&buf[cnt], "\n");
  2558. -           break;
  2559. -       }
  2560. -       j++;
  2561. -   }
  2562. -   if( j > 6 )
  2563. -       goto lEnd;
  2564. -
  2565. -   for(j=0; j<6; j++){
  2566. -       retval = cyttsp_bn_testdata_get(ts, CY_RAWBASE_MODE);
  2567. -       // Check if data is valid and frame type
  2568. -       if( g_test_data[1]&0x20 || retval<0 ){
  2569. -           printk("%s: invalid buffer or get data failed \n", __FUNCTION__);
  2570. -           continue; // Frame is invalid
  2571. -       }
  2572. -       if( ((g_test_data[1]>>6)%2) == 0 )
  2573. -       {
  2574. -           //baseline (even)
  2575. -           printk("%s: got lidac!!!!(%d)\n", __FUNCTION__, (unsigned int)j);
  2576. -           for( i=7; i<247; i++)
  2577. -           {
  2578. -               cnt = cnt + sprintf(&buf[cnt], "%d ", g_test_data[i] );
  2579. -           }
  2580. -           cnt = cnt + sprintf(&buf[cnt], "\n");
  2581. -           break;
  2582. -       }
  2583. -       j++;
  2584. -   }
  2585. -   if( j > 6 )
  2586. -       goto lEnd;
  2587. -
  2588. -   buf[cnt--] = 0;
  2589. -   cyttsp_info("%s: %s \n", __FUNCTION__, buf);
  2590. -lEnd:
  2591. -   return cnt;
  2592. -}
  2593. -
  2594. -static ssize_t ttsp_rawbase_show2(struct device *dev,
  2595. -               struct device_attribute *attr, char *buf)
  2596. -{
  2597. -   int i, cnt, retval;
  2598. -
  2599. -   struct i2c_client *client = container_of(dev, struct i2c_client, dev);
  2600. -   struct cyttsp *ts = i2c_get_clientdata(client);
  2601. -
  2602. -   cyttsp_info("%s: \n", __FUNCTION__);
  2603. -   retval = cyttsp_bn_testdata_get(ts, CY_RAWBASE_MODE);
  2604. -   if( retval < 0){
  2605. -       cnt = 0;
  2606. -       goto lEnd;
  2607. -   }
  2608. -
  2609. -   cnt = 0;
  2610. -   for( i=7; i<247; i++)
  2611. -   {
  2612. -       cnt = cnt + sprintf(&buf[cnt], "%d ", g_test_data[i] );
  2613. -   }
  2614. -
  2615. -   cnt = cnt + sprintf(&buf[cnt], "\n");
  2616. -
  2617. -   for( i=7; i<247; i++ )
  2618. -   {
  2619. -       cnt = cnt + sprintf(&buf[cnt], "%d ", g_test_data[i] );
  2620. -   }
  2621. -   buf[cnt++] = 0;
  2622. -   cyttsp_info("%s: %s \n", __FUNCTION__, buf);
  2623. -
  2624. -lEnd:
  2625. -   return cnt;
  2626. -
  2627. -}
  2628. -
  2629. -static ssize_t ttsp_rawbase_store(struct device *dev,
  2630. -                   struct device_attribute *attr,
  2631. -                       const char *buf, size_t count)
  2632. -{
  2633. -   /* place holder for future use */
  2634. -   return -1;
  2635. -}
  2636. -
  2637. -static ssize_t ttsp_tpfwver_show(struct device *dev, struct device_attribute *attr, char *buf)
  2638. -{
  2639. -    int cnt = 0;
  2640. -
  2641. -    cnt = sprintf(buf,
  2642. -                  "%02X%02X %02X%02X %02X%02X\n",
  2643. -                  g_bl_data.appver_hi,
  2644. -                  g_bl_data.appver_lo,
  2645. -                  cyttsp_app_verh(),
  2646. -                  cyttsp_app_verl(),
  2647. -                  g_sysinfo_data.app_verh,
  2648. -                  g_sysinfo_data.app_verl);
  2649. -              
  2650. -    cyttsp_info("%s: tpfwver=%s \n", __FUNCTION__, buf);
  2651. -
  2652. -    return cnt;
  2653. -}
  2654. -
  2655. -static ssize_t ttsp_tpfwver_store(struct device *dev,
  2656. -                   struct device_attribute *attr,
  2657. -                       const char *buf, size_t count)
  2658. -{
  2659. -   /* place holder for future use */
  2660. -   return -1;
  2661. -}
  2662. -
  2663. -static ssize_t ttsp_forcecal_show(struct device *dev, struct device_attribute *attr, char *buf)
  2664. -{
  2665. -    int cnt = 0;
  2666. -
  2667. -    cyttsp_info("%s: \n", __FUNCTION__);
  2668. -    cnt = cnt + sprintf(&buf[cnt], "%02X\n ", initiate_tpcal);
  2669. -    buf[cnt--] = 0;
  2670. -
  2671. -    cyttsp_info("%s: tpfwver=%s \n", __FUNCTION__, buf);
  2672. -
  2673. -    return cnt;
  2674. -}
  2675. -
  2676. -static ssize_t ttsp_forcecal_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
  2677. -{
  2678. -    struct i2c_client *client = container_of(dev, struct i2c_client, dev);
  2679. -    struct cyttsp *ts = i2c_get_clientdata(client);
  2680. -
  2681. -    int err = 0;
  2682. -    unsigned long value;
  2683. -
  2684. -
  2685. -    if (size > 2)
  2686. -    {
  2687. -        return -EINVAL;
  2688. -    }
  2689. -
  2690. -    err = strict_strtoul(buf, 10, &value);
  2691. -    if (err != 0)
  2692. -    {
  2693. -        return err;
  2694. -    }
  2695. -
  2696. -    switch (value)
  2697. -    {
  2698. -        case 2:
  2699. -            if (initiate_tpcal != 1)
  2700. -            {
  2701. -                printk("%s: Forcing TP calibration NOW.\n", __FUNCTION__);
  2702. -                initiate_tpcal = 1;
  2703. -                cyttsp_calibrate(ts);
  2704. -                initiate_tpcal = 0;
  2705. -            }
  2706. -            break;    
  2707. -
  2708. -        default:
  2709. -            /* Do Nothing */
  2710. -            break;
  2711. -    }
  2712. -
  2713. -    return size;
  2714. -}
  2715. -
  2716. -
  2717. -static ssize_t ttsp_fwupdate_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
  2718. -{
  2719. -    struct i2c_client *client = container_of(dev, struct i2c_client, dev);
  2720. -    struct cyttsp *ts = i2c_get_clientdata(client);
  2721. -
  2722. -    unsigned long value = 0;
  2723. -    ssize_t retval = size;
  2724. -
  2725. -    if (0 != strict_strtoul(buf, 10, &value))
  2726. -    {
  2727. -        dev_err(dev, "%s() - ERROR: Could not convert the given input (\"%s\") to a usable number.\n", __FUNCTION__, buf);
  2728. -        retval = -EINVAL;
  2729. -        goto error_return;
  2730. -    }
  2731. -
  2732. -    if (1 != value)
  2733. -    {
  2734. -        dev_err(dev, "%s() - ERROR: Invalid input: %lu\n", __FUNCTION__, value);
  2735. -        retval = -EINVAL;
  2736. -        goto error_return;
  2737. -    }
  2738. -
  2739. -    if (0 != fw_update_flag)
  2740. -    {
  2741. -        dev_info(dev, "%s() - Firmware Update is already in progress.\n", __FUNCTION__);
  2742. -        goto error_return;
  2743. -    }
  2744. -
  2745. -    dev_info(dev, "%s() - Scheduling Firmware Upgrade.\n", __FUNCTION__);
  2746. -    fw_update_flag = 1;
  2747. -    INIT_WORK(&ts->update_work, cyttsp_update_worker);
  2748. -    queue_work(cyttsp_ts_wq, &ts->update_work);
  2749. -
  2750. -error_return:
  2751. -    return retval;
  2752. -}
  2753. -
  2754. -static ssize_t ttsp_fwupdate_show(struct device *dev, struct device_attribute *attr, char *buf)
  2755. -{
  2756. -    if (1 == fw_update_flag)
  2757. -    {
  2758. -        dev_info(dev, "%s() - Firmware Update in progress.\n", __FUNCTION__);
  2759. -    }
  2760. -    else
  2761. -    {
  2762. -        dev_info(dev, "%s() - Firmware Update not in progress.\n",__FUNCTION__);
  2763. -    }
  2764. -
  2765. -    return sprintf(&buf[0], "%02X\n",fw_update_flag);
  2766. -}
  2767. -
  2768. -static bool poll_gpio(const int gpio_num, const int requested_gpio_val)
  2769. -{
  2770. -    const int poll_count_limit = 10;
  2771. -    const int poll_delay_ms    = 20;
  2772. -    int poll_count = 0;
  2773. -    int gpio_val   = -1;
  2774. -
  2775. -
  2776. -    while ((poll_count_limit > poll_count++) && (requested_gpio_val != gpio_val))
  2777. -    {
  2778. -        msleep(poll_delay_ms);
  2779. -        gpio_val = gpio_get_value(gpio_num);
  2780. -    }
  2781. -
  2782. -    return (requested_gpio_val == gpio_val);
  2783. -}
  2784. -
  2785. -static ssize_t ttsp_interrupt_test_show(struct device *dev, struct device_attribute *attr, char *buf)
  2786. -{
  2787. -    struct i2c_client *client = container_of(dev, struct i2c_client, dev);
  2788. -    struct cyttsp *ts = i2c_get_clientdata(client);
  2789. -    int test_result = 0;
  2790. -    u8  host_mode_reg_val = 0;
  2791. -    const int gpio_num = irq_to_gpio(ts->client->irq);
  2792. -
  2793. -
  2794. -    disable_irq(ts->client->irq);
  2795. -
  2796. -    if (!poll_gpio(gpio_num, 1))
  2797. -    {
  2798. -        printk(KERN_ERR "%s() - Interrupt GPIO Line is not 1 in Operational Mode.\n", __FUNCTION__);
  2799. -        goto done;
  2800. -    }
  2801. -
  2802. -    if (CY_OK > set_host_mode(ts, CY_SYSINFO_MODE))
  2803. -    {
  2804. -        printk(KERN_ERR "%s() - Could not switch Touchscreen to System Information Mode.\n", __FUNCTION__);
  2805. -        goto done;
  2806. -    }
  2807. -
  2808. -    if (!poll_gpio(gpio_num, 0))
  2809. -    {
  2810. -        printk(KERN_ERR "%s() - Interrupt GPIO Line did not go to 0 in System Information Mode.\n", __FUNCTION__);
  2811. -        goto done;
  2812. -    }
  2813. -
  2814. -    if (CY_OK > get_host_mode_reg(ts, &host_mode_reg_val))
  2815. -    {
  2816. -        printk(KERN_ERR "%s() - Could not read Host Mode register.\n", __FUNCTION__);
  2817. -        goto done;
  2818. -    }
  2819. -
  2820. -    if (CY_HNDSHK_BIT & host_mode_reg_val)
  2821. -    {
  2822. -        host_mode_reg_val &= ~CY_HNDSHK_BIT;
  2823. -    }
  2824. -    else
  2825. -    {
  2826. -        host_mode_reg_val |= CY_HNDSHK_BIT;
  2827. -    }
  2828. -
  2829. -    if (CY_OK > set_host_mode_reg(ts, host_mode_reg_val))
  2830. -    {
  2831. -        printk(KERN_ERR "%s() - Could not acknowledge Driven Interrupt Line.\n", __FUNCTION__);
  2832. -        goto done;
  2833. -    }
  2834. -
  2835. -    if (CY_OK > set_host_mode(ts, CY_OP_MODE))
  2836. -    {
  2837. -        printk(KERN_ERR "%s() - Could not switch Touchscreen to Operational Mode.\n", __FUNCTION__);
  2838. -        goto done;
  2839. -    }
  2840. -
  2841. -    if (!poll_gpio(gpio_num, 1))
  2842. -    {
  2843. -        printk(KERN_ERR "%s() - Interrupt GPIO Line did not return to 1 in Operational Mode.\n", __FUNCTION__);
  2844. -        goto done;
  2845. -    }
  2846. -
  2847. -    test_result = 1;
  2848. -
  2849. -done:
  2850. -    enable_irq(ts->client->irq);
  2851. -
  2852. -    printk(KERN_INFO "%s() - Test Result: %s\n", __FUNCTION__, (test_result ? "PASS" : "FAIL"));
  2853. -
  2854. -    return snprintf(buf, PAGE_SIZE, "%d\n", test_result);
  2855. -}
  2856. -
  2857. -
  2858. -/* sysfs */
  2859. -static DEVICE_ATTR(idac, S_IRUGO|S_IWUSR, ttsp_idac_show, ttsp_idac_store);
  2860. -static DEVICE_ATTR(sig, S_IRUGO|S_IWUSR, ttsp_sig_show, ttsp_sig_store);
  2861. -static DEVICE_ATTR(rawbase, S_IRUGO|S_IWUSR, ttsp_rawbase_show, ttsp_rawbase_store);
  2862. -static DEVICE_ATTR(tpfwver, S_IRUGO|S_IWUSR, ttsp_tpfwver_show, ttsp_tpfwver_store);
  2863. -static DEVICE_ATTR(forcecal, S_IRUGO|S_IWUSR, ttsp_forcecal_show, ttsp_forcecal_store);
  2864. -static DEVICE_ATTR(fwupdate, S_IRUGO|S_IWUSR, ttsp_fwupdate_show, ttsp_fwupdate_store);
  2865. -static DEVICE_ATTR(interrupt_test, S_IRUGO, ttsp_interrupt_test_show, NULL);
  2866. -
  2867. -static struct attribute *ttsp_attributes[] = {
  2868. -    &dev_attr_idac.attr,
  2869. -    &dev_attr_sig.attr,
  2870. -    &dev_attr_rawbase.attr,
  2871. -    &dev_attr_tpfwver.attr,
  2872. -    &dev_attr_forcecal.attr,
  2873. -    &dev_attr_fwupdate.attr,
  2874. -    &dev_attr_interrupt_test.attr,
  2875. -    NULL
  2876. -};
  2877. -
  2878. -static struct attribute_group ttsp_attribute_group = {
  2879. -   .attrs = ttsp_attributes
  2880. -};
  2881. -
  2882. -static int cyttsp_power_on(struct cyttsp *ts)
  2883. -{
  2884. -   int retval = CY_OK;
  2885. -   u8 host_reg;
  2886. -   int tries;
  2887. -
  2888. -   cyttsp_debug("Power up \n");
  2889. -
  2890. -   tries = 0;
  2891. -   do {
  2892. -       /* set arg2 to non-0 to activate */
  2893. -       retval = cyttsp_putbl(ts, 1, true, true, true);
  2894. -       cyttsp_info("BL%d: f=%02X s=%02X err=%02X bl=%02X%02X bld=%02X%02X R=%d\n", \
  2895. -           101, \
  2896. -           g_bl_data.bl_file, g_bl_data.bl_status, \
  2897. -           g_bl_data.bl_error, \
  2898. -           g_bl_data.blver_hi, g_bl_data.blver_lo, \
  2899. -           g_bl_data.bld_blver_hi, g_bl_data.bld_blver_lo,
  2900. -           retval);
  2901. -       cyttsp_info("BL%d: tver=%02X%02X a_id=%02X%02X aver=%02X%02X\n", \
  2902. -           102, \
  2903. -           g_bl_data.ttspver_hi, g_bl_data.ttspver_lo, \
  2904. -           g_bl_data.appid_hi, g_bl_data.appid_lo, \
  2905. -           g_bl_data.appver_hi, g_bl_data.appver_lo);
  2906. -       cyttsp_info("BL%d: c_id=%02X%02X%02X\n", \
  2907. -           103, \
  2908. -           g_bl_data.cid_0, g_bl_data.cid_1, g_bl_data.cid_2);
  2909. -   } while (((retval < CY_OK) ||
  2910. -       !GET_BOOTLOADERMODE(g_bl_data.bl_status)) &&
  2911. -       tries++ < 10);
  2912. -  
  2913. -   /* is bootloader missing? */
  2914. -   if (!(retval < CY_OK)) {
  2915. -       cyttsp_xdebug("Ret=%d  Check if bootloader is missing...\n", \
  2916. -           retval);
  2917. -       if (!GET_BOOTLOADERMODE(g_bl_data.bl_status)) {
  2918. -           /* skip all bl and sys info and go to op mode */
  2919. -           if (!(retval < CY_OK)) {
  2920. -               cyttsp_xdebug("Bl is missing (ret=%d)\n", \
  2921. -                   retval);
  2922. -               host_reg = CY_OP_MODE/* + CY_LOW_PWR_MODE*/;
  2923. -               retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE,
  2924. -                   sizeof(host_reg), &host_reg);
  2925. -               /* wait for TTSP Device to complete switch to
  2926. -                * Operational mode */
  2927. -               mdelay(CYTTSP_MDELAY);
  2928. -               goto bypass;
  2929. -           }
  2930. -       }
  2931. -   }
  2932. -
  2933. -   /* take TTSP out of bootloader mode; go to TrueTouch operational mode */
  2934. -   if (!(retval < CY_OK)) {
  2935. -       cyttsp_xdebug1("exit bootloader; go operational\n");
  2936. -       tries = 0;
  2937. -       do {
  2938. -
  2939. -           retval = i2c_smbus_write_i2c_block_data(ts->client,
  2940. -                               CY_REG_BASE,
  2941. -                               sizeof(bl_cmd),
  2942. -                               bl_cmd);
  2943. -
  2944. -           if(retval < 0){
  2945. -               msleep(100);
  2946. -           }
  2947. -       }while((retval < 0) && ( tries++ < 10));
  2948. -
  2949. -       if(retval < 0){
  2950. -           printk("\ncyttsp: line - %d:i2c write failed\n",__LINE__);
  2951. -       }
  2952. -
  2953. -       msleep(CYTTSP_MDELAY);
  2954. -
  2955. -                retval = cyttsp_wait_for_i2c(ts);
  2956. -                if(retval < 0){
  2957. -                        printk("\ncyttsp: - line %d: i2c not ready\n",__LINE__);
  2958. -                }
  2959. -   }
  2960. -
  2961. -
  2962. -bypass:
  2963. -   /* switch to System Information mode to read versions
  2964. -    * and set interval registers */
  2965. -   if (!(retval < CY_OK)) {
  2966. -       cyttsp_debug("switch to sysinfo mode \n");
  2967. -       host_reg = CY_SYSINFO_MODE;
  2968. -       tries = 0;
  2969. -       do{
  2970. -
  2971. -           retval = i2c_smbus_write_i2c_block_data(ts->client,
  2972. -                               CY_REG_BASE,
  2973. -                               sizeof(host_reg),
  2974. -                               &host_reg);
  2975. -           if(retval < 0){
  2976. -               msleep(100);
  2977. -           }
  2978. -       }while((retval < 0) && (tries++ < 10));
  2979. -
  2980. -       if(retval < 0){
  2981. -           printk("\ncyttsp:line - %d: i2c write failed\n",__LINE__);
  2982. -       }
  2983. -
  2984. -       /* wait for TTSP Device to complete switch to SysInfo mode */
  2985. -       mdelay(CYTTSP_MDELAY);
  2986. -                retval = cyttsp_wait_for_i2c(ts);
  2987. -       if(retval < 0){
  2988. -           printk("\ncyttsp: line - %d: i2c not ready\n",__LINE__);
  2989. -       }
  2990. -
  2991. -       if (!(retval < CY_OK)) {
  2992. -           retval = i2c_smbus_read_i2c_block_data(ts->client,
  2993. -                               CY_REG_BASE,
  2994. -                               sizeof(struct cyttsp_sysinfo_data_t),
  2995. -                               (u8 *)&g_sysinfo_data);
  2996. -           if(retval<0){
  2997. -               printk("\ncyttsp: line - %d: i2c read failed\n",__LINE__);
  2998. -           }
  2999. -           cyttsp_debug("SI2: hst_mode=0x%02X mfg_cmd=0x%02X mfg_stat=0x%02X\n", \
  3000. -               g_sysinfo_data.hst_mode, \
  3001. -               g_sysinfo_data.mfg_cmd, \
  3002. -               g_sysinfo_data.mfg_stat);
  3003. -           cyttsp_debug("SI2: bl_ver=0x%02X%02X\n", \
  3004. -               g_sysinfo_data.bl_verh, \
  3005. -               g_sysinfo_data.bl_verl);
  3006. -           cyttsp_debug("SI2: sysinfo act_int=0x%02X tch_tmout=0x%02X lp_int=0x%02X\n", \
  3007. -               g_sysinfo_data.act_intrvl, \
  3008. -               g_sysinfo_data.tch_tmout, \
  3009. -               g_sysinfo_data.lp_intrvl);
  3010. -           cyttsp_info("SI%d: tver=%02X%02X a_id=%02X%02X aver=%02X%02X\n", \
  3011. -               102, \
  3012. -               g_sysinfo_data.tts_verh, \
  3013. -               g_sysinfo_data.tts_verl, \
  3014. -               g_sysinfo_data.app_idh, \
  3015. -               g_sysinfo_data.app_idl, \
  3016. -               g_sysinfo_data.app_verh, \
  3017. -               g_sysinfo_data.app_verl);
  3018. -           cyttsp_info("SI%d: c_id=%02X%02X%02X\n", \
  3019. -               103, \
  3020. -               g_sysinfo_data.cid[0], \
  3021. -               g_sysinfo_data.cid[1], \
  3022. -               g_sysinfo_data.cid[2]);
  3023. -           if (!(retval < CY_OK) &&
  3024. -               (CY_DIFF(ts->platform_data->act_intrvl,
  3025. -                   CY_ACT_INTRVL_DFLT)  ||
  3026. -               CY_DIFF(ts->platform_data->tch_tmout,
  3027. -                   CY_TCH_TMOUT_DFLT) ||
  3028. -               CY_DIFF(ts->platform_data->lp_intrvl,
  3029. -                   CY_LP_INTRVL_DFLT))) {
  3030. -               if (!(retval < CY_OK)) {
  3031. -                   u8 intrvl_ray[sizeof(ts->platform_data->act_intrvl) +
  3032. -                       sizeof(ts->platform_data->tch_tmout) +
  3033. -                       sizeof(ts->platform_data->lp_intrvl)];
  3034. -                   u8 i = 0;
  3035. -
  3036. -                   intrvl_ray[i++] =
  3037. -                       ts->platform_data->act_intrvl;
  3038. -                   intrvl_ray[i++] =
  3039. -                       ts->platform_data->tch_tmout;
  3040. -                   intrvl_ray[i++] =
  3041. -                       ts->platform_data->lp_intrvl;
  3042. -
  3043. -                   cyttsp_debug("SI2: platinfo act_intrvl=0x%02X tch_tmout=0x%02X lp_intrvl=0x%02X\n", \
  3044. -                       ts->platform_data->act_intrvl, \
  3045. -                       ts->platform_data->tch_tmout, \
  3046. -                       ts->platform_data->lp_intrvl);
  3047. -                   /* set intrvl registers */
  3048. -                   tries = 0;
  3049. -                   do {
  3050. -                       retval = i2c_smbus_write_i2c_block_data(ts->client,
  3051. -                                           CY_REG_ACT_INTRVL,
  3052. -                                           sizeof(intrvl_ray),
  3053. -                                           intrvl_ray);
  3054. -                       msleep(CY_DLY_SYSINFO);
  3055. -                       if(retval < 0){
  3056. -                           msleep(100);
  3057. -                       }
  3058. -                   }while( (retval < 0) && (tries++ < 10) );
  3059. -               }
  3060. -           }
  3061. -       }
  3062. -       /* switch back to Operational mode */
  3063. -       cyttsp_debug("switch back to operational mode \n");
  3064. -       if (!(retval < CY_OK)) {
  3065. -           tries = 0;
  3066. -           do{
  3067. -               host_reg = CY_OP_MODE/* + CY_LOW_PWR_MODE*/;
  3068. -               retval = i2c_smbus_write_i2c_block_data(ts->client,
  3069. -                                   CY_REG_BASE,
  3070. -                                   sizeof(host_reg),
  3071. -                                   &host_reg);
  3072. -               if(retval < 0){
  3073. -                   msleep(100);
  3074. -               }
  3075. -           }while( (retval < 0) && (tries++ < 10));
  3076. -
  3077. -           /* wait for TTSP Device to complete
  3078. -            * switch to Operational mode */
  3079. -           mdelay(CYTTSP_MDELAY);
  3080. -           retval = cyttsp_wait_for_i2c(ts);
  3081. -           if(retval < 0){
  3082. -               printk("\ncyttsp: line - %d: i2c not ready",__LINE__);
  3083. -           }
  3084. -       }
  3085. -   }
  3086. -   /* init gesture setup;
  3087. -    * this is required even if not using gestures
  3088. -    * in order to set the active distance */
  3089. -   tries = 0 ;
  3090. -   if (!(retval < CY_OK)) {
  3091. -       u8 gesture_setup;
  3092. -       cyttsp_debug("init gesture setup \n");
  3093. -       do {
  3094. -           gesture_setup = ts->platform_data->gest_set;
  3095. -           retval = i2c_smbus_write_i2c_block_data(ts->client,
  3096. -                               CY_REG_GEST_SET,
  3097. -                               sizeof(gesture_setup),
  3098. -                               &gesture_setup);
  3099. -           msleep(CY_DLY_DFLT);
  3100. -
  3101. -           if(retval < 0){
  3102. -               msleep(100);
  3103. -           }
  3104. -
  3105. -       } while((retval < 0) && (tries++ < 10 ));
  3106. -   }
  3107. -
  3108. -   if(retval < 0){
  3109. -       printk("\ncyttsp: line - %d : i2c write failed",__LINE__);
  3110. -   }
  3111. -
  3112. -   if (!(retval < CY_OK))
  3113. -       ts->platform_data->power_state = CY_ACTIVE_STATE;
  3114. -   else
  3115. -       ts->platform_data->power_state = CY_IDLE_STATE;
  3116. -
  3117. -   cyttsp_debug("Retval=%d Power state is %s\n", \
  3118. -       retval, \
  3119. -       ts->platform_data->power_state == CY_ACTIVE_STATE ? \
  3120. -        "ACTIVE" : "IDLE");
  3121. -   return retval;
  3122. -}
  3123. -
  3124. -/* cyttsp_initialize: Driver Initialization. This function takes
  3125. - * care of the following tasks:
  3126. - * 1. Create and register an input device with input layer
  3127. - * 2. Take CYTTSP device out of bootloader mode; go operational
  3128. - * 3. Start any timers/Work queues.  */
  3129. -static int cyttsp_initialize(struct i2c_client *client, struct cyttsp *ts)
  3130. -{
  3131. -   struct input_dev *input_device;
  3132. -   int error = 0;
  3133. -   int retval = CY_OK;
  3134. -   u8 id;
  3135. -   int err = -1;
  3136. -
  3137. -   /* Create the input device and register it. */
  3138. -   input_device = input_allocate_device();
  3139. -   if (!input_device) {
  3140. -       error = -ENOMEM;
  3141. -       cyttsp_xdebug1("err input allocate device\n");
  3142. -       goto error_free_device;
  3143. -   }
  3144. -
  3145. -   if (!client) {
  3146. -       error = ~ENODEV;
  3147. -       cyttsp_xdebug1("err client is Null\n");
  3148. -       goto error_free_device;
  3149. -   }
  3150. -
  3151. -   if (!ts) {
  3152. -       error = ~ENODEV;
  3153. -       cyttsp_xdebug1("err context is Null\n");
  3154. -       goto error_free_device;
  3155. -   }
  3156. -
  3157. -
  3158. -   ts->input = input_device;
  3159. -   input_device->name = CY_I2C_NAME;
  3160. -   input_device->phys = ts->phys;
  3161. -   input_device->dev.parent = &client->dev;
  3162. -
  3163. -   /* init the touch structures */
  3164. -   ts->num_prv_st_tch = CY_NTCH;
  3165. -   for (id = 0; id < CY_NUM_TRK_ID; id++) {
  3166. -       ts->act_trk[id] = CY_NTCH;
  3167. -       ts->prv_mt_pos[id][CY_XPOS] = 0;
  3168. -       ts->prv_mt_pos[id][CY_YPOS] = 0;
  3169. -   }
  3170. -
  3171. -   for (id = 0; id < CY_NUM_MT_TCH_ID; id++)
  3172. -       ts->prv_mt_tch[id] = CY_IGNR_TCH;
  3173. -
  3174. -   for (id = 0; id < CY_NUM_ST_TCH_ID; id++)
  3175. -       ts->prv_st_tch[id] = CY_IGNR_TCH;
  3176. -
  3177. -   set_bit(EV_SYN, input_device->evbit);
  3178. -   set_bit(EV_KEY, input_device->evbit);
  3179. -   set_bit(EV_ABS, input_device->evbit);
  3180. -   set_bit(BTN_TOUCH, input_device->keybit);
  3181. -   set_bit(BTN_2, input_device->keybit);
  3182. -   if (ts->platform_data->use_gestures)
  3183. -       set_bit(BTN_3, input_device->keybit);
  3184. -
  3185. -   input_set_abs_params(input_device,
  3186. -       ABS_X, 0, ts->platform_data->maxx, 0, 0);
  3187. -   input_set_abs_params(input_device,
  3188. -       ABS_Y, 0, ts->platform_data->maxy, 0, 0);
  3189. -   input_set_abs_params(input_device,
  3190. -       ABS_TOOL_WIDTH, 0, CY_LARGE_TOOL_WIDTH, 0 , 0);
  3191. -   input_set_abs_params(input_device,
  3192. -       ABS_PRESSURE, 0, CY_MAXZ, 0, 0);
  3193. -   input_set_abs_params(input_device,
  3194. -       ABS_HAT0X, 0, ts->platform_data->maxx, 0, 0);
  3195. -   input_set_abs_params(input_device,
  3196. -       ABS_HAT0Y, 0, ts->platform_data->maxy, 0, 0);
  3197. -   if (ts->platform_data->use_gestures) {
  3198. -       input_set_abs_params(input_device,
  3199. -           ABS_HAT1X, 0, 255, 0, 0);  // Gesture code.
  3200. -       input_set_abs_params(input_device,
  3201. -           ABS_HAT2X, 0, 255, 0, 0);  // Gesture touch count.
  3202. -       input_set_abs_params(input_device,
  3203. -           ABS_HAT2Y, 0, 255, 0, 0);  // Gesture occur count.
  3204. -   }
  3205. -   if (ts->platform_data->use_mt) {
  3206. -       input_set_abs_params(input_device,
  3207. -           ABS_MT_POSITION_X, 0, ts->platform_data->maxx, 0, 0);
  3208. -       input_set_abs_params(input_device,
  3209. -           ABS_MT_POSITION_Y, 0, ts->platform_data->maxy, 0, 0);
  3210. -       input_set_abs_params(input_device,
  3211. -           ABS_MT_TOUCH_MAJOR, 0, CY_MAXZ, 0, 0);
  3212. -       input_set_abs_params(input_device,
  3213. -           ABS_MT_WIDTH_MAJOR, 0, CY_LARGE_TOOL_WIDTH, 0, 0);
  3214. -       if (ts->platform_data->use_trk_id) {
  3215. -           input_set_abs_params(input_device,
  3216. -               ABS_MT_TRACKING_ID, 0, CY_NUM_TRK_ID, 0, 0);
  3217. -       }
  3218. -   }
  3219. -
  3220. -   /* set dummy key to make driver work with virtual keys */
  3221. -   input_set_capability(input_device, EV_KEY, KEY_PROG1);
  3222. -
  3223. -   cyttsp_info("%s: Register input device\n", CY_I2C_NAME);
  3224. -   error = input_register_device(input_device);
  3225. -   if (error) {
  3226. -       cyttsp_alert("%s: Failed to register input device\n", \
  3227. -           CY_I2C_NAME);
  3228. -       retval = error;
  3229. -       goto error_free_device;
  3230. -   }
  3231. -
  3232. -   mutex_lock(&thread_mutex);
  3233. -
  3234. -   /* Set up update worker thread, which will unlock the mutex when done */
  3235. -        INIT_WORK(&ts->init_work, cyttsp_init_worker);
  3236. -
  3237. -   /* Prepare our worker structure prior to setting up the timer/ISR */
  3238. -        INIT_WORK(&ts->work, cyttsp_xy_worker);
  3239. -
  3240. -   /* Interrupt setup */
  3241. -   if (ts->client->irq) {
  3242. -       cyttsp_info("Setting up interrupt %d\n",ts->client->irq);
  3243. -
  3244. -       /* request_irq() will call enable_irq() */
  3245. -       retval = request_irq(ts->client->irq,
  3246. -               cyttsp_irq,
  3247. -               IRQF_TRIGGER_FALLING,
  3248. -               ts->client->dev.driver->name,
  3249. -               ts);
  3250. -
  3251. -       if (retval) {
  3252. -           cyttsp_alert("error: could not request irq\n");
  3253. -           free_irq(ts->client->irq, ts);
  3254. -       }
  3255. -   }
  3256. -
  3257. -   irq_cnt = 0;
  3258. -   irq_cnt_total = 0;
  3259. -   irq_err_cnt = 0;
  3260. -
  3261. -   atomic_set(&ts->irq_enabled, 1);
  3262. -
  3263. -   err = sysfs_create_group(&client->dev.kobj, &ttsp_attribute_group);
  3264. -   if (err){
  3265. -       cyttsp_alert("%s: sysfs_create_group() failed!!\n", \
  3266. -           __FUNCTION__);
  3267. -   }
  3268. -   else
  3269. -       cyttsp_info("%s:  Create sysfs_group successfully!\n", __FUNCTION__);
  3270. -
  3271. -   retval = device_create_file(&ts->client->dev, &dev_attr_irq_enable);
  3272. -        if (retval < CY_OK) {
  3273. -                cyttsp_alert("File device creation failed: %d\n", retval);
  3274. -                retval = -ENODEV;
  3275. -                goto error_free_irq;
  3276. -        }
  3277. -
  3278. -
  3279. -   queue_work(cyttsp_ts_wq, &ts->init_work);
  3280. -
  3281. -   goto success;
  3282. -
  3283. -error_free_irq:
  3284. -   cyttsp_alert("Error: Failed to register IRQ handler\n");
  3285. -   free_irq(client->irq, ts);
  3286. -
  3287. -error_free_device:
  3288. -   if (input_device)
  3289. -       input_free_device(input_device);
  3290. -
  3291. -success:
  3292. -   return retval;
  3293. -}
  3294. -
  3295. -/* I2C driver probe function */
  3296. -static int __devinit cyttsp_probe(struct i2c_client *client,
  3297. -           const struct i2c_device_id *id)
  3298. -{
  3299. -   struct cyttsp *ts;
  3300. -   int error;
  3301. -   int retval = CY_OK;
  3302. -  
  3303. -   // request gpio resources
  3304. -   if (cyttsp_dev_init(1) <0)
  3305. -   {
  3306. -       retval = -ENODEV;
  3307. -       goto exit;
  3308. -   }
  3309. -  
  3310. -   ts = kzalloc(sizeof(struct cyttsp), GFP_KERNEL);
  3311. -   if (ts == NULL) {
  3312. -       cyttsp_xdebug1("err kzalloc for cyttsp\n");
  3313. -       retval = -ENOMEM;
  3314. -       goto err0;
  3315. -   }
  3316. -
  3317. -   /* allocate and clear memory */
  3318. -   ts->reg = regulator_get(NULL, "vtp");
  3319. -
  3320. -   if (IS_ERR(ts->reg)) {
  3321. -       printk("cyttsp:failed to get vtp regulator\n");
  3322. -       retval = IS_ERR(ts->reg);
  3323. -       goto err1;
  3324. -   }
  3325. -
  3326. -   retval = regulator_enable(ts->reg);
  3327. -
  3328. -   if (retval) {
  3329. -       printk("cyttsp:failed to enable regulator\n");
  3330. -       goto err2;
  3331. -   }
  3332. -
  3333. -   mdelay(100);
  3334. -   printk("cyttsp:Reseting TMA340\n");
  3335. -   gpio_direction_output(OMAP_CYTTSP_RESET_GPIO, 0);
  3336. -   mdelay(10);
  3337. -   gpio_direction_output(OMAP_CYTTSP_RESET_GPIO, 1);
  3338. -   mdelay(100); //TODO: Delay is needed for chip to reset but may not need 100.
  3339. -
  3340. -   printk("cyttsp:Start Probe 1.2\n");
  3341. -  
  3342. -   //TODO: temp. needed to determine TP type (tma340 or tmg120)
  3343. -   //TODO: To be removed once tmg120 is not supported.
  3344. -   {
  3345. -       unsigned char buf;
  3346. -       int rc;
  3347. -       client->addr = 34;
  3348. -       buf=15;
  3349. -       rc = i2c_master_send(client, &buf, 1);
  3350. -       rc = i2c_master_recv(client, &buf, 1);
  3351. -       if (rc < 0){
  3352. -           printk("cyttsp:No TMA340 found; exiting probe.\n");
  3353. -           retval = -ENODEV;      
  3354. -           // free resources
  3355. -           goto err3;
  3356. -       }
  3357. -   }
  3358. -  
  3359. -   if (!(retval < CY_OK)) {
  3360. -       /* register driver_data */
  3361. -       ts->client = client;
  3362. -       ts->platform_data = client->dev.platform_data;
  3363. -       i2c_set_clientdata(client, ts);
  3364. -
  3365. -                retval = i2c_smbus_read_i2c_block_data(ts->client,
  3366. -                                CY_REG_BASE,
  3367. -                                sizeof(struct cyttsp_bootloader_data_t),
  3368. -                                (u8 *)&g_bl_data);
  3369. -
  3370. -                if( retval > CY_OK ) {
  3371. -
  3372. -                   if(GET_BOOTLOADERMODE(g_bl_data.bl_status)){
  3373. -               printk("\ncyttsp::found BL, Overriding maxx & maxy\n");
  3374. -               ts->platform_data->maxx=600;
  3375. -               ts->platform_data->maxy=1024;
  3376. -           }
  3377. -           else {
  3378. -               printk("\ncyttsp::BL NOT FOUND\n");
  3379. -           }
  3380. -
  3381. -       }
  3382. -
  3383. -       error = cyttsp_initialize(client, ts);
  3384. -       if (error) {
  3385. -           cyttsp_xdebug1("err cyttsp_initialize\n");
  3386. -           retval = -ENODEV;
  3387. -            goto err3;
  3388. -       } else
  3389. -           cyttsp_openlog();
  3390. -   }
  3391. -
  3392. -#ifdef CONFIG_HAS_EARLYSUSPEND
  3393. -   if (!(retval < CY_OK)) {
  3394. -       ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
  3395. -       ts->early_suspend.suspend = cyttsp_early_suspend;
  3396. -       ts->early_suspend.resume = cyttsp_late_resume;
  3397. -       register_early_suspend(&ts->early_suspend);
  3398. -   }
  3399. -#endif /* CONFIG_HAS_EARLYSUSPEND */
  3400. -
  3401. -exit:
  3402. -   printk("cyttsp:Start Probe %s\n", \
  3403. -       (retval < CY_OK) ? "FAIL" : "PASS");
  3404. -
  3405. -   if(retval>0)
  3406. -   {
  3407. -       retval = 0;
  3408. -   }
  3409. -
  3410. -   return retval;
  3411. -err3:
  3412. -    regulator_disable(ts->reg);
  3413. -err2:
  3414. -    regulator_put(ts->reg);
  3415. -err1:
  3416. -    kfree(ts);
  3417. -err0:
  3418. -    cyttsp_dev_init(0);
  3419. -    printk("cyttsp:probe failed: %d\n", retval);
  3420. -    return retval;
  3421. -}
  3422. -
  3423. -/* Function to manage power-on resume */
  3424. -static int cyttsp_resume(struct i2c_client *client)
  3425. -{
  3426. -   struct cyttsp *ts;
  3427. -   int retval = CY_OK;
  3428. -
  3429. -   cyttsp_debug("Wake Up\n");
  3430. -   ts = (struct cyttsp *) i2c_get_clientdata(client);
  3431. -
  3432. -   retval = regulator_enable(ts->reg);
  3433. -   /* pulse reset */
  3434. -   msleep(10);
  3435. -   gpio_direction_output(OMAP_CYTTSP_RESET_GPIO, 0);
  3436. -   msleep(10);
  3437. -   gpio_direction_output(OMAP_CYTTSP_RESET_GPIO, 1);
  3438. -   msleep(10);
  3439. -
  3440. -   if (retval == 0) {
  3441. -       retval = cyttsp_power_on(ts);
  3442. -   }
  3443. -
  3444. -   if (!(retval < CY_OK) &&
  3445. -       (GET_HSTMODE(g_bl_data.bl_file) == CY_OK)) {
  3446. -
  3447. -       ts->platform_data->power_state = CY_ACTIVE_STATE;
  3448. -       if(ts->client->irq){
  3449. -           cyttsp_debug("enable irq\n");
  3450. -           enable_irq(ts->client->irq);
  3451. -       }
  3452. -   } else
  3453. -       retval = -ENODEV;
  3454. -
  3455. -   cyttsp_debug("Wake Up %s\n", \
  3456. -       (retval < CY_OK) ? "FAIL" : "PASS");
  3457. -
  3458. -   return retval;
  3459. -}
  3460. -
  3461. -
  3462. -/* Function to manage low power suspend */
  3463. -static int cyttsp_suspend(struct i2c_client *client, pm_message_t message)
  3464. -{
  3465. -   struct cyttsp *ts;
  3466. -   u8 sleep_mode = CY_OK;
  3467. -   int retval = CY_OK;
  3468. -
  3469. -   cyttsp_debug("Enter Sleep\n");
  3470. -   ts = (struct cyttsp *) i2c_get_clientdata(client);
  3471. -
  3472. -   /* finish any work already scheduled,
  3473. -    * this is important for fw update */
  3474. -   flush_workqueue(cyttsp_ts_wq);
  3475. -
  3476. -   /* disable worker */
  3477. -   if (ts->client->irq == 0)
  3478. -       del_timer(&ts->timer);
  3479. -   else
  3480. -       disable_irq(ts->client->irq);
  3481. -
  3482. -   retval = cancel_work_sync(&ts->work);
  3483. -
  3484. -   if (retval)
  3485. -       enable_irq(ts->client->irq);
  3486. -
  3487. -   retval = regulator_disable(ts->reg);
  3488. -
  3489. -   if (!(retval < CY_OK)) {
  3490. -       if (sleep_mode == CY_DEEP_SLEEP_MODE)
  3491. -           ts->platform_data->power_state = CY_SLEEP_STATE;
  3492. -       else if (sleep_mode == CY_LOW_PWR_MODE)
  3493. -           ts->platform_data->power_state = CY_LOW_PWR_STATE;
  3494. -       else // is off
  3495. -           ts->platform_data->power_state = CY_POWER_OFF_STATE;
  3496. -   }
  3497. -
  3498. -   cyttsp_debug("Sleep Power state is %s\n", \
  3499. -       (ts->platform_data->power_state == CY_ACTIVE_STATE) ? \
  3500. -       "ACTIVE" : \
  3501. -       ((ts->platform_data->power_state == CY_SLEEP_STATE) ? \
  3502. -       "SLEEP" : \
  3503. -        (((ts->platform_data->power_state == CY_LOW_PWR_STATE) ? "LOW POWER" : "POWER OFF"))));
  3504. -
  3505. -   return retval;
  3506. -}
  3507. -
  3508. -/* registered in driver struct */
  3509. -static int __devexit cyttsp_remove(struct i2c_client *client)
  3510. -{
  3511. -   struct cyttsp *ts;
  3512. -   int err;
  3513. -
  3514. -   cyttsp_alert("Unregister\n");
  3515. -
  3516. -   /* clientdata registered on probe */
  3517. -   ts = i2c_get_clientdata(client);
  3518. -   device_remove_file(&ts->client->dev, &dev_attr_irq_enable);
  3519. -
  3520. -   /* Remove update work if still scheduled */
  3521. -   cancel_work_sync(&ts->init_work);
  3522. -
  3523. -   /* Start cleaning up by removing any delayed work and the timer */
  3524. -   if (cancel_delayed_work((struct delayed_work *)&ts->work) < CY_OK)
  3525. -       cyttsp_alert("error: could not remove work from workqueue\n");
  3526. -
  3527. -   /* free up timer or irq */
  3528. -   if (ts->client->irq == 0) {
  3529. -       err = del_timer(&ts->timer);
  3530. -       if (err < CY_OK)
  3531. -           cyttsp_alert("error: failed to delete timer\n");
  3532. -   } else
  3533. -       free_irq(client->irq, ts);
  3534. -
  3535. -#ifdef CONFIG_HAS_EARLYSUSPEND
  3536. -   unregister_early_suspend(&ts->early_suspend);
  3537. -#endif /* CONFIG_HAS_EARLYSUSPEND */
  3538. -
  3539. -   if (ts->platform_data->power_state != CY_POWER_OFF_STATE) {
  3540. -       regulator_disable(ts->reg);
  3541. -   }
  3542. -
  3543. -   regulator_put(ts->reg);
  3544. -
  3545. -   /* housekeeping */
  3546. -   sysfs_remove_group(&client->dev.kobj, &ttsp_attribute_group);
  3547. -   if (ts != NULL)
  3548. -       kfree(ts);
  3549. -
  3550. -   cyttsp_alert("Leaving\n");
  3551. -
  3552. -   return 0;
  3553. -}
  3554. -
  3555. -#ifdef CONFIG_HAS_EARLYSUSPEND
  3556. -static void cyttsp_early_suspend(struct early_suspend *handler)
  3557. -{
  3558. -   struct cyttsp *ts;
  3559. -   ts = container_of(handler, struct cyttsp, early_suspend);
  3560. -   cyttsp_suspend(ts->client, PMSG_SUSPEND);
  3561. -}
  3562. -
  3563. -static void cyttsp_late_resume(struct early_suspend *handler)
  3564. -{
  3565. -   struct cyttsp *ts;
  3566. -   ts = container_of(handler, struct cyttsp, early_suspend);
  3567. -   cyttsp_resume(ts->client);
  3568. -}
  3569. -#endif  /* CONFIG_HAS_EARLYSUSPEND */
  3570. -
  3571. -static int cyttsp_init(void)
  3572. -{
  3573. -   int ret;
  3574. -
  3575. -   cyttsp_info("Cypress TrueTouch(R) Standard Product\n");
  3576. -   cyttsp_info("I2C Touchscreen Driver (Built %s @ %s)\n", \
  3577. -       __DATE__, __TIME__);
  3578. -
  3579. -   cyttsp_ts_wq = create_singlethread_workqueue("cyttsp_ts_wq");
  3580. -   if (cyttsp_ts_wq == NULL) {
  3581. -       cyttsp_debug("No memory for cyttsp_ts_wq\n");
  3582. -       return -ENOMEM;
  3583. -   }
  3584. -
  3585. -   ret = i2c_add_driver(&cyttsp_driver);
  3586. -
  3587. -   return ret;
  3588. -}
  3589. -
  3590. -static void cyttsp_exit(void)
  3591. -{
  3592. -   if (cyttsp_ts_wq)
  3593. -       destroy_workqueue(cyttsp_ts_wq);
  3594. -   return i2c_del_driver(&cyttsp_driver);
  3595. -}
  3596. -
  3597. -module_init(cyttsp_init);
  3598. -module_exit(cyttsp_exit);
  3599. -
  3600. diff --git a/include/linux/cyttsp.h b/include/linux/cyttsp.h
  3601. deleted file mode 100644
  3602. index 5a34382..0000000
  3603. --- a/include/linux/cyttsp.h
  3604. +++ /dev/null
  3605. @@ -1,695 +0,0 @@
  3606. -/* Header file for:
  3607. - * Cypress TrueTouch(TM) Standard Product touchscreen drivers.
  3608. - * include/linux/cyttsp.h
  3609. - *
  3610. - * Copyright (C) 2009, 2010 Cypress Semiconductor, Inc.
  3611. - *
  3612. - * Copyright (c) 2010, Barnes & Noble.
  3613. - *
  3614. - * This program is free software; you can redistribute it and/or
  3615. - * modify it under the terms of the GNU General Public License
  3616. - * version 2, and only version 2, as published by the
  3617. - * Free Software Foundation.
  3618. - *
  3619. - * This program is distributed in the hope that it will be useful,
  3620. - * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3621. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3622. - * GNU General Public License for more details.
  3623. - *
  3624. - * You should have received a copy of the GNU General Public License along
  3625. - * with this program; if not, write to the Free Software Foundation, Inc.,
  3626. - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  3627. - *
  3628. - * Cypress reserves the right to make changes without further notice
  3629. - * to the materials described herein. Cypress does not assume any
  3630. - * liability arising out of the application described herein.
  3631. - *
  3632. - * Contact Cypress Semiconductor at www.cypress.com
  3633. - *
  3634. - */
  3635. -
  3636. -
  3637. -#ifndef __CYTTSP_H__
  3638. -#define __CYTTSP_H__
  3639. -
  3640. -#include <linux/input.h>
  3641. -#include <linux/timer.h>
  3642. -#include <linux/workqueue.h>
  3643. -#include <linux/kernel.h>
  3644. -#include <linux/delay.h>
  3645. -
  3646. -#define CYPRESS_TTSP_NAME  "cyttsp"
  3647. -#define CY_I2C_NAME        "cyttsp-i2c"
  3648. -#define CY_SPI_NAME        "cyttsp-spi"
  3649. -
  3650. -#ifdef CY_DECLARE_GLOBALS
  3651. -   uint32_t cyttsp_tsdebug;
  3652. -   module_param_named(tsdebug, cyttsp_tsdebug, uint, 0664);
  3653. -   uint32_t cyttsp_tsxdebug;
  3654. -   module_param_named(tsxdebug, cyttsp_tsxdebug, uint, 0664);
  3655. -
  3656. -   uint32_t cyttsp_disable_touch;
  3657. -   module_param_named(disable_touch, cyttsp_disable_touch, uint, 0664);
  3658. -#else
  3659. -   extern uint32_t cyttsp_tsdebug;
  3660. -   extern uint32_t cyttsp_tsxdebug;
  3661. -   extern uint32_t cyttsp_disable_touch;
  3662. -#endif
  3663. -
  3664. -
  3665. -
  3666. -/******************************************************************************
  3667. - * Global Control, Used to control the behavior of the driver
  3668. - */
  3669. -
  3670. -/* defines for Gen2 (Txx2xx); Gen3 (Txx3xx)
  3671. - * use these defines to set cyttsp_platform_data.gen in board config file
  3672. - */
  3673. -#define CY_GEN2        2
  3674. -#define CY_GEN3        3
  3675. -
  3676. -/* define for using I2C driver
  3677. - */
  3678. -#define CY_USE_I2C_DRIVER
  3679. -
  3680. -/* defines for using SPI driver */
  3681. -/*
  3682. -#define CY_USE_SPI_DRIVER
  3683. - */
  3684. -#define CY_SPI_DFLT_SPEED_HZ       1000000
  3685. -#define CY_SPI_MAX_SPEED_HZ        4000000
  3686. -#define CY_SPI_SPEED_HZ            CY_SPI_DFLT_SPEED_HZ
  3687. -#define CY_SPI_BITS_PER_WORD       8
  3688. -#define CY_SPI_DAV         139 /* set correct gpio id */
  3689. -#define CY_SPI_BUFSIZE         512
  3690. -
  3691. -/* define if force new load file for bootloader load */
  3692. -/*
  3693. -#define CY_FORCE_FW_UPDATE
  3694. -*/
  3695. -
  3696. -/* undef for production use */
  3697. -/*
  3698. - */
  3699. -//#define CY_USE_DEBUG
  3700. -
  3701. -/* undef for irq use; use this define in the board configuration file */
  3702. -/*
  3703. -#define CY_USE_TIMER
  3704. - */
  3705. -
  3706. -/* undef to allow use of extra debug capability */
  3707. -
  3708. -//#define CY_ALLOW_EXTRA_DEBUG
  3709. -
  3710. -
  3711. -/* undef to remove additional debug prints */
  3712. -
  3713. -//#define CY_USE_EXTRA_DEBUG
  3714. -
  3715. -/* undef to remove additional debug prints */
  3716. -
  3717. -//#define CY_USE_EXTRA_DEBUG1
  3718. -
  3719. -/* undef to use operational touch timer jiffies; else use test jiffies */
  3720. -/*
  3721. -#define CY_USE_TIMER_DEBUG
  3722. - */
  3723. -
  3724. -/* define to use canned test data */
  3725. -/*
  3726. -#define CY_USE_TEST_DATA
  3727. - */
  3728. -
  3729. -/* define to activate power management */
  3730. -/*
  3731. -#define CY_USE_LOW_POWER
  3732. - */
  3733. -
  3734. -/* define if wake on i2c addr is activated */
  3735. -/*
  3736. -#define CY_USE_DEEP_SLEEP
  3737. - */
  3738. -
  3739. -/* define if gesture signaling is used
  3740. - * and which gesture groups to use
  3741. - */
  3742. -#define CY_USE_GEST
  3743. -// #define CY_USE_GEST_GRP1
  3744. -#define CY_USE_GEST_GRP2
  3745. -#define CY_USE_GEST_GRP3
  3746. -// #define CY_USE_GEST_GRP4
  3747. -
  3748. -/* Active distance in pixels for a gesture to be reported
  3749. - * if set to 0, then all gesture movements are reported
  3750. - */
  3751. -#define CY_ACT_DIST_DFLT   1
  3752. -#define CY_ACT_DIST            CY_ACT_DIST_DFLT
  3753. -
  3754. -/* define if MT signals are desired */
  3755. -/*
  3756. -*/
  3757. -#define CY_USE_MT_SIGNALS
  3758. -
  3759. -/* define if MT tracking id signals are used */
  3760. -/*
  3761. -#define CY_USE_MT_TRACK_ID
  3762. - */
  3763. -
  3764. -/* define if ST signals are required */
  3765. -/*
  3766. -#define CY_USE_ST_SIGNALS
  3767. -*/
  3768. -
  3769. -/* define to send handshake to device */
  3770. -/*
  3771. -#define CY_USE_HNDSHK
  3772. -*/
  3773. -
  3774. -/* define if log all raw motion signals to a sysfs file */
  3775. -/*
  3776. -#define CY_LOG_TO_FILE
  3777. -*/
  3778. -
  3779. -
  3780. -/* End of the Global Control section
  3781. - ******************************************************************************
  3782. - */
  3783. -#define CY_DIFF(m, n)      ((m) != (n))
  3784. -#define CY_LESS(m, n)      ((m) < (n))
  3785. -
  3786. -#ifdef CY_LOG_TO_FILE
  3787. -   #define cyttsp_openlog()    /* use sysfs */
  3788. -#else
  3789. -   #define cyttsp_openlog()
  3790. -#endif /* CY_LOG_TO_FILE */
  3791. -
  3792. -/* see kernel.h for pr_xxx def'ns */
  3793. -#define cyttsp_info(f, a...)       pr_info("%s:" f,  __func__ , ## a)
  3794. -#define cyttsp_error(f, a...)      pr_err("%s:" f,  __func__ , ## a)
  3795. -#define cyttsp_alert(f, a...)      pr_alert("%s:" f,  __func__ , ## a)
  3796. -
  3797. -#ifdef CY_USE_DEBUG
  3798. -   #define cyttsp_debug(f, a...)   pr_alert("%s:" f,  __func__ , ## a)
  3799. -#else
  3800. -   #define cyttsp_debug(f, a...)   {if (cyttsp_tsdebug) \
  3801. -                   pr_alert("%s:" f,  __func__ , ## a); }
  3802. -#endif /* CY_USE_DEBUG */
  3803. -
  3804. -#ifdef CY_ALLOW_EXTRA_DEBUG
  3805. -#ifdef CY_USE_EXTRA_DEBUG
  3806. -   #define cyttsp_xdebug(f, a...)  pr_alert("%s:" f,  __func__ , ## a)
  3807. -#else
  3808. -   #define cyttsp_xdebug(f, a...)  {if (cyttsp_tsxdebug) \
  3809. -                   pr_alert("%s:" f,  __func__ , ## a); }
  3810. -#endif /* CY_USE_EXTRA_DEBUG */
  3811. -
  3812. -#ifdef CY_USE_EXTRA_DEBUG1
  3813. -   #define cyttsp_xdebug1(f, a...) pr_alert("%s:" f,  __func__ , ## a)
  3814. -#else
  3815. -   #define cyttsp_xdebug1(f, a...)
  3816. -#endif /* CY_USE_EXTRA_DEBUG1 */
  3817. -#else
  3818. -   #define cyttsp_xdebug(f, a...)
  3819. -   #define cyttsp_xdebug1(f, a...)
  3820. -#endif /* CY_ALLOW_EXTRA_DEBUG */
  3821. -
  3822. -#ifdef CY_USE_TIMER_DEBUG
  3823. -   #define TOUCHSCREEN_TIMEOUT (msecs_to_jiffies(1000))
  3824. -#else
  3825. -   #define TOUCHSCREEN_TIMEOUT (msecs_to_jiffies(28))
  3826. -#endif
  3827. -
  3828. -/* reduce extra signals in MT only build
  3829. - * be careful not to lose backward compatibility for pre-MT apps
  3830. - */
  3831. -#ifdef CY_USE_ST_SIGNALS
  3832. -   #define CY_USE_ST   1
  3833. -#else
  3834. -   #define CY_USE_ST   0
  3835. -#endif /* CY_USE_ST_SIGNALS */
  3836. -
  3837. -/* rely on kernel input.h to define Multi-Touch capability */
  3838. -/* if input.h defines the Multi-Touch signals, then use MT */
  3839. -#if defined(ABS_MT_TOUCH_MAJOR) && defined(CY_USE_MT_SIGNALS)
  3840. -   #define CY_USE_MT   1
  3841. -   #define CY_MT_SYNC(input)   input_mt_sync(input)
  3842. -#else
  3843. -   #define CY_USE_MT   0
  3844. -   #define CY_MT_SYNC(input)
  3845. -   /* the following includes are provided to ensure a compile;
  3846. -    * the code that compiles with these defines will not be executed if
  3847. -    * the CY_USE_MT is properly used in the platform structure init
  3848. -    */
  3849. -   #ifndef ABS_MT_TOUCH_MAJOR
  3850. -   #define ABS_MT_TOUCH_MAJOR  0x30    /* touching ellipse */
  3851. -   #define ABS_MT_TOUCH_MINOR  0x31    /* (omit if circular) */
  3852. -   #define ABS_MT_WIDTH_MAJOR  0x32    /* approaching ellipse */
  3853. -   #define ABS_MT_WIDTH_MINOR  0x33    /* (omit if circular) */
  3854. -   #define ABS_MT_ORIENTATION  0x34    /* Ellipse orientation */
  3855. -   #define ABS_MT_POSITION_X   0x35    /* Center X ellipse position */
  3856. -   #define ABS_MT_POSITION_Y   0x36    /* Center Y ellipse position */
  3857. -   #define ABS_MT_TOOL_TYPE    0x37    /* Type of touching device */
  3858. -   #define ABS_MT_BLOB_ID      0x38    /* Group set of pkts as blob */
  3859. -   #endif /* ABS_MT_TOUCH_MAJOR */
  3860. -#endif /* ABS_MT_TOUCH_MAJOR and CY_USE_MT_SIGNALS */
  3861. -#if defined(ABS_MT_TRACKING_ID)  && defined(CY_USE_MT_TRACK_ID)
  3862. -   #define CY_USE_TRACKING_ID  1
  3863. -#else
  3864. -   #define CY_USE_TRACKING_ID  0
  3865. -/* define only if not defined already by system;
  3866. - * value based on linux kernel 2.6.30.10
  3867. - */
  3868. -#ifndef ABS_MT_TRACKING_ID
  3869. -   #define ABS_MT_TRACKING_ID  (ABS_MT_BLOB_ID+1)
  3870. -#endif
  3871. -#endif /* ABS_MT_TRACKING_ID */
  3872. -
  3873. -#ifdef CY_USE_DEEP_SLEEP
  3874. -   #define CY_USE_DEEP_SLEEP_SEL   0x80
  3875. -#else
  3876. -   #define CY_USE_DEEP_SLEEP_SEL   0x00
  3877. -#endif
  3878. -#ifdef CY_USE_LOW_POWER
  3879. -   #define CY_USE_SLEEP    (CY_USE_DEEP_SLEEP_SEL | 0x01)
  3880. -#else
  3881. -   #define CY_USE_SLEEP    0x00
  3882. -#endif /* CY_USE_LOW_POWER */
  3883. -
  3884. -#ifdef CY_USE_TEST_DATA
  3885. -   #define cyttsp_testdat(ray1, ray2, sizeofray) \
  3886. -       { \
  3887. -           int i; \
  3888. -           u8 *up1 = (u8 *)ray1; \
  3889. -           u8 *up2 = (u8 *)ray2; \
  3890. -           for (i = 0; i < sizeofray; i++) { \
  3891. -               up1[i] = up2[i]; \
  3892. -           } \
  3893. -       }
  3894. -#else
  3895. -   #define cyttsp_testdat(xy, test_xy, sizeofray)
  3896. -#endif /* CY_USE_TEST_DATA */
  3897. -
  3898. -/* helper macros */
  3899. -#define GET_NUM_TOUCHES(x)     ((x) & 0x0F)
  3900. -#define GET_TOUCH1_ID(x)       (((x) & 0xF0) >> 4)
  3901. -#define GET_TOUCH2_ID(x)       ((x) & 0x0F)
  3902. -#define GET_TOUCH3_ID(x)       (((x) & 0xF0) >> 4)
  3903. -#define GET_TOUCH4_ID(x)       ((x) & 0x0F)
  3904. -#define IS_LARGE_AREA(x)       (((x) & 0x10) >> 4)
  3905. -#define FLIP_DATA_FLAG         0x01
  3906. -#define REVERSE_X_FLAG         0x02
  3907. -#define REVERSE_Y_FLAG         0x04
  3908. -#define FLIP_DATA(flags)       ((flags) & FLIP_DATA_FLAG)
  3909. -#define REVERSE_X(flags)       ((flags) & REVERSE_X_FLAG)
  3910. -#define REVERSE_Y(flags)       ((flags) & REVERSE_Y_FLAG)
  3911. -#define FLIP_XY(x, y)          { \
  3912. -                       u16 tmp; \
  3913. -                       tmp = (x); \
  3914. -                       (x) = (y); \
  3915. -                       (y) = tmp; \
  3916. -                   }
  3917. -#define INVERT_X(x, xmax)      ((xmax) - (x))
  3918. -#define INVERT_Y(y, ymax)      ((ymax) - (y))
  3919. -#define SET_HSTMODE(reg, mode)     ((reg) & (mode))
  3920. -#define GET_HSTMODE(reg)       ((reg & 0x70) >> 4)
  3921. -#define GET_BOOTLOADERMODE(reg)        ((reg & 0x10) >> 4)
  3922. -
  3923. -/* constant definitions */
  3924. -/* maximum number of concurrent ST track IDs */
  3925. -#define CY_NUM_ST_TCH_ID       2
  3926. -
  3927. -/* maximum number of concurrent MT track IDs */
  3928. -#define CY_NUM_MT_TCH_ID       4
  3929. -
  3930. -/* maximum number of track IDs */
  3931. -#define CY_NUM_TRK_ID          16
  3932. -
  3933. -#define CY_NTCH                0   /* no touch (lift off) */
  3934. -#define CY_TCH             1   /* active touch (touchdown) */
  3935. -#define CY_ST_FNGR1_IDX            0
  3936. -#define CY_ST_FNGR2_IDX            1
  3937. -#define CY_MT_TCH1_IDX         0
  3938. -#define CY_MT_TCH2_IDX         1
  3939. -#define CY_MT_TCH3_IDX         2
  3940. -#define CY_MT_TCH4_IDX         3
  3941. -#define CY_XPOS                0
  3942. -#define CY_YPOS                1
  3943. -#define CY_IGNR_TCH            (-1)
  3944. -#define CY_SMALL_TOOL_WIDTH        10
  3945. -#define CY_LARGE_TOOL_WIDTH        255
  3946. -#define CY_REG_BASE            0x00
  3947. -#define CY_REG_GEST_SET            0x1E
  3948. -#define CY_REG_ACT_INTRVL      0x1D
  3949. -#define CY_REG_TCH_TMOUT       (CY_REG_ACT_INTRVL+1)
  3950. -#define CY_REG_LP_INTRVL       (CY_REG_TCH_TMOUT+1)
  3951. -#define CY_SOFT_RESET          ((1 << 0))
  3952. -#define CY_DEEP_SLEEP          ((1 << 1))
  3953. -#define CY_LOW_POWER           ((1 << 2))
  3954. -#define CY_MAXZ                255
  3955. -#define CY_OK              0
  3956. -#define CY_INIT                1
  3957. -#define    CY_DLY_DFLT         10  /* ms */
  3958. -#define CY_DLY_SYSINFO         20  /* ms */
  3959. -#define CY_DLY_BL          300
  3960. -#define CY_DLY_DNLOAD          100 /* ms */
  3961. -#define CY_NUM_RETRY           4   /* max num touch data read */
  3962. -
  3963. -/* handshake bit in the hst_mode reg */
  3964. -#define CY_HNDSHK_BIT          0x80
  3965. -#ifdef CY_USE_HNDSHK
  3966. -   #define CY_SEND_HNDSHK      1
  3967. -#else
  3968. -   #define CY_SEND_HNDSHK      0
  3969. -#endif
  3970. -
  3971. -/* Bootloader File 0 offset */
  3972. -#define CY_BL_FILE0            0x00
  3973. -
  3974. -/* Bootloader command directive */
  3975. -#define CY_BL_CMD          0xFF
  3976. -
  3977. -/* Bootloader Initiate Bootload */
  3978. -#define CY_BL_INIT_LOAD            0x38
  3979. -
  3980. -/* Bootloader Write a Block */
  3981. -#define CY_BL_WRITE_BLK            0x39
  3982. -
  3983. -/* Bootloader Terminate Bootload */
  3984. -#define CY_BL_TERMINATE            0x3B
  3985. -
  3986. -/* Bootloader Exit and Verify Checksum command */
  3987. -#define CY_BL_EXIT         0xA5
  3988. -
  3989. -/* Bootloader default keys */
  3990. -#define CY_BL_KEY0         0x00
  3991. -#define CY_BL_KEY1         0x01
  3992. -#define CY_BL_KEY2         0x02
  3993. -#define CY_BL_KEY3         0x03
  3994. -#define CY_BL_KEY4         0x04
  3995. -#define CY_BL_KEY5         0x05
  3996. -#define CY_BL_KEY6         0x06
  3997. -#define CY_BL_KEY7         0x07
  3998. -
  3999. -/* Active Power state scanning/processing refresh interval */
  4000. -#define CY_ACT_INTRVL_DFLT     0x00
  4001. -
  4002. -/* touch timeout for the Active power */
  4003. -#define CY_TCH_TMOUT_DFLT      0xFF
  4004. -
  4005. -/* Low Power state scanning/processing refresh interval */
  4006. -#define CY_LP_INTRVL_DFLT      0x0A
  4007. -
  4008. -#define CY_IDLE_STATE      0
  4009. -#define CY_ACTIVE_STATE        1
  4010. -#define CY_LOW_PWR_STATE       2
  4011. -#define CY_SLEEP_STATE     3
  4012. -#ifdef CONFIG_MACH_OMAP3621_EVT1A
  4013. -#define CY_POWER_OFF_STATE        4 /* EVT1A specific state, regulator has turned touch panel off. */
  4014. -#endif /* CONFIG_MACH_OMAP3621_EVT1A */
  4015. -
  4016. -/* device mode bits */
  4017. -#define CY_OP_MODE          0x00
  4018. -#define CY_SYSINFO_MODE     0x10
  4019. -#define CY_RAW_MODE         0x40
  4020. -#define CY_SIG_MODE         0x50
  4021. -#define CY_IDAC_MODE        0x60
  4022. -#define CY_RAWBASE_MODE     0x70
  4023. -
  4024. -/* power mode select bits */
  4025. -#define CY_SOFT_RESET_MODE     0x01    /* return to Bootloader mode */
  4026. -#define CY_DEEP_SLEEP_MODE     0x02
  4027. -#define CY_LOW_PWR_MODE        0x04
  4028. -
  4029. -#define CY_NUM_KEY         8
  4030. -
  4031. -#ifdef CY_USE_GEST
  4032. -   #define CY_USE_GESTURES 1
  4033. -#else
  4034. -   #define CY_USE_GESTURES 0
  4035. -#endif /* CY_USE_GESTURE_SIGNALS */
  4036. -
  4037. -#ifdef CY_USE_GEST_GRP1
  4038. -   #define CY_GEST_GRP1    0x10
  4039. -#else
  4040. -   #define CY_GEST_GRP1    0x00
  4041. -#endif /* CY_USE_GEST_GRP1 */
  4042. -#ifdef CY_USE_GEST_GRP2
  4043. -   #define CY_GEST_GRP2    0x20
  4044. -#else
  4045. -   #define CY_GEST_GRP2    0x00
  4046. -#endif /* CY_USE_GEST_GRP2 */
  4047. -#ifdef CY_USE_GEST_GRP3
  4048. -   #define CY_GEST_GRP3    0x40
  4049. -#else
  4050. -   #define CY_GEST_GRP3    0x00
  4051. -#endif /* CY_USE_GEST_GRP3 */
  4052. -#ifdef CY_USE_GEST_GRP4
  4053. -   #define CY_GEST_GRP4    0x80
  4054. -#else
  4055. -   #define CY_GEST_GRP4    0x00
  4056. -#endif /* CY_USE_GEST_GRP4 */
  4057. -
  4058. -#ifdef CY_USE_I2C_DRIVER
  4059. -struct i2c_client;
  4060. -#endif
  4061. -
  4062. -struct cyttsp_platform_data {
  4063. -   u32 maxx;
  4064. -   u32 maxy;
  4065. -   u32 flags;
  4066. -   u8 gen;
  4067. -   u8 use_st;
  4068. -   u8 use_mt;
  4069. -   u8 use_hndshk;
  4070. -   u8 use_trk_id;
  4071. -   u8 use_sleep;
  4072. -   u8 use_gestures;
  4073. -   u8 gest_set;
  4074. -   u8 act_intrvl;
  4075. -   u8 tch_tmout;
  4076. -   u8 lp_intrvl;
  4077. -   u8 power_state;
  4078. -#ifdef CY_USE_I2C_DRIVER
  4079. -   s32 (*init)(struct i2c_client *client);
  4080. -   s32 (*resume)(struct i2c_client *client);
  4081. -#endif
  4082. -#ifdef CY_USE_SPI_DRIVER
  4083. -   s32 (*init)(struct spi_device *spi);
  4084. -   s32 (*resume)(struct spi_device *spi);
  4085. -#endif
  4086. -};
  4087. -
  4088. -/* TrueTouch Standard Product Gen3 (Txx3xx) interface definition */
  4089. -struct cyttsp_gen3_xydata_t {
  4090. -   u8 hst_mode;
  4091. -   u8 tt_mode;
  4092. -   u8 tt_stat;
  4093. -   u16 x1 __attribute__ ((packed));
  4094. -   u16 y1 __attribute__ ((packed));
  4095. -   u8 z1;
  4096. -   u8 touch12_id;
  4097. -   u16 x2 __attribute__ ((packed));
  4098. -   u16 y2 __attribute__ ((packed));
  4099. -   u8 z2;
  4100. -   u8 gest_cnt;
  4101. -   u8 gest_id;
  4102. -   u16 x3 __attribute__ ((packed));
  4103. -   u16 y3 __attribute__ ((packed));
  4104. -   u8 z3;
  4105. -   u8 touch34_id;
  4106. -   u16 x4 __attribute__ ((packed));
  4107. -   u16 y4 __attribute__ ((packed));
  4108. -   u8 z4;
  4109. -   u8 tt_undef[3];
  4110. -   u8 gest_set;
  4111. -   u8 tt_reserved;
  4112. -};
  4113. -
  4114. -/* TrueTouch Standard Product Gen3 (Txx3xx) test data interface definition */
  4115. -
  4116. -struct cyttsp_gen3_testdata_t {
  4117. -   u8 hst_mode;
  4118. -   u8 tt_mode;
  4119. -   u8 tt_stat;
  4120. -   u16 x1 __attribute__ ((packed));
  4121. -   u16 y1 __attribute__ ((packed));
  4122. -   u8 sensor[240];
  4123. -   u8 resv[64];
  4124. -};
  4125. -
  4126. -/* TrueTouch Standard Product Gen2 (Txx2xx) interface definition */
  4127. -#define CY_GEN2_NOTOUCH        0x03    /* Both touches removed */
  4128. -#define CY_GEN2_GHOST      0x02    /* ghost */
  4129. -#define CY_GEN2_2TOUCH     0x03    /* 2 touch; no ghost */
  4130. -#define CY_GEN2_1TOUCH     0x01    /* 1 touch only */
  4131. -#define CY_GEN2_TOUCH2     0x01    /* 1st touch removed;
  4132. -                        * 2nd touch remains */
  4133. -struct cyttsp_gen2_xydata_t {
  4134. -   u8 hst_mode;
  4135. -   u8 tt_mode;
  4136. -   u8 tt_stat;
  4137. -   u16 x1 __attribute__ ((packed));
  4138. -   u16 y1 __attribute__ ((packed));
  4139. -   u8 z1;
  4140. -   u8 evnt_idx;
  4141. -   u16 x2 __attribute__ ((packed));
  4142. -   u16 y2 __attribute__ ((packed));
  4143. -   u8 tt_undef1;
  4144. -   u8 gest_cnt;
  4145. -   u8 gest_id;
  4146. -   u8 tt_undef[14];
  4147. -   u8 gest_set;
  4148. -   u8 tt_reserved;
  4149. -};
  4150. -
  4151. -/* TTSP System Information interface definition */
  4152. -struct cyttsp_sysinfo_data_t {
  4153. -   u8 hst_mode;
  4154. -   u8 mfg_cmd;
  4155. -   u8 mfg_stat;
  4156. -   u8 cid[3];
  4157. -   u8 tt_undef1;
  4158. -   u8 uid[8];
  4159. -   u8 bl_verh;
  4160. -   u8 bl_verl;
  4161. -   u8 tts_verh;
  4162. -   u8 tts_verl;
  4163. -   u8 app_idh;
  4164. -   u8 app_idl;
  4165. -   u8 app_verh;
  4166. -   u8 app_verl;
  4167. -   u8 tt_undef[6];
  4168. -   u8 act_intrvl;
  4169. -   u8 tch_tmout;
  4170. -   u8 lp_intrvl;
  4171. -};
  4172. -
  4173. -/* TTSP Bootloader Register Map interface definition */
  4174. -struct cyttsp_bootloader_data_t {
  4175. -   u8 bl_file;
  4176. -   u8 bl_status;
  4177. -   u8 bl_error;
  4178. -   u8 blver_hi;
  4179. -   u8 blver_lo;
  4180. -   u8 bld_blver_hi;
  4181. -   u8 bld_blver_lo;
  4182. -   u8 ttspver_hi;
  4183. -   u8 ttspver_lo;
  4184. -   u8 appid_hi;
  4185. -   u8 appid_lo;
  4186. -   u8 appver_hi;
  4187. -   u8 appver_lo;
  4188. -   u8 cid_0;
  4189. -   u8 cid_1;
  4190. -   u8 cid_2;
  4191. -};
  4192. -
  4193. -/* TTSP Bootloader Status and Error register bits */
  4194. -#define CYTTSP_BLSTATUS_BOOTLOADER_RUNNING       0x10
  4195. -#define CYTTSP_BLSTATUS_CHECKSUM_VALID           0x01
  4196. -#define CYTTSP_BLSTATUS_READY                    (CYTTSP_BLSTATUS_BOOTLOADER_RUNNING | CYTTSP_BLSTATUS_CHECKSUM_VALID)
  4197. -#define CYTTSP_BLSTATUS_MASK                     0x11
  4198. -
  4199. -#define CYTTSP_BLERROR_INVALID_COMMAND           0x80
  4200. -#define CYTTSP_BLERROR_INVALID_SECURITY_KEY      0x40
  4201. -#define CYTTSP_BLERROR_BOOTLOADING               0x20
  4202. -#define CYTTSP_BLERROR_COMMAND_CHECKSUM_ERROR    0x10
  4203. -#define CYTTSP_BLERROR_FLASH_PROTECTION_ERROR    0x08
  4204. -#define CYTTSP_BLERROR_FLASH_CHECKSUM_ERROR      0x04
  4205. -#define CYTTSP_BLERROR_IMAGE_VERIFICATION_ERROR  0x02
  4206. -#define CYTTSP_BLERROR_SUCCESS                   0x00
  4207. -#define CYTTSP_BLERROR_MASK                      0xFE
  4208. -
  4209. -/*********************************************************/
  4210. -
  4211. -#define cyttsp_wake_data_t      cyttsp_gen3_xydata_t
  4212. -#define cyttsp_test_data_t      cyttsp_gen3_testdata_t
  4213. -
  4214. -#ifdef CY_DECLARE_GLOBALS
  4215. -   #ifdef CY_INCLUDE_LOAD_FILE
  4216. -       /* this file declares:
  4217. -        * firmware download block array (cyttsp_fw[]),
  4218. -        * the number of command block records (cyttsp_fw_records),
  4219. -        * and the version variables
  4220. -        */
  4221. -       #include "cyttsp_fw.h"      /* imports cyttsp_fw[] array */
  4222. -       #define cyttsp_app_load()   1
  4223. -       #ifdef CY_FORCE_FW_UPDATE
  4224. -           #define cyttsp_force_fw_load()  1
  4225. -       #else
  4226. -           #define cyttsp_force_fw_load()  0
  4227. -       #endif
  4228. -
  4229. -   #else
  4230. -       /* the following declarations are to allow
  4231. -        * some debugging capability
  4232. -        */
  4233. -
  4234. -                typedef struct cyttsp_ld_blk_ray_t {
  4235. -                        unsigned short Record;
  4236. -                        unsigned short Length;
  4237. -                        unsigned char  Command;
  4238. -                        unsigned short Address;
  4239. -                        unsigned char  Block[0];
  4240. -                } cyttsp_ld_blk_ray;
  4241. -
  4242. -                cyttsp_ld_blk_ray cyttsp_fw[1] = {{0}};
  4243. -
  4244. -                unsigned short cyttsp_fw_records = 0;
  4245. -       unsigned char cyttsp_fw_tts_verh = 0x00;
  4246. -       unsigned char cyttsp_fw_tts_verl = 0x00;
  4247. -       unsigned char cyttsp_fw_app_idh = 0x00;
  4248. -       unsigned char cyttsp_fw_app_idl = 0x00;
  4249. -       unsigned char cyttsp_fw_app_verh = 0x00;
  4250. -       unsigned char cyttsp_fw_app_verl = 0x00;
  4251. -       unsigned char cyttsp_fw_cid_0 = 0x00;
  4252. -       unsigned char cyttsp_fw_cid_1 = 0x00;
  4253. -       unsigned char cyttsp_fw_cid_2 = 0x00;
  4254. -
  4255. -       #define cyttsp_app_load()   0
  4256. -       #define cyttsp_force_fw_load()  0
  4257. -   #endif
  4258. -   #define cyttsp_tts_verh()   cyttsp_fw_tts_verh
  4259. -   #define cyttsp_tts_verl()   cyttsp_fw_tts_verl
  4260. -   #define cyttsp_app_idh()    cyttsp_fw_app_idh
  4261. -   #define cyttsp_app_idl()    cyttsp_fw_app_idl
  4262. -   #define cyttsp_app_verh()   cyttsp_fw_app_verh
  4263. -   #define cyttsp_app_verl()   cyttsp_fw_app_verl
  4264. -   #define cyttsp_cid_0()      cyttsp_fw_cid_0
  4265. -   #define cyttsp_cid_1()      cyttsp_fw_cid_1
  4266. -   #define cyttsp_cid_2()      cyttsp_fw_cid_2
  4267. -   #ifdef CY_USE_TEST_DATA
  4268. -       static struct cyttsp_gen2_xydata_t tt_gen2_testray[] = {
  4269. -       {0x00}, {0x00}, {0x04},
  4270. -       {0x4000}, {0x8000}, {0x80},
  4271. -       {0x03},
  4272. -       {0x2000}, {0x1000}, {0x00},
  4273. -       {0x00},
  4274. -       {0x00},
  4275. -       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4276. -        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
  4277. -       {0x00},
  4278. -       {0x00}
  4279. -       };
  4280. -
  4281. -       static struct cyttsp_gen3_xydata_t tt_gen3_testray[] = {
  4282. -       {0x00}, {0x00}, {0x04},
  4283. -       {0x4000}, {0x8000}, {0x80},
  4284. -       {0x12},
  4285. -       {0x2000}, {0x1000}, {0xA0},
  4286. -       {0x00}, {0x00},
  4287. -       {0x8000}, {0x4000}, {0xB0},
  4288. -       {0x34},
  4289. -       {0x4000}, {0x1000}, {0xC0},
  4290. -       {0x00, 0x00, 0x00},
  4291. -       {0x00},
  4292. -       {0x00}
  4293. -       };
  4294. -   #endif /* CY_USE_TEST_DATA */
  4295. -
  4296. -#else
  4297. -       extern u8 g_appload_ray[];
  4298. -#endif
  4299. -
  4300. -#endif /* __CYTTSP_H__ */
  4301.  
  4302.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement