diff options
author | Iiro Valkonen <iiro.valkonen@atmel.com> | 2011-02-15 16:36:52 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-02-21 04:02:33 -0500 |
commit | 71749f5c66e797a39600dae9de58aab3858dc488 (patch) | |
tree | dfb7593588c36288e3bbbae68a5ca22ac62c255b /drivers/input | |
parent | 46ee2a05a466ca7e34d65fe3feba195d62109362 (diff) |
Input: atmel_mxt_ts - allow board code to suppliy controller config
As there is no common configuration settings that would work in every
situation, remove the fixed config data from driver code and add
config data to platform data.
Signed-off-by: Iiro Valkonen <iiro.valkonen@atmel.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/touchscreen/atmel_mxt_ts.c | 148 |
1 files changed, 13 insertions, 135 deletions
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index fe8902e1f010..52032ef3d3ab 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c | |||
@@ -199,122 +199,6 @@ | |||
199 | 199 | ||
200 | #define MXT_MAX_FINGER 10 | 200 | #define MXT_MAX_FINGER 10 |
201 | 201 | ||
202 | /* Initial register values recommended from chip vendor */ | ||
203 | static const u8 init_vals_ver_20[] = { | ||
204 | /* MXT_GEN_COMMAND(6) */ | ||
205 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
206 | /* MXT_GEN_POWER(7) */ | ||
207 | 0x20, 0xff, 0x32, | ||
208 | /* MXT_GEN_ACQUIRE(8) */ | ||
209 | 0x08, 0x05, 0x05, 0x00, 0x00, 0x00, 0x05, 0x14, | ||
210 | /* MXT_TOUCH_MULTI(9) */ | ||
211 | 0x00, 0x00, 0x00, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x02, 0x00, | ||
212 | 0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00, | ||
213 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x64, | ||
214 | /* MXT_TOUCH_KEYARRAY(15) */ | ||
215 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
216 | 0x00, | ||
217 | /* MXT_SPT_GPIOPWM(19) */ | ||
218 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
219 | 0x00, 0x00, | ||
220 | /* MXT_PROCI_GRIPFACE(20) */ | ||
221 | 0x00, 0x64, 0x64, 0x64, 0x64, 0x00, 0x00, 0x1e, 0x14, 0x04, | ||
222 | 0x1e, 0x00, | ||
223 | /* MXT_PROCG_NOISE(22) */ | ||
224 | 0x05, 0x00, 0x00, 0x19, 0x00, 0xe7, 0xff, 0x04, 0x32, 0x00, | ||
225 | 0x01, 0x0a, 0x0f, 0x14, 0x00, 0x00, 0xe8, | ||
226 | /* MXT_TOUCH_PROXIMITY(23) */ | ||
227 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
228 | 0x00, 0x00, 0x00, | ||
229 | /* MXT_PROCI_ONETOUCH(24) */ | ||
230 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
231 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
232 | /* MXT_SPT_SELFTEST(25) */ | ||
233 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
234 | 0x00, 0x00, 0x00, 0x00, | ||
235 | /* MXT_PROCI_TWOTOUCH(27) */ | ||
236 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
237 | /* MXT_SPT_CTECONFIG(28) */ | ||
238 | 0x00, 0x00, 0x00, 0x04, 0x08, | ||
239 | }; | ||
240 | |||
241 | static const u8 init_vals_ver_21[] = { | ||
242 | /* MXT_GEN_COMMAND(6) */ | ||
243 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
244 | /* MXT_GEN_POWER(7) */ | ||
245 | 0x20, 0xff, 0x32, | ||
246 | /* MXT_GEN_ACQUIRE(8) */ | ||
247 | 0x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x23, | ||
248 | /* MXT_TOUCH_MULTI(9) */ | ||
249 | 0x00, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00, | ||
250 | 0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00, | ||
251 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
252 | /* MXT_TOUCH_KEYARRAY(15) */ | ||
253 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
254 | 0x00, | ||
255 | /* MXT_SPT_GPIOPWM(19) */ | ||
256 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
257 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
258 | /* MXT_PROCI_GRIPFACE(20) */ | ||
259 | 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x28, 0x04, | ||
260 | 0x0f, 0x0a, | ||
261 | /* MXT_PROCG_NOISE(22) */ | ||
262 | 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x23, 0x00, | ||
263 | 0x00, 0x05, 0x0f, 0x19, 0x23, 0x2d, 0x03, | ||
264 | /* MXT_TOUCH_PROXIMITY(23) */ | ||
265 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
266 | 0x00, 0x00, 0x00, | ||
267 | /* MXT_PROCI_ONETOUCH(24) */ | ||
268 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
269 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
270 | /* MXT_SPT_SELFTEST(25) */ | ||
271 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
272 | 0x00, 0x00, 0x00, 0x00, | ||
273 | /* MXT_PROCI_TWOTOUCH(27) */ | ||
274 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
275 | /* MXT_SPT_CTECONFIG(28) */ | ||
276 | 0x00, 0x00, 0x00, 0x08, 0x10, 0x00, | ||
277 | }; | ||
278 | |||
279 | static const u8 init_vals_ver_22[] = { | ||
280 | /* MXT_GEN_COMMAND(6) */ | ||
281 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
282 | /* MXT_GEN_POWER(7) */ | ||
283 | 0x20, 0xff, 0x32, | ||
284 | /* MXT_GEN_ACQUIRE(8) */ | ||
285 | 0x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x23, | ||
286 | /* MXT_TOUCH_MULTI(9) */ | ||
287 | 0x00, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00, | ||
288 | 0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00, | ||
289 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
290 | 0x00, | ||
291 | /* MXT_TOUCH_KEYARRAY(15) */ | ||
292 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
293 | 0x00, | ||
294 | /* MXT_SPT_GPIOPWM(19) */ | ||
295 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
296 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
297 | /* MXT_PROCI_GRIPFACE(20) */ | ||
298 | 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x28, 0x04, | ||
299 | 0x0f, 0x0a, | ||
300 | /* MXT_PROCG_NOISE(22) */ | ||
301 | 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x23, 0x00, | ||
302 | 0x00, 0x05, 0x0f, 0x19, 0x23, 0x2d, 0x03, | ||
303 | /* MXT_TOUCH_PROXIMITY(23) */ | ||
304 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
305 | 0x00, 0x00, 0x00, 0x00, 0x00, | ||
306 | /* MXT_PROCI_ONETOUCH(24) */ | ||
307 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
308 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
309 | /* MXT_SPT_SELFTEST(25) */ | ||
310 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
311 | 0x00, 0x00, 0x00, 0x00, | ||
312 | /* MXT_PROCI_TWOTOUCH(27) */ | ||
313 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
314 | /* MXT_SPT_CTECONFIG(28) */ | ||
315 | 0x00, 0x00, 0x00, 0x08, 0x10, 0x00, | ||
316 | }; | ||
317 | |||
318 | struct mxt_info { | 202 | struct mxt_info { |
319 | u8 family_id; | 203 | u8 family_id; |
320 | u8 variant_id; | 204 | u8 variant_id; |
@@ -714,26 +598,15 @@ end: | |||
714 | 598 | ||
715 | static int mxt_check_reg_init(struct mxt_data *data) | 599 | static int mxt_check_reg_init(struct mxt_data *data) |
716 | { | 600 | { |
601 | const struct mxt_platform_data *pdata = data->pdata; | ||
717 | struct mxt_object *object; | 602 | struct mxt_object *object; |
718 | struct device *dev = &data->client->dev; | 603 | struct device *dev = &data->client->dev; |
719 | int index = 0; | 604 | int index = 0; |
720 | int i, j; | 605 | int i, j, config_offset; |
721 | u8 version = data->info.version; | ||
722 | u8 *init_vals; | ||
723 | 606 | ||
724 | switch (version) { | 607 | if (!pdata->config) { |
725 | case MXT_VER_20: | 608 | dev_dbg(dev, "No cfg data defined, skipping reg init\n"); |
726 | init_vals = (u8 *)init_vals_ver_20; | 609 | return 0; |
727 | break; | ||
728 | case MXT_VER_21: | ||
729 | init_vals = (u8 *)init_vals_ver_21; | ||
730 | break; | ||
731 | case MXT_VER_22: | ||
732 | init_vals = (u8 *)init_vals_ver_22; | ||
733 | break; | ||
734 | default: | ||
735 | dev_err(dev, "Firmware version %d doesn't support\n", version); | ||
736 | return -EINVAL; | ||
737 | } | 610 | } |
738 | 611 | ||
739 | for (i = 0; i < data->info.object_num; i++) { | 612 | for (i = 0; i < data->info.object_num; i++) { |
@@ -742,10 +615,15 @@ static int mxt_check_reg_init(struct mxt_data *data) | |||
742 | if (!mxt_object_writable(object->type)) | 615 | if (!mxt_object_writable(object->type)) |
743 | continue; | 616 | continue; |
744 | 617 | ||
745 | for (j = 0; j < object->size + 1; j++) | 618 | for (j = 0; j < object->size + 1; j++) { |
619 | config_offset = index + j; | ||
620 | if (config_offset > pdata->config_length) { | ||
621 | dev_err(dev, "Not enough config data!\n"); | ||
622 | return -EINVAL; | ||
623 | } | ||
746 | mxt_write_object(data, object->type, j, | 624 | mxt_write_object(data, object->type, j, |
747 | init_vals[index + j]); | 625 | pdata->config[config_offset]); |
748 | 626 | } | |
749 | index += object->size + 1; | 627 | index += object->size + 1; |
750 | } | 628 | } |
751 | 629 | ||