elan_i2c.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Elan I2C/SMBus Touchpad driver
  4. *
  5. * Copyright (c) 2013 ELAN Microelectronics Corp.
  6. *
  7. * Author: 林政維 (Duson Lin) <[email protected]>
  8. *
  9. * Based on cyapa driver:
  10. * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
  11. * copyright (c) 2011-2012 Google, Inc.
  12. *
  13. * Trademarks are the property of their respective owners.
  14. */
  15. #ifndef _ELAN_I2C_H
  16. #define _ELAN_I2C_H
  17. #include <linux/types.h>
  18. #define ETP_ENABLE_ABS 0x0001
  19. #define ETP_ENABLE_CALIBRATE 0x0002
  20. #define ETP_DISABLE_CALIBRATE 0x0000
  21. #define ETP_DISABLE_POWER 0x0001
  22. #define ETP_PRESSURE_OFFSET 25
  23. #define ETP_CALIBRATE_MAX_LEN 3
  24. #define ETP_FEATURE_REPORT_MK BIT(0)
  25. #define ETP_REPORT_ID 0x5D
  26. #define ETP_TP_REPORT_ID 0x5E
  27. #define ETP_TP_REPORT_ID2 0x5F
  28. #define ETP_REPORT_ID2 0x60 /* High precision report */
  29. #define ETP_REPORT_ID_OFFSET 2
  30. #define ETP_TOUCH_INFO_OFFSET 3
  31. #define ETP_FINGER_DATA_OFFSET 4
  32. #define ETP_HOVER_INFO_OFFSET 30
  33. #define ETP_MK_DATA_OFFSET 33 /* For high precision reports */
  34. #define ETP_MAX_REPORT_LEN 39
  35. #define ETP_MAX_FINGERS 5
  36. #define ETP_FINGER_DATA_LEN 5
  37. /* IAP Firmware handling */
  38. #define ETP_PRODUCT_ID_FORMAT_STRING "%d.0"
  39. #define ETP_FW_NAME "elan_i2c_" ETP_PRODUCT_ID_FORMAT_STRING ".bin"
  40. #define ETP_IAP_START_ADDR 0x0083
  41. #define ETP_FW_IAP_PAGE_ERR (1 << 5)
  42. #define ETP_FW_IAP_INTF_ERR (1 << 4)
  43. #define ETP_FW_PAGE_SIZE 64
  44. #define ETP_FW_PAGE_SIZE_128 128
  45. #define ETP_FW_PAGE_SIZE_512 512
  46. #define ETP_FW_SIGNATURE_SIZE 6
  47. #define ETP_PRODUCT_ID_WHITEBOX 0x00B8
  48. #define ETP_PRODUCT_ID_VOXEL 0x00BF
  49. #define ETP_PRODUCT_ID_DELBIN 0x00C2
  50. #define ETP_PRODUCT_ID_MAGPIE 0x0120
  51. #define ETP_PRODUCT_ID_BOBBA 0x0121
  52. struct i2c_client;
  53. struct completion;
  54. enum tp_mode {
  55. IAP_MODE = 1,
  56. MAIN_MODE
  57. };
  58. struct elan_transport_ops {
  59. int (*initialize)(struct i2c_client *client);
  60. int (*sleep_control)(struct i2c_client *, bool sleep);
  61. int (*power_control)(struct i2c_client *, bool enable);
  62. int (*set_mode)(struct i2c_client *client, u8 mode);
  63. int (*calibrate)(struct i2c_client *client);
  64. int (*calibrate_result)(struct i2c_client *client, u8 *val);
  65. int (*get_baseline_data)(struct i2c_client *client,
  66. bool max_baseline, u8 *value);
  67. int (*get_version)(struct i2c_client *client, u8 pattern, bool iap,
  68. u8 *version);
  69. int (*get_sm_version)(struct i2c_client *client, u8 pattern,
  70. u16 *ic_type, u8 *version, u8 *clickpad);
  71. int (*get_checksum)(struct i2c_client *client, bool iap, u16 *csum);
  72. int (*get_product_id)(struct i2c_client *client, u16 *id);
  73. int (*get_max)(struct i2c_client *client,
  74. unsigned int *max_x, unsigned int *max_y);
  75. int (*get_resolution)(struct i2c_client *client,
  76. u8 *hw_res_x, u8 *hw_res_y);
  77. int (*get_num_traces)(struct i2c_client *client,
  78. unsigned int *x_tracenum,
  79. unsigned int *y_tracenum);
  80. int (*iap_get_mode)(struct i2c_client *client, enum tp_mode *mode);
  81. int (*iap_reset)(struct i2c_client *client);
  82. int (*prepare_fw_update)(struct i2c_client *client, u16 ic_type,
  83. u8 iap_version, u16 fw_page_size);
  84. int (*write_fw_block)(struct i2c_client *client, u16 fw_page_size,
  85. const u8 *page, u16 checksum, int idx);
  86. int (*finish_fw_update)(struct i2c_client *client,
  87. struct completion *reset_done);
  88. int (*get_report_features)(struct i2c_client *client, u8 pattern,
  89. unsigned int *features,
  90. unsigned int *report_len);
  91. int (*get_report)(struct i2c_client *client, u8 *report,
  92. unsigned int report_len);
  93. int (*get_pressure_adjustment)(struct i2c_client *client,
  94. int *adjustment);
  95. int (*get_pattern)(struct i2c_client *client, u8 *pattern);
  96. };
  97. extern const struct elan_transport_ops elan_smbus_ops, elan_i2c_ops;
  98. #endif /* _ELAN_I2C_H */