cyttsp_core.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Header file for:
  4. * Cypress TrueTouch(TM) Standard Product (TTSP) touchscreen drivers.
  5. * For use with Cypress Txx3xx parts.
  6. * Supported parts include:
  7. * CY8CTST341
  8. * CY8CTMA340
  9. *
  10. * Copyright (C) 2009, 2010, 2011 Cypress Semiconductor, Inc.
  11. * Copyright (C) 2012 Javier Martinez Canillas <javier@dowhile0.org>
  12. *
  13. * Contact Cypress Semiconductor at www.cypress.com <kev@cypress.com>
  14. */
  15. #ifndef __CYTTSP_CORE_H__
  16. #define __CYTTSP_CORE_H__
  17. #include <linux/kernel.h>
  18. #include <linux/err.h>
  19. #include <linux/module.h>
  20. #include <linux/types.h>
  21. #include <linux/device.h>
  22. #include <linux/regulator/consumer.h>
  23. #define CY_NUM_RETRY 16 /* max number of retries for read ops */
  24. struct cyttsp_tch {
  25. __be16 x, y;
  26. u8 z;
  27. } __packed;
  28. /* TrueTouch Standard Product Gen3 interface definition */
  29. struct cyttsp_xydata {
  30. u8 hst_mode;
  31. u8 tt_mode;
  32. u8 tt_stat;
  33. struct cyttsp_tch tch1;
  34. u8 touch12_id;
  35. struct cyttsp_tch tch2;
  36. u8 gest_cnt;
  37. u8 gest_id;
  38. struct cyttsp_tch tch3;
  39. u8 touch34_id;
  40. struct cyttsp_tch tch4;
  41. u8 tt_undef[3];
  42. u8 act_dist;
  43. u8 tt_reserved;
  44. } __packed;
  45. /* TTSP System Information interface definition */
  46. struct cyttsp_sysinfo_data {
  47. u8 hst_mode;
  48. u8 mfg_stat;
  49. u8 mfg_cmd;
  50. u8 cid[3];
  51. u8 tt_undef1;
  52. u8 uid[8];
  53. u8 bl_verh;
  54. u8 bl_verl;
  55. u8 tts_verh;
  56. u8 tts_verl;
  57. u8 app_idh;
  58. u8 app_idl;
  59. u8 app_verh;
  60. u8 app_verl;
  61. u8 tt_undef[5];
  62. u8 scn_typ;
  63. u8 act_intrvl;
  64. u8 tch_tmout;
  65. u8 lp_intrvl;
  66. };
  67. /* TTSP Bootloader Register Map interface definition */
  68. #define CY_BL_CHKSUM_OK 0x01
  69. struct cyttsp_bootloader_data {
  70. u8 bl_file;
  71. u8 bl_status;
  72. u8 bl_error;
  73. u8 blver_hi;
  74. u8 blver_lo;
  75. u8 bld_blver_hi;
  76. u8 bld_blver_lo;
  77. u8 ttspver_hi;
  78. u8 ttspver_lo;
  79. u8 appid_hi;
  80. u8 appid_lo;
  81. u8 appver_hi;
  82. u8 appver_lo;
  83. u8 cid_0;
  84. u8 cid_1;
  85. u8 cid_2;
  86. };
  87. struct cyttsp;
  88. struct cyttsp_bus_ops {
  89. u16 bustype;
  90. int (*write)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length,
  91. const void *values);
  92. int (*read)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length,
  93. void *values);
  94. };
  95. enum cyttsp_state {
  96. CY_IDLE_STATE,
  97. CY_ACTIVE_STATE,
  98. CY_BL_STATE,
  99. };
  100. struct cyttsp {
  101. struct device *dev;
  102. int irq;
  103. struct input_dev *input;
  104. const struct cyttsp_bus_ops *bus_ops;
  105. struct cyttsp_bootloader_data bl_data;
  106. struct cyttsp_sysinfo_data sysinfo_data;
  107. struct cyttsp_xydata xy_data;
  108. struct completion bl_ready;
  109. enum cyttsp_state state;
  110. bool suspended;
  111. struct gpio_desc *reset_gpio;
  112. bool use_hndshk;
  113. u8 act_dist;
  114. u8 act_intrvl;
  115. u8 tch_tmout;
  116. u8 lp_intrvl;
  117. u8 *bl_keys;
  118. u8 xfer_buf[] ____cacheline_aligned;
  119. };
  120. struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
  121. struct device *dev, int irq, size_t xfer_buf_size);
  122. extern const struct dev_pm_ops cyttsp_pm_ops;
  123. #endif /* __CYTTSP_CORE_H__ */