1 /*
2 * cyttsp5_regs.h
3 * Parade TrueTouch(TM) Standard Product V5 Registers.
4 * For use with Parade touchscreen controllers.
5 * Supported parts include:
6 * CYTMA5XX
7 * CYTMA448
8 * CYTMA445A
9 * CYTT21XXX
10 * CYTT31XXX
11 *
12 * Copyright (C) 2015 Parade Technologies
13 * Copyright (C) 2012-2015 Cypress Semiconductor
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * version 2, and only version 2, as published by the
18 * Free Software Foundation.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * Contact Parade Technologies at www.paradetech.com <ttdrivers@paradetech.com>
26 *
27 */
28
29 #ifndef _CYTTSP5_REGS_H
30 #define _CYTTSP5_REGS_H
31
32 #include <linux/device.h>
33 #ifdef CONFIG_HAS_EARLYSUSPEND
34 #include <linux/earlysuspend.h>
35 #elif defined(CONFIG_FB)
36 #include <linux/notifier.h>
37 #include <linux/fb.h>
38 #endif
39 #include <asm/unaligned.h>
40 #include <linux/debugfs.h>
41 #include <linux/delay.h>
42 #include <linux/err.h>
43 #include <linux/gpio.h>
44 #include <linux/hid.h>
45 #include <linux/input.h>
46 #include <linux/interrupt.h>
47 #include <linux/irq.h>
48 #include <linux/kernel.h>
49 #include <linux/limits.h>
50 #include <linux/module.h>
51 #include <linux/of_device.h>
52 #include <linux/of.h>
53 #include <linux/pm_runtime.h>
54 #include <linux/sched.h>
55 #include <linux/slab.h>
56 #include <linux/suspend.h>
57 #include <linux/stringify.h>
58 #include <linux/types.h>
59 #include <linux/uaccess.h>
60 #include <linux/workqueue.h>
61 #include <linux/version.h>
62 #include <linux/i2c.h>
63 #include <linux/timer.h>
64 #include <linux/timex.h>
65 #include <linux/rtc.h>
66 #include "../tp_suspend.h"
67 #include "cyttsp5_core.h"
68
69 //2019-03-22
70 //this may cause system hang on mod_timer_pending during call cyttsp5_parse_input,
71 //maybe there are some troubles when working on linux 4.19.
72 //#define CYTTSP_WATCHDOG_DELAY_ENBALE
73
74 /* #define EASYWAKE_TSG6 */
75 //2018-12-19 ttconfig upgrade
76 #define CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP5_PLATFORM_TTCONFIG_UPGRADE
77
78 #define CY_FW_FILE_PREFIX "cyttsp5_fw"
79 #define CY_FW_FILE_SUFFIX ".bin"
80 #define CY_FW_FILE_NAME "cyttsp5_fw.bin"
81
82 #ifdef TTHE_TUNER_SUPPORT
83 #define CYTTSP5_TTHE_TUNER_FILE_NAME "tthe_tuner"
84 #endif
85
86 #define CY_MAX_PRBUF_SIZE PIPE_BUF
87 #define CY_PR_TRUNCATED " truncated..."
88
89 #define CY_DEFAULT_CORE_ID "cyttsp5_core0"
90 #define CY_MAX_NUM_CORE_DEVS 5
91 #define CY_IRQ_ASSERTED_VALUE 0
92
93
94 #ifdef CY_ENABLE_MAX_ELEN
95 #define CY_MAX_ELEN 100
96 #endif
97
98 enum PARADE_DEBUG_LEVEL {
99 DEBUG_LEVEL_0,/*no debug info*/
100 DEBUG_LEVEL_1,/*only print dev_dbg info*/
101 DEBUG_LEVEL_2,/*print dev_dbg and dev_vdbg info*/
102 DEBUG_LEVEL_NUM
103 };
104
105 #define CY_INITIAL_DEBUG_LEVEL 0
106 #define CY_INITIAL_SHOW_TIME_STAMP 0
107
108 /*
109 * those current debug level smaller than setted debug level
110 * will be printed out
111 */
112 #define parade_debug(dev, dlevel, format, arg...) \
113 do { \
114 struct cyttsp5_core_data *cd_tmp = dev_get_drvdata(dev);\
115 if (cd_tmp->debug_level >= dlevel) {\
116 dev_info(dev, format, ##arg);\
117 } \
118 } while (0)
119
120 /* HID */
121 #define HID_CYVENDOR 0xff010000
122 #define CY_HID_VENDOR_ID 0x04B4
123 #define CY_HID_BL_PRODUCT_ID 0xC100
124 #define CY_HID_APP_PRODUCT_ID 0xC101
125 #define CY_HID_VERSION 0x0100
126 #define CY_HID_APP_REPORT_ID 0xF7
127 #define CY_HID_BL_REPORT_ID 0xFF
128
129 #define HID_INVALID_REPORT_ID 0x0
130 #define HID_TOUCH_REPORT_ID 0x1
131 #define HID_BTN_REPORT_ID 0x3
132 #define HID_WAKEUP_REPORT_ID 0x4
133 #define HID_NOISE_METRIC_REPORT_ID 0x5
134 #define HID_TRACKING_HEATMAP_REPOR_ID 0xE
135 #define HID_SENSOR_DATA_REPORT_ID 0xF
136 #define HID_APP_RESPONSE_REPORT_ID 0x1F
137 #define HID_APP_OUTPUT_REPORT_ID 0x2F
138 #define HID_BL_RESPONSE_REPORT_ID 0x30
139 #define HID_BL_OUTPUT_REPORT_ID 0x40
140 #define HID_RESPONSE_REPORT_ID 0xF0
141
142 #define HID_OUTPUT_RESPONSE_REPORT_OFFSET 2
143 #define HID_OUTPUT_RESPONSE_CMD_OFFSET 4
144 #define HID_OUTPUT_RESPONSE_CMD_MASK 0x7F
145 #define HID_OUTPUT_CMD_OFFSET 6
146 #define HID_OUTPUT_CMD_MASK 0x7F
147
148 #define HID_SYSINFO_CYDATA_OFFSET 5
149 #define HID_SYSINFO_SENSING_OFFSET 33
150 #define HID_SYSINFO_BTN_OFFSET 48
151 #define HID_SYSINFO_BTN_MASK 0xFF
152 #define HID_SYSINFO_MAX_BTN 8
153
154 #define HID_POWER_ON 0x0
155 #define HID_POWER_SLEEP 0x1
156 #define HID_LENGTH_BYTES 2
157 #define HID_LENGTH_AND_REPORT_ID_BYTES 3
158
159 /* Timeout in ms */
160 #define CY_REQUEST_EXCLUSIVE_TIMEOUT 8000
161 #define CY_WATCHDOG_TIMEOUT 1000
162 #define CY_HID_RESET_TIMEOUT 5000
163 #define CY_HID_AUTO_CALI_CPLT_TIMEOUT 2500
164 /* HID_DESCRIPTOR_TIMEOUT value based on FW spec (CAL_OS) */
165 #define CY_HID_GET_HID_DESCRIPTOR_TIMEOUT 4000
166 #define CY_HID_GET_REPORT_DESCRIPTOR_TIMEOUT 500
167 #define CY_HID_SET_POWER_TIMEOUT 500
168 #ifdef VERBOSE_DEBUG
169 #define CY_HID_OUTPUT_TIMEOUT 2000
170 #else
171 #define CY_HID_OUTPUT_TIMEOUT 200
172 #endif
173 #define CY_HID_OUTPUT_START_BOOTLOADER_TIMEOUT 2000
174 #define CY_HID_OUTPUT_USER_TIMEOUT 8000
175 #define CY_HID_OUTPUT_GET_SYSINFO_TIMEOUT 3000
176 #define CY_HID_OUTPUT_CALIBRATE_IDAC_TIMEOUT 5000
177 #define CY_HID_OUTPUT_WRITE_CONF_BLOCK_TIMEOUT 400
178 #define CY_HID_OUTPUT_RUN_SELF_TEST_TIMEOUT 10000
179 #define CY_HID_OUTPUT_BL_INITIATE_BL_TIMEOUT 20000
180 #define CY_HID_OUTPUT_BL_PROGRAM_AND_VERIFY_TIMEOUT 400
181
182 #define CY_WATCHDOG_RETRY_COUNT 60
183
184 /* maximum number of concurrent tracks */
185 #define TOUCH_REPORT_SIZE 10
186 #define TOUCH_INPUT_HEADER_SIZE 7
187 #define TOUCH_COUNT_BYTE_OFFSET 5
188 #define BTN_REPORT_SIZE 9
189 #define BTN_INPUT_HEADER_SIZE 5
190 #define SENSOR_REPORT_SIZE 150
191 #define SENSOR_HEADER_SIZE 4
192
193 /* helpers */
194 #define GET_NUM_TOUCHES(x) ((x) & 0x1F)
195 #define IS_LARGE_AREA(x) ((x) & 0x20)
196 #define IS_BAD_PKT(x) ((x) & 0x20)
197 #define IS_TMO(t) ((t) == 0)
198 #define HI_BYTE(x) (u8)(((x) >> 8) & 0xFF)
199 #define LOW_BYTE(x) (u8)((x) & 0xFF)
200 #define SET_CMD_LOW(byte, bits) \
201 ((byte) = (((byte) & 0xF0) | ((bits) & 0x0F)))
202 #define SET_CMD_HIGH(byte, bits)\
203 ((byte) = (((byte) & 0x0F) | ((bits) & 0xF0)))
204
205 #define GET_MASK(length) \
206 ((1 << length) - 1)
207 #define GET_FIELD(name, length, shift) \
208 ((name >> shift) & GET_MASK(length))
209
210 #define HID_ITEM_SIZE_MASK 0x03
211 #define HID_ITEM_TYPE_MASK 0x0C
212 #define HID_ITEM_TAG_MASK 0xF0
213
214 #define HID_ITEM_SIZE_SHIFT 0
215 #define HID_ITEM_TYPE_SHIFT 2
216 #define HID_ITEM_TAG_SHIFT 4
217
218 #define HID_GET_ITEM_SIZE(x) \
219 ((x & HID_ITEM_SIZE_MASK) >> HID_ITEM_SIZE_SHIFT)
220 #define HID_GET_ITEM_TYPE(x) \
221 ((x & HID_ITEM_TYPE_MASK) >> HID_ITEM_TYPE_SHIFT)
222 #define HID_GET_ITEM_TAG(x) \
223 ((x & HID_ITEM_TAG_MASK) >> HID_ITEM_TAG_SHIFT)
224
225 #define IS_DEEP_SLEEP_CONFIGURED(x) \
226 ((x) == 0 || (x) == 0xFF)
227
228 #define IS_PIP_VER_GE(p, maj, min) \
229 ((p)->cydata.pip_ver_major < (maj) ? \
230 0 : \
231 ((p)->cydata.pip_ver_minor < (min) ? \
232 0 : \
233 1))
234
235 /* drv_debug commands */
236 #define CY_DBG_SUSPEND 4
237 #define CY_DBG_RESUME 5
238 #define CY_DBG_SOFT_RESET 97
239 #define CY_DBG_RESET 98
240 #define CY_DBG_HID_RESET 50
241 #define CY_DBG_HID_GET_REPORT 51
242 #define CY_DBG_HID_SET_REPORT 52
243 #define CY_DBG_HID_SET_POWER_ON 53
244 #define CY_DBG_HID_SET_POWER_SLEEP 54
245 #define CY_DBG_HID_NULL 100
246 #define CY_DBG_HID_ENTER_BL 101
247 #define CY_DBG_HID_SYSINFO 102
248 #define CY_DBG_HID_SUSPEND_SCAN 103
249 #define CY_DBG_HID_RESUME_SCAN 104
250 #define CY_DBG_HID_STOP_WD 105
251 #define CY_DBG_HID_START_WD 106
252
253 #define CY_TTHE_TUNER_EXIT 107
254 #define CY_TTHE_BUF_CLEAN 108
255
256 /*
257 * Commands that require additional parameters
258 * will be in the 200 range. Commands that do not
259 * require additional parameters remain below 200.
260 */
261 #define CY_DBG_REPORT_LEVEL 200
262 #define CY_DBG_WATCHDOG_INTERVAL 201
263 #define CY_DBG_SHOW_TIMESTAMP 202
264
265 /* Recognized usages */
266 /* undef them first for possible redefinition in Linux */
267 #undef HID_DI_PRESSURE
268 #undef HID_DI_TIP
269 #undef HID_DI_CONTACTID
270 #undef HID_DI_CONTACTCOUNT
271 #undef HID_DI_SCANTIME
272 #define HID_DI_PRESSURE 0x000d0030
273 #define HID_DI_TIP 0x000d0042
274 #define HID_DI_CONTACTID 0x000d0051
275 #define HID_DI_CONTACTCOUNT 0x000d0054
276 #define HID_DI_SCANTIME 0x000d0056
277
278 /* Parade vendor specific usages */
279 #define HID_CY_UNDEFINED 0xff010000
280 #define HID_CY_BOOTLOADER 0xff010001
281 #define HID_CY_TOUCHAPPLICATION 0xff010002
282 #define HID_CY_BUTTONS 0xff010020
283 #define HID_CY_GENERICITEM 0xff010030
284 #define HID_CY_LARGEOBJECT 0xff010040
285 #define HID_CY_NOISEEFFECTS 0xff010041
286 #define HID_CY_REPORTCOUNTER 0xff010042
287 #define HID_CY_TOUCHTYPE 0xff010060
288 #define HID_CY_EVENTID 0xff010061
289 #define HID_CY_MAJORAXISLENGTH 0xff010062
290 #define HID_CY_MINORAXISLENGTH 0xff010063
291 #define HID_CY_ORIENTATION 0xff010064
292 #define HID_CY_BUTTONSIGNAL 0xff010065
293 #define HID_CY_MAJOR_CONTACT_AXIS_LENGTH 0xff010066
294 #define HID_CY_MINOR_CONTACT_AXIS_LENGTH 0xff010067
295 #define HID_CY_TCH_COL_USAGE_PG 0x000D0022
296 #define HID_CY_BTN_COL_USAGE_PG 0xFF010020
297
298 #define PANEL_ID_NOT_ENABLED 0xFF
299
300 #ifdef EASYWAKE_TSG6
301 #define GESTURE_DOUBLE_TAP (1)
302 #define GESTURE_TWO_FINGERS_SLIDE (2)
303 #define GESTURE_TOUCH_DETECTED (3)
304 #define GESTURE_PUSH_BUTTON (4)
305 #define GESTURE_SINGLE_SLIDE_DE_TX (5)
306 #define GESTURE_SINGLE_SLIDE_IN_TX (6)
307 #define GESTURE_SINGLE_SLIDE_DE_RX (7)
308 #define GESTURE_SINGLE_SLIDE_IN_RX (8)
309 #endif
310
311 /* FW RAM parameters */
312 #define CY_RAM_ID_TOUCHMODE_ENABLED 0x02
313 #define CY_RAM_ID_PROXIMITY_ENABLE 0x20
314 #define CY_RAM_ID_TOUCHMODE_ENABLED_SIZE 1
315 #define CY_RAM_ID_PROXIMITY_ENABLE_SIZE 1
316
317 /* abs signal capabilities offsets in the frameworks array */
318 enum cyttsp5_sig_caps {
319 CY_SIGNAL_OST,
320 CY_MIN_OST,
321 CY_MAX_OST,
322 CY_FUZZ_OST,
323 CY_FLAT_OST,
324 CY_NUM_ABS_SET /* number of signal capability fields */
325 };
326
327 /* helpers */
328 #define NUM_SIGNALS(frmwrk) ((frmwrk)->size / CY_NUM_ABS_SET)
329 #define PARAM(frmwrk, sig_ost, cap_ost) \
330 ((frmwrk)->abs[((sig_ost) * CY_NUM_ABS_SET) + (cap_ost)])
331
332 #define PARAM_SIGNAL(frmwrk, sig_ost) PARAM(frmwrk, sig_ost, CY_SIGNAL_OST)
333 #define PARAM_MIN(frmwrk, sig_ost) PARAM(frmwrk, sig_ost, CY_MIN_OST)
334 #define PARAM_MAX(frmwrk, sig_ost) PARAM(frmwrk, sig_ost, CY_MAX_OST)
335 #define PARAM_FUZZ(frmwrk, sig_ost) PARAM(frmwrk, sig_ost, CY_FUZZ_OST)
336 #define PARAM_FLAT(frmwrk, sig_ost) PARAM(frmwrk, sig_ost, CY_FLAT_OST)
337
338 /* abs axis signal offsets in the framworks array */
339 enum cyttsp5_sig_ost {
340 CY_ABS_X_OST,
341 CY_ABS_Y_OST,
342 CY_ABS_P_OST,
343 CY_ABS_W_OST,
344 CY_ABS_ID_OST,
345 CY_ABS_MAJ_OST,
346 CY_ABS_MIN_OST,
347 CY_ABS_OR_OST,
348 CY_ABS_TOOL_OST,
349 CY_ABS_D_OST,
350 CY_NUM_ABS_OST /* number of abs signals */
351 };
352
353 enum hid_command {
354 HID_CMD_RESERVED,
355 HID_CMD_RESET,
356 HID_CMD_GET_REPORT,
357 HID_CMD_SET_REPORT,
358 HID_CMD_GET_IDLE,
359 HID_CMD_SET_IDLE,
360 HID_CMD_GET_PROTOCOL,
361 HID_CMD_SET_PROTOCOL,
362 HID_CMD_SET_POWER,
363 HID_CMD_VENDOR = 0xE,
364 };
365
366 enum hid_output_cmd_type {
367 HID_OUTPUT_CMD_APP,
368 HID_OUTPUT_CMD_BL,
369 };
370
371 enum hid_output {
372 HID_OUTPUT_NULL,
373 HID_OUTPUT_START_BOOTLOADER,
374 HID_OUTPUT_GET_SYSINFO,
375 HID_OUTPUT_SUSPEND_SCANNING,
376 HID_OUTPUT_RESUME_SCANNING,
377 HID_OUTPUT_GET_PARAM,
378 HID_OUTPUT_SET_PARAM,
379 HID_OUTPUT_GET_NOISE_METRICS,
380 HID_OUTPUT_RESERVED,
381 HID_OUTPUT_ENTER_EASYWAKE_STATE,
382 HID_OUTPUT_VERIFY_CONFIG_BLOCK_CRC = 0x20,
383 HID_OUTPUT_GET_CONFIG_ROW_SIZE,
384 HID_OUTPUT_READ_CONF_BLOCK,
385 HID_OUTPUT_WRITE_CONF_BLOCK,
386 HID_OUTPUT_GET_DATA_STRUCTURE,
387 HID_OUTPUT_LOAD_SELF_TEST_PARAM,
388 HID_OUTPUT_RUN_SELF_TEST,
389 HID_OUTPUT_GET_SELF_TEST_RESULT,
390 HID_OUTPUT_CALIBRATE_IDACS,
391 HID_OUTPUT_INITIALIZE_BASELINES,
392 HID_OUTPUT_EXEC_PANEL_SCAN,
393 HID_OUTPUT_RETRIEVE_PANEL_SCAN,
394 HID_OUTPUT_START_SENSOR_DATA_MODE,
395 HID_OUTPUT_STOP_SENSOR_DATA_MODE,
396 HID_OUTPUT_START_TRACKING_HEATMAP_MODE,
397 HID_OUTPUT_INT_PIN_OVERRIDE = 0x40,
398 HID_OUTPUT_STORE_PANEL_SCAN = 0x60,
399 HID_OUTPUT_PROCESS_PANEL_SCAN,
400 HID_OUTPUT_DISCARD_INPUT_REPORT,
401 HID_OUTPUT_LAST,
402 HID_OUTPUT_USER_CMD,
403 };
404
405 enum hid_output_bl {
406 HID_OUTPUT_BL_VERIFY_APP_INTEGRITY = 0x31,
407 HID_OUTPUT_BL_GET_INFO = 0x38,
408 HID_OUTPUT_BL_PROGRAM_AND_VERIFY,
409 HID_OUTPUT_BL_LAUNCH_APP = 0x3B,
410 HID_OUTPUT_BL_GET_PANEL_ID = 0x3E,
411 HID_OUTPUT_BL_INITIATE_BL = 0x48,
412 HID_OUTPUT_BL_LAST,
413 };
414
415 #define HID_OUTPUT_BL_SOP 0x1
416 #define HID_OUTPUT_BL_EOP 0x17
417
418 enum hid_output_bl_status {
419 ERROR_SUCCESS,
420 ERROR_KEY,
421 ERROR_VERIFICATION,
422 ERROR_LENGTH,
423 ERROR_DATA,
424 ERROR_COMMAND,
425 ERROR_CRC = 8,
426 ERROR_FLASH_ARRAY,
427 ERROR_FLASH_ROW,
428 ERROR_FLASH_PROTECTION,
429 ERROR_UKNOWN = 15,
430 ERROR_INVALID,
431 };
432
433 enum cyttsp5_mode {
434 CY_MODE_UNKNOWN,
435 CY_MODE_BOOTLOADER,
436 CY_MODE_OPERATIONAL,
437 };
438
439 enum cyttsp5_cmd_status {
440 CY_CMD_STATUS_SUCCESS,
441 CY_CMD_STATUS_FAILURE,
442 };
443
444 enum {
445 CY_IC_GRPNUM_RESERVED,
446 CY_IC_GRPNUM_CMD_REGS,
447 CY_IC_GRPNUM_TCH_REP,
448 CY_IC_GRPNUM_DATA_REC,
449 CY_IC_GRPNUM_TEST_REC,
450 CY_IC_GRPNUM_PCFG_REC,
451 CY_IC_GRPNUM_TCH_PARM_VAL,
452 CY_IC_GRPNUM_TCH_PARM_SIZE,
453 CY_IC_GRPNUM_RESERVED1,
454 CY_IC_GRPNUM_RESERVED2,
455 CY_IC_GRPNUM_OPCFG_REC,
456 CY_IC_GRPNUM_DDATA_REC,
457 CY_IC_GRPNUM_MDATA_REC,
458 CY_IC_GRPNUM_TEST_REGS,
459 CY_IC_GRPNUM_BTN_KEYS,
460 CY_IC_GRPNUM_TTHE_REGS,
461 CY_IC_GRPNUM_SENSING_CONF,
462 CY_IC_GRPNUM_NUM,
463 };
464
465 enum cyttsp5_event_id {
466 CY_EV_NO_EVENT,
467 CY_EV_TOUCHDOWN,
468 CY_EV_MOVE, /* significant displacement (> act dist) */
469 CY_EV_LIFTOFF, /* record reports last position */
470 };
471
472 enum cyttsp5_object_id {
473 CY_OBJ_STANDARD_FINGER,
474 CY_OBJ_PROXIMITY,
475 CY_OBJ_STYLUS,
476 CY_OBJ_HOVER,
477 CY_OBJ_GLOVE,
478 };
479
480 enum cyttsp5_self_test_result {
481 CY_ST_RESULT_PASS,
482 CY_ST_RESULT_FAIL,
483 CY_ST_RESULT_HOST_MUST_INTERPRET = 0xFF,
484 };
485
486 enum cyttsp5_self_test_id {
487 CY_ST_ID_NULL,
488 CY_ST_ID_BIST,
489 CY_ST_ID_SHORTS,
490 CY_ST_ID_OPENS,
491 CY_ST_ID_AUTOSHORTS,
492 CY_ST_ID_CM_PANEL,
493 CY_ST_ID_CP_PANEL,
494 CY_ST_ID_CM_BUTTON,
495 CY_ST_ID_CP_BUTTON,
496 };
497
498 #define CY_NUM_MFGID 8
499
500 /* System Information interface definitions */
501 struct cyttsp5_cydata_dev {
502 u8 pip_ver_major;
503 u8 pip_ver_minor;
504 __le16 fw_pid;
505 u8 fw_ver_major;
506 u8 fw_ver_minor;
507 __le32 revctrl;
508 __le16 fw_ver_conf;
509 u8 bl_ver_major;
510 u8 bl_ver_minor;
511 __le16 jtag_si_id_l;
512 __le16 jtag_si_id_h;
513 u8 mfg_id[CY_NUM_MFGID];
514 __le16 post_code;
515 } __packed;
516
517 struct cyttsp5_sensing_conf_data_dev {
518 u8 electrodes_x;
519 u8 electrodes_y;
520 __le16 len_x;
521 __le16 len_y;
522 __le16 res_x;
523 __le16 res_y;
524 __le16 max_z;
525 u8 origin_x;
526 u8 origin_y;
527 u8 panel_id;
528 u8 btn;
529 u8 scan_mode;
530 u8 max_num_of_tch_per_refresh_cycle;
531 } __packed;
532
533 struct cyttsp5_cydata {
534 u8 pip_ver_major;
535 u8 pip_ver_minor;
536 u8 bl_ver_major;
537 u8 bl_ver_minor;
538 u8 fw_ver_major;
539 u8 fw_ver_minor;
540 u16 fw_pid;
541 u16 fw_ver_conf;
542 u16 post_code;
543 u32 revctrl;
544 u16 jtag_id_l;
545 u16 jtag_id_h;
546 u8 mfg_id[CY_NUM_MFGID];
547 };
548
549 struct cyttsp5_sensing_conf_data {
550 u16 res_x;
551 u16 res_y;
552 u16 max_z;
553 u16 len_x;
554 u16 len_y;
555 u8 electrodes_x;
556 u8 electrodes_y;
557 u8 origin_x;
558 u8 origin_y;
559 u8 panel_id;
560 u8 btn;
561 u8 scan_mode;
562 u8 max_tch;
563 u8 rx_num;
564 u8 tx_num;
565 };
566
567 enum cyttsp5_tch_abs { /* for ordering within the extracted touch data array */
568 CY_TCH_X, /* X */
569 CY_TCH_Y, /* Y */
570 CY_TCH_P, /* P (Z) */
571 CY_TCH_T, /* TOUCH ID */
572 CY_TCH_E, /* EVENT ID */
573 CY_TCH_O, /* OBJECT ID */
574 CY_TCH_TIP, /* OBJECT ID */
575 CY_TCH_MAJ, /* TOUCH_MAJOR */
576 CY_TCH_MIN, /* TOUCH_MINOR */
577 CY_TCH_OR, /* ORIENTATION */
578 CY_TCH_NUM_ABS,
579 };
580
581 enum cyttsp5_tch_hdr {
582 CY_TCH_TIME, /* SCAN TIME */
583 CY_TCH_NUM, /* NUMBER OF RECORDS */
584 CY_TCH_LO, /* LARGE OBJECT */
585 CY_TCH_NOISE, /* NOISE EFFECT */
586 CY_TCH_COUNTER, /* REPORT_COUNTER */
587 CY_TCH_NUM_HDR,
588 };
589
590 static const char * const cyttsp5_tch_abs_string[] = {
591 [CY_TCH_X] = "X",
592 [CY_TCH_Y] = "Y",
593 [CY_TCH_P] = "P",
594 [CY_TCH_T] = "T",
595 [CY_TCH_E] = "E",
596 [CY_TCH_O] = "O",
597 [CY_TCH_TIP] = "TIP",
598 [CY_TCH_MAJ] = "MAJ",
599 [CY_TCH_MIN] = "MIN",
600 [CY_TCH_OR] = "OR",
601 [CY_TCH_NUM_ABS] = "INVALID",
602 };
603
604 static const char * const cyttsp5_tch_hdr_string[] = {
605 [CY_TCH_TIME] = "SCAN TIME",
606 [CY_TCH_NUM] = "NUMBER OF RECORDS",
607 [CY_TCH_LO] = "LARGE OBJECT",
608 [CY_TCH_NOISE] = "NOISE EFFECT",
609 [CY_TCH_COUNTER] = "REPORT_COUNTER",
610 [CY_TCH_NUM_HDR] = "INVALID",
611 };
612
613 static const int cyttsp5_tch_abs_field_map[] = {
614 [CY_TCH_X] = 0x00010030 /* HID_GD_X */,
615 [CY_TCH_Y] = 0x00010031 /* HID_GD_Y */,
616 [CY_TCH_P] = HID_DI_PRESSURE,
617 [CY_TCH_T] = HID_DI_CONTACTID,
618 [CY_TCH_E] = HID_CY_EVENTID,
619 [CY_TCH_O] = HID_CY_TOUCHTYPE,
620 [CY_TCH_TIP] = HID_DI_TIP,
621 [CY_TCH_MAJ] = HID_CY_MAJORAXISLENGTH,
622 [CY_TCH_MIN] = HID_CY_MINORAXISLENGTH,
623 [CY_TCH_OR] = HID_CY_ORIENTATION,
624 [CY_TCH_NUM_ABS] = 0,
625 };
626
627 static const int cyttsp5_tch_hdr_field_map[] = {
628 [CY_TCH_TIME] = HID_DI_SCANTIME,
629 [CY_TCH_NUM] = HID_DI_CONTACTCOUNT,
630 [CY_TCH_LO] = HID_CY_LARGEOBJECT,
631 [CY_TCH_NOISE] = HID_CY_NOISEEFFECTS,
632 [CY_TCH_COUNTER] = HID_CY_REPORTCOUNTER,
633 [CY_TCH_NUM_HDR] = 0,
634 };
635
636 #define CY_NUM_EXT_TCH_FIELDS 3
637
638 struct cyttsp5_tch_abs_params {
639 size_t ofs; /* abs byte offset */
640 size_t size; /* size in bits */
641 size_t min; /* min value */
642 size_t max; /* max value */
643 size_t bofs; /* bit offset */
644 u8 report;
645 };
646
647 struct cyttsp5_touch {
648 int hdr[CY_TCH_NUM_HDR];
649 int abs[CY_TCH_NUM_ABS];
650 };
651
652 /* button to keycode support */
653 #define CY_BITS_PER_BTN 1
654 #define CY_NUM_BTN_EVENT_ID ((1 << CY_BITS_PER_BTN) - 1)
655
656 enum cyttsp5_btn_state {
657 CY_BTN_RELEASED = 0,
658 CY_BTN_PRESSED = 1,
659 CY_BTN_NUM_STATE
660 };
661
662 struct cyttsp5_btn {
663 bool enabled;
664 int state; /* CY_BTN_PRESSED, CY_BTN_RELEASED */
665 int key_code;
666 };
667
668 enum cyttsp5_ic_ebid {
669 CY_TCH_PARM_EBID,
670 CY_MDATA_EBID,
671 CY_DDATA_EBID,
672 };
673
674 /* ttconfig block */
675 #define CY_TTCONFIG_VERSION_OFFSET 8
676 #define CY_TTCONFIG_VERSION_SIZE 2
677 #define CY_TTCONFIG_VERSION_ROW 0
678
679 struct cyttsp5_ttconfig {
680 u16 version;
681 u16 crc;
682 };
683
684 struct cyttsp5_report_desc_data {
685 u16 tch_report_id;
686 u16 tch_record_size;
687 u16 tch_header_size;
688 u16 btn_report_id;
689 };
690
691 struct cyttsp5_sysinfo {
692 bool ready;
693 struct cyttsp5_cydata cydata;
694 struct cyttsp5_sensing_conf_data sensing_conf_data;
695 struct cyttsp5_report_desc_data desc;
696 int num_btns;
697 struct cyttsp5_btn *btn;
698 struct cyttsp5_ttconfig ttconfig;
699 struct cyttsp5_tch_abs_params tch_hdr[CY_TCH_NUM_HDR];
700 struct cyttsp5_tch_abs_params tch_abs[CY_TCH_NUM_ABS];
701 u8 *xy_mode;
702 u8 *xy_data;
703 };
704
705 enum cyttsp5_atten_type {
706 CY_ATTEN_IRQ,
707 CY_ATTEN_STARTUP,
708 CY_ATTEN_EXCLUSIVE,
709 CY_ATTEN_WAKE,
710 CY_ATTEN_LOADER,
711 CY_ATTEN_SUSPEND,
712 CY_ATTEN_RESUME,
713 CY_ATTEN_NUM_ATTEN,
714 };
715
716 enum cyttsp5_sleep_state {
717 SS_SLEEP_OFF,
718 SS_SLEEP_ON,
719 SS_SLEEPING,
720 SS_WAKING,
721 };
722
723 enum cyttsp5_fb_state {
724 FB_ON,
725 FB_OFF,
726 };
727
728 enum cyttsp5_startup_state {
729 STARTUP_NONE,
730 STARTUP_QUEUED,
731 STARTUP_RUNNING,
732 STARTUP_ILLEGAL,
733 };
734
735 struct cyttsp5_hid_desc {
736 __le16 hid_desc_len;
737 u8 packet_id;
738 u8 reserved_byte;
739 __le16 bcd_version;
740 __le16 report_desc_len;
741 __le16 report_desc_register;
742 __le16 input_register;
743 __le16 max_input_len;
744 __le16 output_register;
745 __le16 max_output_len;
746 __le16 command_register;
747 __le16 data_register;
748 __le16 vendor_id;
749 __le16 product_id;
750 __le16 version_id;
751 u8 reserved[4];
752 } __packed;
753
754 struct cyttsp5_hid_core {
755 u16 hid_vendor_id;
756 u16 hid_product_id;
757 __le16 hid_desc_register;
758 u16 hid_report_desc_len;
759 u16 hid_max_input_len;
760 u16 hid_max_output_len;
761 };
762
763 #define CY_HID_MAX_REPORTS 8
764 #define CY_HID_MAX_FIELDS 128
765 #define CY_HID_MAX_COLLECTIONS 3
766 #define CY_HID_MAX_NESTED_COLLECTIONS CY_HID_MAX_COLLECTIONS
767
768 #define CY_MAX_INPUT 512
769 #define CY_PIP_1P7_EMPTY_BUF 0xFF00
770
771 enum cyttsp5_module_id {
772 CY_MODULE_MT,
773 CY_MODULE_BTN,
774 CY_MODULE_PROX,
775 CY_MODULE_LAST,
776 };
777
778 struct cyttsp5_mt_data;
779 struct cyttsp5_mt_function {
780 int (*mt_release)(struct device *dev);
781 int (*mt_probe)(struct device *dev, struct cyttsp5_mt_data *md);
782 void (*report_slot_liftoff)(struct cyttsp5_mt_data *md, int max_slots);
783 void (*input_sync)(struct input_dev *input);
784 void (*input_report)(struct input_dev *input, int sig, int t, int type);
785 void (*final_sync)(struct input_dev *input, int max_slots,
786 int mt_sync_count, unsigned long *ids);
787 int (*input_register_device)(struct input_dev *input, int max_slots);
788 };
789
790 struct cyttsp5_mt_data {
791 struct device *dev;
792 struct cyttsp5_mt_platform_data *pdata;
793 struct cyttsp5_sysinfo *si;
794 struct input_dev *input;
795 struct cyttsp5_mt_function mt_function;
796 struct mutex mt_lock;
797 bool is_suspended;
798 bool input_device_registered;
799 char phys[NAME_MAX];
800 int num_prv_rec;
801 int or_min;
802 int or_max;
803 int t_min;
804 int t_max;
805 };
806
807 struct cyttsp5_btn_data {
808 struct device *dev;
809 struct cyttsp5_btn_platform_data *pdata;
810 struct cyttsp5_sysinfo *si;
811 struct input_dev *input;
812 struct mutex btn_lock;
813 bool is_suspended;
814 bool input_device_registered;
815 char phys[NAME_MAX];
816 };
817
818 struct cyttsp5_proximity_data {
819 struct device *dev;
820 struct cyttsp5_proximity_platform_data *pdata;
821 struct cyttsp5_sysinfo *si;
822 struct input_dev *input;
823 struct mutex prox_lock;
824 struct mutex sysfs_lock;
825 int enable_count;
826 bool input_device_registered;
827 char phys[NAME_MAX];
828 };
829
830 enum cyttsp5_calibrate_idacs_sensing_mode {
831 CY_CI_SM_MUTCAP_FINE,
832 CY_CI_SM_MUTCAP_BUTTON,
833 CY_CI_SM_SELFCAP,
834 };
835
836 enum cyttsp5_initialize_baselines_sensing_mode {
837 CY_IB_SM_MUTCAP = 1,
838 CY_IB_SM_BUTTON = 2,
839 CY_IB_SM_SELFCAP = 4,
840 CY_IB_SM_BALANCED = 8,
841 };
842
843 struct cyttsp5_core_nonhid_cmd {
844 int (*start_bl)(struct device *dev, int protect);
845 int (*suspend_scanning)(struct device *dev, int protect);
846 int (*resume_scanning)(struct device *dev, int protect);
847 int (*get_param)(struct device *dev, int protect, u8 param_id,
848 u32 *value);
849 int (*set_param)(struct device *dev, int protect, u8 param_id,
850 u32 value, u8 size);
851 int (*verify_config_block_crc)(struct device *dev, int protect,
852 u8 ebid, u8 *status, u16 *calculated_crc,
853 u16 *stored_crc);
854 int (*get_config_row_size)(struct device *dev, int protect,
855 u16 *row_size);
856 int (*get_data_structure)(struct device *dev, int protect,
857 u16 read_offset, u16 read_length, u8 data_id,
858 u8 *status, u8 *data_format, u16 *actual_read_len,
859 u8 *data);
860 int (*run_selftest)(struct device *dev, int protect, u8 test_id,
861 u8 write_idacs_to_flash, u8 *status, u8 *summary_result,
862 u8 *results_available);
863 int (*get_selftest_result)(struct device *dev, int protect,
864 u16 read_offset, u16 read_length, u8 test_id, u8 *status,
865 u16 *actual_read_len, u8 *data);
866 int (*calibrate_idacs)(struct device *dev, int protect, u8 mode,
867 u8 *status);
868 int (*initialize_baselines)(struct device *dev, int protect,
869 u8 test_id, u8 *status);
870 int (*exec_panel_scan)(struct device *dev, int protect);
871 int (*retrieve_panel_scan)(struct device *dev, int protect,
872 u16 read_offset, u16 read_count, u8 data_id,
873 u8 *response, u8 *config, u16 *actual_read_len,
874 u8 *read_buf);
875 int (*write_conf_block)(struct device *dev, int protect,
876 u16 row_number, u16 write_length, u8 ebid,
877 u8 *write_buf, u8 *security_key, u16 *actual_write_len);
878 int (*user_cmd)(struct device *dev, int protect, u16 read_len,
879 u8 *read_buf, u16 write_len, u8 *write_buf,
880 u16 *actual_read_len);
881 int (*get_bl_info)(struct device *dev, int protect, u8 *return_data);
882 int (*initiate_bl)(struct device *dev, int protect, u16 key_size,
883 u8 *key_buf, u16 row_size, u8 *metadata_row_buf);
884 int (*launch_app)(struct device *dev, int protect);
885 int (*prog_and_verify)(struct device *dev, int protect, u16 data_len,
886 u8 *data_buf);
887 int (*verify_app_integrity)(struct device *dev, int protect,
888 u8 *result);
889 int (*get_panel_id)(struct device *dev, int protect, u8 *panel_id);
890 };
891
892 typedef int (*cyttsp5_atten_func) (struct device *);
893
894 struct cyttsp5_core_commands {
895 int (*subscribe_attention)(struct device *dev,
896 enum cyttsp5_atten_type type, char *id,
897 cyttsp5_atten_func func, int flags);
898 int (*unsubscribe_attention)(struct device *dev,
899 enum cyttsp5_atten_type type, char *id,
900 cyttsp5_atten_func func, int flags);
901 int (*request_exclusive)(struct device *dev, int timeout_ms);
902 int (*release_exclusive)(struct device *dev);
903 int (*request_reset)(struct device *dev);
904 int (*request_restart)(struct device *dev, bool wait);
905 struct cyttsp5_sysinfo * (*request_sysinfo)(struct device *dev);
906 struct cyttsp5_loader_platform_data
907 *(*request_loader_pdata)(struct device *dev);
908 int (*request_stop_wd)(struct device *dev);
909 int (*request_start_wd)(struct device *dev);
910 int (*request_get_hid_desc)(struct device *dev, int protect);
911 int (*request_get_mode)(struct device *dev, int protect, u8 *mode);
912 int (*request_enable_scan_type)(struct device *dev, u8 scan_type);
913 int (*request_disable_scan_type)(struct device *dev, u8 scan_type);
914 struct cyttsp5_core_nonhid_cmd *nonhid_cmd;
915 #ifdef TTHE_TUNER_SUPPORT
916 int (*request_tthe_print)(struct device *dev, u8 *buf, int buf_len,
917 const u8 *data_name);
918 #endif
919 };
920
921 struct cyttsp5_features {
922 uint8_t easywake;
923 uint8_t noise_metric;
924 uint8_t tracking_heatmap;
925 uint8_t sensor_data;
926 };
927 /*
928 #define NEED_SUSPEND_NOTIFIER \
929 ((LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)) \
930 && defined(CONFIG_PM_SLEEP) && defined(CONFIG_PM_RUNTIME))
931 */
932 #define NEED_SUSPEND_NOTIFIER 0
933
934 struct cyttsp5_module {
935 struct list_head node;
936 char *name;
937 int (*probe)(struct device *dev, void **data);
938 void (*release)(struct device *dev, void *data);
939 };
940
941 struct cyttsp5_core_data {
942 struct list_head node;
943 struct list_head module_list; /* List of probed modules */
944 char core_id[20];
945 struct device *dev;
946 struct list_head atten_list[CY_ATTEN_NUM_ATTEN];
947 struct list_head param_list;
948 struct mutex module_list_lock;
949 struct mutex system_lock;
950 struct mutex adap_lock;
951 struct mutex hid_report_lock;
952 enum cyttsp5_mode mode;
953 spinlock_t spinlock;
954 struct cyttsp5_mt_data md;
955 struct cyttsp5_btn_data bd;
956 struct cyttsp5_proximity_data pd;
957 int phys_num;
958 int number_of_open_input_device;
959 int pm_runtime_usage_count;
960 void *cyttsp5_dynamic_data[CY_MODULE_LAST];
961 struct cyttsp5_platform_data *pdata;
962 struct cyttsp5_core_platform_data *cpdata;
963 const struct cyttsp5_bus_ops *bus_ops;
964 wait_queue_head_t wait_q;
965 enum cyttsp5_sleep_state sleep_state;
966 enum cyttsp5_startup_state startup_state;
967 int irq;
968 bool irq_enabled;
969 bool irq_wake;
970 bool irq_disabled;
971 u8 easy_wakeup_gesture;
972 #ifdef EASYWAKE_TSG6
973 u8 gesture_id;
974 u8 gesture_data_length;
975 u8 gesture_data[80];
976 #endif
977 bool wake_initiated_by_device;
978 bool wait_until_wake;
979 u8 panel_id;
980 #if NEED_SUSPEND_NOTIFIER
981 /*
982 * This notifier is used to receive suspend prepare events
983 * When device is PM runtime suspended, pm_generic_suspend()
984 * does not call our PM suspend callback for kernels with
985 * version less than 3.3.0.
986 */
987 struct notifier_block pm_notifier;
988 #endif
989 struct work_struct startup_work;
990 struct cyttsp5_sysinfo sysinfo;
991 void *exclusive_dev;
992 int exclusive_waits;
993 struct work_struct watchdog_work;
994 struct timer_list watchdog_timer;
995 u16 startup_retry_count;
996 struct cyttsp5_hid_core hid_core;
997 int hid_cmd_state;
998 int hid_reset_cmd_state; /* reset can happen any time */
999 struct cyttsp5_hid_desc hid_desc;
1000 struct cyttsp5_hid_report *hid_reports[CY_HID_MAX_REPORTS];
1001 int num_hid_reports;
1002 struct cyttsp5_features features;
1003 #define CYTTSP5_PREALLOCATED_CMD_BUFFER 32
1004 u8 cmd_buf[CYTTSP5_PREALLOCATED_CMD_BUFFER];
1005 u8 input_buf[CY_MAX_INPUT];
1006 u8 response_buf[CY_MAX_INPUT];
1007 #ifdef CONFIG_HAS_EARLYSUSPEND
1008 struct early_suspend es;
1009 #elif defined(CONFIG_FB)
1010 struct notifier_block fb_notifier;
1011 enum cyttsp5_fb_state fb_state;
1012 #endif
1013 #ifdef TTHE_TUNER_SUPPORT
1014 struct dentry *tthe_debugfs;
1015 u8 *tthe_buf;
1016 u32 tthe_buf_len;
1017 struct mutex tthe_lock;
1018 u8 tthe_exit;
1019 #endif
1020 #ifdef VERBOSE_DEBUG
1021 u8 pr_buf[CY_MAX_PRBUF_SIZE];
1022 #endif
1023 u8 debug_level;
1024 u32 watchdog_interval;
1025 u8 show_timestamp;
1026 struct regulator *supply;
1027 struct tp_device tp;
1028 u32 is_suspend;
1029
1030 //2019-03-22 add delayedwork modify watchdog time
1031 #ifdef CYTTSP_WATCHDOG_DELAY_ENBALE
1032 struct delayed_work watchdog_enable_work;
1033 #endif
1034
1035
1036 };
1037 struct gd_sensor {
1038 int32_t cm_min;
1039 int32_t cm_max;
1040 int32_t cm_ave;
1041 int32_t cm_min_exclude_edge;
1042 int32_t cm_max_exclude_edge;
1043 int32_t cm_ave_exclude_edge;
1044 int32_t gradient_val;
1045 };
1046
1047 #ifdef TTHE_TUNER_SUPPORT
1048 #define CY_CMD_RET_PANEL_IN_DATA_OFFSET 0
1049 #define CY_CMD_RET_PANEL_ELMNT_SZ_MASK 0x07
1050 #define CY_CMD_RET_PANEL_HDR 0x0A
1051 #define CY_CMD_RET_PANEL_ELMNT_SZ_MAX 0x2
1052
1053 enum scan_data_type_list {
1054 CY_MUT_RAW,
1055 CY_MUT_BASE,
1056 CY_MUT_DIFF,
1057 CY_SELF_RAW,
1058 CY_SELF_BASE,
1059 CY_SELF_DIFF,
1060 CY_BAL_RAW,
1061 CY_BAL_BASE,
1062 CY_BAL_DIFF,
1063 };
1064 #endif
1065
1066 struct cyttsp5_bus_ops {
1067 u16 bustype;
1068
1069 int (*read_default)(struct device *dev, void *buf, int size);
1070 int (*read_default_nosize)(struct device *dev, u8 *buf, u32 max);
1071 int (*write_read_specific)(struct device *dev, u8 write_len,
1072 u8 *write_buf, u8 *read_buf);
1073 };
1074
cyttsp5_adap_read_default(struct cyttsp5_core_data * cd,void * buf,int size)1075 static inline int cyttsp5_adap_read_default(struct cyttsp5_core_data *cd,
1076 void *buf, int size)
1077 {
1078 return cd->bus_ops->read_default(cd->dev, buf, size);
1079 }
1080
cyttsp5_adap_read_default_nosize(struct cyttsp5_core_data * cd,void * buf,int max)1081 static inline int cyttsp5_adap_read_default_nosize(struct cyttsp5_core_data *cd,
1082 void *buf, int max)
1083 {
1084 return cd->bus_ops->read_default_nosize(cd->dev, buf, max);
1085 }
1086
cyttsp5_adap_write_read_specific(struct cyttsp5_core_data * cd,u8 write_len,u8 * write_buf,u8 * read_buf)1087 static inline int cyttsp5_adap_write_read_specific(struct cyttsp5_core_data *cd,
1088 u8 write_len, u8 *write_buf, u8 *read_buf)
1089 {
1090 return cd->bus_ops->write_read_specific(cd->dev, write_len, write_buf,
1091 read_buf);
1092 }
1093
cyttsp5_get_dynamic_data(struct device * dev,int id)1094 static inline void *cyttsp5_get_dynamic_data(struct device *dev, int id)
1095 {
1096 struct cyttsp5_core_data *cd = dev_get_drvdata(dev);
1097
1098 return cd->cyttsp5_dynamic_data[id];
1099 }
1100
1101 int request_exclusive(struct cyttsp5_core_data *cd, void *ownptr,
1102 int timeout_ms);
1103 int release_exclusive(struct cyttsp5_core_data *cd, void *ownptr);
1104 int _cyttsp5_request_hid_output_get_param(struct device *dev,
1105 int protect, u8 param_id, u32 *value);
1106 int _cyttsp5_request_hid_output_set_param(struct device *dev,
1107 int protect, u8 param_id, u32 value, u8 size);
1108
cyttsp5_request_exclusive(struct device * dev,int timeout_ms)1109 static inline int cyttsp5_request_exclusive(struct device *dev, int timeout_ms)
1110 {
1111 struct cyttsp5_core_data *cd = dev_get_drvdata(dev);
1112
1113 return request_exclusive(cd, dev, timeout_ms);
1114 }
1115
cyttsp5_release_exclusive(struct device * dev)1116 static inline int cyttsp5_release_exclusive(struct device *dev)
1117 {
1118 struct cyttsp5_core_data *cd = dev_get_drvdata(dev);
1119
1120 return release_exclusive(cd, dev);
1121 }
1122
cyttsp5_request_nonhid_get_param(struct device * dev,int protect,u8 param_id,u32 * value)1123 static inline int cyttsp5_request_nonhid_get_param(struct device *dev,
1124 int protect, u8 param_id, u32 *value)
1125 {
1126 return _cyttsp5_request_hid_output_get_param(dev, protect, param_id,
1127 value);
1128 }
1129
cyttsp5_request_nonhid_set_param(struct device * dev,int protect,u8 param_id,u32 value,u8 size)1130 static inline int cyttsp5_request_nonhid_set_param(struct device *dev,
1131 int protect, u8 param_id, u32 value, u8 size)
1132 {
1133 return _cyttsp5_request_hid_output_set_param(dev, protect, param_id,
1134 value, size);
1135 }
1136
1137 #ifdef VERBOSE_DEBUG
1138 void cyttsp5_pr_buf(struct device *dev, u8 *dptr, int size,
1139 const char *data_name);
1140 #else
1141 #define cyttsp5_pr_buf(a, b, c, d) do { } while (0)
1142 #endif
1143
1144 #ifdef CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP5_DEVICETREE_SUPPORT
1145 int cyttsp5_devtree_create_and_get_pdata(struct device *adap_dev);
1146 int cyttsp5_devtree_clean_pdata(struct device *adap_dev);
1147 #else
cyttsp5_devtree_create_and_get_pdata(struct device * adap_dev)1148 static inline int cyttsp5_devtree_create_and_get_pdata(struct device *adap_dev)
1149 {
1150 return 0;
1151 }
1152
cyttsp5_devtree_clean_pdata(struct device * adap_dev)1153 static inline int cyttsp5_devtree_clean_pdata(struct device *adap_dev)
1154 {
1155 return 0;
1156 }
1157 #endif
1158
1159 int cyttsp5_probe(const struct cyttsp5_bus_ops *ops, struct device *dev,
1160 u16 irq, size_t xfer_buf_size);
1161 int cyttsp5_release(struct cyttsp5_core_data *cd);
1162
1163 struct cyttsp5_core_commands *cyttsp5_get_commands(void);
1164 struct cyttsp5_core_data *cyttsp5_get_core_data(char *id);
1165
1166 int cyttsp5_mt_release(struct device *dev);
1167 int cyttsp5_mt_probe(struct device *dev);
1168
1169 #ifdef CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP5_BUTTON
1170 int cyttsp5_btn_probe(struct device *dev);
1171 int cyttsp5_btn_release(struct device *dev);
1172 #else
cyttsp5_btn_probe(struct device * dev)1173 static inline int cyttsp5_btn_probe(struct device *dev) { return 0; }
cyttsp5_btn_release(struct device * dev)1174 static inline int cyttsp5_btn_release(struct device *dev) { return 0; }
1175 #endif
1176
1177 #ifdef CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP5_PROXIMITY
1178 int cyttsp5_proximity_probe(struct device *dev);
1179 int cyttsp5_proximity_release(struct device *dev);
1180 #else
cyttsp5_proximity_probe(struct device * dev)1181 static inline int cyttsp5_proximity_probe(struct device *dev) { return 0; }
cyttsp5_proximity_release(struct device * dev)1182 static inline int cyttsp5_proximity_release(struct device *dev) { return 0; }
1183 #endif
1184
1185 void cyttsp5_init_function_ptrs(struct cyttsp5_mt_data *md);
1186 int _cyttsp5_subscribe_attention(struct device *dev,
1187 enum cyttsp5_atten_type type, char *id, int (*func)(struct device *),
1188 int mode);
1189 int _cyttsp5_unsubscribe_attention(struct device *dev,
1190 enum cyttsp5_atten_type type, char *id, int (*func)(struct device *),
1191 int mode);
1192 struct cyttsp5_sysinfo *_cyttsp5_request_sysinfo(struct device *dev);
1193
1194 extern const struct dev_pm_ops cyttsp5_pm_ops;
1195
1196 int cyttsp5_register_module(struct cyttsp5_module *module);
1197 void cyttsp5_unregister_module(struct cyttsp5_module *module);
1198
1199 void *cyttsp5_get_module_data(struct device *dev,
1200 struct cyttsp5_module *module);
1201
1202 #endif /* _CYTTSP5_REGS_H */
1203