cyttsp_core.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * Header file for:
  3. * Cypress TrueTouch(TM) Standard Product (TTSP) touchscreen drivers.
  4. * For use with Cypress Txx3xx parts.
  5. * Supported parts include:
  6. * CY8CTST341
  7. * CY8CTMA340
  8. *
  9. * Copyright (C) 2009, 2010, 2011 Cypress Semiconductor, Inc.
  10. * Copyright (C) 2012 Javier Martinez Canillas <javier@dowhile0.org>
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License
  14. * version 2, and only version 2, as published by the
  15. * Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License along
  23. * with this program; if not, write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  25. *
  26. * Contact Cypress Semiconductor at www.cypress.com <kev@cypress.com>
  27. *
  28. */
  29. #ifndef __CYTTSP_CORE_H__
  30. #define __CYTTSP_CORE_H__
  31. #include <linux/kernel.h>
  32. #include <linux/err.h>
  33. #include <linux/module.h>
  34. #include <linux/types.h>
  35. #include <linux/device.h>
  36. #include <linux/input/cyttsp.h>
  37. #define CY_NUM_RETRY 16 /* max number of retries for read ops */
  38. struct cyttsp_tch {
  39. __be16 x, y;
  40. u8 z;
  41. } __packed;
  42. /* TrueTouch Standard Product Gen3 interface definition */
  43. struct cyttsp_xydata {
  44. u8 hst_mode;
  45. u8 tt_mode;
  46. u8 tt_stat;
  47. struct cyttsp_tch tch1;
  48. u8 touch12_id;
  49. struct cyttsp_tch tch2;
  50. u8 gest_cnt;
  51. u8 gest_id;
  52. struct cyttsp_tch tch3;
  53. u8 touch34_id;
  54. struct cyttsp_tch tch4;
  55. u8 tt_undef[3];
  56. u8 act_dist;
  57. u8 tt_reserved;
  58. } __packed;
  59. /* TTSP System Information interface definition */
  60. struct cyttsp_sysinfo_data {
  61. u8 hst_mode;
  62. u8 mfg_stat;
  63. u8 mfg_cmd;
  64. u8 cid[3];
  65. u8 tt_undef1;
  66. u8 uid[8];
  67. u8 bl_verh;
  68. u8 bl_verl;
  69. u8 tts_verh;
  70. u8 tts_verl;
  71. u8 app_idh;
  72. u8 app_idl;
  73. u8 app_verh;
  74. u8 app_verl;
  75. u8 tt_undef[5];
  76. u8 scn_typ;
  77. u8 act_intrvl;
  78. u8 tch_tmout;
  79. u8 lp_intrvl;
  80. };
  81. /* TTSP Bootloader Register Map interface definition */
  82. #define CY_BL_CHKSUM_OK 0x01
  83. struct cyttsp_bootloader_data {
  84. u8 bl_file;
  85. u8 bl_status;
  86. u8 bl_error;
  87. u8 blver_hi;
  88. u8 blver_lo;
  89. u8 bld_blver_hi;
  90. u8 bld_blver_lo;
  91. u8 ttspver_hi;
  92. u8 ttspver_lo;
  93. u8 appid_hi;
  94. u8 appid_lo;
  95. u8 appver_hi;
  96. u8 appver_lo;
  97. u8 cid_0;
  98. u8 cid_1;
  99. u8 cid_2;
  100. };
  101. struct cyttsp;
  102. struct cyttsp_bus_ops {
  103. u16 bustype;
  104. int (*write)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length,
  105. const void *values);
  106. int (*read)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length,
  107. void *values);
  108. };
  109. enum cyttsp_state {
  110. CY_IDLE_STATE,
  111. CY_ACTIVE_STATE,
  112. CY_BL_STATE,
  113. };
  114. struct cyttsp {
  115. struct device *dev;
  116. int irq;
  117. struct input_dev *input;
  118. char phys[32];
  119. const struct cyttsp_platform_data *pdata;
  120. const struct cyttsp_bus_ops *bus_ops;
  121. struct cyttsp_bootloader_data bl_data;
  122. struct cyttsp_sysinfo_data sysinfo_data;
  123. struct cyttsp_xydata xy_data;
  124. struct completion bl_ready;
  125. enum cyttsp_state state;
  126. bool suspended;
  127. u8 xfer_buf[] ____cacheline_aligned;
  128. };
  129. struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
  130. struct device *dev, int irq, size_t xfer_buf_size);
  131. void cyttsp_remove(struct cyttsp *ts);
  132. int cyttsp_i2c_write_block_data(struct device *dev, u8 *xfer_buf, u16 addr,
  133. u8 length, const void *values);
  134. int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, u16 addr,
  135. u8 length, void *values);
  136. extern const struct dev_pm_ops cyttsp_pm_ops;
  137. #endif /* __CYTTSP_CORE_H__ */