-
Notifications
You must be signed in to change notification settings - Fork 0
/
nt36xxx.h
209 lines (179 loc) · 5.45 KB
/
nt36xxx.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/*
* Copyright (C) 2010 - 2017 Novatek, Inc.
* Copyright (C) 2019 XiaoMi, Inc.
*
* $Revision: 21600 $
* $Date: 2018-01-12 15:21:45 +0800 (週五, 12 一月 2018) $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*/
#ifndef _LINUX_NVT_TOUCH_H
#define _LINUX_NVT_TOUCH_H
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/pm_qos.h>
#include "nt36xxx_mem_map.h"
#define PINCTRL_STATE_ACTIVE "pmx_ts_active"
#define PINCTRL_STATE_SUSPEND "pmx_ts_suspend"
#define PINCTRL_STATE_RELEASE "pmx_ts_release"
#define NVT_COORDS_ARR_SIZE 2
#define NVT_DEBUG 0
/*---GPIO number---*/
#define NVTTOUCH_INT_PIN 943
/*---INT trigger mode---*/
/*#define IRQ_TYPE_EDGE_RISING 1*/
/*#define IRQ_TYPE_EDGE_FALLING 2*/
#define INT_TRIGGER_TYPE IRQ_TYPE_EDGE_RISING
/*---I2C driver info.---*/
#define NVT_I2C_NAME "NVT-ts"
#define I2C_BLDR_Address 0x01
#define I2C_FW_Address 0x01
#define I2C_HW_Address 0x62
#if NVT_DEBUG
#define NVT_LOG(fmt, args...) pr_err("[%s] %s %d: " fmt, NVT_I2C_NAME, __func__, __LINE__, ##args)
#else
#define NVT_LOG(fmt, args...) pr_info("[%s] %s %d: " fmt, NVT_I2C_NAME, __func__, __LINE__, ##args)
#endif
#define NVT_ERR(fmt, args...) pr_err("[%s] %s %d: " fmt, NVT_I2C_NAME, __func__, __LINE__, ##args)
/*---Input device info.---*/
#define NVT_TS_NAME "NVTCapacitiveTouchScreen"
/*---Touch info.---*/
#define TOUCH_DEFAULT_MAX_WIDTH 1080
#define TOUCH_DEFAULT_MAX_HEIGHT 2246
#define TOUCH_MAX_FINGER_NUM 10
#define TOUCH_KEY_NUM 0
#if TOUCH_KEY_NUM > 0
extern const uint16_t touch_key_array[TOUCH_KEY_NUM];
#endif
#define TOUCH_FORCE_NUM 1000
/*---Customerized func.---*/
#define NVT_TOUCH_PROC 1
#define NVT_TOUCH_EXT_PROC 1
#ifdef CONFIG_TOUCHSCREEN_NT36XXX_MPCTRL
#define NVT_TOUCH_MP 1
#else
#define NVT_TOUCH_MP 0
#endif
#define MT_PROTOCOL_B 1
#define WAKEUP_GESTURE 1
#if WAKEUP_GESTURE
extern const uint16_t gesture_key_array[];
#endif
#define BOOT_UPDATE_FIRMWARE 1
#define BOOT_UPDATE_FIRMWARE_NAME "novatek_nt36672_e10.fw"
#define NVT_LOCKDOWN_SIZE 8
struct nvt_config_info {
u8 tp_vendor;
u8 tp_color;
u8 tp_hw_version;
const char *nvt_cfg_name;
const char *nvt_limit_name;
};
struct nvt_ts_data {
struct i2c_client *client;
struct input_dev *input_dev;
struct delayed_work nvt_fwu_work;
struct regulator *vddio_reg;
struct regulator *lab_reg;
struct regulator *ibb_reg;
struct nvt_config_info *config_array;
struct attribute_group attrs;
struct proc_dir_entry *tp_selftest_proc;
struct dentry *debugfs;
struct pinctrl *ts_pinctrl;
struct pinctrl_state *pinctrl_state_active;
struct pinctrl_state *pinctrl_state_suspend;
const char *vddio_reg_name;
const char *lab_reg_name;
const char *ibb_reg_name;
const char *fw_name;
int result_type;
u8 lockdown_info[NVT_LOCKDOWN_SIZE];
uint16_t addr;
int8_t phys[32];
#if defined(CONFIG_DRM)
struct notifier_block notifier;
#endif
uint8_t fw_ver;
uint8_t x_num;
uint8_t y_num;
uint16_t abs_x_max;
uint16_t abs_y_max;
uint8_t max_touch_num;
uint8_t max_button_num;
uint32_t int_trigger_type;
int32_t irq_gpio;
uint32_t irq_flags;
int32_t reset_gpio;
uint32_t reset_flags;
int32_t reset_tddi;
struct mutex lock;
struct mutex mdata_lock;
const struct nvt_ts_mem_map *mmap;
uint8_t carrier_system;
uint16_t nvt_pid;
uint8_t xbuf[1025];
struct mutex xbuf_lock;
int gesture_enabled;
int glove_enabled;
int charger_enabled;
int stylus_enabled;
int cover_enabled;
int grip_enabled;
size_t config_array_size;
int current_index;
bool dev_pm_suspend;
struct completion dev_pm_suspend_completion;
struct work_struct resume_work;
struct workqueue_struct *event_wq;
struct pm_qos_request pm_qos_req;
struct proc_dir_entry *input_proc;
};
struct nvt_mode_switch {
struct nvt_ts_data *nvt_data;
unsigned char mode;
struct work_struct switch_mode_work;
};
#if NVT_TOUCH_PROC
struct nvt_flash_data {
rwlock_t lock;
struct i2c_client *client;
};
#endif
typedef enum {
RESET_STATE_INIT = 0xA0,/* IC reset */
RESET_STATE_REK, /* ReK baseline */
RESET_STATE_REK_FINISH, /* baseline is ready */
RESET_STATE_NORMAL_RUN, /* normal run */
RESET_STATE_MAX = 0xAF
} RST_COMPLETE_STATE;
typedef enum {
EVENT_MAP_HOST_CMD = 0x50,
EVENT_MAP_HANDSHAKING_or_SUB_CMD_BYTE = 0x51,
EVENT_MAP_RESET_COMPLETE = 0x60,
EVENT_MAP_FWINFO = 0x78,
EVENT_MAP_PROJECTID = 0x9A,
} I2C_EVENT_MAP;
/*---extern structures---*/
extern struct nvt_ts_data *ts;
/*---extern functions---*/
extern int32_t CTP_I2C_READ(struct i2c_client *client, uint16_t address, uint8_t *buf, uint16_t len);
extern int32_t CTP_I2C_WRITE(struct i2c_client *client, uint16_t address, uint8_t *buf, uint16_t len);
extern int nvt_bootloader_reset(void);
extern void nvt_sw_reset_idle(void);
extern int32_t nvt_check_fw_reset_state(RST_COMPLETE_STATE check_reset_state);
extern int32_t nvt_get_fw_info(void);
extern int32_t nvt_clear_fw_status(void);
extern int32_t nvt_check_fw_status(void);
extern void nvt_stop_crc_reboot(void);
extern int32_t nvt_get_lockdown_info(char *lockdata);
#endif /* _LINUX_NVT_TOUCH_H */