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 #include <linux/earlysuspend.h>
22 #include <linux/hrtimer.h>
23 #include <linux/i2c.h>
24 #include <linux/input.h>
26 //*************************TouchScreen Work Part*****************************
28 #define GOODIX_I2C_NAME "Goodix-TS"
29 #define TS_MAX_X CONFIG_TOUCH_MAX_X
30 #define TS_MAX_Y CONFIG_TOUCH_MAX_Y
33 #define INT_PORT RK29_PIN0_PA2
35 #define TS_INT gpio_to_irq(INT_PORT)
36 // #define INT_CFG S3C_GPIO_SFN(2) //IO configer as EINT
41 //whether need send cfg?
42 //#define DRIVER_SEND_CFG
49 #define POLL_TIME 10 //actual query spacing interval:POLL_TIME+6
51 #define GOODIX_MULTI_TOUCH
52 #ifdef GOODIX_MULTI_TOUCH
53 #define MAX_FINGER_NUM 10
55 #define MAX_FINGER_NUM 1
58 //#define swap(x, y) do { typeof(x) z = x; x = y; y = z; } while (0)
68 struct i2c_client *client;
69 struct input_dev *input_dev;
74 int read_mode; //read moudle mode,20110221 by andrew
76 struct workqueue_struct *ts_wq;
77 struct delayed_work ts_work;
79 struct early_suspend early_suspend;
80 int (*power)(struct rk_ts_data * ts, int on);
81 int (*ts_init)(struct rk_ts_data*ts);
82 int (*input_parms_init)(struct rk_ts_data *ts);
83 void (*get_touch_info)(struct rk_ts_data *ts,char *point_num,struct rk_touch_info *info_buf); //get touch data info
86 uint8_t max_touch_num;
92 struct goodix_ts_data {
95 struct i2c_client *client;
96 struct input_dev *input_dev;
97 int use_reset; //use RESET flag
98 int use_irq; //use EINT flag
99 int read_mode; //read moudle mode,20110221 by andrew
100 struct hrtimer timer;
101 struct delayed_work work;
104 struct early_suspend early_suspend;
105 int (*power)(struct goodix_ts_data * ts, int on);
108 uint8_t max_touch_num;
109 uint8_t int_trigger_type;
113 static const char *rk_ts_name = "Goodix Capacitive TouchScreen";
114 static struct workqueue_struct *goodix_wq;
115 struct i2c_client * i2c_connect_client = NULL;
116 static struct proc_dir_entry *goodix_proc_entry;
117 //static struct kobject *goodix_debug_kobj;
120 #define READ_COOR_ADDR 0x01
122 //*****************************End of Part I *********************************
124 //*************************Touchkey Surpport Part*****************************
125 //#define HAVE_TOUCH_KEY
126 #ifdef HAVE_TOUCH_KEY
127 #define READ_COOR_ADDR 0x00
128 const uint16_t touch_key_array[]={
133 #define MAX_KEY_NUM (sizeof(touch_key_array)/sizeof(touch_key_array[0]))
135 #define READ_COOR_ADDR 0x01
137 //*****************************End of Part II*********************************
139 //*************************Firmware Update part*******************************
140 #define CONFIG_TOUCHSCREEN_GOODIX_IAP
141 #ifdef CONFIG_TOUCHSCREEN_GOODIX_IAP
142 #define UPDATE_NEW_PROTOCOL
144 unsigned int oldcrc32 = 0xFFFFFFFF;
145 unsigned int crc32_table[256];
146 unsigned int ulPolynomial = 0x04c11db7;
147 unsigned char rd_cfg_addr;
148 unsigned char rd_cfg_len;
149 unsigned char g_enter_isp = 0;
151 static int goodix_update_write(struct file *filp, const char __user *buff, unsigned long len, void *data);
152 static int goodix_update_read( char *page, char **start, off_t off, int count, int *eof, void *data );
154 #define PACK_SIZE 64 //update file package size
155 #define MAX_TIMEOUT 60000 //update time out conut
156 #define MAX_I2C_RETRIES 20 //i2c retry times
161 #ifdef UPDATE_NEW_PROTOCOL
168 #define NEW_UPDATE_START 0x01
169 #define UPDATE_START 0x02
170 #define SLAVE_READY 0x08
171 #define UNKNOWN_ERROR 0x00
172 #define FRAME_ERROR 0x10
173 #define CHECKSUM_ERROR 0x20
174 #define TRANSLATE_ERROR 0x40
175 #define FLASH_ERROR 0X80
178 #define ERROR_NO_FILE 2 //ENOENT
179 #define ERROR_FILE_READ 23 //ENFILE
180 #define ERROR_FILE_TYPE 21 //EISDIR
181 #define ERROR_GPIO_REQUEST 4 //EINTR
182 #define ERROR_I2C_TRANSFER 5 //EIO
183 #define ERROR_NO_RESPONSE 16 //EBUSY
184 #define ERROR_TIMEOUT 110 //ETIMEDOUT
187 #define STEP_SET_PATH 1
188 #define STEP_CHECK_FILE 2
189 #define STEP_WRITE_SYN 3
190 #define STEP_WAIT_SYN 4
191 #define STEP_WRITE_LENGTH 5
192 #define STEP_WAIT_READY 6
193 #define STEP_WRITE_DATA 7
194 #define STEP_READ_STATUS 8
195 #define FUN_CLR_VAL 9
197 #define FUN_WRITE_CONFIG 11
200 #define CMD_DISABLE_TP 0
201 #define CMD_ENABLE_TP 1
202 #define CMD_READ_VER 2
203 #define CMD_READ_RAW 3
204 #define CMD_READ_DIF 4
205 #define CMD_READ_CFG 5
206 #define CMD_SYS_REBOOT 101
209 #define MODE_RD_VER 1
210 #define MODE_RD_RAW 2
211 #define MODE_RD_DIF 3
212 #define MODE_RD_CFG 4
216 //*****************************End of Part III********************************
218 struct goodix_i2c_platform_data {
219 uint32_t version; /* Use this entry for panels with */
223 #endif /* _LINUX_GOODIX_TOUCH_H */