rmi_driver.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Copyright (c) 2011-2016 Synaptics Incorporated
  3. * Copyright (c) 2011 Unixphere
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published by
  7. * the Free Software Foundation.
  8. */
  9. #ifndef _RMI_DRIVER_H
  10. #define _RMI_DRIVER_H
  11. #include <linux/ctype.h>
  12. #include <linux/hrtimer.h>
  13. #include <linux/ktime.h>
  14. #include <linux/input.h>
  15. #include "rmi_bus.h"
  16. #define SYNAPTICS_INPUT_DEVICE_NAME "Synaptics RMI4 Touch Sensor"
  17. #define SYNAPTICS_VENDOR_ID 0x06cb
  18. #define GROUP(_attrs) { \
  19. .attrs = _attrs, \
  20. }
  21. #define PDT_PROPERTIES_LOCATION 0x00EF
  22. #define BSR_LOCATION 0x00FE
  23. #define RMI_PDT_PROPS_HAS_BSR 0x02
  24. #define NAME_BUFFER_SIZE 256
  25. #define RMI_PDT_ENTRY_SIZE 6
  26. #define RMI_PDT_FUNCTION_VERSION_MASK 0x60
  27. #define RMI_PDT_INT_SOURCE_COUNT_MASK 0x07
  28. #define PDT_START_SCAN_LOCATION 0x00e9
  29. #define PDT_END_SCAN_LOCATION 0x0005
  30. #define RMI4_END_OF_PDT(id) ((id) == 0x00 || (id) == 0xff)
  31. struct pdt_entry {
  32. u16 page_start;
  33. u8 query_base_addr;
  34. u8 command_base_addr;
  35. u8 control_base_addr;
  36. u8 data_base_addr;
  37. u8 interrupt_source_count;
  38. u8 function_version;
  39. u8 function_number;
  40. };
  41. #define RMI_REG_DESC_PRESENSE_BITS (32 * BITS_PER_BYTE)
  42. #define RMI_REG_DESC_SUBPACKET_BITS (37 * BITS_PER_BYTE)
  43. /* describes a single packet register */
  44. struct rmi_register_desc_item {
  45. u16 reg;
  46. unsigned long reg_size;
  47. u8 num_subpackets;
  48. unsigned long subpacket_map[BITS_TO_LONGS(
  49. RMI_REG_DESC_SUBPACKET_BITS)];
  50. };
  51. /*
  52. * describes the packet registers for a particular type
  53. * (ie query, control, data)
  54. */
  55. struct rmi_register_descriptor {
  56. unsigned long struct_size;
  57. unsigned long presense_map[BITS_TO_LONGS(RMI_REG_DESC_PRESENSE_BITS)];
  58. u8 num_registers;
  59. struct rmi_register_desc_item *registers;
  60. };
  61. int rmi_read_register_desc(struct rmi_device *d, u16 addr,
  62. struct rmi_register_descriptor *rdesc);
  63. const struct rmi_register_desc_item *rmi_get_register_desc_item(
  64. struct rmi_register_descriptor *rdesc, u16 reg);
  65. /*
  66. * Calculate the total size of all of the registers described in the
  67. * descriptor.
  68. */
  69. size_t rmi_register_desc_calc_size(struct rmi_register_descriptor *rdesc);
  70. int rmi_register_desc_calc_reg_offset(
  71. struct rmi_register_descriptor *rdesc, u16 reg);
  72. bool rmi_register_desc_has_subpacket(const struct rmi_register_desc_item *item,
  73. u8 subpacket);
  74. bool rmi_is_physical_driver(struct device_driver *);
  75. int rmi_register_physical_driver(void);
  76. void rmi_unregister_physical_driver(void);
  77. void rmi_free_function_list(struct rmi_device *rmi_dev);
  78. struct rmi_function *rmi_find_function(struct rmi_device *rmi_dev, u8 number);
  79. int rmi_enable_sensor(struct rmi_device *rmi_dev);
  80. int rmi_scan_pdt(struct rmi_device *rmi_dev, void *ctx,
  81. int (*callback)(struct rmi_device *rmi_dev, void *ctx,
  82. const struct pdt_entry *entry));
  83. int rmi_probe_interrupts(struct rmi_driver_data *data);
  84. void rmi_enable_irq(struct rmi_device *rmi_dev, bool clear_wake);
  85. void rmi_disable_irq(struct rmi_device *rmi_dev, bool enable_wake);
  86. int rmi_init_functions(struct rmi_driver_data *data);
  87. int rmi_initial_reset(struct rmi_device *rmi_dev, void *ctx,
  88. const struct pdt_entry *pdt);
  89. const char *rmi_f01_get_product_ID(struct rmi_function *fn);
  90. #ifdef CONFIG_RMI4_F03
  91. int rmi_f03_overwrite_button(struct rmi_function *fn, unsigned int button,
  92. int value);
  93. void rmi_f03_commit_buttons(struct rmi_function *fn);
  94. #else
  95. static inline int rmi_f03_overwrite_button(struct rmi_function *fn,
  96. unsigned int button, int value)
  97. {
  98. return 0;
  99. }
  100. static inline void rmi_f03_commit_buttons(struct rmi_function *fn) {}
  101. #endif
  102. #ifdef CONFIG_RMI4_F34
  103. int rmi_f34_create_sysfs(struct rmi_device *rmi_dev);
  104. void rmi_f34_remove_sysfs(struct rmi_device *rmi_dev);
  105. #else
  106. static inline int rmi_f34_create_sysfs(struct rmi_device *rmi_dev)
  107. {
  108. return 0;
  109. }
  110. static inline void rmi_f34_remove_sysfs(struct rmi_device *rmi_dev)
  111. {
  112. }
  113. #endif /* CONFIG_RMI_F34 */
  114. extern struct rmi_function_handler rmi_f01_handler;
  115. extern struct rmi_function_handler rmi_f03_handler;
  116. extern struct rmi_function_handler rmi_f11_handler;
  117. extern struct rmi_function_handler rmi_f12_handler;
  118. extern struct rmi_function_handler rmi_f30_handler;
  119. extern struct rmi_function_handler rmi_f34_handler;
  120. extern struct rmi_function_handler rmi_f54_handler;
  121. extern struct rmi_function_handler rmi_f55_handler;
  122. #endif