Skip to content

Commit fc13e7c

Browse files
jwrdegoedesmb49
authored andcommittedSep 16, 2022
Input: goodix - add a goodix.h header file
BugLink: https://bugs.launchpad.net/bugs/1987451 [ Upstream commit a2233cb7b65a017067e2f2703375ecc930a0ab30 ] Add a goodix.h header file, and move the register definitions, and struct declarations there and add prototypes for various helper functions. This is a preparation patch for adding support for controllers without flash, which need to have their firmware uploaded and need some other special handling too. Since MAINTAINERS needs updating because of this change anyways, also add myself as co-maintainer. Reviewed-by: Bastien Nocera <hadess@hadess.net> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20210920150643.155872-3-hdegoede@redhat.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 00d1801 commit fc13e7c

File tree

3 files changed

+81
-69
lines changed

3 files changed

+81
-69
lines changed
 

‎MAINTAINERS

+2-1
Original file line numberDiff line numberDiff line change
@@ -7989,9 +7989,10 @@ F: drivers/media/usb/go7007/
79897989

79907990
GOODIX TOUCHSCREEN
79917991
M: Bastien Nocera <hadess@hadess.net>
7992+
M: Hans de Goede <hdegoede@redhat.com>
79927993
L: linux-input@vger.kernel.org
79937994
S: Maintained
7994-
F: drivers/input/touchscreen/goodix.c
7995+
F: drivers/input/touchscreen/goodix*
79957996

79967997
GOOGLE ETHERNET DRIVERS
79977998
M: Jeroen de Borst <jeroendb@google.com>

‎drivers/input/touchscreen/goodix.c

+6-68
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,15 @@
1414
#include <linux/kernel.h>
1515
#include <linux/dmi.h>
1616
#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>
2217
#include <linux/module.h>
2318
#include <linux/delay.h>
2419
#include <linux/irq.h>
2520
#include <linux/interrupt.h>
26-
#include <linux/regulator/consumer.h>
2721
#include <linux/slab.h>
2822
#include <linux/acpi.h>
2923
#include <linux/of.h>
3024
#include <asm/unaligned.h>
25+
#include "goodix.h"
3126

3227
#define GOODIX_GPIO_INT_NAME "irq"
3328
#define GOODIX_GPIO_RST_NAME "reset"
@@ -38,22 +33,11 @@
3833
#define GOODIX_CONTACT_SIZE 8
3934
#define GOODIX_MAX_CONTACT_SIZE 9
4035
#define GOODIX_MAX_CONTACTS 10
41-
#define GOODIX_MAX_KEYS 7
4236

4337
#define GOODIX_CONFIG_MIN_LENGTH 186
4438
#define GOODIX_CONFIG_911_LENGTH 186
4539
#define GOODIX_CONFIG_967_LENGTH 228
4640
#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
5741

