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