1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
#ifndef __GF_SPI_DRIVER_H
#define __GF_SPI_DRIVER_H
#include <linux/types.h>
#include <linux/cdev.h>
#include <linux/wakelock.h>
#include <linux/spi/spidev.h>
#include <linux/delay.h>
#include <linux/workqueue.h>
#include <linux/of_gpio.h>
#include <linux/gpio.h>
#include <linux/regulator/consumer.h>
#include <linux/timer.h>
#include <linux/err.h>
#include <linux/spi/spi.h>
#include <linux/device.h>
#include <linux/mutex.h>
#include <linux/io.h>
#include <linux/version.h>
#include <linux/pm_qos.h>
#include <linux/cpufreq.h>
#ifdef ENABLE_SENSORS_FPRINT_SECURE
#include <linux/clk.h>
#include <linux/pm_runtime.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_dma.h>
#include <linux/amba/bus.h>
#endif
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/of_platform.h>
#ifdef CONFIG_COMPAT
#include <linux/compat.h>
#endif
#define GF_IOC_MAGIC 'g'
#define G3_MCU_ID 0x12011303
#define GX_MCU_ID 0x10041306
#define GW9558_SPI_BAUD_RATE 25000000
#define TANSFER_MAX_LEN (512*1024)
#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 *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;
struct work_struct work_debug;
struct workqueue_struct *wq_dbg;
struct timer_list dbg_timer;
#ifdef ENABLE_SENSORS_FPRINT_SECURE
bool enabled_clk;
struct clk *fp_spi_pclk;
struct clk *fp_spi_sclk;
#else
u8 *spi_buffer;
u8 *tx_buf;
u8 *rx_buf;
struct mutex buf_lock;
#endif
u32 spi_speed;
int sensortype;
int reset_count;
int interrupt_count;
bool ldo_onoff;
bool tz_mode;
const char *chipid;
const char *sensor_position;
const char *rb;
struct wake_lock wake_lock;
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;
};
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);
int gw9558_spi_clk_enable(struct gf_device *gf_dev);
int gw9558_spi_clk_disable(struct gf_device *gf_dev);
void gw9558_hw_reset(struct gf_device *gf_dev, u8 delay);
void gw9558_spi_setup_conf(struct gf_device *gf_dev, u32 bits);
int gw9558_pin_control(struct gf_device *gf_dev, bool pin_set);
int gw9558_register_platform_variable(struct gf_device *gf_dev);
int gw9558_unregister_platform_variable(struct gf_device *gf_dev);
int gw9558_set_cpu_speedup(struct gf_device *gf_dev, int onoff);
#ifndef ENABLE_SENSORS_FPRINT_SECURE
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
#endif /* __GF_SPI_DRIVER_H */
|