aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/input/elantech.txt123
-rw-r--r--Documentation/input/rotary-encoder.txt13
-rw-r--r--arch/arm/mach-tegra/include/mach/kbc.h4
-rw-r--r--drivers/input/evdev.c19
-rw-r--r--drivers/input/input-polldev.c56
-rw-r--r--drivers/input/input.c1
-rw-r--r--drivers/input/joydev.c1
-rw-r--r--drivers/input/keyboard/Kconfig22
-rw-r--r--drivers/input/keyboard/Makefile2
-rw-r--r--drivers/input/keyboard/adp5589-keys.c771
-rw-r--r--drivers/input/keyboard/gpio_keys.c11
-rw-r--r--drivers/input/keyboard/mpr121_touchkey.c339
-rw-r--r--drivers/input/keyboard/omap-keypad.c6
-rw-r--r--drivers/input/keyboard/qt1070.c1
-rw-r--r--drivers/input/keyboard/sh_keysc.c53
-rw-r--r--drivers/input/keyboard/tegra-kbc.c60
-rw-r--r--drivers/input/misc/ad714x.c129
-rw-r--r--drivers/input/misc/ati_remote2.c9
-rw-r--r--drivers/input/misc/rotary_encoder.c119
-rw-r--r--drivers/input/misc/twl4030-pwrbutton.c2
-rw-r--r--drivers/input/mouse/elantech.c72
-rw-r--r--drivers/input/mouse/elantech.h6
-rw-r--r--drivers/input/mousedev.c1
-rw-r--r--drivers/input/touchscreen/Kconfig12
-rw-r--r--drivers/input/touchscreen/Makefile1
-rw-r--r--drivers/input/touchscreen/ads7846.c26
-rw-r--r--drivers/input/touchscreen/atmel_mxt_ts.c92
-rw-r--r--drivers/input/touchscreen/atmel_tsadcc.c2
-rw-r--r--drivers/input/touchscreen/h3600_ts_input.c8
-rw-r--r--drivers/input/touchscreen/max11801_ts.c272
-rw-r--r--drivers/input/touchscreen/tsc2007.c26
-rw-r--r--include/linux/gpio_keys.h8
-rw-r--r--include/linux/i2c/mpr121_touchkey.h20
-rw-r--r--include/linux/i2c/tsc2007.h7
-rw-r--r--include/linux/input/ad714x.h3
-rw-r--r--include/linux/input/adp5589.h213
-rw-r--r--include/linux/rotary_encoder.h1
-rw-r--r--include/linux/spi/ads7846.h3
38 files changed, 2155 insertions, 359 deletions
diff --git a/Documentation/input/elantech.txt b/Documentation/input/elantech.txt
index 56941ae1f5db..db798af5ef98 100644
--- a/Documentation/input/elantech.txt
+++ b/Documentation/input/elantech.txt
@@ -34,7 +34,8 @@ Contents
34Currently the Linux Elantech touchpad driver is aware of two different 34Currently the Linux Elantech touchpad driver is aware of two different
35hardware versions unimaginatively called version 1 and version 2. Version 1 35hardware versions unimaginatively called version 1 and version 2. Version 1
36is found in "older" laptops and uses 4 bytes per packet. Version 2 seems to 36is found in "older" laptops and uses 4 bytes per packet. Version 2 seems to
37be introduced with the EeePC and uses 6 bytes per packet. 37be introduced with the EeePC and uses 6 bytes per packet, and provides
38additional features such as position of two fingers, and width of the touch.
38 39
39The driver tries to support both hardware versions and should be compatible 40The driver tries to support both hardware versions and should be compatible
40with the Xorg Synaptics touchpad driver and its graphical configuration 41with the Xorg Synaptics touchpad driver and its graphical configuration
@@ -94,18 +95,44 @@ Currently the Linux Elantech touchpad driver provides two extra knobs under
94 can check these bits and reject any packet that appears corrupted. Using 95 can check these bits and reject any packet that appears corrupted. Using
95 this knob you can bypass that check. 96 this knob you can bypass that check.
96 97
97 It is not known yet whether hardware version 2 provides the same parity 98 Hardware version 2 does not provide the same parity bits. Only some basic
98 bits. Hence checking is disabled by default. Currently even turning it on 99 data consistency checking can be done. For now checking is disabled by
99 will do nothing. 100 default. Currently even turning it on will do nothing.
100
101 101
102///////////////////////////////////////////////////////////////////////////// 102/////////////////////////////////////////////////////////////////////////////
103 103
1043. Differentiating hardware versions
105 =================================
106
107To detect the hardware version, read the version number as param[0].param[1].param[2]
108
109 4 bytes version: (after the arrow is the name given in the Dell-provided driver)
110 02.00.22 => EF013
111 02.06.00 => EF019
112In the wild, there appear to be more versions, such as 00.01.64, 01.00.21,
11302.00.00, 02.00.04, 02.00.06.
114
115 6 bytes:
116 02.00.30 => EF113
117 02.08.00 => EF023
118 02.08.XX => EF123
119 02.0B.00 => EF215
120 04.01.XX => Scroll_EF051
121 04.02.XX => EF051
122In the wild, there appear to be more versions, such as 04.03.01, 04.04.11. There
123appears to be almost no difference, except for EF113, which does not report
124pressure/width and has different data consistency checks.
125
126Probably all the versions with param[0] <= 01 can be considered as
1274 bytes/firmware 1. The versions < 02.08.00, with the exception of 02.00.30, as
1284 bytes/firmware 2. Everything >= 02.08.00 can be considered as 6 bytes.
129
130/////////////////////////////////////////////////////////////////////////////
104 131
1053. Hardware version 1 1324. Hardware version 1
106 ================== 133 ==================
107 134
1083.1 Registers 1354.1 Registers
109 ~~~~~~~~~ 136 ~~~~~~~~~
110 137
111By echoing a hexadecimal value to a register it contents can be altered. 138By echoing a hexadecimal value to a register it contents can be altered.
@@ -168,7 +195,7 @@ For example:
168 smart edge activation area width? 195 smart edge activation area width?
169 196
170 197
1713.2 Native relative mode 4 byte packet format 1984.2 Native relative mode 4 byte packet format
172 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 199 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
173 200
174byte 0: 201byte 0:
@@ -226,9 +253,13 @@ byte 3:
226 positive = down 253 positive = down
227 254
228 255
2293.3 Native absolute mode 4 byte packet format 2564.3 Native absolute mode 4 byte packet format
230 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 257 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
231 258
259EF013 and EF019 have a special behaviour (due to a bug in the firmware?), and
260when 1 finger is touching, the first 2 position reports must be discarded.
261This counting is reset whenever a different number of fingers is reported.
262
232byte 0: 263byte 0:
233 firmware version 1.x: 264 firmware version 1.x:
234 265
@@ -279,11 +310,11 @@ byte 3:
279///////////////////////////////////////////////////////////////////////////// 310/////////////////////////////////////////////////////////////////////////////
280 311
281 312
2824. Hardware version 2 3135. Hardware version 2
283 ================== 314 ==================
284 315
285 316
2864.1 Registers 3175.1 Registers
287 ~~~~~~~~~ 318 ~~~~~~~~~
288 319
289By echoing a hexadecimal value to a register it contents can be altered. 320By echoing a hexadecimal value to a register it contents can be altered.
@@ -316,16 +347,41 @@ For example:
316 0x7f = never i.e. tap again to release) 347 0x7f = never i.e. tap again to release)
317 348
318 349
3194.2 Native absolute mode 6 byte packet format 3505.2 Native absolute mode 6 byte packet format
320 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 351 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
321 3525.2.1 Parity checking and packet re-synchronization
3224.2.1 One finger touch 353There is no parity checking, however some consistency checks can be performed.
354
355For instance for EF113:
356 SA1= packet[0];
357 A1 = packet[1];
358 B1 = packet[2];
359 SB1= packet[3];
360 C1 = packet[4];
361 D1 = packet[5];
362 if( (((SA1 & 0x3C) != 0x3C) && ((SA1 & 0xC0) != 0x80)) || // check Byte 1
363 (((SA1 & 0x0C) != 0x0C) && ((SA1 & 0xC0) == 0x80)) || // check Byte 1 (one finger pressed)
364 (((SA1 & 0xC0) != 0x80) && (( A1 & 0xF0) != 0x00)) || // check Byte 2
365 (((SB1 & 0x3E) != 0x38) && ((SA1 & 0xC0) != 0x80)) || // check Byte 4
366 (((SB1 & 0x0E) != 0x08) && ((SA1 & 0xC0) == 0x80)) || // check Byte 4 (one finger pressed)
367 (((SA1 & 0xC0) != 0x80) && (( C1 & 0xF0) != 0x00)) ) // check Byte 5
368 // error detected
369
370For all the other ones, there are just a few constant bits:
371 if( ((packet[0] & 0x0C) != 0x04) ||
372 ((packet[3] & 0x0f) != 0x02) )
373 // error detected
374
375
376In case an error is detected, all the packets are shifted by one (and packet[0] is discarded).
377
3785.2.1 One/Three finger touch
323 ~~~~~~~~~~~~~~~~ 379 ~~~~~~~~~~~~~~~~
324 380
325byte 0: 381byte 0:
326 382
327 bit 7 6 5 4 3 2 1 0 383 bit 7 6 5 4 3 2 1 0
328 n1 n0 . . . . R L 384 n1 n0 w3 w2 . . R L
329 385
330 L, R = 1 when Left, Right mouse button pressed 386 L, R = 1 when Left, Right mouse button pressed
331 n1..n0 = numbers of fingers on touchpad 387 n1..n0 = numbers of fingers on touchpad
@@ -333,24 +389,40 @@ byte 0:
333byte 1: 389byte 1:
334 390
335 bit 7 6 5 4 3 2 1 0 391 bit 7 6 5 4 3 2 1 0
336 . . . . . x10 x9 x8 392 p7 p6 p5 p4 . x10 x9 x8
337 393
338byte 2: 394byte 2:
339 395
340 bit 7 6 5 4 3 2 1 0 396 bit 7 6 5 4 3 2 1 0
341 x7 x6 x5 x4 x4 x2 x1 x0 397 x7 x6 x5 x4 x3 x2 x1 x0
342 398
343 x10..x0 = absolute x value (horizontal) 399 x10..x0 = absolute x value (horizontal)
344 400
345byte 3: 401byte 3:
346 402
347 bit 7 6 5 4 3 2 1 0 403 bit 7 6 5 4 3 2 1 0
348 . . . . . . . . 404 n4 vf w1 w0 . . . b2
405
406 n4 = set if more than 3 fingers (only in 3 fingers mode)
407 vf = a kind of flag ? (only on EF123, 0 when finger is over one
408 of the buttons, 1 otherwise)
409 w3..w0 = width of the finger touch (not EF113)
410 b2 (on EF113 only, 0 otherwise), b2.R.L indicates one button pressed:
411 0 = none
412 1 = Left
413 2 = Right
414 3 = Middle (Left and Right)
415 4 = Forward
416 5 = Back
417 6 = Another one
418 7 = Another one
349 419
350byte 4: 420byte 4:
351 421
352 bit 7 6 5 4 3 2 1 0 422 bit 7 6 5 4 3 2 1 0
353 . . . . . . y9 y8 423 p3 p1 p2 p0 . . y9 y8
424
425 p7..p0 = pressure (not EF113)
354 426
355byte 5: 427byte 5:
356 428
@@ -363,6 +435,11 @@ byte 5:
3634.2.2 Two finger touch 4354.2.2 Two finger touch
364 ~~~~~~~~~~~~~~~~ 436 ~~~~~~~~~~~~~~~~
365 437
438Note that the two pairs of coordinates are not exactly the coordinates of the
439two fingers, but only the pair of the lower-left and upper-right coordinates.
440So the actual fingers might be situated on the other diagonal of the square
441defined by these two points.
442
366byte 0: 443byte 0:
367 444
368 bit 7 6 5 4 3 2 1 0 445 bit 7 6 5 4 3 2 1 0
@@ -376,14 +453,14 @@ byte 1:
376 bit 7 6 5 4 3 2 1 0 453 bit 7 6 5 4 3 2 1 0
377 ax7 ax6 ax5 ax4 ax3 ax2 ax1 ax0 454 ax7 ax6 ax5 ax4 ax3 ax2 ax1 ax0
378 455
379 ax8..ax0 = first finger absolute x value 456 ax8..ax0 = lower-left finger absolute x value
380 457
381byte 2: 458byte 2:
382 459
383 bit 7 6 5 4 3 2 1 0 460 bit 7 6 5 4 3 2 1 0
384 ay7 ay6 ay5 ay4 ay3 ay2 ay1 ay0 461 ay7 ay6 ay5 ay4 ay3 ay2 ay1 ay0
385 462
386 ay8..ay0 = first finger absolute y value 463 ay8..ay0 = lower-left finger absolute y value
387 464
388byte 3: 465byte 3:
389 466
@@ -395,11 +472,11 @@ byte 4:
395 bit 7 6 5 4 3 2 1 0 472 bit 7 6 5 4 3 2 1 0
396 bx7 bx6 bx5 bx4 bx3 bx2 bx1 bx0 473 bx7 bx6 bx5 bx4 bx3 bx2 bx1 bx0
397 474
398 bx8..bx0 = second finger absolute x value 475 bx8..bx0 = upper-right finger absolute x value
399 476
400byte 5: 477byte 5:
401 478
402 bit 7 6 5 4 3 2 1 0 479 bit 7 6 5 4 3 2 1 0
403 by7 by8 by5 by4 by3 by2 by1 by0 480 by7 by8 by5 by4 by3 by2 by1 by0
404 481
405 by8..by0 = second finger absolute y value 482 by8..by0 = upper-right finger absolute y value
diff --git a/Documentation/input/rotary-encoder.txt b/Documentation/input/rotary-encoder.txt
index 943e8f6f2b15..92e68bce13a4 100644
--- a/Documentation/input/rotary-encoder.txt
+++ b/Documentation/input/rotary-encoder.txt
@@ -9,6 +9,9 @@ peripherals with two wires. The outputs are phase-shifted by 90 degrees
9and by triggering on falling and rising edges, the turn direction can 9and by triggering on falling and rising edges, the turn direction can
10be determined. 10be determined.
11 11
12Some encoders have both outputs low in stable states, whereas others also have
13a stable state with both outputs high (half-period mode).
14
12The phase diagram of these two outputs look like this: 15The phase diagram of these two outputs look like this:
13 16
14 _____ _____ _____ 17 _____ _____ _____
@@ -26,6 +29,8 @@ The phase diagram of these two outputs look like this:
26 |<-------->| 29 |<-------->|
27 one step 30 one step
28 31
32 |<-->|
33 one step (half-period mode)
29 34
30For more information, please see 35For more information, please see
31 http://en.wikipedia.org/wiki/Rotary_encoder 36 http://en.wikipedia.org/wiki/Rotary_encoder
@@ -34,6 +39,13 @@ For more information, please see
341. Events / state machine 391. Events / state machine
35------------------------- 40-------------------------
36 41
42In half-period mode, state a) and c) above are used to determine the
43rotational direction based on the last stable state. Events are reported in
44states b) and d) given that the new stable state is different from the last
45(i.e. the rotation was not reversed half-way).
46
47Otherwise, the following apply:
48
37a) Rising edge on channel A, channel B in low state 49a) Rising edge on channel A, channel B in low state
38 This state is used to recognize a clockwise turn 50 This state is used to recognize a clockwise turn
39 51
@@ -96,6 +108,7 @@ static struct rotary_encoder_platform_data my_rotary_encoder_info = {
96 .gpio_b = GPIO_ROTARY_B, 108 .gpio_b = GPIO_ROTARY_B,
97 .inverted_a = 0, 109 .inverted_a = 0,
98 .inverted_b = 0, 110 .inverted_b = 0,
111 .half_period = false,
99}; 112};
100 113
101static struct platform_device rotary_encoder_device = { 114static struct platform_device rotary_encoder_device = {
diff --git a/arch/arm/mach-tegra/include/mach/kbc.h b/arch/arm/mach-tegra/include/mach/kbc.h
index 04c779832c78..4f3572a1c684 100644
--- a/arch/arm/mach-tegra/include/mach/kbc.h
+++ b/arch/arm/mach-tegra/include/mach/kbc.h
@@ -50,13 +50,11 @@ struct tegra_kbc_platform_data {
50 unsigned int debounce_cnt; 50 unsigned int debounce_cnt;
51 unsigned int repeat_cnt; 51 unsigned int repeat_cnt;
52 52
53 unsigned int wake_cnt; /* 0:wake on any key >1:wake on wake_cfg */
54 const struct tegra_kbc_wake_key *wake_cfg;
55
56 struct tegra_kbc_pin_cfg pin_cfg[KBC_MAX_GPIO]; 53 struct tegra_kbc_pin_cfg pin_cfg[KBC_MAX_GPIO];
57 const struct matrix_keymap_data *keymap_data; 54 const struct matrix_keymap_data *keymap_data;
58 55
59 bool wakeup; 56 bool wakeup;
60 bool use_fn_map; 57 bool use_fn_map;
58 bool use_ghost_filter;
61}; 59};
62#endif 60#endif
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 88d8e4cb419a..be0921ef6b52 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -41,6 +41,7 @@ struct evdev {
41struct evdev_client { 41struct evdev_client {
42 unsigned int head; 42 unsigned int head;
43 unsigned int tail; 43 unsigned int tail;
44 unsigned int packet_head; /* [future] position of the first element of next packet */
44 spinlock_t buffer_lock; /* protects access to buffer, head and tail */ 45 spinlock_t buffer_lock; /* protects access to buffer, head and tail */
45 struct fasync_struct *fasync; 46 struct fasync_struct *fasync;
46 struct evdev *evdev; 47 struct evdev *evdev;
@@ -72,12 +73,16 @@ static void evdev_pass_event(struct evdev_client *client,
72 client->buffer[client->tail].type = EV_SYN; 73 client->buffer[client->tail].type = EV_SYN;
73 client->buffer[client->tail].code = SYN_DROPPED; 74 client->buffer[client->tail].code = SYN_DROPPED;
74 client->buffer[client->tail].value = 0; 75 client->buffer[client->tail].value = 0;
75 }
76 76
77 spin_unlock(&client->buffer_lock); 77 client->packet_head = client->tail;
78 }
78 79
79 if (event->type == EV_SYN) 80 if (event->type == EV_SYN && event->code == SYN_REPORT) {
81 client->packet_head = client->head;
80 kill_fasync(&client->fasync, SIGIO, POLL_IN); 82 kill_fasync(&client->fasync, SIGIO, POLL_IN);
83 }
84
85 spin_unlock(&client->buffer_lock);
81} 86}
82 87
83/* 88/*
@@ -159,7 +164,6 @@ static int evdev_grab(struct evdev *evdev, struct evdev_client *client)
159 return error; 164 return error;
160 165
161 rcu_assign_pointer(evdev->grab, client); 166 rcu_assign_pointer(evdev->grab, client);
162 synchronize_rcu();
163 167
164 return 0; 168 return 0;
165} 169}
@@ -182,7 +186,6 @@ static void evdev_attach_client(struct evdev *evdev,
182 spin_lock(&evdev->client_lock); 186 spin_lock(&evdev->client_lock);
183 list_add_tail_rcu(&client->node, &evdev->client_list); 187 list_add_tail_rcu(&client->node, &evdev->client_list);
184 spin_unlock(&evdev->client_lock); 188 spin_unlock(&evdev->client_lock);
185 synchronize_rcu();
186} 189}
187 190
188static void evdev_detach_client(struct evdev *evdev, 191static void evdev_detach_client(struct evdev *evdev,
@@ -387,12 +390,12 @@ static ssize_t evdev_read(struct file *file, char __user *buffer,
387 if (count < input_event_size()) 390 if (count < input_event_size())
388 return -EINVAL; 391 return -EINVAL;
389 392
390 if (client->head == client->tail && evdev->exist && 393 if (client->packet_head == client->tail && evdev->exist &&
391 (file->f_flags & O_NONBLOCK)) 394 (file->f_flags & O_NONBLOCK))
392 return -EAGAIN; 395 return -EAGAIN;
393 396
394 retval = wait_event_interruptible(evdev->wait, 397 retval = wait_event_interruptible(evdev->wait,
395 client->head != client->tail || !evdev->exist); 398 client->packet_head != client->tail || !evdev->exist);
396 if (retval) 399 if (retval)
397 return retval; 400 return retval;
398 401
@@ -421,7 +424,7 @@ static unsigned int evdev_poll(struct file *file, poll_table *wait)
421 poll_wait(file, &evdev->wait, wait); 424 poll_wait(file, &evdev->wait, wait);
422 425
423 mask = evdev->exist ? POLLOUT | POLLWRNORM : POLLHUP | POLLERR; 426 mask = evdev->exist ? POLLOUT | POLLWRNORM : POLLHUP | POLLERR;
424 if (client->head != client->tail) 427 if (client->packet_head != client->tail)
425 mask |= POLLIN | POLLRDNORM; 428 mask |= POLLIN | POLLRDNORM;
426 429
427 return mask; 430 return mask;
diff --git a/drivers/input/input-polldev.c b/drivers/input/input-polldev.c
index 3037842a60d8..b1aabde87523 100644
--- a/drivers/input/input-polldev.c
+++ b/drivers/input/input-polldev.c
@@ -13,6 +13,7 @@
13#include <linux/jiffies.h> 13#include <linux/jiffies.h>
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/mutex.h> 15#include <linux/mutex.h>
16#include <linux/workqueue.h>
16#include <linux/input-polldev.h> 17#include <linux/input-polldev.h>
17 18
18MODULE_AUTHOR("Dmitry Torokhov <dtor@mail.ru>"); 19MODULE_AUTHOR("Dmitry Torokhov <dtor@mail.ru>");
@@ -20,44 +21,6 @@ MODULE_DESCRIPTION("Generic implementation of a polled input device");
20MODULE_LICENSE("GPL v2"); 21MODULE_LICENSE("GPL v2");
21MODULE_VERSION("0.1"); 22MODULE_VERSION("0.1");
22 23
23static DEFINE_MUTEX(polldev_mutex);
24static int polldev_users;
25static struct workqueue_struct *polldev_wq;
26
27static int input_polldev_start_workqueue(void)
28{
29 int retval;
30
31 retval = mutex_lock_interruptible(&polldev_mutex);
32 if (retval)
33 return retval;
34
35 if (!polldev_users) {
36 polldev_wq = create_singlethread_workqueue("ipolldevd");
37 if (!polldev_wq) {
38 pr_err("failed to create ipolldevd workqueue\n");
39 retval = -ENOMEM;
40 goto out;
41 }
42 }
43
44 polldev_users++;
45
46 out:
47 mutex_unlock(&polldev_mutex);
48 return retval;
49}
50
51static void input_polldev_stop_workqueue(void)
52{
53 mutex_lock(&polldev_mutex);
54
55 if (!--polldev_users)
56 destroy_workqueue(polldev_wq);
57
58 mutex_unlock(&polldev_mutex);
59}
60
61static void input_polldev_queue_work(struct input_polled_dev *dev) 24static void input_polldev_queue_work(struct input_polled_dev *dev)
62{ 25{
63 unsigned long delay; 26 unsigned long delay;
@@ -66,7 +29,7 @@ static void input_polldev_queue_work(struct input_polled_dev *dev)
66 if (delay >= HZ) 29 if (delay >= HZ)
67 delay = round_jiffies_relative(delay); 30 delay = round_jiffies_relative(delay);
68 31
69 queue_delayed_work(polldev_wq, &dev->work, delay); 32 queue_delayed_work(system_freezable_wq, &dev->work, delay);
70} 33}
71 34
72static void input_polled_device_work(struct work_struct *work) 35static void input_polled_device_work(struct work_struct *work)
@@ -81,18 +44,13 @@ static void input_polled_device_work(struct work_struct *work)
81static int input_open_polled_device(struct input_dev *input) 44static int input_open_polled_device(struct input_dev *input)
82{ 45{
83 struct input_polled_dev *dev = input_get_drvdata(input); 46 struct input_polled_dev *dev = input_get_drvdata(input);
84 int error;
85
86 error = input_polldev_start_workqueue();
87 if (error)
88 return error;
89 47
90 if (dev->open) 48 if (dev->open)
91 dev->open(dev); 49 dev->open(dev);
92 50
93 /* Only start polling if polling is enabled */ 51 /* Only start polling if polling is enabled */
94 if (dev->poll_interval > 0) 52 if (dev->poll_interval > 0)
95 queue_delayed_work(polldev_wq, &dev->work, 0); 53 queue_delayed_work(system_freezable_wq, &dev->work, 0);
96 54
97 return 0; 55 return 0;
98} 56}
@@ -102,13 +60,6 @@ static void input_close_polled_device(struct input_dev *input)
102 struct input_polled_dev *dev = input_get_drvdata(input); 60 struct input_polled_dev *dev = input_get_drvdata(input);
103 61
104 cancel_delayed_work_sync(&dev->work); 62 cancel_delayed_work_sync(&dev->work);
105 /*
106 * Clean up work struct to remove references to the workqueue.
107 * It may be destroyed by the next call. This causes problems
108 * at next device open-close in case of poll_interval == 0.
109 */
110 INIT_DELAYED_WORK(&dev->work, dev->work.work.func);
111 input_polldev_stop_workqueue();
112 63
113 if (dev->close) 64 if (dev->close)
114 dev->close(dev); 65 dev->close(dev);
@@ -295,4 +246,3 @@ void input_unregister_polled_device(struct input_polled_dev *dev)
295 input_unregister_device(dev->input); 246 input_unregister_device(dev->input);
296} 247}
297EXPORT_SYMBOL(input_unregister_polled_device); 248EXPORT_SYMBOL(input_unregister_polled_device);
298
diff --git a/drivers/input/input.c b/drivers/input/input.c
index ebbceedc92f4..75e11c7b70fd 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -451,7 +451,6 @@ int input_grab_device(struct input_handle *handle)
451 } 451 }
452 452
453 rcu_assign_pointer(dev->grab, handle); 453 rcu_assign_pointer(dev->grab, handle);
454 synchronize_rcu();
455 454
456 out: 455 out:
457 mutex_unlock(&dev->mutex); 456 mutex_unlock(&dev->mutex);
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 5688b5c88f24..c24ec2d5f926 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -180,7 +180,6 @@ static void joydev_attach_client(struct joydev *joydev,
180 spin_lock(&joydev->client_lock); 180 spin_lock(&joydev->client_lock);
181 list_add_tail_rcu(&client->node, &joydev->client_list); 181 list_add_tail_rcu(&client->node, &joydev->client_list);
182 spin_unlock(&joydev->client_lock); 182 spin_unlock(&joydev->client_lock);
183 synchronize_rcu();
184} 183}
185 184
186static void joydev_detach_client(struct joydev *joydev, 185static void joydev_detach_client(struct joydev *joydev,
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index b16bed038f72..69badb4e06aa 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -32,6 +32,16 @@ config KEYBOARD_ADP5588
32 To compile this driver as a module, choose M here: the 32 To compile this driver as a module, choose M here: the
33 module will be called adp5588-keys. 33 module will be called adp5588-keys.
34 34
35config KEYBOARD_ADP5589
36 tristate "ADP5589 I2C QWERTY Keypad and IO Expander"
37 depends on I2C
38 help
39 Say Y here if you want to use a ADP5589 attached to your
40 system I2C bus.
41
42 To compile this driver as a module, choose M here: the
43 module will be called adp5589-keys.
44
35config KEYBOARD_AMIGA 45config KEYBOARD_AMIGA
36 tristate "Amiga keyboard" 46 tristate "Amiga keyboard"
37 depends on AMIGA 47 depends on AMIGA
@@ -325,6 +335,18 @@ config KEYBOARD_MCS
325 To compile this driver as a module, choose M here: the 335 To compile this driver as a module, choose M here: the
326 module will be called mcs_touchkey. 336 module will be called mcs_touchkey.
327 337
338config KEYBOARD_MPR121
339 tristate "Freescale MPR121 Touchkey"
340 depends on I2C
341 help
342 Say Y here if you have Freescale MPR121 touchkey controller
343 chip in your system.
344
345 If unsure, say N.
346
347 To compile this driver as a module, choose M here: the
348 module will be called mpr121_touchkey.
349
328config KEYBOARD_IMX 350config KEYBOARD_IMX
329 tristate "IMX keypad support" 351 tristate "IMX keypad support"
330 depends on ARCH_MXC 352 depends on ARCH_MXC
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 878e6c20deb0..c49cf8e04cd7 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -6,6 +6,7 @@
6 6
7obj-$(CONFIG_KEYBOARD_ADP5520) += adp5520-keys.o 7obj-$(CONFIG_KEYBOARD_ADP5520) += adp5520-keys.o
8obj-$(CONFIG_KEYBOARD_ADP5588) += adp5588-keys.o 8obj-$(CONFIG_KEYBOARD_ADP5588) += adp5588-keys.o
9obj-$(CONFIG_KEYBOARD_ADP5589) += adp5589-keys.o
9obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o 10obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o
10obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o 11obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o
11obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o 12obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o
@@ -27,6 +28,7 @@ obj-$(CONFIG_KEYBOARD_MAPLE) += maple_keyb.o
27obj-$(CONFIG_KEYBOARD_MATRIX) += matrix_keypad.o 28obj-$(CONFIG_KEYBOARD_MATRIX) += matrix_keypad.o
28obj-$(CONFIG_KEYBOARD_MAX7359) += max7359_keypad.o 29obj-$(CONFIG_KEYBOARD_MAX7359) += max7359_keypad.o
29obj-$(CONFIG_KEYBOARD_MCS) += mcs_touchkey.o 30obj-$(CONFIG_KEYBOARD_MCS) += mcs_touchkey.o
31obj-$(CONFIG_KEYBOARD_MPR121) += mpr121_touchkey.o
30obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o 32obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o
31obj-$(CONFIG_KEYBOARD_NOMADIK) += nomadik-ske-keypad.o 33obj-$(CONFIG_KEYBOARD_NOMADIK) += nomadik-ske-keypad.o
32obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o 34obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o
diff --git a/drivers/input/keyboard/adp5589-keys.c b/drivers/input/keyboard/adp5589-keys.c
new file mode 100644
index 000000000000..631598663aab
--- /dev/null
+++ b/drivers/input/keyboard/adp5589-keys.c
@@ -0,0 +1,771 @@
1/*
2 * Description: keypad driver for ADP5589
3 * I2C QWERTY Keypad and IO Expander
4 * Bugs: Enter bugs at http://blackfin.uclinux.org/
5 *
6 * Copyright (C) 2010-2011 Analog Devices Inc.
7 * Licensed under the GPL-2.
8 */
9
10#include <linux/module.h>
11#include <linux/version.h>
12#include <linux/init.h>
13#include <linux/interrupt.h>
14#include <linux/irq.h>
15#include <linux/workqueue.h>
16#include <linux/errno.h>
17#include <linux/pm.h>
18#include <linux/platform_device.h>
19#include <linux/input.h>
20#include <linux/i2c.h>
21#include <linux/gpio.h>
22#include <linux/slab.h>
23
24#include <linux/input/adp5589.h>
25
26/* GENERAL_CFG Register */
27#define OSC_EN (1 << 7)
28#define CORE_CLK(x) (((x) & 0x3) << 5)
29#define LCK_TRK_LOGIC (1 << 4)
30#define LCK_TRK_GPI (1 << 3)
31#define INT_CFG (1 << 1)
32#define RST_CFG (1 << 0)
33
34/* INT_EN Register */
35#define LOGIC2_IEN (1 << 5)
36#define LOGIC1_IEN (1 << 4)
37#define LOCK_IEN (1 << 3)
38#define OVRFLOW_IEN (1 << 2)
39#define GPI_IEN (1 << 1)
40#define EVENT_IEN (1 << 0)
41
42/* Interrupt Status Register */
43#define LOGIC2_INT (1 << 5)
44#define LOGIC1_INT (1 << 4)
45#define LOCK_INT (1 << 3)
46#define OVRFLOW_INT (1 << 2)
47#define GPI_INT (1 << 1)
48#define EVENT_INT (1 << 0)
49
50/* STATUS Register */
51
52#define LOGIC2_STAT (1 << 7)
53#define LOGIC1_STAT (1 << 6)
54#define LOCK_STAT (1 << 5)
55#define KEC 0xF
56
57/* PIN_CONFIG_D Register */
58#define C4_EXTEND_CFG (1 << 6) /* RESET2 */
59#define R4_EXTEND_CFG (1 << 5) /* RESET1 */
60
61/* LOCK_CFG */
62#define LOCK_EN (1 << 0)
63
64#define PTIME_MASK 0x3
65#define LTIME_MASK 0x3
66
67/* Key Event Register xy */
68#define KEY_EV_PRESSED (1 << 7)
69#define KEY_EV_MASK (0x7F)
70
71#define KEYP_MAX_EVENT 16
72
73#define MAXGPIO 19
74#define ADP_BANK(offs) ((offs) >> 3)
75#define ADP_BIT(offs) (1u << ((offs) & 0x7))
76
77struct adp5589_kpad {
78 struct i2c_client *client;
79 struct input_dev *input;
80 unsigned short keycode[ADP5589_KEYMAPSIZE];
81 const struct adp5589_gpi_map *gpimap;
82 unsigned short gpimapsize;
83 unsigned extend_cfg;
84#ifdef CONFIG_GPIOLIB
85 unsigned char gpiomap[MAXGPIO];
86 bool export_gpio;
87 struct gpio_chip gc;
88 struct mutex gpio_lock; /* Protect cached dir, dat_out */
89 u8 dat_out[3];
90 u8 dir[3];
91#endif
92};
93
94static int adp5589_read(struct i2c_client *client, u8 reg)
95{
96 int ret = i2c_smbus_read_byte_data(client, reg);
97
98 if (ret < 0)
99 dev_err(&client->dev, "Read Error\n");
100
101 return ret;
102}
103
104static int adp5589_write(struct i2c_client *client, u8 reg, u8 val)
105{
106 return i2c_smbus_write_byte_data(client, reg, val);
107}
108
109#ifdef CONFIG_GPIOLIB
110static int adp5589_gpio_get_value(struct gpio_chip *chip, unsigned off)
111{
112 struct adp5589_kpad *kpad = container_of(chip, struct adp5589_kpad, gc);
113 unsigned int bank = ADP_BANK(kpad->gpiomap[off]);
114 unsigned int bit = ADP_BIT(kpad->gpiomap[off]);
115
116 return !!(adp5589_read(kpad->client, ADP5589_GPI_STATUS_A + bank) &
117 bit);
118}
119
120static void adp5589_gpio_set_value(struct gpio_chip *chip,
121 unsigned off, int val)
122{
123 struct adp5589_kpad *kpad = container_of(chip, struct adp5589_kpad, gc);
124 unsigned int bank = ADP_BANK(kpad->gpiomap[off]);
125 unsigned int bit = ADP_BIT(kpad->gpiomap[off]);
126
127 mutex_lock(&kpad->gpio_lock);
128
129 if (val)
130 kpad->dat_out[bank] |= bit;
131 else
132 kpad->dat_out[bank] &= ~bit;
133
134 adp5589_write(kpad->client, ADP5589_GPO_DATA_OUT_A + bank,
135 kpad->dat_out[bank]);
136
137 mutex_unlock(&kpad->gpio_lock);
138}
139
140static int adp5589_gpio_direction_input(struct gpio_chip *chip, unsigned off)
141{
142 struct adp5589_kpad *kpad = container_of(chip, struct adp5589_kpad, gc);
143 unsigned int bank = ADP_BANK(kpad->gpiomap[off]);
144 unsigned int bit = ADP_BIT(kpad->gpiomap[off]);
145 int ret;
146
147 mutex_lock(&kpad->gpio_lock);
148
149 kpad->dir[bank] &= ~bit;
150 ret = adp5589_write(kpad->client, ADP5589_GPIO_DIRECTION_A + bank,
151 kpad->dir[bank]);
152
153 mutex_unlock(&kpad->gpio_lock);
154
155 return ret;
156}
157
158static int adp5589_gpio_direction_output(struct gpio_chip *chip,
159 unsigned off, int val)
160{
161 struct adp5589_kpad *kpad = container_of(chip, struct adp5589_kpad, gc);
162 unsigned int bank = ADP_BANK(kpad->gpiomap[off]);
163 unsigned int bit = ADP_BIT(kpad->gpiomap[off]);
164 int ret;
165
166 mutex_lock(&kpad->gpio_lock);
167
168 kpad->dir[bank] |= bit;
169
170 if (val)
171 kpad->dat_out[bank] |= bit;
172 else
173 kpad->dat_out[bank] &= ~bit;
174
175 ret = adp5589_write(kpad->client, ADP5589_GPO_DATA_OUT_A + bank,
176 kpad->dat_out[bank]);
177 ret |= adp5589_write(kpad->client, ADP5589_GPIO_DIRECTION_A + bank,
178 kpad->dir[bank]);
179
180 mutex_unlock(&kpad->gpio_lock);
181
182 return ret;
183}
184
185static int __devinit adp5589_build_gpiomap(struct adp5589_kpad *kpad,
186 const struct adp5589_kpad_platform_data *pdata)
187{
188 bool pin_used[MAXGPIO];
189 int n_unused = 0;
190 int i;
191
192 memset(pin_used, false, sizeof(pin_used));
193
194 for (i = 0; i < MAXGPIO; i++)
195 if (pdata->keypad_en_mask & (1 << i))
196 pin_used[i] = true;
197
198 for (i = 0; i < kpad->gpimapsize; i++)
199 pin_used[kpad->gpimap[i].pin - ADP5589_GPI_PIN_BASE] = true;
200
201 if (kpad->extend_cfg & R4_EXTEND_CFG)
202 pin_used[4] = true;
203
204 if (kpad->extend_cfg & C4_EXTEND_CFG)
205 pin_used[12] = true;
206
207 for (i = 0; i < MAXGPIO; i++)
208 if (!pin_used[i])
209 kpad->gpiomap[n_unused++] = i;
210
211 return n_unused;
212}
213
214static int __devinit adp5589_gpio_add(struct adp5589_kpad *kpad)
215{
216 struct device *dev = &kpad->client->dev;
217 const struct adp5589_kpad_platform_data *pdata = dev->platform_data;
218 const struct adp5589_gpio_platform_data *gpio_data = pdata->gpio_data;
219 int i, error;
220
221 if (!gpio_data)
222 return 0;
223
224 kpad->gc.ngpio = adp5589_build_gpiomap(kpad, pdata);
225 if (kpad->gc.ngpio == 0) {
226 dev_info(dev, "No unused gpios left to export\n");
227 return 0;
228 }
229
230 kpad->export_gpio = true;
231
232 kpad->gc.direction_input = adp5589_gpio_direction_input;
233 kpad->gc.direction_output = adp5589_gpio_direction_output;
234 kpad->gc.get = adp5589_gpio_get_value;
235 kpad->gc.set = adp5589_gpio_set_value;
236 kpad->gc.can_sleep = 1;
237
238 kpad->gc.base = gpio_data->gpio_start;
239 kpad->gc.label = kpad->client->name;
240 kpad->gc.owner = THIS_MODULE;
241
242 mutex_init(&kpad->gpio_lock);
243
244 error = gpiochip_add(&kpad->gc);
245 if (error) {
246 dev_err(dev, "gpiochip_add failed, err: %d\n", error);
247 return error;
248 }
249
250 for (i = 0; i <= ADP_BANK(MAXGPIO); i++) {
251 kpad->dat_out[i] = adp5589_read(kpad->client,
252 ADP5589_GPO_DATA_OUT_A + i);
253 kpad->dir[i] = adp5589_read(kpad->client,
254 ADP5589_GPIO_DIRECTION_A + i);
255 }
256
257 if (gpio_data->setup) {
258 error = gpio_data->setup(kpad->client,
259 kpad->gc.base, kpad->gc.ngpio,
260 gpio_data->context);
261 if (error)
262 dev_warn(dev, "setup failed, %d\n", error);
263 }
264
265 return 0;
266}
267
268static void __devexit adp5589_gpio_remove(struct adp5589_kpad *kpad)
269{
270 struct device *dev = &kpad->client->dev;
271 const struct adp5589_kpad_platform_data *pdata = dev->platform_data;
272 const struct adp5589_gpio_platform_data *gpio_data = pdata->gpio_data;
273 int error;
274
275 if (!kpad->export_gpio)
276 return;
277
278 if (gpio_data->teardown) {
279 error = gpio_data->teardown(kpad->client,
280 kpad->gc.base, kpad->gc.ngpio,
281 gpio_data->context);
282 if (error)
283 dev_warn(dev, "teardown failed %d\n", error);
284 }
285
286 error = gpiochip_remove(&kpad->gc);
287 if (error)
288 dev_warn(dev, "gpiochip_remove failed %d\n", error);
289}
290#else
291static inline int adp5589_gpio_add(struct adp5589_kpad *kpad)
292{
293 return 0;
294}
295
296static inline void adp5589_gpio_remove(struct adp5589_kpad *kpad)
297{
298}
299#endif
300
301static void adp5589_report_switches(struct adp5589_kpad *kpad,
302 int key, int key_val)
303{
304 int i;
305
306 for (i = 0; i < kpad->gpimapsize; i++) {
307 if (key_val == kpad->gpimap[i].pin) {
308 input_report_switch(kpad->input,
309 kpad->gpimap[i].sw_evt,
310 key & KEY_EV_PRESSED);
311 break;
312 }
313 }
314}
315
316static void adp5589_report_events(struct adp5589_kpad *kpad, int ev_cnt)
317{
318 int i;
319
320 for (i = 0; i < ev_cnt; i++) {
321 int key = adp5589_read(kpad->client, ADP5589_FIFO_1 + i);
322 int key_val = key & KEY_EV_MASK;
323
324 if (key_val >= ADP5589_GPI_PIN_BASE &&
325 key_val <= ADP5589_GPI_PIN_END) {
326 adp5589_report_switches(kpad, key, key_val);
327 } else {
328 input_report_key(kpad->input,
329 kpad->keycode[key_val - 1],
330 key & KEY_EV_PRESSED);
331 }
332 }
333}
334
335static irqreturn_t adp5589_irq(int irq, void *handle)
336{
337 struct adp5589_kpad *kpad = handle;
338 struct i2c_client *client = kpad->client;
339 int status, ev_cnt;
340
341 status = adp5589_read(client, ADP5589_INT_STATUS);
342
343 if (status & OVRFLOW_INT) /* Unlikely and should never happen */
344 dev_err(&client->dev, "Event Overflow Error\n");
345
346 if (status & EVENT_INT) {
347 ev_cnt = adp5589_read(client, ADP5589_STATUS) & KEC;
348 if (ev_cnt) {
349 adp5589_report_events(kpad, ev_cnt);
350 input_sync(kpad->input);
351 }
352 }
353
354 adp5589_write(client, ADP5589_INT_STATUS, status); /* Status is W1C */
355
356 return IRQ_HANDLED;
357}
358
359static int __devinit adp5589_get_evcode(struct adp5589_kpad *kpad, unsigned short key)
360{
361 int i;
362
363 for (i = 0; i < ADP5589_KEYMAPSIZE; i++)
364 if (key == kpad->keycode[i])
365 return (i + 1) | KEY_EV_PRESSED;
366
367 dev_err(&kpad->client->dev, "RESET/UNLOCK key not in keycode map\n");
368
369 return -EINVAL;
370}
371
372static int __devinit adp5589_setup(struct adp5589_kpad *kpad)
373{
374 struct i2c_client *client = kpad->client;
375 const struct adp5589_kpad_platform_data *pdata =
376 client->dev.platform_data;
377 int i, ret;
378 unsigned char evt_mode1 = 0, evt_mode2 = 0, evt_mode3 = 0;
379 unsigned char pull_mask = 0;
380
381 ret = adp5589_write(client, ADP5589_PIN_CONFIG_A,
382 pdata->keypad_en_mask & 0xFF);
383 ret |= adp5589_write(client, ADP5589_PIN_CONFIG_B,
384 (pdata->keypad_en_mask >> 8) & 0xFF);
385 ret |= adp5589_write(client, ADP5589_PIN_CONFIG_C,
386 (pdata->keypad_en_mask >> 16) & 0xFF);
387
388 if (pdata->en_keylock) {
389 ret |= adp5589_write(client, ADP5589_UNLOCK1,
390 pdata->unlock_key1);
391 ret |= adp5589_write(client, ADP5589_UNLOCK2,
392 pdata->unlock_key2);
393 ret |= adp5589_write(client, ADP5589_UNLOCK_TIMERS,
394 pdata->unlock_timer & LTIME_MASK);
395 ret |= adp5589_write(client, ADP5589_LOCK_CFG, LOCK_EN);
396 }
397
398 for (i = 0; i < KEYP_MAX_EVENT; i++)
399 ret |= adp5589_read(client, ADP5589_FIFO_1 + i);
400
401 for (i = 0; i < pdata->gpimapsize; i++) {
402 unsigned short pin = pdata->gpimap[i].pin;
403
404 if (pin <= ADP5589_GPI_PIN_ROW_END) {
405 evt_mode1 |= (1 << (pin - ADP5589_GPI_PIN_ROW_BASE));
406 } else {
407 evt_mode2 |=
408 ((1 << (pin - ADP5589_GPI_PIN_COL_BASE)) & 0xFF);
409 evt_mode3 |=
410 ((1 << (pin - ADP5589_GPI_PIN_COL_BASE)) >> 8);
411 }
412 }
413
414 if (pdata->gpimapsize) {
415 ret |= adp5589_write(client, ADP5589_GPI_EVENT_EN_A, evt_mode1);
416 ret |= adp5589_write(client, ADP5589_GPI_EVENT_EN_B, evt_mode2);
417 ret |= adp5589_write(client, ADP5589_GPI_EVENT_EN_C, evt_mode3);
418 }
419
420 if (pdata->pull_dis_mask & pdata->pullup_en_100k &
421 pdata->pullup_en_300k & pdata->pulldown_en_300k)
422 dev_warn(&client->dev, "Conflicting pull resistor config\n");
423
424 for (i = 0; i < MAXGPIO; i++) {
425 unsigned val = 0;
426
427 if (pdata->pullup_en_300k & (1 << i))
428 val = 0;
429 else if (pdata->pulldown_en_300k & (1 << i))
430 val = 1;
431 else if (pdata->pullup_en_100k & (1 << i))
432 val = 2;
433 else if (pdata->pull_dis_mask & (1 << i))
434 val = 3;
435
436 pull_mask |= val << (2 * (i & 0x3));
437
438 if ((i & 0x3) == 0x3 || i == MAXGPIO - 1) {
439 ret |= adp5589_write(client,
440 ADP5589_RPULL_CONFIG_A + (i >> 2),
441 pull_mask);
442 pull_mask = 0;
443 }
444 }
445
446 if (pdata->reset1_key_1 && pdata->reset1_key_2 && pdata->reset1_key_3) {
447 ret |= adp5589_write(client, ADP5589_RESET1_EVENT_A,
448 adp5589_get_evcode(kpad,
449 pdata->reset1_key_1));
450 ret |= adp5589_write(client, ADP5589_RESET1_EVENT_B,
451 adp5589_get_evcode(kpad,
452 pdata->reset1_key_2));
453 ret |= adp5589_write(client, ADP5589_RESET1_EVENT_C,
454 adp5589_get_evcode(kpad,
455 pdata->reset1_key_3));
456 kpad->extend_cfg |= R4_EXTEND_CFG;
457 }
458
459 if (pdata->reset2_key_1 && pdata->reset2_key_2) {
460 ret |= adp5589_write(client, ADP5589_RESET2_EVENT_A,
461 adp5589_get_evcode(kpad,
462 pdata->reset2_key_1));
463 ret |= adp5589_write(client, ADP5589_RESET2_EVENT_B,
464 adp5589_get_evcode(kpad,
465 pdata->reset2_key_2));
466 kpad->extend_cfg |= C4_EXTEND_CFG;
467 }
468
469 if (kpad->extend_cfg) {
470 ret |= adp5589_write(client, ADP5589_RESET_CFG,
471 pdata->reset_cfg);
472 ret |= adp5589_write(client, ADP5589_PIN_CONFIG_D,
473 kpad->extend_cfg);
474 }
475
476 for (i = 0; i <= ADP_BANK(MAXGPIO); i++)
477 ret |= adp5589_write(client, ADP5589_DEBOUNCE_DIS_A + i,
478 pdata->debounce_dis_mask >> (i * 8));
479
480 ret |= adp5589_write(client, ADP5589_POLL_PTIME_CFG,
481 pdata->scan_cycle_time & PTIME_MASK);
482 ret |= adp5589_write(client, ADP5589_INT_STATUS, LOGIC2_INT |
483 LOGIC1_INT | OVRFLOW_INT | LOCK_INT |
484 GPI_INT | EVENT_INT); /* Status is W1C */
485
486 ret |= adp5589_write(client, ADP5589_GENERAL_CFG,
487 INT_CFG | OSC_EN | CORE_CLK(3));
488 ret |= adp5589_write(client, ADP5589_INT_EN,
489 OVRFLOW_IEN | GPI_IEN | EVENT_IEN);
490
491 if (ret < 0) {
492 dev_err(&client->dev, "Write Error\n");
493 return ret;
494 }
495
496 return 0;
497}
498
499static void __devinit adp5589_report_switch_state(struct adp5589_kpad *kpad)
500{
501 int gpi_stat1 = adp5589_read(kpad->client, ADP5589_GPI_STATUS_A);
502 int gpi_stat2 = adp5589_read(kpad->client, ADP5589_GPI_STATUS_B);
503 int gpi_stat3 = adp5589_read(kpad->client, ADP5589_GPI_STATUS_C);
504 int gpi_stat_tmp, pin_loc;
505 int i;
506
507 for (i = 0; i < kpad->gpimapsize; i++) {
508 unsigned short pin = kpad->gpimap[i].pin;
509
510 if (pin <= ADP5589_GPI_PIN_ROW_END) {
511 gpi_stat_tmp = gpi_stat1;
512 pin_loc = pin - ADP5589_GPI_PIN_ROW_BASE;
513 } else if ((pin - ADP5589_GPI_PIN_COL_BASE) < 8) {
514 gpi_stat_tmp = gpi_stat2;
515 pin_loc = pin - ADP5589_GPI_PIN_COL_BASE;
516 } else {
517 gpi_stat_tmp = gpi_stat3;
518 pin_loc = pin - ADP5589_GPI_PIN_COL_BASE - 8;
519 }
520
521 if (gpi_stat_tmp < 0) {
522 dev_err(&kpad->client->dev,
523 "Can't read GPIO_DAT_STAT switch"
524 " %d default to OFF\n", pin);
525 gpi_stat_tmp = 0;
526 }
527
528 input_report_switch(kpad->input,
529 kpad->gpimap[i].sw_evt,
530 !(gpi_stat_tmp & (1 << pin_loc)));
531 }
532
533 input_sync(kpad->input);
534}
535
536static int __devinit adp5589_probe(struct i2c_client *client,
537 const struct i2c_device_id *id)
538{
539 struct adp5589_kpad *kpad;
540 const struct adp5589_kpad_platform_data *pdata;
541 struct input_dev *input;
542 unsigned int revid;
543 int ret, i;
544 int error;
545
546 if (!i2c_check_functionality(client->adapter,
547 I2C_FUNC_SMBUS_BYTE_DATA)) {
548 dev_err(&client->dev, "SMBUS Byte Data not Supported\n");
549 return -EIO;
550 }
551
552 pdata = client->dev.platform_data;
553 if (!pdata) {
554 dev_err(&client->dev, "no platform data?\n");
555 return -EINVAL;
556 }
557
558 if (!((pdata->keypad_en_mask & 0xFF) &&
559 (pdata->keypad_en_mask >> 8)) || !pdata->keymap) {
560 dev_err(&client->dev, "no rows, cols or keymap from pdata\n");
561 return -EINVAL;
562 }
563
564 if (pdata->keymapsize != ADP5589_KEYMAPSIZE) {
565 dev_err(&client->dev, "invalid keymapsize\n");
566 return -EINVAL;
567 }
568
569 if (!pdata->gpimap && pdata->gpimapsize) {
570 dev_err(&client->dev, "invalid gpimap from pdata\n");
571 return -EINVAL;
572 }
573
574 if (pdata->gpimapsize > ADP5589_GPIMAPSIZE_MAX) {
575 dev_err(&client->dev, "invalid gpimapsize\n");
576 return -EINVAL;
577 }
578
579 for (i = 0; i < pdata->gpimapsize; i++) {
580 unsigned short pin = pdata->gpimap[i].pin;
581
582 if (pin < ADP5589_GPI_PIN_BASE || pin > ADP5589_GPI_PIN_END) {
583 dev_err(&client->dev, "invalid gpi pin data\n");
584 return -EINVAL;
585 }
586
587 if ((1 << (pin - ADP5589_GPI_PIN_ROW_BASE)) &
588 pdata->keypad_en_mask) {
589 dev_err(&client->dev, "invalid gpi row/col data\n");
590 return -EINVAL;
591 }
592 }
593
594 if (!client->irq) {
595 dev_err(&client->dev, "no IRQ?\n");
596 return -EINVAL;
597 }
598
599 kpad = kzalloc(sizeof(*kpad), GFP_KERNEL);
600 input = input_allocate_device();
601 if (!kpad || !input) {
602 error = -ENOMEM;
603 goto err_free_mem;
604 }
605
606 kpad->client = client;
607 kpad->input = input;
608
609 ret = adp5589_read(client, ADP5589_ID);
610 if (ret < 0) {
611 error = ret;
612 goto err_free_mem;
613 }
614
615 revid = (u8) ret & ADP5589_DEVICE_ID_MASK;
616
617 input->name = client->name;
618 input->phys = "adp5589-keys/input0";
619 input->dev.parent = &client->dev;
620
621 input_set_drvdata(input, kpad);
622
623 input->id.bustype = BUS_I2C;
624 input->id.vendor = 0x0001;
625 input->id.product = 0x0001;
626 input->id.version = revid;
627
628 input->keycodesize = sizeof(kpad->keycode[0]);
629 input->keycodemax = pdata->keymapsize;
630 input->keycode = kpad->keycode;
631
632 memcpy(kpad->keycode, pdata->keymap,
633 pdata->keymapsize * input->keycodesize);
634
635 kpad->gpimap = pdata->gpimap;
636 kpad->gpimapsize = pdata->gpimapsize;
637
638 /* setup input device */
639 __set_bit(EV_KEY, input->evbit);
640
641 if (pdata->repeat)
642 __set_bit(EV_REP, input->evbit);
643
644 for (i = 0; i < input->keycodemax; i++)
645 __set_bit(kpad->keycode[i] & KEY_MAX, input->keybit);
646 __clear_bit(KEY_RESERVED, input->keybit);
647
648 if (kpad->gpimapsize)
649 __set_bit(EV_SW, input->evbit);
650 for (i = 0; i < kpad->gpimapsize; i++)
651 __set_bit(kpad->gpimap[i].sw_evt, input->swbit);
652
653 error = input_register_device(input);
654 if (error) {
655 dev_err(&client->dev, "unable to register input device\n");
656 goto err_free_mem;
657 }
658
659 error = request_threaded_irq(client->irq, NULL, adp5589_irq,
660 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
661 client->dev.driver->name, kpad);
662 if (error) {
663 dev_err(&client->dev, "irq %d busy?\n", client->irq);
664 goto err_unreg_dev;
665 }
666
667 error = adp5589_setup(kpad);
668 if (error)
669 goto err_free_irq;
670
671 if (kpad->gpimapsize)
672 adp5589_report_switch_state(kpad);
673
674 error = adp5589_gpio_add(kpad);
675 if (error)
676 goto err_free_irq;
677
678 device_init_wakeup(&client->dev, 1);
679 i2c_set_clientdata(client, kpad);
680
681 dev_info(&client->dev, "Rev.%d keypad, irq %d\n", revid, client->irq);
682 return 0;
683
684err_free_irq:
685 free_irq(client->irq, kpad);
686err_unreg_dev:
687 input_unregister_device(input);
688 input = NULL;
689err_free_mem:
690 input_free_device(input);
691 kfree(kpad);
692
693 return error;
694}
695
696static int __devexit adp5589_remove(struct i2c_client *client)
697{
698 struct adp5589_kpad *kpad = i2c_get_clientdata(client);
699
700 adp5589_write(client, ADP5589_GENERAL_CFG, 0);
701 free_irq(client->irq, kpad);
702 input_unregister_device(kpad->input);
703 adp5589_gpio_remove(kpad);
704 kfree(kpad);
705
706 return 0;
707}
708
709#ifdef CONFIG_PM_SLEEP
710static int adp5589_suspend(struct device *dev)
711{
712 struct adp5589_kpad *kpad = dev_get_drvdata(dev);
713 struct i2c_client *client = kpad->client;
714
715 disable_irq(client->irq);
716
717 if (device_may_wakeup(&client->dev))
718 enable_irq_wake(client->irq);
719
720 return 0;
721}
722
723static int adp5589_resume(struct device *dev)
724{
725 struct adp5589_kpad *kpad = dev_get_drvdata(dev);
726 struct i2c_client *client = kpad->client;
727
728 if (device_may_wakeup(&client->dev))
729 disable_irq_wake(client->irq);
730
731 enable_irq(client->irq);
732
733 return 0;
734}
735#endif
736
737static SIMPLE_DEV_PM_OPS(adp5589_dev_pm_ops, adp5589_suspend, adp5589_resume);
738
739static const struct i2c_device_id adp5589_id[] = {
740 {"adp5589-keys", 0},
741 {}
742};
743
744MODULE_DEVICE_TABLE(i2c, adp5589_id);
745
746static struct i2c_driver adp5589_driver = {
747 .driver = {
748 .name = KBUILD_MODNAME,
749 .owner = THIS_MODULE,
750 .pm = &adp5589_dev_pm_ops,
751 },
752 .probe = adp5589_probe,
753 .remove = __devexit_p(adp5589_remove),
754 .id_table = adp5589_id,
755};
756
757static int __init adp5589_init(void)
758{
759 return i2c_add_driver(&adp5589_driver);
760}
761module_init(adp5589_init);
762
763static void __exit adp5589_exit(void)
764{
765 i2c_del_driver(&adp5589_driver);
766}
767module_exit(adp5589_exit);
768
769MODULE_LICENSE("GPL");
770MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
771MODULE_DESCRIPTION("ADP5589 Keypad driver");
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index eb3006361ee4..6e6145b9a4c1 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -324,7 +324,12 @@ static void gpio_keys_report_event(struct gpio_button_data *bdata)
324 unsigned int type = button->type ?: EV_KEY; 324 unsigned int type = button->type ?: EV_KEY;
325 int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low; 325 int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low;
326 326
327 input_event(input, type, button->code, !!state); 327 if (type == EV_ABS) {
328 if (state)
329 input_event(input, type, button->code, button->value);
330 } else {
331 input_event(input, type, button->code, !!state);
332 }
328 input_sync(input); 333 input_sync(input);
329} 334}
330 335
@@ -363,7 +368,7 @@ static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
363 struct gpio_button_data *bdata, 368 struct gpio_button_data *bdata,
364 struct gpio_keys_button *button) 369 struct gpio_keys_button *button)
365{ 370{
366 char *desc = button->desc ? button->desc : "gpio_keys"; 371 const char *desc = button->desc ? button->desc : "gpio_keys";
367 struct device *dev = &pdev->dev; 372 struct device *dev = &pdev->dev;
368 unsigned long irqflags; 373 unsigned long irqflags;
369 int irq, error; 374 int irq, error;
@@ -468,7 +473,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
468 platform_set_drvdata(pdev, ddata); 473 platform_set_drvdata(pdev, ddata);
469 input_set_drvdata(input, ddata); 474 input_set_drvdata(input, ddata);
470 475
471 input->name = pdev->name; 476 input->name = pdata->name ? : pdev->name;
472 input->phys = "gpio-keys/input0"; 477 input->phys = "gpio-keys/input0";
473 input->dev.parent = &pdev->dev; 478 input->dev.parent = &pdev->dev;
474 input->open = gpio_keys_open; 479 input->open = gpio_keys_open;
diff --git a/drivers/input/keyboard/mpr121_touchkey.c b/drivers/input/keyboard/mpr121_touchkey.c
new file mode 100644
index 000000000000..0a9e81194888
--- /dev/null
+++ b/drivers/input/keyboard/mpr121_touchkey.c
@@ -0,0 +1,339 @@
1/*
2 * Touchkey driver for Freescale MPR121 Controllor
3 *
4 * Copyright (C) 2011 Freescale Semiconductor, Inc.
5 * Author: Zhang Jiejing <jiejing.zhang@freescale.com>
6 *
7 * Based on mcs_touchkey.c
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 */
14
15#include <linux/module.h>
16#include <linux/init.h>
17#include <linux/input.h>
18#include <linux/i2c.h>
19#include <linux/slab.h>
20#include <linux/delay.h>
21#include <linux/bitops.h>
22#include <linux/interrupt.h>
23#include <linux/i2c/mpr121_touchkey.h>
24
25/* Register definitions */
26#define ELE_TOUCH_STATUS_0_ADDR 0x0
27#define ELE_TOUCH_STATUS_1_ADDR 0X1
28#define MHD_RISING_ADDR 0x2b
29#define NHD_RISING_ADDR 0x2c
30#define NCL_RISING_ADDR 0x2d
31#define FDL_RISING_ADDR 0x2e
32#define MHD_FALLING_ADDR 0x2f
33#define NHD_FALLING_ADDR 0x30
34#define NCL_FALLING_ADDR 0x31
35#define FDL_FALLING_ADDR 0x32
36#define ELE0_TOUCH_THRESHOLD_ADDR 0x41
37#define ELE0_RELEASE_THRESHOLD_ADDR 0x42
38#define AFE_CONF_ADDR 0x5c
39#define FILTER_CONF_ADDR 0x5d
40
41/*
42 * ELECTRODE_CONF_ADDR: This register configures the number of
43 * enabled capacitance sensing inputs and its run/suspend mode.
44 */
45#define ELECTRODE_CONF_ADDR 0x5e
46#define AUTO_CONFIG_CTRL_ADDR 0x7b
47#define AUTO_CONFIG_USL_ADDR 0x7d
48#define AUTO_CONFIG_LSL_ADDR 0x7e
49#define AUTO_CONFIG_TL_ADDR 0x7f
50
51/* Threshold of touch/release trigger */
52#define TOUCH_THRESHOLD 0x0f
53#define RELEASE_THRESHOLD 0x0a
54/* Masks for touch and release triggers */
55#define TOUCH_STATUS_MASK 0xfff
56/* MPR121 has 12 keys */
57#define MPR121_MAX_KEY_COUNT 12
58
59struct mpr121_touchkey {
60 struct i2c_client *client;
61 struct input_dev *input_dev;
62 unsigned int key_val;
63 unsigned int statusbits;
64 unsigned int keycount;
65 u16 keycodes[MPR121_MAX_KEY_COUNT];
66};
67
68struct mpr121_init_register {
69 int addr;
70 u8 val;
71};
72
73static const struct mpr121_init_register init_reg_table[] __devinitconst = {
74 { MHD_RISING_ADDR, 0x1 },
75 { NHD_RISING_ADDR, 0x1 },
76 { MHD_FALLING_ADDR, 0x1 },
77 { NHD_FALLING_ADDR, 0x1 },
78 { NCL_FALLING_ADDR, 0xff },
79 { FDL_FALLING_ADDR, 0x02 },
80 { FILTER_CONF_ADDR, 0x04 },
81 { AFE_CONF_ADDR, 0x0b },
82 { AUTO_CONFIG_CTRL_ADDR, 0x0b },
83};
84
85static irqreturn_t mpr_touchkey_interrupt(int irq, void *dev_id)
86{
87 struct mpr121_touchkey *mpr121 = dev_id;
88 struct i2c_client *client = mpr121->client;
89 struct input_dev *input = mpr121->input_dev;
90 unsigned int key_num, key_val, pressed;
91 int reg;
92
93 reg = i2c_smbus_read_byte_data(client, ELE_TOUCH_STATUS_1_ADDR);
94 if (reg < 0) {
95 dev_err(&client->dev, "i2c read error [%d]\n", reg);
96 goto out;
97 }
98
99 reg <<= 8;
100 reg |= i2c_smbus_read_byte_data(client, ELE_TOUCH_STATUS_0_ADDR);
101 if (reg < 0) {
102 dev_err(&client->dev, "i2c read error [%d]\n", reg);
103 goto out;
104 }
105
106 reg &= TOUCH_STATUS_MASK;
107 /* use old press bit to figure out which bit changed */
108 key_num = ffs(reg ^ mpr121->statusbits) - 1;
109 pressed = reg & (1 << key_num);
110 mpr121->statusbits = reg;
111
112 key_val = mpr121->keycodes[key_num];
113
114 input_event(input, EV_MSC, MSC_SCAN, key_num);
115 input_report_key(input, key_val, pressed);
116 input_sync(input);
117
118 dev_dbg(&client->dev, "key %d %d %s\n", key_num, key_val,
119 pressed ? "pressed" : "released");
120
121out:
122 return IRQ_HANDLED;
123}
124
125static int __devinit mpr121_phys_init(const struct mpr121_platform_data *pdata,
126 struct mpr121_touchkey *mpr121,
127 struct i2c_client *client)
128{
129 const struct mpr121_init_register *reg;
130 unsigned char usl, lsl, tl;
131 int i, t, vdd, ret;
132
133 /* Set up touch/release threshold for ele0-ele11 */
134 for (i = 0; i <= MPR121_MAX_KEY_COUNT; i++) {
135 t = ELE0_TOUCH_THRESHOLD_ADDR + (i * 2);
136 ret = i2c_smbus_write_byte_data(client, t, TOUCH_THRESHOLD);
137 if (ret < 0)
138 goto err_i2c_write;
139 ret = i2c_smbus_write_byte_data(client, t + 1,
140 RELEASE_THRESHOLD);
141 if (ret < 0)
142 goto err_i2c_write;
143 }
144
145 /* Set up init register */
146 for (i = 0; i < ARRAY_SIZE(init_reg_table); i++) {
147 reg = &init_reg_table[i];
148 ret = i2c_smbus_write_byte_data(client, reg->addr, reg->val);
149 if (ret < 0)
150 goto err_i2c_write;
151 }
152
153
154 /*
155 * Capacitance on sensing input varies and needs to be compensated.
156 * The internal MPR121-auto-configuration can do this if it's
157 * registers are set properly (based on pdata->vdd_uv).
158 */
159 vdd = pdata->vdd_uv / 1000;
160 usl = ((vdd - 700) * 256) / vdd;
161 lsl = (usl * 65) / 100;
162 tl = (usl * 90) / 100;
163 ret = i2c_smbus_write_byte_data(client, AUTO_CONFIG_USL_ADDR, usl);
164 ret |= i2c_smbus_write_byte_data(client, AUTO_CONFIG_LSL_ADDR, lsl);
165 ret |= i2c_smbus_write_byte_data(client, AUTO_CONFIG_TL_ADDR, tl);
166 ret |= i2c_smbus_write_byte_data(client, ELECTRODE_CONF_ADDR,
167 mpr121->keycount);
168 if (ret != 0)
169 goto err_i2c_write;
170
171 dev_dbg(&client->dev, "set up with %x keys.\n", mpr121->keycount);
172
173 return 0;
174
175err_i2c_write:
176 dev_err(&client->dev, "i2c write error: %d\n", ret);
177 return ret;
178}
179
180static int __devinit mpr_touchkey_probe(struct i2c_client *client,
181 const struct i2c_device_id *id)
182{
183 const struct mpr121_platform_data *pdata = client->dev.platform_data;
184 struct mpr121_touchkey *mpr121;
185 struct input_dev *input_dev;
186 int error;
187 int i;
188
189 if (!pdata) {
190 dev_err(&client->dev, "no platform data defined\n");
191 return -EINVAL;
192 }
193
194 if (!pdata->keymap || !pdata->keymap_size) {
195 dev_err(&client->dev, "missing keymap data\n");
196 return -EINVAL;
197 }
198
199 if (pdata->keymap_size > MPR121_MAX_KEY_COUNT) {
200 dev_err(&client->dev, "too many keys defined\n");
201 return -EINVAL;
202 }
203
204 if (!client->irq) {
205 dev_err(&client->dev, "irq number should not be zero\n");
206 return -EINVAL;
207 }
208
209 mpr121 = kzalloc(sizeof(struct mpr121_touchkey), GFP_KERNEL);
210 input_dev = input_allocate_device();
211 if (!mpr121 || !input_dev) {
212 dev_err(&client->dev, "Failed to allocate memory\n");
213 error = -ENOMEM;
214 goto err_free_mem;
215 }
216
217 mpr121->client = client;
218 mpr121->input_dev = input_dev;
219 mpr121->keycount = pdata->keymap_size;
220
221 input_dev->name = "Freescale MPR121 Touchkey";
222 input_dev->id.bustype = BUS_I2C;
223 input_dev->dev.parent = &client->dev;
224 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
225
226 input_dev->keycode = mpr121->keycodes;
227 input_dev->keycodesize = sizeof(mpr121->keycodes[0]);
228 input_dev->keycodemax = mpr121->keycount;
229
230 for (i = 0; i < pdata->keymap_size; i++) {
231 input_set_capability(input_dev, EV_KEY, pdata->keymap[i]);
232 mpr121->keycodes[i] = pdata->keymap[i];
233 }
234
235 error = mpr121_phys_init(pdata, mpr121, client);
236 if (error) {
237 dev_err(&client->dev, "Failed to init register\n");
238 goto err_free_mem;
239 }
240
241 error = request_threaded_irq(client->irq, NULL,
242 mpr_touchkey_interrupt,
243 IRQF_TRIGGER_FALLING,
244 client->dev.driver->name, mpr121);
245 if (error) {
246 dev_err(&client->dev, "Failed to register interrupt\n");
247 goto err_free_mem;
248 }
249
250 error = input_register_device(input_dev);
251 if (error)
252 goto err_free_irq;
253
254 i2c_set_clientdata(client, mpr121);
255 device_init_wakeup(&client->dev, pdata->wakeup);
256
257 return 0;
258
259err_free_irq:
260 free_irq(client->irq, mpr121);
261err_free_mem:
262 input_free_device(input_dev);
263 kfree(mpr121);
264 return error;
265}
266
267static int __devexit mpr_touchkey_remove(struct i2c_client *client)
268{
269 struct mpr121_touchkey *mpr121 = i2c_get_clientdata(client);
270
271 free_irq(client->irq, mpr121);
272 input_unregister_device(mpr121->input_dev);
273 kfree(mpr121);
274
275 return 0;
276}
277
278#ifdef CONFIG_PM_SLEEP
279static int mpr_suspend(struct device *dev)
280{
281 struct i2c_client *client = to_i2c_client(dev);
282
283 if (device_may_wakeup(&client->dev))
284 enable_irq_wake(client->irq);
285
286 i2c_smbus_write_byte_data(client, ELECTRODE_CONF_ADDR, 0x00);
287
288 return 0;
289}
290
291static int mpr_resume(struct device *dev)
292{
293 struct i2c_client *client = to_i2c_client(dev);
294 struct mpr121_touchkey *mpr121 = i2c_get_clientdata(client);
295
296 if (device_may_wakeup(&client->dev))
297 disable_irq_wake(client->irq);
298
299 i2c_smbus_write_byte_data(client, ELECTRODE_CONF_ADDR,
300 mpr121->keycount);
301
302 return 0;
303}
304#endif
305
306static SIMPLE_DEV_PM_OPS(mpr121_touchkey_pm_ops, mpr_suspend, mpr_resume);
307
308static const struct i2c_device_id mpr121_id[] = {
309 { "mpr121_touchkey", 0 },
310 { }
311};
312MODULE_DEVICE_TABLE(i2c, mpr121_id);
313
314static struct i2c_driver mpr_touchkey_driver = {
315 .driver = {
316 .name = "mpr121",
317 .owner = THIS_MODULE,
318 .pm = &mpr121_touchkey_pm_ops,
319 },
320 .id_table = mpr121_id,
321 .probe = mpr_touchkey_probe,
322 .remove = __devexit_p(mpr_touchkey_remove),
323};
324
325static int __init mpr_touchkey_init(void)
326{
327 return i2c_add_driver(&mpr_touchkey_driver);
328}
329module_init(mpr_touchkey_init);
330
331static void __exit mpr_touchkey_exit(void)
332{
333 i2c_del_driver(&mpr_touchkey_driver);
334}
335module_exit(mpr_touchkey_exit);
336
337MODULE_LICENSE("GPL");
338MODULE_AUTHOR("Zhang Jiejing <jiejing.zhang@freescale.com>");
339MODULE_DESCRIPTION("Touch Key driver for Freescale MPR121 Chip");
diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c
index 0e2a19cb43d8..f23a743817db 100644
--- a/drivers/input/keyboard/omap-keypad.c
+++ b/drivers/input/keyboard/omap-keypad.c
@@ -413,7 +413,7 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
413 return 0; 413 return 0;
414err5: 414err5:
415 for (i = irq_idx - 1; i >=0; i--) 415 for (i = irq_idx - 1; i >=0; i--)
416 free_irq(row_gpios[i], NULL); 416 free_irq(row_gpios[i], omap_kp);
417err4: 417err4:
418 input_unregister_device(omap_kp->input); 418 input_unregister_device(omap_kp->input);
419 input_dev = NULL; 419 input_dev = NULL;
@@ -444,11 +444,11 @@ static int __devexit omap_kp_remove(struct platform_device *pdev)
444 gpio_free(col_gpios[i]); 444 gpio_free(col_gpios[i]);
445 for (i = 0; i < omap_kp->rows; i++) { 445 for (i = 0; i < omap_kp->rows; i++) {
446 gpio_free(row_gpios[i]); 446 gpio_free(row_gpios[i]);
447 free_irq(gpio_to_irq(row_gpios[i]), NULL); 447 free_irq(gpio_to_irq(row_gpios[i]), omap_kp);
448 } 448 }
449 } else { 449 } else {
450 omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT); 450 omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
451 free_irq(omap_kp->irq, NULL); 451 free_irq(omap_kp->irq, omap_kp);
452 } 452 }
453 453
454 del_timer_sync(&omap_kp->timer); 454 del_timer_sync(&omap_kp->timer);
diff --git a/drivers/input/keyboard/qt1070.c b/drivers/input/keyboard/qt1070.c
index fba8404c7297..ca7b89196ab7 100644
--- a/drivers/input/keyboard/qt1070.c
+++ b/drivers/input/keyboard/qt1070.c
@@ -248,6 +248,7 @@ static const struct i2c_device_id qt1070_id[] = {
248 { "qt1070", 0 }, 248 { "qt1070", 0 },
249 { }, 249 { },
250}; 250};
251MODULE_DEVICE_TABLE(i2c, qt1070_id);
251 252
252static struct i2c_driver qt1070_driver = { 253static struct i2c_driver qt1070_driver = {
253 .driver = { 254 .driver = {
diff --git a/drivers/input/keyboard/sh_keysc.c b/drivers/input/keyboard/sh_keysc.c
index d7dafd9425b6..834cf98e7efb 100644
--- a/drivers/input/keyboard/sh_keysc.c
+++ b/drivers/input/keyboard/sh_keysc.c
@@ -20,7 +20,7 @@
20#include <linux/input.h> 20#include <linux/input.h>
21#include <linux/input/sh_keysc.h> 21#include <linux/input/sh_keysc.h>
22#include <linux/bitmap.h> 22#include <linux/bitmap.h>
23#include <linux/clk.h> 23#include <linux/pm_runtime.h>
24#include <linux/io.h> 24#include <linux/io.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26 26
@@ -37,7 +37,6 @@ static const struct {
37 37
38struct sh_keysc_priv { 38struct sh_keysc_priv {
39 void __iomem *iomem_base; 39 void __iomem *iomem_base;
40 struct clk *clk;
41 DECLARE_BITMAP(last_keys, SH_KEYSC_MAXKEYS); 40 DECLARE_BITMAP(last_keys, SH_KEYSC_MAXKEYS);
42 struct input_dev *input; 41 struct input_dev *input;
43 struct sh_keysc_info pdata; 42 struct sh_keysc_info pdata;
@@ -169,7 +168,6 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev)
169 struct sh_keysc_info *pdata; 168 struct sh_keysc_info *pdata;
170 struct resource *res; 169 struct resource *res;
171 struct input_dev *input; 170 struct input_dev *input;
172 char clk_name[8];
173 int i; 171 int i;
174 int irq, error; 172 int irq, error;
175 173
@@ -210,19 +208,11 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev)
210 goto err1; 208 goto err1;
211 } 209 }
212 210
213 snprintf(clk_name, sizeof(clk_name), "keysc%d", pdev->id);
214 priv->clk = clk_get(&pdev->dev, clk_name);
215 if (IS_ERR(priv->clk)) {
216 dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name);
217 error = PTR_ERR(priv->clk);
218 goto err2;
219 }
220
221 priv->input = input_allocate_device(); 211 priv->input = input_allocate_device();
222 if (!priv->input) { 212 if (!priv->input) {
223 dev_err(&pdev->dev, "failed to allocate input device\n"); 213 dev_err(&pdev->dev, "failed to allocate input device\n");
224 error = -ENOMEM; 214 error = -ENOMEM;
225 goto err3; 215 goto err2;
226 } 216 }
227 217
228 input = priv->input; 218 input = priv->input;
@@ -241,10 +231,11 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev)
241 input->keycodesize = sizeof(pdata->keycodes[0]); 231 input->keycodesize = sizeof(pdata->keycodes[0]);
242 input->keycodemax = ARRAY_SIZE(pdata->keycodes); 232 input->keycodemax = ARRAY_SIZE(pdata->keycodes);
243 233
244 error = request_irq(irq, sh_keysc_isr, 0, pdev->name, pdev); 234 error = request_threaded_irq(irq, NULL, sh_keysc_isr, IRQF_ONESHOT,
235 dev_name(&pdev->dev), pdev);
245 if (error) { 236 if (error) {
246 dev_err(&pdev->dev, "failed to request IRQ\n"); 237 dev_err(&pdev->dev, "failed to request IRQ\n");
247 goto err4; 238 goto err3;
248 } 239 }
249 240
250 for (i = 0; i < SH_KEYSC_MAXKEYS; i++) 241 for (i = 0; i < SH_KEYSC_MAXKEYS; i++)
@@ -254,10 +245,11 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev)
254 error = input_register_device(input); 245 error = input_register_device(input);
255 if (error) { 246 if (error) {
256 dev_err(&pdev->dev, "failed to register input device\n"); 247 dev_err(&pdev->dev, "failed to register input device\n");
257 goto err5; 248 goto err4;
258 } 249 }
259 250
260 clk_enable(priv->clk); 251 pm_runtime_enable(&pdev->dev);
252 pm_runtime_get_sync(&pdev->dev);
261 253
262 sh_keysc_write(priv, KYCR1, (sh_keysc_mode[pdata->mode].kymd << 8) | 254 sh_keysc_write(priv, KYCR1, (sh_keysc_mode[pdata->mode].kymd << 8) |
263 pdata->scan_timing); 255 pdata->scan_timing);
@@ -267,12 +259,10 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev)
267 259
268 return 0; 260 return 0;
269 261
270 err5:
271 free_irq(irq, pdev);
272 err4: 262 err4:
273 input_free_device(input); 263 free_irq(irq, pdev);
274 err3: 264 err3:
275 clk_put(priv->clk); 265 input_free_device(input);
276 err2: 266 err2:
277 iounmap(priv->iomem_base); 267 iounmap(priv->iomem_base);
278 err1: 268 err1:
@@ -292,8 +282,8 @@ static int __devexit sh_keysc_remove(struct platform_device *pdev)
292 free_irq(platform_get_irq(pdev, 0), pdev); 282 free_irq(platform_get_irq(pdev, 0), pdev);
293 iounmap(priv->iomem_base); 283 iounmap(priv->iomem_base);
294 284
295 clk_disable(priv->clk); 285 pm_runtime_put_sync(&pdev->dev);
296 clk_put(priv->clk); 286 pm_runtime_disable(&pdev->dev);
297 287
298 platform_set_drvdata(pdev, NULL); 288 platform_set_drvdata(pdev, NULL);
299 kfree(priv); 289 kfree(priv);
@@ -301,6 +291,7 @@ static int __devexit sh_keysc_remove(struct platform_device *pdev)
301 return 0; 291 return 0;
302} 292}
303 293
294#if CONFIG_PM_SLEEP
304static int sh_keysc_suspend(struct device *dev) 295static int sh_keysc_suspend(struct device *dev)
305{ 296{
306 struct platform_device *pdev = to_platform_device(dev); 297 struct platform_device *pdev = to_platform_device(dev);
@@ -311,14 +302,13 @@ static int sh_keysc_suspend(struct device *dev)
311 value = sh_keysc_read(priv, KYCR1); 302 value = sh_keysc_read(priv, KYCR1);
312 303
313 if (device_may_wakeup(dev)) { 304 if (device_may_wakeup(dev)) {
314 value |= 0x80; 305 sh_keysc_write(priv, KYCR1, value | 0x80);
315 enable_irq_wake(irq); 306 enable_irq_wake(irq);
316 } else { 307 } else {
317 value &= ~0x80; 308 sh_keysc_write(priv, KYCR1, value & ~0x80);
309 pm_runtime_put_sync(dev);
318 } 310 }
319 311
320 sh_keysc_write(priv, KYCR1, value);
321
322 return 0; 312 return 0;
323} 313}
324 314
@@ -329,16 +319,17 @@ static int sh_keysc_resume(struct device *dev)
329 319
330 if (device_may_wakeup(dev)) 320 if (device_may_wakeup(dev))
331 disable_irq_wake(irq); 321 disable_irq_wake(irq);
322 else
323 pm_runtime_get_sync(dev);
332 324
333 return 0; 325 return 0;
334} 326}
327#endif
335 328
336static const struct dev_pm_ops sh_keysc_dev_pm_ops = { 329static SIMPLE_DEV_PM_OPS(sh_keysc_dev_pm_ops,
337 .suspend = sh_keysc_suspend, 330 sh_keysc_suspend, sh_keysc_resume);
338 .resume = sh_keysc_resume,
339};
340 331
341struct platform_driver sh_keysc_device_driver = { 332static struct platform_driver sh_keysc_device_driver = {
342 .probe = sh_keysc_probe, 333 .probe = sh_keysc_probe,
343 .remove = __devexit_p(sh_keysc_remove), 334 .remove = __devexit_p(sh_keysc_remove),
344 .driver = { 335 .driver = {
diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c
index 99ce9032d08c..2b3b73ec6689 100644
--- a/drivers/input/keyboard/tegra-kbc.c
+++ b/drivers/input/keyboard/tegra-kbc.c
@@ -66,12 +66,11 @@ struct tegra_kbc {
66 void __iomem *mmio; 66 void __iomem *mmio;
67 struct input_dev *idev; 67 struct input_dev *idev;
68 unsigned int irq; 68 unsigned int irq;
69 unsigned int wake_enable_rows;
70 unsigned int wake_enable_cols;
71 spinlock_t lock; 69 spinlock_t lock;
72 unsigned int repoll_dly; 70 unsigned int repoll_dly;
73 unsigned long cp_dly_jiffies; 71 unsigned long cp_dly_jiffies;
74 bool use_fn_map; 72 bool use_fn_map;
73 bool use_ghost_filter;
75 const struct tegra_kbc_platform_data *pdata; 74 const struct tegra_kbc_platform_data *pdata;
76 unsigned short keycode[KBC_MAX_KEY * 2]; 75 unsigned short keycode[KBC_MAX_KEY * 2];
77 unsigned short current_keys[KBC_MAX_KPENT]; 76 unsigned short current_keys[KBC_MAX_KPENT];
@@ -260,6 +259,8 @@ static void tegra_kbc_report_keys(struct tegra_kbc *kbc)
260 unsigned int num_down = 0; 259 unsigned int num_down = 0;
261 unsigned long flags; 260 unsigned long flags;
262 bool fn_keypress = false; 261 bool fn_keypress = false;
262 bool key_in_same_row = false;
263 bool key_in_same_col = false;
263 264
264 spin_lock_irqsave(&kbc->lock, flags); 265 spin_lock_irqsave(&kbc->lock, flags);
265 for (i = 0; i < KBC_MAX_KPENT; i++) { 266 for (i = 0; i < KBC_MAX_KPENT; i++) {
@@ -285,6 +286,34 @@ static void tegra_kbc_report_keys(struct tegra_kbc *kbc)
285 } 286 }
286 287
287 /* 288 /*
289 * Matrix keyboard designs are prone to keyboard ghosting.
290 * Ghosting occurs if there are 3 keys such that -
291 * any 2 of the 3 keys share a row, and any 2 of them share a column.
292 * If so ignore the key presses for this iteration.
293 */
294 if ((kbc->use_ghost_filter) && (num_down >= 3)) {
295 for (i = 0; i < num_down; i++) {
296 unsigned int j;
297 u8 curr_col = scancodes[i] & 0x07;
298 u8 curr_row = scancodes[i] >> KBC_ROW_SHIFT;
299
300 /*
301 * Find 2 keys such that one key is in the same row
302 * and the other is in the same column as the i-th key.
303 */
304 for (j = i + 1; j < num_down; j++) {
305 u8 col = scancodes[j] & 0x07;
306 u8 row = scancodes[j] >> KBC_ROW_SHIFT;
307
308 if (col == curr_col)
309 key_in_same_col = true;
310 if (row == curr_row)
311 key_in_same_row = true;
312 }
313 }
314 }
315
316 /*
288 * If the platform uses Fn keymaps, translate keys on a Fn keypress. 317 * If the platform uses Fn keymaps, translate keys on a Fn keypress.
289 * Function keycodes are KBC_MAX_KEY apart from the plain keycodes. 318 * Function keycodes are KBC_MAX_KEY apart from the plain keycodes.
290 */ 319 */
@@ -297,6 +326,10 @@ static void tegra_kbc_report_keys(struct tegra_kbc *kbc)
297 326
298 spin_unlock_irqrestore(&kbc->lock, flags); 327 spin_unlock_irqrestore(&kbc->lock, flags);
299 328
329 /* Ignore the key presses for this iteration? */
330 if (key_in_same_col && key_in_same_row)
331 return;
332
300 tegra_kbc_report_released_keys(kbc->idev, 333 tegra_kbc_report_released_keys(kbc->idev,
301 kbc->current_keys, kbc->num_pressed_keys, 334 kbc->current_keys, kbc->num_pressed_keys,
302 keycodes, num_down); 335 keycodes, num_down);
@@ -383,21 +416,11 @@ static void tegra_kbc_setup_wakekeys(struct tegra_kbc *kbc, bool filter)
383 int i; 416 int i;
384 unsigned int rst_val; 417 unsigned int rst_val;
385 418
386 BUG_ON(pdata->wake_cnt > KBC_MAX_KEY); 419 /* Either mask all keys or none. */
387 rst_val = (filter && pdata->wake_cnt) ? ~0 : 0; 420 rst_val = (filter && !pdata->wakeup) ? ~0 : 0;
388 421
389 for (i = 0; i < KBC_MAX_ROW; i++) 422 for (i = 0; i < KBC_MAX_ROW; i++)
390 writel(rst_val, kbc->mmio + KBC_ROW0_MASK_0 + i * 4); 423 writel(rst_val, kbc->mmio + KBC_ROW0_MASK_0 + i * 4);
391
392 if (filter) {
393 for (i = 0; i < pdata->wake_cnt; i++) {
394 u32 val, addr;
395 addr = pdata->wake_cfg[i].row * 4 + KBC_ROW0_MASK_0;
396 val = readl(kbc->mmio + addr);
397 val &= ~(1 << pdata->wake_cfg[i].col);
398 writel(val, kbc->mmio + addr);
399 }
400 }
401} 424}
402 425
403static void tegra_kbc_config_pins(struct tegra_kbc *kbc) 426static void tegra_kbc_config_pins(struct tegra_kbc *kbc)
@@ -559,7 +582,6 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev)
559 struct resource *res; 582 struct resource *res;
560 int irq; 583 int irq;
561 int err; 584 int err;
562 int i;
563 int num_rows = 0; 585 int num_rows = 0;
564 unsigned int debounce_cnt; 586 unsigned int debounce_cnt;
565 unsigned int scan_time_rows; 587 unsigned int scan_time_rows;
@@ -616,13 +638,6 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev)
616 goto err_iounmap; 638 goto err_iounmap;
617 } 639 }
618 640
619 kbc->wake_enable_rows = 0;
620 kbc->wake_enable_cols = 0;
621 for (i = 0; i < pdata->wake_cnt; i++) {
622 kbc->wake_enable_rows |= (1 << pdata->wake_cfg[i].row);
623 kbc->wake_enable_cols |= (1 << pdata->wake_cfg[i].col);
624 }
625
626 /* 641 /*
627 * The time delay between two consecutive reads of the FIFO is 642 * The time delay between two consecutive reads of the FIFO is
628 * the sum of the repeat time and the time taken for scanning 643 * the sum of the repeat time and the time taken for scanning
@@ -652,6 +667,7 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev)
652 input_dev->keycodemax *= 2; 667 input_dev->keycodemax *= 2;
653 668
654 kbc->use_fn_map = pdata->use_fn_map; 669 kbc->use_fn_map = pdata->use_fn_map;
670 kbc->use_ghost_filter = pdata->use_ghost_filter;
655 keymap_data = pdata->keymap_data ?: &tegra_kbc_default_keymap_data; 671 keymap_data = pdata->keymap_data ?: &tegra_kbc_default_keymap_data;
656 matrix_keypad_build_keymap(keymap_data, KBC_ROW_SHIFT, 672 matrix_keypad_build_keymap(keymap_data, KBC_ROW_SHIFT,
657 input_dev->keycode, input_dev->keybit); 673 input_dev->keycode, input_dev->keybit);
diff --git a/drivers/input/misc/ad714x.c b/drivers/input/misc/ad714x.c
index c431d09e401a..c3a62c42cd28 100644
--- a/drivers/input/misc/ad714x.c
+++ b/drivers/input/misc/ad714x.c
@@ -79,13 +79,7 @@ struct ad714x_slider_drv {
79struct ad714x_wheel_drv { 79struct ad714x_wheel_drv {
80 int abs_pos; 80 int abs_pos;
81 int flt_pos; 81 int flt_pos;
82 int pre_mean_value;
83 int pre_highest_stage; 82 int pre_highest_stage;
84 int pre_mean_value_no_offset;
85 int mean_value;
86 int mean_value_no_offset;
87 int pos_offset;
88 int pos_ratio;
89 int highest_stage; 83 int highest_stage;
90 enum ad714x_device_state state; 84 enum ad714x_device_state state;
91 struct input_dev *input; 85 struct input_dev *input;
@@ -158,10 +152,10 @@ static void ad714x_use_com_int(struct ad714x_chip *ad714x,
158 unsigned short data; 152 unsigned short data;
159 unsigned short mask; 153 unsigned short mask;
160 154
161 mask = ((1 << (end_stage + 1)) - 1) - (1 << start_stage); 155 mask = ((1 << (end_stage + 1)) - 1) - ((1 << start_stage) - 1);
162 156
163 ad714x->read(ad714x->dev, STG_COM_INT_EN_REG, &data); 157 ad714x->read(ad714x->dev, STG_COM_INT_EN_REG, &data);
164 data |= 1 << start_stage; 158 data |= 1 << end_stage;
165 ad714x->write(ad714x->dev, STG_COM_INT_EN_REG, data); 159 ad714x->write(ad714x->dev, STG_COM_INT_EN_REG, data);
166 160
167 ad714x->read(ad714x->dev, STG_HIGH_INT_EN_REG, &data); 161 ad714x->read(ad714x->dev, STG_HIGH_INT_EN_REG, &data);
@@ -175,10 +169,10 @@ static void ad714x_use_thr_int(struct ad714x_chip *ad714x,
175 unsigned short data; 169 unsigned short data;
176 unsigned short mask; 170 unsigned short mask;
177 171
178 mask = ((1 << (end_stage + 1)) - 1) - (1 << start_stage); 172 mask = ((1 << (end_stage + 1)) - 1) - ((1 << start_stage) - 1);
179 173
180 ad714x->read(ad714x->dev, STG_COM_INT_EN_REG, &data); 174 ad714x->read(ad714x->dev, STG_COM_INT_EN_REG, &data);
181 data &= ~(1 << start_stage); 175 data &= ~(1 << end_stage);
182 ad714x->write(ad714x->dev, STG_COM_INT_EN_REG, data); 176 ad714x->write(ad714x->dev, STG_COM_INT_EN_REG, data);
183 177
184 ad714x->read(ad714x->dev, STG_HIGH_INT_EN_REG, &data); 178 ad714x->read(ad714x->dev, STG_HIGH_INT_EN_REG, &data);
@@ -404,7 +398,6 @@ static void ad714x_slider_state_machine(struct ad714x_chip *ad714x, int idx)
404 ad714x_slider_cal_highest_stage(ad714x, idx); 398 ad714x_slider_cal_highest_stage(ad714x, idx);
405 ad714x_slider_cal_abs_pos(ad714x, idx); 399 ad714x_slider_cal_abs_pos(ad714x, idx);
406 ad714x_slider_cal_flt_pos(ad714x, idx); 400 ad714x_slider_cal_flt_pos(ad714x, idx);
407
408 input_report_abs(sw->input, ABS_X, sw->flt_pos); 401 input_report_abs(sw->input, ABS_X, sw->flt_pos);
409 input_report_key(sw->input, BTN_TOUCH, 1); 402 input_report_key(sw->input, BTN_TOUCH, 1);
410 } else { 403 } else {
@@ -468,104 +461,41 @@ static void ad714x_wheel_cal_sensor_val(struct ad714x_chip *ad714x, int idx)
468/* 461/*
469 * When the scroll wheel is activated, we compute the absolute position based 462 * When the scroll wheel is activated, we compute the absolute position based
470 * on the sensor values. To calculate the position, we first determine the 463 * on the sensor values. To calculate the position, we first determine the
471 * sensor that has the greatest response among the 8 sensors that constitutes 464 * sensor that has the greatest response among the sensors that constitutes
472 * the scrollwheel. Then we determined the 2 sensors on either sides of the 465 * the scrollwheel. Then we determined the sensors on either sides of the
473 * sensor with the highest response and we apply weights to these sensors. The 466 * sensor with the highest response and we apply weights to these sensors. The
474 * result of this computation gives us the mean value which defined by the 467 * result of this computation gives us the mean value.
475 * following formula:
476 * For i= second_before_highest_stage to i= second_after_highest_stage
477 * v += Sensor response(i)*WEIGHT*(i+3)
478 * w += Sensor response(i)
479 * Mean_Value=v/w
480 * pos_on_scrollwheel = (Mean_Value - position_offset) / position_ratio
481 */ 468 */
482 469
483#define WEIGHT_FACTOR 30
484/* This constant prevents the "PositionOffset" from reaching a big value */
485#define OFFSET_POSITION_CLAMP 120
486static void ad714x_wheel_cal_abs_pos(struct ad714x_chip *ad714x, int idx) 470static void ad714x_wheel_cal_abs_pos(struct ad714x_chip *ad714x, int idx)
487{ 471{
488 struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx]; 472 struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx];
489 struct ad714x_wheel_drv *sw = &ad714x->sw->wheel[idx]; 473 struct ad714x_wheel_drv *sw = &ad714x->sw->wheel[idx];
490 int stage_num = hw->end_stage - hw->start_stage + 1; 474 int stage_num = hw->end_stage - hw->start_stage + 1;
491 int second_before, first_before, highest, first_after, second_after; 475 int first_before, highest, first_after;
492 int a_param, b_param; 476 int a_param, b_param;
493 477
494 /* Calculate Mean value */
495
496 second_before = (sw->highest_stage + stage_num - 2) % stage_num;
497 first_before = (sw->highest_stage + stage_num - 1) % stage_num; 478 first_before = (sw->highest_stage + stage_num - 1) % stage_num;
498 highest = sw->highest_stage; 479 highest = sw->highest_stage;
499 first_after = (sw->highest_stage + stage_num + 1) % stage_num; 480 first_after = (sw->highest_stage + stage_num + 1) % stage_num;
500 second_after = (sw->highest_stage + stage_num + 2) % stage_num;
501
502 if (((sw->highest_stage - hw->start_stage) > 1) &&
503 ((hw->end_stage - sw->highest_stage) > 1)) {
504 a_param = ad714x->sensor_val[second_before] *
505 (second_before - hw->start_stage + 3) +
506 ad714x->sensor_val[first_before] *
507 (second_before - hw->start_stage + 3) +
508 ad714x->sensor_val[highest] *
509 (second_before - hw->start_stage + 3) +
510 ad714x->sensor_val[first_after] *
511 (first_after - hw->start_stage + 3) +
512 ad714x->sensor_val[second_after] *
513 (second_after - hw->start_stage + 3);
514 } else {
515 a_param = ad714x->sensor_val[second_before] *
516 (second_before - hw->start_stage + 1) +
517 ad714x->sensor_val[first_before] *
518 (second_before - hw->start_stage + 2) +
519 ad714x->sensor_val[highest] *
520 (second_before - hw->start_stage + 3) +
521 ad714x->sensor_val[first_after] *
522 (first_after - hw->start_stage + 4) +
523 ad714x->sensor_val[second_after] *
524 (second_after - hw->start_stage + 5);
525 }
526 a_param *= WEIGHT_FACTOR;
527 481
528 b_param = ad714x->sensor_val[second_before] + 482 a_param = ad714x->sensor_val[highest] *
483 (highest - hw->start_stage) +
484 ad714x->sensor_val[first_before] *
485 (highest - hw->start_stage - 1) +
486 ad714x->sensor_val[first_after] *
487 (highest - hw->start_stage + 1);
488 b_param = ad714x->sensor_val[highest] +
529 ad714x->sensor_val[first_before] + 489 ad714x->sensor_val[first_before] +
530 ad714x->sensor_val[highest] + 490 ad714x->sensor_val[first_after];
531 ad714x->sensor_val[first_after] + 491
532 ad714x->sensor_val[second_after]; 492 sw->abs_pos = ((hw->max_coord / (hw->end_stage - hw->start_stage)) *
533 493 a_param) / b_param;
534 sw->pre_mean_value = sw->mean_value; 494
535 sw->mean_value = a_param / b_param;
536
537 /* Calculate the offset */
538
539 if ((sw->pre_highest_stage == hw->end_stage) &&
540 (sw->highest_stage == hw->start_stage))
541 sw->pos_offset = sw->mean_value;
542 else if ((sw->pre_highest_stage == hw->start_stage) &&
543 (sw->highest_stage == hw->end_stage))
544 sw->pos_offset = sw->pre_mean_value;
545
546 if (sw->pos_offset > OFFSET_POSITION_CLAMP)
547 sw->pos_offset = OFFSET_POSITION_CLAMP;
548
549 /* Calculate the mean value without the offset */
550
551 sw->pre_mean_value_no_offset = sw->mean_value_no_offset;
552 sw->mean_value_no_offset = sw->mean_value - sw->pos_offset;
553 if (sw->mean_value_no_offset < 0)
554 sw->mean_value_no_offset = 0;
555
556 /* Calculate ratio to scale down to NUMBER_OF_WANTED_POSITIONS */
557
558 if ((sw->pre_highest_stage == hw->end_stage) &&
559 (sw->highest_stage == hw->start_stage))
560 sw->pos_ratio = (sw->pre_mean_value_no_offset * 100) /
561 hw->max_coord;
562 else if ((sw->pre_highest_stage == hw->start_stage) &&
563 (sw->highest_stage == hw->end_stage))
564 sw->pos_ratio = (sw->mean_value_no_offset * 100) /
565 hw->max_coord;
566 sw->abs_pos = (sw->mean_value_no_offset * 100) / sw->pos_ratio;
567 if (sw->abs_pos > hw->max_coord) 495 if (sw->abs_pos > hw->max_coord)
568 sw->abs_pos = hw->max_coord; 496 sw->abs_pos = hw->max_coord;
497 else if (sw->abs_pos < 0)
498 sw->abs_pos = 0;
569} 499}
570 500
571static void ad714x_wheel_cal_flt_pos(struct ad714x_chip *ad714x, int idx) 501static void ad714x_wheel_cal_flt_pos(struct ad714x_chip *ad714x, int idx)
@@ -639,9 +569,8 @@ static void ad714x_wheel_state_machine(struct ad714x_chip *ad714x, int idx)
639 ad714x_wheel_cal_highest_stage(ad714x, idx); 569 ad714x_wheel_cal_highest_stage(ad714x, idx);
640 ad714x_wheel_cal_abs_pos(ad714x, idx); 570 ad714x_wheel_cal_abs_pos(ad714x, idx);
641 ad714x_wheel_cal_flt_pos(ad714x, idx); 571 ad714x_wheel_cal_flt_pos(ad714x, idx);
642
643 input_report_abs(sw->input, ABS_WHEEL, 572 input_report_abs(sw->input, ABS_WHEEL,
644 sw->abs_pos); 573 sw->flt_pos);
645 input_report_key(sw->input, BTN_TOUCH, 1); 574 input_report_key(sw->input, BTN_TOUCH, 1);
646 } else { 575 } else {
647 /* When the user lifts off the sensor, configure 576 /* When the user lifts off the sensor, configure
@@ -1149,6 +1078,8 @@ struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq,
1149 input[alloc_idx]->id.bustype = bus_type; 1078 input[alloc_idx]->id.bustype = bus_type;
1150 input[alloc_idx]->id.product = ad714x->product; 1079 input[alloc_idx]->id.product = ad714x->product;
1151 input[alloc_idx]->id.version = ad714x->version; 1080 input[alloc_idx]->id.version = ad714x->version;
1081 input[alloc_idx]->name = "ad714x_captouch_slider";
1082 input[alloc_idx]->dev.parent = dev;
1152 1083
1153 error = input_register_device(input[alloc_idx]); 1084 error = input_register_device(input[alloc_idx]);
1154 if (error) 1085 if (error)
@@ -1179,6 +1110,8 @@ struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq,
1179 input[alloc_idx]->id.bustype = bus_type; 1110 input[alloc_idx]->id.bustype = bus_type;
1180 input[alloc_idx]->id.product = ad714x->product; 1111 input[alloc_idx]->id.product = ad714x->product;
1181 input[alloc_idx]->id.version = ad714x->version; 1112 input[alloc_idx]->id.version = ad714x->version;
1113 input[alloc_idx]->name = "ad714x_captouch_wheel";
1114 input[alloc_idx]->dev.parent = dev;
1182 1115
1183 error = input_register_device(input[alloc_idx]); 1116 error = input_register_device(input[alloc_idx]);
1184 if (error) 1117 if (error)
@@ -1212,6 +1145,8 @@ struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq,
1212 input[alloc_idx]->id.bustype = bus_type; 1145 input[alloc_idx]->id.bustype = bus_type;
1213 input[alloc_idx]->id.product = ad714x->product; 1146 input[alloc_idx]->id.product = ad714x->product;
1214 input[alloc_idx]->id.version = ad714x->version; 1147 input[alloc_idx]->id.version = ad714x->version;
1148 input[alloc_idx]->name = "ad714x_captouch_pad";
1149 input[alloc_idx]->dev.parent = dev;
1215 1150
1216 error = input_register_device(input[alloc_idx]); 1151 error = input_register_device(input[alloc_idx]);
1217 if (error) 1152 if (error)
@@ -1240,6 +1175,8 @@ struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq,
1240 input[alloc_idx]->id.bustype = bus_type; 1175 input[alloc_idx]->id.bustype = bus_type;
1241 input[alloc_idx]->id.product = ad714x->product; 1176 input[alloc_idx]->id.product = ad714x->product;
1242 input[alloc_idx]->id.version = ad714x->version; 1177 input[alloc_idx]->id.version = ad714x->version;
1178 input[alloc_idx]->name = "ad714x_captouch_button";
1179 input[alloc_idx]->dev.parent = dev;
1243 1180
1244 error = input_register_device(input[alloc_idx]); 1181 error = input_register_device(input[alloc_idx]);
1245 if (error) 1182 if (error)
@@ -1249,7 +1186,9 @@ struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq,
1249 } 1186 }
1250 1187
1251 error = request_threaded_irq(ad714x->irq, NULL, ad714x_interrupt_thread, 1188 error = request_threaded_irq(ad714x->irq, NULL, ad714x_interrupt_thread,
1252 IRQF_TRIGGER_FALLING, "ad714x_captouch", ad714x); 1189 plat_data->irqflags ?
1190 plat_data->irqflags : IRQF_TRIGGER_FALLING,
1191 "ad714x_captouch", ad714x);
1253 if (error) { 1192 if (error) {
1254 dev_err(dev, "can't allocate irq %d\n", ad714x->irq); 1193 dev_err(dev, "can't allocate irq %d\n", ad714x->irq);
1255 goto err_unreg_dev; 1194 goto err_unreg_dev;
diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c
index 9ccdb82d869a..1de58e8a1b71 100644
--- a/drivers/input/misc/ati_remote2.c
+++ b/drivers/input/misc/ati_remote2.c
@@ -737,14 +737,17 @@ static ssize_t ati_remote2_store_channel_mask(struct device *dev,
737 737
738 mutex_lock(&ati_remote2_mutex); 738 mutex_lock(&ati_remote2_mutex);
739 739
740 if (mask != ar2->channel_mask && !ati_remote2_setup(ar2, mask)) 740 if (mask != ar2->channel_mask) {
741 ar2->channel_mask = mask; 741 r = ati_remote2_setup(ar2, mask);
742 if (!r)
743 ar2->channel_mask = mask;
744 }
742 745
743 mutex_unlock(&ati_remote2_mutex); 746 mutex_unlock(&ati_remote2_mutex);
744 747
745 usb_autopm_put_interface(ar2->intf[0]); 748 usb_autopm_put_interface(ar2->intf[0]);
746 749
747 return count; 750 return r ? r : count;
748} 751}
749 752
750static ssize_t ati_remote2_show_mode_mask(struct device *dev, 753static ssize_t ati_remote2_show_mode_mask(struct device *dev,
diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c
index 7e64d01da2be..2c8b84dd9dac 100644
--- a/drivers/input/misc/rotary_encoder.c
+++ b/drivers/input/misc/rotary_encoder.c
@@ -2,6 +2,7 @@
2 * rotary_encoder.c 2 * rotary_encoder.c
3 * 3 *
4 * (c) 2009 Daniel Mack <daniel@caiaq.de> 4 * (c) 2009 Daniel Mack <daniel@caiaq.de>
5 * Copyright (C) 2011 Johan Hovold <jhovold@gmail.com>
5 * 6 *
6 * state machine code inspired by code from Tim Ruetz 7 * state machine code inspired by code from Tim Ruetz
7 * 8 *
@@ -38,52 +39,66 @@ struct rotary_encoder {
38 39
39 bool armed; 40 bool armed;
40 unsigned char dir; /* 0 - clockwise, 1 - CCW */ 41 unsigned char dir; /* 0 - clockwise, 1 - CCW */
42
43 char last_stable;
41}; 44};
42 45
43static irqreturn_t rotary_encoder_irq(int irq, void *dev_id) 46static int rotary_encoder_get_state(struct rotary_encoder_platform_data *pdata)
44{ 47{
45 struct rotary_encoder *encoder = dev_id;
46 struct rotary_encoder_platform_data *pdata = encoder->pdata;
47 int a = !!gpio_get_value(pdata->gpio_a); 48 int a = !!gpio_get_value(pdata->gpio_a);
48 int b = !!gpio_get_value(pdata->gpio_b); 49 int b = !!gpio_get_value(pdata->gpio_b);
49 int state;
50 50
51 a ^= pdata->inverted_a; 51 a ^= pdata->inverted_a;
52 b ^= pdata->inverted_b; 52 b ^= pdata->inverted_b;
53 state = (a << 1) | b;
54 53
55 switch (state) { 54 return ((a << 1) | b);
55}
56 56
57 case 0x0: 57static void rotary_encoder_report_event(struct rotary_encoder *encoder)
58 if (!encoder->armed) 58{
59 break; 59 struct rotary_encoder_platform_data *pdata = encoder->pdata;
60 60
61 if (pdata->relative_axis) { 61 if (pdata->relative_axis) {
62 input_report_rel(encoder->input, pdata->axis, 62 input_report_rel(encoder->input,
63 encoder->dir ? -1 : 1); 63 pdata->axis, encoder->dir ? -1 : 1);
64 } else { 64 } else {
65 unsigned int pos = encoder->pos; 65 unsigned int pos = encoder->pos;
66 66
67 if (encoder->dir) { 67 if (encoder->dir) {
68 /* turning counter-clockwise */ 68 /* turning counter-clockwise */
69 if (pdata->rollover)
70 pos += pdata->steps;
71 if (pos)
72 pos--;
73 } else {
74 /* turning clockwise */
75 if (pdata->rollover || pos < pdata->steps)
76 pos++;
77 }
78 if (pdata->rollover) 69 if (pdata->rollover)
79 pos %= pdata->steps; 70 pos += pdata->steps;
80 encoder->pos = pos; 71 if (pos)
81 input_report_abs(encoder->input, pdata->axis, 72 pos--;
82 encoder->pos); 73 } else {
74 /* turning clockwise */
75 if (pdata->rollover || pos < pdata->steps)
76 pos++;
83 } 77 }
84 input_sync(encoder->input);
85 78
86 encoder->armed = false; 79 if (pdata->rollover)
80 pos %= pdata->steps;
81
82 encoder->pos = pos;
83 input_report_abs(encoder->input, pdata->axis, encoder->pos);
84 }
85
86 input_sync(encoder->input);
87}
88
89static irqreturn_t rotary_encoder_irq(int irq, void *dev_id)
90{
91 struct rotary_encoder *encoder = dev_id;
92 int state;
93
94 state = rotary_encoder_get_state(encoder->pdata);
95
96 switch (state) {
97 case 0x0:
98 if (encoder->armed) {
99 rotary_encoder_report_event(encoder);
100 encoder->armed = false;
101 }
87 break; 102 break;
88 103
89 case 0x1: 104 case 0x1:
@@ -100,11 +115,37 @@ static irqreturn_t rotary_encoder_irq(int irq, void *dev_id)
100 return IRQ_HANDLED; 115 return IRQ_HANDLED;
101} 116}
102 117
118static irqreturn_t rotary_encoder_half_period_irq(int irq, void *dev_id)
119{
120 struct rotary_encoder *encoder = dev_id;
121 int state;
122
123 state = rotary_encoder_get_state(encoder->pdata);
124
125 switch (state) {
126 case 0x00:
127 case 0x03:
128 if (state != encoder->last_stable) {
129 rotary_encoder_report_event(encoder);
130 encoder->last_stable = state;
131 }
132 break;
133
134 case 0x01:
135 case 0x02:
136 encoder->dir = (encoder->last_stable + state) & 0x01;
137 break;
138 }
139
140 return IRQ_HANDLED;
141}
142
103static int __devinit rotary_encoder_probe(struct platform_device *pdev) 143static int __devinit rotary_encoder_probe(struct platform_device *pdev)
104{ 144{
105 struct rotary_encoder_platform_data *pdata = pdev->dev.platform_data; 145 struct rotary_encoder_platform_data *pdata = pdev->dev.platform_data;
106 struct rotary_encoder *encoder; 146 struct rotary_encoder *encoder;
107 struct input_dev *input; 147 struct input_dev *input;
148 irq_handler_t handler;
108 int err; 149 int err;
109 150
110 if (!pdata) { 151 if (!pdata) {
@@ -175,7 +216,14 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev)
175 } 216 }
176 217
177 /* request the IRQs */ 218 /* request the IRQs */
178 err = request_irq(encoder->irq_a, &rotary_encoder_irq, 219 if (pdata->half_period) {
220 handler = &rotary_encoder_half_period_irq;
221 encoder->last_stable = rotary_encoder_get_state(pdata);
222 } else {
223 handler = &rotary_encoder_irq;
224 }
225
226 err = request_irq(encoder->irq_a, handler,
179 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 227 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
180 DRV_NAME, encoder); 228 DRV_NAME, encoder);
181 if (err) { 229 if (err) {
@@ -184,7 +232,7 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev)
184 goto exit_free_gpio_b; 232 goto exit_free_gpio_b;
185 } 233 }
186 234
187 err = request_irq(encoder->irq_b, &rotary_encoder_irq, 235 err = request_irq(encoder->irq_b, handler,
188 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 236 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
189 DRV_NAME, encoder); 237 DRV_NAME, encoder);
190 if (err) { 238 if (err) {
@@ -252,6 +300,5 @@ module_exit(rotary_encoder_exit);
252 300
253MODULE_ALIAS("platform:" DRV_NAME); 301MODULE_ALIAS("platform:" DRV_NAME);
254MODULE_DESCRIPTION("GPIO rotary encoder driver"); 302MODULE_DESCRIPTION("GPIO rotary encoder driver");
255MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); 303MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>, Johan Hovold");
256MODULE_LICENSE("GPL v2"); 304MODULE_LICENSE("GPL v2");
257
diff --git a/drivers/input/misc/twl4030-pwrbutton.c b/drivers/input/misc/twl4030-pwrbutton.c
index f16972bddca4..38e4b507b94c 100644
--- a/drivers/input/misc/twl4030-pwrbutton.c
+++ b/drivers/input/misc/twl4030-pwrbutton.c
@@ -89,7 +89,7 @@ static int __init twl4030_pwrbutton_probe(struct platform_device *pdev)
89 return 0; 89 return 0;
90 90
91free_irq: 91free_irq:
92 free_irq(irq, NULL); 92 free_irq(irq, pwr);
93free_input_dev: 93free_input_dev:
94 input_free_device(pwr); 94 input_free_device(pwr);
95 return err; 95 return err;
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 04d9bf320a4f..32503565faf9 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -16,6 +16,7 @@
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/input.h> 18#include <linux/input.h>
19#include <linux/input/mt.h>
19#include <linux/serio.h> 20#include <linux/serio.h>
20#include <linux/libps2.h> 21#include <linux/libps2.h>
21#include "psmouse.h" 22#include "psmouse.h"
@@ -242,15 +243,37 @@ static void elantech_report_absolute_v1(struct psmouse *psmouse)
242 input_sync(dev); 243 input_sync(dev);
243} 244}
244 245
246static void elantech_set_slot(struct input_dev *dev, int slot, bool active,
247 unsigned int x, unsigned int y)
248{
249 input_mt_slot(dev, slot);
250 input_mt_report_slot_state(dev, MT_TOOL_FINGER, active);
251 if (active) {
252 input_report_abs(dev, ABS_MT_POSITION_X, x);
253 input_report_abs(dev, ABS_MT_POSITION_Y, y);
254 }
255}
256
257/* x1 < x2 and y1 < y2 when two fingers, x = y = 0 when not pressed */
258static void elantech_report_semi_mt_data(struct input_dev *dev,
259 unsigned int num_fingers,
260 unsigned int x1, unsigned int y1,
261 unsigned int x2, unsigned int y2)
262{
263 elantech_set_slot(dev, 0, num_fingers != 0, x1, y1);
264 elantech_set_slot(dev, 1, num_fingers == 2, x2, y2);
265}
266
245/* 267/*
246 * Interpret complete data packets and report absolute mode input events for 268 * Interpret complete data packets and report absolute mode input events for
247 * hardware version 2. (6 byte packets) 269 * hardware version 2. (6 byte packets)
248 */ 270 */
249static void elantech_report_absolute_v2(struct psmouse *psmouse) 271static void elantech_report_absolute_v2(struct psmouse *psmouse)
250{ 272{
273 struct elantech_data *etd = psmouse->private;
251 struct input_dev *dev = psmouse->dev; 274 struct input_dev *dev = psmouse->dev;
252 unsigned char *packet = psmouse->packet; 275 unsigned char *packet = psmouse->packet;
253 int fingers, x1, y1, x2, y2; 276 unsigned int fingers, x1 = 0, y1 = 0, x2 = 0, y2 = 0, width = 0, pres = 0;
254 277
255 /* byte 0: n1 n0 . . . . R L */ 278 /* byte 0: n1 n0 . . . . R L */
256 fingers = (packet[0] & 0xc0) >> 6; 279 fingers = (packet[0] & 0xc0) >> 6;
@@ -270,14 +293,18 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse)
270 * byte 1: . . . . . x10 x9 x8 293 * byte 1: . . . . . x10 x9 x8
271 * byte 2: x7 x6 x5 x4 x4 x2 x1 x0 294 * byte 2: x7 x6 x5 x4 x4 x2 x1 x0
272 */ 295 */
273 input_report_abs(dev, ABS_X, 296 x1 = ((packet[1] & 0x07) << 8) | packet[2];
274 ((packet[1] & 0x07) << 8) | packet[2]);
275 /* 297 /*
276 * byte 4: . . . . . . y9 y8 298 * byte 4: . . . . . . y9 y8
277 * byte 5: y7 y6 y5 y4 y3 y2 y1 y0 299 * byte 5: y7 y6 y5 y4 y3 y2 y1 y0
278 */ 300 */
279 input_report_abs(dev, ABS_Y, 301 y1 = ETP_YMAX_V2 - (((packet[4] & 0x03) << 8) | packet[5]);
280 ETP_YMAX_V2 - (((packet[4] & 0x03) << 8) | packet[5])); 302
303 input_report_abs(dev, ABS_X, x1);
304 input_report_abs(dev, ABS_Y, y1);
305
306 pres = (packet[1] & 0xf0) | ((packet[4] & 0xf0) >> 4);
307 width = ((packet[0] & 0x30) >> 2) | ((packet[3] & 0x30) >> 4);
281 break; 308 break;
282 309
283 case 2: 310 case 2:
@@ -303,23 +330,24 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse)
303 */ 330 */
304 input_report_abs(dev, ABS_X, x1 << 2); 331 input_report_abs(dev, ABS_X, x1 << 2);
305 input_report_abs(dev, ABS_Y, y1 << 2); 332 input_report_abs(dev, ABS_Y, y1 << 2);
306 /* 333
307 * For compatibility with the proprietary X Elantech driver 334 /* Unknown so just report sensible values */
308 * report both coordinates as hat coordinates 335 pres = 127;
309 */ 336 width = 7;
310 input_report_abs(dev, ABS_HAT0X, x1);
311 input_report_abs(dev, ABS_HAT0Y, y1);
312 input_report_abs(dev, ABS_HAT1X, x2);
313 input_report_abs(dev, ABS_HAT1Y, y2);
314 break; 337 break;
315 } 338 }
316 339
340 elantech_report_semi_mt_data(dev, fingers, x1, y1, x2, y2);
317 input_report_key(dev, BTN_TOOL_FINGER, fingers == 1); 341 input_report_key(dev, BTN_TOOL_FINGER, fingers == 1);
318 input_report_key(dev, BTN_TOOL_DOUBLETAP, fingers == 2); 342 input_report_key(dev, BTN_TOOL_DOUBLETAP, fingers == 2);
319 input_report_key(dev, BTN_TOOL_TRIPLETAP, fingers == 3); 343 input_report_key(dev, BTN_TOOL_TRIPLETAP, fingers == 3);
320 input_report_key(dev, BTN_TOOL_QUADTAP, fingers == 4); 344 input_report_key(dev, BTN_TOOL_QUADTAP, fingers == 4);
321 input_report_key(dev, BTN_LEFT, packet[0] & 0x01); 345 input_report_key(dev, BTN_LEFT, packet[0] & 0x01);
322 input_report_key(dev, BTN_RIGHT, packet[0] & 0x02); 346 input_report_key(dev, BTN_RIGHT, packet[0] & 0x02);
347 if (etd->reports_pressure) {
348 input_report_abs(dev, ABS_PRESSURE, pres);
349 input_report_abs(dev, ABS_TOOL_WIDTH, width);
350 }
323 351
324 input_sync(dev); 352 input_sync(dev);
325} 353}
@@ -478,10 +506,16 @@ static void elantech_set_input_params(struct psmouse *psmouse)
478 __set_bit(BTN_TOOL_QUADTAP, dev->keybit); 506 __set_bit(BTN_TOOL_QUADTAP, dev->keybit);
479 input_set_abs_params(dev, ABS_X, ETP_XMIN_V2, ETP_XMAX_V2, 0, 0); 507 input_set_abs_params(dev, ABS_X, ETP_XMIN_V2, ETP_XMAX_V2, 0, 0);
480 input_set_abs_params(dev, ABS_Y, ETP_YMIN_V2, ETP_YMAX_V2, 0, 0); 508 input_set_abs_params(dev, ABS_Y, ETP_YMIN_V2, ETP_YMAX_V2, 0, 0);
481 input_set_abs_params(dev, ABS_HAT0X, ETP_2FT_XMIN, ETP_2FT_XMAX, 0, 0); 509 if (etd->reports_pressure) {
482 input_set_abs_params(dev, ABS_HAT0Y, ETP_2FT_YMIN, ETP_2FT_YMAX, 0, 0); 510 input_set_abs_params(dev, ABS_PRESSURE, ETP_PMIN_V2,
483 input_set_abs_params(dev, ABS_HAT1X, ETP_2FT_XMIN, ETP_2FT_XMAX, 0, 0); 511 ETP_PMAX_V2, 0, 0);
484 input_set_abs_params(dev, ABS_HAT1Y, ETP_2FT_YMIN, ETP_2FT_YMAX, 0, 0); 512 input_set_abs_params(dev, ABS_TOOL_WIDTH, ETP_WMIN_V2,
513 ETP_WMAX_V2, 0, 0);
514 }
515 __set_bit(INPUT_PROP_SEMI_MT, dev->propbit);
516 input_mt_init_slots(dev, 2);
517 input_set_abs_params(dev, ABS_MT_POSITION_X, ETP_XMIN_V2, ETP_XMAX_V2, 0, 0);
518 input_set_abs_params(dev, ABS_MT_POSITION_Y, ETP_YMIN_V2, ETP_YMAX_V2, 0, 0);
485 break; 519 break;
486 } 520 }
487} 521}
@@ -725,6 +759,10 @@ int elantech_init(struct psmouse *psmouse)
725 etd->debug = 1; 759 etd->debug = 1;
726 /* Don't know how to do parity checking for version 2 */ 760 /* Don't know how to do parity checking for version 2 */
727 etd->paritycheck = 0; 761 etd->paritycheck = 0;
762
763 if (etd->fw_version >= 0x020800)
764 etd->reports_pressure = true;
765
728 } else { 766 } else {
729 etd->hw_version = 1; 767 etd->hw_version = 1;
730 etd->paritycheck = 1; 768 etd->paritycheck = 1;
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h
index aa4aac5d2198..fabb2b99615c 100644
--- a/drivers/input/mouse/elantech.h
+++ b/drivers/input/mouse/elantech.h
@@ -77,6 +77,11 @@
77#define ETP_YMIN_V2 ( 0 + ETP_EDGE_FUZZ_V2) 77#define ETP_YMIN_V2 ( 0 + ETP_EDGE_FUZZ_V2)
78#define ETP_YMAX_V2 ( 768 - ETP_EDGE_FUZZ_V2) 78#define ETP_YMAX_V2 ( 768 - ETP_EDGE_FUZZ_V2)
79 79
80#define ETP_PMIN_V2 0
81#define ETP_PMAX_V2 255
82#define ETP_WMIN_V2 0
83#define ETP_WMAX_V2 15
84
80/* 85/*
81 * For two finger touches the coordinate of each finger gets reported 86 * For two finger touches the coordinate of each finger gets reported
82 * separately but with reduced resolution. 87 * separately but with reduced resolution.
@@ -102,6 +107,7 @@ struct elantech_data {
102 unsigned char capabilities; 107 unsigned char capabilities;
103 bool paritycheck; 108 bool paritycheck;
104 bool jumpy_cursor; 109 bool jumpy_cursor;
110 bool reports_pressure;
105 unsigned char hw_version; 111 unsigned char hw_version;
106 unsigned int fw_version; 112 unsigned int fw_version;
107 unsigned int single_finger_reports; 113 unsigned int single_finger_reports;
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index 7630273e9474..257e033986e4 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -508,7 +508,6 @@ static void mousedev_attach_client(struct mousedev *mousedev,
508 spin_lock(&mousedev->client_lock); 508 spin_lock(&mousedev->client_lock);
509 list_add_tail_rcu(&client->node, &mousedev->client_list); 509 list_add_tail_rcu(&client->node, &mousedev->client_list);
510 spin_unlock(&mousedev->client_lock); 510 spin_unlock(&mousedev->client_lock);
511 synchronize_rcu();
512} 511}
513 512
514static void mousedev_detach_client(struct mousedev *mousedev, 513static void mousedev_detach_client(struct mousedev *mousedev,
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 434fd800cd24..cabd9e54863f 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -248,6 +248,18 @@ config TOUCHSCREEN_LPC32XX
248 To compile this driver as a module, choose M here: the 248 To compile this driver as a module, choose M here: the
249 module will be called lpc32xx_ts. 249 module will be called lpc32xx_ts.
250 250
251config TOUCHSCREEN_MAX11801
252 tristate "MAX11801 based touchscreens"
253 depends on I2C
254 help
255 Say Y here if you have a MAX11801 based touchscreen
256 controller.
257
258 If unsure, say N.
259
260 To compile this driver as a module, choose M here: the
261 module will be called max11801_ts.
262
251config TOUCHSCREEN_MCS5000 263config TOUCHSCREEN_MCS5000
252 tristate "MELFAS MCS-5000 touchscreen" 264 tristate "MELFAS MCS-5000 touchscreen"
253 depends on I2C 265 depends on I2C
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index ca94098d4c92..282d6f76ae26 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_TOUCHSCREEN_FUJITSU) += fujitsu_ts.o
27obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o 27obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o
28obj-$(CONFIG_TOUCHSCREEN_INTEL_MID) += intel-mid-touch.o 28obj-$(CONFIG_TOUCHSCREEN_INTEL_MID) += intel-mid-touch.o
29obj-$(CONFIG_TOUCHSCREEN_LPC32XX) += lpc32xx_ts.o 29obj-$(CONFIG_TOUCHSCREEN_LPC32XX) += lpc32xx_ts.o
30obj-$(CONFIG_TOUCHSCREEN_MAX11801) += max11801_ts.o
30obj-$(CONFIG_TOUCHSCREEN_MC13783) += mc13783_ts.o 31obj-$(CONFIG_TOUCHSCREEN_MC13783) += mc13783_ts.o
31obj-$(CONFIG_TOUCHSCREEN_MCS5000) += mcs5000_ts.o 32obj-$(CONFIG_TOUCHSCREEN_MCS5000) += mcs5000_ts.o
32obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o 33obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 1de1c19dad30..5196861b86ef 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -109,6 +109,7 @@ struct ads7846 {
109 u16 pressure_max; 109 u16 pressure_max;
110 110
111 bool swap_xy; 111 bool swap_xy;
112 bool use_internal;
112 113
113 struct ads7846_packet *packet; 114 struct ads7846_packet *packet;
114 115
@@ -307,7 +308,6 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
307 struct ads7846 *ts = dev_get_drvdata(dev); 308 struct ads7846 *ts = dev_get_drvdata(dev);
308 struct ser_req *req; 309 struct ser_req *req;
309 int status; 310 int status;
310 int use_internal;
311 311
312 req = kzalloc(sizeof *req, GFP_KERNEL); 312 req = kzalloc(sizeof *req, GFP_KERNEL);
313 if (!req) 313 if (!req)
@@ -315,11 +315,8 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
315 315
316 spi_message_init(&req->msg); 316 spi_message_init(&req->msg);
317 317
318 /* FIXME boards with ads7846 might use external vref instead ... */
319 use_internal = (ts->model == 7846);
320
321 /* maybe turn on internal vREF, and let it settle */ 318 /* maybe turn on internal vREF, and let it settle */
322 if (use_internal) { 319 if (ts->use_internal) {
323 req->ref_on = REF_ON; 320 req->ref_on = REF_ON;
324 req->xfer[0].tx_buf = &req->ref_on; 321 req->xfer[0].tx_buf = &req->ref_on;
325 req->xfer[0].len = 1; 322 req->xfer[0].len = 1;
@@ -331,8 +328,14 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
331 /* for 1uF, settle for 800 usec; no cap, 100 usec. */ 328 /* for 1uF, settle for 800 usec; no cap, 100 usec. */
332 req->xfer[1].delay_usecs = ts->vref_delay_usecs; 329 req->xfer[1].delay_usecs = ts->vref_delay_usecs;
333 spi_message_add_tail(&req->xfer[1], &req->msg); 330 spi_message_add_tail(&req->xfer[1], &req->msg);
331
332 /* Enable reference voltage */
333 command |= ADS_PD10_REF_ON;
334 } 334 }
335 335
336 /* Enable ADC in every case */
337 command |= ADS_PD10_ADC_ON;
338
336 /* take sample */ 339 /* take sample */
337 req->command = (u8) command; 340 req->command = (u8) command;
338 req->xfer[2].tx_buf = &req->command; 341 req->xfer[2].tx_buf = &req->command;
@@ -416,7 +419,7 @@ name ## _show(struct device *dev, struct device_attribute *attr, char *buf) \
416{ \ 419{ \
417 struct ads7846 *ts = dev_get_drvdata(dev); \ 420 struct ads7846 *ts = dev_get_drvdata(dev); \
418 ssize_t v = ads7846_read12_ser(dev, \ 421 ssize_t v = ads7846_read12_ser(dev, \
419 READ_12BIT_SER(var) | ADS_PD10_ALL_ON); \ 422 READ_12BIT_SER(var)); \
420 if (v < 0) \ 423 if (v < 0) \
421 return v; \ 424 return v; \
422 return sprintf(buf, "%u\n", adjust(ts, v)); \ 425 return sprintf(buf, "%u\n", adjust(ts, v)); \
@@ -509,6 +512,7 @@ static int ads784x_hwmon_register(struct spi_device *spi, struct ads7846 *ts)
509 if (!ts->vref_mv) { 512 if (!ts->vref_mv) {
510 dev_dbg(&spi->dev, "assuming 2.5V internal vREF\n"); 513 dev_dbg(&spi->dev, "assuming 2.5V internal vREF\n");
511 ts->vref_mv = 2500; 514 ts->vref_mv = 2500;
515 ts->use_internal = true;
512 } 516 }
513 break; 517 break;
514 case 7845: 518 case 7845:
@@ -969,6 +973,13 @@ static int __devinit ads7846_setup_pendown(struct spi_device *spi, struct ads784
969 pdata->gpio_pendown); 973 pdata->gpio_pendown);
970 return err; 974 return err;
971 } 975 }
976 err = gpio_direction_input(pdata->gpio_pendown);
977 if (err) {
978 dev_err(&spi->dev, "failed to setup pendown GPIO%d\n",
979 pdata->gpio_pendown);
980 gpio_free(pdata->gpio_pendown);
981 return err;
982 }
972 983
973 ts->gpio_pendown = pdata->gpio_pendown; 984 ts->gpio_pendown = pdata->gpio_pendown;
974 985
@@ -1340,8 +1351,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
1340 if (ts->model == 7845) 1351 if (ts->model == 7845)
1341 ads7845_read12_ser(&spi->dev, PWRDOWN); 1352 ads7845_read12_ser(&spi->dev, PWRDOWN);
1342 else 1353 else
1343 (void) ads7846_read12_ser(&spi->dev, 1354 (void) ads7846_read12_ser(&spi->dev, READ_12BIT_SER(vaux));
1344 READ_12BIT_SER(vaux) | ADS_PD10_ALL_ON);
1345 1355
1346 err = sysfs_create_group(&spi->dev.kobj, &ads784x_attr_group); 1356 err = sysfs_create_group(&spi->dev.kobj, &ads784x_attr_group);
1347 if (err) 1357 if (err)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 4012436633b1..1e61387c73ca 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -17,7 +17,7 @@
17#include <linux/firmware.h> 17#include <linux/firmware.h>
18#include <linux/i2c.h> 18#include <linux/i2c.h>
19#include <linux/i2c/atmel_mxt_ts.h> 19#include <linux/i2c/atmel_mxt_ts.h>
20#include <linux/input.h> 20#include <linux/input/mt.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23 23
@@ -196,9 +196,12 @@
196#define MXT_PRESS (1 << 6) 196#define MXT_PRESS (1 << 6)
197#define MXT_DETECT (1 << 7) 197#define MXT_DETECT (1 << 7)
198 198
199/* Touch orient bits */
200#define MXT_XY_SWITCH (1 << 0)
201#define MXT_X_INVERT (1 << 1)
202#define MXT_Y_INVERT (1 << 2)
203
199/* Touchscreen absolute values */ 204/* Touchscreen absolute values */
200#define MXT_MAX_XC 0x3ff
201#define MXT_MAX_YC 0x3ff
202#define MXT_MAX_AREA 0xff 205#define MXT_MAX_AREA 0xff
203 206
204#define MXT_MAX_FINGER 10 207#define MXT_MAX_FINGER 10
@@ -246,6 +249,8 @@ struct mxt_data {
246 struct mxt_info info; 249 struct mxt_info info;
247 struct mxt_finger finger[MXT_MAX_FINGER]; 250 struct mxt_finger finger[MXT_MAX_FINGER];
248 unsigned int irq; 251 unsigned int irq;
252 unsigned int max_x;
253 unsigned int max_y;
249}; 254};
250 255
251static bool mxt_object_readable(unsigned int type) 256static bool mxt_object_readable(unsigned int type)
@@ -499,19 +504,21 @@ static void mxt_input_report(struct mxt_data *data, int single_id)
499 if (!finger[id].status) 504 if (!finger[id].status)
500 continue; 505 continue;
501 506
502 input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, 507 input_mt_slot(input_dev, id);
503 finger[id].status != MXT_RELEASE ? 508 input_mt_report_slot_state(input_dev, MT_TOOL_FINGER,
504 finger[id].area : 0); 509 finger[id].status != MXT_RELEASE);
505 input_report_abs(input_dev, ABS_MT_POSITION_X,
506 finger[id].x);
507 input_report_abs(input_dev, ABS_MT_POSITION_Y,
508 finger[id].y);
509 input_mt_sync(input_dev);
510 510
511 if (finger[id].status == MXT_RELEASE) 511 if (finger[id].status != MXT_RELEASE) {
512 finger[id].status = 0;
513 else
514 finger_num++; 512 finger_num++;
513 input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR,
514 finger[id].area);
515 input_report_abs(input_dev, ABS_MT_POSITION_X,
516 finger[id].x);
517 input_report_abs(input_dev, ABS_MT_POSITION_Y,
518 finger[id].y);
519 } else {
520 finger[id].status = 0;
521 }
515 } 522 }
516 523
517 input_report_key(input_dev, BTN_TOUCH, finger_num > 0); 524 input_report_key(input_dev, BTN_TOUCH, finger_num > 0);
@@ -549,8 +556,13 @@ static void mxt_input_touchevent(struct mxt_data *data,
549 if (!(status & (MXT_PRESS | MXT_MOVE))) 556 if (!(status & (MXT_PRESS | MXT_MOVE)))
550 return; 557 return;
551 558
552 x = (message->message[1] << 2) | ((message->message[3] & ~0x3f) >> 6); 559 x = (message->message[1] << 4) | ((message->message[3] >> 4) & 0xf);
553 y = (message->message[2] << 2) | ((message->message[3] & ~0xf3) >> 2); 560 y = (message->message[2] << 4) | ((message->message[3] & 0xf));
561 if (data->max_x < 1024)
562 x = x >> 2;
563 if (data->max_y < 1024)
564 y = y >> 2;
565
554 area = message->message[4]; 566 area = message->message[4];
555 567
556 dev_dbg(dev, "[%d] %s x: %d, y: %d, area: %d\n", id, 568 dev_dbg(dev, "[%d] %s x: %d, y: %d, area: %d\n", id,
@@ -804,10 +816,6 @@ static int mxt_initialize(struct mxt_data *data)
804 if (error) 816 if (error)
805 return error; 817 return error;
806 818
807 error = mxt_make_highchg(data);
808 if (error)
809 return error;
810
811 mxt_handle_pdata(data); 819 mxt_handle_pdata(data);
812 820
813 /* Backup to memory */ 821 /* Backup to memory */
@@ -845,6 +853,20 @@ static int mxt_initialize(struct mxt_data *data)
845 return 0; 853 return 0;
846} 854}
847 855
856static void mxt_calc_resolution(struct mxt_data *data)
857{
858 unsigned int max_x = data->pdata->x_size - 1;
859 unsigned int max_y = data->pdata->y_size - 1;
860
861 if (data->pdata->orient & MXT_XY_SWITCH) {
862 data->max_x = max_y;
863 data->max_y = max_x;
864 } else {
865 data->max_x = max_x;
866 data->max_y = max_y;
867 }
868}
869
848static ssize_t mxt_object_show(struct device *dev, 870static ssize_t mxt_object_show(struct device *dev,
849 struct device_attribute *attr, char *buf) 871 struct device_attribute *attr, char *buf)
850{ 872{
@@ -981,6 +1003,10 @@ static ssize_t mxt_update_fw_store(struct device *dev,
981 1003
982 enable_irq(data->irq); 1004 enable_irq(data->irq);
983 1005
1006 error = mxt_make_highchg(data);
1007 if (error)
1008 return error;
1009
984 return count; 1010 return count;
985} 1011}
986 1012
@@ -1052,31 +1078,33 @@ static int __devinit mxt_probe(struct i2c_client *client,
1052 input_dev->open = mxt_input_open; 1078 input_dev->open = mxt_input_open;
1053 input_dev->close = mxt_input_close; 1079 input_dev->close = mxt_input_close;
1054 1080
1081 data->client = client;
1082 data->input_dev = input_dev;
1083 data->pdata = pdata;
1084 data->irq = client->irq;
1085
1086 mxt_calc_resolution(data);
1087
1055 __set_bit(EV_ABS, input_dev->evbit); 1088 __set_bit(EV_ABS, input_dev->evbit);
1056 __set_bit(EV_KEY, input_dev->evbit); 1089 __set_bit(EV_KEY, input_dev->evbit);
1057 __set_bit(BTN_TOUCH, input_dev->keybit); 1090 __set_bit(BTN_TOUCH, input_dev->keybit);
1058 1091
1059 /* For single touch */ 1092 /* For single touch */
1060 input_set_abs_params(input_dev, ABS_X, 1093 input_set_abs_params(input_dev, ABS_X,
1061 0, MXT_MAX_XC, 0, 0); 1094 0, data->max_x, 0, 0);
1062 input_set_abs_params(input_dev, ABS_Y, 1095 input_set_abs_params(input_dev, ABS_Y,
1063 0, MXT_MAX_YC, 0, 0); 1096 0, data->max_y, 0, 0);
1064 1097
1065 /* For multi touch */ 1098 /* For multi touch */
1099 input_mt_init_slots(input_dev, MXT_MAX_FINGER);
1066 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 1100 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
1067 0, MXT_MAX_AREA, 0, 0); 1101 0, MXT_MAX_AREA, 0, 0);
1068 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 1102 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1069 0, MXT_MAX_XC, 0, 0); 1103 0, data->max_x, 0, 0);
1070 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 1104 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1071 0, MXT_MAX_YC, 0, 0); 1105 0, data->max_y, 0, 0);
1072 1106
1073 input_set_drvdata(input_dev, data); 1107 input_set_drvdata(input_dev, data);
1074
1075 data->client = client;
1076 data->input_dev = input_dev;
1077 data->pdata = pdata;
1078 data->irq = client->irq;
1079
1080 i2c_set_clientdata(client, data); 1108 i2c_set_clientdata(client, data);
1081 1109
1082 error = mxt_initialize(data); 1110 error = mxt_initialize(data);
@@ -1090,6 +1118,10 @@ static int __devinit mxt_probe(struct i2c_client *client,
1090 goto err_free_object; 1118 goto err_free_object;
1091 } 1119 }
1092 1120
1121 error = mxt_make_highchg(data);
1122 if (error)
1123 goto err_free_irq;
1124
1093 error = input_register_device(input_dev); 1125 error = input_register_device(input_dev);
1094 if (error) 1126 if (error)
1095 goto err_free_irq; 1127 goto err_free_irq;
diff --git a/drivers/input/touchscreen/atmel_tsadcc.c b/drivers/input/touchscreen/atmel_tsadcc.c
index 3d9b5166ebe9..432c69be6ac6 100644
--- a/drivers/input/touchscreen/atmel_tsadcc.c
+++ b/drivers/input/touchscreen/atmel_tsadcc.c
@@ -317,7 +317,7 @@ err_unmap_regs:
317err_release_mem: 317err_release_mem:
318 release_mem_region(res->start, resource_size(res)); 318 release_mem_region(res->start, resource_size(res));
319err_free_dev: 319err_free_dev:
320 input_free_device(ts_dev->input); 320 input_free_device(input_dev);
321err_free_mem: 321err_free_mem:
322 kfree(ts_dev); 322 kfree(ts_dev);
323 return err; 323 return err;
diff --git a/drivers/input/touchscreen/h3600_ts_input.c b/drivers/input/touchscreen/h3600_ts_input.c
index 45f93d0f5592..211811ae5525 100644
--- a/drivers/input/touchscreen/h3600_ts_input.c
+++ b/drivers/input/touchscreen/h3600_ts_input.c
@@ -396,14 +396,14 @@ static int h3600ts_connect(struct serio *serio, struct serio_driver *drv)
396 set_GPIO_IRQ_edge(GPIO_BITSY_NPOWER_BUTTON, GPIO_RISING_EDGE); 396 set_GPIO_IRQ_edge(GPIO_BITSY_NPOWER_BUTTON, GPIO_RISING_EDGE);
397 397
398 if (request_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, action_button_handler, 398 if (request_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, action_button_handler,
399 IRQF_SHARED | IRQF_DISABLED, "h3600_action", &ts->dev)) { 399 IRQF_SHARED | IRQF_DISABLED, "h3600_action", ts->dev)) {
400 printk(KERN_ERR "h3600ts.c: Could not allocate Action Button IRQ!\n"); 400 printk(KERN_ERR "h3600ts.c: Could not allocate Action Button IRQ!\n");
401 err = -EBUSY; 401 err = -EBUSY;
402 goto fail1; 402 goto fail1;
403 } 403 }
404 404
405 if (request_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, npower_button_handler, 405 if (request_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, npower_button_handler,
406 IRQF_SHARED | IRQF_DISABLED, "h3600_suspend", &ts->dev)) { 406 IRQF_SHARED | IRQF_DISABLED, "h3600_suspend", ts->dev)) {
407 printk(KERN_ERR "h3600ts.c: Could not allocate Power Button IRQ!\n"); 407 printk(KERN_ERR "h3600ts.c: Could not allocate Power Button IRQ!\n");
408 err = -EBUSY; 408 err = -EBUSY;
409 goto fail2; 409 goto fail2;
@@ -439,8 +439,8 @@ static void h3600ts_disconnect(struct serio *serio)
439{ 439{
440 struct h3600_dev *ts = serio_get_drvdata(serio); 440 struct h3600_dev *ts = serio_get_drvdata(serio);
441 441
442 free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev); 442 free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts->dev);
443 free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, &ts->dev); 443 free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, ts->dev);
444 input_get_device(ts->dev); 444 input_get_device(ts->dev);
445 input_unregister_device(ts->dev); 445 input_unregister_device(ts->dev);
446 serio_close(serio); 446 serio_close(serio);
diff --git a/drivers/input/touchscreen/max11801_ts.c b/drivers/input/touchscreen/max11801_ts.c
new file mode 100644
index 000000000000..4f2713d92791
--- /dev/null
+++ b/drivers/input/touchscreen/max11801_ts.c
@@ -0,0 +1,272 @@
1/*
2 * Driver for MAXI MAX11801 - A Resistive touch screen controller with
3 * i2c interface
4 *
5 * Copyright (C) 2011 Freescale Semiconductor, Inc.
6 * Author: Zhang Jiejing <jiejing.zhang@freescale.com>
7 *
8 * Based on mcs5000_ts.c
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License.
13 */
14
15/*
16 * This driver aims to support the series of MAXI touch chips max11801
17 * through max11803. The main difference between these 4 chips can be
18 * found in the table below:
19 * -----------------------------------------------------
20 * | CHIP | AUTO MODE SUPPORT(FIFO) | INTERFACE |
21 * |----------------------------------------------------|
22 * | max11800 | YES | SPI |
23 * | max11801 | YES | I2C |
24 * | max11802 | NO | SPI |
25 * | max11803 | NO | I2C |
26 * ------------------------------------------------------
27 *
28 * Currently, this driver only supports max11801.
29 *
30 * Data Sheet:
31 * http://www.maxim-ic.com/datasheet/index.mvp/id/5943
32 */
33
34#include <linux/module.h>
35#include <linux/init.h>
36#include <linux/i2c.h>
37#include <linux/interrupt.h>
38#include <linux/input.h>
39#include <linux/slab.h>
40#include <linux/bitops.h>
41
42/* Register Address define */
43#define GENERNAL_STATUS_REG 0x00
44#define GENERNAL_CONF_REG 0x01
45#define MESURE_RES_CONF_REG 0x02
46#define MESURE_AVER_CONF_REG 0x03
47#define ADC_SAMPLE_TIME_CONF_REG 0x04
48#define PANEL_SETUPTIME_CONF_REG 0x05
49#define DELAY_CONVERSION_CONF_REG 0x06
50#define TOUCH_DETECT_PULLUP_CONF_REG 0x07
51#define AUTO_MODE_TIME_CONF_REG 0x08 /* only for max11800/max11801 */
52#define APERTURE_CONF_REG 0x09 /* only for max11800/max11801 */
53#define AUX_MESURE_CONF_REG 0x0a
54#define OP_MODE_CONF_REG 0x0b
55
56/* FIFO is found only in max11800 and max11801 */
57#define FIFO_RD_CMD (0x50 << 1)
58#define MAX11801_FIFO_INT (1 << 2)
59#define MAX11801_FIFO_OVERFLOW (1 << 3)
60
61#define XY_BUFSIZE 4
62#define XY_BUF_OFFSET 4
63
64#define MAX11801_MAX_X 0xfff
65#define MAX11801_MAX_Y 0xfff
66
67#define MEASURE_TAG_OFFSET 2
68#define MEASURE_TAG_MASK (3 << MEASURE_TAG_OFFSET)
69#define EVENT_TAG_OFFSET 0
70#define EVENT_TAG_MASK (3 << EVENT_TAG_OFFSET)
71#define MEASURE_X_TAG (0 << MEASURE_TAG_OFFSET)
72#define MEASURE_Y_TAG (1 << MEASURE_TAG_OFFSET)
73
74/* These are the state of touch event state machine */
75enum {
76 EVENT_INIT,
77 EVENT_MIDDLE,
78 EVENT_RELEASE,
79 EVENT_FIFO_END
80};
81
82struct max11801_data {
83 struct i2c_client *client;
84 struct input_dev *input_dev;
85};
86
87static u8 read_register(struct i2c_client *client, int addr)
88{
89 /* XXX: The chip ignores LSB of register address */
90 return i2c_smbus_read_byte_data(client, addr << 1);
91}
92
93static int max11801_write_reg(struct i2c_client *client, int addr, int data)
94{
95 /* XXX: The chip ignores LSB of register address */
96 return i2c_smbus_write_byte_data(client, addr << 1, data);
97}
98
99static irqreturn_t max11801_ts_interrupt(int irq, void *dev_id)
100{
101 struct max11801_data *data = dev_id;
102 struct i2c_client *client = data->client;
103 int status, i, ret;
104 u8 buf[XY_BUFSIZE];
105 int x = -1;
106 int y = -1;
107
108 status = read_register(data->client, GENERNAL_STATUS_REG);
109
110 if (status & (MAX11801_FIFO_INT | MAX11801_FIFO_OVERFLOW)) {
111 status = read_register(data->client, GENERNAL_STATUS_REG);
112
113 ret = i2c_smbus_read_i2c_block_data(client, FIFO_RD_CMD,
114 XY_BUFSIZE, buf);
115
116 /*
117 * We should get 4 bytes buffer that contains X,Y
118 * and event tag
119 */
120 if (ret < XY_BUFSIZE)
121 goto out;
122
123 for (i = 0; i < XY_BUFSIZE; i += XY_BUFSIZE / 2) {
124 if ((buf[i + 1] & MEASURE_TAG_MASK) == MEASURE_X_TAG)
125 x = (buf[i] << XY_BUF_OFFSET) +
126 (buf[i + 1] >> XY_BUF_OFFSET);
127 else if ((buf[i + 1] & MEASURE_TAG_MASK) == MEASURE_Y_TAG)
128 y = (buf[i] << XY_BUF_OFFSET) +
129 (buf[i + 1] >> XY_BUF_OFFSET);
130 }
131
132 if ((buf[1] & EVENT_TAG_MASK) != (buf[3] & EVENT_TAG_MASK))
133 goto out;
134
135 switch (buf[1] & EVENT_TAG_MASK) {
136 case EVENT_INIT:
137 /* fall through */
138 case EVENT_MIDDLE:
139 input_report_abs(data->input_dev, ABS_X, x);
140 input_report_abs(data->input_dev, ABS_Y, y);
141 input_event(data->input_dev, EV_KEY, BTN_TOUCH, 1);
142 input_sync(data->input_dev);
143 break;
144
145 case EVENT_RELEASE:
146 input_event(data->input_dev, EV_KEY, BTN_TOUCH, 0);
147 input_sync(data->input_dev);
148 break;
149
150 case EVENT_FIFO_END:
151 break;
152 }
153 }
154out:
155 return IRQ_HANDLED;
156}
157
158static void __devinit max11801_ts_phy_init(struct max11801_data *data)
159{
160 struct i2c_client *client = data->client;
161
162 /* Average X,Y, take 16 samples, average eight media sample */
163 max11801_write_reg(client, MESURE_AVER_CONF_REG, 0xff);
164 /* X,Y panel setup time set to 20us */
165 max11801_write_reg(client, PANEL_SETUPTIME_CONF_REG, 0x11);
166 /* Rough pullup time (2uS), Fine pullup time (10us) */
167 max11801_write_reg(client, TOUCH_DETECT_PULLUP_CONF_REG, 0x10);
168 /* Auto mode init period = 5ms , scan period = 5ms*/
169 max11801_write_reg(client, AUTO_MODE_TIME_CONF_REG, 0xaa);
170 /* Aperture X,Y set to +- 4LSB */
171 max11801_write_reg(client, APERTURE_CONF_REG, 0x33);
172 /* Enable Power, enable Automode, enable Aperture, enable Average X,Y */
173 max11801_write_reg(client, OP_MODE_CONF_REG, 0x36);
174}
175
176static int __devinit max11801_ts_probe(struct i2c_client *client,
177 const struct i2c_device_id *id)
178{
179 struct max11801_data *data;
180 struct input_dev *input_dev;
181 int error;
182
183 data = kzalloc(sizeof(struct max11801_data), GFP_KERNEL);
184 input_dev = input_allocate_device();
185 if (!data || !input_dev) {
186 dev_err(&client->dev, "Failed to allocate memory\n");
187 error = -ENOMEM;
188 goto err_free_mem;
189 }
190
191 data->client = client;
192 data->input_dev = input_dev;
193
194 input_dev->name = "max11801_ts";
195 input_dev->id.bustype = BUS_I2C;
196 input_dev->dev.parent = &client->dev;
197
198 __set_bit(EV_ABS, input_dev->evbit);
199 __set_bit(EV_KEY, input_dev->evbit);
200 __set_bit(BTN_TOUCH, input_dev->keybit);
201 input_set_abs_params(input_dev, ABS_X, 0, MAX11801_MAX_X, 0, 0);
202 input_set_abs_params(input_dev, ABS_Y, 0, MAX11801_MAX_Y, 0, 0);
203 input_set_drvdata(input_dev, data);
204
205 max11801_ts_phy_init(data);
206
207 error = request_threaded_irq(client->irq, NULL, max11801_ts_interrupt,
208 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
209 "max11801_ts", data);
210 if (error) {
211 dev_err(&client->dev, "Failed to register interrupt\n");
212 goto err_free_mem;
213 }
214
215 error = input_register_device(data->input_dev);
216 if (error)
217 goto err_free_irq;
218
219 i2c_set_clientdata(client, data);
220 return 0;
221
222err_free_irq:
223 free_irq(client->irq, data);
224err_free_mem:
225 input_free_device(input_dev);
226 kfree(data);
227 return error;
228}
229
230static __devexit int max11801_ts_remove(struct i2c_client *client)
231{
232 struct max11801_data *data = i2c_get_clientdata(client);
233
234 free_irq(client->irq, data);
235 input_unregister_device(data->input_dev);
236 kfree(data);
237
238 return 0;
239}
240
241static const struct i2c_device_id max11801_ts_id[] = {
242 {"max11801", 0},
243 { }
244};
245MODULE_DEVICE_TABLE(i2c, max11801_ts_id);
246
247static struct i2c_driver max11801_ts_driver = {
248 .driver = {
249 .name = "max11801_ts",
250 .owner = THIS_MODULE,
251 },
252 .id_table = max11801_ts_id,
253 .probe = max11801_ts_probe,
254 .remove = __devexit_p(max11801_ts_remove),
255};
256
257static int __init max11801_ts_init(void)
258{
259 return i2c_add_driver(&max11801_ts_driver);
260}
261
262static void __exit max11801_ts_exit(void)
263{
264 i2c_del_driver(&max11801_ts_driver);
265}
266
267module_init(max11801_ts_init);
268module_exit(max11801_ts_exit);
269
270MODULE_AUTHOR("Zhang Jiejing <jiejing.zhang@freescale.com>");
271MODULE_DESCRIPTION("Touchscreen driver for MAXI MAX11801 controller");
272MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
index 80467f262331..fadc11545b1e 100644
--- a/drivers/input/touchscreen/tsc2007.c
+++ b/drivers/input/touchscreen/tsc2007.c
@@ -27,9 +27,6 @@
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28#include <linux/i2c/tsc2007.h> 28#include <linux/i2c/tsc2007.h>
29 29
30#define TS_POLL_DELAY 1 /* ms delay between samples */
31#define TS_POLL_PERIOD 1 /* ms delay between samples */
32
33#define TSC2007_MEASURE_TEMP0 (0x0 << 4) 30#define TSC2007_MEASURE_TEMP0 (0x0 << 4)
34#define TSC2007_MEASURE_AUX (0x2 << 4) 31#define TSC2007_MEASURE_AUX (0x2 << 4)
35#define TSC2007_MEASURE_TEMP1 (0x4 << 4) 32#define TSC2007_MEASURE_TEMP1 (0x4 << 4)
@@ -75,6 +72,9 @@ struct tsc2007 {
75 72
76 u16 model; 73 u16 model;
77 u16 x_plate_ohms; 74 u16 x_plate_ohms;
75 u16 max_rt;
76 unsigned long poll_delay;
77 unsigned long poll_period;
78 78
79 bool pendown; 79 bool pendown;
80 int irq; 80 int irq;
@@ -156,6 +156,7 @@ static void tsc2007_work(struct work_struct *work)
156{ 156{
157 struct tsc2007 *ts = 157 struct tsc2007 *ts =
158 container_of(to_delayed_work(work), struct tsc2007, work); 158 container_of(to_delayed_work(work), struct tsc2007, work);
159 bool debounced = false;
159 struct ts_event tc; 160 struct ts_event tc;
160 u32 rt; 161 u32 rt;
161 162
@@ -184,13 +185,14 @@ static void tsc2007_work(struct work_struct *work)
184 tsc2007_read_values(ts, &tc); 185 tsc2007_read_values(ts, &tc);
185 186
186 rt = tsc2007_calculate_pressure(ts, &tc); 187 rt = tsc2007_calculate_pressure(ts, &tc);
187 if (rt > MAX_12BIT) { 188 if (rt > ts->max_rt) {
188 /* 189 /*
189 * Sample found inconsistent by debouncing or pressure is 190 * Sample found inconsistent by debouncing or pressure is
190 * beyond the maximum. Don't report it to user space, 191 * beyond the maximum. Don't report it to user space,
191 * repeat at least once more the measurement. 192 * repeat at least once more the measurement.
192 */ 193 */
193 dev_dbg(&ts->client->dev, "ignored pressure %d\n", rt); 194 dev_dbg(&ts->client->dev, "ignored pressure %d\n", rt);
195 debounced = true;
194 goto out; 196 goto out;
195 197
196 } 198 }
@@ -225,9 +227,9 @@ static void tsc2007_work(struct work_struct *work)
225 } 227 }
226 228
227 out: 229 out:
228 if (ts->pendown) 230 if (ts->pendown || debounced)
229 schedule_delayed_work(&ts->work, 231 schedule_delayed_work(&ts->work,
230 msecs_to_jiffies(TS_POLL_PERIOD)); 232 msecs_to_jiffies(ts->poll_period));
231 else 233 else
232 enable_irq(ts->irq); 234 enable_irq(ts->irq);
233} 235}
@@ -239,7 +241,7 @@ static irqreturn_t tsc2007_irq(int irq, void *handle)
239 if (!ts->get_pendown_state || likely(ts->get_pendown_state())) { 241 if (!ts->get_pendown_state || likely(ts->get_pendown_state())) {
240 disable_irq_nosync(ts->irq); 242 disable_irq_nosync(ts->irq);
241 schedule_delayed_work(&ts->work, 243 schedule_delayed_work(&ts->work,
242 msecs_to_jiffies(TS_POLL_DELAY)); 244 msecs_to_jiffies(ts->poll_delay));
243 } 245 }
244 246
245 if (ts->clear_penirq) 247 if (ts->clear_penirq)
@@ -292,6 +294,9 @@ static int __devinit tsc2007_probe(struct i2c_client *client,
292 294
293 ts->model = pdata->model; 295 ts->model = pdata->model;
294 ts->x_plate_ohms = pdata->x_plate_ohms; 296 ts->x_plate_ohms = pdata->x_plate_ohms;
297 ts->max_rt = pdata->max_rt ? : MAX_12BIT;
298 ts->poll_delay = pdata->poll_delay ? : 1;
299 ts->poll_period = pdata->poll_period ? : 1;
295 ts->get_pendown_state = pdata->get_pendown_state; 300 ts->get_pendown_state = pdata->get_pendown_state;
296 ts->clear_penirq = pdata->clear_penirq; 301 ts->clear_penirq = pdata->clear_penirq;
297 302
@@ -305,9 +310,10 @@ static int __devinit tsc2007_probe(struct i2c_client *client,
305 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 310 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
306 input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); 311 input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
307 312
308 input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0); 313 input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, pdata->fuzzx, 0);
309 input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0); 314 input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, pdata->fuzzy, 0);
310 input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT, 0, 0); 315 input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT,
316 pdata->fuzzz, 0);
311 317
312 if (pdata->init_platform_hw) 318 if (pdata->init_platform_hw)
313 pdata->init_platform_hw(); 319 pdata->init_platform_hw();
diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
index dd1a56fbe924..b5ca4b2c08ec 100644
--- a/include/linux/gpio_keys.h
+++ b/include/linux/gpio_keys.h
@@ -3,14 +3,15 @@
3 3
4struct gpio_keys_button { 4struct gpio_keys_button {
5 /* Configuration parameters */ 5 /* Configuration parameters */
6 int code; /* input event code (KEY_*, SW_*) */ 6 unsigned int code; /* input event code (KEY_*, SW_*) */
7 int gpio; 7 int gpio;
8 int active_low; 8 int active_low;
9 char *desc; 9 const char *desc;
10 int type; /* input event type (EV_KEY, EV_SW) */ 10 unsigned int type; /* input event type (EV_KEY, EV_SW, EV_ABS) */
11 int wakeup; /* configure the button as a wake-up source */ 11 int wakeup; /* configure the button as a wake-up source */
12 int debounce_interval; /* debounce ticks interval in msecs */ 12 int debounce_interval; /* debounce ticks interval in msecs */
13 bool can_disable; 13 bool can_disable;
14 int value; /* axis value for EV_ABS */
14}; 15};
15 16
16struct gpio_keys_platform_data { 17struct gpio_keys_platform_data {
@@ -21,6 +22,7 @@ struct gpio_keys_platform_data {
21 unsigned int rep:1; /* enable input subsystem auto repeat */ 22 unsigned int rep:1; /* enable input subsystem auto repeat */
22 int (*enable)(struct device *dev); 23 int (*enable)(struct device *dev);
23 void (*disable)(struct device *dev); 24 void (*disable)(struct device *dev);
25 const char *name; /* input device name */
24}; 26};
25 27
26#endif 28#endif
diff --git a/include/linux/i2c/mpr121_touchkey.h b/include/linux/i2c/mpr121_touchkey.h
new file mode 100644
index 000000000000..f0bcc38bbb97
--- /dev/null
+++ b/include/linux/i2c/mpr121_touchkey.h
@@ -0,0 +1,20 @@
1/* Header file for Freescale MPR121 Capacitive Touch Sensor */
2
3#ifndef _MPR121_TOUCHKEY_H
4#define _MPR121_TOUCHKEY_H
5
6/**
7 * struct mpr121_platform_data - platform data for mpr121 sensor
8 * @keymap: pointer to array of KEY_* values representing keymap
9 * @keymap_size: size of the keymap
10 * @wakeup: configure the button as a wake-up source
11 * @vdd_uv: VDD voltage in uV
12 */
13struct mpr121_platform_data {
14 const unsigned short *keymap;
15 unsigned int keymap_size;
16 bool wakeup;
17 int vdd_uv;
18};
19
20#endif /* _MPR121_TOUCHKEY_H */
diff --git a/include/linux/i2c/tsc2007.h b/include/linux/i2c/tsc2007.h
index c6361fbb7bf9..591427a63b06 100644
--- a/include/linux/i2c/tsc2007.h
+++ b/include/linux/i2c/tsc2007.h
@@ -6,6 +6,13 @@
6struct tsc2007_platform_data { 6struct tsc2007_platform_data {
7 u16 model; /* 2007. */ 7 u16 model; /* 2007. */
8 u16 x_plate_ohms; 8 u16 x_plate_ohms;
9 u16 max_rt; /* max. resistance above which samples are ignored */
10 unsigned long poll_delay; /* delay (in ms) after pen-down event
11 before polling starts */
12 unsigned long poll_period; /* time (in ms) between samples */
13 int fuzzx; /* fuzz factor for X, Y and pressure axes */
14 int fuzzy;
15 int fuzzz;
9 16
10 int (*get_pendown_state)(void); 17 int (*get_pendown_state)(void);
11 void (*clear_penirq)(void); /* If needed, clear 2nd level 18 void (*clear_penirq)(void); /* If needed, clear 2nd level
diff --git a/include/linux/input/ad714x.h b/include/linux/input/ad714x.h
index 0cbe5e81482e..d388d857bf14 100644
--- a/include/linux/input/ad714x.h
+++ b/include/linux/input/ad714x.h
@@ -6,7 +6,7 @@
6 * The platform_data for the device's "struct device" holds this 6 * The platform_data for the device's "struct device" holds this
7 * information. 7 * information.
8 * 8 *
9 * Copyright 2009 Analog Devices Inc. 9 * Copyright 2009-2011 Analog Devices Inc.
10 * 10 *
11 * Licensed under the GPL-2 or later. 11 * Licensed under the GPL-2 or later.
12 */ 12 */
@@ -58,6 +58,7 @@ struct ad714x_platform_data {
58 struct ad714x_button_plat *button; 58 struct ad714x_button_plat *button;
59 unsigned short stage_cfg_reg[STAGE_NUM][STAGE_CFGREG_NUM]; 59 unsigned short stage_cfg_reg[STAGE_NUM][STAGE_CFGREG_NUM];
60 unsigned short sys_cfg_reg[SYS_CFGREG_NUM]; 60 unsigned short sys_cfg_reg[SYS_CFGREG_NUM];
61 unsigned long irqflags;
61}; 62};
62 63
63#endif 64#endif
diff --git a/include/linux/input/adp5589.h b/include/linux/input/adp5589.h
new file mode 100644
index 000000000000..ef792ecfaabf
--- /dev/null
+++ b/include/linux/input/adp5589.h
@@ -0,0 +1,213 @@
1/*
2 * Analog Devices ADP5589 I/O Expander and QWERTY Keypad Controller
3 *
4 * Copyright 2010-2011 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2.
7 */
8
9#ifndef _ADP5589_H
10#define _ADP5589_H
11
12#define ADP5589_ID 0x00
13#define ADP5589_INT_STATUS 0x01
14#define ADP5589_STATUS 0x02
15#define ADP5589_FIFO_1 0x03
16#define ADP5589_FIFO_2 0x04
17#define ADP5589_FIFO_3 0x05
18#define ADP5589_FIFO_4 0x06
19#define ADP5589_FIFO_5 0x07
20#define ADP5589_FIFO_6 0x08
21#define ADP5589_FIFO_7 0x09
22#define ADP5589_FIFO_8 0x0A
23#define ADP5589_FIFO_9 0x0B
24#define ADP5589_FIFO_10 0x0C
25#define ADP5589_FIFO_11 0x0D
26#define ADP5589_FIFO_12 0x0E
27#define ADP5589_FIFO_13 0x0F
28#define ADP5589_FIFO_14 0x10
29#define ADP5589_FIFO_15 0x11
30#define ADP5589_FIFO_16 0x12
31#define ADP5589_GPI_INT_STAT_A 0x13
32#define ADP5589_GPI_INT_STAT_B 0x14
33#define ADP5589_GPI_INT_STAT_C 0x15
34#define ADP5589_GPI_STATUS_A 0x16
35#define ADP5589_GPI_STATUS_B 0x17
36#define ADP5589_GPI_STATUS_C 0x18
37#define ADP5589_RPULL_CONFIG_A 0x19
38#define ADP5589_RPULL_CONFIG_B 0x1A
39#define ADP5589_RPULL_CONFIG_C 0x1B
40#define ADP5589_RPULL_CONFIG_D 0x1C
41#define ADP5589_RPULL_CONFIG_E 0x1D
42#define ADP5589_GPI_INT_LEVEL_A 0x1E
43#define ADP5589_GPI_INT_LEVEL_B 0x1F
44#define ADP5589_GPI_INT_LEVEL_C 0x20
45#define ADP5589_GPI_EVENT_EN_A 0x21
46#define ADP5589_GPI_EVENT_EN_B 0x22
47#define ADP5589_GPI_EVENT_EN_C 0x23
48#define ADP5589_GPI_INTERRUPT_EN_A 0x24
49#define ADP5589_GPI_INTERRUPT_EN_B 0x25
50#define ADP5589_GPI_INTERRUPT_EN_C 0x26
51#define ADP5589_DEBOUNCE_DIS_A 0x27
52#define ADP5589_DEBOUNCE_DIS_B 0x28
53#define ADP5589_DEBOUNCE_DIS_C 0x29
54#define ADP5589_GPO_DATA_OUT_A 0x2A
55#define ADP5589_GPO_DATA_OUT_B 0x2B
56#define ADP5589_GPO_DATA_OUT_C 0x2C
57#define ADP5589_GPO_OUT_MODE_A 0x2D
58#define ADP5589_GPO_OUT_MODE_B 0x2E
59#define ADP5589_GPO_OUT_MODE_C 0x2F
60#define ADP5589_GPIO_DIRECTION_A 0x30
61#define ADP5589_GPIO_DIRECTION_B 0x31
62#define ADP5589_GPIO_DIRECTION_C 0x32
63#define ADP5589_UNLOCK1 0x33
64#define ADP5589_UNLOCK2 0x34
65#define ADP5589_EXT_LOCK_EVENT 0x35
66#define ADP5589_UNLOCK_TIMERS 0x36
67#define ADP5589_LOCK_CFG 0x37
68#define ADP5589_RESET1_EVENT_A 0x38
69#define ADP5589_RESET1_EVENT_B 0x39
70#define ADP5589_RESET1_EVENT_C 0x3A
71#define ADP5589_RESET2_EVENT_A 0x3B
72#define ADP5589_RESET2_EVENT_B 0x3C
73#define ADP5589_RESET_CFG 0x3D
74#define ADP5589_PWM_OFFT_LOW 0x3E
75#define ADP5589_PWM_OFFT_HIGH 0x3F
76#define ADP5589_PWM_ONT_LOW 0x40
77#define ADP5589_PWM_ONT_HIGH 0x41
78#define ADP5589_PWM_CFG 0x42
79#define ADP5589_CLOCK_DIV_CFG 0x43
80#define ADP5589_LOGIC_1_CFG 0x44
81#define ADP5589_LOGIC_2_CFG 0x45
82#define ADP5589_LOGIC_FF_CFG 0x46
83#define ADP5589_LOGIC_INT_EVENT_EN 0x47
84#define ADP5589_POLL_PTIME_CFG 0x48
85#define ADP5589_PIN_CONFIG_A 0x49
86#define ADP5589_PIN_CONFIG_B 0x4A
87#define ADP5589_PIN_CONFIG_C 0x4B
88#define ADP5589_PIN_CONFIG_D 0x4C
89#define ADP5589_GENERAL_CFG 0x4D
90#define ADP5589_INT_EN 0x4E
91
92#define ADP5589_DEVICE_ID_MASK 0xF
93
94/* Put one of these structures in i2c_board_info platform_data */
95
96#define ADP5589_KEYMAPSIZE 88
97
98#define ADP5589_GPI_PIN_ROW0 97
99#define ADP5589_GPI_PIN_ROW1 98
100#define ADP5589_GPI_PIN_ROW2 99
101#define ADP5589_GPI_PIN_ROW3 100
102#define ADP5589_GPI_PIN_ROW4 101
103#define ADP5589_GPI_PIN_ROW5 102
104#define ADP5589_GPI_PIN_ROW6 103
105#define ADP5589_GPI_PIN_ROW7 104
106#define ADP5589_GPI_PIN_COL0 105
107#define ADP5589_GPI_PIN_COL1 106
108#define ADP5589_GPI_PIN_COL2 107
109#define ADP5589_GPI_PIN_COL3 108
110#define ADP5589_GPI_PIN_COL4 109
111#define ADP5589_GPI_PIN_COL5 110
112#define ADP5589_GPI_PIN_COL6 111
113#define ADP5589_GPI_PIN_COL7 112
114#define ADP5589_GPI_PIN_COL8 113
115#define ADP5589_GPI_PIN_COL9 114
116#define ADP5589_GPI_PIN_COL10 115
117#define GPI_LOGIC1 116
118#define GPI_LOGIC2 117
119
120#define ADP5589_GPI_PIN_ROW_BASE ADP5589_GPI_PIN_ROW0
121#define ADP5589_GPI_PIN_ROW_END ADP5589_GPI_PIN_ROW7
122#define ADP5589_GPI_PIN_COL_BASE ADP5589_GPI_PIN_COL0
123#define ADP5589_GPI_PIN_COL_END ADP5589_GPI_PIN_COL10
124
125#define ADP5589_GPI_PIN_BASE ADP5589_GPI_PIN_ROW_BASE
126#define ADP5589_GPI_PIN_END ADP5589_GPI_PIN_COL_END
127
128#define ADP5589_GPIMAPSIZE_MAX (ADP5589_GPI_PIN_END - ADP5589_GPI_PIN_BASE + 1)
129
130struct adp5589_gpi_map {
131 unsigned short pin;
132 unsigned short sw_evt;
133};
134
135/* scan_cycle_time */
136#define ADP5589_SCAN_CYCLE_10ms 0
137#define ADP5589_SCAN_CYCLE_20ms 1
138#define ADP5589_SCAN_CYCLE_30ms 2
139#define ADP5589_SCAN_CYCLE_40ms 3
140
141/* RESET_CFG */
142#define RESET_PULSE_WIDTH_500us 0
143#define RESET_PULSE_WIDTH_1ms 1
144#define RESET_PULSE_WIDTH_2ms 2
145#define RESET_PULSE_WIDTH_10ms 3
146
147#define RESET_TRIG_TIME_0ms (0 << 2)
148#define RESET_TRIG_TIME_1000ms (1 << 2)
149#define RESET_TRIG_TIME_1500ms (2 << 2)
150#define RESET_TRIG_TIME_2000ms (3 << 2)
151#define RESET_TRIG_TIME_2500ms (4 << 2)
152#define RESET_TRIG_TIME_3000ms (5 << 2)
153#define RESET_TRIG_TIME_3500ms (6 << 2)
154#define RESET_TRIG_TIME_4000ms (7 << 2)
155
156#define RESET_PASSTHRU_EN (1 << 5)
157#define RESET1_POL_HIGH (1 << 6)
158#define RESET1_POL_LOW (0 << 6)
159#define RESET2_POL_HIGH (1 << 7)
160#define RESET2_POL_LOW (0 << 7)
161
162/* Mask Bits:
163 * C C C C C C C C C C C | R R R R R R R R
164 * 1 9 8 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0
165 * 0
166 * ---------------- BIT ------------------
167 * 1 1 1 1 1 1 1 1 1 0 0 | 0 0 0 0 0 0 0 0
168 * 8 7 6 5 4 3 2 1 0 9 8 | 7 6 5 4 3 2 1 0
169 */
170
171#define ADP_ROW(x) (1 << (x))
172#define ADP_COL(x) (1 << (x + 8))
173
174struct adp5589_kpad_platform_data {
175 unsigned keypad_en_mask; /* Keypad (Rows/Columns) enable mask */
176 const unsigned short *keymap; /* Pointer to keymap */
177 unsigned short keymapsize; /* Keymap size */
178 bool repeat; /* Enable key repeat */
179 bool en_keylock; /* Enable key lock feature */
180 unsigned char unlock_key1; /* Unlock Key 1 */
181 unsigned char unlock_key2; /* Unlock Key 2 */
182 unsigned char unlock_timer; /* Time in seconds [0..7] between the two unlock keys 0=disable */
183 unsigned char scan_cycle_time; /* Time between consecutive scan cycles */
184 unsigned char reset_cfg; /* Reset config */
185 unsigned short reset1_key_1; /* Reset Key 1 */
186 unsigned short reset1_key_2; /* Reset Key 2 */
187 unsigned short reset1_key_3; /* Reset Key 3 */
188 unsigned short reset2_key_1; /* Reset Key 1 */
189 unsigned short reset2_key_2; /* Reset Key 2 */
190 unsigned debounce_dis_mask; /* Disable debounce mask */
191 unsigned pull_dis_mask; /* Disable all pull resistors mask */
192 unsigned pullup_en_100k; /* Pull-Up 100k Enable Mask */
193 unsigned pullup_en_300k; /* Pull-Up 300k Enable Mask */
194 unsigned pulldown_en_300k; /* Pull-Down 300k Enable Mask */
195 const struct adp5589_gpi_map *gpimap;
196 unsigned short gpimapsize;
197 const struct adp5589_gpio_platform_data *gpio_data;
198};
199
200struct i2c_client; /* forward declaration */
201
202struct adp5589_gpio_platform_data {
203 int gpio_start; /* GPIO Chip base # */
204 int (*setup)(struct i2c_client *client,
205 int gpio, unsigned ngpio,
206 void *context);
207 int (*teardown)(struct i2c_client *client,
208 int gpio, unsigned ngpio,
209 void *context);
210 void *context;
211};
212
213#endif
diff --git a/include/linux/rotary_encoder.h b/include/linux/rotary_encoder.h
index 215278b8df2a..3f594dce5716 100644
--- a/include/linux/rotary_encoder.h
+++ b/include/linux/rotary_encoder.h
@@ -10,6 +10,7 @@ struct rotary_encoder_platform_data {
10 unsigned int inverted_b; 10 unsigned int inverted_b;
11 bool relative_axis; 11 bool relative_axis;
12 bool rollover; 12 bool rollover;
13 bool half_period;
13}; 14};
14 15
15#endif /* __ROTARY_ENCODER_H__ */ 16#endif /* __ROTARY_ENCODER_H__ */
diff --git a/include/linux/spi/ads7846.h b/include/linux/spi/ads7846.h
index 92bd0839d5b4..c64de9dd7631 100644
--- a/include/linux/spi/ads7846.h
+++ b/include/linux/spi/ads7846.h
@@ -14,7 +14,8 @@ enum ads7846_filter {
14struct ads7846_platform_data { 14struct ads7846_platform_data {
15 u16 model; /* 7843, 7845, 7846, 7873. */ 15 u16 model; /* 7843, 7845, 7846, 7873. */
16 u16 vref_delay_usecs; /* 0 for external vref; etc */ 16 u16 vref_delay_usecs; /* 0 for external vref; etc */
17 u16 vref_mv; /* external vref value, milliVolts */ 17 u16 vref_mv; /* external vref value, milliVolts
18 * ads7846: if 0, use internal vref */
18 bool keep_vref_on; /* set to keep vref on for differential 19 bool keep_vref_on; /* set to keep vref on for differential
19 * measurements as well */ 20 * measurements as well */
20 bool swap_xy; /* swap x and y axes */ 21 bool swap_xy; /* swap x and y axes */