1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef __CYTTSP_CORE_H__
18#define __CYTTSP_CORE_H__
19
20#include <linux/kernel.h>
21#include <linux/err.h>
22#include <linux/module.h>
23#include <linux/types.h>
24#include <linux/device.h>
25#include <linux/regulator/consumer.h>
26
27#define CY_NUM_RETRY 16
28
29struct cyttsp_tch {
30 __be16 x, y;
31 u8 z;
32} __packed;
33
34
35struct cyttsp_xydata {
36 u8 hst_mode;
37 u8 tt_mode;
38 u8 tt_stat;
39 struct cyttsp_tch tch1;
40 u8 touch12_id;
41 struct cyttsp_tch tch2;
42 u8 gest_cnt;
43 u8 gest_id;
44 struct cyttsp_tch tch3;
45 u8 touch34_id;
46 struct cyttsp_tch tch4;
47 u8 tt_undef[3];
48 u8 act_dist;
49 u8 tt_reserved;
50} __packed;
51
52
53
54struct cyttsp_sysinfo_data {
55 u8 hst_mode;
56 u8 mfg_stat;
57 u8 mfg_cmd;
58 u8 cid[3];
59 u8 tt_undef1;
60 u8 uid[8];
61 u8 bl_verh;
62 u8 bl_verl;
63 u8 tts_verh;
64 u8 tts_verl;
65 u8 app_idh;
66 u8 app_idl;
67 u8 app_verh;
68 u8 app_verl;
69 u8 tt_undef[5];
70 u8 scn_typ;
71 u8 act_intrvl;
72 u8 tch_tmout;
73 u8 lp_intrvl;
74};
75
76
77#define CY_BL_CHKSUM_OK 0x01
78struct cyttsp_bootloader_data {
79 u8 bl_file;
80 u8 bl_status;
81 u8 bl_error;
82 u8 blver_hi;
83 u8 blver_lo;
84 u8 bld_blver_hi;
85 u8 bld_blver_lo;
86 u8 ttspver_hi;
87 u8 ttspver_lo;
88 u8 appid_hi;
89 u8 appid_lo;
90 u8 appver_hi;
91 u8 appver_lo;
92 u8 cid_0;
93 u8 cid_1;
94 u8 cid_2;
95};
96
97struct cyttsp;
98
99struct cyttsp_bus_ops {
100 u16 bustype;
101 int (*write)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length,
102 const void *values);
103 int (*read)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length,
104 void *values);
105};
106
107enum cyttsp_state {
108 CY_IDLE_STATE,
109 CY_ACTIVE_STATE,
110 CY_BL_STATE,
111};
112
113struct cyttsp {
114 struct device *dev;
115 int irq;
116 struct input_dev *input;
117 const struct cyttsp_bus_ops *bus_ops;
118 struct cyttsp_bootloader_data bl_data;
119 struct cyttsp_sysinfo_data sysinfo_data;
120 struct cyttsp_xydata xy_data;
121 struct completion bl_ready;
122 enum cyttsp_state state;
123 bool suspended;
124
125 struct regulator_bulk_data regulators[2];
126 struct gpio_desc *reset_gpio;
127 bool use_hndshk;
128 u8 act_dist;
129 u8 act_intrvl;
130 u8 tch_tmout;
131 u8 lp_intrvl;
132 u8 *bl_keys;
133
134 u8 xfer_buf[] ____cacheline_aligned;
135};
136
137struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
138 struct device *dev, int irq, size_t xfer_buf_size);
139
140int cyttsp_i2c_write_block_data(struct device *dev, u8 *xfer_buf, u16 addr,
141 u8 length, const void *values);
142int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, u16 addr,
143 u8 length, void *values);
144extern const struct dev_pm_ops cyttsp_pm_ops;
145
146#endif
147