qfs4008_common.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #ifndef _UAPI_QFS4008_H_
  2. #define _UAPI_QFS4008_H_
  3. #include <linux/ktime.h>
  4. #include <linux/kernel.h>
  5. #include <linux/module.h>
  6. #include <linux/fs.h>
  7. #include <linux/uaccess.h>
  8. #include <linux/platform_device.h>
  9. #include <linux/types.h>
  10. #include <linux/cdev.h>
  11. #include <linux/slab.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/pm.h>
  14. #include <linux/mutex.h>
  15. #include <linux/atomic.h>
  16. #include <linux/of.h>
  17. #include <linux/of_gpio.h>
  18. #include <linux/kfifo.h>
  19. #include <linux/poll.h>
  20. #include <linux/gpio.h>
  21. #include <linux/err.h>
  22. #include <linux/spi/spidev.h>
  23. #include <linux/regulator/consumer.h>
  24. #include <linux/pinctrl/consumer.h>
  25. #include "fingerprint_common.h"
  26. #undef DISABLED_GPIO_PROTECTION
  27. #define VENDOR "QCOM"
  28. #define CHIP_ID "QFS4008"
  29. #define SPI_CLOCK_MAX 35000000
  30. #define QFS4008_DEV "qbt2000"
  31. #define MAX_FW_EVENTS 128
  32. #define IPC_MSG_ID_CBGE_REQUIRED 29
  33. #define IPC_MSG_ID_FINGER_ON_SENSOR 55
  34. #define IPC_MSG_ID_FINGER_OFF_SENSOR 56
  35. #define QFS4008_WAKELOCK_HOLD_TIME 500
  36. #define MINOR_NUM_FD 0
  37. #define MINOR_NUM_IPC 1
  38. #define FINGER_DOWN_GPIO_STATE 1
  39. #define FINGER_LEAVE_GPIO_STATE 0
  40. enum qfs4008_commands {
  41. QFS4008_POWER_CONTROL = 21,
  42. QFS4008_ENABLE_SPI_CLOCK = 22,
  43. QFS4008_DISABLE_SPI_CLOCK = 23,
  44. QFS4008_ENABLE_IPC = 24,
  45. QFS4008_DISABLE_IPC = 25,
  46. QFS4008_ENABLE_WUHB = 26,
  47. QFS4008_DISABLE_WUHB = 27,
  48. QFS4008_CPU_SPEEDUP = 28,
  49. QFS4008_SET_SENSOR_TYPE = 29,
  50. QFS4008_SET_LOCKSCREEN = 30,
  51. QFS4008_SENSOR_RESET = 31,
  52. QFS4008_SENSOR_TEST = 32,
  53. QFS4008_GET_MODELINFO = 38,
  54. QFS4008_SET_TOUCH_IGNORE = 39,
  55. QFS4008_IS_WHUB_CONNECTED = 105,
  56. };
  57. #define QFS4008_SENSORTEST_DONE 0x0000 // do nothing or test done
  58. #define QFS4008_SENSORTEST_BGECAL 0x0001 // begin the BGECAL
  59. #define QFS4008_SENSORTEST_NORMALSCAN 0x0002 // begin the normalscan
  60. #define QFS4008_SENSORTEST_SNR 0x0004 // begin the snr
  61. #define QFS4008_SENSORTEST_CAPTURE 0x0008 // begin the image capture. it also needs liveness capture.
  62. /*
  63. * enum qfs4008_fw_event -
  64. * enumeration of firmware events
  65. * @FW_EVENT_FINGER_DOWN - finger down detected
  66. * @FW_EVENT_FINGER_UP - finger up detected
  67. * @FW_EVENT_INDICATION - an indication IPC from the firmware is pending
  68. */
  69. enum qfs4008_fw_event {
  70. FW_EVENT_FINGER_DOWN = 1,
  71. FW_EVENT_FINGER_UP = 2,
  72. FW_EVENT_CBGE_REQUIRED = 3,
  73. };
  74. struct finger_detect_gpio {
  75. int gpio;
  76. int active_low;
  77. int irq;
  78. struct work_struct work;
  79. int last_gpio_state;
  80. };
  81. struct fw_event_desc {
  82. enum qfs4008_fw_event ev;
  83. };
  84. struct fw_ipc_info {
  85. int gpio;
  86. int irq;
  87. };
  88. struct qfs4008_drvdata {
  89. struct class *qfs4008_class;
  90. struct cdev qfs4008_fd_cdev;
  91. struct cdev qfs4008_ipc_cdev;
  92. struct device *dev;
  93. struct device *fp_device;
  94. atomic_t fd_available;
  95. atomic_t ipc_available;
  96. struct mutex mutex;
  97. struct mutex ioctl_mutex;
  98. struct mutex fd_events_mutex;
  99. struct mutex ipc_events_mutex;
  100. struct fw_ipc_info fw_ipc;
  101. struct finger_detect_gpio fd_gpio;
  102. DECLARE_KFIFO(fd_events, struct fw_event_desc, MAX_FW_EVENTS);
  103. DECLARE_KFIFO(ipc_events, struct fw_event_desc, MAX_FW_EVENTS);
  104. wait_queue_head_t read_wait_queue_fd;
  105. wait_queue_head_t read_wait_queue_ipc;
  106. int sensortype;
  107. int cbge_count;
  108. int wuhb_count;
  109. int reset_count;
  110. bool enabled_ipc;
  111. bool enabled_wuhb;
  112. bool enabled_ldo;
  113. bool tz_mode;
  114. bool touch_ignore;
  115. const char *model_info;
  116. const char *chipid;
  117. struct pinctrl *p;
  118. struct pinctrl_state *pins_poweron;
  119. struct pinctrl_state *pins_poweroff;
  120. const char *sensor_position;
  121. const char *btp_vdd_1p8;
  122. const char *btp_vdd_3p0;
  123. struct regulator *regulator_1p8;
  124. struct regulator *regulator_3p0;
  125. struct wakeup_source *fp_signal_lock;
  126. struct spi_clk_setting *clk_setting;
  127. struct boosting_config *boosting;
  128. struct debug_logger *logger;
  129. };
  130. #ifdef CONFIG_BATTERY_SAMSUNG
  131. extern unsigned int lpcharge;
  132. #endif
  133. struct debug_logger *g_logger;
  134. #endif /* _UAPI_QFS4008_H_ */