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)
70 struct i2c_client *client;
71 struct input_dev *input_dev;
76 int read_mode; //read moudle mode,20110221 by andrew
78 struct workqueue_struct *ts_wq;
79 struct delayed_work ts_work;
81 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;
94 struct goodix_ts_data {
97 struct i2c_client *client;
98 struct input_dev *input_dev;
99 int use_reset; //use RESET flag
100 int use_irq; //use EINT flag
101 int read_mode; //read moudle mode,20110221 by andrew
102 struct hrtimer timer;
103 struct delayed_work work;
106 struct early_suspend early_suspend;
107 int (*power)(struct goodix_ts_data * ts, int on);
110 uint8_t max_touch_num;
111 uint8_t int_trigger_type;
115 static const char *rk_ts_name = "Goodix Capacitive TouchScreen";
116 static struct workqueue_struct *goodix_wq;
117 struct i2c_client * i2c_connect_client = NULL;
118 static struct proc_dir_entry *goodix_proc_entry;
119 //static struct kobject *goodix_debug_kobj;
122 #define READ_COOR_ADDR 0x01
124 //*****************************End of Part I *********************************
126 //*************************Touchkey Surpport Part*****************************
127 //#define HAVE_TOUCH_KEY
128 #ifdef HAVE_TOUCH_KEY
129 #define READ_COOR_ADDR 0x00
130 const uint16_t touch_key_array[]={
135 #define MAX_KEY_NUM (sizeof(touch_key_array)/sizeof(touch_key_array[0]))
137 #define READ_COOR_ADDR 0x01
139 //*****************************End of Part II*********************************
141 //*************************Firmware Update part*******************************
142 #define CONFIG_TOUCHSCREEN_GOODIX_IAP
143 #ifdef CONFIG_TOUCHSCREEN_GOODIX_IAP
144 #define UPDATE_NEW_PROTOCOL
146 unsigned int oldcrc32 = 0xFFFFFFFF;
147 unsigned int crc32_table[256];
148 unsigned int ulPolynomial = 0x04c11db7;
149 unsigned char rd_cfg_addr;
150 unsigned char rd_cfg_len;
151 unsigned char g_enter_isp = 0;
153 static int goodix_update_write(struct file *filp, const char __user *buff, unsigned long len, void *data);
154 static int goodix_update_read( char *page, char **start, off_t off, int count, int *eof, void *data );
156 #define PACK_SIZE 64 //update file package size
157 #define MAX_TIMEOUT 60000 //update time out conut
158 #define MAX_I2C_RETRIES 20 //i2c retry times
163 #ifdef UPDATE_NEW_PROTOCOL
170 #define NEW_UPDATE_START 0x01
171 #define UPDATE_START 0x02
172 #define SLAVE_READY 0x08
173 #define UNKNOWN_ERROR 0x00
174 #define FRAME_ERROR 0x10
175 #define CHECKSUM_ERROR 0x20
176 #define TRANSLATE_ERROR 0x40
177 #define FLASH_ERROR 0X80
180 #define ERROR_NO_FILE 2 //ENOENT
181 #define ERROR_FILE_READ 23 //ENFILE
182 #define ERROR_FILE_TYPE 21 //EISDIR
183 #define ERROR_GPIO_REQUEST 4 //EINTR
184 #define ERROR_I2C_TRANSFER 5 //EIO
185 #define ERROR_NO_RESPONSE 16 //EBUSY
186 #define ERROR_TIMEOUT 110 //ETIMEDOUT
189 #define STEP_SET_PATH 1
190 #define STEP_CHECK_FILE 2
191 #define STEP_WRITE_SYN 3
192 #define STEP_WAIT_SYN 4
193 #define STEP_WRITE_LENGTH 5
194 #define STEP_WAIT_READY 6
195 #define STEP_WRITE_DATA 7
196 #define STEP_READ_STATUS 8
197 #define FUN_CLR_VAL 9
199 #define FUN_WRITE_CONFIG 11
202 #define CMD_DISABLE_TP 0
203 #define CMD_ENABLE_TP 1
204 #define CMD_READ_VER 2
205 #define CMD_READ_RAW 3
206 #define CMD_READ_DIF 4
207 #define CMD_READ_CFG 5
208 #define CMD_SYS_REBOOT 101
211 #define MODE_RD_VER 1
212 #define MODE_RD_RAW 2
213 #define MODE_RD_DIF 3
214 #define MODE_RD_CFG 4
218 //*****************************End of Part III********************************
220 struct goodix_i2c_platform_data {
221 uint32_t version; /* Use this entry for panels with */
225 #endif /* _LINUX_GOODIX_TOUCH_H */