elan_i2c.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Elan I2C/SMBus Touchpad driver
  3. *
  4. * Copyright (c) 2013 ELAN Microelectronics Corp.
  5. *
  6. * Author: 林政維 (Duson Lin) <dusonlin@emc.com.tw>
  7. * Version: 1.5.5
  8. *
  9. * Based on cyapa driver:
  10. * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
  11. * copyright (c) 2011-2012 Google, Inc.
  12. *
  13. * This program is free software; you can redistribute it and/or modify it
  14. * under the terms of the GNU General Public License version 2 as published
  15. * by the Free Software Foundation.
  16. *
  17. * Trademarks are the property of their respective owners.
  18. */
  19. #ifndef _ELAN_I2C_H
  20. #define _ELAN_i2C_H
  21. #include <linux/types.h>
  22. #define ETP_ENABLE_ABS 0x0001
  23. #define ETP_ENABLE_CALIBRATE 0x0002
  24. #define ETP_DISABLE_CALIBRATE 0x0000
  25. #define ETP_DISABLE_POWER 0x0001
  26. /* IAP Firmware handling */
  27. #define ETP_FW_NAME "elan_i2c.bin"
  28. #define ETP_IAP_START_ADDR 0x0083
  29. #define ETP_FW_IAP_PAGE_ERR (1 << 5)
  30. #define ETP_FW_IAP_INTF_ERR (1 << 4)
  31. #define ETP_FW_PAGE_SIZE 64
  32. #define ETP_FW_PAGE_COUNT 768
  33. #define ETP_FW_SIZE (ETP_FW_PAGE_SIZE * ETP_FW_PAGE_COUNT)
  34. struct i2c_client;
  35. struct completion;
  36. enum tp_mode {
  37. IAP_MODE = 1,
  38. MAIN_MODE
  39. };
  40. struct elan_transport_ops {
  41. int (*initialize)(struct i2c_client *client);
  42. int (*sleep_control)(struct i2c_client *, bool sleep);
  43. int (*power_control)(struct i2c_client *, bool enable);
  44. int (*set_mode)(struct i2c_client *client, u8 mode);
  45. int (*calibrate)(struct i2c_client *client);
  46. int (*calibrate_result)(struct i2c_client *client, u8 *val);
  47. int (*get_baseline_data)(struct i2c_client *client,
  48. bool max_baseliune, u8 *value);
  49. int (*get_version)(struct i2c_client *client, bool iap, u8 *version);
  50. int (*get_sm_version)(struct i2c_client *client, u8 *version);
  51. int (*get_checksum)(struct i2c_client *client, bool iap, u16 *csum);
  52. int (*get_product_id)(struct i2c_client *client, u8 *id);
  53. int (*get_max)(struct i2c_client *client,
  54. unsigned int *max_x, unsigned int *max_y);
  55. int (*get_resolution)(struct i2c_client *client,
  56. u8 *hw_res_x, u8 *hw_res_y);
  57. int (*get_num_traces)(struct i2c_client *client,
  58. unsigned int *x_tracenum,
  59. unsigned int *y_tracenum);
  60. int (*iap_get_mode)(struct i2c_client *client, enum tp_mode *mode);
  61. int (*iap_reset)(struct i2c_client *client);
  62. int (*prepare_fw_update)(struct i2c_client *client);
  63. int (*write_fw_block)(struct i2c_client *client,
  64. const u8 *page, u16 checksum, int idx);
  65. int (*finish_fw_update)(struct i2c_client *client,
  66. struct completion *reset_done);
  67. int (*get_report)(struct i2c_client *client, u8 *report);
  68. };
  69. extern const struct elan_transport_ops elan_smbus_ops, elan_i2c_ops;
  70. #endif /* _ELAN_I2C_H */