input: touchscreen: add touch screen of gslx680 for rk3399-firefly-edp
[firefly-linux-kernel-4.4.55.git] / drivers / input / touchscreen / vtl_ts / vtl_ts.h
1 #ifndef _TS_CORE_H_ \r
2 #define _TS_CORE_H_ \r
3 \r
4 #include <linux/gpio.h>\r
5 #ifdef CONFIG_HAS_EARLYSUSPEND\r
6 #include <linux/earlysuspend.h>\r
7 #endif\r
8 #include "../tp_suspend.h"\r
9 \r
10 \r
11 /*vtl touch IC define*/\r
12 #define CT36X                   0x01//(CT36X:ct362,ct363,ct365)\r
13 #define CT360                   0x02//(CT360:ct360)\r
14 \r
15 /*xy data protocol*/\r
16 #define OLD_PROTOCOL            0x01\r
17 #define NEW_PROTOCOL            0x02\r
18 \r
19 \r
20 /***********************vtl ts driver config ******************************************/\r
21 \r
22 /*vtl chip ID*/\r
23 #define CHIP_ID                 CT36X//CT360//\r
24 \r
25 #define XY_DATA_PROTOCOL        NEW_PROTOCOL//OLD_PROTOCOL//\r
26 \r
27 #define TS_I2C_SPEED            400000      //for rockchip\r
28 /*\r
29 #if(TB1_USE_F402)\r
30 #define         XY_SWAP_ENABLE          1\r
31 #else\r
32 #define         XY_SWAP_ENABLE          0\r
33 #endif\r
34 \r
35 #define         X_REVERSE_ENABLE        0\r
36 \r
37 #if(TB1_USE_F402)\r
38 #define         Y_REVERSE_ENABLE        0\r
39 #else\r
40 #define         Y_REVERSE_ENABLE        1\r
41 #endif\r
42 */\r
43 \r
44 #define         CHIP_UPDATE_ENABLE      1\r
45 \r
46 #define         DEBUG_ENABLE            0\r
47 \r
48 \r
49 /***********************vtl ts driver config  end******************************************/\r
50 \r
51 \r
52 \r
53 \r
54 \r
55 \r
56 \r
57 \r
58 \r
59 \r
60 \r
61 \r
62 \r
63 \r
64 \r
65 \r
66 \r
67 \r
68 \r
69 \r
70 \r
71 \r
72 \r
73 \r
74 \r
75 \r
76 \r
77 \r
78 \r
79 \r
80 /*vtl ts driver name*/\r
81 #define DRIVER_NAME             "vtl_ts"\r
82 //#define DEBUG_ENABLE  1\r
83 #if(DEBUG_ENABLE)\r
84 #define         DEBUG()                         printk("___%s___\n",__func__);\r
85 //#define       XY_DEBUG(id,status,x,y)         printk("id = %d,status = %d,X = %d,Y = %d\n",id,status,x,y);\r
86 #else   \r
87 #define         DEBUG()\r
88 //#define       XY_DEBUG(id,status,x,y)\r
89 #endif\r
90 \r
91 /*TOUCH_POINT_NUM define*/\r
92 #if(CHIP_ID == CT360)\r
93 #define TOUCH_POINT_NUM         5\r
94 #elif(CHIP_ID == CT36X)\r
95 #define TOUCH_POINT_NUM         10\r
96 #endif\r
97 \r
98 /*priate define and declare*/\r
99 #if(CHIP_ID == CT360)\r
100 struct xy_data {\r
101         #if(XY_DATA_PROTOCOL == OLD_PROTOCOL)\r
102         unsigned char   status : 4;             // Action information, 1: Down; 2: Move; 3: Up\r
103         unsigned char   id : 4;                 // ID information, from 1 to CFG_MAX_POINT_NUM\r
104         #endif\r
105         unsigned char   xhi;                    // X coordinate Hi\r
106         unsigned char   yhi;                    // Y coordinate Hi\r
107         unsigned char   ylo : 4;                // Y coordinate Lo\r
108         unsigned char   xlo : 4;                // X coordinate Lo\r
109         #if(XY_DATA_PROTOCOL == NEW_PROTOCOL)\r
110         unsigned char   status : 4;             // Action information, 1: Down; 2: Move; 3: Up\r
111         unsigned char   id : 4;                 // ID information, from 1 to CFG_MAX_POINT_NUM\r
112         #endif\r
113 };\r
114 #else\r
115 struct xy_data {\r
116         #if(XY_DATA_PROTOCOL == OLD_PROTOCOL)\r
117         unsigned char   status : 3;             // Action information, 1: Down; 2: Move; 3: Up\r
118         unsigned char   id : 5;                 // ID information, from 1 to CFG_MAX_POINT_NUM\r
119         #endif\r
120         unsigned char   xhi;                    // X coordinate Hi\r
121         unsigned char   yhi;                    // Y coordinate Hi\r
122         unsigned char   ylo : 4;                // Y coordinate Lo\r
123         unsigned char   xlo : 4;                // X coordinate Lo\r
124         #if(XY_DATA_PROTOCOL == NEW_PROTOCOL)\r
125         unsigned char   status : 3;             // Action information, 1: Down; 2: Move; 3: Up\r
126         unsigned char   id : 5;                 // ID information, from 1 to CFG_MAX_POINT_NUM\r
127         #endif\r
128         unsigned char   area;                   // Touch area\r
129         unsigned char   pressure;               // Touch Pressure\r
130 };\r
131 #endif\r
132 \r
133 \r
134 union ts_xy_data {\r
135         struct xy_data  point[TOUCH_POINT_NUM];\r
136         unsigned char   buf[TOUCH_POINT_NUM * sizeof(struct xy_data)];\r
137 };\r
138 \r
139 \r
140 struct ts_driver{\r
141 \r
142         struct i2c_client               *client;\r
143 \r
144         /* input devices */\r
145         struct input_dev                *input_dev;                     \r
146 \r
147         struct proc_dir_entry           *proc_entry;    \r
148 \r
149         struct task_struct              *ts_thread;\r
150 \r
151         //#ifdef CONFIG_HAS_EARLYSUSPEND\r
152         //struct early_suspend          early_suspend;\r
153         //#endif\r
154 };\r
155 \r
156 struct ts_config_info{      \r
157         \r
158         unsigned int    screen_max_x;\r
159         unsigned int    screen_max_y;\r
160         unsigned int    xy_swap;\r
161         unsigned int    x_reverse;\r
162         unsigned int    y_reverse;\r
163         unsigned int    x_mul;\r
164         unsigned int    y_mul;\r
165                 unsigned int    bin_ver;\r
166         unsigned int    irq_gpio_number;\r
167         unsigned int    irq_number;\r
168         unsigned int    rst_gpio_number;\r
169         unsigned char   touch_point_number;\r
170         unsigned char   ctp_used;\r
171         //unsigned char i2c_bus_number;\r
172         //unsigned char revert_x_flag;\r
173         //unsigned char revert_y_flag;\r
174         //unsigned char exchange_x_y_flag;                  \r
175 };\r
176 \r
177 struct  ts_info{\r
178         \r
179         struct ts_driver        *driver;\r
180         struct ts_config_info   config_info;\r
181         union ts_xy_data        xy_data;\r
182         unsigned char           debug;\r
183         struct  tp_device  tp;\r
184 };\r
185 \r
186 \r
187 //extern struct ts_info *pg_ts;\r
188 extern struct ts_info * vtl_ts_get_object(void);\r
189 extern void vtl_ts_hw_reset(void);\r
190 \r
191 #endif\r
192 \r