5842
#define GOODIX_BUFFER_STATUS_READY BIT(7)
5943
#define GOODIX_HAVE_KEY BIT(4)
@@ -68,55 +52,11 @@
6852
#define ACPI_GPIO_SUPPORT
6953
#endif
7054

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-
8755
struct goodix_chip_id {
8856
const char *id;
8957
const struct goodix_chip_data *data;
9058
};
9159

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-
12060
static int goodix_check_cfg_8(struct goodix_ts_data *ts,
12161
const u8 *cfg, int len);
12262
static int goodix_check_cfg_16(struct goodix_ts_data *ts,
@@ -216,8 +156,7 @@ static const struct dmi_system_id inverted_x_screen[] = {
216156
* @buf: raw write data buffer.
217157
* @len: length of the buffer to write
218158
*/
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)
221160
{
222161
struct i2c_msg msgs[2];
223162
__be16 wbuf = cpu_to_be16(reg);
@@ -245,8 +184,7 @@ static int goodix_i2c_read(struct i2c_client *client,
245184
* @buf: raw data buffer to write.
246185
* @len: length of the buffer to write
247186
*/
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)
250188
{
251189
u8 *addr_buf;
252190
struct i2c_msg msg;
@@ -270,7 +208,7 @@ static int goodix_i2c_write(struct i2c_client *client, u16 reg, const u8 *buf,
270208
return ret < 0 ? ret : (ret != 1 ? -EIO : 0);
271209
}
272210

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)
274212
{
275213
return goodix_i2c_write(client, reg, &value, sizeof(value));
276214
}
@@ -554,7 +492,7 @@ static int goodix_check_cfg(struct goodix_ts_data *ts, const u8 *cfg, int len)
554492
* @cfg: config firmware to write to device
555493
* @len: config data length
556494
*/
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)
558496
{
559497
int error;
560498

@@ -652,7 +590,7 @@ static int goodix_irq_direction_input(struct goodix_ts_data *ts)
652590
return -EINVAL; /* Never reached */
653591
}
654592

655-
static int goodix_int_sync(struct goodix_ts_data *ts)
593+
int goodix_int_sync(struct goodix_ts_data *ts)
656594
{
657595
int error;
658596

‎drivers/input/touchscreen/goodix.h

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
#ifndef __GOODIX_H__
3+
#define __GOODIX_H__
4+
5+
#include <linux/gpio/consumer.h>
6+
#include <linux/i2c.h>
7+
#include <linux/input.h>
8+
#include <linux/input/mt.h>
9+
#include <linux/input/touchscreen.h>
10+
#include <linux/regulator/consumer.h>
11+
12+
/* Register defines */
13+
#define GOODIX_REG_COMMAND 0x8040
14+
#define GOODIX_CMD_SCREEN_OFF 0x05
15+
16+
#define GOODIX_GT1X_REG_CONFIG_DATA 0x8050
17+
#define GOODIX_GT9X_REG_CONFIG_DATA 0x8047
18+
#define GOODIX_REG_ID 0x8140
19+
#define GOODIX_READ_COOR_ADDR 0x814E
20+
21+
#define GOODIX_ID_MAX_LEN 4
22+
#define GOODIX_CONFIG_MAX_LENGTH 240
23+
#define GOODIX_MAX_KEYS 7
24+
25+
enum goodix_irq_pin_access_method {
26+
IRQ_PIN_ACCESS_NONE,
27+
IRQ_PIN_ACCESS_GPIO,
28+
IRQ_PIN_ACCESS_ACPI_GPIO,
29+
IRQ_PIN_ACCESS_ACPI_METHOD,
30+
};
31+
32+
struct goodix_ts_data;
33+
34+
struct goodix_chip_data {
35+
u16 config_addr;
36+
int config_len;
37+
int (*check_config)(struct goodix_ts_data *ts, const u8 *cfg, int len);
38+
void (*calc_config_checksum)(struct goodix_ts_data *ts);
39+
};
40+
41+
struct goodix_ts_data {
42+
struct i2c_client *client;
43+
struct input_dev *input_dev;
44+
const struct goodix_chip_data *chip;
45+
struct touchscreen_properties prop;
46+
unsigned int max_touch_num;
47+
unsigned int int_trigger_type;
48+
struct regulator *avdd28;
49+
struct regulator *vddio;
50+
struct gpio_desc *gpiod_int;
51+
struct gpio_desc *gpiod_rst;
52+
int gpio_count;
53+
int gpio_int_idx;
54+
char id[GOODIX_ID_MAX_LEN + 1];
55+
u16 version;
56+
const char *cfg_name;
57+
bool reset_controller_at_probe;
58+
bool load_cfg_from_disk;
59+
struct completion firmware_loading_complete;
60+
unsigned long irq_flags;
61+
enum goodix_irq_pin_access_method irq_pin_access_method;
62+
unsigned int contact_size;
63+
u8 config[GOODIX_CONFIG_MAX_LENGTH];
64+
unsigned short keymap[GOODIX_MAX_KEYS];
65+
};
66+
67+
int goodix_i2c_read(struct i2c_client *client, u16 reg, u8 *buf, int len);
68+
int goodix_i2c_write(struct i2c_client *client, u16 reg, const u8 *buf, int len);
69+
int goodix_i2c_write_u8(struct i2c_client *client, u16 reg, u8 value);
70+
int goodix_send_cfg(struct goodix_ts_data *ts, const u8 *cfg, int len);
71+
int goodix_int_sync(struct goodix_ts_data *ts);
72+
73+
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.