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 GOODIX_1024X768 1
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)
64 u32 status; // 1:down,0:up
71 struct i2c_client *client;
72 struct input_dev *input_dev;
73 int use_reset; //use RESET flag
74 int use_irq; //use EINT flag
77 int read_mode; //read moudle mode,20110221 by andrew
79 struct workqueue_struct *ts_wq;
80 struct delayed_work ts_work;
83 struct early_suspend early_suspend;
84 int (*power)(struct rk_ts_data * ts, int on);
85 int (*ts_init)(struct rk_ts_data*ts);
86 int (*input_parms_init)(struct rk_ts_data *ts);
87 void (*get_touch_info)(struct rk_ts_data *ts,char *point_num,struct rk_touch_info *info_buf); //get touch data info
90 uint8_t max_touch_num;
91 uint8_t int_trigger_type;
97 struct goodix_ts_data {
100 struct i2c_client *client;
101 struct input_dev *input_dev;
102 int use_reset; //use RESET flag
103 int use_irq; //use EINT flag
104 int read_mode; //read moudle mode,20110221 by andrew
105 struct hrtimer timer;
106 struct delayed_work work;
109 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 static struct workqueue_struct *goodix_wq;
120 struct i2c_client * i2c_connect_client = NULL;
121 static struct proc_dir_entry *goodix_proc_entry;
122 //static struct kobject *goodix_debug_kobj;
124 #ifdef CONFIG_HAS_EARLYSUSPEND
125 static void goodix_ts_early_suspend(struct early_suspend *h);
126 static void goodix_ts_late_resume(struct early_suspend *h);
129 #define READ_COOR_ADDR 0x01
131 //*****************************End of Part I *********************************
133 //*************************Touchkey Surpport Part*****************************
134 //#define HAVE_TOUCH_KEY
135 #ifdef HAVE_TOUCH_KEY
136 #define READ_COOR_ADDR 0x00
137 const uint16_t touch_key_array[]={
142 #define MAX_KEY_NUM (sizeof(touch_key_array)/sizeof(touch_key_array[0]))
144 #define READ_COOR_ADDR 0x01
146 //*****************************End of Part II*********************************
148 //*************************Firmware Update part*******************************
149 #define CONFIG_TOUCHSCREEN_GOODIX_IAP
150 #ifdef CONFIG_TOUCHSCREEN_GOODIX_IAP
151 #define UPDATE_NEW_PROTOCOL
153 unsigned int oldcrc32 = 0xFFFFFFFF;
154 unsigned int crc32_table[256];
155 unsigned int ulPolynomial = 0x04c11db7;
156 unsigned char rd_cfg_addr;
157 unsigned char rd_cfg_len;
158 unsigned char g_enter_isp = 0;
160 static int goodix_update_write(struct file *filp, const char __user *buff, unsigned long len, void *data);
161 static int goodix_update_read( char *page, char **start, off_t off, int count, int *eof, void *data );
163 #define PACK_SIZE 64 //update file package size
164 #define MAX_TIMEOUT 60000 //update time out conut
165 #define MAX_I2C_RETRIES 20 //i2c retry times
170 #ifdef UPDATE_NEW_PROTOCOL
177 #define NEW_UPDATE_START 0x01
178 #define UPDATE_START 0x02
179 #define SLAVE_READY 0x08
180 #define UNKNOWN_ERROR 0x00
181 #define FRAME_ERROR 0x10
182 #define CHECKSUM_ERROR 0x20
183 #define TRANSLATE_ERROR 0x40
184 #define FLASH_ERROR 0X80
187 #define ERROR_NO_FILE 2 //ENOENT
188 #define ERROR_FILE_READ 23 //ENFILE
189 #define ERROR_FILE_TYPE 21 //EISDIR
190 #define ERROR_GPIO_REQUEST 4 //EINTR
191 #define ERROR_I2C_TRANSFER 5 //EIO
192 #define ERROR_NO_RESPONSE 16 //EBUSY
193 #define ERROR_TIMEOUT 110 //ETIMEDOUT
196 #define STEP_SET_PATH 1
197 #define STEP_CHECK_FILE 2
198 #define STEP_WRITE_SYN 3
199 #define STEP_WAIT_SYN 4
200 #define STEP_WRITE_LENGTH 5
201 #define STEP_WAIT_READY 6
202 #define STEP_WRITE_DATA 7
203 #define STEP_READ_STATUS 8
204 #define FUN_CLR_VAL 9
206 #define FUN_WRITE_CONFIG 11
209 #define CMD_DISABLE_TP 0
210 #define CMD_ENABLE_TP 1
211 #define CMD_READ_VER 2
212 #define CMD_READ_RAW 3
213 #define CMD_READ_DIF 4
214 #define CMD_READ_CFG 5
215 #define CMD_SYS_REBOOT 101
218 #define MODE_RD_VER 1
219 #define MODE_RD_RAW 2
220 #define MODE_RD_DIF 3
221 #define MODE_RD_CFG 4
225 //*****************************End of Part III********************************
227 struct goodix_i2c_platform_data {
228 uint32_t version; /* Use this entry for panels with */
232 #endif /* _LINUX_GOODIX_TOUCH_H */