input: touchscreen: add touch screen of gslx680 for rk3399-firefly-edp
[firefly-linux-kernel-4.4.55.git] / drivers / input / touchscreen / sitronix_ts_a720.h
1 /*
2  * drivers/input/touchscreen/sitronix_i2c_touch.h
3  *
4  * Touchscreen driver for Sitronix
5  *
6  * Copyright (C) 2011 Sitronix Technology Co., Ltd.
7  *      Rudy Huang <rudy_huang@sitronix.com.tw>
8  */
9 /*
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU General Public License as published by the Free
12  * Software Foundation; either version 2 of the License, or (at your option)
13  * any later version.
14  */
15
16 #ifndef __SITRONIX_I2C_TOUCH_h
17 #define __SITRONIX_I2C_TOUCH_h
18
19 #include <linux/ioctl.h> /* needed for the _IOW etc stuff used later */
20
21 #define SITRONIX_TOUCH_DRIVER_VERSION 0x03
22 #define SITRONIX_MAX_SUPPORTED_POINT 5
23 #define SITRONIX_I2C_TOUCH_DRV_NAME "sitronix"
24 #define SITRONIX_I2C_TOUCH_DEV_NAME "sitronixDev"
25
26 //#define SITRONIX_WAKE_UP_TOUCH_BY_INT
27
28 //#define SITRONIX_MONITOR_THREAD
29 #define DELAY_MONITOR_THREAD_START_PROBE 10000
30 #define DELAY_MONITOR_THREAD_START_RESUME 3000
31 #define SITRONIX_FW_UPGRADE_FEATURE
32 #define SITRONIX_LEVEL_TRIGGERED
33 // When enable_irq() is invoked, irq will be sent once while INT is not triggered if CONFIG_HARDIRQS_SW_RESEND is set.
34 // This behavior is implemented by linux kernel, it is used to prevent irq from losting when irq is edge-triggered mode.
35 #ifndef SITRONIX_LEVEL_TRIGGERED
36 #define SITRONIX_INT_POLLING_MODE
37 #define INT_POLLING_MODE_INTERVAL 14
38 #endif // SITRONIX_LEVEL_TRIGGERED
39 #define SITRONIX_FINGER_COUNT_REG_ENABLE
40
41 //#define EnableDbgMsg 0
42 //#define EnableUpgradeMsg 1
43
44 #ifdef EnableDbgMsg
45 #define DbgMsg(arg...) printk(arg)
46 #else
47 #define DbgMsg(arg...)
48 #endif
49
50 #ifdef EnableUpgradeMsg
51 #define UpgradeMsg(arg...) printk(arg)
52 #else
53 #define UpgradeMsg(arg...)
54 #endif
55
56 typedef enum{
57         FIRMWARE_VERSION,
58         STATUS_REG,
59         DEVICE_CONTROL_REG,
60         TIMEOUT_TO_IDLE_REG,
61         XY_RESOLUTION_HIGH,
62         X_RESOLUTION_LOW,
63         Y_RESOLUTION_LOW,
64         FIRMWARE_REVISION_3 = 0x0C,
65         FIRMWARE_REVISION_2,
66         FIRMWARE_REVISION_1,
67         FIRMWARE_REVISION_0,
68         FINGERS,
69         KEYS_REG,
70         XY0_COORD_H,
71         X0_COORD_L,
72         Y0_COORD_L,
73         I2C_PROTOCOL = 0x3E,
74         MAX_NUM_TOUCHES,
75         DATA_0_HIGH,
76         DATA_0_LOW,
77
78         PAGE_REG = 0xff,
79 }RegisterOffset;
80
81 #define SITRONIX_TS_CHANGE_MODE_DELAY 150
82
83 typedef enum{
84         XY_COORD_H,
85         X_COORD_L,
86         Y_COORD_L,
87         PIXEL_DATA_LENGTH_B,
88         PIXEL_DATA_LENGTH_A,
89 }PIXEL_DATA_FORMAT;
90
91 #define X_RES_H_SHFT 4
92 #define X_RES_H_BMSK 0xf
93 #define Y_RES_H_SHFT 0
94 #define Y_RES_H_BMSK 0xf
95 #define FINGERS_SHFT 0
96 #define FINGERS_BMSK 0xf
97 #define X_COORD_VALID_SHFT 7
98 #define X_COORD_VALID_BMSK 0x1
99 #define X_COORD_H_SHFT 4
100 #define X_COORD_H_BMSK 0x7
101 #define Y_COORD_H_SHFT 0
102 #define Y_COORD_H_BMSK 0x7
103
104 typedef enum{
105         SITRONIX_A_TYPE = 1,
106         SITRONIX_B_TYPE,
107 }I2C_PROTOCOL_TYPE;
108
109 #define I2C_PROTOCOL_SHFT 0x0
110 #define I2C_PROTOCOL_BMSK 0x3
111
112 #define SMT_IOC_MAGIC   0xf1
113
114 enum{
115         SMT_GET_DRIVER_REVISION = 1,
116         SMT_GET_FW_REVISION,
117         SMT_ENABLE_IRQ,
118         SMT_DISABLE_IRQ,
119         SMT_RESUME,
120         SMT_SUSPEND,
121         SMT_HW_RESET,
122         SMT_IOC_MAXNR,
123 };
124
125 #define IOCTL_SMT_GET_DRIVER_REVISION                           _IOC(_IOC_READ,  SMT_IOC_MAGIC, SMT_GET_DRIVER_REVISION,                        1)
126 #define IOCTL_SMT_GET_FW_REVISION                                       _IOC(_IOC_READ,  SMT_IOC_MAGIC, SMT_GET_FW_REVISION,                            4)
127 #define IOCTL_SMT_ENABLE_IRQ                                    _IOC(_IOC_NONE, SMT_IOC_MAGIC, SMT_ENABLE_IRQ, 0)
128 #define IOCTL_SMT_DISABLE_IRQ                                   _IOC(_IOC_NONE, SMT_IOC_MAGIC, SMT_DISABLE_IRQ, 0)
129 #define IOCTL_SMT_RESUME                                        _IOC(_IOC_NONE, SMT_IOC_MAGIC, SMT_RESUME, 0)
130 #define IOCTL_SMT_SUSPEND                                       _IOC(_IOC_NONE, SMT_IOC_MAGIC, SMT_SUSPEND, 0)
131 #define IOCTL_SMT_HW_RESET                                      _IOC(_IOC_NONE, SMT_IOC_MAGIC, SMT_HW_RESET, 0)
132
133 #define SITRONIX_SENSOR_KEY
134 //#define SITRONIX_TOUCH_KEY
135 //#define SITRONIX_KEY_BOUNDARY_MANUAL_SPECIFY
136
137 typedef struct _tag_MTD_STRUCTURE{
138         u16 Pixel_X;
139         u16 Pixel_Y;
140         u8 First_Pressed_area; /* 0: no press; 1: display; 2: touch key */
141         u8 Current_Pressed_area; /* 0: no press; 1: display; 2: touch key */
142         unsigned int First_key_index; 
143         unsigned int Current_key_index; 
144 }MTD_STRUCTURE, *PMTD_STRUCTURE;
145
146 #ifndef SITRONIX_TOUCH_KEY
147 enum{
148         AREA_NONE,
149         AREA_DISPLAY,
150 };
151 #else
152 enum{
153         AREA_NONE,
154         AREA_DISPLAY,
155         AREA_KEY,
156         AREA_INVALID,
157 };
158
159 struct sitronix_AA_key{
160         int x_low;
161         int x_high;
162         int y_low;
163         int y_high;
164         unsigned int code;
165 };
166 #endif // SITRONIX_TOUCH_KEY
167
168 struct sitronix_i2c_touch_platform_data {
169         uint32_t version;       /* Use this entry for panels with */
170                                 /* (major << 8 | minor) version or above. */
171                                 /* If non-zero another array entry follows */
172         void (*reset_ic)(void);
173 };
174
175 #endif // __SITRONIX_I2C_TOUCH_h