generated from gaoyang3513/SDK_RK3288
151 lines
5.3 KiB
C
Executable File
151 lines
5.3 KiB
C
Executable File
/*
|
|
* Goodix GT9xx touchscreen driver
|
|
*
|
|
* Copyright (C) 2010 - 2014 Goodix. Ltd.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be a reference
|
|
* to you, when you are integrating the GOODiX's CTP IC into your system,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* Base version 2.4
|
|
* Release Date: 2021/11/27
|
|
*/
|
|
|
|
#ifndef _GOODIX_GT9XX_H_
|
|
#define _GOODIX_GT9XX_H_
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/hrtimer.h>
|
|
#include <linux/i2c.h>
|
|
#include <linux/input.h>
|
|
#include <linux/module.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/i2c.h>
|
|
#include <linux/proc_fs.h>
|
|
#include <linux/string.h>
|
|
#include <asm/uaccess.h>
|
|
#include <linux/vmalloc.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/io.h>
|
|
#include <linux/gpio.h>
|
|
#include <linux/of_gpio.h>
|
|
#include <linux/regulator/consumer.h>
|
|
#include <linux/fb.h>
|
|
|
|
#define GTP_DEBUG_ON 0
|
|
#define GTP_DEBUG_ARRAY_ON 0
|
|
#define GTP_DEBUG_FUNC_ON 0
|
|
|
|
struct goodix_chip_data {
|
|
u16 config_addr;
|
|
int config_len;
|
|
};
|
|
|
|
struct goodix_ts_data {
|
|
spinlock_t irq_lock;
|
|
struct i2c_client *client;
|
|
struct input_dev *input_dev;
|
|
struct hrtimer timer;
|
|
struct work_struct work;
|
|
const struct goodix_chip_data *chip;
|
|
s32 irq_is_disable;
|
|
s32 use_irq;
|
|
u16 abs_x_max;
|
|
u16 abs_y_max;
|
|
u8 max_touch_num;
|
|
u8 int_trigger_type;
|
|
u8 green_wake_mode;
|
|
u8 enter_update;
|
|
u8 gtp_is_suspend;
|
|
u8 gtp_rawdiff_mode;
|
|
int gtp_cfg_len;
|
|
u8 fw_error;
|
|
u8 pnl_init_error;
|
|
u16 id;
|
|
u16 version;
|
|
};
|
|
|
|
extern u16 show_len;
|
|
extern u16 total_len;
|
|
extern int gtp_rst_gpio;
|
|
extern int gtp_int_gpio;
|
|
|
|
#define GTP_GPIO_AS_INPUT(pin) do {\
|
|
gpio_direction_input(pin);\
|
|
} while(0)
|
|
#define GTP_GPIO_AS_INT(pin) do {\
|
|
GTP_GPIO_AS_INPUT(pin);\
|
|
} while(0)
|
|
#define GTP_GPIO_GET_VALUE(pin) gpio_get_value(pin)
|
|
#define GTP_GPIO_OUTPUT(pin, level) gpio_direction_output(pin,level)
|
|
#define GTP_IRQ_TAB {IRQ_TYPE_EDGE_RISING, IRQ_TYPE_EDGE_FALLING, IRQ_TYPE_LEVEL_LOW, IRQ_TYPE_LEVEL_HIGH}
|
|
|
|
#define GTP_MAX_HEIGHT 4096
|
|
#define GTP_MAX_WIDTH 4096
|
|
#define GTP_INT_TRIGGER 1 /* 0: Rising 1: Falling */
|
|
#define GTP_MAX_TOUCH 5
|
|
|
|
#define GTP_DRIVER_VERSION "gt9xx driver Rleased <2021/11/27> Based V2.4"
|
|
#define GTP_I2C_NAME "goodix-ts"
|
|
#define GT91XX_CONFIG_PROC_FILE "gt9xx_config"
|
|
#define GTP_POLL_TIME 10
|
|
#define GTP_ADDR_LENGTH 2
|
|
#define GTP_CONFIG_MIN_LENGTH 186
|
|
#define GTP_CONFIG_MAX_LENGTH 240
|
|
#define FAIL 0
|
|
#define SUCCESS 1
|
|
#define SWITCH_OFF 0
|
|
#define SWITCH_ON 1
|
|
|
|
/* Registers define */
|
|
#define GTP_READ_COOR_ADDR 0x814E
|
|
#define GTP_REG_SLEEP 0x8040
|
|
#define GTP_REG_SENSOR_ID 0x814A
|
|
#define GTP_GT1X_REG_CONFIG_DATA 0x8050
|
|
#define GTP_GT9X_REG_CONFIG_DATA 0x8047
|
|
#define GTP_REG_VERSION 0x8140
|
|
|
|
#define RESOLUTION_LOC 3
|
|
#define TRIGGER_LOC 8
|
|
|
|
#define CFG_GROUP_LEN(p_cfg_grp) (sizeof(p_cfg_grp) / sizeof(p_cfg_grp[0]))
|
|
/* Log define */
|
|
#define GTP_INFO(fmt,arg...) printk("<<-GTP-INFO->> "fmt"\n",##arg)
|
|
#define GTP_ERROR(fmt,arg...) printk("<<-GTP-ERROR->> "fmt"\n",##arg)
|
|
#define GTP_DEBUG(fmt,arg...) do {\
|
|
if(GTP_DEBUG_ON)\
|
|
printk("<<-GTP-DEBUG->> [%d]"fmt"\n",__LINE__, ##arg);\
|
|
} while(0)
|
|
#define GTP_DEBUG_ARRAY(array, num) do {\
|
|
s32 i;\
|
|
u8* a = array;\
|
|
if (GTP_DEBUG_ARRAY_ON) {\
|
|
printk("<<-GTP-DEBUG-ARRAY->>\n");\
|
|
for (i = 0; i < (num); i++) {\
|
|
printk("%02x ", (a)[i]);\
|
|
if ((i + 1 ) %10 == 0) {\
|
|
printk("\n");\
|
|
}\
|
|
}\
|
|
printk("\n");\
|
|
}\
|
|
} while(0)
|
|
#define GTP_DEBUG_FUNC() do {\
|
|
if(GTP_DEBUG_FUNC_ON)\
|
|
printk("<<-GTP-FUNC->> Func:%s@Line:%d\n",__func__,__LINE__);\
|
|
} while(0)
|
|
#define GTP_SWAP(x, y) do {\
|
|
typeof(x) z = x;\
|
|
x = y;\
|
|
y = z;\
|
|
} while (0)
|
|
|
|
#endif /* _GOODIX_GT9XX_H_ */
|