newton: update board defconfig file to enable FT5406 and Goodix GT819 touch panel
[firefly-linux-kernel-4.4.55.git] / drivers / input / touchscreen / goodix_touch_newton.h
1 /*
2  * include/linux/goodix_touch.h
3  *
4  * Copyright (C) 2010 - 2011 Goodix, Inc.
5  * 
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.
10  *
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
14  * more details.
15  *
16  */
17
18 #ifndef         _LINUX_GOODIX_TOUCH_H
19 #define         _LINUX_GOODIX_TOUCH_H
20
21 #include <linux/earlysuspend.h>
22 #include <linux/hrtimer.h>
23 #include <linux/i2c.h>
24 #include <linux/input.h>
25
26 //*************************TouchScreen Work Part*****************************
27
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
32
33 #define INT_PORT RK29_PIN0_PA2//            S3C64XX_GPN(15)                                             //Int IO port  S3C64XX_GPL(10)
34 #ifdef INT_PORT
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
37 #else
38         #define TS_INT  0
39 #endif  
40
41 //whether need send cfg?
42 //#define DRIVER_SEND_CFG
43
44 //set trigger mode
45 #define INT_TRIGGER                     0
46
47 #define POLL_TIME               10      //actual query spacing interval:POLL_TIME+6
48
49 #define GOODIX_MULTI_TOUCH
50 #ifdef GOODIX_MULTI_TOUCH
51         #define MAX_FINGER_NUM  10      
52 #else
53         #define MAX_FINGER_NUM  1       
54 #endif
55
56 //#define swap(x, y) do { typeof(x) z = x; x = y; y = z; } while (0)
57
58 struct goodix_ts_data {
59         uint16_t addr;
60         uint8_t bad_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
66         struct hrtimer timer;
67         struct work_struct  work;
68         char phys[32];
69         int retry;
70         struct early_suspend early_suspend;
71         int (*power)(struct goodix_ts_data * ts, int on);
72         uint16_t abs_x_max;
73         uint16_t abs_y_max;
74         uint8_t max_touch_num;
75         uint8_t int_trigger_type;
76         uint8_t green_wake_mode;
77 };
78
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;
84 int ts_irq = 0;
85 int int_gpio = 0;
86
87         
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);
91 #endif 
92
93 //*****************************End of Part I *********************************
94
95 //*************************Touchkey Surpport Part*****************************
96 //#define HAVE_TOUCH_KEY
97 #ifdef HAVE_TOUCH_KEY
98         #define READ_COOR_ADDR 0x00
99         const uint16_t touch_key_array[]={
100                                                                           KEY_MENU,                             //MENU
101                                                                           KEY_HOME,                             //HOME
102                                                                           KEY_SEND                              //CALL
103                                                                          }; 
104         #define MAX_KEY_NUM      (sizeof(touch_key_array)/sizeof(touch_key_array[0]))
105 #else
106         #define READ_COOR_ADDR 0x01
107 #endif
108 //*****************************End of Part II*********************************
109
110 //*************************Firmware Update part*******************************
111 #define CONFIG_TOUCHSCREEN_GOODIX_IAP
112 #ifdef CONFIG_TOUCHSCREEN_GOODIX_IAP
113 #define UPDATE_NEW_PROTOCOL
114
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;
121
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 );
124
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
128
129 //I2C buf address
130 #define ADDR_CMD                                        80
131 #define ADDR_STA                                        81
132 #ifdef UPDATE_NEW_PROTOCOL
133         #define ADDR_DAT                                0
134 #else
135         #define ADDR_DAT                                82
136 #endif
137
138 //moudle state
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
147
148 //error no
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
156
157 //update steps
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
167 #define FUN_CMD                    10
168 #define FUN_WRITE_CONFIG           11
169
170 //fun cmd
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
178
179 //read mode
180 #define MODE_RD_VER                1
181 #define MODE_RD_RAW                2
182 #define MODE_RD_DIF                3
183 #define MODE_RD_CFG                4
184
185
186 #endif
187 //*****************************End of Part III********************************
188
189
190 #endif /* _LINUX_GOODIX_TOUCH_H */