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 default resolution of the touchscreen
30 #define TOUCH_MAX_HEIGHT 4096
31 #define TOUCH_MAX_WIDTH 4096
33 #define INT_PORT RK29_PIN0_PA2// S3C64XX_GPN(15) //Int IO port S3C64XX_GPL(10)
35 #define TS_INT gpio_to_irq(INT_PORT) //Interrupt Number,EINT18(119)
36 #define INT_CFG S3C_GPIO_SFN(3) //IO configer as EINT
41 //whether need send cfg?
42 //#define DRIVER_SEND_CFG
47 #define POLL_TIME 10 //actual query spacing interval:POLL_TIME+6
49 #define GOODIX_MULTI_TOUCH
50 #ifdef GOODIX_MULTI_TOUCH
51 #define MAX_FINGER_NUM 10
53 #define MAX_FINGER_NUM 1
56 //#define swap(x, y) do { typeof(x) z = x; x = y; y = z; } while (0)
58 struct goodix_ts_data {
61 struct i2c_client *client;
62 struct input_dev *input_dev;
63 int use_reset; //use RESET flag
64 int use_irq; //use EINT flag
65 int read_mode; //read moudle mode,20110221 by andrew
67 struct work_struct work;
70 struct early_suspend early_suspend;
71 int (*power)(struct goodix_ts_data * ts, int on);
74 uint8_t max_touch_num;
75 uint8_t int_trigger_type;
76 uint8_t green_wake_mode;
79 static const char *goodix_ts_name = "Goodix Capacitive TouchScreen";
80 static struct workqueue_struct *goodix_wq;
81 struct i2c_client * i2c_connect_client = NULL;
82 static struct proc_dir_entry *goodix_proc_entry;
83 static struct kobject *goodix_debug_kobj;
88 #ifdef CONFIG_HAS_EARLYSUSPEND
89 static void goodix_ts_early_suspend(struct early_suspend *h);
90 static void goodix_ts_late_resume(struct early_suspend *h);
93 //*****************************End of Part I *********************************
95 //*************************Touchkey Surpport Part*****************************
96 //#define HAVE_TOUCH_KEY
98 #define READ_COOR_ADDR 0x00
99 const uint16_t touch_key_array[]={
104 #define MAX_KEY_NUM (sizeof(touch_key_array)/sizeof(touch_key_array[0]))
106 #define READ_COOR_ADDR 0x01
108 //*****************************End of Part II*********************************
110 //*************************Firmware Update part*******************************
111 #define CONFIG_TOUCHSCREEN_GOODIX_IAP
112 #ifdef CONFIG_TOUCHSCREEN_GOODIX_IAP
113 #define UPDATE_NEW_PROTOCOL
115 unsigned int oldcrc32 = 0xFFFFFFFF;
116 unsigned int crc32_table[256];
117 unsigned int ulPolynomial = 0x04c11db7;
118 unsigned char rd_cfg_addr;
119 unsigned char rd_cfg_len;
120 unsigned char g_enter_isp = 0;
122 static int goodix_update_write(struct file *filp, const char __user *buff, unsigned long len, void *data);
123 static int goodix_update_read( char *page, char **start, off_t off, int count, int *eof, void *data );
125 #define PACK_SIZE 64 //update file package size
126 #define MAX_TIMEOUT 60000 //update time out conut
127 #define MAX_I2C_RETRIES 20 //i2c retry times
132 #ifdef UPDATE_NEW_PROTOCOL
139 #define NEW_UPDATE_START 0x01
140 #define UPDATE_START 0x02
141 #define SLAVE_READY 0x08
142 #define UNKNOWN_ERROR 0x00
143 #define FRAME_ERROR 0x10
144 #define CHECKSUM_ERROR 0x20
145 #define TRANSLATE_ERROR 0x40
146 #define FLASH_ERROR 0X80
149 #define ERROR_NO_FILE 2 //ENOENT
150 #define ERROR_FILE_READ 23 //ENFILE
151 #define ERROR_FILE_TYPE 21 //EISDIR
152 #define ERROR_GPIO_REQUEST 4 //EINTR
153 #define ERROR_I2C_TRANSFER 5 //EIO
154 #define ERROR_NO_RESPONSE 16 //EBUSY
155 #define ERROR_TIMEOUT 110 //ETIMEDOUT
158 #define STEP_SET_PATH 1
159 #define STEP_CHECK_FILE 2
160 #define STEP_WRITE_SYN 3
161 #define STEP_WAIT_SYN 4
162 #define STEP_WRITE_LENGTH 5
163 #define STEP_WAIT_READY 6
164 #define STEP_WRITE_DATA 7
165 #define STEP_READ_STATUS 8
166 #define FUN_CLR_VAL 9
168 #define FUN_WRITE_CONFIG 11
171 #define CMD_DISABLE_TP 0
172 #define CMD_ENABLE_TP 1
173 #define CMD_READ_VER 2
174 #define CMD_READ_RAW 3
175 #define CMD_READ_DIF 4
176 #define CMD_READ_CFG 5
177 #define CMD_SYS_REBOOT 101
180 #define MODE_RD_VER 1
181 #define MODE_RD_RAW 2
182 #define MODE_RD_DIF 3
183 #define MODE_RD_CFG 4
187 //*****************************End of Part III********************************
190 #endif /* _LINUX_GOODIX_TOUCH_H */