#ifndef __GF_SPI_DRIVER_H #define __GF_SPI_DRIVER_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef ENABLE_SENSORS_FPRINT_SECURE #include #include #include #include #include #endif #include #include #include #ifdef CONFIG_COMPAT #include #endif #include "fingerprint_common.h" #define GF_IOC_MAGIC 'g' #define G3_MCU_ID 0x1303 #define GX_MCU_ID 0x1306 #define G3S_MCU_ID 0x1231 #define GW9558_SPI_BAUD_RATE 25000000 #define TANSFER_MAX_LEN (512*1024) #define SPI_TRANSFER_DELAY 5 #define GF_DEV_NAME "goodix_fp" #define GF_DEV_MAJOR 0 /* assigned */ #define GF_CLASS_NAME "goodix_fp" #ifndef ENABLE_SENSORS_FPRINT_SECURE struct gf_ioc_transfer { u8 cmd; /* spi read = 0, spi write = 1 */ u8 reserved; u16 addr; u32 len; u8 *buf; }; struct gf_ioc_transfer_raw { u32 len; u8 *read_buf; u8 *write_buf; uint32_t high_time; uint32_t bits_per_word; }; #endif /* define commands */ #define GF_IOC_INIT _IOR(GF_IOC_MAGIC, 0, u8) #define GF_IOC_RESET _IO(GF_IOC_MAGIC, 2) #define GF_IOC_ENABLE_SPI_CLK _IOW(GF_IOC_MAGIC, 5, uint32_t) #define GF_IOC_DISABLE_SPI_CLK _IO(GF_IOC_MAGIC, 6) #define GF_IOC_ENABLE_POWER _IO(GF_IOC_MAGIC, 7) #define GF_IOC_DISABLE_POWER _IO(GF_IOC_MAGIC, 8) #define GF_IOC_GET_FW_INFO _IOR(GF_IOC_MAGIC, 11, u8) #ifndef ENABLE_SENSORS_FPRINT_SECURE #define GF_IOC_TRANSFER_CMD _IOWR(GF_IOC_MAGIC, 15, struct gf_ioc_transfer) #define GF_IOC_TRANSFER_RAW_CMD _IOWR(GF_IOC_MAGIC, 16, struct gf_ioc_transfer_raw) #else #define GF_IOC_SET_SENSOR_TYPE _IOW(GF_IOC_MAGIC, 18, unsigned int) #endif #define GF_IOC_POWER_CONTROL _IOW(GF_IOC_MAGIC, 19, unsigned int) #define GF_IOC_SPEEDUP _IOW(GF_IOC_MAGIC, 20, unsigned int) #define GF_MODEL_INFO _IOR(GF_IOC_MAGIC, 23, unsigned int) #define GF_IOC_RESERVED01 _IO(GF_IOC_MAGIC, 1) #define GF_IOC_RESERVED02 _IO(GF_IOC_MAGIC, 3) #define GF_IOC_RESERVED03 _IO(GF_IOC_MAGIC, 4) #define GF_IOC_RESERVED04 _IO(GF_IOC_MAGIC, 10) #define GF_IOC_RESERVED05 _IO(GF_IOC_MAGIC, 12) #define GF_IOC_RESERVED06 _IOW(GF_IOC_MAGIC, 21, unsigned int) #define GF_IOC_RESERVED07 _IOR(GF_IOC_MAGIC, 22, unsigned int) #define GF_IOC_MAXNR 24 /* THIS MACRO IS NOT USED NOW... */ struct gf_device { dev_t devno; struct cdev cdev; struct device *dev; struct device *fp_device; struct class *class; struct spi_device *spi; struct list_head device_entry; int device_count; spinlock_t spi_lock; u32 pwr_gpio; u32 reset_gpio; int prev_bits_per_word; unsigned int min_cpufreq_limit; struct pm_qos_request pm_qos; #ifndef ENABLE_SENSORS_FPRINT_SECURE u8 *spi_buffer; u8 *tx_buf; u8 *rx_buf; struct mutex buf_lock; #endif int sensortype; int reset_count; bool ldo_onoff; bool tz_mode; const char *chipid; const char *sensor_position; const char *rb; const char *btp_vdd; struct regulator *regulator_3p3; struct pinctrl *p; struct pinctrl_state *pins_poweron; struct pinctrl_state *pins_poweroff; const char *model_info; struct spi_clk_setting *clk_setting; struct boosting_config *boosting; struct debug_logger *logger; }; int gw9558_get_gpio_dts_info(struct device *dev, struct gf_device *gf_dev); void gw9558_cleanup_info(struct gf_device *gf_dev); void gw9558_hw_power_enable(struct gf_device *gf_dev, u8 onoff); void gw9558_hw_reset(struct gf_device *gf_dev, u8 delay); #ifndef ENABLE_SENSORS_FPRINT_SECURE void gw9558_spi_setup_conf(struct gf_device *gf_dev, u32 bits); int gw9558_spi_read_bytes(struct gf_device *gf_dev, u16 addr, u32 data_len, u8 *rx_buf); int gw9558_spi_write_bytes(struct gf_device *gf_dev, u16 addr, u32 data_len, u8 *tx_buf); int gw9558_spi_read_byte(struct gf_device *gf_dev, u16 addr, u8 *value); int gw9558_spi_write_byte(struct gf_device *gf_dev, u16 addr, u8 value); int gw9558_ioctl_transfer_raw_cmd(struct gf_device *gf_dev, unsigned long arg, unsigned int bufsiz); int gw9558_init_buffer(struct gf_device *gf_dev); int gw9558_free_buffer(struct gf_device *gf_dev); #endif extern int fingerprint_register(struct device *dev, void *drvdata, struct device_attribute *attributes[], char *name); extern void fingerprint_unregister(struct device *dev, struct device_attribute *attributes[]); #endif /* __GF_SPI_DRIVER_H */