Commit | Line | Data |
---|---|---|
6fa3eb70 S |
1 | /* |
2 | * mms_ts.h - Platform data for Melfas MMS-series touch driver | |
3 | * | |
4 | * Copyright (C) 2013 Melfas Inc. | |
5 | * Author: DVK team <dvk@melfas.com> | |
6 | * | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify it | |
9 | * under the terms of the GNU General Public License as published by the | |
10 | * Free Software Foundation; either version 2 of the License, or (at your | |
11 | * option) any later version. | |
12 | * | |
13 | */ | |
14 | ||
15 | #ifndef _LINUX_MMS_TOUCH_H | |
16 | #define _LINUX_MMS_TOUCH_H | |
17 | ||
18 | #include <linux/cdev.h> | |
19 | ||
20 | ||
21 | /* Change IIC Slave Address */ | |
22 | #define FW_DL_To_Change_IIC_Address 0//demo address:0x48,some project change for other; anderson | |
23 | ||
24 | /* Firmware file name */ | |
25 | #define FW_NAME "mms_ts.fw" | |
26 | #define FW_CONFIG_NAME "mms_ts_cfg.fw" | |
27 | ||
28 | /* mfsp offset */ | |
29 | #define MMS_MFSP_OFFSET 16 | |
30 | ||
31 | /* Runtime config */ | |
32 | #define MMS_RUN_CONF_POINTER 0xA1 | |
33 | #define MMS_GET_RUN_CONF 0xA2 | |
34 | #define MMS_SET_RUN_CONF 0xA3 | |
35 | #define MMS_READ_BYTE 8//the size of one point info,8 or 6,anderson | |
36 | ||
37 | /* Registers */ | |
38 | #define MMS_MODE_CONTROL 0x01 | |
39 | #define MMS_TX_NUM 0x0B | |
40 | #define MMS_RX_NUM 0x0C | |
41 | #define MMS_EVENT_PKT_SZ 0x0F | |
42 | #define MMS_INPUT_EVENT 0x10 | |
43 | #define MMS_UNIVERSAL_CMD 0xA0 | |
44 | #define MMS_UNIVERSAL_RESULT_LENGTH 0xAE | |
45 | #define MMS_UNIVERSAL_RESULT 0xAF | |
46 | #define MMS_UNIV_SET_SPEC 0x30 | |
47 | #define MMS_UNIV_ENTER_TEST 0x40 | |
48 | #define MMS_UNIV_TEST_CM 0x41 | |
49 | #define MMS_UNIV_GET_CM 0x42 | |
50 | #define MMS_UNIV_EXIT_TEST 0x4F | |
51 | #define MMS_UNIV_INTENSITY 0x70 | |
52 | #define MMS_CMD_ENTER_ISC 0x5F | |
53 | #define MMS_FW_VERSION 0xE1 | |
54 | #define MMS_ERASE_DEFEND 0xB0 | |
55 | ||
56 | /* Universal commands */ | |
57 | #define MMS_CMD_SET_LOG_MODE 0x20 | |
58 | #define MMS_CMD_CONTROL 0x22 | |
59 | #define MMS_SUBCMD_START 0x80 | |
60 | ||
61 | /* Firmware Start Control */ | |
62 | #define RUN_START 0 | |
63 | #define RUN_STOP 1 | |
64 | ||
65 | #define MAX_SECTION_NUM 3 | |
66 | #define ISC_XFER_LEN 128 | |
67 | #define MMS_FLASH_PAGE_SZ 1024 | |
68 | #define ISC_BLOCK_NUM (MMS_FLASH_PAGE_SZ / ISC_XFER_LEN) | |
69 | ||
70 | // runtime config | |
71 | #define MMS_RUNTIME | |
72 | ||
73 | enum { | |
74 | MMS_RUN_TYPE_SINGLE = 1, | |
75 | MMS_RUN_TYPE_ARRAY, | |
76 | MMS_RUN_TYPE_END, | |
77 | MMS_RUN_TYPE_INFO, | |
78 | MMS_RUN_TYPE_UNKNOWN, | |
79 | }; | |
80 | ||
81 | ||
82 | enum { | |
83 | ISC_ADDR = 0xD5, | |
84 | ||
85 | ISC_CMD_READ_STATUS = 0xD9, | |
86 | ISC_CMD_READ = 0x4000, | |
87 | ISC_CMD_EXIT = 0x8200, | |
88 | ISC_CMD_PAGE_ERASE = 0xC000, | |
89 | ||
90 | ISC_PAGE_ERASE_DONE = 0x10000, | |
91 | ISC_PAGE_ERASE_ENTER = 0x20000, | |
92 | }; | |
93 | ||
94 | struct mms_ts_platform_data { | |
95 | int max_x; | |
96 | int max_y; | |
97 | ||
98 | int gpio_sda; | |
99 | int gpio_scl; | |
100 | int gpio_resetb; | |
101 | int gpio_vdd_en; | |
102 | }; | |
103 | ||
104 | struct mms_config_item { | |
105 | u16 type; | |
106 | u16 category; | |
107 | u16 offset; | |
108 | u16 datasize; | |
109 | u16 data_blocksize; | |
110 | u16 reserved; | |
111 | ||
112 | u32 value; | |
113 | } __attribute__ ((packed)); | |
114 | ||
115 | struct mms_config_hdr { | |
116 | char mark[4]; | |
117 | ||
118 | char tag[4]; | |
119 | ||
120 | u32 core_version; | |
121 | u32 config_version; | |
122 | u32 data_offset; | |
123 | u32 data_count; | |
124 | ||
125 | u32 reserved0; | |
126 | u32 info_offset; | |
127 | u32 reserved2; | |
128 | u32 reserved3; | |
129 | u32 reserved4; | |
130 | u32 reserved5; | |
131 | ||
132 | } __attribute__ ((packed)); | |
133 | ||
134 | struct mms_ts_info { | |
135 | struct i2c_client *client; | |
136 | struct input_dev *input_dev; | |
137 | char phys[32]; | |
138 | ||
139 | u8 tx_num; | |
140 | u8 rx_num; | |
141 | int data_cmd; | |
142 | ||
143 | ||
144 | int irq; | |
145 | ||
146 | struct mms_ts_platform_data *pdata; | |
147 | ||
148 | char *fw_name; | |
149 | struct completion init_done; | |
150 | struct early_suspend early_suspend; | |
151 | ||
152 | struct mutex lock; | |
153 | bool enabled; | |
154 | ||
155 | struct cdev cdev; | |
156 | dev_t mms_dev; | |
157 | struct class *class; | |
158 | ||
159 | u8 ver[3]; | |
160 | int run_count; | |
161 | ||
162 | struct mms_log_data { | |
163 | u8 *data; | |
164 | int cmd; | |
165 | } log; | |
166 | ||
167 | char *cm_intensity; | |
168 | }; | |
169 | ||
170 | struct mms_bin_hdr { | |
171 | char tag[8]; | |
172 | u16 core_version; | |
173 | u16 section_num; | |
174 | u16 contains_full_binary; | |
175 | u16 reserved0; | |
176 | ||
177 | u32 binary_offset; | |
178 | u32 binary_length; | |
179 | ||
180 | u32 extention_offset; | |
181 | u32 reserved1; | |
182 | ||
183 | } __attribute__ ((packed)); | |
184 | ||
185 | struct mms_fw_img { | |
186 | u16 type; | |
187 | u16 version; | |
188 | ||
189 | u16 start_page; | |
190 | u16 end_page; | |
191 | ||
192 | u32 offset; | |
193 | u32 length; | |
194 | ||
195 | } __attribute__ ((packed)); | |
196 | ||
197 | struct isc_packet { | |
198 | u8 cmd; | |
199 | u32 addr; | |
200 | u8 data[0]; | |
201 | } __attribute__ ((packed)); | |
202 | ||
203 | extern int mms_config_start(struct mms_ts_info *info); | |
204 | void mms_fw_update_controller(const struct firmware *fw, void * context); | |
205 | ||
206 | ||
207 | #endif /* _LINUX_MMS_TOUCH_H */ |