14
14
#include <linux/kernel.h>
15
15
#include <linux/dmi.h>
16
16
#include <linux/firmware.h>
17
- #include <linux/gpio/consumer.h>
18
- #include <linux/i2c.h>
19
- #include <linux/input.h>
20
- #include <linux/input/mt.h>
21
- #include <linux/input/touchscreen.h>
22
17
#include <linux/module.h>
23
18
#include <linux/delay.h>
24
19
#include <linux/irq.h>
25
20
#include <linux/interrupt.h>
26
- #include <linux/regulator/consumer.h>
27
21
#include <linux/slab.h>
28
22
#include <linux/acpi.h>
29
23
#include <linux/of.h>
30
24
#include <asm/unaligned.h>
25
+ #include "goodix.h"
31
26
32
27
#define GOODIX_GPIO_INT_NAME "irq"
33
28
#define GOODIX_GPIO_RST_NAME "reset"
38
33
#define GOODIX_CONTACT_SIZE 8
39
34
#define GOODIX_MAX_CONTACT_SIZE 9
40
35
#define GOODIX_MAX_CONTACTS 10
41
- #define GOODIX_MAX_KEYS 7
42
36
43
37
#define GOODIX_CONFIG_MIN_LENGTH 186
44
38
#define GOODIX_CONFIG_911_LENGTH 186
45
39
#define GOODIX_CONFIG_967_LENGTH 228
46
40
#define GOODIX_CONFIG_GT9X_LENGTH 240
47
- #define GOODIX_CONFIG_MAX_LENGTH 240
48
-
49
- /* Register defines */
50
- #define GOODIX_REG_COMMAND 0x8040
51
- #define GOODIX_CMD_SCREEN_OFF 0x05
52
-
53
- #define GOODIX_READ_COOR_ADDR 0x814E
54
- #define GOODIX_GT1X_REG_CONFIG_DATA 0x8050
55
- #define GOODIX_GT9X_REG_CONFIG_DATA 0x8047
56
- #define GOODIX_REG_ID 0x8140
57
41
58
42
#define GOODIX_BUFFER_STATUS_READY BIT(7)
59
43
#define GOODIX_HAVE_KEY BIT(4)
68
52
#define ACPI_GPIO_SUPPORT
69
53
#endif
70
54
71
- struct goodix_ts_data ;
72
-
73
- enum goodix_irq_pin_access_method {
74
- IRQ_PIN_ACCESS_NONE ,
75
- IRQ_PIN_ACCESS_GPIO ,
76
- IRQ_PIN_ACCESS_ACPI_GPIO ,
77
- IRQ_PIN_ACCESS_ACPI_METHOD ,
78
- };
79
-
80
- struct goodix_chip_data {
81
- u16 config_addr ;
82
- int config_len ;
83
- int (* check_config )(struct goodix_ts_data * ts , const u8 * cfg , int len );
84
- void (* calc_config_checksum )(struct goodix_ts_data * ts );
85
- };
86
-
87
55
struct goodix_chip_id {
88
56
const char * id ;
89
57
const struct goodix_chip_data * data ;
90
58
};
91
59
92
- #define GOODIX_ID_MAX_LEN 4
93
-
94
- struct goodix_ts_data {
95
- struct i2c_client * client ;
96
- struct input_dev * input_dev ;
97
- const struct goodix_chip_data * chip ;
98
- struct touchscreen_properties prop ;
99
- unsigned int max_touch_num ;
100
- unsigned int int_trigger_type ;
101
- struct regulator * avdd28 ;
102
- struct regulator * vddio ;
103
- struct gpio_desc * gpiod_int ;
104
- struct gpio_desc * gpiod_rst ;
105
- int gpio_count ;
106
- int gpio_int_idx ;
107
- char id [GOODIX_ID_MAX_LEN + 1 ];
108
- u16 version ;
109
- const char * cfg_name ;
110
- bool reset_controller_at_probe ;
111
- bool load_cfg_from_disk ;
112
- struct completion firmware_loading_complete ;
113
- unsigned long irq_flags ;
114
- enum goodix_irq_pin_access_method irq_pin_access_method ;
115
- unsigned int contact_size ;
116
- u8 config [GOODIX_CONFIG_MAX_LENGTH ];
117
- unsigned short keymap [GOODIX_MAX_KEYS ];
118
- };
119
-
120
60
static int goodix_check_cfg_8 (struct goodix_ts_data * ts ,
121
61
const u8 * cfg , int len );
122
62
static int goodix_check_cfg_16 (struct goodix_ts_data * ts ,
@@ -216,8 +156,7 @@ static const struct dmi_system_id inverted_x_screen[] = {
216
156
* @buf: raw write data buffer.
217
157
* @len: length of the buffer to write
218
158
*/
219
- static int goodix_i2c_read (struct i2c_client * client ,
220
- u16 reg , u8 * buf , int len )
159
+ int goodix_i2c_read (struct i2c_client * client , u16 reg , u8 * buf , int len )
221
160
{
222
161
struct i2c_msg msgs [2 ];
223
162
__be16 wbuf = cpu_to_be16 (reg );
@@ -245,8 +184,7 @@ static int goodix_i2c_read(struct i2c_client *client,
245
184
* @buf: raw data buffer to write.
246
185
* @len: length of the buffer to write
247
186
*/
248
- static int goodix_i2c_write (struct i2c_client * client , u16 reg , const u8 * buf ,
249
- int len )
187
+ int goodix_i2c_write (struct i2c_client * client , u16 reg , const u8 * buf , int len )
250
188
{
251
189
u8 * addr_buf ;
252
190
struct i2c_msg msg ;
@@ -270,7 +208,7 @@ static int goodix_i2c_write(struct i2c_client *client, u16 reg, const u8 *buf,
270
208
return ret < 0 ? ret : (ret != 1 ? - EIO : 0 );
271
209
}
272
210
273
- static int goodix_i2c_write_u8 (struct i2c_client * client , u16 reg , u8 value )
211
+ int goodix_i2c_write_u8 (struct i2c_client * client , u16 reg , u8 value )
274
212
{
275
213
return goodix_i2c_write (client , reg , & value , sizeof (value ));
276
214
}
@@ -554,7 +492,7 @@ static int goodix_check_cfg(struct goodix_ts_data *ts, const u8 *cfg, int len)
554
492
* @cfg: config firmware to write to device
555
493
* @len: config data length
556
494
*/
557
- static int goodix_send_cfg (struct goodix_ts_data * ts , const u8 * cfg , int len )
495
+ int goodix_send_cfg (struct goodix_ts_data * ts , const u8 * cfg , int len )
558
496
{
559
497
int error ;
560
498
@@ -652,7 +590,7 @@ static int goodix_irq_direction_input(struct goodix_ts_data *ts)
652
590
return - EINVAL ; /* Never reached */
653
591
}
654
592
655
- static int goodix_int_sync (struct goodix_ts_data * ts )
593
+ int goodix_int_sync (struct goodix_ts_data * ts )
656
594
{
657
595
int error ;
658
596
0 commit comments