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/hrtimer.h>
22 #include <linux/i2c.h>
23 #include <linux/input.h>
25 #include "tp_suspend.h"
27 //*************************TouchScreen Work Part*****************************
29 #define GOODIX_I2C_NAME "Goodix-TS"
30 #define TS_MAX_X CONFIG_TOUCH_MAX_X
31 #define TS_MAX_Y CONFIG_TOUCH_MAX_Y
34 #define INT_PORT RK29_PIN0_PA2
36 #define TS_INT gpio_to_irq(INT_PORT)
37 // #define INT_CFG S3C_GPIO_SFN(2) //IO configer as EINT
42 //whether need send cfg?
43 //#define DRIVER_SEND_CFG
50 #define POLL_TIME 10 //actual query spacing interval:POLL_TIME+6
52 #define GOODIX_MULTI_TOUCH
53 #ifdef GOODIX_MULTI_TOUCH
54 #define MAX_FINGER_NUM 10
56 #define MAX_FINGER_NUM 1
59 //#define swap(x, y) do { typeof(x) z = x; x = y; y = z; } while (0)
69 struct i2c_client *client;
70 struct input_dev *input_dev;
76 int read_mode; //read moudle mode,20110221 by andrew
78 int (*power)(struct rk_ts_data * ts, int on);
79 int (*ts_init)(struct rk_ts_data*ts);
80 int (*input_parms_init)(struct rk_ts_data *ts);
81 void (*get_touch_info)(struct rk_ts_data *ts,char *point_num,struct rk_touch_info *info_buf); //get touch data info
84 uint8_t max_touch_num;
86 struct rk_touch_info *info_buf;
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 int (*power)(struct goodix_ts_data * ts, int on);
107 uint8_t max_touch_num;
108 uint8_t int_trigger_type;
112 static const char *rk_ts_name = "Goodix Capacitive TouchScreen";
113 struct i2c_client * i2c_connect_client = NULL;
114 #ifdef CONFIG_TOUCHSCREEN_GOODIX_IAP
115 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 */