vfs61xx.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. * Copyright 2011 Validity Sensors, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  17. * MA 02110-1301, USA.
  18. */
  19. #ifndef VFS61XX_H_
  20. #define VFS61XX_H_
  21. #include <linux/kernel.h>
  22. #include <linux/init.h>
  23. #include <linux/module.h>
  24. #include <linux/ioctl.h>
  25. #include <linux/fs.h>
  26. #include <linux/device.h>
  27. #include <linux/err.h>
  28. #include <linux/list.h>
  29. #include <linux/errno.h>
  30. #include <linux/mutex.h>
  31. #include <linux/slab.h>
  32. #include <linux/interrupt.h>
  33. #include <linux/delay.h>
  34. #include <linux/io.h>
  35. #include <linux/gpio.h>
  36. #include <linux/i2c/twl.h>
  37. #include <linux/wait.h>
  38. #include <linux/spi/spi.h>
  39. #include <asm-generic/uaccess.h>
  40. #include <linux/irq.h>
  41. #include <asm-generic/siginfo.h>
  42. #include <linux/rcupdate.h>
  43. #include <linux/sched.h>
  44. #include <linux/jiffies.h>
  45. #include <linux/wakelock.h>
  46. #include <linux/fprint_secure.h>
  47. /* Major number of device ID.
  48. * A device ID consists of two parts: a major number, identifying the class of
  49. * the device, and a minor ID, identifying a specific instance of a device in
  50. * that class. A device ID is represented using the type dev_t. The minor number
  51. * of the Validity device is 0. */
  52. #define VFSSPI_MAJOR (221)
  53. /* Maximum transfer size */
  54. #define DEFAULT_BUFFER_SIZE (4096 * 5)
  55. #define DRDY_ACTIVE_STATUS 0
  56. #define BITS_PER_WORD 16
  57. #define DRDY_IRQ_FLAG IRQF_TRIGGER_FALLING
  58. #define VENDOR "SYNAPTICS"
  59. #define CHIP_ID "RAPTOR"
  60. /* Timeout value for polling DRDY signal assertion */
  61. #define DRDY_TIMEOUT_MS 40
  62. /*
  63. * Definitions of structures which are used by IOCTL commands
  64. */
  65. #ifndef ENABLE_SENSORS_FPRINT_SECURE
  66. /* Pass to VFSSPI_IOCTL_SET_USER_DATA
  67. * and VFSSPI_IOCTL_GET_USER_DATA commands */
  68. struct vfsspi_iocUserData {
  69. void *buffer;
  70. unsigned int len;
  71. };
  72. #endif
  73. #ifndef ENABLE_SENSORS_FPRINT_SECURE
  74. /* Pass to VFSSPI_IOCTL_RW_SPI_MESSAGE command */
  75. struct vfsspi_iocTransfer {
  76. unsigned char *rxBuffer; /* pointer to retrieved data */
  77. unsigned char *txBuffer; /* pointer to transmitted data */
  78. unsigned int len; /* transmitted/retrieved data size */
  79. };
  80. #endif
  81. /* Pass to VFSSPI_IOCTL_REGISTER_DRDY_SIGNAL command */
  82. struct vfsspi_iocRegSignal {
  83. /* Process ID to which SPI driver sends signal
  84. * indicating that DRDY is asserted */
  85. int userPID;
  86. int signalID; /* Signal number */
  87. };
  88. #ifdef CONFIG_SENSORS_FINGERPRINT_SYSFS
  89. extern int fingerprint_register(struct device *dev, void *drvdata,
  90. struct device_attribute *attributes[], char *name);
  91. extern void fingerprint_unregister(struct device *dev,
  92. struct device_attribute *attributes[]);
  93. #endif
  94. /* Magic number of IOCTL command */
  95. #define VFSSPI_IOCTL_MAGIC 'k'
  96. /*
  97. * IOCTL commands definitions
  98. */
  99. #ifndef ENABLE_SENSORS_FPRINT_SECURE
  100. /* Transmit data to the device
  101. and retrieve data from it simultaneously */
  102. #define VFSSPI_IOCTL_RW_SPI_MESSAGE \
  103. _IOWR(VFSSPI_IOCTL_MAGIC, 1, unsigned int)
  104. #endif
  105. /* Hard reset the device */
  106. #define VFSSPI_IOCTL_DEVICE_RESET \
  107. _IO(VFSSPI_IOCTL_MAGIC, 2)
  108. /* Set the baud rate of SPI master clock */
  109. #define VFSSPI_IOCTL_SET_CLK \
  110. _IOW(VFSSPI_IOCTL_MAGIC, 3, unsigned int)
  111. #ifndef ENABLE_SENSORS_FPRINT_SECURE
  112. /* Get level state of DRDY GPIO */
  113. #define VFSSPI_IOCTL_CHECK_DRDY \
  114. _IO(VFSSPI_IOCTL_MAGIC, 4)
  115. #endif
  116. /* Register DRDY signal. It is used by SPI driver
  117. * for indicating host that DRDY signal is asserted. */
  118. #define VFSSPI_IOCTL_REGISTER_DRDY_SIGNAL \
  119. _IOW(VFSSPI_IOCTL_MAGIC, 5, unsigned int)
  120. /* Store the user data into the SPI driver. Currently user data is a
  121. * device info data, which is obtained from announce packet. */
  122. #ifndef ENABLE_SENSORS_FPRINT_SECURE
  123. #define VFSSPI_IOCTL_SET_USER_DATA \
  124. _IOW(VFSSPI_IOCTL_MAGIC, 6, unsigned int)
  125. #endif
  126. #ifndef ENABLE_SENSORS_FPRINT_SECURE
  127. /* Retrieve user data from the SPI driver*/
  128. #define VFSSPI_IOCTL_GET_USER_DATA \
  129. _IOWR(VFSSPI_IOCTL_MAGIC, 7, unsigned int)
  130. #endif
  131. /* Enable/disable DRDY interrupt handling in the SPI driver */
  132. #define VFSSPI_IOCTL_SET_DRDY_INT \
  133. _IOW(VFSSPI_IOCTL_MAGIC, 8, unsigned int)
  134. /* Put device in Low power mode */
  135. #define VFSSPI_IOCTL_DEVICE_SUSPEND \
  136. _IO(VFSSPI_IOCTL_MAGIC, 9)
  137. #ifndef ENABLE_SENSORS_FPRINT_SECURE
  138. /* Indicate the fingerprint buffer size for read */
  139. #define VFSSPI_IOCTL_STREAM_READ_START \
  140. _IOW(VFSSPI_IOCTL_MAGIC, 10, unsigned int)
  141. /* Indicate that fingerprint acquisition is completed */
  142. #define VFSSPI_IOCTL_STREAM_READ_STOP \
  143. _IO(VFSSPI_IOCTL_MAGIC, 11)
  144. /* Retrieve supported SPI baud rate table */
  145. #define VFSSPI_IOCTL_GET_FREQ_TABLE \
  146. _IOWR(VFSSPI_IOCTL_MAGIC, 12, unsigned int)
  147. #endif
  148. /* Turn on the power to the sensor */
  149. #define VFSSPI_IOCTL_POWER_ON \
  150. _IO(VFSSPI_IOCTL_MAGIC, 13)
  151. /* Turn off the power to the sensor */
  152. #define VFSSPI_IOCTL_POWER_OFF \
  153. _IO(VFSSPI_IOCTL_MAGIC, 14)
  154. #ifdef ENABLE_SENSORS_FPRINT_SECURE
  155. /* To disable spi core clock */
  156. #define VFSSPI_IOCTL_DISABLE_SPI_CLOCK \
  157. _IO(VFSSPI_IOCTL_MAGIC, 15)
  158. /* To set SPI configurations like gpio, clks */
  159. #define VFSSPI_IOCTL_SET_SPI_CONFIGURATION \
  160. _IO(VFSSPI_IOCTL_MAGIC, 16)
  161. /* To reset SPI configurations */
  162. #define VFSSPI_IOCTL_RESET_SPI_CONFIGURATION \
  163. _IO(VFSSPI_IOCTL_MAGIC, 17)
  164. #endif
  165. /* get sensor orienation from the SPI driver*/
  166. #define VFSSPI_IOCTL_GET_SENSOR_ORIENT \
  167. _IOR(VFSSPI_IOCTL_MAGIC, 18, unsigned int)
  168. #endif /* VFS61XX_H_ */