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 enum gpiod_flags gpiod_rst_flags; 55 char id[GOODIX_ID_MAX_LEN + 1]; 56 u16 version; 57 const char *cfg_name; 58 bool reset_controller_at_probe; 59 bool load_cfg_from_disk; 60 struct completion firmware_loading_complete; 61 unsigned long irq_flags; 62 enum goodix_irq_pin_access_method irq_pin_access_method; 63 unsigned int contact_size; 64 u8 config[GOODIX_CONFIG_MAX_LENGTH]; 65 unsigned short keymap[GOODIX_MAX_KEYS]; 66 }; 67 68 int goodix_i2c_read(struct i2c_client *client, u16 reg, u8 *buf, int len); 69 int goodix_i2c_write(struct i2c_client *client, u16 reg, const u8 *buf, int len); 70 int goodix_i2c_write_u8(struct i2c_client *client, u16 reg, u8 value); 71 int goodix_send_cfg(struct goodix_ts_data *ts, const u8 *cfg, int len); 72 int goodix_int_sync(struct goodix_ts_data *ts); 73 int goodix_reset_no_int_sync(struct goodix_ts_data *ts); 74 75 #endif 76