2 * include/linux/goodix_touch.h
4 * Copyright (C) 2010 - 2011 Goodix, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 #ifndef _LINUX_GOODIX_TOUCH_H
19 #define _LINUX_GOODIX_TOUCH_H
21 #ifdef CONFIG_HAS_EARLYSUSPEND
22 #include <linux/earlysuspend.h>
24 #include <linux/hrtimer.h>
25 #include <linux/i2c.h>
26 #include <linux/input.h>
28 //*************************TouchScreen Work Part*****************************
30 #define GOODIX_I2C_NAME "Goodix-TS"
31 #define TS_MAX_X CONFIG_TOUCH_MAX_X
32 #define TS_MAX_Y CONFIG_TOUCH_MAX_Y
35 #define INT_PORT RK29_PIN0_PA2
37 #define TS_INT gpio_to_irq(INT_PORT)
38 // #define INT_CFG S3C_GPIO_SFN(2) //IO configer as EINT
43 //whether need send cfg?
44 //#define DRIVER_SEND_CFG
51 #define POLL_TIME 10 //actual query spacing interval:POLL_TIME+6
53 #define GOODIX_MULTI_TOUCH
54 #ifdef GOODIX_MULTI_TOUCH
55 #define MAX_FINGER_NUM 10
57 #define MAX_FINGER_NUM 1
60 //#define swap(x, y) do { typeof(x) z = x; x = y; y = z; } while (0)
70 struct i2c_client *client;
71 struct input_dev *input_dev;
77 int read_mode; //read moudle mode,20110221 by andrew
79 #ifdef CONFIG_HAS_EARLYSUSPEND
80 struct early_suspend early_suspend;
82 int (*power)(struct rk_ts_data * ts, int on);
83 int (*ts_init)(struct rk_ts_data*ts);
84 int (*input_parms_init)(struct rk_ts_data *ts);
85 void (*get_touch_info)(struct rk_ts_data *ts,char *point_num,struct rk_touch_info *info_buf); //get touch data info
88 uint8_t max_touch_num;
90 struct rk_touch_info *info_buf;
95 struct goodix_ts_data {
98 struct i2c_client *client;
99 struct input_dev *input_dev;
100 int use_reset; //use RESET flag
101 int use_irq; //use EINT flag
102 int read_mode; //read moudle mode,20110221 by andrew
103 struct hrtimer timer;
104 struct delayed_work work;
107 #ifdef CONFIG_HAS_EARLYSUSPEND
108 struct early_suspend early_suspend;
110 int (*power)(struct goodix_ts_data * ts, int on);
113 uint8_t max_touch_num;
114 uint8_t int_trigger_type;
118 static const char *rk_ts_name = "Goodix Capacitive TouchScreen";
119 struct i2c_client * i2c_connect_client = NULL;
120 static struct proc_dir_entry *goodix_proc_entry;
121 //static struct kobject *goodix_debug_kobj;
124 #define READ_COOR_ADDR 0x01
126 //*****************************End of Part I *********************************
128 //*************************Touchkey Surpport Part*****************************
129 //#define HAVE_TOUCH_KEY
130 #ifdef HAVE_TOUCH_KEY
131 #define READ_COOR_ADDR 0x00
132 const uint16_t touch_key_array[]={
137 #define MAX_KEY_NUM (sizeof(touch_key_array)/sizeof(touch_key_array[0]))
139 #define READ_COOR_ADDR 0x01
141 //*****************************End of Part II*********************************
143 //*************************Firmware Update part*******************************
144 //#define CONFIG_TOUCHSCREEN_GOODIX_IAP
145 #ifdef CONFIG_TOUCHSCREEN_GOODIX_IAP
146 #define UPDATE_NEW_PROTOCOL
148 unsigned int oldcrc32 = 0xFFFFFFFF;
149 unsigned int crc32_table[256];
150 unsigned int ulPolynomial = 0x04c11db7;
151 unsigned char rd_cfg_addr;
152 unsigned char rd_cfg_len;
153 unsigned char g_enter_isp = 0;
155 static int goodix_update_write(struct file *filp, const char __user *buff, unsigned long len, void *data);
156 static int goodix_update_read( char *page, char **start, off_t off, int count, int *eof, void *data );
158 #define PACK_SIZE 64 //update file package size
159 #define MAX_TIMEOUT 60000 //update time out conut
160 #define MAX_I2C_RETRIES 20 //i2c retry times
165 #ifdef UPDATE_NEW_PROTOCOL
172 #define NEW_UPDATE_START 0x01
173 #define UPDATE_START 0x02
174 #define SLAVE_READY 0x08
175 #define UNKNOWN_ERROR 0x00
176 #define FRAME_ERROR 0x10
177 #define CHECKSUM_ERROR 0x20
178 #define TRANSLATE_ERROR 0x40
179 #define FLASH_ERROR 0X80
182 #define ERROR_NO_FILE 2 //ENOENT
183 #define ERROR_FILE_READ 23 //ENFILE
184 #define ERROR_FILE_TYPE 21 //EISDIR
185 #define ERROR_GPIO_REQUEST 4 //EINTR
186 #define ERROR_I2C_TRANSFER 5 //EIO
187 #define ERROR_NO_RESPONSE 16 //EBUSY
188 #define ERROR_TIMEOUT 110 //ETIMEDOUT
191 #define STEP_SET_PATH 1
192 #define STEP_CHECK_FILE 2
193 #define STEP_WRITE_SYN 3
194 #define STEP_WAIT_SYN 4
195 #define STEP_WRITE_LENGTH 5
196 #define STEP_WAIT_READY 6
197 #define STEP_WRITE_DATA 7
198 #define STEP_READ_STATUS 8
199 #define FUN_CLR_VAL 9
201 #define FUN_WRITE_CONFIG 11
204 #define CMD_DISABLE_TP 0
205 #define CMD_ENABLE_TP 1
206 #define CMD_READ_VER 2
207 #define CMD_READ_RAW 3
208 #define CMD_READ_DIF 4
209 #define CMD_READ_CFG 5
210 #define CMD_SYS_REBOOT 101
213 #define MODE_RD_VER 1
214 #define MODE_RD_RAW 2
215 #define MODE_RD_DIF 3
216 #define MODE_RD_CFG 4
220 //*****************************End of Part III********************************
222 struct goodix_i2c_platform_data {
223 uint32_t version; /* Use this entry for panels with */
227 #endif /* _LINUX_GOODIX_TOUCH_H */