aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/Kconfig10
-rw-r--r--drivers/input/Makefile2
-rw-r--r--drivers/input/evdev.c43
-rw-r--r--drivers/input/input-polldev.c4
-rw-r--r--drivers/input/input.c95
-rw-r--r--drivers/input/joydev.c4
-rw-r--r--drivers/input/joystick/a3d.c4
-rw-r--r--drivers/input/keyboard/Kconfig10
-rw-r--r--drivers/input/keyboard/Makefile1
-rw-r--r--drivers/input/keyboard/davinci_keyscan.c2
-rw-r--r--drivers/input/keyboard/lm8323.c19
-rw-r--r--drivers/input/keyboard/max7359_keypad.c17
-rw-r--r--drivers/input/keyboard/mcs_touchkey.c57
-rw-r--r--drivers/input/keyboard/omap4-keypad.c74
-rw-r--r--drivers/input/keyboard/qt1070.c276
-rw-r--r--drivers/input/keyboard/spear-keyboard.c2
-rw-r--r--drivers/input/keyboard/tc3589x-keypad.c22
-rw-r--r--drivers/input/keyboard/tca6416-keypad.c28
-rw-r--r--drivers/input/keyboard/twl4030_keypad.c6
-rw-r--r--drivers/input/misc/88pm860x_onkey.c2
-rw-r--r--drivers/input/misc/Kconfig13
-rw-r--r--drivers/input/misc/Makefile1
-rw-r--r--drivers/input/misc/ad714x-i2c.c17
-rw-r--r--drivers/input/misc/ad714x-spi.c17
-rw-r--r--drivers/input/misc/adxl34x-i2c.c16
-rw-r--r--drivers/input/misc/adxl34x-spi.c20
-rw-r--r--drivers/input/misc/adxl34x.c2
-rw-r--r--drivers/input/misc/ati_remote2.c4
-rw-r--r--drivers/input/misc/keyspan_remote.c2
-rw-r--r--drivers/input/misc/twl4030-vibra.c3
-rw-r--r--drivers/input/misc/uinput.c54
-rw-r--r--drivers/input/misc/wistron_btns.c2
-rw-r--r--drivers/input/misc/xen-kbdfront.c (renamed from drivers/input/xen-kbdfront.c)74
-rw-r--r--drivers/input/mouse/bcm5974.c30
-rw-r--r--drivers/input/mouse/synaptics.c4
-rw-r--r--drivers/input/mouse/synaptics_i2c.c18
-rw-r--r--drivers/input/mouse/vsxxxaa.c2
-rw-r--r--drivers/input/serio/ams_delta_serio.c2
-rw-r--r--drivers/input/serio/hp_sdc.c2
-rw-r--r--drivers/input/serio/i8042.c7
-rw-r--r--drivers/input/serio/rpckbd.c2
-rw-r--r--drivers/input/serio/xilinx_ps2.c2
-rw-r--r--drivers/input/sparse-keymap.c18
-rw-r--r--drivers/input/tablet/wacom_sys.c12
-rw-r--r--drivers/input/tablet/wacom_wac.c528
-rw-r--r--drivers/input/tablet/wacom_wac.h8
-rw-r--r--drivers/input/touchscreen/Kconfig45
-rw-r--r--drivers/input/touchscreen/Makefile4
-rw-r--r--drivers/input/touchscreen/ad7877.c19
-rw-r--r--drivers/input/touchscreen/ad7879-spi.c17
-rw-r--r--drivers/input/touchscreen/ads7846.c16
-rw-r--r--drivers/input/touchscreen/atmel_mxt_ts.c1211
-rw-r--r--drivers/input/touchscreen/h3600_ts_input.c19
-rw-r--r--drivers/input/touchscreen/intel-mid-touch.c2
-rw-r--r--drivers/input/touchscreen/mainstone-wm97xx.c2
-rw-r--r--drivers/input/touchscreen/qt602240_ts.c1406
-rw-r--r--drivers/input/touchscreen/tsc2005.c764
-rw-r--r--drivers/input/touchscreen/ucb1400_ts.c2
-rw-r--r--drivers/input/touchscreen/wm831x-ts.c368
-rw-r--r--drivers/input/touchscreen/wm9705.c2
-rw-r--r--drivers/input/touchscreen/wm9712.c2
-rw-r--r--drivers/input/touchscreen/wm9713.c2
-rw-r--r--drivers/input/touchscreen/wm97xx-core.c4
-rw-r--r--drivers/input/touchscreen/zylonite-wm97xx.c2
64 files changed, 3451 insertions, 1974 deletions
diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index 1903c0f5b925..23e82e46656d 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -161,16 +161,6 @@ config INPUT_APMPOWER
161 To compile this driver as a module, choose M here: the 161 To compile this driver as a module, choose M here: the
162 module will be called apm-power. 162 module will be called apm-power.
163 163
164config XEN_KBDDEV_FRONTEND
165 tristate "Xen virtual keyboard and mouse support"
166 depends on XEN_FBDEV_FRONTEND
167 default y
168 select XEN_XENBUS_FRONTEND
169 help
170 This driver implements the front-end of the Xen virtual
171 keyboard and mouse device driver. It communicates with a back-end
172 in another domain.
173
174comment "Input Device Drivers" 164comment "Input Device Drivers"
175 165
176source "drivers/input/keyboard/Kconfig" 166source "drivers/input/keyboard/Kconfig"
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index 09614ce74961..0c789490e0b3 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -24,5 +24,3 @@ obj-$(CONFIG_INPUT_TOUCHSCREEN) += touchscreen/
24obj-$(CONFIG_INPUT_MISC) += misc/ 24obj-$(CONFIG_INPUT_MISC) += misc/
25 25
26obj-$(CONFIG_INPUT_APMPOWER) += apm-power.o 26obj-$(CONFIG_INPUT_APMPOWER) += apm-power.o
27
28obj-$(CONFIG_XEN_KBDDEV_FRONTEND) += xen-kbdfront.o
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index c8471a2552e7..88d8e4cb419a 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -39,13 +39,13 @@ struct evdev {
39}; 39};
40 40
41struct evdev_client { 41struct evdev_client {
42 int head; 42 unsigned int head;
43 int tail; 43 unsigned int tail;
44 spinlock_t buffer_lock; /* protects access to buffer, head and tail */ 44 spinlock_t buffer_lock; /* protects access to buffer, head and tail */
45 struct fasync_struct *fasync; 45 struct fasync_struct *fasync;
46 struct evdev *evdev; 46 struct evdev *evdev;
47 struct list_head node; 47 struct list_head node;
48 int bufsize; 48 unsigned int bufsize;
49 struct input_event buffer[]; 49 struct input_event buffer[];
50}; 50};
51 51
@@ -55,16 +55,25 @@ static DEFINE_MUTEX(evdev_table_mutex);
55static void evdev_pass_event(struct evdev_client *client, 55static void evdev_pass_event(struct evdev_client *client,
56 struct input_event *event) 56 struct input_event *event)
57{ 57{
58 /* 58 /* Interrupts are disabled, just acquire the lock. */
59 * Interrupts are disabled, just acquire the lock.
60 * Make sure we don't leave with the client buffer
61 * "empty" by having client->head == client->tail.
62 */
63 spin_lock(&client->buffer_lock); 59 spin_lock(&client->buffer_lock);
64 do { 60
65 client->buffer[client->head++] = *event; 61 client->buffer[client->head++] = *event;
66 client->head &= client->bufsize - 1; 62 client->head &= client->bufsize - 1;
67 } while (client->head == client->tail); 63
64 if (unlikely(client->head == client->tail)) {
65 /*
66 * This effectively "drops" all unconsumed events, leaving
67 * EV_SYN/SYN_DROPPED plus the newest event in the queue.
68 */
69 client->tail = (client->head - 2) & (client->bufsize - 1);
70
71 client->buffer[client->tail].time = event->time;
72 client->buffer[client->tail].type = EV_SYN;
73 client->buffer[client->tail].code = SYN_DROPPED;
74 client->buffer[client->tail].value = 0;
75 }
76
68 spin_unlock(&client->buffer_lock); 77 spin_unlock(&client->buffer_lock);
69 78
70 if (event->type == EV_SYN) 79 if (event->type == EV_SYN)
@@ -321,6 +330,9 @@ static ssize_t evdev_write(struct file *file, const char __user *buffer,
321 struct input_event event; 330 struct input_event event;
322 int retval; 331 int retval;
323 332
333 if (count < input_event_size())
334 return -EINVAL;
335
324 retval = mutex_lock_interruptible(&evdev->mutex); 336 retval = mutex_lock_interruptible(&evdev->mutex);
325 if (retval) 337 if (retval)
326 return retval; 338 return retval;
@@ -330,17 +342,16 @@ static ssize_t evdev_write(struct file *file, const char __user *buffer,
330 goto out; 342 goto out;
331 } 343 }
332 344
333 while (retval < count) { 345 do {
334
335 if (input_event_from_user(buffer + retval, &event)) { 346 if (input_event_from_user(buffer + retval, &event)) {
336 retval = -EFAULT; 347 retval = -EFAULT;
337 goto out; 348 goto out;
338 } 349 }
350 retval += input_event_size();
339 351
340 input_inject_event(&evdev->handle, 352 input_inject_event(&evdev->handle,
341 event.type, event.code, event.value); 353 event.type, event.code, event.value);
342 retval += input_event_size(); 354 } while (retval + input_event_size() <= count);
343 }
344 355
345 out: 356 out:
346 mutex_unlock(&evdev->mutex); 357 mutex_unlock(&evdev->mutex);
diff --git a/drivers/input/input-polldev.c b/drivers/input/input-polldev.c
index 0559e309bac9..3037842a60d8 100644
--- a/drivers/input/input-polldev.c
+++ b/drivers/input/input-polldev.c
@@ -192,7 +192,7 @@ static struct attribute_group input_polldev_attribute_group = {
192}; 192};
193 193
194/** 194/**
195 * input_allocate_polled_device - allocated memory polled device 195 * input_allocate_polled_device - allocate memory for polled device
196 * 196 *
197 * The function allocates memory for a polled device and also 197 * The function allocates memory for a polled device and also
198 * for an input device associated with this polled device. 198 * for an input device associated with this polled device.
@@ -239,7 +239,7 @@ EXPORT_SYMBOL(input_free_polled_device);
239 * with input layer. The device should be allocated with call to 239 * with input layer. The device should be allocated with call to
240 * input_allocate_polled_device(). Callers should also set up poll() 240 * input_allocate_polled_device(). Callers should also set up poll()
241 * method and set up capabilities (id, name, phys, bits) of the 241 * method and set up capabilities (id, name, phys, bits) of the
242 * corresponing input_dev structure. 242 * corresponding input_dev structure.
243 */ 243 */
244int input_register_polled_device(struct input_polled_dev *dev) 244int input_register_polled_device(struct input_polled_dev *dev)
245{ 245{
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 11905b6a3023..ebbceedc92f4 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -791,22 +791,9 @@ int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke)
791 int retval; 791 int retval;
792 792
793 spin_lock_irqsave(&dev->event_lock, flags); 793 spin_lock_irqsave(&dev->event_lock, flags);
794 794 retval = dev->getkeycode(dev, ke);
795 if (dev->getkeycode) {
796 /*
797 * Support for legacy drivers, that don't implement the new
798 * ioctls
799 */
800 u32 scancode = ke->index;
801
802 memcpy(ke->scancode, &scancode, sizeof(scancode));
803 ke->len = sizeof(scancode);
804 retval = dev->getkeycode(dev, scancode, &ke->keycode);
805 } else {
806 retval = dev->getkeycode_new(dev, ke);
807 }
808
809 spin_unlock_irqrestore(&dev->event_lock, flags); 795 spin_unlock_irqrestore(&dev->event_lock, flags);
796
810 return retval; 797 return retval;
811} 798}
812EXPORT_SYMBOL(input_get_keycode); 799EXPORT_SYMBOL(input_get_keycode);
@@ -831,35 +818,7 @@ int input_set_keycode(struct input_dev *dev,
831 818
832 spin_lock_irqsave(&dev->event_lock, flags); 819 spin_lock_irqsave(&dev->event_lock, flags);
833 820
834 if (dev->setkeycode) { 821 retval = dev->setkeycode(dev, ke, &old_keycode);
835 /*
836 * Support for legacy drivers, that don't implement the new
837 * ioctls
838 */
839 unsigned int scancode;
840
841 retval = input_scancode_to_scalar(ke, &scancode);
842 if (retval)
843 goto out;
844
845 /*
846 * We need to know the old scancode, in order to generate a
847 * keyup effect, if the set operation happens successfully
848 */
849 if (!dev->getkeycode) {
850 retval = -EINVAL;
851 goto out;
852 }
853
854 retval = dev->getkeycode(dev, scancode, &old_keycode);
855 if (retval)
856 goto out;
857
858 retval = dev->setkeycode(dev, scancode, ke->keycode);
859 } else {
860 retval = dev->setkeycode_new(dev, ke, &old_keycode);
861 }
862
863 if (retval) 822 if (retval)
864 goto out; 823 goto out;
865 824
@@ -1787,6 +1746,42 @@ void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int
1787} 1746}
1788EXPORT_SYMBOL(input_set_capability); 1747EXPORT_SYMBOL(input_set_capability);
1789 1748
1749static unsigned int input_estimate_events_per_packet(struct input_dev *dev)
1750{
1751 int mt_slots;
1752 int i;
1753 unsigned int events;
1754
1755 if (dev->mtsize) {
1756 mt_slots = dev->mtsize;
1757 } else if (test_bit(ABS_MT_TRACKING_ID, dev->absbit)) {
1758 mt_slots = dev->absinfo[ABS_MT_TRACKING_ID].maximum -
1759 dev->absinfo[ABS_MT_TRACKING_ID].minimum + 1,
1760 clamp(mt_slots, 2, 32);
1761 } else if (test_bit(ABS_MT_POSITION_X, dev->absbit)) {
1762 mt_slots = 2;
1763 } else {
1764 mt_slots = 0;
1765 }
1766
1767 events = mt_slots + 1; /* count SYN_MT_REPORT and SYN_REPORT */
1768
1769 for (i = 0; i < ABS_CNT; i++) {
1770 if (test_bit(i, dev->absbit)) {
1771 if (input_is_mt_axis(i))
1772 events += mt_slots;
1773 else
1774 events++;
1775 }
1776 }
1777
1778 for (i = 0; i < REL_CNT; i++)
1779 if (test_bit(i, dev->relbit))
1780 events++;
1781
1782 return events;
1783}
1784
1790#define INPUT_CLEANSE_BITMASK(dev, type, bits) \ 1785#define INPUT_CLEANSE_BITMASK(dev, type, bits) \
1791 do { \ 1786 do { \
1792 if (!test_bit(EV_##type, dev->evbit)) \ 1787 if (!test_bit(EV_##type, dev->evbit)) \
@@ -1834,6 +1829,10 @@ int input_register_device(struct input_dev *dev)
1834 /* Make sure that bitmasks not mentioned in dev->evbit are clean. */ 1829 /* Make sure that bitmasks not mentioned in dev->evbit are clean. */
1835 input_cleanse_bitmasks(dev); 1830 input_cleanse_bitmasks(dev);
1836 1831
1832 if (!dev->hint_events_per_packet)
1833 dev->hint_events_per_packet =
1834 input_estimate_events_per_packet(dev);
1835
1837 /* 1836 /*
1838 * If delay and period are pre-set by the driver, then autorepeating 1837 * If delay and period are pre-set by the driver, then autorepeating
1839 * is handled by the driver itself and we don't do it in input.c. 1838 * is handled by the driver itself and we don't do it in input.c.
@@ -1846,11 +1845,11 @@ int input_register_device(struct input_dev *dev)
1846 dev->rep[REP_PERIOD] = 33; 1845 dev->rep[REP_PERIOD] = 33;
1847 } 1846 }
1848 1847
1849 if (!dev->getkeycode && !dev->getkeycode_new) 1848 if (!dev->getkeycode)
1850 dev->getkeycode_new = input_default_getkeycode; 1849 dev->getkeycode = input_default_getkeycode;
1851 1850
1852 if (!dev->setkeycode && !dev->setkeycode_new) 1851 if (!dev->setkeycode)
1853 dev->setkeycode_new = input_default_setkeycode; 1852 dev->setkeycode = input_default_setkeycode;
1854 1853
1855 dev_set_name(&dev->dev, "input%ld", 1854 dev_set_name(&dev->dev, "input%ld",
1856 (unsigned long) atomic_inc_return(&input_no) - 1); 1855 (unsigned long) atomic_inc_return(&input_no) - 1);
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 3182c9cd1b0e..5688b5c88f24 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -758,7 +758,7 @@ static void joydev_remove_chrdev(struct joydev *joydev)
758} 758}
759 759
760/* 760/*
761 * Mark device non-existant. This disables writes, ioctls and 761 * Mark device non-existent. This disables writes, ioctls and
762 * prevents new users from opening the device. Already posted 762 * prevents new users from opening the device. Already posted
763 * blocking reads will stay, however new ones will fail. 763 * blocking reads will stay, however new ones will fail.
764 */ 764 */
@@ -777,7 +777,7 @@ static void joydev_cleanup(struct joydev *joydev)
777 joydev_hangup(joydev); 777 joydev_hangup(joydev);
778 joydev_remove_chrdev(joydev); 778 joydev_remove_chrdev(joydev);
779 779
780 /* joydev is marked dead so noone else accesses joydev->open */ 780 /* joydev is marked dead so no one else accesses joydev->open */
781 if (joydev->open) 781 if (joydev->open)
782 input_close_device(handle); 782 input_close_device(handle);
783} 783}
diff --git a/drivers/input/joystick/a3d.c b/drivers/input/joystick/a3d.c
index d259b41354b8..1639ab2b94b7 100644
--- a/drivers/input/joystick/a3d.c
+++ b/drivers/input/joystick/a3d.c
@@ -3,7 +3,7 @@
3 */ 3 */
4 4
5/* 5/*
6 * FP-Gaming Assasin 3D joystick driver for Linux 6 * FP-Gaming Assassin 3D joystick driver for Linux
7 */ 7 */
8 8
9/* 9/*
@@ -34,7 +34,7 @@
34#include <linux/input.h> 34#include <linux/input.h>
35#include <linux/jiffies.h> 35#include <linux/jiffies.h>
36 36
37#define DRIVER_DESC "FP-Gaming Assasin 3D joystick driver" 37#define DRIVER_DESC "FP-Gaming Assassin 3D joystick driver"
38 38
39MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); 39MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
40MODULE_DESCRIPTION(DRIVER_DESC); 40MODULE_DESCRIPTION(DRIVER_DESC);
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index c7a92028f450..b16bed038f72 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -112,6 +112,16 @@ config KEYBOARD_ATKBD_RDI_KEYCODES
112 right-hand column will be interpreted as the key shown in the 112 right-hand column will be interpreted as the key shown in the
113 left-hand column. 113 left-hand column.
114 114
115config KEYBOARD_QT1070
116 tristate "Atmel AT42QT1070 Touch Sensor Chip"
117 depends on I2C
118 help
119 Say Y here if you want to use Atmel AT42QT1070 QTouch
120 Sensor chip as input device.
121
122 To compile this driver as a module, choose M here:
123 the module will be called qt1070
124
115config KEYBOARD_QT2160 125config KEYBOARD_QT2160
116 tristate "Atmel AT42QT2160 Touch Sensor Chip" 126 tristate "Atmel AT42QT2160 Touch Sensor Chip"
117 depends on I2C && EXPERIMENTAL 127 depends on I2C && EXPERIMENTAL
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 468c627a2844..878e6c20deb0 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_KEYBOARD_OMAP4) += omap4-keypad.o
34obj-$(CONFIG_KEYBOARD_OPENCORES) += opencores-kbd.o 34obj-$(CONFIG_KEYBOARD_OPENCORES) += opencores-kbd.o
35obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o 35obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o
36obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o 36obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o
37obj-$(CONFIG_KEYBOARD_QT1070) += qt1070.o
37obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o 38obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o
38obj-$(CONFIG_KEYBOARD_SAMSUNG) += samsung-keypad.o 39obj-$(CONFIG_KEYBOARD_SAMSUNG) += samsung-keypad.o
39obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o 40obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o
diff --git a/drivers/input/keyboard/davinci_keyscan.c b/drivers/input/keyboard/davinci_keyscan.c
index a91ee941b5c1..cd89d17162a3 100644
--- a/drivers/input/keyboard/davinci_keyscan.c
+++ b/drivers/input/keyboard/davinci_keyscan.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * Author: Miguel Aguilar <miguel.aguilar@ridgerun.com> 6 * Author: Miguel Aguilar <miguel.aguilar@ridgerun.com>
7 * 7 *
8 * Intial Code: Sandeep Paulraj <s-paulraj@ti.com> 8 * Initial Code: Sandeep Paulraj <s-paulraj@ti.com>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/input/keyboard/lm8323.c b/drivers/input/keyboard/lm8323.c
index f7c2a166576b..71f744a8e686 100644
--- a/drivers/input/keyboard/lm8323.c
+++ b/drivers/input/keyboard/lm8323.c
@@ -30,6 +30,7 @@
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/input.h> 31#include <linux/input.h>
32#include <linux/leds.h> 32#include <linux/leds.h>
33#include <linux/pm.h>
33#include <linux/i2c/lm8323.h> 34#include <linux/i2c/lm8323.h>
34#include <linux/slab.h> 35#include <linux/slab.h>
35 36
@@ -802,12 +803,13 @@ static int __devexit lm8323_remove(struct i2c_client *client)
802 * We don't need to explicitly suspend the chip, as it already switches off 803 * We don't need to explicitly suspend the chip, as it already switches off
803 * when there's no activity. 804 * when there's no activity.
804 */ 805 */
805static int lm8323_suspend(struct i2c_client *client, pm_message_t mesg) 806static int lm8323_suspend(struct device *dev)
806{ 807{
808 struct i2c_client *client = to_i2c_client(dev);
807 struct lm8323_chip *lm = i2c_get_clientdata(client); 809 struct lm8323_chip *lm = i2c_get_clientdata(client);
808 int i; 810 int i;
809 811
810 set_irq_wake(client->irq, 0); 812 irq_set_irq_wake(client->irq, 0);
811 disable_irq(client->irq); 813 disable_irq(client->irq);
812 814
813 mutex_lock(&lm->lock); 815 mutex_lock(&lm->lock);
@@ -821,8 +823,9 @@ static int lm8323_suspend(struct i2c_client *client, pm_message_t mesg)
821 return 0; 823 return 0;
822} 824}
823 825
824static int lm8323_resume(struct i2c_client *client) 826static int lm8323_resume(struct device *dev)
825{ 827{
828 struct i2c_client *client = to_i2c_client(dev);
826 struct lm8323_chip *lm = i2c_get_clientdata(client); 829 struct lm8323_chip *lm = i2c_get_clientdata(client);
827 int i; 830 int i;
828 831
@@ -835,15 +838,14 @@ static int lm8323_resume(struct i2c_client *client)
835 led_classdev_resume(&lm->pwm[i].cdev); 838 led_classdev_resume(&lm->pwm[i].cdev);
836 839
837 enable_irq(client->irq); 840 enable_irq(client->irq);
838 set_irq_wake(client->irq, 1); 841 irq_set_irq_wake(client->irq, 1);
839 842
840 return 0; 843 return 0;
841} 844}
842#else
843#define lm8323_suspend NULL
844#define lm8323_resume NULL
845#endif 845#endif
846 846
847static SIMPLE_DEV_PM_OPS(lm8323_pm_ops, lm8323_suspend, lm8323_resume);
848
847static const struct i2c_device_id lm8323_id[] = { 849static const struct i2c_device_id lm8323_id[] = {
848 { "lm8323", 0 }, 850 { "lm8323", 0 },
849 { } 851 { }
@@ -852,11 +854,10 @@ static const struct i2c_device_id lm8323_id[] = {
852static struct i2c_driver lm8323_i2c_driver = { 854static struct i2c_driver lm8323_i2c_driver = {
853 .driver = { 855 .driver = {
854 .name = "lm8323", 856 .name = "lm8323",
857 .pm = &lm8323_pm_ops,
855 }, 858 },
856 .probe = lm8323_probe, 859 .probe = lm8323_probe,
857 .remove = __devexit_p(lm8323_remove), 860 .remove = __devexit_p(lm8323_remove),
858 .suspend = lm8323_suspend,
859 .resume = lm8323_resume,
860 .id_table = lm8323_id, 861 .id_table = lm8323_id,
861}; 862};
862MODULE_DEVICE_TABLE(i2c, lm8323_id); 863MODULE_DEVICE_TABLE(i2c, lm8323_id);
diff --git a/drivers/input/keyboard/max7359_keypad.c b/drivers/input/keyboard/max7359_keypad.c
index 9091ff5ea808..5afe35ad24d3 100644
--- a/drivers/input/keyboard/max7359_keypad.c
+++ b/drivers/input/keyboard/max7359_keypad.c
@@ -17,6 +17,7 @@
17#include <linux/i2c.h> 17#include <linux/i2c.h>
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/pm.h>
20#include <linux/input.h> 21#include <linux/input.h>
21#include <linux/input/matrix_keypad.h> 22#include <linux/input/matrix_keypad.h>
22 23
@@ -271,8 +272,10 @@ static int __devexit max7359_remove(struct i2c_client *client)
271} 272}
272 273
273#ifdef CONFIG_PM 274#ifdef CONFIG_PM
274static int max7359_suspend(struct i2c_client *client, pm_message_t mesg) 275static int max7359_suspend(struct device *dev)
275{ 276{
277 struct i2c_client *client = to_i2c_client(dev);
278
276 max7359_fall_deepsleep(client); 279 max7359_fall_deepsleep(client);
277 280
278 if (device_may_wakeup(&client->dev)) 281 if (device_may_wakeup(&client->dev))
@@ -281,8 +284,10 @@ static int max7359_suspend(struct i2c_client *client, pm_message_t mesg)
281 return 0; 284 return 0;
282} 285}
283 286
284static int max7359_resume(struct i2c_client *client) 287static int max7359_resume(struct device *dev)
285{ 288{
289 struct i2c_client *client = to_i2c_client(dev);
290
286 if (device_may_wakeup(&client->dev)) 291 if (device_may_wakeup(&client->dev))
287 disable_irq_wake(client->irq); 292 disable_irq_wake(client->irq);
288 293
@@ -291,11 +296,10 @@ static int max7359_resume(struct i2c_client *client)
291 296
292 return 0; 297 return 0;
293} 298}
294#else
295#define max7359_suspend NULL
296#define max7359_resume NULL
297#endif 299#endif
298 300
301static SIMPLE_DEV_PM_OPS(max7359_pm, max7359_suspend, max7359_resume);
302
299static const struct i2c_device_id max7359_ids[] = { 303static const struct i2c_device_id max7359_ids[] = {
300 { "max7359", 0 }, 304 { "max7359", 0 },
301 { } 305 { }
@@ -305,11 +309,10 @@ MODULE_DEVICE_TABLE(i2c, max7359_ids);
305static struct i2c_driver max7359_i2c_driver = { 309static struct i2c_driver max7359_i2c_driver = {
306 .driver = { 310 .driver = {
307 .name = "max7359", 311 .name = "max7359",
312 .pm = &max7359_pm,
308 }, 313 },
309 .probe = max7359_probe, 314 .probe = max7359_probe,
310 .remove = __devexit_p(max7359_remove), 315 .remove = __devexit_p(max7359_remove),
311 .suspend = max7359_suspend,
312 .resume = max7359_resume,
313 .id_table = max7359_ids, 316 .id_table = max7359_ids,
314}; 317};
315 318
diff --git a/drivers/input/keyboard/mcs_touchkey.c b/drivers/input/keyboard/mcs_touchkey.c
index 63b849d7e90b..af1aab324a4c 100644
--- a/drivers/input/keyboard/mcs_touchkey.c
+++ b/drivers/input/keyboard/mcs_touchkey.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * mcs_touchkey.c - Touchkey driver for MELFAS MCS5000/5080 controller 2 * Touchkey driver for MELFAS MCS5000/5080 controller
3 * 3 *
4 * Copyright (C) 2010 Samsung Electronics Co.Ltd 4 * Copyright (C) 2010 Samsung Electronics Co.Ltd
5 * Author: HeungJun Kim <riverful.kim@samsung.com> 5 * Author: HeungJun Kim <riverful.kim@samsung.com>
@@ -19,6 +19,7 @@
19#include <linux/input.h> 19#include <linux/input.h>
20#include <linux/irq.h> 20#include <linux/irq.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/pm.h>
22 23
23/* MCS5000 Touchkey */ 24/* MCS5000 Touchkey */
24#define MCS5000_TOUCHKEY_STATUS 0x04 25#define MCS5000_TOUCHKEY_STATUS 0x04
@@ -45,6 +46,8 @@ struct mcs_touchkey_chip {
45}; 46};
46 47
47struct mcs_touchkey_data { 48struct mcs_touchkey_data {
49 void (*poweron)(bool);
50
48 struct i2c_client *client; 51 struct i2c_client *client;
49 struct input_dev *input_dev; 52 struct input_dev *input_dev;
50 struct mcs_touchkey_chip chip; 53 struct mcs_touchkey_chip chip;
@@ -169,6 +172,11 @@ static int __devinit mcs_touchkey_probe(struct i2c_client *client,
169 if (pdata->cfg_pin) 172 if (pdata->cfg_pin)
170 pdata->cfg_pin(); 173 pdata->cfg_pin();
171 174
175 if (pdata->poweron) {
176 data->poweron = pdata->poweron;
177 data->poweron(true);
178 }
179
172 error = request_threaded_irq(client->irq, NULL, mcs_touchkey_interrupt, 180 error = request_threaded_irq(client->irq, NULL, mcs_touchkey_interrupt,
173 IRQF_TRIGGER_FALLING, client->dev.driver->name, data); 181 IRQF_TRIGGER_FALLING, client->dev.driver->name, data);
174 if (error) { 182 if (error) {
@@ -196,12 +204,57 @@ static int __devexit mcs_touchkey_remove(struct i2c_client *client)
196 struct mcs_touchkey_data *data = i2c_get_clientdata(client); 204 struct mcs_touchkey_data *data = i2c_get_clientdata(client);
197 205
198 free_irq(client->irq, data); 206 free_irq(client->irq, data);
207 if (data->poweron)
208 data->poweron(false);
199 input_unregister_device(data->input_dev); 209 input_unregister_device(data->input_dev);
200 kfree(data); 210 kfree(data);
201 211
202 return 0; 212 return 0;
203} 213}
204 214
215static void mcs_touchkey_shutdown(struct i2c_client *client)
216{
217 struct mcs_touchkey_data *data = i2c_get_clientdata(client);
218
219 if (data->poweron)
220 data->poweron(false);
221}
222
223#ifdef CONFIG_PM_SLEEP
224static int mcs_touchkey_suspend(struct device *dev)
225{
226 struct mcs_touchkey_data *data = dev_get_drvdata(dev);
227 struct i2c_client *client = data->client;
228
229 /* Disable the work */
230 disable_irq(client->irq);
231
232 /* Finally turn off the power */
233 if (data->poweron)
234 data->poweron(false);
235
236 return 0;
237}
238
239static int mcs_touchkey_resume(struct device *dev)
240{
241 struct mcs_touchkey_data *data = dev_get_drvdata(dev);
242 struct i2c_client *client = data->client;
243
244 /* Enable the device first */
245 if (data->poweron)
246 data->poweron(true);
247
248 /* Enable irq again */
249 enable_irq(client->irq);
250
251 return 0;
252}
253#endif
254
255static SIMPLE_DEV_PM_OPS(mcs_touchkey_pm_ops,
256 mcs_touchkey_suspend, mcs_touchkey_resume);
257
205static const struct i2c_device_id mcs_touchkey_id[] = { 258static const struct i2c_device_id mcs_touchkey_id[] = {
206 { "mcs5000_touchkey", MCS5000_TOUCHKEY }, 259 { "mcs5000_touchkey", MCS5000_TOUCHKEY },
207 { "mcs5080_touchkey", MCS5080_TOUCHKEY }, 260 { "mcs5080_touchkey", MCS5080_TOUCHKEY },
@@ -213,9 +266,11 @@ static struct i2c_driver mcs_touchkey_driver = {
213 .driver = { 266 .driver = {
214 .name = "mcs_touchkey", 267 .name = "mcs_touchkey",
215 .owner = THIS_MODULE, 268 .owner = THIS_MODULE,
269 .pm = &mcs_touchkey_pm_ops,
216 }, 270 },
217 .probe = mcs_touchkey_probe, 271 .probe = mcs_touchkey_probe,
218 .remove = __devexit_p(mcs_touchkey_remove), 272 .remove = __devexit_p(mcs_touchkey_remove),
273 .shutdown = mcs_touchkey_shutdown,
219 .id_table = mcs_touchkey_id, 274 .id_table = mcs_touchkey_id,
220}; 275};
221 276
diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index 45bd0977d006..c51a3c4a7feb 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -29,6 +29,7 @@
29#include <linux/io.h> 29#include <linux/io.h>
30#include <linux/input.h> 30#include <linux/input.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/pm_runtime.h>
32 33
33#include <plat/omap4-keypad.h> 34#include <plat/omap4-keypad.h>
34 35
@@ -80,20 +81,6 @@ struct omap4_keypad {
80 unsigned short keymap[]; 81 unsigned short keymap[];
81}; 82};
82 83
83static void __devinit omap4_keypad_config(struct omap4_keypad *keypad_data)
84{
85 __raw_writel(OMAP4_VAL_FUNCTIONALCFG,
86 keypad_data->base + OMAP4_KBD_CTRL);
87 __raw_writel(OMAP4_VAL_DEBOUNCINGTIME,
88 keypad_data->base + OMAP4_KBD_DEBOUNCINGTIME);
89 __raw_writel(OMAP4_VAL_IRQDISABLE,
90 keypad_data->base + OMAP4_KBD_IRQSTATUS);
91 __raw_writel(OMAP4_DEF_IRQENABLE_EVENTEN | OMAP4_DEF_IRQENABLE_LONGKEY,
92 keypad_data->base + OMAP4_KBD_IRQENABLE);
93 __raw_writel(OMAP4_DEF_WUP_EVENT_ENA | OMAP4_DEF_WUP_LONG_KEY_ENA,
94 keypad_data->base + OMAP4_KBD_WAKEUPENABLE);
95}
96
97/* Interrupt handler */ 84/* Interrupt handler */
98static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) 85static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id)
99{ 86{
@@ -144,6 +131,49 @@ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id)
144 return IRQ_HANDLED; 131 return IRQ_HANDLED;
145} 132}
146 133
134static int omap4_keypad_open(struct input_dev *input)
135{
136 struct omap4_keypad *keypad_data = input_get_drvdata(input);
137
138 pm_runtime_get_sync(input->dev.parent);
139
140 disable_irq(keypad_data->irq);
141
142 __raw_writel(OMAP4_VAL_FUNCTIONALCFG,
143 keypad_data->base + OMAP4_KBD_CTRL);
144 __raw_writel(OMAP4_VAL_DEBOUNCINGTIME,
145 keypad_data->base + OMAP4_KBD_DEBOUNCINGTIME);
146 __raw_writel(OMAP4_VAL_IRQDISABLE,
147 keypad_data->base + OMAP4_KBD_IRQSTATUS);
148 __raw_writel(OMAP4_DEF_IRQENABLE_EVENTEN | OMAP4_DEF_IRQENABLE_LONGKEY,
149 keypad_data->base + OMAP4_KBD_IRQENABLE);
150 __raw_writel(OMAP4_DEF_WUP_EVENT_ENA | OMAP4_DEF_WUP_LONG_KEY_ENA,
151 keypad_data->base + OMAP4_KBD_WAKEUPENABLE);
152
153 enable_irq(keypad_data->irq);
154
155 return 0;
156}
157
158static void omap4_keypad_close(struct input_dev *input)
159{
160 struct omap4_keypad *keypad_data = input_get_drvdata(input);
161
162 disable_irq(keypad_data->irq);
163
164 /* Disable interrupts */
165 __raw_writel(OMAP4_VAL_IRQDISABLE,
166 keypad_data->base + OMAP4_KBD_IRQENABLE);
167
168 /* clear pending interrupts */
169 __raw_writel(__raw_readl(keypad_data->base + OMAP4_KBD_IRQSTATUS),
170 keypad_data->base + OMAP4_KBD_IRQSTATUS);
171
172 enable_irq(keypad_data->irq);
173
174 pm_runtime_put_sync(input->dev.parent);
175}
176
147static int __devinit omap4_keypad_probe(struct platform_device *pdev) 177static int __devinit omap4_keypad_probe(struct platform_device *pdev)
148{ 178{
149 const struct omap4_keypad_platform_data *pdata; 179 const struct omap4_keypad_platform_data *pdata;
@@ -225,6 +255,9 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev)
225 input_dev->id.product = 0x0001; 255 input_dev->id.product = 0x0001;
226 input_dev->id.version = 0x0001; 256 input_dev->id.version = 0x0001;
227 257
258 input_dev->open = omap4_keypad_open;
259 input_dev->close = omap4_keypad_close;
260
228 input_dev->keycode = keypad_data->keymap; 261 input_dev->keycode = keypad_data->keymap;
229 input_dev->keycodesize = sizeof(keypad_data->keymap[0]); 262 input_dev->keycodesize = sizeof(keypad_data->keymap[0]);
230 input_dev->keycodemax = max_keys; 263 input_dev->keycodemax = max_keys;
@@ -239,8 +272,6 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev)
239 matrix_keypad_build_keymap(pdata->keymap_data, row_shift, 272 matrix_keypad_build_keymap(pdata->keymap_data, row_shift,
240 input_dev->keycode, input_dev->keybit); 273 input_dev->keycode, input_dev->keybit);
241 274
242 omap4_keypad_config(keypad_data);
243
244 error = request_irq(keypad_data->irq, omap4_keypad_interrupt, 275 error = request_irq(keypad_data->irq, omap4_keypad_interrupt,
245 IRQF_TRIGGER_RISING, 276 IRQF_TRIGGER_RISING,
246 "omap4-keypad", keypad_data); 277 "omap4-keypad", keypad_data);
@@ -249,17 +280,19 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev)
249 goto err_free_input; 280 goto err_free_input;
250 } 281 }
251 282
283 pm_runtime_enable(&pdev->dev);
284
252 error = input_register_device(keypad_data->input); 285 error = input_register_device(keypad_data->input);
253 if (error < 0) { 286 if (error < 0) {
254 dev_err(&pdev->dev, "failed to register input device\n"); 287 dev_err(&pdev->dev, "failed to register input device\n");
255 goto err_free_irq; 288 goto err_pm_disable;
256 } 289 }
257 290
258
259 platform_set_drvdata(pdev, keypad_data); 291 platform_set_drvdata(pdev, keypad_data);
260 return 0; 292 return 0;
261 293
262err_free_irq: 294err_pm_disable:
295 pm_runtime_disable(&pdev->dev);
263 free_irq(keypad_data->irq, keypad_data); 296 free_irq(keypad_data->irq, keypad_data);
264err_free_input: 297err_free_input:
265 input_free_device(input_dev); 298 input_free_device(input_dev);
@@ -278,6 +311,9 @@ static int __devexit omap4_keypad_remove(struct platform_device *pdev)
278 struct resource *res; 311 struct resource *res;
279 312
280 free_irq(keypad_data->irq, keypad_data); 313 free_irq(keypad_data->irq, keypad_data);
314
315 pm_runtime_disable(&pdev->dev);
316
281 input_unregister_device(keypad_data->input); 317 input_unregister_device(keypad_data->input);
282 318
283 iounmap(keypad_data->base); 319 iounmap(keypad_data->base);
diff --git a/drivers/input/keyboard/qt1070.c b/drivers/input/keyboard/qt1070.c
new file mode 100644
index 000000000000..fba8404c7297
--- /dev/null
+++ b/drivers/input/keyboard/qt1070.c
@@ -0,0 +1,276 @@
1/*
2 * Atmel AT42QT1070 QTouch Sensor Controller
3 *
4 * Copyright (C) 2011 Atmel
5 *
6 * Authors: Bo Shen <voice.shen@atmel.com>
7 *
8 * Base on AT42QT2160 driver by:
9 * Raphael Derosso Pereira <raphaelpereira@gmail.com>
10 * Copyright (C) 2009
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */
26#include <linux/kernel.h>
27#include <linux/module.h>
28#include <linux/init.h>
29#include <linux/i2c.h>
30#include <linux/input.h>
31#include <linux/slab.h>
32#include <linux/irq.h>
33#include <linux/interrupt.h>
34#include <linux/jiffies.h>
35#include <linux/delay.h>
36
37/* Address for each register */
38#define CHIP_ID 0x00
39#define QT1070_CHIP_ID 0x2E
40
41#define FW_VERSION 0x01
42#define QT1070_FW_VERSION 0x15
43
44#define DET_STATUS 0x02
45
46#define KEY_STATUS 0x03
47
48/* Calibrate */
49#define CALIBRATE_CMD 0x38
50#define QT1070_CAL_TIME 200
51
52/* Reset */
53#define RESET 0x39
54#define QT1070_RESET_TIME 255
55
56/* AT42QT1070 support up to 7 keys */
57static const unsigned short qt1070_key2code[] = {
58 KEY_0, KEY_1, KEY_2, KEY_3,
59 KEY_4, KEY_5, KEY_6,
60};
61
62struct qt1070_data {
63 struct i2c_client *client;
64 struct input_dev *input;
65 unsigned int irq;
66 unsigned short keycodes[ARRAY_SIZE(qt1070_key2code)];
67 u8 last_keys;
68};
69
70static int qt1070_read(struct i2c_client *client, u8 reg)
71{
72 int ret;
73
74 ret = i2c_smbus_read_byte_data(client, reg);
75 if (ret < 0)
76 dev_err(&client->dev,
77 "can not read register, returned %d\n", ret);
78
79 return ret;
80}
81
82static int qt1070_write(struct i2c_client *client, u8 reg, u8 data)
83{
84 int ret;
85
86 ret = i2c_smbus_write_byte_data(client, reg, data);
87 if (ret < 0)
88 dev_err(&client->dev,
89 "can not write register, returned %d\n", ret);
90
91 return ret;
92}
93
94static bool __devinit qt1070_identify(struct i2c_client *client)
95{
96 int id, ver;
97
98 /* Read Chip ID */
99 id = qt1070_read(client, CHIP_ID);
100 if (id != QT1070_CHIP_ID) {
101 dev_err(&client->dev, "ID %d not supported\n", id);
102 return false;
103 }
104
105 /* Read firmware version */
106 ver = qt1070_read(client, FW_VERSION);
107 if (ver < 0) {
108 dev_err(&client->dev, "could not read the firmware version\n");
109 return false;
110 }
111
112 dev_info(&client->dev, "AT42QT1070 firmware version %x\n", ver);
113
114 return true;
115}
116
117static irqreturn_t qt1070_interrupt(int irq, void *dev_id)
118{
119 struct qt1070_data *data = dev_id;
120 struct i2c_client *client = data->client;
121 struct input_dev *input = data->input;
122 int i;
123 u8 new_keys, keyval, mask = 0x01;
124
125 /* Read the detected status register, thus clearing interrupt */
126 qt1070_read(client, DET_STATUS);
127
128 /* Read which key changed */
129 new_keys = qt1070_read(client, KEY_STATUS);
130
131 for (i = 0; i < ARRAY_SIZE(qt1070_key2code); i++) {
132 keyval = new_keys & mask;
133 if ((data->last_keys & mask) != keyval)
134 input_report_key(input, data->keycodes[i], keyval);
135 mask <<= 1;
136 }
137 input_sync(input);
138
139 data->last_keys = new_keys;
140 return IRQ_HANDLED;
141}
142
143static int __devinit qt1070_probe(struct i2c_client *client,
144 const struct i2c_device_id *id)
145{
146 struct qt1070_data *data;
147 struct input_dev *input;
148 int i;
149 int err;
150
151 err = i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE);
152 if (!err) {
153 dev_err(&client->dev, "%s adapter not supported\n",
154 dev_driver_string(&client->adapter->dev));
155 return -ENODEV;
156 }
157
158 if (!client->irq) {
159 dev_err(&client->dev, "please assign the irq to this device\n");
160 return -EINVAL;
161 }
162
163 /* Identify the qt1070 chip */
164 if (!qt1070_identify(client))
165 return -ENODEV;
166
167 data = kzalloc(sizeof(struct qt1070_data), GFP_KERNEL);
168 input = input_allocate_device();
169 if (!data || !input) {
170 dev_err(&client->dev, "insufficient memory\n");
171 err = -ENOMEM;
172 goto err_free_mem;
173 }
174
175 data->client = client;
176 data->input = input;
177 data->irq = client->irq;
178
179 input->name = "AT42QT1070 QTouch Sensor";
180 input->dev.parent = &client->dev;
181 input->id.bustype = BUS_I2C;
182
183 /* Add the keycode */
184 input->keycode = data->keycodes;
185 input->keycodesize = sizeof(data->keycodes[0]);
186 input->keycodemax = ARRAY_SIZE(qt1070_key2code);
187
188 __set_bit(EV_KEY, input->evbit);
189
190 for (i = 0; i < ARRAY_SIZE(qt1070_key2code); i++) {
191 data->keycodes[i] = qt1070_key2code[i];
192 __set_bit(qt1070_key2code[i], input->keybit);
193 }
194
195 /* Calibrate device */
196 qt1070_write(client, CALIBRATE_CMD, 1);
197 msleep(QT1070_CAL_TIME);
198
199 /* Soft reset */
200 qt1070_write(client, RESET, 1);
201 msleep(QT1070_RESET_TIME);
202
203 err = request_threaded_irq(client->irq, NULL, qt1070_interrupt,
204 IRQF_TRIGGER_NONE, client->dev.driver->name, data);
205 if (err) {
206 dev_err(&client->dev, "fail to request irq\n");
207 goto err_free_mem;
208 }
209
210 /* Register the input device */
211 err = input_register_device(data->input);
212 if (err) {
213 dev_err(&client->dev, "Failed to register input device\n");
214 goto err_free_irq;
215 }
216
217 i2c_set_clientdata(client, data);
218
219 /* Read to clear the chang line */
220 qt1070_read(client, DET_STATUS);
221
222 return 0;
223
224err_free_irq:
225 free_irq(client->irq, data);
226err_free_mem:
227 input_free_device(input);
228 kfree(data);
229 return err;
230}
231
232static int __devexit qt1070_remove(struct i2c_client *client)
233{
234 struct qt1070_data *data = i2c_get_clientdata(client);
235
236 /* Release IRQ */
237 free_irq(client->irq, data);
238
239 input_unregister_device(data->input);
240 kfree(data);
241
242 i2c_set_clientdata(client, NULL);
243
244 return 0;
245}
246
247static const struct i2c_device_id qt1070_id[] = {
248 { "qt1070", 0 },
249 { },
250};
251
252static struct i2c_driver qt1070_driver = {
253 .driver = {
254 .name = "qt1070",
255 .owner = THIS_MODULE,
256 },
257 .id_table = qt1070_id,
258 .probe = qt1070_probe,
259 .remove = __devexit_p(qt1070_remove),
260};
261
262static int __init qt1070_init(void)
263{
264 return i2c_add_driver(&qt1070_driver);
265}
266module_init(qt1070_init);
267
268static void __exit qt1070_exit(void)
269{
270 i2c_del_driver(&qt1070_driver);
271}
272module_exit(qt1070_exit);
273
274MODULE_AUTHOR("Bo Shen <voice.shen@atmel.com>");
275MODULE_DESCRIPTION("Driver for AT42QT1070 QTouch sensor");
276MODULE_LICENSE("GPL");
diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c
index bee03d64c453..d712dffd2157 100644
--- a/drivers/input/keyboard/spear-keyboard.c
+++ b/drivers/input/keyboard/spear-keyboard.c
@@ -69,7 +69,7 @@ static irqreturn_t spear_kbd_interrupt(int irq, void *dev_id)
69 u8 sts, val; 69 u8 sts, val;
70 70
71 sts = readb(kbd->io_base + STATUS_REG); 71 sts = readb(kbd->io_base + STATUS_REG);
72 if (sts & DATA_AVAIL) 72 if (!(sts & DATA_AVAIL))
73 return IRQ_NONE; 73 return IRQ_NONE;
74 74
75 if (kbd->last_key != KEY_RESERVED) { 75 if (kbd->last_key != KEY_RESERVED) {
diff --git a/drivers/input/keyboard/tc3589x-keypad.c b/drivers/input/keyboard/tc3589x-keypad.c
index dbbe761778d2..99122f59e988 100644
--- a/drivers/input/keyboard/tc3589x-keypad.c
+++ b/drivers/input/keyboard/tc3589x-keypad.c
@@ -402,7 +402,7 @@ static int __devexit tc3589x_keypad_remove(struct platform_device *pdev)
402 return 0; 402 return 0;
403} 403}
404 404
405#ifdef CONFIG_PM 405#ifdef CONFIG_PM_SLEEP
406static int tc3589x_keypad_suspend(struct device *dev) 406static int tc3589x_keypad_suspend(struct device *dev)
407{ 407{
408 struct platform_device *pdev = to_platform_device(dev); 408 struct platform_device *pdev = to_platform_device(dev);
@@ -439,19 +439,19 @@ static int tc3589x_keypad_resume(struct device *dev)
439 439
440 return 0; 440 return 0;
441} 441}
442
443static const SIMPLE_DEV_PM_OPS(tc3589x_keypad_dev_pm_ops,
444 tc3589x_keypad_suspend, tc3589x_keypad_resume);
445#endif 442#endif
446 443
444static SIMPLE_DEV_PM_OPS(tc3589x_keypad_dev_pm_ops,
445 tc3589x_keypad_suspend, tc3589x_keypad_resume);
446
447static struct platform_driver tc3589x_keypad_driver = { 447static struct platform_driver tc3589x_keypad_driver = {
448 .driver.name = "tc3589x-keypad", 448 .driver = {
449 .driver.owner = THIS_MODULE, 449 .name = "tc3589x-keypad",
450#ifdef CONFIG_PM 450 .owner = THIS_MODULE,
451 .driver.pm = &tc3589x_keypad_dev_pm_ops, 451 .pm = &tc3589x_keypad_dev_pm_ops,
452#endif 452 },
453 .probe = tc3589x_keypad_probe, 453 .probe = tc3589x_keypad_probe,
454 .remove = __devexit_p(tc3589x_keypad_remove), 454 .remove = __devexit_p(tc3589x_keypad_remove),
455}; 455};
456 456
457static int __init tc3589x_keypad_init(void) 457static int __init tc3589x_keypad_init(void)
diff --git a/drivers/input/keyboard/tca6416-keypad.c b/drivers/input/keyboard/tca6416-keypad.c
index 800fbccf1f0f..3afea3f89718 100644
--- a/drivers/input/keyboard/tca6416-keypad.c
+++ b/drivers/input/keyboard/tca6416-keypad.c
@@ -297,6 +297,7 @@ static int __devinit tca6416_keypad_probe(struct i2c_client *client,
297 } 297 }
298 298
299 i2c_set_clientdata(client, chip); 299 i2c_set_clientdata(client, chip);
300 device_init_wakeup(&client->dev, 1);
300 301
301 return 0; 302 return 0;
302 303
@@ -326,10 +327,37 @@ static int __devexit tca6416_keypad_remove(struct i2c_client *client)
326 return 0; 327 return 0;
327} 328}
328 329
330#ifdef CONFIG_PM_SLEEP
331static int tca6416_keypad_suspend(struct device *dev)
332{
333 struct i2c_client *client = to_i2c_client(dev);
334 struct tca6416_keypad_chip *chip = i2c_get_clientdata(client);
335
336 if (device_may_wakeup(dev))
337 enable_irq_wake(chip->irqnum);
338
339 return 0;
340}
341
342static int tca6416_keypad_resume(struct device *dev)
343{
344 struct i2c_client *client = to_i2c_client(dev);
345 struct tca6416_keypad_chip *chip = i2c_get_clientdata(client);
346
347 if (device_may_wakeup(dev))
348 disable_irq_wake(chip->irqnum);
349
350 return 0;
351}
352#endif
353
354static SIMPLE_DEV_PM_OPS(tca6416_keypad_dev_pm_ops,
355 tca6416_keypad_suspend, tca6416_keypad_resume);
329 356
330static struct i2c_driver tca6416_keypad_driver = { 357static struct i2c_driver tca6416_keypad_driver = {
331 .driver = { 358 .driver = {
332 .name = "tca6416-keypad", 359 .name = "tca6416-keypad",
360 .pm = &tca6416_keypad_dev_pm_ops,
333 }, 361 },
334 .probe = tca6416_keypad_probe, 362 .probe = tca6416_keypad_probe,
335 .remove = __devexit_p(tca6416_keypad_remove), 363 .remove = __devexit_p(tca6416_keypad_remove),
diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c
index 09bef79d9da1..a26922cf0e84 100644
--- a/drivers/input/keyboard/twl4030_keypad.c
+++ b/drivers/input/keyboard/twl4030_keypad.c
@@ -332,18 +332,20 @@ static int __devinit twl4030_kp_program(struct twl4030_keypad *kp)
332static int __devinit twl4030_kp_probe(struct platform_device *pdev) 332static int __devinit twl4030_kp_probe(struct platform_device *pdev)
333{ 333{
334 struct twl4030_keypad_data *pdata = pdev->dev.platform_data; 334 struct twl4030_keypad_data *pdata = pdev->dev.platform_data;
335 const struct matrix_keymap_data *keymap_data = pdata->keymap_data; 335 const struct matrix_keymap_data *keymap_data;
336 struct twl4030_keypad *kp; 336 struct twl4030_keypad *kp;
337 struct input_dev *input; 337 struct input_dev *input;
338 u8 reg; 338 u8 reg;
339 int error; 339 int error;
340 340
341 if (!pdata || !pdata->rows || !pdata->cols || 341 if (!pdata || !pdata->rows || !pdata->cols || !pdata->keymap_data ||
342 pdata->rows > TWL4030_MAX_ROWS || pdata->cols > TWL4030_MAX_COLS) { 342 pdata->rows > TWL4030_MAX_ROWS || pdata->cols > TWL4030_MAX_COLS) {
343 dev_err(&pdev->dev, "Invalid platform_data\n"); 343 dev_err(&pdev->dev, "Invalid platform_data\n");
344 return -EINVAL; 344 return -EINVAL;
345 } 345 }
346 346
347 keymap_data = pdata->keymap_data;
348
347 kp = kzalloc(sizeof(*kp), GFP_KERNEL); 349 kp = kzalloc(sizeof(*kp), GFP_KERNEL);
348 input = input_allocate_device(); 350 input = input_allocate_device();
349 if (!kp || !input) { 351 if (!kp || !input) {
diff --git a/drivers/input/misc/88pm860x_onkey.c b/drivers/input/misc/88pm860x_onkey.c
index 4cc82826ea6b..3dca3c14510e 100644
--- a/drivers/input/misc/88pm860x_onkey.c
+++ b/drivers/input/misc/88pm860x_onkey.c
@@ -74,7 +74,7 @@ static int __devinit pm860x_onkey_probe(struct platform_device *pdev)
74 info->chip = chip; 74 info->chip = chip;
75 info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion; 75 info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion;
76 info->dev = &pdev->dev; 76 info->dev = &pdev->dev;
77 info->irq = irq + chip->irq_base; 77 info->irq = irq;
78 78
79 info->idev = input_allocate_device(); 79 info->idev = input_allocate_device();
80 if (!info->idev) { 80 if (!info->idev) {
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index b0c6772851a9..f9cf0881b0e3 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -454,4 +454,17 @@ config INPUT_CMA3000_I2C
454 To compile this driver as a module, choose M here: the 454 To compile this driver as a module, choose M here: the
455 module will be called cma3000_d0x_i2c. 455 module will be called cma3000_d0x_i2c.
456 456
457config INPUT_XEN_KBDDEV_FRONTEND
458 tristate "Xen virtual keyboard and mouse support"
459 depends on XEN_FBDEV_FRONTEND
460 default y
461 select XEN_XENBUS_FRONTEND
462 help
463 This driver implements the front-end of the Xen virtual
464 keyboard and mouse device driver. It communicates with a back-end
465 in another domain.
466
467 To compile this driver as a module, choose M here: the
468 module will be called xen-kbdfront.
469
457endif 470endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 9b4797112c9a..e3f7984e6274 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -42,5 +42,6 @@ obj-$(CONFIG_INPUT_TWL4030_VIBRA) += twl4030-vibra.o
42obj-$(CONFIG_INPUT_UINPUT) += uinput.o 42obj-$(CONFIG_INPUT_UINPUT) += uinput.o
43obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o 43obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o
44obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o 44obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o
45obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND) += xen-kbdfront.o
45obj-$(CONFIG_INPUT_YEALINK) += yealink.o 46obj-$(CONFIG_INPUT_YEALINK) += yealink.o
46 47
diff --git a/drivers/input/misc/ad714x-i2c.c b/drivers/input/misc/ad714x-i2c.c
index 2bef8fa56c94..e21deb1baa8a 100644
--- a/drivers/input/misc/ad714x-i2c.c
+++ b/drivers/input/misc/ad714x-i2c.c
@@ -10,23 +10,23 @@
10#include <linux/i2c.h> 10#include <linux/i2c.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/pm.h>
13#include "ad714x.h" 14#include "ad714x.h"
14 15
15#ifdef CONFIG_PM 16#ifdef CONFIG_PM
16static int ad714x_i2c_suspend(struct i2c_client *client, pm_message_t message) 17static int ad714x_i2c_suspend(struct device *dev)
17{ 18{
18 return ad714x_disable(i2c_get_clientdata(client)); 19 return ad714x_disable(i2c_get_clientdata(to_i2c_client(dev)));
19} 20}
20 21
21static int ad714x_i2c_resume(struct i2c_client *client) 22static int ad714x_i2c_resume(struct device *dev)
22{ 23{
23 return ad714x_enable(i2c_get_clientdata(client)); 24 return ad714x_enable(i2c_get_clientdata(to_i2c_client(dev)));
24} 25}
25#else
26# define ad714x_i2c_suspend NULL
27# define ad714x_i2c_resume NULL
28#endif 26#endif
29 27
28static SIMPLE_DEV_PM_OPS(ad714x_i2c_pm, ad714x_i2c_suspend, ad714x_i2c_resume);
29
30static int ad714x_i2c_write(struct device *dev, unsigned short reg, 30static int ad714x_i2c_write(struct device *dev, unsigned short reg,
31 unsigned short data) 31 unsigned short data)
32{ 32{
@@ -114,11 +114,10 @@ MODULE_DEVICE_TABLE(i2c, ad714x_id);
114static struct i2c_driver ad714x_i2c_driver = { 114static struct i2c_driver ad714x_i2c_driver = {
115 .driver = { 115 .driver = {
116 .name = "ad714x_captouch", 116 .name = "ad714x_captouch",
117 .pm = &ad714x_i2c_pm,
117 }, 118 },
118 .probe = ad714x_i2c_probe, 119 .probe = ad714x_i2c_probe,
119 .remove = __devexit_p(ad714x_i2c_remove), 120 .remove = __devexit_p(ad714x_i2c_remove),
120 .suspend = ad714x_i2c_suspend,
121 .resume = ad714x_i2c_resume,
122 .id_table = ad714x_id, 121 .id_table = ad714x_id,
123}; 122};
124 123
diff --git a/drivers/input/misc/ad714x-spi.c b/drivers/input/misc/ad714x-spi.c
index 7f8dedfd1bfe..4120dd549305 100644
--- a/drivers/input/misc/ad714x-spi.c
+++ b/drivers/input/misc/ad714x-spi.c
@@ -9,6 +9,7 @@
9#include <linux/input.h> /* BUS_I2C */ 9#include <linux/input.h> /* BUS_I2C */
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/spi/spi.h> 11#include <linux/spi/spi.h>
12#include <linux/pm.h>
12#include <linux/types.h> 13#include <linux/types.h>
13#include "ad714x.h" 14#include "ad714x.h"
14 15
@@ -16,20 +17,19 @@
16#define AD714x_SPI_READ BIT(10) 17#define AD714x_SPI_READ BIT(10)
17 18
18#ifdef CONFIG_PM 19#ifdef CONFIG_PM
19static int ad714x_spi_suspend(struct spi_device *spi, pm_message_t message) 20static int ad714x_spi_suspend(struct device *dev)
20{ 21{
21 return ad714x_disable(spi_get_drvdata(spi)); 22 return ad714x_disable(spi_get_drvdata(to_spi_device(dev)));
22} 23}
23 24
24static int ad714x_spi_resume(struct spi_device *spi) 25static int ad714x_spi_resume(struct device *dev)
25{ 26{
26 return ad714x_enable(spi_get_drvdata(spi)); 27 return ad714x_enable(spi_get_drvdata(to_spi_device(dev)));
27} 28}
28#else
29# define ad714x_spi_suspend NULL
30# define ad714x_spi_resume NULL
31#endif 29#endif
32 30
31static SIMPLE_DEV_PM_OPS(ad714x_spi_pm, ad714x_spi_suspend, ad714x_spi_resume);
32
33static int ad714x_spi_read(struct device *dev, unsigned short reg, 33static int ad714x_spi_read(struct device *dev, unsigned short reg,
34 unsigned short *data) 34 unsigned short *data)
35{ 35{
@@ -79,11 +79,10 @@ static struct spi_driver ad714x_spi_driver = {
79 .driver = { 79 .driver = {
80 .name = "ad714x_captouch", 80 .name = "ad714x_captouch",
81 .owner = THIS_MODULE, 81 .owner = THIS_MODULE,
82 .pm = &ad714x_spi_pm,
82 }, 83 },
83 .probe = ad714x_spi_probe, 84 .probe = ad714x_spi_probe,
84 .remove = __devexit_p(ad714x_spi_remove), 85 .remove = __devexit_p(ad714x_spi_remove),
85 .suspend = ad714x_spi_suspend,
86 .resume = ad714x_spi_resume,
87}; 86};
88 87
89static __init int ad714x_spi_init(void) 88static __init int ad714x_spi_init(void)
diff --git a/drivers/input/misc/adxl34x-i2c.c b/drivers/input/misc/adxl34x-i2c.c
index 0779724af7e7..ccacf2bb06a4 100644
--- a/drivers/input/misc/adxl34x-i2c.c
+++ b/drivers/input/misc/adxl34x-i2c.c
@@ -11,6 +11,7 @@
11#include <linux/i2c.h> 11#include <linux/i2c.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/types.h> 13#include <linux/types.h>
14#include <linux/pm.h>
14#include "adxl34x.h" 15#include "adxl34x.h"
15 16
16static int adxl34x_smbus_read(struct device *dev, unsigned char reg) 17static int adxl34x_smbus_read(struct device *dev, unsigned char reg)
@@ -105,8 +106,9 @@ static int __devexit adxl34x_i2c_remove(struct i2c_client *client)
105} 106}
106 107
107#ifdef CONFIG_PM 108#ifdef CONFIG_PM
108static int adxl34x_i2c_suspend(struct i2c_client *client, pm_message_t message) 109static int adxl34x_i2c_suspend(struct device *dev)
109{ 110{
111 struct i2c_client *client = to_i2c_client(dev);
110 struct adxl34x *ac = i2c_get_clientdata(client); 112 struct adxl34x *ac = i2c_get_clientdata(client);
111 113
112 adxl34x_suspend(ac); 114 adxl34x_suspend(ac);
@@ -114,19 +116,20 @@ static int adxl34x_i2c_suspend(struct i2c_client *client, pm_message_t message)
114 return 0; 116 return 0;
115} 117}
116 118
117static int adxl34x_i2c_resume(struct i2c_client *client) 119static int adxl34x_i2c_resume(struct device *dev)
118{ 120{
121 struct i2c_client *client = to_i2c_client(dev);
119 struct adxl34x *ac = i2c_get_clientdata(client); 122 struct adxl34x *ac = i2c_get_clientdata(client);
120 123
121 adxl34x_resume(ac); 124 adxl34x_resume(ac);
122 125
123 return 0; 126 return 0;
124} 127}
125#else
126# define adxl34x_i2c_suspend NULL
127# define adxl34x_i2c_resume NULL
128#endif 128#endif
129 129
130static SIMPLE_DEV_PM_OPS(adxl34x_i2c_pm, adxl34x_i2c_suspend,
131 adxl34x_i2c_resume);
132
130static const struct i2c_device_id adxl34x_id[] = { 133static const struct i2c_device_id adxl34x_id[] = {
131 { "adxl34x", 0 }, 134 { "adxl34x", 0 },
132 { } 135 { }
@@ -138,11 +141,10 @@ static struct i2c_driver adxl34x_driver = {
138 .driver = { 141 .driver = {
139 .name = "adxl34x", 142 .name = "adxl34x",
140 .owner = THIS_MODULE, 143 .owner = THIS_MODULE,
144 .pm = &adxl34x_i2c_pm,
141 }, 145 },
142 .probe = adxl34x_i2c_probe, 146 .probe = adxl34x_i2c_probe,
143 .remove = __devexit_p(adxl34x_i2c_remove), 147 .remove = __devexit_p(adxl34x_i2c_remove),
144 .suspend = adxl34x_i2c_suspend,
145 .resume = adxl34x_i2c_resume,
146 .id_table = adxl34x_id, 148 .id_table = adxl34x_id,
147}; 149};
148 150
diff --git a/drivers/input/misc/adxl34x-spi.c b/drivers/input/misc/adxl34x-spi.c
index 782de9e89828..f29de22fdda0 100644
--- a/drivers/input/misc/adxl34x-spi.c
+++ b/drivers/input/misc/adxl34x-spi.c
@@ -10,6 +10,7 @@
10#include <linux/input.h> /* BUS_SPI */ 10#include <linux/input.h> /* BUS_SPI */
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/spi/spi.h> 12#include <linux/spi/spi.h>
13#include <linux/pm.h>
13#include <linux/types.h> 14#include <linux/types.h>
14#include "adxl34x.h" 15#include "adxl34x.h"
15 16
@@ -57,7 +58,7 @@ static int adxl34x_spi_read_block(struct device *dev,
57 return (status < 0) ? status : 0; 58 return (status < 0) ? status : 0;
58} 59}
59 60
60static const struct adxl34x_bus_ops adx134x_spi_bops = { 61static const struct adxl34x_bus_ops adxl34x_spi_bops = {
61 .bustype = BUS_SPI, 62 .bustype = BUS_SPI,
62 .write = adxl34x_spi_write, 63 .write = adxl34x_spi_write,
63 .read = adxl34x_spi_read, 64 .read = adxl34x_spi_read,
@@ -76,7 +77,7 @@ static int __devinit adxl34x_spi_probe(struct spi_device *spi)
76 77
77 ac = adxl34x_probe(&spi->dev, spi->irq, 78 ac = adxl34x_probe(&spi->dev, spi->irq,
78 spi->max_speed_hz > MAX_FREQ_NO_FIFODELAY, 79 spi->max_speed_hz > MAX_FREQ_NO_FIFODELAY,
79 &adx134x_spi_bops); 80 &adxl34x_spi_bops);
80 81
81 if (IS_ERR(ac)) 82 if (IS_ERR(ac))
82 return PTR_ERR(ac); 83 return PTR_ERR(ac);
@@ -94,8 +95,9 @@ static int __devexit adxl34x_spi_remove(struct spi_device *spi)
94} 95}
95 96
96#ifdef CONFIG_PM 97#ifdef CONFIG_PM
97static int adxl34x_spi_suspend(struct spi_device *spi, pm_message_t message) 98static int adxl34x_spi_suspend(struct device *dev)
98{ 99{
100 struct spi_device *spi = to_spi_device(dev);
99 struct adxl34x *ac = dev_get_drvdata(&spi->dev); 101 struct adxl34x *ac = dev_get_drvdata(&spi->dev);
100 102
101 adxl34x_suspend(ac); 103 adxl34x_suspend(ac);
@@ -103,29 +105,29 @@ static int adxl34x_spi_suspend(struct spi_device *spi, pm_message_t message)
103 return 0; 105 return 0;
104} 106}
105 107
106static int adxl34x_spi_resume(struct spi_device *spi) 108static int adxl34x_spi_resume(struct device *dev)
107{ 109{
110 struct spi_device *spi = to_spi_device(dev);
108 struct adxl34x *ac = dev_get_drvdata(&spi->dev); 111 struct adxl34x *ac = dev_get_drvdata(&spi->dev);
109 112
110 adxl34x_resume(ac); 113 adxl34x_resume(ac);
111 114
112 return 0; 115 return 0;
113} 116}
114#else
115# define adxl34x_spi_suspend NULL
116# define adxl34x_spi_resume NULL
117#endif 117#endif
118 118
119static SIMPLE_DEV_PM_OPS(adxl34x_spi_pm, adxl34x_spi_suspend,
120 adxl34x_spi_resume);
121
119static struct spi_driver adxl34x_driver = { 122static struct spi_driver adxl34x_driver = {
120 .driver = { 123 .driver = {
121 .name = "adxl34x", 124 .name = "adxl34x",
122 .bus = &spi_bus_type, 125 .bus = &spi_bus_type,
123 .owner = THIS_MODULE, 126 .owner = THIS_MODULE,
127 .pm = &adxl34x_spi_pm,
124 }, 128 },
125 .probe = adxl34x_spi_probe, 129 .probe = adxl34x_spi_probe,
126 .remove = __devexit_p(adxl34x_spi_remove), 130 .remove = __devexit_p(adxl34x_spi_remove),
127 .suspend = adxl34x_spi_suspend,
128 .resume = adxl34x_spi_resume,
129}; 131};
130 132
131static int __init adxl34x_spi_init(void) 133static int __init adxl34x_spi_init(void)
diff --git a/drivers/input/misc/adxl34x.c b/drivers/input/misc/adxl34x.c
index de5900d50788..144ddbdeb9b3 100644
--- a/drivers/input/misc/adxl34x.c
+++ b/drivers/input/misc/adxl34x.c
@@ -716,7 +716,7 @@ struct adxl34x *adxl34x_probe(struct device *dev, int irq,
716 pdata = dev->platform_data; 716 pdata = dev->platform_data;
717 if (!pdata) { 717 if (!pdata) {
718 dev_dbg(dev, 718 dev_dbg(dev,
719 "No platfrom data: Using default initialization\n"); 719 "No platform data: Using default initialization\n");
720 pdata = &adxl34x_default_init; 720 pdata = &adxl34x_default_init;
721 } 721 }
722 722
diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c
index 0b0e9be63542..9ccdb82d869a 100644
--- a/drivers/input/misc/ati_remote2.c
+++ b/drivers/input/misc/ati_remote2.c
@@ -612,8 +612,8 @@ static int ati_remote2_input_init(struct ati_remote2 *ar2)
612 idev->open = ati_remote2_open; 612 idev->open = ati_remote2_open;
613 idev->close = ati_remote2_close; 613 idev->close = ati_remote2_close;
614 614
615 idev->getkeycode_new = ati_remote2_getkeycode; 615 idev->getkeycode = ati_remote2_getkeycode;
616 idev->setkeycode_new = ati_remote2_setkeycode; 616 idev->setkeycode = ati_remote2_setkeycode;
617 617
618 idev->name = ar2->name; 618 idev->name = ar2->name;
619 idev->phys = ar2->phys; 619 idev->phys = ar2->phys;
diff --git a/drivers/input/misc/keyspan_remote.c b/drivers/input/misc/keyspan_remote.c
index a93c525475c6..fc62256c963f 100644
--- a/drivers/input/misc/keyspan_remote.c
+++ b/drivers/input/misc/keyspan_remote.c
@@ -312,7 +312,7 @@ static void keyspan_check_data(struct usb_keyspan *remote)
312 remote->data.tester = remote->data.tester >> 5; 312 remote->data.tester = remote->data.tester >> 5;
313 remote->data.bits_left -= 5; 313 remote->data.bits_left -= 5;
314 } else { 314 } else {
315 err("Bad message recieved, no stop bit found.\n"); 315 err("Bad message received, no stop bit found.\n");
316 } 316 }
317 317
318 dev_dbg(&remote->udev->dev, 318 dev_dbg(&remote->udev->dev,
diff --git a/drivers/input/misc/twl4030-vibra.c b/drivers/input/misc/twl4030-vibra.c
index 014dd4ad0d4f..6a11694e3fc7 100644
--- a/drivers/input/misc/twl4030-vibra.c
+++ b/drivers/input/misc/twl4030-vibra.c
@@ -29,6 +29,7 @@
29#include <linux/workqueue.h> 29#include <linux/workqueue.h>
30#include <linux/i2c/twl.h> 30#include <linux/i2c/twl.h>
31#include <linux/mfd/twl4030-codec.h> 31#include <linux/mfd/twl4030-codec.h>
32#include <linux/mfd/core.h>
32#include <linux/input.h> 33#include <linux/input.h>
33#include <linux/slab.h> 34#include <linux/slab.h>
34 35
@@ -196,7 +197,7 @@ static SIMPLE_DEV_PM_OPS(twl4030_vibra_pm_ops,
196 197
197static int __devinit twl4030_vibra_probe(struct platform_device *pdev) 198static int __devinit twl4030_vibra_probe(struct platform_device *pdev)
198{ 199{
199 struct twl4030_codec_vibra_data *pdata = pdev->dev.platform_data; 200 struct twl4030_codec_vibra_data *pdata = mfd_get_data(pdev);
200 struct vibra_info *info; 201 struct vibra_info *info;
201 int ret; 202 int ret;
202 203
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index 82542a1c1098..736056897e50 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -302,10 +302,14 @@ static int uinput_validate_absbits(struct input_dev *dev)
302 int retval = 0; 302 int retval = 0;
303 303
304 for (cnt = 0; cnt < ABS_CNT; cnt++) { 304 for (cnt = 0; cnt < ABS_CNT; cnt++) {
305 int min, max;
305 if (!test_bit(cnt, dev->absbit)) 306 if (!test_bit(cnt, dev->absbit))
306 continue; 307 continue;
307 308
308 if (input_abs_get_max(dev, cnt) <= input_abs_get_min(dev, cnt)) { 309 min = input_abs_get_min(dev, cnt);
310 max = input_abs_get_max(dev, cnt);
311
312 if ((min != 0 || max != 0) && max <= min) {
309 printk(KERN_DEBUG 313 printk(KERN_DEBUG
310 "%s: invalid abs[%02x] min:%d max:%d\n", 314 "%s: invalid abs[%02x] min:%d max:%d\n",
311 UINPUT_NAME, cnt, 315 UINPUT_NAME, cnt,
@@ -347,8 +351,7 @@ static int uinput_setup_device(struct uinput_device *udev, const char __user *bu
347{ 351{
348 struct uinput_user_dev *user_dev; 352 struct uinput_user_dev *user_dev;
349 struct input_dev *dev; 353 struct input_dev *dev;
350 char *name; 354 int i;
351 int i, size;
352 int retval; 355 int retval;
353 356
354 if (count != sizeof(struct uinput_user_dev)) 357 if (count != sizeof(struct uinput_user_dev))
@@ -362,30 +365,25 @@ static int uinput_setup_device(struct uinput_device *udev, const char __user *bu
362 365
363 dev = udev->dev; 366 dev = udev->dev;
364 367
365 user_dev = kmalloc(sizeof(struct uinput_user_dev), GFP_KERNEL); 368 user_dev = memdup_user(buffer, sizeof(struct uinput_user_dev));
366 if (!user_dev) 369 if (IS_ERR(user_dev))
367 return -ENOMEM; 370 return PTR_ERR(user_dev);
368
369 if (copy_from_user(user_dev, buffer, sizeof(struct uinput_user_dev))) {
370 retval = -EFAULT;
371 goto exit;
372 }
373 371
374 udev->ff_effects_max = user_dev->ff_effects_max; 372 udev->ff_effects_max = user_dev->ff_effects_max;
375 373
376 size = strnlen(user_dev->name, UINPUT_MAX_NAME_SIZE) + 1; 374 /* Ensure name is filled in */
377 if (!size) { 375 if (!user_dev->name[0]) {
378 retval = -EINVAL; 376 retval = -EINVAL;
379 goto exit; 377 goto exit;
380 } 378 }
381 379
382 kfree(dev->name); 380 kfree(dev->name);
383 dev->name = name = kmalloc(size, GFP_KERNEL); 381 dev->name = kstrndup(user_dev->name, UINPUT_MAX_NAME_SIZE,
384 if (!name) { 382 GFP_KERNEL);
383 if (!dev->name) {
385 retval = -ENOMEM; 384 retval = -ENOMEM;
386 goto exit; 385 goto exit;
387 } 386 }
388 strlcpy(name, user_dev->name, size);
389 387
390 dev->id.bustype = user_dev->id.bustype; 388 dev->id.bustype = user_dev->id.bustype;
391 dev->id.vendor = user_dev->id.vendor; 389 dev->id.vendor = user_dev->id.vendor;
@@ -622,7 +620,6 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
622 struct uinput_ff_upload ff_up; 620 struct uinput_ff_upload ff_up;
623 struct uinput_ff_erase ff_erase; 621 struct uinput_ff_erase ff_erase;
624 struct uinput_request *req; 622 struct uinput_request *req;
625 int length;
626 char *phys; 623 char *phys;
627 624
628 retval = mutex_lock_interruptible(&udev->mutex); 625 retval = mutex_lock_interruptible(&udev->mutex);
@@ -689,24 +686,15 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
689 retval = -EINVAL; 686 retval = -EINVAL;
690 goto out; 687 goto out;
691 } 688 }
692 length = strnlen_user(p, 1024); 689
693 if (length <= 0) { 690 phys = strndup_user(p, 1024);
694 retval = -EFAULT; 691 if (IS_ERR(phys)) {
695 break; 692 retval = PTR_ERR(phys);
693 goto out;
696 } 694 }
695
697 kfree(udev->dev->phys); 696 kfree(udev->dev->phys);
698 udev->dev->phys = phys = kmalloc(length, GFP_KERNEL); 697 udev->dev->phys = phys;
699 if (!phys) {
700 retval = -ENOMEM;
701 break;
702 }
703 if (copy_from_user(phys, p, length)) {
704 udev->dev->phys = NULL;
705 kfree(phys);
706 retval = -EFAULT;
707 break;
708 }
709 phys[length - 1] = '\0';
710 break; 698 break;
711 699
712 case UI_BEGIN_FF_UPLOAD: 700 case UI_BEGIN_FF_UPLOAD:
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index 12501de0c5cd..52b419348983 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -274,7 +274,7 @@ static struct key_entry keymap_fs_amilo_pro_v3505[] __initdata = {
274 { KE_BLUETOOTH, 0x30 }, /* Fn+F10 */ 274 { KE_BLUETOOTH, 0x30 }, /* Fn+F10 */
275 { KE_KEY, 0x31, {KEY_MAIL} }, /* mail button */ 275 { KE_KEY, 0x31, {KEY_MAIL} }, /* mail button */
276 { KE_KEY, 0x36, {KEY_WWW} }, /* www button */ 276 { KE_KEY, 0x36, {KEY_WWW} }, /* www button */
277 { KE_WIFI, 0x78 }, /* satelite dish button */ 277 { KE_WIFI, 0x78 }, /* satellite dish button */
278 { KE_END, 0 } 278 { KE_END, 0 }
279}; 279};
280 280
diff --git a/drivers/input/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
index 7f85a862ad11..62bae99424e6 100644
--- a/drivers/input/xen-kbdfront.c
+++ b/drivers/input/misc/xen-kbdfront.c
@@ -11,12 +11,6 @@
11 * more details. 11 * more details.
12 */ 12 */
13 13
14/*
15 * TODO:
16 *
17 * Switch to grant tables together with xen-fbfront.c.
18 */
19
20#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 14#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
21 15
22#include <linux/kernel.h> 16#include <linux/kernel.h>
@@ -30,6 +24,8 @@
30#include <xen/xen.h> 24#include <xen/xen.h>
31#include <xen/events.h> 25#include <xen/events.h>
32#include <xen/page.h> 26#include <xen/page.h>
27#include <xen/grant_table.h>
28#include <xen/interface/grant_table.h>
33#include <xen/interface/io/fbif.h> 29#include <xen/interface/io/fbif.h>
34#include <xen/interface/io/kbdif.h> 30#include <xen/interface/io/kbdif.h>
35#include <xen/xenbus.h> 31#include <xen/xenbus.h>
@@ -38,6 +34,7 @@ struct xenkbd_info {
38 struct input_dev *kbd; 34 struct input_dev *kbd;
39 struct input_dev *ptr; 35 struct input_dev *ptr;
40 struct xenkbd_page *page; 36 struct xenkbd_page *page;
37 int gref;
41 int irq; 38 int irq;
42 struct xenbus_device *xbdev; 39 struct xenbus_device *xbdev;
43 char phys[32]; 40 char phys[32];
@@ -110,7 +107,7 @@ static irqreturn_t input_handler(int rq, void *dev_id)
110static int __devinit xenkbd_probe(struct xenbus_device *dev, 107static int __devinit xenkbd_probe(struct xenbus_device *dev,
111 const struct xenbus_device_id *id) 108 const struct xenbus_device_id *id)
112{ 109{
113 int ret, i; 110 int ret, i, abs;
114 struct xenkbd_info *info; 111 struct xenkbd_info *info;
115 struct input_dev *kbd, *ptr; 112 struct input_dev *kbd, *ptr;
116 113
@@ -122,12 +119,18 @@ static int __devinit xenkbd_probe(struct xenbus_device *dev,
122 dev_set_drvdata(&dev->dev, info); 119 dev_set_drvdata(&dev->dev, info);
123 info->xbdev = dev; 120 info->xbdev = dev;
124 info->irq = -1; 121 info->irq = -1;
122 info->gref = -1;
125 snprintf(info->phys, sizeof(info->phys), "xenbus/%s", dev->nodename); 123 snprintf(info->phys, sizeof(info->phys), "xenbus/%s", dev->nodename);
126 124
127 info->page = (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO); 125 info->page = (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
128 if (!info->page) 126 if (!info->page)
129 goto error_nomem; 127 goto error_nomem;
130 128
129 if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-abs-pointer", "%d", &abs) < 0)
130 abs = 0;
131 if (abs)
132 xenbus_printf(XBT_NIL, dev->nodename, "request-abs-pointer", "1");
133
131 /* keyboard */ 134 /* keyboard */
132 kbd = input_allocate_device(); 135 kbd = input_allocate_device();
133 if (!kbd) 136 if (!kbd)
@@ -137,11 +140,12 @@ static int __devinit xenkbd_probe(struct xenbus_device *dev,
137 kbd->id.bustype = BUS_PCI; 140 kbd->id.bustype = BUS_PCI;
138 kbd->id.vendor = 0x5853; 141 kbd->id.vendor = 0x5853;
139 kbd->id.product = 0xffff; 142 kbd->id.product = 0xffff;
140 kbd->evbit[0] = BIT(EV_KEY); 143
144 __set_bit(EV_KEY, kbd->evbit);
141 for (i = KEY_ESC; i < KEY_UNKNOWN; i++) 145 for (i = KEY_ESC; i < KEY_UNKNOWN; i++)
142 set_bit(i, kbd->keybit); 146 __set_bit(i, kbd->keybit);
143 for (i = KEY_OK; i < KEY_MAX; i++) 147 for (i = KEY_OK; i < KEY_MAX; i++)
144 set_bit(i, kbd->keybit); 148 __set_bit(i, kbd->keybit);
145 149
146 ret = input_register_device(kbd); 150 ret = input_register_device(kbd);
147 if (ret) { 151 if (ret) {
@@ -160,12 +164,20 @@ static int __devinit xenkbd_probe(struct xenbus_device *dev,
160 ptr->id.bustype = BUS_PCI; 164 ptr->id.bustype = BUS_PCI;
161 ptr->id.vendor = 0x5853; 165 ptr->id.vendor = 0x5853;
162 ptr->id.product = 0xfffe; 166 ptr->id.product = 0xfffe;
163 ptr->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS); 167
168 if (abs) {
169 __set_bit(EV_ABS, ptr->evbit);
170 input_set_abs_params(ptr, ABS_X, 0, XENFB_WIDTH, 0, 0);
171 input_set_abs_params(ptr, ABS_Y, 0, XENFB_HEIGHT, 0, 0);
172 } else {
173 input_set_capability(ptr, EV_REL, REL_X);
174 input_set_capability(ptr, EV_REL, REL_Y);
175 }
176 input_set_capability(ptr, EV_REL, REL_WHEEL);
177
178 __set_bit(EV_KEY, ptr->evbit);
164 for (i = BTN_LEFT; i <= BTN_TASK; i++) 179 for (i = BTN_LEFT; i <= BTN_TASK; i++)
165 set_bit(i, ptr->keybit); 180 __set_bit(i, ptr->keybit);
166 ptr->relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL);
167 input_set_abs_params(ptr, ABS_X, 0, XENFB_WIDTH, 0, 0);
168 input_set_abs_params(ptr, ABS_Y, 0, XENFB_HEIGHT, 0, 0);
169 181
170 ret = input_register_device(ptr); 182 ret = input_register_device(ptr);
171 if (ret) { 183 if (ret) {
@@ -218,15 +230,20 @@ static int xenkbd_connect_backend(struct xenbus_device *dev,
218 int ret, evtchn; 230 int ret, evtchn;
219 struct xenbus_transaction xbt; 231 struct xenbus_transaction xbt;
220 232
233 ret = gnttab_grant_foreign_access(dev->otherend_id,
234 virt_to_mfn(info->page), 0);
235 if (ret < 0)
236 return ret;
237 info->gref = ret;
238
221 ret = xenbus_alloc_evtchn(dev, &evtchn); 239 ret = xenbus_alloc_evtchn(dev, &evtchn);
222 if (ret) 240 if (ret)
223 return ret; 241 goto error_grant;
224 ret = bind_evtchn_to_irqhandler(evtchn, input_handler, 242 ret = bind_evtchn_to_irqhandler(evtchn, input_handler,
225 0, dev->devicetype, info); 243 0, dev->devicetype, info);
226 if (ret < 0) { 244 if (ret < 0) {
227 xenbus_free_evtchn(dev, evtchn);
228 xenbus_dev_fatal(dev, ret, "bind_evtchn_to_irqhandler"); 245 xenbus_dev_fatal(dev, ret, "bind_evtchn_to_irqhandler");
229 return ret; 246 goto error_evtchan;
230 } 247 }
231 info->irq = ret; 248 info->irq = ret;
232 249
@@ -234,12 +251,15 @@ static int xenkbd_connect_backend(struct xenbus_device *dev,
234 ret = xenbus_transaction_start(&xbt); 251 ret = xenbus_transaction_start(&xbt);
235 if (ret) { 252 if (ret) {
236 xenbus_dev_fatal(dev, ret, "starting transaction"); 253 xenbus_dev_fatal(dev, ret, "starting transaction");
237 return ret; 254 goto error_irqh;
238 } 255 }
239 ret = xenbus_printf(xbt, dev->nodename, "page-ref", "%lu", 256 ret = xenbus_printf(xbt, dev->nodename, "page-ref", "%lu",
240 virt_to_mfn(info->page)); 257 virt_to_mfn(info->page));
241 if (ret) 258 if (ret)
242 goto error_xenbus; 259 goto error_xenbus;
260 ret = xenbus_printf(xbt, dev->nodename, "page-gref", "%u", info->gref);
261 if (ret)
262 goto error_xenbus;
243 ret = xenbus_printf(xbt, dev->nodename, "event-channel", "%u", 263 ret = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
244 evtchn); 264 evtchn);
245 if (ret) 265 if (ret)
@@ -249,7 +269,7 @@ static int xenkbd_connect_backend(struct xenbus_device *dev,
249 if (ret == -EAGAIN) 269 if (ret == -EAGAIN)
250 goto again; 270 goto again;
251 xenbus_dev_fatal(dev, ret, "completing transaction"); 271 xenbus_dev_fatal(dev, ret, "completing transaction");
252 return ret; 272 goto error_irqh;
253 } 273 }
254 274
255 xenbus_switch_state(dev, XenbusStateInitialised); 275 xenbus_switch_state(dev, XenbusStateInitialised);
@@ -258,6 +278,14 @@ static int xenkbd_connect_backend(struct xenbus_device *dev,
258 error_xenbus: 278 error_xenbus:
259 xenbus_transaction_end(xbt, 1); 279 xenbus_transaction_end(xbt, 1);
260 xenbus_dev_fatal(dev, ret, "writing xenstore"); 280 xenbus_dev_fatal(dev, ret, "writing xenstore");
281 error_irqh:
282 unbind_from_irqhandler(info->irq, info);
283 info->irq = -1;
284 error_evtchan:
285 xenbus_free_evtchn(dev, evtchn);
286 error_grant:
287 gnttab_end_foreign_access_ref(info->gref, 0);
288 info->gref = -1;
261 return ret; 289 return ret;
262} 290}
263 291
@@ -266,6 +294,9 @@ static void xenkbd_disconnect_backend(struct xenkbd_info *info)
266 if (info->irq >= 0) 294 if (info->irq >= 0)
267 unbind_from_irqhandler(info->irq, info); 295 unbind_from_irqhandler(info->irq, info);
268 info->irq = -1; 296 info->irq = -1;
297 if (info->gref >= 0)
298 gnttab_end_foreign_access_ref(info->gref, 0);
299 info->gref = -1;
269} 300}
270 301
271static void xenkbd_backend_changed(struct xenbus_device *dev, 302static void xenkbd_backend_changed(struct xenbus_device *dev,
@@ -293,8 +324,9 @@ InitWait:
293 ret = xenbus_printf(XBT_NIL, info->xbdev->nodename, 324 ret = xenbus_printf(XBT_NIL, info->xbdev->nodename,
294 "request-abs-pointer", "1"); 325 "request-abs-pointer", "1");
295 if (ret) 326 if (ret)
296 pr_warning("can't request abs-pointer\n"); 327 pr_warning("xenkbd: can't request abs-pointer");
297 } 328 }
329
298 xenbus_switch_state(dev, XenbusStateConnected); 330 xenbus_switch_state(dev, XenbusStateConnected);
299 break; 331 break;
300 332
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
index ee82851afe3e..3126983c004a 100644
--- a/drivers/input/mouse/bcm5974.c
+++ b/drivers/input/mouse/bcm5974.c
@@ -63,6 +63,10 @@
63#define USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI 0x0242 63#define USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI 0x0242
64#define USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO 0x0243 64#define USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO 0x0243
65#define USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS 0x0244 65#define USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS 0x0244
66/* Macbook8 (unibody, March 2011) */
67#define USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI 0x0245
68#define USB_DEVICE_ID_APPLE_WELLSPRING5_ISO 0x0246
69#define USB_DEVICE_ID_APPLE_WELLSPRING5_JIS 0x0247
66 70
67#define BCM5974_DEVICE(prod) { \ 71#define BCM5974_DEVICE(prod) { \
68 .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \ 72 .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \
@@ -96,6 +100,10 @@ static const struct usb_device_id bcm5974_table[] = {
96 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI), 100 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI),
97 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO), 101 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO),
98 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS), 102 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS),
103 /* MacbookPro8 */
104 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI),
105 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_ISO),
106 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_JIS),
99 /* Terminating entry */ 107 /* Terminating entry */
100 {} 108 {}
101}; 109};
@@ -274,6 +282,18 @@ static const struct bcm5974_config bcm5974_config_table[] = {
274 { DIM_X, DIM_X / SN_COORD, -4616, 5112 }, 282 { DIM_X, DIM_X / SN_COORD, -4616, 5112 },
275 { DIM_Y, DIM_Y / SN_COORD, -142, 5234 } 283 { DIM_Y, DIM_Y / SN_COORD, -142, 5234 }
276 }, 284 },
285 {
286 USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI,
287 USB_DEVICE_ID_APPLE_WELLSPRING5_ISO,
288 USB_DEVICE_ID_APPLE_WELLSPRING5_JIS,
289 HAS_INTEGRATED_BUTTON,
290 0x84, sizeof(struct bt_data),
291 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
292 { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 },
293 { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
294 { DIM_X, DIM_X / SN_COORD, -4415, 5050 },
295 { DIM_Y, DIM_Y / SN_COORD, -55, 6680 }
296 },
277 {} 297 {}
278}; 298};
279 299
@@ -430,10 +450,6 @@ static int report_tp_state(struct bcm5974 *dev, int size)
430 ptest = int2bound(&c->p, raw_p); 450 ptest = int2bound(&c->p, raw_p);
431 origin = raw2int(f->origin); 451 origin = raw2int(f->origin);
432 452
433 /* set the integrated button if applicable */
434 if (c->tp_type == TYPE2)
435 ibt = raw2int(dev->tp_data[BUTTON_TYPE2]);
436
437 /* while tracking finger still valid, count all fingers */ 453 /* while tracking finger still valid, count all fingers */
438 if (ptest > PRESSURE_LOW && origin) { 454 if (ptest > PRESSURE_LOW && origin) {
439 abs_p = ptest; 455 abs_p = ptest;
@@ -452,6 +468,10 @@ static int report_tp_state(struct bcm5974 *dev, int size)
452 } 468 }
453 } 469 }
454 470
471 /* set the integrated button if applicable */
472 if (c->tp_type == TYPE2)
473 ibt = raw2int(dev->tp_data[BUTTON_TYPE2]);
474
455 if (dev->fingers < nmin) 475 if (dev->fingers < nmin)
456 dev->fingers = nmin; 476 dev->fingers = nmin;
457 if (dev->fingers > nmax) 477 if (dev->fingers > nmax)
@@ -619,7 +639,7 @@ exit:
619 * device, resulting in trackpad malfunction under certain 639 * device, resulting in trackpad malfunction under certain
620 * circumstances. To get around this problem, there is at least one 640 * circumstances. To get around this problem, there is at least one
621 * example that utilizes the USB_QUIRK_RESET_RESUME quirk in order to 641 * example that utilizes the USB_QUIRK_RESET_RESUME quirk in order to
622 * recieve a reset_resume request rather than the normal resume. 642 * receive a reset_resume request rather than the normal resume.
623 * Since the implementation of reset_resume is equal to mode switch 643 * Since the implementation of reset_resume is equal to mode switch
624 * plus start_traffic, it seems easier to always do the switch when 644 * plus start_traffic, it seems easier to always do the switch when
625 * starting traffic on the device. 645 * starting traffic on the device.
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index aa186cf6c514..e06e045bf907 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -836,8 +836,8 @@ static const struct dmi_system_id __initconst toshiba_dmi_table[] = {
836 }, 836 },
837 837
838 }, 838 },
839 { }
840#endif 839#endif
840 { }
841}; 841};
842 842
843static bool broken_olpc_ec; 843static bool broken_olpc_ec;
@@ -851,8 +851,8 @@ static const struct dmi_system_id __initconst olpc_dmi_table[] = {
851 DMI_MATCH(DMI_PRODUCT_NAME, "XO"), 851 DMI_MATCH(DMI_PRODUCT_NAME, "XO"),
852 }, 852 },
853 }, 853 },
854 { }
855#endif 854#endif
855 { }
856}; 856};
857 857
858void __init synaptics_module_init(void) 858void __init synaptics_module_init(void)
diff --git a/drivers/input/mouse/synaptics_i2c.c b/drivers/input/mouse/synaptics_i2c.c
index 0ae62f0bcb32..cba3c84d2f21 100644
--- a/drivers/input/mouse/synaptics_i2c.c
+++ b/drivers/input/mouse/synaptics_i2c.c
@@ -18,6 +18,7 @@
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/workqueue.h> 19#include <linux/workqueue.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/pm.h>
21 22
22#define DRIVER_NAME "synaptics_i2c" 23#define DRIVER_NAME "synaptics_i2c"
23/* maximum product id is 15 characters */ 24/* maximum product id is 15 characters */
@@ -461,7 +462,7 @@ static void synaptics_i2c_work_handler(struct work_struct *work)
461 * While interrupt driven, there is no real need to poll the device. 462 * While interrupt driven, there is no real need to poll the device.
462 * But touchpads are very sensitive, so there could be errors 463 * But touchpads are very sensitive, so there could be errors
463 * related to physical environment and the attention line isn't 464 * related to physical environment and the attention line isn't
464 * neccesarily asserted. In such case we can lose the touchpad. 465 * necessarily asserted. In such case we can lose the touchpad.
465 * We poll the device once in THREAD_IRQ_SLEEP_SECS and 466 * We poll the device once in THREAD_IRQ_SLEEP_SECS and
466 * if error is detected, we try to reset and reconfigure the touchpad. 467 * if error is detected, we try to reset and reconfigure the touchpad.
467 */ 468 */
@@ -619,8 +620,9 @@ static int __devexit synaptics_i2c_remove(struct i2c_client *client)
619} 620}
620 621
621#ifdef CONFIG_PM 622#ifdef CONFIG_PM
622static int synaptics_i2c_suspend(struct i2c_client *client, pm_message_t mesg) 623static int synaptics_i2c_suspend(struct device *dev)
623{ 624{
625 struct i2c_client *client = to_i2c_client(dev);
624 struct synaptics_i2c *touch = i2c_get_clientdata(client); 626 struct synaptics_i2c *touch = i2c_get_clientdata(client);
625 627
626 cancel_delayed_work_sync(&touch->dwork); 628 cancel_delayed_work_sync(&touch->dwork);
@@ -631,9 +633,10 @@ static int synaptics_i2c_suspend(struct i2c_client *client, pm_message_t mesg)
631 return 0; 633 return 0;
632} 634}
633 635
634static int synaptics_i2c_resume(struct i2c_client *client) 636static int synaptics_i2c_resume(struct device *dev)
635{ 637{
636 int ret; 638 int ret;
639 struct i2c_client *client = to_i2c_client(dev);
637 struct synaptics_i2c *touch = i2c_get_clientdata(client); 640 struct synaptics_i2c *touch = i2c_get_clientdata(client);
638 641
639 ret = synaptics_i2c_reset_config(client); 642 ret = synaptics_i2c_reset_config(client);
@@ -645,11 +648,11 @@ static int synaptics_i2c_resume(struct i2c_client *client)
645 648
646 return 0; 649 return 0;
647} 650}
648#else
649#define synaptics_i2c_suspend NULL
650#define synaptics_i2c_resume NULL
651#endif 651#endif
652 652
653static SIMPLE_DEV_PM_OPS(synaptics_i2c_pm, synaptics_i2c_suspend,
654 synaptics_i2c_resume);
655
653static const struct i2c_device_id synaptics_i2c_id_table[] = { 656static const struct i2c_device_id synaptics_i2c_id_table[] = {
654 { "synaptics_i2c", 0 }, 657 { "synaptics_i2c", 0 },
655 { }, 658 { },
@@ -660,13 +663,12 @@ static struct i2c_driver synaptics_i2c_driver = {
660 .driver = { 663 .driver = {
661 .name = DRIVER_NAME, 664 .name = DRIVER_NAME,
662 .owner = THIS_MODULE, 665 .owner = THIS_MODULE,
666 .pm = &synaptics_i2c_pm,
663 }, 667 },
664 668
665 .probe = synaptics_i2c_probe, 669 .probe = synaptics_i2c_probe,
666 .remove = __devexit_p(synaptics_i2c_remove), 670 .remove = __devexit_p(synaptics_i2c_remove),
667 671
668 .suspend = synaptics_i2c_suspend,
669 .resume = synaptics_i2c_resume,
670 .id_table = synaptics_i2c_id_table, 672 .id_table = synaptics_i2c_id_table,
671}; 673};
672 674
diff --git a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c
index bf2c0c80d6cc..eb9a3cfbeefa 100644
--- a/drivers/input/mouse/vsxxxaa.c
+++ b/drivers/input/mouse/vsxxxaa.c
@@ -334,7 +334,7 @@ static void vsxxxaa_handle_POR_packet(struct vsxxxaa *mouse)
334 * M: manufacturer location code 334 * M: manufacturer location code
335 * R: revision code 335 * R: revision code
336 * E: Error code. If it's in the range of 0x00..0x1f, only some 336 * E: Error code. If it's in the range of 0x00..0x1f, only some
337 * minor problem occured. Errors >= 0x20 are considered bad 337 * minor problem occurred. Errors >= 0x20 are considered bad
338 * and the device may not work properly... 338 * and the device may not work properly...
339 * D: <0010> == mouse, <0100> == tablet 339 * D: <0010> == mouse, <0100> == tablet
340 */ 340 */
diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c
index ebe955325677..4b2a42f9f0bb 100644
--- a/drivers/input/serio/ams_delta_serio.c
+++ b/drivers/input/serio/ams_delta_serio.c
@@ -149,7 +149,7 @@ static int __init ams_delta_serio_init(void)
149 * at FIQ level, switch back from edge to simple interrupt handler 149 * at FIQ level, switch back from edge to simple interrupt handler
150 * to avoid bad interaction. 150 * to avoid bad interaction.
151 */ 151 */
152 set_irq_handler(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 152 irq_set_handler(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK),
153 handle_simple_irq); 153 handle_simple_irq);
154 154
155 serio_register_port(ams_delta_serio); 155 serio_register_port(ams_delta_serio);
diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c
index 8c0b51c31424..42206205e4f5 100644
--- a/drivers/input/serio/hp_sdc.c
+++ b/drivers/input/serio/hp_sdc.c
@@ -955,7 +955,7 @@ static int __init hp_sdc_init_hppa(struct parisc_device *d)
955 INIT_DELAYED_WORK(&moduleloader_work, request_module_delayed); 955 INIT_DELAYED_WORK(&moduleloader_work, request_module_delayed);
956 956
957 ret = hp_sdc_init(); 957 ret = hp_sdc_init();
958 /* after successfull initialization give SDC some time to settle 958 /* after successful initialization give SDC some time to settle
959 * and then load the hp_sdc_mlc upper layer driver */ 959 * and then load the hp_sdc_mlc upper layer driver */
960 if (!ret) 960 if (!ret)
961 schedule_delayed_work(&moduleloader_work, 961 schedule_delayed_work(&moduleloader_work,
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index ac4c93689ab9..d37a48e099d0 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -869,15 +869,15 @@ static int i8042_controller_selftest(void)
869 do { 869 do {
870 870
871 if (i8042_command(&param, I8042_CMD_CTL_TEST)) { 871 if (i8042_command(&param, I8042_CMD_CTL_TEST)) {
872 pr_err("i8042 controller self test timeout\n"); 872 pr_err("i8042 controller selftest timeout\n");
873 return -ENODEV; 873 return -ENODEV;
874 } 874 }
875 875
876 if (param == I8042_RET_CTL_TEST) 876 if (param == I8042_RET_CTL_TEST)
877 return 0; 877 return 0;
878 878
879 pr_err("i8042 controller selftest failed. (%#x != %#x)\n", 879 dbg("i8042 controller selftest: %#x != %#x\n",
880 param, I8042_RET_CTL_TEST); 880 param, I8042_RET_CTL_TEST);
881 msleep(50); 881 msleep(50);
882 } while (i++ < 5); 882 } while (i++ < 5);
883 883
@@ -891,6 +891,7 @@ static int i8042_controller_selftest(void)
891 pr_info("giving up on controller selftest, continuing anyway...\n"); 891 pr_info("giving up on controller selftest, continuing anyway...\n");
892 return 0; 892 return 0;
893#else 893#else
894 pr_err("i8042 controller selftest failed\n");
894 return -EIO; 895 return -EIO;
895#endif 896#endif
896} 897}
diff --git a/drivers/input/serio/rpckbd.c b/drivers/input/serio/rpckbd.c
index 9da6fbcaaa7e..7ec3c97dc1b9 100644
--- a/drivers/input/serio/rpckbd.c
+++ b/drivers/input/serio/rpckbd.c
@@ -90,7 +90,7 @@ static int rpckbd_open(struct serio *port)
90 90
91 if (request_irq(IRQ_KEYBOARDTX, rpckbd_tx, 0, "rpckbd", port) != 0) { 91 if (request_irq(IRQ_KEYBOARDTX, rpckbd_tx, 0, "rpckbd", port) != 0) {
92 printk(KERN_ERR "rpckbd.c: Could not allocate keyboard transmit IRQ\n"); 92 printk(KERN_ERR "rpckbd.c: Could not allocate keyboard transmit IRQ\n");
93 free_irq(IRQ_KEYBOARDRX, NULL); 93 free_irq(IRQ_KEYBOARDRX, port);
94 return -EBUSY; 94 return -EBUSY;
95 } 95 }
96 96
diff --git a/drivers/input/serio/xilinx_ps2.c b/drivers/input/serio/xilinx_ps2.c
index 7540bafc95cf..80baa53da5b1 100644
--- a/drivers/input/serio/xilinx_ps2.c
+++ b/drivers/input/serio/xilinx_ps2.c
@@ -225,7 +225,7 @@ static void sxps2_close(struct serio *pserio)
225/** 225/**
226 * xps2_of_probe - probe method for the PS/2 device. 226 * xps2_of_probe - probe method for the PS/2 device.
227 * @of_dev: pointer to OF device structure 227 * @of_dev: pointer to OF device structure
228 * @match: pointer to the stucture used for matching a device 228 * @match: pointer to the structure used for matching a device
229 * 229 *
230 * This function probes the PS/2 device in the device tree. 230 * This function probes the PS/2 device in the device tree.
231 * It initializes the driver data structure and the hardware. 231 * It initializes the driver data structure and the hardware.
diff --git a/drivers/input/sparse-keymap.c b/drivers/input/sparse-keymap.c
index 7729e547ba65..fdb6a3976f94 100644
--- a/drivers/input/sparse-keymap.c
+++ b/drivers/input/sparse-keymap.c
@@ -208,10 +208,16 @@ int sparse_keymap_setup(struct input_dev *dev,
208 } 208 }
209 } 209 }
210 210
211 if (test_bit(EV_KEY, dev->evbit)) {
212 __set_bit(KEY_UNKNOWN, dev->keybit);
213 __set_bit(EV_MSC, dev->evbit);
214 __set_bit(MSC_SCAN, dev->mscbit);
215 }
216
211 dev->keycode = map; 217 dev->keycode = map;
212 dev->keycodemax = map_size; 218 dev->keycodemax = map_size;
213 dev->getkeycode_new = sparse_keymap_getkeycode; 219 dev->getkeycode = sparse_keymap_getkeycode;
214 dev->setkeycode_new = sparse_keymap_setkeycode; 220 dev->setkeycode = sparse_keymap_setkeycode;
215 221
216 return 0; 222 return 0;
217 223
@@ -268,6 +274,7 @@ void sparse_keymap_report_entry(struct input_dev *dev, const struct key_entry *k
268{ 274{
269 switch (ke->type) { 275 switch (ke->type) {
270 case KE_KEY: 276 case KE_KEY:
277 input_event(dev, EV_MSC, MSC_SCAN, ke->code);
271 input_report_key(dev, ke->keycode, value); 278 input_report_key(dev, ke->keycode, value);
272 input_sync(dev); 279 input_sync(dev);
273 if (value && autorelease) { 280 if (value && autorelease) {
@@ -305,12 +312,19 @@ bool sparse_keymap_report_event(struct input_dev *dev, unsigned int code,
305{ 312{
306 const struct key_entry *ke = 313 const struct key_entry *ke =
307 sparse_keymap_entry_from_scancode(dev, code); 314 sparse_keymap_entry_from_scancode(dev, code);
315 struct key_entry unknown_ke;
308 316
309 if (ke) { 317 if (ke) {
310 sparse_keymap_report_entry(dev, ke, value, autorelease); 318 sparse_keymap_report_entry(dev, ke, value, autorelease);
311 return true; 319 return true;
312 } 320 }
313 321
322 /* Report an unknown key event as a debugging aid */
323 unknown_ke.type = KE_KEY;
324 unknown_ke.code = code;
325 unknown_ke.keycode = KEY_UNKNOWN;
326 sparse_keymap_report_entry(dev, &unknown_ke, value, true);
327
314 return false; 328 return false;
315} 329}
316EXPORT_SYMBOL(sparse_keymap_report_event); 330EXPORT_SYMBOL(sparse_keymap_report_event);
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index cf8fb9f5d4a8..449c0a46dbac 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -193,16 +193,16 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
193 case HID_USAGE_X: 193 case HID_USAGE_X:
194 if (usage == WCM_DESKTOP) { 194 if (usage == WCM_DESKTOP) {
195 if (finger) { 195 if (finger) {
196 features->device_type = BTN_TOOL_DOUBLETAP; 196 features->device_type = BTN_TOOL_FINGER;
197 if (features->type == TABLETPC2FG) { 197 if (features->type == TABLETPC2FG) {
198 /* need to reset back */ 198 /* need to reset back */
199 features->pktlen = WACOM_PKGLEN_TPC2FG; 199 features->pktlen = WACOM_PKGLEN_TPC2FG;
200 features->device_type = BTN_TOOL_TRIPLETAP; 200 features->device_type = BTN_TOOL_DOUBLETAP;
201 } 201 }
202 if (features->type == BAMBOO_PT) { 202 if (features->type == BAMBOO_PT) {
203 /* need to reset back */ 203 /* need to reset back */
204 features->pktlen = WACOM_PKGLEN_BBTOUCH; 204 features->pktlen = WACOM_PKGLEN_BBTOUCH;
205 features->device_type = BTN_TOOL_TRIPLETAP; 205 features->device_type = BTN_TOOL_DOUBLETAP;
206 features->x_phy = 206 features->x_phy =
207 get_unaligned_le16(&report[i + 5]); 207 get_unaligned_le16(&report[i + 5]);
208 features->x_max = 208 features->x_max =
@@ -241,11 +241,11 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
241 case HID_USAGE_Y: 241 case HID_USAGE_Y:
242 if (usage == WCM_DESKTOP) { 242 if (usage == WCM_DESKTOP) {
243 if (finger) { 243 if (finger) {
244 features->device_type = BTN_TOOL_DOUBLETAP; 244 features->device_type = BTN_TOOL_FINGER;
245 if (features->type == TABLETPC2FG) { 245 if (features->type == TABLETPC2FG) {
246 /* need to reset back */ 246 /* need to reset back */
247 features->pktlen = WACOM_PKGLEN_TPC2FG; 247 features->pktlen = WACOM_PKGLEN_TPC2FG;
248 features->device_type = BTN_TOOL_TRIPLETAP; 248 features->device_type = BTN_TOOL_DOUBLETAP;
249 features->y_max = 249 features->y_max =
250 get_unaligned_le16(&report[i + 3]); 250 get_unaligned_le16(&report[i + 3]);
251 features->y_phy = 251 features->y_phy =
@@ -254,7 +254,7 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
254 } else if (features->type == BAMBOO_PT) { 254 } else if (features->type == BAMBOO_PT) {
255 /* need to reset back */ 255 /* need to reset back */
256 features->pktlen = WACOM_PKGLEN_BBTOUCH; 256 features->pktlen = WACOM_PKGLEN_BBTOUCH;
257 features->device_type = BTN_TOOL_TRIPLETAP; 257 features->device_type = BTN_TOOL_DOUBLETAP;
258 features->y_phy = 258 features->y_phy =
259 get_unaligned_le16(&report[i + 3]); 259 get_unaligned_le16(&report[i + 3]);
260 features->y_max = 260 features->y_max =
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 367fa82a607e..08ba5ad9c9be 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -16,6 +16,14 @@
16#include "wacom.h" 16#include "wacom.h"
17#include <linux/input/mt.h> 17#include <linux/input/mt.h>
18 18
19/* resolution for penabled devices */
20#define WACOM_PL_RES 20
21#define WACOM_PENPRTN_RES 40
22#define WACOM_VOLITO_RES 50
23#define WACOM_GRAPHIRE_RES 80
24#define WACOM_INTUOS_RES 100
25#define WACOM_INTUOS3_RES 200
26
19static int wacom_penpartner_irq(struct wacom_wac *wacom) 27static int wacom_penpartner_irq(struct wacom_wac *wacom)
20{ 28{
21 unsigned char *data = wacom->data; 29 unsigned char *data = wacom->data;
@@ -675,169 +683,87 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
675 return 1; 683 return 1;
676} 684}
677 685
678 686static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
679static void wacom_tpc_finger_in(struct wacom_wac *wacom, char *data, int idx)
680{ 687{
681 struct input_dev *input = wacom->input; 688 struct input_dev *input = wacom->input;
682 int finger = idx + 1; 689 unsigned char *data = wacom->data;
683 int x = le16_to_cpup((__le16 *)&data[finger * 2]) & 0x7fff; 690 int contact_with_no_pen_down_count = 0;
684 int y = le16_to_cpup((__le16 *)&data[4 + finger * 2]) & 0x7fff; 691 int i;
685 692
686 /* 693 for (i = 0; i < 2; i++) {
687 * Work around input core suppressing "duplicate" events since 694 int p = data[1] & (1 << i);
688 * we are abusing ABS_X/ABS_Y to transmit multi-finger data. 695 bool touch = p && !wacom->shared->stylus_in_proximity;
689 * This should go away once we switch to true multitouch 696
690 * protocol. 697 input_mt_slot(input, i);
691 */ 698 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
692 if (wacom->last_finger != finger) { 699 if (touch) {
693 if (x == input_abs_get_val(input, ABS_X)) 700 int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
694 x++; 701 int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
695 702
696 if (y == input_abs_get_val(input, ABS_Y)) 703 input_report_abs(input, ABS_MT_POSITION_X, x);
697 y++; 704 input_report_abs(input, ABS_MT_POSITION_Y, y);
705 contact_with_no_pen_down_count++;
706 }
698 } 707 }
699 708
700 input_report_abs(input, ABS_X, x); 709 /* keep touch state for pen event */
701 input_report_abs(input, ABS_Y, y); 710 wacom->shared->touch_down = (contact_with_no_pen_down_count > 0);
702 input_report_abs(input, ABS_MISC, wacom->id[0]);
703 input_report_key(input, wacom->tool[finger], 1);
704 if (!idx)
705 input_report_key(input, BTN_TOUCH, 1);
706 input_event(input, EV_MSC, MSC_SERIAL, finger);
707 input_sync(input);
708 711
709 wacom->last_finger = finger; 712 input_mt_report_pointer_emulation(input, true);
710}
711 713
712static void wacom_tpc_touch_out(struct wacom_wac *wacom, int idx) 714 return 1;
713{
714 struct input_dev *input = wacom->input;
715 int finger = idx + 1;
716
717 input_report_abs(input, ABS_X, 0);
718 input_report_abs(input, ABS_Y, 0);
719 input_report_abs(input, ABS_MISC, 0);
720 input_report_key(input, wacom->tool[finger], 0);
721 if (!idx)
722 input_report_key(input, BTN_TOUCH, 0);
723 input_event(input, EV_MSC, MSC_SERIAL, finger);
724 input_sync(input);
725} 715}
726 716
727static void wacom_tpc_touch_in(struct wacom_wac *wacom, size_t len) 717static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
728{ 718{
729 char *data = wacom->data; 719 char *data = wacom->data;
730 struct input_dev *input = wacom->input; 720 struct input_dev *input = wacom->input;
721 bool prox;
722 int x = 0, y = 0;
731 723
732 wacom->tool[1] = BTN_TOOL_DOUBLETAP; 724 if (!wacom->shared->stylus_in_proximity) {
733 wacom->id[0] = TOUCH_DEVICE_ID; 725 if (len == WACOM_PKGLEN_TPC1FG) {
734 wacom->tool[2] = BTN_TOOL_TRIPLETAP; 726 prox = data[0] & 0x01;
735 727 x = get_unaligned_le16(&data[1]);
736 if (len != WACOM_PKGLEN_TPC1FG) { 728 y = get_unaligned_le16(&data[3]);
737 729 } else { /* with capacity */
738 switch (data[0]) { 730 prox = data[1] & 0x01;
731 x = le16_to_cpup((__le16 *)&data[2]);
732 y = le16_to_cpup((__le16 *)&data[4]);
733 }
734 } else
735 /* force touch out when pen is in prox */
736 prox = 0;
739 737
740 case WACOM_REPORT_TPC1FG: 738 if (prox) {
741 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); 739 input_report_abs(input, ABS_X, x);
742 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); 740 input_report_abs(input, ABS_Y, y);
743 input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6])); 741 }
744 input_report_key(input, BTN_TOUCH, le16_to_cpup((__le16 *)&data[6])); 742 input_report_key(input, BTN_TOUCH, prox);
745 input_report_abs(input, ABS_MISC, wacom->id[0]);
746 input_report_key(input, wacom->tool[1], 1);
747 input_sync(input);
748 break;
749 743
750 case WACOM_REPORT_TPC2FG: 744 /* keep touch state for pen events */
751 if (data[1] & 0x01) 745 wacom->shared->touch_down = prox;
752 wacom_tpc_finger_in(wacom, data, 0);
753 else if (wacom->id[1] & 0x01)
754 wacom_tpc_touch_out(wacom, 0);
755 746
756 if (data[1] & 0x02) 747 return 1;
757 wacom_tpc_finger_in(wacom, data, 1);
758 else if (wacom->id[1] & 0x02)
759 wacom_tpc_touch_out(wacom, 1);
760 break;
761 }
762 } else {
763 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
764 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
765 input_report_key(input, BTN_TOUCH, 1);
766 input_report_abs(input, ABS_MISC, wacom->id[1]);
767 input_report_key(input, wacom->tool[1], 1);
768 input_sync(input);
769 }
770} 748}
771 749
772static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len) 750static int wacom_tpc_pen(struct wacom_wac *wacom)
773{ 751{
774 struct wacom_features *features = &wacom->features; 752 struct wacom_features *features = &wacom->features;
775 char *data = wacom->data; 753 char *data = wacom->data;
776 struct input_dev *input = wacom->input; 754 struct input_dev *input = wacom->input;
777 int prox = 0, pressure; 755 int pressure;
778 int retval = 0; 756 bool prox = data[1] & 0x20;
779
780 dbg("wacom_tpc_irq: received report #%d", data[0]);
781
782 if (len == WACOM_PKGLEN_TPC1FG || /* single touch */
783 data[0] == WACOM_REPORT_TPC1FG || /* single touch */
784 data[0] == WACOM_REPORT_TPC2FG) { /* 2FG touch */
785
786 if (wacom->shared->stylus_in_proximity) {
787 if (wacom->id[1] & 0x01)
788 wacom_tpc_touch_out(wacom, 0);
789
790 if (wacom->id[1] & 0x02)
791 wacom_tpc_touch_out(wacom, 1);
792 757
793 wacom->id[1] = 0; 758 if (!wacom->shared->stylus_in_proximity) /* first in prox */
794 return 0; 759 /* Going into proximity select tool */
795 } 760 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
796
797 if (len == WACOM_PKGLEN_TPC1FG) { /* with touch */
798 prox = data[0] & 0x01;
799 } else { /* with capacity */
800 if (data[0] == WACOM_REPORT_TPC1FG)
801 /* single touch */
802 prox = data[1] & 0x01;
803 else
804 /* 2FG touch data */
805 prox = data[1] & 0x03;
806 }
807
808 if (prox) {
809 if (!wacom->id[1])
810 wacom->last_finger = 1;
811 wacom_tpc_touch_in(wacom, len);
812 } else {
813 if (data[0] == WACOM_REPORT_TPC2FG) {
814 /* 2FGT out-prox */
815 if (wacom->id[1] & 0x01)
816 wacom_tpc_touch_out(wacom, 0);
817 761
818 if (wacom->id[1] & 0x02) 762 /* keep pen state for touch events */
819 wacom_tpc_touch_out(wacom, 1); 763 wacom->shared->stylus_in_proximity = prox;
820 } else
821 /* one finger touch */
822 wacom_tpc_touch_out(wacom, 0);
823 764
824 wacom->id[0] = 0; 765 /* send pen events only when touch is up or forced out */
825 } 766 if (!wacom->shared->touch_down) {
826 /* keep prox bit to send proper out-prox event */
827 wacom->id[1] = prox;
828 } else if (data[0] == WACOM_REPORT_PENABLED) { /* Penabled */
829 prox = data[1] & 0x20;
830
831 if (!wacom->shared->stylus_in_proximity) { /* first in prox */
832 /* Going into proximity select tool */
833 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
834 if (wacom->tool[0] == BTN_TOOL_PEN)
835 wacom->id[0] = STYLUS_DEVICE_ID;
836 else
837 wacom->id[0] = ERASER_DEVICE_ID;
838
839 wacom->shared->stylus_in_proximity = true;
840 }
841 input_report_key(input, BTN_STYLUS, data[1] & 0x02); 767 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
842 input_report_key(input, BTN_STYLUS2, data[1] & 0x10); 768 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
843 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); 769 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
@@ -847,15 +773,27 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
847 pressure = features->pressure_max + pressure + 1; 773 pressure = features->pressure_max + pressure + 1;
848 input_report_abs(input, ABS_PRESSURE, pressure); 774 input_report_abs(input, ABS_PRESSURE, pressure);
849 input_report_key(input, BTN_TOUCH, data[1] & 0x05); 775 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
850 if (!prox) { /* out-prox */
851 wacom->id[0] = 0;
852 wacom->shared->stylus_in_proximity = false;
853 }
854 input_report_key(input, wacom->tool[0], prox); 776 input_report_key(input, wacom->tool[0], prox);
855 input_report_abs(input, ABS_MISC, wacom->id[0]); 777 return 1;
856 retval = 1;
857 } 778 }
858 return retval; 779
780 return 0;
781}
782
783static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
784{
785 char *data = wacom->data;
786
787 dbg("wacom_tpc_irq: received report #%d", data[0]);
788
789 if (len == WACOM_PKGLEN_TPC1FG || data[0] == WACOM_REPORT_TPC1FG)
790 return wacom_tpc_single_touch(wacom, len);
791 else if (data[0] == WACOM_REPORT_TPC2FG)
792 return wacom_tpc_mt_touch(wacom);
793 else if (data[0] == WACOM_REPORT_PENABLED)
794 return wacom_tpc_pen(wacom);
795
796 return 0;
859} 797}
860 798
861static int wacom_bpt_touch(struct wacom_wac *wacom) 799static int wacom_bpt_touch(struct wacom_wac *wacom)
@@ -1078,7 +1016,7 @@ void wacom_setup_device_quirks(struct wacom_features *features)
1078{ 1016{
1079 1017
1080 /* touch device found but size is not defined. use default */ 1018 /* touch device found but size is not defined. use default */
1081 if (features->device_type == BTN_TOOL_DOUBLETAP && !features->x_max) { 1019 if (features->device_type == BTN_TOOL_FINGER && !features->x_max) {
1082 features->x_max = 1023; 1020 features->x_max = 1023;
1083 features->y_max = 1023; 1021 features->y_max = 1023;
1084 } 1022 }
@@ -1090,7 +1028,7 @@ void wacom_setup_device_quirks(struct wacom_features *features)
1090 1028
1091 /* quirks for bamboo touch */ 1029 /* quirks for bamboo touch */
1092 if (features->type == BAMBOO_PT && 1030 if (features->type == BAMBOO_PT &&
1093 features->device_type == BTN_TOOL_TRIPLETAP) { 1031 features->device_type == BTN_TOOL_DOUBLETAP) {
1094 features->x_max <<= 5; 1032 features->x_max <<= 5;
1095 features->y_max <<= 5; 1033 features->y_max <<= 5;
1096 features->x_fuzz <<= 5; 1034 features->x_fuzz <<= 5;
@@ -1125,6 +1063,19 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
1125 input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max, 1063 input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max,
1126 features->pressure_fuzz, 0); 1064 features->pressure_fuzz, 0);
1127 1065
1066 if (features->device_type == BTN_TOOL_PEN) {
1067 /* penabled devices have fixed resolution for each model */
1068 input_abs_set_res(input_dev, ABS_X, features->x_resolution);
1069 input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
1070 } else {
1071 input_abs_set_res(input_dev, ABS_X,
1072 wacom_calculate_touch_res(features->x_max,
1073 features->x_phy));
1074 input_abs_set_res(input_dev, ABS_Y,
1075 wacom_calculate_touch_res(features->y_max,
1076 features->y_phy));
1077 }
1078
1128 __set_bit(ABS_MISC, input_dev->absbit); 1079 __set_bit(ABS_MISC, input_dev->absbit);
1129 1080
1130 switch (wacom_wac->features.type) { 1081 switch (wacom_wac->features.type) {
@@ -1226,23 +1177,20 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
1226 break; 1177 break;
1227 1178
1228 case TABLETPC2FG: 1179 case TABLETPC2FG:
1229 if (features->device_type == BTN_TOOL_TRIPLETAP) { 1180 if (features->device_type == BTN_TOOL_DOUBLETAP) {
1230 __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); 1181
1231 input_set_capability(input_dev, EV_MSC, MSC_SERIAL); 1182 input_mt_init_slots(input_dev, 2);
1183 input_set_abs_params(input_dev, ABS_MT_TOOL_TYPE,
1184 0, MT_TOOL_MAX, 0, 0);
1185 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1186 0, features->x_max, 0, 0);
1187 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1188 0, features->y_max, 0, 0);
1232 } 1189 }
1233 /* fall through */ 1190 /* fall through */
1234 1191
1235 case TABLETPC: 1192 case TABLETPC:
1236 if (features->device_type == BTN_TOOL_DOUBLETAP || 1193 __clear_bit(ABS_MISC, input_dev->absbit);
1237 features->device_type == BTN_TOOL_TRIPLETAP) {
1238 input_abs_set_res(input_dev, ABS_X,
1239 wacom_calculate_touch_res(features->x_max,
1240 features->x_phy));
1241 input_abs_set_res(input_dev, ABS_Y,
1242 wacom_calculate_touch_res(features->y_max,
1243 features->y_phy));
1244 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
1245 }
1246 1194
1247 if (features->device_type != BTN_TOOL_PEN) 1195 if (features->device_type != BTN_TOOL_PEN)
1248 break; /* no need to process stylus stuff */ 1196 break; /* no need to process stylus stuff */
@@ -1264,7 +1212,7 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
1264 case BAMBOO_PT: 1212 case BAMBOO_PT:
1265 __clear_bit(ABS_MISC, input_dev->absbit); 1213 __clear_bit(ABS_MISC, input_dev->absbit);
1266 1214
1267 if (features->device_type == BTN_TOOL_TRIPLETAP) { 1215 if (features->device_type == BTN_TOOL_DOUBLETAP) {
1268 __set_bit(BTN_LEFT, input_dev->keybit); 1216 __set_bit(BTN_LEFT, input_dev->keybit);
1269 __set_bit(BTN_FORWARD, input_dev->keybit); 1217 __set_bit(BTN_FORWARD, input_dev->keybit);
1270 __set_bit(BTN_BACK, input_dev->keybit); 1218 __set_bit(BTN_BACK, input_dev->keybit);
@@ -1283,12 +1231,6 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
1283 input_set_abs_params(input_dev, ABS_MT_PRESSURE, 1231 input_set_abs_params(input_dev, ABS_MT_PRESSURE,
1284 0, features->pressure_max, 1232 0, features->pressure_max,
1285 features->pressure_fuzz, 0); 1233 features->pressure_fuzz, 0);
1286 input_abs_set_res(input_dev, ABS_X,
1287 wacom_calculate_touch_res(features->x_max,
1288 features->x_phy));
1289 input_abs_set_res(input_dev, ABS_Y,
1290 wacom_calculate_touch_res(features->y_max,
1291 features->y_phy));
1292 } else if (features->device_type == BTN_TOOL_PEN) { 1234 } else if (features->device_type == BTN_TOOL_PEN) {
1293 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); 1235 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1294 __set_bit(BTN_TOOL_PEN, input_dev->keybit); 1236 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
@@ -1300,161 +1242,242 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
1300} 1242}
1301 1243
1302static const struct wacom_features wacom_features_0x00 = 1244static const struct wacom_features wacom_features_0x00 =
1303 { "Wacom Penpartner", WACOM_PKGLEN_PENPRTN, 5040, 3780, 255, 0, PENPARTNER }; 1245 { "Wacom Penpartner", WACOM_PKGLEN_PENPRTN, 5040, 3780, 255,
1246 0, PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
1304static const struct wacom_features wacom_features_0x10 = 1247static const struct wacom_features wacom_features_0x10 =
1305 { "Wacom Graphire", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE }; 1248 { "Wacom Graphire", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511,
1249 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
1306static const struct wacom_features wacom_features_0x11 = 1250static const struct wacom_features wacom_features_0x11 =
1307 { "Wacom Graphire2 4x5", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE }; 1251 { "Wacom Graphire2 4x5", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511,
1252 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
1308static const struct wacom_features wacom_features_0x12 = 1253static const struct wacom_features wacom_features_0x12 =
1309 { "Wacom Graphire2 5x7", WACOM_PKGLEN_GRAPHIRE, 13918, 10206, 511, 63, GRAPHIRE }; 1254 { "Wacom Graphire2 5x7", WACOM_PKGLEN_GRAPHIRE, 13918, 10206, 511,
1255 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
1310static const struct wacom_features wacom_features_0x13 = 1256static const struct wacom_features wacom_features_0x13 =
1311 { "Wacom Graphire3", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, GRAPHIRE }; 1257 { "Wacom Graphire3", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511,
1258 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
1312static const struct wacom_features wacom_features_0x14 = 1259static const struct wacom_features wacom_features_0x14 =
1313 { "Wacom Graphire3 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE }; 1260 { "Wacom Graphire3 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
1261 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
1314static const struct wacom_features wacom_features_0x15 = 1262static const struct wacom_features wacom_features_0x15 =
1315 { "Wacom Graphire4 4x5", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, WACOM_G4 }; 1263 { "Wacom Graphire4 4x5", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511,
1264 63, WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
1316static const struct wacom_features wacom_features_0x16 = 1265static const struct wacom_features wacom_features_0x16 =
1317 { "Wacom Graphire4 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, WACOM_G4 }; 1266 { "Wacom Graphire4 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
1267 63, WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
1318static const struct wacom_features wacom_features_0x17 = 1268static const struct wacom_features wacom_features_0x17 =
1319 { "Wacom BambooFun 4x5", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO }; 1269 { "Wacom BambooFun 4x5", WACOM_PKGLEN_BBFUN, 14760, 9225, 511,
1270 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1320static const struct wacom_features wacom_features_0x18 = 1271static const struct wacom_features wacom_features_0x18 =
1321 { "Wacom BambooFun 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 511, 63, WACOM_MO }; 1272 { "Wacom BambooFun 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 511,
1273 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1322static const struct wacom_features wacom_features_0x19 = 1274static const struct wacom_features wacom_features_0x19 =
1323 { "Wacom Bamboo1 Medium", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE }; 1275 { "Wacom Bamboo1 Medium", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
1276 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
1324static const struct wacom_features wacom_features_0x60 = 1277static const struct wacom_features wacom_features_0x60 =
1325 { "Wacom Volito", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE }; 1278 { "Wacom Volito", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
1279 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
1326static const struct wacom_features wacom_features_0x61 = 1280static const struct wacom_features wacom_features_0x61 =
1327 { "Wacom PenStation2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 255, 63, GRAPHIRE }; 1281 { "Wacom PenStation2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 255,
1282 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
1328static const struct wacom_features wacom_features_0x62 = 1283static const struct wacom_features wacom_features_0x62 =
1329 { "Wacom Volito2 4x5", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE }; 1284 { "Wacom Volito2 4x5", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
1285 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
1330static const struct wacom_features wacom_features_0x63 = 1286static const struct wacom_features wacom_features_0x63 =
1331 { "Wacom Volito2 2x3", WACOM_PKGLEN_GRAPHIRE, 3248, 2320, 511, 63, GRAPHIRE }; 1287 { "Wacom Volito2 2x3", WACOM_PKGLEN_GRAPHIRE, 3248, 2320, 511,
1288 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
1332static const struct wacom_features wacom_features_0x64 = 1289static const struct wacom_features wacom_features_0x64 =
1333 { "Wacom PenPartner2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 511, 63, GRAPHIRE }; 1290 { "Wacom PenPartner2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 511,
1291 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
1334static const struct wacom_features wacom_features_0x65 = 1292static const struct wacom_features wacom_features_0x65 =
1335 { "Wacom Bamboo", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO }; 1293 { "Wacom Bamboo", WACOM_PKGLEN_BBFUN, 14760, 9225, 511,
1294 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1336static const struct wacom_features wacom_features_0x69 = 1295static const struct wacom_features wacom_features_0x69 =
1337 { "Wacom Bamboo1", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE }; 1296 { "Wacom Bamboo1", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
1297 63, GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
1338static const struct wacom_features wacom_features_0x20 = 1298static const struct wacom_features wacom_features_0x20 =
1339 { "Wacom Intuos 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS }; 1299 { "Wacom Intuos 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023,
1300 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1340static const struct wacom_features wacom_features_0x21 = 1301static const struct wacom_features wacom_features_0x21 =
1341 { "Wacom Intuos 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS }; 1302 { "Wacom Intuos 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
1303 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1342static const struct wacom_features wacom_features_0x22 = 1304static const struct wacom_features wacom_features_0x22 =
1343 { "Wacom Intuos 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS }; 1305 { "Wacom Intuos 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023,
1306 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1344static const struct wacom_features wacom_features_0x23 = 1307static const struct wacom_features wacom_features_0x23 =
1345 { "Wacom Intuos 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS }; 1308 { "Wacom Intuos 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023,
1309 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1346static const struct wacom_features wacom_features_0x24 = 1310static const struct wacom_features wacom_features_0x24 =
1347 { "Wacom Intuos 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS }; 1311 { "Wacom Intuos 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023,
1312 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1348static const struct wacom_features wacom_features_0x30 = 1313static const struct wacom_features wacom_features_0x30 =
1349 { "Wacom PL400", WACOM_PKGLEN_GRAPHIRE, 5408, 4056, 255, 0, PL }; 1314 { "Wacom PL400", WACOM_PKGLEN_GRAPHIRE, 5408, 4056, 255,
1315 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1350static const struct wacom_features wacom_features_0x31 = 1316static const struct wacom_features wacom_features_0x31 =
1351 { "Wacom PL500", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 255, 0, PL }; 1317 { "Wacom PL500", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 255,
1318 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1352static const struct wacom_features wacom_features_0x32 = 1319static const struct wacom_features wacom_features_0x32 =
1353 { "Wacom PL600", WACOM_PKGLEN_GRAPHIRE, 6126, 4604, 255, 0, PL }; 1320 { "Wacom PL600", WACOM_PKGLEN_GRAPHIRE, 6126, 4604, 255,
1321 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1354static const struct wacom_features wacom_features_0x33 = 1322static const struct wacom_features wacom_features_0x33 =
1355 { "Wacom PL600SX", WACOM_PKGLEN_GRAPHIRE, 6260, 5016, 255, 0, PL }; 1323 { "Wacom PL600SX", WACOM_PKGLEN_GRAPHIRE, 6260, 5016, 255,
1324 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1356static const struct wacom_features wacom_features_0x34 = 1325static const struct wacom_features wacom_features_0x34 =
1357 { "Wacom PL550", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 511, 0, PL }; 1326 { "Wacom PL550", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 511,
1327 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1358static const struct wacom_features wacom_features_0x35 = 1328static const struct wacom_features wacom_features_0x35 =
1359 { "Wacom PL800", WACOM_PKGLEN_GRAPHIRE, 7220, 5780, 511, 0, PL }; 1329 { "Wacom PL800", WACOM_PKGLEN_GRAPHIRE, 7220, 5780, 511,
1330 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1360static const struct wacom_features wacom_features_0x37 = 1331static const struct wacom_features wacom_features_0x37 =
1361 { "Wacom PL700", WACOM_PKGLEN_GRAPHIRE, 6758, 5406, 511, 0, PL }; 1332 { "Wacom PL700", WACOM_PKGLEN_GRAPHIRE, 6758, 5406, 511,
1333 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1362static const struct wacom_features wacom_features_0x38 = 1334static const struct wacom_features wacom_features_0x38 =
1363 { "Wacom PL510", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL }; 1335 { "Wacom PL510", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511,
1336 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1364static const struct wacom_features wacom_features_0x39 = 1337static const struct wacom_features wacom_features_0x39 =
1365 { "Wacom DTU710", WACOM_PKGLEN_GRAPHIRE, 34080, 27660, 511, 0, PL }; 1338 { "Wacom DTU710", WACOM_PKGLEN_GRAPHIRE, 34080, 27660, 511,
1339 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1366static const struct wacom_features wacom_features_0xC4 = 1340static const struct wacom_features wacom_features_0xC4 =
1367 { "Wacom DTF521", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL }; 1341 { "Wacom DTF521", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511,
1342 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1368static const struct wacom_features wacom_features_0xC0 = 1343static const struct wacom_features wacom_features_0xC0 =
1369 { "Wacom DTF720", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL }; 1344 { "Wacom DTF720", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511,
1345 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1370static const struct wacom_features wacom_features_0xC2 = 1346static const struct wacom_features wacom_features_0xC2 =
1371 { "Wacom DTF720a", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL }; 1347 { "Wacom DTF720a", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511,
1348 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1372static const struct wacom_features wacom_features_0x03 = 1349static const struct wacom_features wacom_features_0x03 =
1373 { "Wacom Cintiq Partner", WACOM_PKGLEN_GRAPHIRE, 20480, 15360, 511, 0, PTU }; 1350 { "Wacom Cintiq Partner", WACOM_PKGLEN_GRAPHIRE, 20480, 15360, 511,
1351 0, PTU, WACOM_PL_RES, WACOM_PL_RES };
1374static const struct wacom_features wacom_features_0x41 = 1352static const struct wacom_features wacom_features_0x41 =
1375 { "Wacom Intuos2 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS }; 1353 { "Wacom Intuos2 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023,
1354 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1376static const struct wacom_features wacom_features_0x42 = 1355static const struct wacom_features wacom_features_0x42 =
1377 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS }; 1356 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
1357 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1378static const struct wacom_features wacom_features_0x43 = 1358static const struct wacom_features wacom_features_0x43 =
1379 { "Wacom Intuos2 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS }; 1359 { "Wacom Intuos2 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023,
1360 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1380static const struct wacom_features wacom_features_0x44 = 1361static const struct wacom_features wacom_features_0x44 =
1381 { "Wacom Intuos2 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS }; 1362 { "Wacom Intuos2 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023,
1363 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1382static const struct wacom_features wacom_features_0x45 = 1364static const struct wacom_features wacom_features_0x45 =
1383 { "Wacom Intuos2 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS }; 1365 { "Wacom Intuos2 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023,
1366 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1384static const struct wacom_features wacom_features_0xB0 = 1367static const struct wacom_features wacom_features_0xB0 =
1385 { "Wacom Intuos3 4x5", WACOM_PKGLEN_INTUOS, 25400, 20320, 1023, 63, INTUOS3S }; 1368 { "Wacom Intuos3 4x5", WACOM_PKGLEN_INTUOS, 25400, 20320, 1023,
1369 63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1386static const struct wacom_features wacom_features_0xB1 = 1370static const struct wacom_features wacom_features_0xB1 =
1387 { "Wacom Intuos3 6x8", WACOM_PKGLEN_INTUOS, 40640, 30480, 1023, 63, INTUOS3 }; 1371 { "Wacom Intuos3 6x8", WACOM_PKGLEN_INTUOS, 40640, 30480, 1023,
1372 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1388static const struct wacom_features wacom_features_0xB2 = 1373static const struct wacom_features wacom_features_0xB2 =
1389 { "Wacom Intuos3 9x12", WACOM_PKGLEN_INTUOS, 60960, 45720, 1023, 63, INTUOS3 }; 1374 { "Wacom Intuos3 9x12", WACOM_PKGLEN_INTUOS, 60960, 45720, 1023,
1375 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1390static const struct wacom_features wacom_features_0xB3 = 1376static const struct wacom_features wacom_features_0xB3 =
1391 { "Wacom Intuos3 12x12", WACOM_PKGLEN_INTUOS, 60960, 60960, 1023, 63, INTUOS3L }; 1377 { "Wacom Intuos3 12x12", WACOM_PKGLEN_INTUOS, 60960, 60960, 1023,
1378 63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1392static const struct wacom_features wacom_features_0xB4 = 1379static const struct wacom_features wacom_features_0xB4 =
1393 { "Wacom Intuos3 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 1023, 63, INTUOS3L }; 1380 { "Wacom Intuos3 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 1023,
1381 63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1394static const struct wacom_features wacom_features_0xB5 = 1382static const struct wacom_features wacom_features_0xB5 =
1395 { "Wacom Intuos3 6x11", WACOM_PKGLEN_INTUOS, 54204, 31750, 1023, 63, INTUOS3 }; 1383 { "Wacom Intuos3 6x11", WACOM_PKGLEN_INTUOS, 54204, 31750, 1023,
1384 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1396static const struct wacom_features wacom_features_0xB7 = 1385static const struct wacom_features wacom_features_0xB7 =
1397 { "Wacom Intuos3 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 1023, 63, INTUOS3S }; 1386 { "Wacom Intuos3 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 1023,
1387 63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1398static const struct wacom_features wacom_features_0xB8 = 1388static const struct wacom_features wacom_features_0xB8 =
1399 { "Wacom Intuos4 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047, 63, INTUOS4S }; 1389 { "Wacom Intuos4 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
1390 63, INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1400static const struct wacom_features wacom_features_0xB9 = 1391static const struct wacom_features wacom_features_0xB9 =
1401 { "Wacom Intuos4 6x9", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047, 63, INTUOS4 }; 1392 { "Wacom Intuos4 6x9", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
1393 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1402static const struct wacom_features wacom_features_0xBA = 1394static const struct wacom_features wacom_features_0xBA =
1403 { "Wacom Intuos4 8x13", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047, 63, INTUOS4L }; 1395 { "Wacom Intuos4 8x13", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047,
1396 63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1404static const struct wacom_features wacom_features_0xBB = 1397static const struct wacom_features wacom_features_0xBB =
1405 { "Wacom Intuos4 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 2047, 63, INTUOS4L }; 1398 { "Wacom Intuos4 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 2047,
1399 63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1406static const struct wacom_features wacom_features_0xBC = 1400static const struct wacom_features wacom_features_0xBC =
1407 { "Wacom Intuos4 WL", WACOM_PKGLEN_INTUOS, 40840, 25400, 2047, 63, INTUOS4 }; 1401 { "Wacom Intuos4 WL", WACOM_PKGLEN_INTUOS, 40840, 25400, 2047,
1402 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1408static const struct wacom_features wacom_features_0x3F = 1403static const struct wacom_features wacom_features_0x3F =
1409 { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023, 63, CINTIQ }; 1404 { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023,
1405 63, CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1410static const struct wacom_features wacom_features_0xC5 = 1406static const struct wacom_features wacom_features_0xC5 =
1411 { "Wacom Cintiq 20WSX", WACOM_PKGLEN_INTUOS, 86680, 54180, 1023, 63, WACOM_BEE }; 1407 { "Wacom Cintiq 20WSX", WACOM_PKGLEN_INTUOS, 86680, 54180, 1023,
1408 63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1412static const struct wacom_features wacom_features_0xC6 = 1409static const struct wacom_features wacom_features_0xC6 =
1413 { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023, 63, WACOM_BEE }; 1410 { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023,
1411 63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1414static const struct wacom_features wacom_features_0xC7 = 1412static const struct wacom_features wacom_features_0xC7 =
1415 { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511, 0, PL }; 1413 { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511,
1414 0, PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1416static const struct wacom_features wacom_features_0xCE = 1415static const struct wacom_features wacom_features_0xCE =
1417 { "Wacom DTU2231", WACOM_PKGLEN_GRAPHIRE, 47864, 27011, 511, 0, DTU }; 1416 { "Wacom DTU2231", WACOM_PKGLEN_GRAPHIRE, 47864, 27011, 511,
1417 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1418static const struct wacom_features wacom_features_0xF0 = 1418static const struct wacom_features wacom_features_0xF0 =
1419 { "Wacom DTU1631", WACOM_PKGLEN_GRAPHIRE, 34623, 19553, 511, 0, DTU }; 1419 { "Wacom DTU1631", WACOM_PKGLEN_GRAPHIRE, 34623, 19553, 511,
1420 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1420static const struct wacom_features wacom_features_0xCC = 1421static const struct wacom_features wacom_features_0xCC =
1421 { "Wacom Cintiq 21UX2", WACOM_PKGLEN_INTUOS, 87200, 65600, 2047, 63, WACOM_21UX2 }; 1422 { "Wacom Cintiq 21UX2", WACOM_PKGLEN_INTUOS, 87200, 65600, 2047,
1423 63, WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1422static const struct wacom_features wacom_features_0x90 = 1424static const struct wacom_features wacom_features_0x90 =
1423 { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC }; 1425 { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1426 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1424static const struct wacom_features wacom_features_0x93 = 1427static const struct wacom_features wacom_features_0x93 =
1425 { "Wacom ISDv4 93", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC }; 1428 { "Wacom ISDv4 93", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1429 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1426static const struct wacom_features wacom_features_0x9A = 1430static const struct wacom_features wacom_features_0x9A =
1427 { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC }; 1431 { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1432 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1428static const struct wacom_features wacom_features_0x9F = 1433static const struct wacom_features wacom_features_0x9F =
1429 { "Wacom ISDv4 9F", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC }; 1434 { "Wacom ISDv4 9F", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1435 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1430static const struct wacom_features wacom_features_0xE2 = 1436static const struct wacom_features wacom_features_0xE2 =
1431 { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG }; 1437 { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255,
1438 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1432static const struct wacom_features wacom_features_0xE3 = 1439static const struct wacom_features wacom_features_0xE3 =
1433 { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG }; 1440 { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255,
1441 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1442static const struct wacom_features wacom_features_0xE6 =
1443 { "Wacom ISDv4 E6", WACOM_PKGLEN_TPC2FG, 27760, 15694, 255,
1444 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1434static const struct wacom_features wacom_features_0x47 = 1445static const struct wacom_features wacom_features_0x47 =
1435 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS }; 1446 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
1436static struct wacom_features wacom_features_0xD0 = 1447 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1437 { "Wacom Bamboo 2FG", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT }; 1448static const struct wacom_features wacom_features_0xD0 =
1438static struct wacom_features wacom_features_0xD1 = 1449 { "Wacom Bamboo 2FG", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
1439 { "Wacom Bamboo 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT }; 1450 63, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1440static struct wacom_features wacom_features_0xD2 = 1451static const struct wacom_features wacom_features_0xD1 =
1441 { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT }; 1452 { "Wacom Bamboo 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
1442static struct wacom_features wacom_features_0xD3 = 1453 63, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1443 { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT }; 1454static const struct wacom_features wacom_features_0xD2 =
1455 { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
1456 63, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1457static const struct wacom_features wacom_features_0xD3 =
1458 { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023,
1459 63, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1444static const struct wacom_features wacom_features_0xD4 = 1460static const struct wacom_features wacom_features_0xD4 =
1445 { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 255, 63, BAMBOO_PT }; 1461 { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 255,
1446static struct wacom_features wacom_features_0xD6 = 1462 63, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1447 { "Wacom BambooPT 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT }; 1463static const struct wacom_features wacom_features_0xD6 =
1448static struct wacom_features wacom_features_0xD7 = 1464 { "Wacom BambooPT 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
1449 { "Wacom BambooPT 2FG Small", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT }; 1465 63, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1450static struct wacom_features wacom_features_0xD8 = 1466static const struct wacom_features wacom_features_0xD7 =
1451 { "Wacom Bamboo Comic 2FG", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT }; 1467 { "Wacom BambooPT 2FG Small", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
1452static struct wacom_features wacom_features_0xDA = 1468 63, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1453 { "Wacom Bamboo 2FG 4x5 SE", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT }; 1469static const struct wacom_features wacom_features_0xD8 =
1470 { "Wacom Bamboo Comic 2FG", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023,
1471 63, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1472static const struct wacom_features wacom_features_0xDA =
1473 { "Wacom Bamboo 2FG 4x5 SE", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
1474 63, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1454static struct wacom_features wacom_features_0xDB = 1475static struct wacom_features wacom_features_0xDB =
1455 { "Wacom Bamboo 2FG 6x8 SE", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT }; 1476 { "Wacom Bamboo 2FG 6x8 SE", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023,
1477 63, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1456static const struct wacom_features wacom_features_0x6004 = 1478static const struct wacom_features wacom_features_0x6004 =
1457 { "ISD-V4", WACOM_PKGLEN_GRAPHIRE, 12800, 8000, 255, 0, TABLETPC }; 1479 { "ISD-V4", WACOM_PKGLEN_GRAPHIRE, 12800, 8000, 255,
1480 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1458 1481
1459#define USB_DEVICE_WACOM(prod) \ 1482#define USB_DEVICE_WACOM(prod) \
1460 USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \ 1483 USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \
@@ -1541,6 +1564,7 @@ const struct usb_device_id wacom_ids[] = {
1541 { USB_DEVICE_WACOM(0x9F) }, 1564 { USB_DEVICE_WACOM(0x9F) },
1542 { USB_DEVICE_WACOM(0xE2) }, 1565 { USB_DEVICE_WACOM(0xE2) },
1543 { USB_DEVICE_WACOM(0xE3) }, 1566 { USB_DEVICE_WACOM(0xE3) },
1567 { USB_DEVICE_WACOM(0xE6) },
1544 { USB_DEVICE_WACOM(0x47) }, 1568 { USB_DEVICE_WACOM(0x47) },
1545 { USB_DEVICE_LENOVO(0x6004) }, 1569 { USB_DEVICE_LENOVO(0x6004) },
1546 { } 1570 { }
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index b1310ec9720c..53eb71b68330 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -74,6 +74,8 @@ struct wacom_features {
74 int pressure_max; 74 int pressure_max;
75 int distance_max; 75 int distance_max;
76 int type; 76 int type;
77 int x_resolution;
78 int y_resolution;
77 int device_type; 79 int device_type;
78 int x_phy; 80 int x_phy;
79 int y_phy; 81 int y_phy;
@@ -88,15 +90,15 @@ struct wacom_features {
88 90
89struct wacom_shared { 91struct wacom_shared {
90 bool stylus_in_proximity; 92 bool stylus_in_proximity;
93 bool touch_down;
91}; 94};
92 95
93struct wacom_wac { 96struct wacom_wac {
94 char name[64]; 97 char name[64];
95 unsigned char *data; 98 unsigned char *data;
96 int tool[3]; 99 int tool[2];
97 int id[3]; 100 int id[2];
98 __u32 serial[2]; 101 __u32 serial[2];
99 int last_finger;
100 struct wacom_features features; 102 struct wacom_features features;
101 struct wacom_shared *shared; 103 struct wacom_shared *shared;
102 struct input_dev *input; 104 struct input_dev *input;
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 61834ae282e1..434fd800cd24 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -86,6 +86,18 @@ config TOUCHSCREEN_AD7879_SPI
86 To compile this driver as a module, choose M here: the 86 To compile this driver as a module, choose M here: the
87 module will be called ad7879-spi. 87 module will be called ad7879-spi.
88 88
89config TOUCHSCREEN_ATMEL_MXT
90 tristate "Atmel mXT I2C Touchscreen"
91 depends on I2C
92 help
93 Say Y here if you have Atmel mXT series I2C touchscreen,
94 such as AT42QT602240/ATMXT224, connected to your system.
95
96 If unsure, say N.
97
98 To compile this driver as a module, choose M here: the
99 module will be called atmel_mxt_ts.
100
89config TOUCHSCREEN_BITSY 101config TOUCHSCREEN_BITSY
90 tristate "Compaq iPAQ H3600 (Bitsy) touchscreen" 102 tristate "Compaq iPAQ H3600 (Bitsy) touchscreen"
91 depends on SA1100_BITSY 103 depends on SA1100_BITSY
@@ -339,18 +351,6 @@ config TOUCHSCREEN_PENMOUNT
339 To compile this driver as a module, choose M here: the 351 To compile this driver as a module, choose M here: the
340 module will be called penmount. 352 module will be called penmount.
341 353
342config TOUCHSCREEN_QT602240
343 tristate "QT602240 I2C Touchscreen"
344 depends on I2C
345 help
346 Say Y here if you have the AT42QT602240/ATMXT224 I2C touchscreen
347 connected to your system.
348
349 If unsure, say N.
350
351 To compile this driver as a module, choose M here: the
352 module will be called qt602240_ts.
353
354config TOUCHSCREEN_MIGOR 354config TOUCHSCREEN_MIGOR
355 tristate "Renesas MIGO-R touchscreen" 355 tristate "Renesas MIGO-R touchscreen"
356 depends on SH_MIGOR && I2C 356 depends on SH_MIGOR && I2C
@@ -423,6 +423,16 @@ config TOUCHSCREEN_UCB1400
423 To compile this driver as a module, choose M here: the 423 To compile this driver as a module, choose M here: the
424 module will be called ucb1400_ts. 424 module will be called ucb1400_ts.
425 425
426config TOUCHSCREEN_WM831X
427 tristate "Support for WM831x touchscreen controllers"
428 depends on MFD_WM831X
429 help
430 This enables support for the touchscreen controller on the WM831x
431 series of PMICs.
432
433 To compile this driver as a module, choose M here: the
434 module will be called wm831x-ts.
435
426config TOUCHSCREEN_WM97XX 436config TOUCHSCREEN_WM97XX
427 tristate "Support for WM97xx AC97 touchscreen controllers" 437 tristate "Support for WM97xx AC97 touchscreen controllers"
428 depends on AC97_BUS 438 depends on AC97_BUS
@@ -629,6 +639,17 @@ config TOUCHSCREEN_TOUCHIT213
629 To compile this driver as a module, choose M here: the 639 To compile this driver as a module, choose M here: the
630 module will be called touchit213. 640 module will be called touchit213.
631 641
642config TOUCHSCREEN_TSC2005
643 tristate "TSC2005 based touchscreens"
644 depends on SPI_MASTER && GENERIC_HARDIRQS
645 help
646 Say Y here if you have a TSC2005 based touchscreen.
647
648 If unsure, say N.
649
650 To compile this driver as a module, choose M here: the
651 module will be called tsc2005.
652
632config TOUCHSCREEN_TSC2007 653config TOUCHSCREEN_TSC2007
633 tristate "TSC2007 based touchscreens" 654 tristate "TSC2007 based touchscreens"
634 depends on I2C 655 depends on I2C
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 718bcc814952..ca94098d4c92 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_TOUCHSCREEN_AD7879) += ad7879.o
12obj-$(CONFIG_TOUCHSCREEN_AD7879_I2C) += ad7879-i2c.o 12obj-$(CONFIG_TOUCHSCREEN_AD7879_I2C) += ad7879-i2c.o
13obj-$(CONFIG_TOUCHSCREEN_AD7879_SPI) += ad7879-spi.o 13obj-$(CONFIG_TOUCHSCREEN_AD7879_SPI) += ad7879-spi.o
14obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o 14obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o
15obj-$(CONFIG_TOUCHSCREEN_ATMEL_MXT) += atmel_mxt_ts.o
15obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o 16obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o
16obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o 17obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o
17obj-$(CONFIG_TOUCHSCREEN_BU21013) += bu21013_ts.o 18obj-$(CONFIG_TOUCHSCREEN_BU21013) += bu21013_ts.o
@@ -37,7 +38,6 @@ obj-$(CONFIG_TOUCHSCREEN_HTCPEN) += htcpen.o
37obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE) += usbtouchscreen.o 38obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE) += usbtouchscreen.o
38obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o 39obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
39obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o 40obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
40obj-$(CONFIG_TOUCHSCREEN_QT602240) += qt602240_ts.o
41obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o 41obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o
42obj-$(CONFIG_TOUCHSCREEN_ST1232) += st1232.o 42obj-$(CONFIG_TOUCHSCREEN_ST1232) += st1232.o
43obj-$(CONFIG_TOUCHSCREEN_STMPE) += stmpe-ts.o 43obj-$(CONFIG_TOUCHSCREEN_STMPE) += stmpe-ts.o
@@ -45,9 +45,11 @@ obj-$(CONFIG_TOUCHSCREEN_TNETV107X) += tnetv107x-ts.o
45obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o 45obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o
46obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o 46obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o
47obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o 47obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o
48obj-$(CONFIG_TOUCHSCREEN_TSC2005) += tsc2005.o
48obj-$(CONFIG_TOUCHSCREEN_TSC2007) += tsc2007.o 49obj-$(CONFIG_TOUCHSCREEN_TSC2007) += tsc2007.o
49obj-$(CONFIG_TOUCHSCREEN_UCB1400) += ucb1400_ts.o 50obj-$(CONFIG_TOUCHSCREEN_UCB1400) += ucb1400_ts.o
50obj-$(CONFIG_TOUCHSCREEN_WACOM_W8001) += wacom_w8001.o 51obj-$(CONFIG_TOUCHSCREEN_WACOM_W8001) += wacom_w8001.o
52obj-$(CONFIG_TOUCHSCREEN_WM831X) += wm831x-ts.o
51obj-$(CONFIG_TOUCHSCREEN_WM97XX) += wm97xx-ts.o 53obj-$(CONFIG_TOUCHSCREEN_WM97XX) += wm97xx-ts.o
52wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9705) += wm9705.o 54wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9705) += wm9705.o
53wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712) += wm9712.o 55wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712) += wm9712.o
diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c
index a1952fcc083e..714d4e0f9f95 100644
--- a/drivers/input/touchscreen/ad7877.c
+++ b/drivers/input/touchscreen/ad7877.c
@@ -41,6 +41,7 @@
41#include <linux/delay.h> 41#include <linux/delay.h>
42#include <linux/input.h> 42#include <linux/input.h>
43#include <linux/interrupt.h> 43#include <linux/interrupt.h>
44#include <linux/pm.h>
44#include <linux/slab.h> 45#include <linux/slab.h>
45#include <linux/spi/spi.h> 46#include <linux/spi/spi.h>
46#include <linux/spi/ad7877.h> 47#include <linux/spi/ad7877.h>
@@ -826,39 +827,37 @@ static int __devexit ad7877_remove(struct spi_device *spi)
826 return 0; 827 return 0;
827} 828}
828 829
829#ifdef CONFIG_PM 830#ifdef CONFIG_PM_SLEEP
830static int ad7877_suspend(struct spi_device *spi, pm_message_t message) 831static int ad7877_suspend(struct device *dev)
831{ 832{
832 struct ad7877 *ts = dev_get_drvdata(&spi->dev); 833 struct ad7877 *ts = dev_get_drvdata(dev);
833 834
834 ad7877_disable(ts); 835 ad7877_disable(ts);
835 836
836 return 0; 837 return 0;
837} 838}
838 839
839static int ad7877_resume(struct spi_device *spi) 840static int ad7877_resume(struct device *dev)
840{ 841{
841 struct ad7877 *ts = dev_get_drvdata(&spi->dev); 842 struct ad7877 *ts = dev_get_drvdata(dev);
842 843
843 ad7877_enable(ts); 844 ad7877_enable(ts);
844 845
845 return 0; 846 return 0;
846} 847}
847#else
848#define ad7877_suspend NULL
849#define ad7877_resume NULL
850#endif 848#endif
851 849
850static SIMPLE_DEV_PM_OPS(ad7877_pm, ad7877_suspend, ad7877_resume);
851
852static struct spi_driver ad7877_driver = { 852static struct spi_driver ad7877_driver = {
853 .driver = { 853 .driver = {
854 .name = "ad7877", 854 .name = "ad7877",
855 .bus = &spi_bus_type, 855 .bus = &spi_bus_type,
856 .owner = THIS_MODULE, 856 .owner = THIS_MODULE,
857 .pm = &ad7877_pm,
857 }, 858 },
858 .probe = ad7877_probe, 859 .probe = ad7877_probe,
859 .remove = __devexit_p(ad7877_remove), 860 .remove = __devexit_p(ad7877_remove),
860 .suspend = ad7877_suspend,
861 .resume = ad7877_resume,
862}; 861};
863 862
864static int __init ad7877_init(void) 863static int __init ad7877_init(void)
diff --git a/drivers/input/touchscreen/ad7879-spi.c b/drivers/input/touchscreen/ad7879-spi.c
index 59c6e68c4325..ddf732f3cafc 100644
--- a/drivers/input/touchscreen/ad7879-spi.c
+++ b/drivers/input/touchscreen/ad7879-spi.c
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9#include <linux/input.h> /* BUS_SPI */ 9#include <linux/input.h> /* BUS_SPI */
10#include <linux/pm.h>
10#include <linux/spi/spi.h> 11#include <linux/spi/spi.h>
11 12
12#include "ad7879.h" 13#include "ad7879.h"
@@ -20,9 +21,10 @@
20#define AD7879_WRITECMD(reg) (AD7879_CMD(reg)) 21#define AD7879_WRITECMD(reg) (AD7879_CMD(reg))
21#define AD7879_READCMD(reg) (AD7879_CMD(reg) | AD7879_CMD_READ) 22#define AD7879_READCMD(reg) (AD7879_CMD(reg) | AD7879_CMD_READ)
22 23
23#ifdef CONFIG_PM 24#ifdef CONFIG_PM_SLEEP
24static int ad7879_spi_suspend(struct spi_device *spi, pm_message_t message) 25static int ad7879_spi_suspend(struct device *dev)
25{ 26{
27 struct spi_device *spi = to_spi_device(dev);
26 struct ad7879 *ts = spi_get_drvdata(spi); 28 struct ad7879 *ts = spi_get_drvdata(spi);
27 29
28 ad7879_suspend(ts); 30 ad7879_suspend(ts);
@@ -30,19 +32,19 @@ static int ad7879_spi_suspend(struct spi_device *spi, pm_message_t message)
30 return 0; 32 return 0;
31} 33}
32 34
33static int ad7879_spi_resume(struct spi_device *spi) 35static int ad7879_spi_resume(struct device *dev)
34{ 36{
37 struct spi_device *spi = to_spi_device(dev);
35 struct ad7879 *ts = spi_get_drvdata(spi); 38 struct ad7879 *ts = spi_get_drvdata(spi);
36 39
37 ad7879_resume(ts); 40 ad7879_resume(ts);
38 41
39 return 0; 42 return 0;
40} 43}
41#else
42# define ad7879_spi_suspend NULL
43# define ad7879_spi_resume NULL
44#endif 44#endif
45 45
46static SIMPLE_DEV_PM_OPS(ad7879_spi_pm, ad7879_spi_suspend, ad7879_spi_resume);
47
46/* 48/*
47 * ad7879_read/write are only used for initial setup and for sysfs controls. 49 * ad7879_read/write are only used for initial setup and for sysfs controls.
48 * The main traffic is done in ad7879_collect(). 50 * The main traffic is done in ad7879_collect().
@@ -173,11 +175,10 @@ static struct spi_driver ad7879_spi_driver = {
173 .name = "ad7879", 175 .name = "ad7879",
174 .bus = &spi_bus_type, 176 .bus = &spi_bus_type,
175 .owner = THIS_MODULE, 177 .owner = THIS_MODULE,
178 .pm = &ad7879_spi_pm,
176 }, 179 },
177 .probe = ad7879_spi_probe, 180 .probe = ad7879_spi_probe,
178 .remove = __devexit_p(ad7879_spi_remove), 181 .remove = __devexit_p(ad7879_spi_remove),
179 .suspend = ad7879_spi_suspend,
180 .resume = ad7879_spi_resume,
181}; 182};
182 183
183static int __init ad7879_spi_init(void) 184static int __init ad7879_spi_init(void)
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 4bf2316e3284..c24946f51256 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -26,6 +26,7 @@
26#include <linux/input.h> 26#include <linux/input.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/pm.h>
29#include <linux/gpio.h> 30#include <linux/gpio.h>
30#include <linux/spi/spi.h> 31#include <linux/spi/spi.h>
31#include <linux/spi/ads7846.h> 32#include <linux/spi/ads7846.h>
@@ -892,9 +893,10 @@ static irqreturn_t ads7846_irq(int irq, void *handle)
892 return IRQ_HANDLED; 893 return IRQ_HANDLED;
893} 894}
894 895
895static int ads7846_suspend(struct spi_device *spi, pm_message_t message) 896#ifdef CONFIG_PM_SLEEP
897static int ads7846_suspend(struct device *dev)
896{ 898{
897 struct ads7846 *ts = dev_get_drvdata(&spi->dev); 899 struct ads7846 *ts = dev_get_drvdata(dev);
898 900
899 mutex_lock(&ts->lock); 901 mutex_lock(&ts->lock);
900 902
@@ -914,9 +916,9 @@ static int ads7846_suspend(struct spi_device *spi, pm_message_t message)
914 return 0; 916 return 0;
915} 917}
916 918
917static int ads7846_resume(struct spi_device *spi) 919static int ads7846_resume(struct device *dev)
918{ 920{
919 struct ads7846 *ts = dev_get_drvdata(&spi->dev); 921 struct ads7846 *ts = dev_get_drvdata(dev);
920 922
921 mutex_lock(&ts->lock); 923 mutex_lock(&ts->lock);
922 924
@@ -935,6 +937,9 @@ static int ads7846_resume(struct spi_device *spi)
935 937
936 return 0; 938 return 0;
937} 939}
940#endif
941
942static SIMPLE_DEV_PM_OPS(ads7846_pm, ads7846_suspend, ads7846_resume);
938 943
939static int __devinit ads7846_setup_pendown(struct spi_device *spi, struct ads7846 *ts) 944static int __devinit ads7846_setup_pendown(struct spi_device *spi, struct ads7846 *ts)
940{ 945{
@@ -1408,11 +1413,10 @@ static struct spi_driver ads7846_driver = {
1408 .name = "ads7846", 1413 .name = "ads7846",
1409 .bus = &spi_bus_type, 1414 .bus = &spi_bus_type,
1410 .owner = THIS_MODULE, 1415 .owner = THIS_MODULE,
1416 .pm = &ads7846_pm,
1411 }, 1417 },
1412 .probe = ads7846_probe, 1418 .probe = ads7846_probe,
1413 .remove = __devexit_p(ads7846_remove), 1419 .remove = __devexit_p(ads7846_remove),
1414 .suspend = ads7846_suspend,
1415 .resume = ads7846_resume,
1416}; 1420};
1417 1421
1418static int __init ads7846_init(void) 1422static int __init ads7846_init(void)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
new file mode 100644
index 000000000000..4012436633b1
--- /dev/null
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -0,0 +1,1211 @@
1/*
2 * Atmel maXTouch Touchscreen driver
3 *
4 * Copyright (C) 2010 Samsung Electronics Co.Ltd
5 * Author: Joonyoung Shim <jy0922.shim@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 */
13
14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/delay.h>
17#include <linux/firmware.h>
18#include <linux/i2c.h>
19#include <linux/i2c/atmel_mxt_ts.h>
20#include <linux/input.h>
21#include <linux/interrupt.h>
22#include <linux/slab.h>
23
24/* Version */
25#define MXT_VER_20 20
26#define MXT_VER_21 21
27#define MXT_VER_22 22
28
29/* Slave addresses */
30#define MXT_APP_LOW 0x4a
31#define MXT_APP_HIGH 0x4b
32#define MXT_BOOT_LOW 0x24
33#define MXT_BOOT_HIGH 0x25
34
35/* Firmware */
36#define MXT_FW_NAME "maxtouch.fw"
37
38/* Registers */
39#define MXT_FAMILY_ID 0x00
40#define MXT_VARIANT_ID 0x01
41#define MXT_VERSION 0x02
42#define MXT_BUILD 0x03
43#define MXT_MATRIX_X_SIZE 0x04
44#define MXT_MATRIX_Y_SIZE 0x05
45#define MXT_OBJECT_NUM 0x06
46#define MXT_OBJECT_START 0x07
47
48#define MXT_OBJECT_SIZE 6
49
50/* Object types */
51#define MXT_DEBUG_DIAGNOSTIC 37
52#define MXT_GEN_MESSAGE 5
53#define MXT_GEN_COMMAND 6
54#define MXT_GEN_POWER 7
55#define MXT_GEN_ACQUIRE 8
56#define MXT_TOUCH_MULTI 9
57#define MXT_TOUCH_KEYARRAY 15
58#define MXT_TOUCH_PROXIMITY 23
59#define MXT_PROCI_GRIPFACE 20
60#define MXT_PROCG_NOISE 22
61#define MXT_PROCI_ONETOUCH 24
62#define MXT_PROCI_TWOTOUCH 27
63#define MXT_PROCI_GRIP 40
64#define MXT_PROCI_PALM 41
65#define MXT_SPT_COMMSCONFIG 18
66#define MXT_SPT_GPIOPWM 19
67#define MXT_SPT_SELFTEST 25
68#define MXT_SPT_CTECONFIG 28
69#define MXT_SPT_USERDATA 38
70#define MXT_SPT_DIGITIZER 43
71#define MXT_SPT_MESSAGECOUNT 44
72
73/* MXT_GEN_COMMAND field */
74#define MXT_COMMAND_RESET 0
75#define MXT_COMMAND_BACKUPNV 1
76#define MXT_COMMAND_CALIBRATE 2
77#define MXT_COMMAND_REPORTALL 3
78#define MXT_COMMAND_DIAGNOSTIC 5
79
80/* MXT_GEN_POWER field */
81#define MXT_POWER_IDLEACQINT 0
82#define MXT_POWER_ACTVACQINT 1
83#define MXT_POWER_ACTV2IDLETO 2
84
85/* MXT_GEN_ACQUIRE field */
86#define MXT_ACQUIRE_CHRGTIME 0
87#define MXT_ACQUIRE_TCHDRIFT 2
88#define MXT_ACQUIRE_DRIFTST 3
89#define MXT_ACQUIRE_TCHAUTOCAL 4
90#define MXT_ACQUIRE_SYNC 5
91#define MXT_ACQUIRE_ATCHCALST 6
92#define MXT_ACQUIRE_ATCHCALSTHR 7
93
94/* MXT_TOUCH_MULTI field */
95#define MXT_TOUCH_CTRL 0
96#define MXT_TOUCH_XORIGIN 1
97#define MXT_TOUCH_YORIGIN 2
98#define MXT_TOUCH_XSIZE 3
99#define MXT_TOUCH_YSIZE 4
100#define MXT_TOUCH_BLEN 6
101#define MXT_TOUCH_TCHTHR 7
102#define MXT_TOUCH_TCHDI 8
103#define MXT_TOUCH_ORIENT 9
104#define MXT_TOUCH_MOVHYSTI 11
105#define MXT_TOUCH_MOVHYSTN 12
106#define MXT_TOUCH_NUMTOUCH 14
107#define MXT_TOUCH_MRGHYST 15
108#define MXT_TOUCH_MRGTHR 16
109#define MXT_TOUCH_AMPHYST 17
110#define MXT_TOUCH_XRANGE_LSB 18
111#define MXT_TOUCH_XRANGE_MSB 19
112#define MXT_TOUCH_YRANGE_LSB 20
113#define MXT_TOUCH_YRANGE_MSB 21
114#define MXT_TOUCH_XLOCLIP 22
115#define MXT_TOUCH_XHICLIP 23
116#define MXT_TOUCH_YLOCLIP 24
117#define MXT_TOUCH_YHICLIP 25
118#define MXT_TOUCH_XEDGECTRL 26
119#define MXT_TOUCH_XEDGEDIST 27
120#define MXT_TOUCH_YEDGECTRL 28
121#define MXT_TOUCH_YEDGEDIST 29
122#define MXT_TOUCH_JUMPLIMIT 30
123
124/* MXT_PROCI_GRIPFACE field */
125#define MXT_GRIPFACE_CTRL 0
126#define MXT_GRIPFACE_XLOGRIP 1
127#define MXT_GRIPFACE_XHIGRIP 2
128#define MXT_GRIPFACE_YLOGRIP 3
129#define MXT_GRIPFACE_YHIGRIP 4
130#define MXT_GRIPFACE_MAXTCHS 5
131#define MXT_GRIPFACE_SZTHR1 7
132#define MXT_GRIPFACE_SZTHR2 8
133#define MXT_GRIPFACE_SHPTHR1 9
134#define MXT_GRIPFACE_SHPTHR2 10
135#define MXT_GRIPFACE_SUPEXTTO 11
136
137/* MXT_PROCI_NOISE field */
138#define MXT_NOISE_CTRL 0
139#define MXT_NOISE_OUTFLEN 1
140#define MXT_NOISE_GCAFUL_LSB 3
141#define MXT_NOISE_GCAFUL_MSB 4
142#define MXT_NOISE_GCAFLL_LSB 5
143#define MXT_NOISE_GCAFLL_MSB 6
144#define MXT_NOISE_ACTVGCAFVALID 7
145#define MXT_NOISE_NOISETHR 8
146#define MXT_NOISE_FREQHOPSCALE 10
147#define MXT_NOISE_FREQ0 11
148#define MXT_NOISE_FREQ1 12
149#define MXT_NOISE_FREQ2 13
150#define MXT_NOISE_FREQ3 14
151#define MXT_NOISE_FREQ4 15
152#define MXT_NOISE_IDLEGCAFVALID 16
153
154/* MXT_SPT_COMMSCONFIG */
155#define MXT_COMMS_CTRL 0
156#define MXT_COMMS_CMD 1
157
158/* MXT_SPT_CTECONFIG field */
159#define MXT_CTE_CTRL 0
160#define MXT_CTE_CMD 1
161#define MXT_CTE_MODE 2
162#define MXT_CTE_IDLEGCAFDEPTH 3
163#define MXT_CTE_ACTVGCAFDEPTH 4
164#define MXT_CTE_VOLTAGE 5
165
166#define MXT_VOLTAGE_DEFAULT 2700000
167#define MXT_VOLTAGE_STEP 10000
168
169/* Define for MXT_GEN_COMMAND */
170#define MXT_BOOT_VALUE 0xa5
171#define MXT_BACKUP_VALUE 0x55
172#define MXT_BACKUP_TIME 25 /* msec */
173#define MXT_RESET_TIME 65 /* msec */
174
175#define MXT_FWRESET_TIME 175 /* msec */
176
177/* Command to unlock bootloader */
178#define MXT_UNLOCK_CMD_MSB 0xaa
179#define MXT_UNLOCK_CMD_LSB 0xdc
180
181/* Bootloader mode status */
182#define MXT_WAITING_BOOTLOAD_CMD 0xc0 /* valid 7 6 bit only */
183#define MXT_WAITING_FRAME_DATA 0x80 /* valid 7 6 bit only */
184#define MXT_FRAME_CRC_CHECK 0x02
185#define MXT_FRAME_CRC_FAIL 0x03
186#define MXT_FRAME_CRC_PASS 0x04
187#define MXT_APP_CRC_FAIL 0x40 /* valid 7 8 bit only */
188#define MXT_BOOT_STATUS_MASK 0x3f
189
190/* Touch status */
191#define MXT_SUPPRESS (1 << 1)
192#define MXT_AMP (1 << 2)
193#define MXT_VECTOR (1 << 3)
194#define MXT_MOVE (1 << 4)
195#define MXT_RELEASE (1 << 5)
196#define MXT_PRESS (1 << 6)
197#define MXT_DETECT (1 << 7)
198
199/* Touchscreen absolute values */
200#define MXT_MAX_XC 0x3ff
201#define MXT_MAX_YC 0x3ff
202#define MXT_MAX_AREA 0xff
203
204#define MXT_MAX_FINGER 10
205
206struct mxt_info {
207 u8 family_id;
208 u8 variant_id;
209 u8 version;
210 u8 build;
211 u8 matrix_xsize;
212 u8 matrix_ysize;
213 u8 object_num;
214};
215
216struct mxt_object {
217 u8 type;
218 u16 start_address;
219 u8 size;
220 u8 instances;
221 u8 num_report_ids;
222
223 /* to map object and message */
224 u8 max_reportid;
225};
226
227struct mxt_message {
228 u8 reportid;
229 u8 message[7];
230 u8 checksum;
231};
232
233struct mxt_finger {
234 int status;
235 int x;
236 int y;
237 int area;
238};
239
240/* Each client has this additional data */
241struct mxt_data {
242 struct i2c_client *client;
243 struct input_dev *input_dev;
244 const struct mxt_platform_data *pdata;
245 struct mxt_object *object_table;
246 struct mxt_info info;
247 struct mxt_finger finger[MXT_MAX_FINGER];
248 unsigned int irq;
249};
250
251static bool mxt_object_readable(unsigned int type)
252{
253 switch (type) {
254 case MXT_GEN_MESSAGE:
255 case MXT_GEN_COMMAND:
256 case MXT_GEN_POWER:
257 case MXT_GEN_ACQUIRE:
258 case MXT_TOUCH_MULTI:
259 case MXT_TOUCH_KEYARRAY:
260 case MXT_TOUCH_PROXIMITY:
261 case MXT_PROCI_GRIPFACE:
262 case MXT_PROCG_NOISE:
263 case MXT_PROCI_ONETOUCH:
264 case MXT_PROCI_TWOTOUCH:
265 case MXT_PROCI_GRIP:
266 case MXT_PROCI_PALM:
267 case MXT_SPT_COMMSCONFIG:
268 case MXT_SPT_GPIOPWM:
269 case MXT_SPT_SELFTEST:
270 case MXT_SPT_CTECONFIG:
271 case MXT_SPT_USERDATA:
272 return true;
273 default:
274 return false;
275 }
276}
277
278static bool mxt_object_writable(unsigned int type)
279{
280 switch (type) {
281 case MXT_GEN_COMMAND:
282 case MXT_GEN_POWER:
283 case MXT_GEN_ACQUIRE:
284 case MXT_TOUCH_MULTI:
285 case MXT_TOUCH_KEYARRAY:
286 case MXT_TOUCH_PROXIMITY:
287 case MXT_PROCI_GRIPFACE:
288 case MXT_PROCG_NOISE:
289 case MXT_PROCI_ONETOUCH:
290 case MXT_PROCI_TWOTOUCH:
291 case MXT_PROCI_GRIP:
292 case MXT_PROCI_PALM:
293 case MXT_SPT_GPIOPWM:
294 case MXT_SPT_SELFTEST:
295 case MXT_SPT_CTECONFIG:
296 return true;
297 default:
298 return false;
299 }
300}
301
302static void mxt_dump_message(struct device *dev,
303 struct mxt_message *message)
304{
305 dev_dbg(dev, "reportid:\t0x%x\n", message->reportid);
306 dev_dbg(dev, "message1:\t0x%x\n", message->message[0]);
307 dev_dbg(dev, "message2:\t0x%x\n", message->message[1]);
308 dev_dbg(dev, "message3:\t0x%x\n", message->message[2]);
309 dev_dbg(dev, "message4:\t0x%x\n", message->message[3]);
310 dev_dbg(dev, "message5:\t0x%x\n", message->message[4]);
311 dev_dbg(dev, "message6:\t0x%x\n", message->message[5]);
312 dev_dbg(dev, "message7:\t0x%x\n", message->message[6]);
313 dev_dbg(dev, "checksum:\t0x%x\n", message->checksum);
314}
315
316static int mxt_check_bootloader(struct i2c_client *client,
317 unsigned int state)
318{
319 u8 val;
320
321recheck:
322 if (i2c_master_recv(client, &val, 1) != 1) {
323 dev_err(&client->dev, "%s: i2c recv failed\n", __func__);
324 return -EIO;
325 }
326
327 switch (state) {
328 case MXT_WAITING_BOOTLOAD_CMD:
329 case MXT_WAITING_FRAME_DATA:
330 val &= ~MXT_BOOT_STATUS_MASK;
331 break;
332 case MXT_FRAME_CRC_PASS:
333 if (val == MXT_FRAME_CRC_CHECK)
334 goto recheck;
335 break;
336 default:
337 return -EINVAL;
338 }
339
340 if (val != state) {
341 dev_err(&client->dev, "Unvalid bootloader mode state\n");
342 return -EINVAL;
343 }
344
345 return 0;
346}
347
348static int mxt_unlock_bootloader(struct i2c_client *client)
349{
350 u8 buf[2];
351
352 buf[0] = MXT_UNLOCK_CMD_LSB;
353 buf[1] = MXT_UNLOCK_CMD_MSB;
354
355 if (i2c_master_send(client, buf, 2) != 2) {
356 dev_err(&client->dev, "%s: i2c send failed\n", __func__);
357 return -EIO;
358 }
359
360 return 0;
361}
362
363static int mxt_fw_write(struct i2c_client *client,
364 const u8 *data, unsigned int frame_size)
365{
366 if (i2c_master_send(client, data, frame_size) != frame_size) {
367 dev_err(&client->dev, "%s: i2c send failed\n", __func__);
368 return -EIO;
369 }
370
371 return 0;
372}
373
374static int __mxt_read_reg(struct i2c_client *client,
375 u16 reg, u16 len, void *val)
376{
377 struct i2c_msg xfer[2];
378 u8 buf[2];
379
380 buf[0] = reg & 0xff;
381 buf[1] = (reg >> 8) & 0xff;
382
383 /* Write register */
384 xfer[0].addr = client->addr;
385 xfer[0].flags = 0;
386 xfer[0].len = 2;
387 xfer[0].buf = buf;
388
389 /* Read data */
390 xfer[1].addr = client->addr;
391 xfer[1].flags = I2C_M_RD;
392 xfer[1].len = len;
393 xfer[1].buf = val;
394
395 if (i2c_transfer(client->adapter, xfer, 2) != 2) {
396 dev_err(&client->dev, "%s: i2c transfer failed\n", __func__);
397 return -EIO;
398 }
399
400 return 0;
401}
402
403static int mxt_read_reg(struct i2c_client *client, u16 reg, u8 *val)
404{
405 return __mxt_read_reg(client, reg, 1, val);
406}
407
408static int mxt_write_reg(struct i2c_client *client, u16 reg, u8 val)
409{
410 u8 buf[3];
411
412 buf[0] = reg & 0xff;
413 buf[1] = (reg >> 8) & 0xff;
414 buf[2] = val;
415
416 if (i2c_master_send(client, buf, 3) != 3) {
417 dev_err(&client->dev, "%s: i2c send failed\n", __func__);
418 return -EIO;
419 }
420
421 return 0;
422}
423
424static int mxt_read_object_table(struct i2c_client *client,
425 u16 reg, u8 *object_buf)
426{
427 return __mxt_read_reg(client, reg, MXT_OBJECT_SIZE,
428 object_buf);
429}
430
431static struct mxt_object *
432mxt_get_object(struct mxt_data *data, u8 type)
433{
434 struct mxt_object *object;
435 int i;
436
437 for (i = 0; i < data->info.object_num; i++) {
438 object = data->object_table + i;
439 if (object->type == type)
440 return object;
441 }
442
443 dev_err(&data->client->dev, "Invalid object type\n");
444 return NULL;
445}
446
447static int mxt_read_message(struct mxt_data *data,
448 struct mxt_message *message)
449{
450 struct mxt_object *object;
451 u16 reg;
452
453 object = mxt_get_object(data, MXT_GEN_MESSAGE);
454 if (!object)
455 return -EINVAL;
456
457 reg = object->start_address;
458 return __mxt_read_reg(data->client, reg,
459 sizeof(struct mxt_message), message);
460}
461
462static int mxt_read_object(struct mxt_data *data,
463 u8 type, u8 offset, u8 *val)
464{
465 struct mxt_object *object;
466 u16 reg;
467
468 object = mxt_get_object(data, type);
469 if (!object)
470 return -EINVAL;
471
472 reg = object->start_address;
473 return __mxt_read_reg(data->client, reg + offset, 1, val);
474}
475
476static int mxt_write_object(struct mxt_data *data,
477 u8 type, u8 offset, u8 val)
478{
479 struct mxt_object *object;
480 u16 reg;
481
482 object = mxt_get_object(data, type);
483 if (!object)
484 return -EINVAL;
485
486 reg = object->start_address;
487 return mxt_write_reg(data->client, reg + offset, val);
488}
489
490static void mxt_input_report(struct mxt_data *data, int single_id)
491{
492 struct mxt_finger *finger = data->finger;
493 struct input_dev *input_dev = data->input_dev;
494 int status = finger[single_id].status;
495 int finger_num = 0;
496 int id;
497
498 for (id = 0; id < MXT_MAX_FINGER; id++) {
499 if (!finger[id].status)
500 continue;
501
502 input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR,
503 finger[id].status != MXT_RELEASE ?
504 finger[id].area : 0);
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
511 if (finger[id].status == MXT_RELEASE)
512 finger[id].status = 0;
513 else
514 finger_num++;
515 }
516
517 input_report_key(input_dev, BTN_TOUCH, finger_num > 0);
518
519 if (status != MXT_RELEASE) {
520 input_report_abs(input_dev, ABS_X, finger[single_id].x);
521 input_report_abs(input_dev, ABS_Y, finger[single_id].y);
522 }
523
524 input_sync(input_dev);
525}
526
527static void mxt_input_touchevent(struct mxt_data *data,
528 struct mxt_message *message, int id)
529{
530 struct mxt_finger *finger = data->finger;
531 struct device *dev = &data->client->dev;
532 u8 status = message->message[0];
533 int x;
534 int y;
535 int area;
536
537 /* Check the touch is present on the screen */
538 if (!(status & MXT_DETECT)) {
539 if (status & MXT_RELEASE) {
540 dev_dbg(dev, "[%d] released\n", id);
541
542 finger[id].status = MXT_RELEASE;
543 mxt_input_report(data, id);
544 }
545 return;
546 }
547
548 /* Check only AMP detection */
549 if (!(status & (MXT_PRESS | MXT_MOVE)))
550 return;
551
552 x = (message->message[1] << 2) | ((message->message[3] & ~0x3f) >> 6);
553 y = (message->message[2] << 2) | ((message->message[3] & ~0xf3) >> 2);
554 area = message->message[4];
555
556 dev_dbg(dev, "[%d] %s x: %d, y: %d, area: %d\n", id,
557 status & MXT_MOVE ? "moved" : "pressed",
558 x, y, area);
559
560 finger[id].status = status & MXT_MOVE ?
561 MXT_MOVE : MXT_PRESS;
562 finger[id].x = x;
563 finger[id].y = y;
564 finger[id].area = area;
565
566 mxt_input_report(data, id);
567}
568
569static irqreturn_t mxt_interrupt(int irq, void *dev_id)
570{
571 struct mxt_data *data = dev_id;
572 struct mxt_message message;
573 struct mxt_object *object;
574 struct device *dev = &data->client->dev;
575 int id;
576 u8 reportid;
577 u8 max_reportid;
578 u8 min_reportid;
579
580 do {
581 if (mxt_read_message(data, &message)) {
582 dev_err(dev, "Failed to read message\n");
583 goto end;
584 }
585
586 reportid = message.reportid;
587
588 /* whether reportid is thing of MXT_TOUCH_MULTI */
589 object = mxt_get_object(data, MXT_TOUCH_MULTI);
590 if (!object)
591 goto end;
592
593 max_reportid = object->max_reportid;
594 min_reportid = max_reportid - object->num_report_ids + 1;
595 id = reportid - min_reportid;
596
597 if (reportid >= min_reportid && reportid <= max_reportid)
598 mxt_input_touchevent(data, &message, id);
599 else
600 mxt_dump_message(dev, &message);
601 } while (reportid != 0xff);
602
603end:
604 return IRQ_HANDLED;
605}
606
607static int mxt_check_reg_init(struct mxt_data *data)
608{
609 const struct mxt_platform_data *pdata = data->pdata;
610 struct mxt_object *object;
611 struct device *dev = &data->client->dev;
612 int index = 0;
613 int i, j, config_offset;
614
615 if (!pdata->config) {
616 dev_dbg(dev, "No cfg data defined, skipping reg init\n");
617 return 0;
618 }
619
620 for (i = 0; i < data->info.object_num; i++) {
621 object = data->object_table + i;
622
623 if (!mxt_object_writable(object->type))
624 continue;
625
626 for (j = 0; j < object->size + 1; j++) {
627 config_offset = index + j;
628 if (config_offset > pdata->config_length) {
629 dev_err(dev, "Not enough config data!\n");
630 return -EINVAL;
631 }
632 mxt_write_object(data, object->type, j,
633 pdata->config[config_offset]);
634 }
635 index += object->size + 1;
636 }
637
638 return 0;
639}
640
641static int mxt_make_highchg(struct mxt_data *data)
642{
643 struct device *dev = &data->client->dev;
644 struct mxt_message message;
645 int count = 10;
646 int error;
647
648 /* Read dummy message to make high CHG pin */
649 do {
650 error = mxt_read_message(data, &message);
651 if (error)
652 return error;
653 } while (message.reportid != 0xff && --count);
654
655 if (!count) {
656 dev_err(dev, "CHG pin isn't cleared\n");
657 return -EBUSY;
658 }
659
660 return 0;
661}
662
663static void mxt_handle_pdata(struct mxt_data *data)
664{
665 const struct mxt_platform_data *pdata = data->pdata;
666 u8 voltage;
667
668 /* Set touchscreen lines */
669 mxt_write_object(data, MXT_TOUCH_MULTI, MXT_TOUCH_XSIZE,
670 pdata->x_line);
671 mxt_write_object(data, MXT_TOUCH_MULTI, MXT_TOUCH_YSIZE,
672 pdata->y_line);
673
674 /* Set touchscreen orient */
675 mxt_write_object(data, MXT_TOUCH_MULTI, MXT_TOUCH_ORIENT,
676 pdata->orient);
677
678 /* Set touchscreen burst length */
679 mxt_write_object(data, MXT_TOUCH_MULTI,
680 MXT_TOUCH_BLEN, pdata->blen);
681
682 /* Set touchscreen threshold */
683 mxt_write_object(data, MXT_TOUCH_MULTI,
684 MXT_TOUCH_TCHTHR, pdata->threshold);
685
686 /* Set touchscreen resolution */
687 mxt_write_object(data, MXT_TOUCH_MULTI,
688 MXT_TOUCH_XRANGE_LSB, (pdata->x_size - 1) & 0xff);
689 mxt_write_object(data, MXT_TOUCH_MULTI,
690 MXT_TOUCH_XRANGE_MSB, (pdata->x_size - 1) >> 8);
691 mxt_write_object(data, MXT_TOUCH_MULTI,
692 MXT_TOUCH_YRANGE_LSB, (pdata->y_size - 1) & 0xff);
693 mxt_write_object(data, MXT_TOUCH_MULTI,
694 MXT_TOUCH_YRANGE_MSB, (pdata->y_size - 1) >> 8);
695
696 /* Set touchscreen voltage */
697 if (pdata->voltage) {
698 if (pdata->voltage < MXT_VOLTAGE_DEFAULT) {
699 voltage = (MXT_VOLTAGE_DEFAULT - pdata->voltage) /
700 MXT_VOLTAGE_STEP;
701 voltage = 0xff - voltage + 1;
702 } else
703 voltage = (pdata->voltage - MXT_VOLTAGE_DEFAULT) /
704 MXT_VOLTAGE_STEP;
705
706 mxt_write_object(data, MXT_SPT_CTECONFIG,
707 MXT_CTE_VOLTAGE, voltage);
708 }
709}
710
711static int mxt_get_info(struct mxt_data *data)
712{
713 struct i2c_client *client = data->client;
714 struct mxt_info *info = &data->info;
715 int error;
716 u8 val;
717
718 error = mxt_read_reg(client, MXT_FAMILY_ID, &val);
719 if (error)
720 return error;
721 info->family_id = val;
722
723 error = mxt_read_reg(client, MXT_VARIANT_ID, &val);
724 if (error)
725 return error;
726 info->variant_id = val;
727
728 error = mxt_read_reg(client, MXT_VERSION, &val);
729 if (error)
730 return error;
731 info->version = val;
732
733 error = mxt_read_reg(client, MXT_BUILD, &val);
734 if (error)
735 return error;
736 info->build = val;
737
738 error = mxt_read_reg(client, MXT_OBJECT_NUM, &val);
739 if (error)
740 return error;
741 info->object_num = val;
742
743 return 0;
744}
745
746static int mxt_get_object_table(struct mxt_data *data)
747{
748 int error;
749 int i;
750 u16 reg;
751 u8 reportid = 0;
752 u8 buf[MXT_OBJECT_SIZE];
753
754 for (i = 0; i < data->info.object_num; i++) {
755 struct mxt_object *object = data->object_table + i;
756
757 reg = MXT_OBJECT_START + MXT_OBJECT_SIZE * i;
758 error = mxt_read_object_table(data->client, reg, buf);
759 if (error)
760 return error;
761
762 object->type = buf[0];
763 object->start_address = (buf[2] << 8) | buf[1];
764 object->size = buf[3];
765 object->instances = buf[4];
766 object->num_report_ids = buf[5];
767
768 if (object->num_report_ids) {
769 reportid += object->num_report_ids *
770 (object->instances + 1);
771 object->max_reportid = reportid;
772 }
773 }
774
775 return 0;
776}
777
778static int mxt_initialize(struct mxt_data *data)
779{
780 struct i2c_client *client = data->client;
781 struct mxt_info *info = &data->info;
782 int error;
783 u8 val;
784
785 error = mxt_get_info(data);
786 if (error)
787 return error;
788
789 data->object_table = kcalloc(info->object_num,
790 sizeof(struct mxt_object),
791 GFP_KERNEL);
792 if (!data->object_table) {
793 dev_err(&client->dev, "Failed to allocate memory\n");
794 return -ENOMEM;
795 }
796
797 /* Get object table information */
798 error = mxt_get_object_table(data);
799 if (error)
800 return error;
801
802 /* Check register init values */
803 error = mxt_check_reg_init(data);
804 if (error)
805 return error;
806
807 error = mxt_make_highchg(data);
808 if (error)
809 return error;
810
811 mxt_handle_pdata(data);
812
813 /* Backup to memory */
814 mxt_write_object(data, MXT_GEN_COMMAND,
815 MXT_COMMAND_BACKUPNV,
816 MXT_BACKUP_VALUE);
817 msleep(MXT_BACKUP_TIME);
818
819 /* Soft reset */
820 mxt_write_object(data, MXT_GEN_COMMAND,
821 MXT_COMMAND_RESET, 1);
822 msleep(MXT_RESET_TIME);
823
824 /* Update matrix size at info struct */
825 error = mxt_read_reg(client, MXT_MATRIX_X_SIZE, &val);
826 if (error)
827 return error;
828 info->matrix_xsize = val;
829
830 error = mxt_read_reg(client, MXT_MATRIX_Y_SIZE, &val);
831 if (error)
832 return error;
833 info->matrix_ysize = val;
834
835 dev_info(&client->dev,
836 "Family ID: %d Variant ID: %d Version: %d Build: %d\n",
837 info->family_id, info->variant_id, info->version,
838 info->build);
839
840 dev_info(&client->dev,
841 "Matrix X Size: %d Matrix Y Size: %d Object Num: %d\n",
842 info->matrix_xsize, info->matrix_ysize,
843 info->object_num);
844
845 return 0;
846}
847
848static ssize_t mxt_object_show(struct device *dev,
849 struct device_attribute *attr, char *buf)
850{
851 struct mxt_data *data = dev_get_drvdata(dev);
852 struct mxt_object *object;
853 int count = 0;
854 int i, j;
855 int error;
856 u8 val;
857
858 for (i = 0; i < data->info.object_num; i++) {
859 object = data->object_table + i;
860
861 count += sprintf(buf + count,
862 "Object Table Element %d(Type %d)\n",
863 i + 1, object->type);
864
865 if (!mxt_object_readable(object->type)) {
866 count += sprintf(buf + count, "\n");
867 continue;
868 }
869
870 for (j = 0; j < object->size + 1; j++) {
871 error = mxt_read_object(data,
872 object->type, j, &val);
873 if (error)
874 return error;
875
876 count += sprintf(buf + count,
877 " Byte %d: 0x%x (%d)\n", j, val, val);
878 }
879
880 count += sprintf(buf + count, "\n");
881 }
882
883 return count;
884}
885
886static int mxt_load_fw(struct device *dev, const char *fn)
887{
888 struct mxt_data *data = dev_get_drvdata(dev);
889 struct i2c_client *client = data->client;
890 const struct firmware *fw = NULL;
891 unsigned int frame_size;
892 unsigned int pos = 0;
893 int ret;
894
895 ret = request_firmware(&fw, fn, dev);
896 if (ret) {
897 dev_err(dev, "Unable to open firmware %s\n", fn);
898 return ret;
899 }
900
901 /* Change to the bootloader mode */
902 mxt_write_object(data, MXT_GEN_COMMAND,
903 MXT_COMMAND_RESET, MXT_BOOT_VALUE);
904 msleep(MXT_RESET_TIME);
905
906 /* Change to slave address of bootloader */
907 if (client->addr == MXT_APP_LOW)
908 client->addr = MXT_BOOT_LOW;
909 else
910 client->addr = MXT_BOOT_HIGH;
911
912 ret = mxt_check_bootloader(client, MXT_WAITING_BOOTLOAD_CMD);
913 if (ret)
914 goto out;
915
916 /* Unlock bootloader */
917 mxt_unlock_bootloader(client);
918
919 while (pos < fw->size) {
920 ret = mxt_check_bootloader(client,
921 MXT_WAITING_FRAME_DATA);
922 if (ret)
923 goto out;
924
925 frame_size = ((*(fw->data + pos) << 8) | *(fw->data + pos + 1));
926
927 /* We should add 2 at frame size as the the firmware data is not
928 * included the CRC bytes.
929 */
930 frame_size += 2;
931
932 /* Write one frame to device */
933 mxt_fw_write(client, fw->data + pos, frame_size);
934
935 ret = mxt_check_bootloader(client,
936 MXT_FRAME_CRC_PASS);
937 if (ret)
938 goto out;
939
940 pos += frame_size;
941
942 dev_dbg(dev, "Updated %d bytes / %zd bytes\n", pos, fw->size);
943 }
944
945out:
946 release_firmware(fw);
947
948 /* Change to slave address of application */
949 if (client->addr == MXT_BOOT_LOW)
950 client->addr = MXT_APP_LOW;
951 else
952 client->addr = MXT_APP_HIGH;
953
954 return ret;
955}
956
957static ssize_t mxt_update_fw_store(struct device *dev,
958 struct device_attribute *attr,
959 const char *buf, size_t count)
960{
961 struct mxt_data *data = dev_get_drvdata(dev);
962 int error;
963
964 disable_irq(data->irq);
965
966 error = mxt_load_fw(dev, MXT_FW_NAME);
967 if (error) {
968 dev_err(dev, "The firmware update failed(%d)\n", error);
969 count = error;
970 } else {
971 dev_dbg(dev, "The firmware update succeeded\n");
972
973 /* Wait for reset */
974 msleep(MXT_FWRESET_TIME);
975
976 kfree(data->object_table);
977 data->object_table = NULL;
978
979 mxt_initialize(data);
980 }
981
982 enable_irq(data->irq);
983
984 return count;
985}
986
987static DEVICE_ATTR(object, 0444, mxt_object_show, NULL);
988static DEVICE_ATTR(update_fw, 0664, NULL, mxt_update_fw_store);
989
990static struct attribute *mxt_attrs[] = {
991 &dev_attr_object.attr,
992 &dev_attr_update_fw.attr,
993 NULL
994};
995
996static const struct attribute_group mxt_attr_group = {
997 .attrs = mxt_attrs,
998};
999
1000static void mxt_start(struct mxt_data *data)
1001{
1002 /* Touch enable */
1003 mxt_write_object(data,
1004 MXT_TOUCH_MULTI, MXT_TOUCH_CTRL, 0x83);
1005}
1006
1007static void mxt_stop(struct mxt_data *data)
1008{
1009 /* Touch disable */
1010 mxt_write_object(data,
1011 MXT_TOUCH_MULTI, MXT_TOUCH_CTRL, 0);
1012}
1013
1014static int mxt_input_open(struct input_dev *dev)
1015{
1016 struct mxt_data *data = input_get_drvdata(dev);
1017
1018 mxt_start(data);
1019
1020 return 0;
1021}
1022
1023static void mxt_input_close(struct input_dev *dev)
1024{
1025 struct mxt_data *data = input_get_drvdata(dev);
1026
1027 mxt_stop(data);
1028}
1029
1030static int __devinit mxt_probe(struct i2c_client *client,
1031 const struct i2c_device_id *id)
1032{
1033 const struct mxt_platform_data *pdata = client->dev.platform_data;
1034 struct mxt_data *data;
1035 struct input_dev *input_dev;
1036 int error;
1037
1038 if (!pdata)
1039 return -EINVAL;
1040
1041 data = kzalloc(sizeof(struct mxt_data), GFP_KERNEL);
1042 input_dev = input_allocate_device();
1043 if (!data || !input_dev) {
1044 dev_err(&client->dev, "Failed to allocate memory\n");
1045 error = -ENOMEM;
1046 goto err_free_mem;
1047 }
1048
1049 input_dev->name = "Atmel maXTouch Touchscreen";
1050 input_dev->id.bustype = BUS_I2C;
1051 input_dev->dev.parent = &client->dev;
1052 input_dev->open = mxt_input_open;
1053 input_dev->close = mxt_input_close;
1054
1055 __set_bit(EV_ABS, input_dev->evbit);
1056 __set_bit(EV_KEY, input_dev->evbit);
1057 __set_bit(BTN_TOUCH, input_dev->keybit);
1058
1059 /* For single touch */
1060 input_set_abs_params(input_dev, ABS_X,
1061 0, MXT_MAX_XC, 0, 0);
1062 input_set_abs_params(input_dev, ABS_Y,
1063 0, MXT_MAX_YC, 0, 0);
1064
1065 /* For multi touch */
1066 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
1067 0, MXT_MAX_AREA, 0, 0);
1068 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1069 0, MXT_MAX_XC, 0, 0);
1070 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1071 0, MXT_MAX_YC, 0, 0);
1072
1073 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);
1081
1082 error = mxt_initialize(data);
1083 if (error)
1084 goto err_free_object;
1085
1086 error = request_threaded_irq(client->irq, NULL, mxt_interrupt,
1087 pdata->irqflags, client->dev.driver->name, data);
1088 if (error) {
1089 dev_err(&client->dev, "Failed to register interrupt\n");
1090 goto err_free_object;
1091 }
1092
1093 error = input_register_device(input_dev);
1094 if (error)
1095 goto err_free_irq;
1096
1097 error = sysfs_create_group(&client->dev.kobj, &mxt_attr_group);
1098 if (error)
1099 goto err_unregister_device;
1100
1101 return 0;
1102
1103err_unregister_device:
1104 input_unregister_device(input_dev);
1105 input_dev = NULL;
1106err_free_irq:
1107 free_irq(client->irq, data);
1108err_free_object:
1109 kfree(data->object_table);
1110err_free_mem:
1111 input_free_device(input_dev);
1112 kfree(data);
1113 return error;
1114}
1115
1116static int __devexit mxt_remove(struct i2c_client *client)
1117{
1118 struct mxt_data *data = i2c_get_clientdata(client);
1119
1120 sysfs_remove_group(&client->dev.kobj, &mxt_attr_group);
1121 free_irq(data->irq, data);
1122 input_unregister_device(data->input_dev);
1123 kfree(data->object_table);
1124 kfree(data);
1125
1126 return 0;
1127}
1128
1129#ifdef CONFIG_PM
1130static int mxt_suspend(struct device *dev)
1131{
1132 struct i2c_client *client = to_i2c_client(dev);
1133 struct mxt_data *data = i2c_get_clientdata(client);
1134 struct input_dev *input_dev = data->input_dev;
1135
1136 mutex_lock(&input_dev->mutex);
1137
1138 if (input_dev->users)
1139 mxt_stop(data);
1140
1141 mutex_unlock(&input_dev->mutex);
1142
1143 return 0;
1144}
1145
1146static int mxt_resume(struct device *dev)
1147{
1148 struct i2c_client *client = to_i2c_client(dev);
1149 struct mxt_data *data = i2c_get_clientdata(client);
1150 struct input_dev *input_dev = data->input_dev;
1151
1152 /* Soft reset */
1153 mxt_write_object(data, MXT_GEN_COMMAND,
1154 MXT_COMMAND_RESET, 1);
1155
1156 msleep(MXT_RESET_TIME);
1157
1158 mutex_lock(&input_dev->mutex);
1159
1160 if (input_dev->users)
1161 mxt_start(data);
1162
1163 mutex_unlock(&input_dev->mutex);
1164
1165 return 0;
1166}
1167
1168static const struct dev_pm_ops mxt_pm_ops = {
1169 .suspend = mxt_suspend,
1170 .resume = mxt_resume,
1171};
1172#endif
1173
1174static const struct i2c_device_id mxt_id[] = {
1175 { "qt602240_ts", 0 },
1176 { "atmel_mxt_ts", 0 },
1177 { "mXT224", 0 },
1178 { }
1179};
1180MODULE_DEVICE_TABLE(i2c, mxt_id);
1181
1182static struct i2c_driver mxt_driver = {
1183 .driver = {
1184 .name = "atmel_mxt_ts",
1185 .owner = THIS_MODULE,
1186#ifdef CONFIG_PM
1187 .pm = &mxt_pm_ops,
1188#endif
1189 },
1190 .probe = mxt_probe,
1191 .remove = __devexit_p(mxt_remove),
1192 .id_table = mxt_id,
1193};
1194
1195static int __init mxt_init(void)
1196{
1197 return i2c_add_driver(&mxt_driver);
1198}
1199
1200static void __exit mxt_exit(void)
1201{
1202 i2c_del_driver(&mxt_driver);
1203}
1204
1205module_init(mxt_init);
1206module_exit(mxt_exit);
1207
1208/* Module information */
1209MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>");
1210MODULE_DESCRIPTION("Atmel maXTouch Touchscreen driver");
1211MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/h3600_ts_input.c b/drivers/input/touchscreen/h3600_ts_input.c
index b4d7f63deff1..45f93d0f5592 100644
--- a/drivers/input/touchscreen/h3600_ts_input.c
+++ b/drivers/input/touchscreen/h3600_ts_input.c
@@ -62,7 +62,7 @@ MODULE_LICENSE("GPL");
62 Programmer has no control over these numbers. 62 Programmer has no control over these numbers.
63 TODO there are holes - specifically 1,7,0x0a 63 TODO there are holes - specifically 1,7,0x0a
64*/ 64*/
65#define VERSION_ID 0 /* Get Version (request/respose) */ 65#define VERSION_ID 0 /* Get Version (request/response) */
66#define KEYBD_ID 2 /* Keyboard (event) */ 66#define KEYBD_ID 2 /* Keyboard (event) */
67#define TOUCHS_ID 3 /* Touch Screen (event)*/ 67#define TOUCHS_ID 3 /* Touch Screen (event)*/
68#define EEPROM_READ_ID 4 /* (request/response) */ 68#define EEPROM_READ_ID 4 /* (request/response) */
@@ -399,31 +399,34 @@ static int h3600ts_connect(struct serio *serio, struct serio_driver *drv)
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 fail2; 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 fail3; 409 goto fail2;
410 } 410 }
411 411
412 serio_set_drvdata(serio, ts); 412 serio_set_drvdata(serio, ts);
413 413
414 err = serio_open(serio, drv); 414 err = serio_open(serio, drv);
415 if (err) 415 if (err)
416 return err; 416 goto fail3;
417 417
418 //h3600_flite_control(1, 25); /* default brightness */ 418 //h3600_flite_control(1, 25); /* default brightness */
419 input_register_device(ts->dev); 419 err = input_register_device(ts->dev);
420 if (err)
421 goto fail4;
420 422
421 return 0; 423 return 0;
422 424
423fail3: free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, ts->dev); 425fail4: serio_close(serio);
426fail3: serio_set_drvdata(serio, NULL);
427 free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, ts->dev);
424fail2: free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts->dev); 428fail2: free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts->dev);
425fail1: serio_set_drvdata(serio, NULL); 429fail1: input_free_device(input_dev);
426 input_free_device(input_dev);
427 kfree(ts); 430 kfree(ts);
428 return err; 431 return err;
429} 432}
diff --git a/drivers/input/touchscreen/intel-mid-touch.c b/drivers/input/touchscreen/intel-mid-touch.c
index c0307b22d86f..66c96bfc5522 100644
--- a/drivers/input/touchscreen/intel-mid-touch.c
+++ b/drivers/input/touchscreen/intel-mid-touch.c
@@ -542,7 +542,7 @@ static int __devinit mrstouch_adc_init(struct mrstouch_dev *tsdev)
542 * ADC power on, start, enable PENDET and set loop delay 542 * ADC power on, start, enable PENDET and set loop delay
543 * ADC loop delay is set to 4.5 ms approximately 543 * ADC loop delay is set to 4.5 ms approximately
544 * Loop delay more than this results in jitter in adc readings 544 * Loop delay more than this results in jitter in adc readings
545 * Setting loop delay to 0 (continous loop) in MAXIM stops PENDET 545 * Setting loop delay to 0 (continuous loop) in MAXIM stops PENDET
546 * interrupt generation sometimes. 546 * interrupt generation sometimes.
547 */ 547 */
548 548
diff --git a/drivers/input/touchscreen/mainstone-wm97xx.c b/drivers/input/touchscreen/mainstone-wm97xx.c
index b6b8b1c7ecea..3242e7076258 100644
--- a/drivers/input/touchscreen/mainstone-wm97xx.c
+++ b/drivers/input/touchscreen/mainstone-wm97xx.c
@@ -219,7 +219,7 @@ static int wm97xx_acc_startup(struct wm97xx *wm)
219 } 219 }
220 220
221 wm->pen_irq = gpio_to_irq(irq); 221 wm->pen_irq = gpio_to_irq(irq);
222 set_irq_type(wm->pen_irq, IRQ_TYPE_EDGE_BOTH); 222 irq_set_irq_type(wm->pen_irq, IRQ_TYPE_EDGE_BOTH);
223 } else /* pen irq not supported */ 223 } else /* pen irq not supported */
224 pen_int = 0; 224 pen_int = 0;
225 225
diff --git a/drivers/input/touchscreen/qt602240_ts.c b/drivers/input/touchscreen/qt602240_ts.c
deleted file mode 100644
index 4dcb0e872f6a..000000000000
--- a/drivers/input/touchscreen/qt602240_ts.c
+++ /dev/null
@@ -1,1406 +0,0 @@
1/*
2 * AT42QT602240/ATMXT224 Touchscreen driver
3 *
4 * Copyright (C) 2010 Samsung Electronics Co.Ltd
5 * Author: Joonyoung Shim <jy0922.shim@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 */
13
14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/delay.h>
17#include <linux/firmware.h>
18#include <linux/i2c.h>
19#include <linux/i2c/qt602240_ts.h>
20#include <linux/input.h>
21#include <linux/interrupt.h>
22#include <linux/slab.h>
23
24/* Version */
25#define QT602240_VER_20 20
26#define QT602240_VER_21 21
27#define QT602240_VER_22 22
28
29/* Slave addresses */
30#define QT602240_APP_LOW 0x4a
31#define QT602240_APP_HIGH 0x4b
32#define QT602240_BOOT_LOW 0x24
33#define QT602240_BOOT_HIGH 0x25
34
35/* Firmware */
36#define QT602240_FW_NAME "qt602240.fw"
37
38/* Registers */
39#define QT602240_FAMILY_ID 0x00
40#define QT602240_VARIANT_ID 0x01
41#define QT602240_VERSION 0x02
42#define QT602240_BUILD 0x03
43#define QT602240_MATRIX_X_SIZE 0x04
44#define QT602240_MATRIX_Y_SIZE 0x05
45#define QT602240_OBJECT_NUM 0x06
46#define QT602240_OBJECT_START 0x07
47
48#define QT602240_OBJECT_SIZE 6
49
50/* Object types */
51#define QT602240_DEBUG_DIAGNOSTIC 37
52#define QT602240_GEN_MESSAGE 5
53#define QT602240_GEN_COMMAND 6
54#define QT602240_GEN_POWER 7
55#define QT602240_GEN_ACQUIRE 8
56#define QT602240_TOUCH_MULTI 9
57#define QT602240_TOUCH_KEYARRAY 15
58#define QT602240_TOUCH_PROXIMITY 23
59#define QT602240_PROCI_GRIPFACE 20
60#define QT602240_PROCG_NOISE 22
61#define QT602240_PROCI_ONETOUCH 24
62#define QT602240_PROCI_TWOTOUCH 27
63#define QT602240_SPT_COMMSCONFIG 18 /* firmware ver 21 over */
64#define QT602240_SPT_GPIOPWM 19
65#define QT602240_SPT_SELFTEST 25
66#define QT602240_SPT_CTECONFIG 28
67#define QT602240_SPT_USERDATA 38 /* firmware ver 21 over */
68
69/* QT602240_GEN_COMMAND field */
70#define QT602240_COMMAND_RESET 0
71#define QT602240_COMMAND_BACKUPNV 1
72#define QT602240_COMMAND_CALIBRATE 2
73#define QT602240_COMMAND_REPORTALL 3
74#define QT602240_COMMAND_DIAGNOSTIC 5
75
76/* QT602240_GEN_POWER field */
77#define QT602240_POWER_IDLEACQINT 0
78#define QT602240_POWER_ACTVACQINT 1
79#define QT602240_POWER_ACTV2IDLETO 2
80
81/* QT602240_GEN_ACQUIRE field */
82#define QT602240_ACQUIRE_CHRGTIME 0
83#define QT602240_ACQUIRE_TCHDRIFT 2
84#define QT602240_ACQUIRE_DRIFTST 3
85#define QT602240_ACQUIRE_TCHAUTOCAL 4
86#define QT602240_ACQUIRE_SYNC 5
87#define QT602240_ACQUIRE_ATCHCALST 6
88#define QT602240_ACQUIRE_ATCHCALSTHR 7
89
90/* QT602240_TOUCH_MULTI field */
91#define QT602240_TOUCH_CTRL 0
92#define QT602240_TOUCH_XORIGIN 1
93#define QT602240_TOUCH_YORIGIN 2
94#define QT602240_TOUCH_XSIZE 3
95#define QT602240_TOUCH_YSIZE 4
96#define QT602240_TOUCH_BLEN 6
97#define QT602240_TOUCH_TCHTHR 7
98#define QT602240_TOUCH_TCHDI 8
99#define QT602240_TOUCH_ORIENT 9
100#define QT602240_TOUCH_MOVHYSTI 11
101#define QT602240_TOUCH_MOVHYSTN 12
102#define QT602240_TOUCH_NUMTOUCH 14
103#define QT602240_TOUCH_MRGHYST 15
104#define QT602240_TOUCH_MRGTHR 16
105#define QT602240_TOUCH_AMPHYST 17
106#define QT602240_TOUCH_XRANGE_LSB 18
107#define QT602240_TOUCH_XRANGE_MSB 19
108#define QT602240_TOUCH_YRANGE_LSB 20
109#define QT602240_TOUCH_YRANGE_MSB 21
110#define QT602240_TOUCH_XLOCLIP 22
111#define QT602240_TOUCH_XHICLIP 23
112#define QT602240_TOUCH_YLOCLIP 24
113#define QT602240_TOUCH_YHICLIP 25
114#define QT602240_TOUCH_XEDGECTRL 26
115#define QT602240_TOUCH_XEDGEDIST 27
116#define QT602240_TOUCH_YEDGECTRL 28
117#define QT602240_TOUCH_YEDGEDIST 29
118#define QT602240_TOUCH_JUMPLIMIT 30 /* firmware ver 22 over */
119
120/* QT602240_PROCI_GRIPFACE field */
121#define QT602240_GRIPFACE_CTRL 0
122#define QT602240_GRIPFACE_XLOGRIP 1
123#define QT602240_GRIPFACE_XHIGRIP 2
124#define QT602240_GRIPFACE_YLOGRIP 3
125#define QT602240_GRIPFACE_YHIGRIP 4
126#define QT602240_GRIPFACE_MAXTCHS 5
127#define QT602240_GRIPFACE_SZTHR1 7
128#define QT602240_GRIPFACE_SZTHR2 8
129#define QT602240_GRIPFACE_SHPTHR1 9
130#define QT602240_GRIPFACE_SHPTHR2 10
131#define QT602240_GRIPFACE_SUPEXTTO 11
132
133/* QT602240_PROCI_NOISE field */
134#define QT602240_NOISE_CTRL 0
135#define QT602240_NOISE_OUTFLEN 1
136#define QT602240_NOISE_GCAFUL_LSB 3
137#define QT602240_NOISE_GCAFUL_MSB 4
138#define QT602240_NOISE_GCAFLL_LSB 5
139#define QT602240_NOISE_GCAFLL_MSB 6
140#define QT602240_NOISE_ACTVGCAFVALID 7
141#define QT602240_NOISE_NOISETHR 8
142#define QT602240_NOISE_FREQHOPSCALE 10
143#define QT602240_NOISE_FREQ0 11
144#define QT602240_NOISE_FREQ1 12
145#define QT602240_NOISE_FREQ2 13
146#define QT602240_NOISE_FREQ3 14
147#define QT602240_NOISE_FREQ4 15
148#define QT602240_NOISE_IDLEGCAFVALID 16
149
150/* QT602240_SPT_COMMSCONFIG */
151#define QT602240_COMMS_CTRL 0
152#define QT602240_COMMS_CMD 1
153
154/* QT602240_SPT_CTECONFIG field */
155#define QT602240_CTE_CTRL 0
156#define QT602240_CTE_CMD 1
157#define QT602240_CTE_MODE 2
158#define QT602240_CTE_IDLEGCAFDEPTH 3
159#define QT602240_CTE_ACTVGCAFDEPTH 4
160#define QT602240_CTE_VOLTAGE 5 /* firmware ver 21 over */
161
162#define QT602240_VOLTAGE_DEFAULT 2700000
163#define QT602240_VOLTAGE_STEP 10000
164
165/* Define for QT602240_GEN_COMMAND */
166#define QT602240_BOOT_VALUE 0xa5
167#define QT602240_BACKUP_VALUE 0x55
168#define QT602240_BACKUP_TIME 25 /* msec */
169#define QT602240_RESET_TIME 65 /* msec */
170
171#define QT602240_FWRESET_TIME 175 /* msec */
172
173/* Command to unlock bootloader */
174#define QT602240_UNLOCK_CMD_MSB 0xaa
175#define QT602240_UNLOCK_CMD_LSB 0xdc
176
177/* Bootloader mode status */
178#define QT602240_WAITING_BOOTLOAD_CMD 0xc0 /* valid 7 6 bit only */
179#define QT602240_WAITING_FRAME_DATA 0x80 /* valid 7 6 bit only */
180#define QT602240_FRAME_CRC_CHECK 0x02
181#define QT602240_FRAME_CRC_FAIL 0x03
182#define QT602240_FRAME_CRC_PASS 0x04
183#define QT602240_APP_CRC_FAIL 0x40 /* valid 7 8 bit only */
184#define QT602240_BOOT_STATUS_MASK 0x3f
185
186/* Touch status */
187#define QT602240_SUPPRESS (1 << 1)
188#define QT602240_AMP (1 << 2)
189#define QT602240_VECTOR (1 << 3)
190#define QT602240_MOVE (1 << 4)
191#define QT602240_RELEASE (1 << 5)
192#define QT602240_PRESS (1 << 6)
193#define QT602240_DETECT (1 << 7)
194
195/* Touchscreen absolute values */
196#define QT602240_MAX_XC 0x3ff
197#define QT602240_MAX_YC 0x3ff
198#define QT602240_MAX_AREA 0xff
199
200#define QT602240_MAX_FINGER 10
201
202/* Initial register values recommended from chip vendor */
203static const u8 init_vals_ver_20[] = {
204 /* QT602240_GEN_COMMAND(6) */
205 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
206 /* QT602240_GEN_POWER(7) */
207 0x20, 0xff, 0x32,
208 /* QT602240_GEN_ACQUIRE(8) */
209 0x08, 0x05, 0x05, 0x00, 0x00, 0x00, 0x05, 0x14,
210 /* QT602240_TOUCH_MULTI(9) */
211 0x00, 0x00, 0x00, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x02, 0x00,
212 0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00,
213 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x64,
214 /* QT602240_TOUCH_KEYARRAY(15) */
215 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
216 0x00,
217 /* QT602240_SPT_GPIOPWM(19) */
218 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
219 0x00, 0x00,
220 /* QT602240_PROCI_GRIPFACE(20) */
221 0x00, 0x64, 0x64, 0x64, 0x64, 0x00, 0x00, 0x1e, 0x14, 0x04,
222 0x1e, 0x00,
223 /* QT602240_PROCG_NOISE(22) */
224 0x05, 0x00, 0x00, 0x19, 0x00, 0xe7, 0xff, 0x04, 0x32, 0x00,
225 0x01, 0x0a, 0x0f, 0x14, 0x00, 0x00, 0xe8,
226 /* QT602240_TOUCH_PROXIMITY(23) */
227 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
228 0x00, 0x00, 0x00,
229 /* QT602240_PROCI_ONETOUCH(24) */
230 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
231 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
232 /* QT602240_SPT_SELFTEST(25) */
233 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
234 0x00, 0x00, 0x00, 0x00,
235 /* QT602240_PROCI_TWOTOUCH(27) */
236 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
237 /* QT602240_SPT_CTECONFIG(28) */
238 0x00, 0x00, 0x00, 0x04, 0x08,
239};
240
241static const u8 init_vals_ver_21[] = {
242 /* QT602240_GEN_COMMAND(6) */
243 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
244 /* QT602240_GEN_POWER(7) */
245 0x20, 0xff, 0x32,
246 /* QT602240_GEN_ACQUIRE(8) */
247 0x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x23,
248 /* QT602240_TOUCH_MULTI(9) */
249 0x00, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00,
250 0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00,
251 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
252 /* QT602240_TOUCH_KEYARRAY(15) */
253 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
254 0x00,
255 /* QT602240_SPT_GPIOPWM(19) */
256 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
257 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
258 /* QT602240_PROCI_GRIPFACE(20) */
259 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x28, 0x04,
260 0x0f, 0x0a,
261 /* QT602240_PROCG_NOISE(22) */
262 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x23, 0x00,
263 0x00, 0x05, 0x0f, 0x19, 0x23, 0x2d, 0x03,
264 /* QT602240_TOUCH_PROXIMITY(23) */
265 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
266 0x00, 0x00, 0x00,
267 /* QT602240_PROCI_ONETOUCH(24) */
268 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
269 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
270 /* QT602240_SPT_SELFTEST(25) */
271 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
272 0x00, 0x00, 0x00, 0x00,
273 /* QT602240_PROCI_TWOTOUCH(27) */
274 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
275 /* QT602240_SPT_CTECONFIG(28) */
276 0x00, 0x00, 0x00, 0x08, 0x10, 0x00,
277};
278
279static const u8 init_vals_ver_22[] = {
280 /* QT602240_GEN_COMMAND(6) */
281 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
282 /* QT602240_GEN_POWER(7) */
283 0x20, 0xff, 0x32,
284 /* QT602240_GEN_ACQUIRE(8) */
285 0x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x23,
286 /* QT602240_TOUCH_MULTI(9) */
287 0x00, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00,
288 0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00,
289 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
290 0x00,
291 /* QT602240_TOUCH_KEYARRAY(15) */
292 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
293 0x00,
294 /* QT602240_SPT_GPIOPWM(19) */
295 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
296 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
297 /* QT602240_PROCI_GRIPFACE(20) */
298 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x28, 0x04,
299 0x0f, 0x0a,
300 /* QT602240_PROCG_NOISE(22) */
301 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x23, 0x00,
302 0x00, 0x05, 0x0f, 0x19, 0x23, 0x2d, 0x03,
303 /* QT602240_TOUCH_PROXIMITY(23) */
304 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
305 0x00, 0x00, 0x00, 0x00, 0x00,
306 /* QT602240_PROCI_ONETOUCH(24) */
307 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
308 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
309 /* QT602240_SPT_SELFTEST(25) */
310 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
311 0x00, 0x00, 0x00, 0x00,
312 /* QT602240_PROCI_TWOTOUCH(27) */
313 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
314 /* QT602240_SPT_CTECONFIG(28) */
315 0x00, 0x00, 0x00, 0x08, 0x10, 0x00,
316};
317
318struct qt602240_info {
319 u8 family_id;
320 u8 variant_id;
321 u8 version;
322 u8 build;
323 u8 matrix_xsize;
324 u8 matrix_ysize;
325 u8 object_num;
326};
327
328struct qt602240_object {
329 u8 type;
330 u16 start_address;
331 u8 size;
332 u8 instances;
333 u8 num_report_ids;
334
335 /* to map object and message */
336 u8 max_reportid;
337};
338
339struct qt602240_message {
340 u8 reportid;
341 u8 message[7];
342 u8 checksum;
343};
344
345struct qt602240_finger {
346 int status;
347 int x;
348 int y;
349 int area;
350};
351
352/* Each client has this additional data */
353struct qt602240_data {
354 struct i2c_client *client;
355 struct input_dev *input_dev;
356 const struct qt602240_platform_data *pdata;
357 struct qt602240_object *object_table;
358 struct qt602240_info info;
359 struct qt602240_finger finger[QT602240_MAX_FINGER];
360 unsigned int irq;
361};
362
363static bool qt602240_object_readable(unsigned int type)
364{
365 switch (type) {
366 case QT602240_GEN_MESSAGE:
367 case QT602240_GEN_COMMAND:
368 case QT602240_GEN_POWER:
369 case QT602240_GEN_ACQUIRE:
370 case QT602240_TOUCH_MULTI:
371 case QT602240_TOUCH_KEYARRAY:
372 case QT602240_TOUCH_PROXIMITY:
373 case QT602240_PROCI_GRIPFACE:
374 case QT602240_PROCG_NOISE:
375 case QT602240_PROCI_ONETOUCH:
376 case QT602240_PROCI_TWOTOUCH:
377 case QT602240_SPT_COMMSCONFIG:
378 case QT602240_SPT_GPIOPWM:
379 case QT602240_SPT_SELFTEST:
380 case QT602240_SPT_CTECONFIG:
381 case QT602240_SPT_USERDATA:
382 return true;
383 default:
384 return false;
385 }
386}
387
388static bool qt602240_object_writable(unsigned int type)
389{
390 switch (type) {
391 case QT602240_GEN_COMMAND:
392 case QT602240_GEN_POWER:
393 case QT602240_GEN_ACQUIRE:
394 case QT602240_TOUCH_MULTI:
395 case QT602240_TOUCH_KEYARRAY:
396 case QT602240_TOUCH_PROXIMITY:
397 case QT602240_PROCI_GRIPFACE:
398 case QT602240_PROCG_NOISE:
399 case QT602240_PROCI_ONETOUCH:
400 case QT602240_PROCI_TWOTOUCH:
401 case QT602240_SPT_GPIOPWM:
402 case QT602240_SPT_SELFTEST:
403 case QT602240_SPT_CTECONFIG:
404 return true;
405 default:
406 return false;
407 }
408}
409
410static void qt602240_dump_message(struct device *dev,
411 struct qt602240_message *message)
412{
413 dev_dbg(dev, "reportid:\t0x%x\n", message->reportid);
414 dev_dbg(dev, "message1:\t0x%x\n", message->message[0]);
415 dev_dbg(dev, "message2:\t0x%x\n", message->message[1]);
416 dev_dbg(dev, "message3:\t0x%x\n", message->message[2]);
417 dev_dbg(dev, "message4:\t0x%x\n", message->message[3]);
418 dev_dbg(dev, "message5:\t0x%x\n", message->message[4]);
419 dev_dbg(dev, "message6:\t0x%x\n", message->message[5]);
420 dev_dbg(dev, "message7:\t0x%x\n", message->message[6]);
421 dev_dbg(dev, "checksum:\t0x%x\n", message->checksum);
422}
423
424static int qt602240_check_bootloader(struct i2c_client *client,
425 unsigned int state)
426{
427 u8 val;
428
429recheck:
430 if (i2c_master_recv(client, &val, 1) != 1) {
431 dev_err(&client->dev, "%s: i2c recv failed\n", __func__);
432 return -EIO;
433 }
434
435 switch (state) {
436 case QT602240_WAITING_BOOTLOAD_CMD:
437 case QT602240_WAITING_FRAME_DATA:
438 val &= ~QT602240_BOOT_STATUS_MASK;
439 break;
440 case QT602240_FRAME_CRC_PASS:
441 if (val == QT602240_FRAME_CRC_CHECK)
442 goto recheck;
443 break;
444 default:
445 return -EINVAL;
446 }
447
448 if (val != state) {
449 dev_err(&client->dev, "Unvalid bootloader mode state\n");
450 return -EINVAL;
451 }
452
453 return 0;
454}
455
456static int qt602240_unlock_bootloader(struct i2c_client *client)
457{
458 u8 buf[2];
459
460 buf[0] = QT602240_UNLOCK_CMD_LSB;
461 buf[1] = QT602240_UNLOCK_CMD_MSB;
462
463 if (i2c_master_send(client, buf, 2) != 2) {
464 dev_err(&client->dev, "%s: i2c send failed\n", __func__);
465 return -EIO;
466 }
467
468 return 0;
469}
470
471static int qt602240_fw_write(struct i2c_client *client,
472 const u8 *data, unsigned int frame_size)
473{
474 if (i2c_master_send(client, data, frame_size) != frame_size) {
475 dev_err(&client->dev, "%s: i2c send failed\n", __func__);
476 return -EIO;
477 }
478
479 return 0;
480}
481
482static int __qt602240_read_reg(struct i2c_client *client,
483 u16 reg, u16 len, void *val)
484{
485 struct i2c_msg xfer[2];
486 u8 buf[2];
487
488 buf[0] = reg & 0xff;
489 buf[1] = (reg >> 8) & 0xff;
490
491 /* Write register */
492 xfer[0].addr = client->addr;
493 xfer[0].flags = 0;
494 xfer[0].len = 2;
495 xfer[0].buf = buf;
496
497 /* Read data */
498 xfer[1].addr = client->addr;
499 xfer[1].flags = I2C_M_RD;
500 xfer[1].len = len;
501 xfer[1].buf = val;
502
503 if (i2c_transfer(client->adapter, xfer, 2) != 2) {
504 dev_err(&client->dev, "%s: i2c transfer failed\n", __func__);
505 return -EIO;
506 }
507
508 return 0;
509}
510
511static int qt602240_read_reg(struct i2c_client *client, u16 reg, u8 *val)
512{
513 return __qt602240_read_reg(client, reg, 1, val);
514}
515
516static int qt602240_write_reg(struct i2c_client *client, u16 reg, u8 val)
517{
518 u8 buf[3];
519
520 buf[0] = reg & 0xff;
521 buf[1] = (reg >> 8) & 0xff;
522 buf[2] = val;
523
524 if (i2c_master_send(client, buf, 3) != 3) {
525 dev_err(&client->dev, "%s: i2c send failed\n", __func__);
526 return -EIO;
527 }
528
529 return 0;
530}
531
532static int qt602240_read_object_table(struct i2c_client *client,
533 u16 reg, u8 *object_buf)
534{
535 return __qt602240_read_reg(client, reg, QT602240_OBJECT_SIZE,
536 object_buf);
537}
538
539static struct qt602240_object *
540qt602240_get_object(struct qt602240_data *data, u8 type)
541{
542 struct qt602240_object *object;
543 int i;
544
545 for (i = 0; i < data->info.object_num; i++) {
546 object = data->object_table + i;
547 if (object->type == type)
548 return object;
549 }
550
551 dev_err(&data->client->dev, "Invalid object type\n");
552 return NULL;
553}
554
555static int qt602240_read_message(struct qt602240_data *data,
556 struct qt602240_message *message)
557{
558 struct qt602240_object *object;
559 u16 reg;
560
561 object = qt602240_get_object(data, QT602240_GEN_MESSAGE);
562 if (!object)
563 return -EINVAL;
564
565 reg = object->start_address;
566 return __qt602240_read_reg(data->client, reg,
567 sizeof(struct qt602240_message), message);
568}
569
570static int qt602240_read_object(struct qt602240_data *data,
571 u8 type, u8 offset, u8 *val)
572{
573 struct qt602240_object *object;
574 u16 reg;
575
576 object = qt602240_get_object(data, type);
577 if (!object)
578 return -EINVAL;
579
580 reg = object->start_address;
581 return __qt602240_read_reg(data->client, reg + offset, 1, val);
582}
583
584static int qt602240_write_object(struct qt602240_data *data,
585 u8 type, u8 offset, u8 val)
586{
587 struct qt602240_object *object;
588 u16 reg;
589
590 object = qt602240_get_object(data, type);
591 if (!object)
592 return -EINVAL;
593
594 reg = object->start_address;
595 return qt602240_write_reg(data->client, reg + offset, val);
596}
597
598static void qt602240_input_report(struct qt602240_data *data, int single_id)
599{
600 struct qt602240_finger *finger = data->finger;
601 struct input_dev *input_dev = data->input_dev;
602 int status = finger[single_id].status;
603 int finger_num = 0;
604 int id;
605
606 for (id = 0; id < QT602240_MAX_FINGER; id++) {
607 if (!finger[id].status)
608 continue;
609
610 input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR,
611 finger[id].status != QT602240_RELEASE ?
612 finger[id].area : 0);
613 input_report_abs(input_dev, ABS_MT_POSITION_X,
614 finger[id].x);
615 input_report_abs(input_dev, ABS_MT_POSITION_Y,
616 finger[id].y);
617 input_mt_sync(input_dev);
618
619 if (finger[id].status == QT602240_RELEASE)
620 finger[id].status = 0;
621 else
622 finger_num++;
623 }
624
625 input_report_key(input_dev, BTN_TOUCH, finger_num > 0);
626
627 if (status != QT602240_RELEASE) {
628 input_report_abs(input_dev, ABS_X, finger[single_id].x);
629 input_report_abs(input_dev, ABS_Y, finger[single_id].y);
630 }
631
632 input_sync(input_dev);
633}
634
635static void qt602240_input_touchevent(struct qt602240_data *data,
636 struct qt602240_message *message, int id)
637{
638 struct qt602240_finger *finger = data->finger;
639 struct device *dev = &data->client->dev;
640 u8 status = message->message[0];
641 int x;
642 int y;
643 int area;
644
645 /* Check the touch is present on the screen */
646 if (!(status & QT602240_DETECT)) {
647 if (status & QT602240_RELEASE) {
648 dev_dbg(dev, "[%d] released\n", id);
649
650 finger[id].status = QT602240_RELEASE;
651 qt602240_input_report(data, id);
652 }
653 return;
654 }
655
656 /* Check only AMP detection */
657 if (!(status & (QT602240_PRESS | QT602240_MOVE)))
658 return;
659
660 x = (message->message[1] << 2) | ((message->message[3] & ~0x3f) >> 6);
661 y = (message->message[2] << 2) | ((message->message[3] & ~0xf3) >> 2);
662 area = message->message[4];
663
664 dev_dbg(dev, "[%d] %s x: %d, y: %d, area: %d\n", id,
665 status & QT602240_MOVE ? "moved" : "pressed",
666 x, y, area);
667
668 finger[id].status = status & QT602240_MOVE ?
669 QT602240_MOVE : QT602240_PRESS;
670 finger[id].x = x;
671 finger[id].y = y;
672 finger[id].area = area;
673
674 qt602240_input_report(data, id);
675}
676
677static irqreturn_t qt602240_interrupt(int irq, void *dev_id)
678{
679 struct qt602240_data *data = dev_id;
680 struct qt602240_message message;
681 struct qt602240_object *object;
682 struct device *dev = &data->client->dev;
683 int id;
684 u8 reportid;
685 u8 max_reportid;
686 u8 min_reportid;
687
688 do {
689 if (qt602240_read_message(data, &message)) {
690 dev_err(dev, "Failed to read message\n");
691 goto end;
692 }
693
694 reportid = message.reportid;
695
696 /* whether reportid is thing of QT602240_TOUCH_MULTI */
697 object = qt602240_get_object(data, QT602240_TOUCH_MULTI);
698 if (!object)
699 goto end;
700
701 max_reportid = object->max_reportid;
702 min_reportid = max_reportid - object->num_report_ids + 1;
703 id = reportid - min_reportid;
704
705 if (reportid >= min_reportid && reportid <= max_reportid)
706 qt602240_input_touchevent(data, &message, id);
707 else
708 qt602240_dump_message(dev, &message);
709 } while (reportid != 0xff);
710
711end:
712 return IRQ_HANDLED;
713}
714
715static int qt602240_check_reg_init(struct qt602240_data *data)
716{
717 struct qt602240_object *object;
718 struct device *dev = &data->client->dev;
719 int index = 0;
720 int i, j;
721 u8 version = data->info.version;
722 u8 *init_vals;
723
724 switch (version) {
725 case QT602240_VER_20:
726 init_vals = (u8 *)init_vals_ver_20;
727 break;
728 case QT602240_VER_21:
729 init_vals = (u8 *)init_vals_ver_21;
730 break;
731 case QT602240_VER_22:
732 init_vals = (u8 *)init_vals_ver_22;
733 break;
734 default:
735 dev_err(dev, "Firmware version %d doesn't support\n", version);
736 return -EINVAL;
737 }
738
739 for (i = 0; i < data->info.object_num; i++) {
740 object = data->object_table + i;
741
742 if (!qt602240_object_writable(object->type))
743 continue;
744
745 for (j = 0; j < object->size + 1; j++)
746 qt602240_write_object(data, object->type, j,
747 init_vals[index + j]);
748
749 index += object->size + 1;
750 }
751
752 return 0;
753}
754
755static int qt602240_check_matrix_size(struct qt602240_data *data)
756{
757 const struct qt602240_platform_data *pdata = data->pdata;
758 struct device *dev = &data->client->dev;
759 int mode = -1;
760 int error;
761 u8 val;
762
763 dev_dbg(dev, "Number of X lines: %d\n", pdata->x_line);
764 dev_dbg(dev, "Number of Y lines: %d\n", pdata->y_line);
765
766 switch (pdata->x_line) {
767 case 0 ... 15:
768 if (pdata->y_line <= 14)
769 mode = 0;
770 break;
771 case 16:
772 if (pdata->y_line <= 12)
773 mode = 1;
774 if (pdata->y_line == 13 || pdata->y_line == 14)
775 mode = 0;
776 break;
777 case 17:
778 if (pdata->y_line <= 11)
779 mode = 2;
780 if (pdata->y_line == 12 || pdata->y_line == 13)
781 mode = 1;
782 break;
783 case 18:
784 if (pdata->y_line <= 10)
785 mode = 3;
786 if (pdata->y_line == 11 || pdata->y_line == 12)
787 mode = 2;
788 break;
789 case 19:
790 if (pdata->y_line <= 9)
791 mode = 4;
792 if (pdata->y_line == 10 || pdata->y_line == 11)
793 mode = 3;
794 break;
795 case 20:
796 mode = 4;
797 }
798
799 if (mode < 0) {
800 dev_err(dev, "Invalid X/Y lines\n");
801 return -EINVAL;
802 }
803
804 error = qt602240_read_object(data, QT602240_SPT_CTECONFIG,
805 QT602240_CTE_MODE, &val);
806 if (error)
807 return error;
808
809 if (mode == val)
810 return 0;
811
812 /* Change the CTE configuration */
813 qt602240_write_object(data, QT602240_SPT_CTECONFIG,
814 QT602240_CTE_CTRL, 1);
815 qt602240_write_object(data, QT602240_SPT_CTECONFIG,
816 QT602240_CTE_MODE, mode);
817 qt602240_write_object(data, QT602240_SPT_CTECONFIG,
818 QT602240_CTE_CTRL, 0);
819
820 return 0;
821}
822
823static int qt602240_make_highchg(struct qt602240_data *data)
824{
825 struct device *dev = &data->client->dev;
826 int count = 10;
827 int error;
828 u8 val;
829
830 /* Read dummy message to make high CHG pin */
831 do {
832 error = qt602240_read_object(data, QT602240_GEN_MESSAGE, 0, &val);
833 if (error)
834 return error;
835 } while ((val != 0xff) && --count);
836
837 if (!count) {
838 dev_err(dev, "CHG pin isn't cleared\n");
839 return -EBUSY;
840 }
841
842 return 0;
843}
844
845static void qt602240_handle_pdata(struct qt602240_data *data)
846{
847 const struct qt602240_platform_data *pdata = data->pdata;
848 u8 voltage;
849
850 /* Set touchscreen lines */
851 qt602240_write_object(data, QT602240_TOUCH_MULTI, QT602240_TOUCH_XSIZE,
852 pdata->x_line);
853 qt602240_write_object(data, QT602240_TOUCH_MULTI, QT602240_TOUCH_YSIZE,
854 pdata->y_line);
855
856 /* Set touchscreen orient */
857 qt602240_write_object(data, QT602240_TOUCH_MULTI, QT602240_TOUCH_ORIENT,
858 pdata->orient);
859
860 /* Set touchscreen burst length */
861 qt602240_write_object(data, QT602240_TOUCH_MULTI,
862 QT602240_TOUCH_BLEN, pdata->blen);
863
864 /* Set touchscreen threshold */
865 qt602240_write_object(data, QT602240_TOUCH_MULTI,
866 QT602240_TOUCH_TCHTHR, pdata->threshold);
867
868 /* Set touchscreen resolution */
869 qt602240_write_object(data, QT602240_TOUCH_MULTI,
870 QT602240_TOUCH_XRANGE_LSB, (pdata->x_size - 1) & 0xff);
871 qt602240_write_object(data, QT602240_TOUCH_MULTI,
872 QT602240_TOUCH_XRANGE_MSB, (pdata->x_size - 1) >> 8);
873 qt602240_write_object(data, QT602240_TOUCH_MULTI,
874 QT602240_TOUCH_YRANGE_LSB, (pdata->y_size - 1) & 0xff);
875 qt602240_write_object(data, QT602240_TOUCH_MULTI,
876 QT602240_TOUCH_YRANGE_MSB, (pdata->y_size - 1) >> 8);
877
878 /* Set touchscreen voltage */
879 if (data->info.version >= QT602240_VER_21 && pdata->voltage) {
880 if (pdata->voltage < QT602240_VOLTAGE_DEFAULT) {
881 voltage = (QT602240_VOLTAGE_DEFAULT - pdata->voltage) /
882 QT602240_VOLTAGE_STEP;
883 voltage = 0xff - voltage + 1;
884 } else
885 voltage = (pdata->voltage - QT602240_VOLTAGE_DEFAULT) /
886 QT602240_VOLTAGE_STEP;
887
888 qt602240_write_object(data, QT602240_SPT_CTECONFIG,
889 QT602240_CTE_VOLTAGE, voltage);
890 }
891}
892
893static int qt602240_get_info(struct qt602240_data *data)
894{
895 struct i2c_client *client = data->client;
896 struct qt602240_info *info = &data->info;
897 int error;
898 u8 val;
899
900 error = qt602240_read_reg(client, QT602240_FAMILY_ID, &val);
901 if (error)
902 return error;
903 info->family_id = val;
904
905 error = qt602240_read_reg(client, QT602240_VARIANT_ID, &val);
906 if (error)
907 return error;
908 info->variant_id = val;
909
910 error = qt602240_read_reg(client, QT602240_VERSION, &val);
911 if (error)
912 return error;
913 info->version = val;
914
915 error = qt602240_read_reg(client, QT602240_BUILD, &val);
916 if (error)
917 return error;
918 info->build = val;
919
920 error = qt602240_read_reg(client, QT602240_OBJECT_NUM, &val);
921 if (error)
922 return error;
923 info->object_num = val;
924
925 return 0;
926}
927
928static int qt602240_get_object_table(struct qt602240_data *data)
929{
930 int error;
931 int i;
932 u16 reg;
933 u8 reportid = 0;
934 u8 buf[QT602240_OBJECT_SIZE];
935
936 for (i = 0; i < data->info.object_num; i++) {
937 struct qt602240_object *object = data->object_table + i;
938
939 reg = QT602240_OBJECT_START + QT602240_OBJECT_SIZE * i;
940 error = qt602240_read_object_table(data->client, reg, buf);
941 if (error)
942 return error;
943
944 object->type = buf[0];
945 object->start_address = (buf[2] << 8) | buf[1];
946 object->size = buf[3];
947 object->instances = buf[4];
948 object->num_report_ids = buf[5];
949
950 if (object->num_report_ids) {
951 reportid += object->num_report_ids *
952 (object->instances + 1);
953 object->max_reportid = reportid;
954 }
955 }
956
957 return 0;
958}
959
960static int qt602240_initialize(struct qt602240_data *data)
961{
962 struct i2c_client *client = data->client;
963 struct qt602240_info *info = &data->info;
964 int error;
965 u8 val;
966
967 error = qt602240_get_info(data);
968 if (error)
969 return error;
970
971 data->object_table = kcalloc(info->object_num,
972 sizeof(struct qt602240_object),
973 GFP_KERNEL);
974 if (!data->object_table) {
975 dev_err(&client->dev, "Failed to allocate memory\n");
976 return -ENOMEM;
977 }
978
979 /* Get object table information */
980 error = qt602240_get_object_table(data);
981 if (error)
982 return error;
983
984 /* Check register init values */
985 error = qt602240_check_reg_init(data);
986 if (error)
987 return error;
988
989 /* Check X/Y matrix size */
990 error = qt602240_check_matrix_size(data);
991 if (error)
992 return error;
993
994 error = qt602240_make_highchg(data);
995 if (error)
996 return error;
997
998 qt602240_handle_pdata(data);
999
1000 /* Backup to memory */
1001 qt602240_write_object(data, QT602240_GEN_COMMAND,
1002 QT602240_COMMAND_BACKUPNV,
1003 QT602240_BACKUP_VALUE);
1004 msleep(QT602240_BACKUP_TIME);
1005
1006 /* Soft reset */
1007 qt602240_write_object(data, QT602240_GEN_COMMAND,
1008 QT602240_COMMAND_RESET, 1);
1009 msleep(QT602240_RESET_TIME);
1010
1011 /* Update matrix size at info struct */
1012 error = qt602240_read_reg(client, QT602240_MATRIX_X_SIZE, &val);
1013 if (error)
1014 return error;
1015 info->matrix_xsize = val;
1016
1017 error = qt602240_read_reg(client, QT602240_MATRIX_Y_SIZE, &val);
1018 if (error)
1019 return error;
1020 info->matrix_ysize = val;
1021
1022 dev_info(&client->dev,
1023 "Family ID: %d Variant ID: %d Version: %d Build: %d\n",
1024 info->family_id, info->variant_id, info->version,
1025 info->build);
1026
1027 dev_info(&client->dev,
1028 "Matrix X Size: %d Matrix Y Size: %d Object Num: %d\n",
1029 info->matrix_xsize, info->matrix_ysize,
1030 info->object_num);
1031
1032 return 0;
1033}
1034
1035static ssize_t qt602240_object_show(struct device *dev,
1036 struct device_attribute *attr, char *buf)
1037{
1038 struct qt602240_data *data = dev_get_drvdata(dev);
1039 struct qt602240_object *object;
1040 int count = 0;
1041 int i, j;
1042 int error;
1043 u8 val;
1044
1045 for (i = 0; i < data->info.object_num; i++) {
1046 object = data->object_table + i;
1047
1048 count += sprintf(buf + count,
1049 "Object Table Element %d(Type %d)\n",
1050 i + 1, object->type);
1051
1052 if (!qt602240_object_readable(object->type)) {
1053 count += sprintf(buf + count, "\n");
1054 continue;
1055 }
1056
1057 for (j = 0; j < object->size + 1; j++) {
1058 error = qt602240_read_object(data,
1059 object->type, j, &val);
1060 if (error)
1061 return error;
1062
1063 count += sprintf(buf + count,
1064 " Byte %d: 0x%x (%d)\n", j, val, val);
1065 }
1066
1067 count += sprintf(buf + count, "\n");
1068 }
1069
1070 return count;
1071}
1072
1073static int qt602240_load_fw(struct device *dev, const char *fn)
1074{
1075 struct qt602240_data *data = dev_get_drvdata(dev);
1076 struct i2c_client *client = data->client;
1077 const struct firmware *fw = NULL;
1078 unsigned int frame_size;
1079 unsigned int pos = 0;
1080 int ret;
1081
1082 ret = request_firmware(&fw, fn, dev);
1083 if (ret) {
1084 dev_err(dev, "Unable to open firmware %s\n", fn);
1085 return ret;
1086 }
1087
1088 /* Change to the bootloader mode */
1089 qt602240_write_object(data, QT602240_GEN_COMMAND,
1090 QT602240_COMMAND_RESET, QT602240_BOOT_VALUE);
1091 msleep(QT602240_RESET_TIME);
1092
1093 /* Change to slave address of bootloader */
1094 if (client->addr == QT602240_APP_LOW)
1095 client->addr = QT602240_BOOT_LOW;
1096 else
1097 client->addr = QT602240_BOOT_HIGH;
1098
1099 ret = qt602240_check_bootloader(client, QT602240_WAITING_BOOTLOAD_CMD);
1100 if (ret)
1101 goto out;
1102
1103 /* Unlock bootloader */
1104 qt602240_unlock_bootloader(client);
1105
1106 while (pos < fw->size) {
1107 ret = qt602240_check_bootloader(client,
1108 QT602240_WAITING_FRAME_DATA);
1109 if (ret)
1110 goto out;
1111
1112 frame_size = ((*(fw->data + pos) << 8) | *(fw->data + pos + 1));
1113
1114 /* We should add 2 at frame size as the the firmware data is not
1115 * included the CRC bytes.
1116 */
1117 frame_size += 2;
1118
1119 /* Write one frame to device */
1120 qt602240_fw_write(client, fw->data + pos, frame_size);
1121
1122 ret = qt602240_check_bootloader(client,
1123 QT602240_FRAME_CRC_PASS);
1124 if (ret)
1125 goto out;
1126
1127 pos += frame_size;
1128
1129 dev_dbg(dev, "Updated %d bytes / %zd bytes\n", pos, fw->size);
1130 }
1131
1132out:
1133 release_firmware(fw);
1134
1135 /* Change to slave address of application */
1136 if (client->addr == QT602240_BOOT_LOW)
1137 client->addr = QT602240_APP_LOW;
1138 else
1139 client->addr = QT602240_APP_HIGH;
1140
1141 return ret;
1142}
1143
1144static ssize_t qt602240_update_fw_store(struct device *dev,
1145 struct device_attribute *attr,
1146 const char *buf, size_t count)
1147{
1148 struct qt602240_data *data = dev_get_drvdata(dev);
1149 unsigned int version;
1150 int error;
1151
1152 if (sscanf(buf, "%u", &version) != 1) {
1153 dev_err(dev, "Invalid values\n");
1154 return -EINVAL;
1155 }
1156
1157 if (data->info.version < QT602240_VER_21 || version < QT602240_VER_21) {
1158 dev_err(dev, "FW update supported starting with version 21\n");
1159 return -EINVAL;
1160 }
1161
1162 disable_irq(data->irq);
1163
1164 error = qt602240_load_fw(dev, QT602240_FW_NAME);
1165 if (error) {
1166 dev_err(dev, "The firmware update failed(%d)\n", error);
1167 count = error;
1168 } else {
1169 dev_dbg(dev, "The firmware update succeeded\n");
1170
1171 /* Wait for reset */
1172 msleep(QT602240_FWRESET_TIME);
1173
1174 kfree(data->object_table);
1175 data->object_table = NULL;
1176
1177 qt602240_initialize(data);
1178 }
1179
1180 enable_irq(data->irq);
1181
1182 return count;
1183}
1184
1185static DEVICE_ATTR(object, 0444, qt602240_object_show, NULL);
1186static DEVICE_ATTR(update_fw, 0664, NULL, qt602240_update_fw_store);
1187
1188static struct attribute *qt602240_attrs[] = {
1189 &dev_attr_object.attr,
1190 &dev_attr_update_fw.attr,
1191 NULL
1192};
1193
1194static const struct attribute_group qt602240_attr_group = {
1195 .attrs = qt602240_attrs,
1196};
1197
1198static void qt602240_start(struct qt602240_data *data)
1199{
1200 /* Touch enable */
1201 qt602240_write_object(data,
1202 QT602240_TOUCH_MULTI, QT602240_TOUCH_CTRL, 0x83);
1203}
1204
1205static void qt602240_stop(struct qt602240_data *data)
1206{
1207 /* Touch disable */
1208 qt602240_write_object(data,
1209 QT602240_TOUCH_MULTI, QT602240_TOUCH_CTRL, 0);
1210}
1211
1212static int qt602240_input_open(struct input_dev *dev)
1213{
1214 struct qt602240_data *data = input_get_drvdata(dev);
1215
1216 qt602240_start(data);
1217
1218 return 0;
1219}
1220
1221static void qt602240_input_close(struct input_dev *dev)
1222{
1223 struct qt602240_data *data = input_get_drvdata(dev);
1224
1225 qt602240_stop(data);
1226}
1227
1228static int __devinit qt602240_probe(struct i2c_client *client,
1229 const struct i2c_device_id *id)
1230{
1231 struct qt602240_data *data;
1232 struct input_dev *input_dev;
1233 int error;
1234
1235 if (!client->dev.platform_data)
1236 return -EINVAL;
1237
1238 data = kzalloc(sizeof(struct qt602240_data), GFP_KERNEL);
1239 input_dev = input_allocate_device();
1240 if (!data || !input_dev) {
1241 dev_err(&client->dev, "Failed to allocate memory\n");
1242 error = -ENOMEM;
1243 goto err_free_mem;
1244 }
1245
1246 input_dev->name = "AT42QT602240/ATMXT224 Touchscreen";
1247 input_dev->id.bustype = BUS_I2C;
1248 input_dev->dev.parent = &client->dev;
1249 input_dev->open = qt602240_input_open;
1250 input_dev->close = qt602240_input_close;
1251
1252 __set_bit(EV_ABS, input_dev->evbit);
1253 __set_bit(EV_KEY, input_dev->evbit);
1254 __set_bit(BTN_TOUCH, input_dev->keybit);
1255
1256 /* For single touch */
1257 input_set_abs_params(input_dev, ABS_X,
1258 0, QT602240_MAX_XC, 0, 0);
1259 input_set_abs_params(input_dev, ABS_Y,
1260 0, QT602240_MAX_YC, 0, 0);
1261
1262 /* For multi touch */
1263 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
1264 0, QT602240_MAX_AREA, 0, 0);
1265 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1266 0, QT602240_MAX_XC, 0, 0);
1267 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1268 0, QT602240_MAX_YC, 0, 0);
1269
1270 input_set_drvdata(input_dev, data);
1271
1272 data->client = client;
1273 data->input_dev = input_dev;
1274 data->pdata = client->dev.platform_data;
1275 data->irq = client->irq;
1276
1277 i2c_set_clientdata(client, data);
1278
1279 error = qt602240_initialize(data);
1280 if (error)
1281 goto err_free_object;
1282
1283 error = request_threaded_irq(client->irq, NULL, qt602240_interrupt,
1284 IRQF_TRIGGER_FALLING, client->dev.driver->name, data);
1285 if (error) {
1286 dev_err(&client->dev, "Failed to register interrupt\n");
1287 goto err_free_object;
1288 }
1289
1290 error = input_register_device(input_dev);
1291 if (error)
1292 goto err_free_irq;
1293
1294 error = sysfs_create_group(&client->dev.kobj, &qt602240_attr_group);
1295 if (error)
1296 goto err_unregister_device;
1297
1298 return 0;
1299
1300err_unregister_device:
1301 input_unregister_device(input_dev);
1302 input_dev = NULL;
1303err_free_irq:
1304 free_irq(client->irq, data);
1305err_free_object:
1306 kfree(data->object_table);
1307err_free_mem:
1308 input_free_device(input_dev);
1309 kfree(data);
1310 return error;
1311}
1312
1313static int __devexit qt602240_remove(struct i2c_client *client)
1314{
1315 struct qt602240_data *data = i2c_get_clientdata(client);
1316
1317 sysfs_remove_group(&client->dev.kobj, &qt602240_attr_group);
1318 free_irq(data->irq, data);
1319 input_unregister_device(data->input_dev);
1320 kfree(data->object_table);
1321 kfree(data);
1322
1323 return 0;
1324}
1325
1326#ifdef CONFIG_PM
1327static int qt602240_suspend(struct device *dev)
1328{
1329 struct i2c_client *client = to_i2c_client(dev);
1330 struct qt602240_data *data = i2c_get_clientdata(client);
1331 struct input_dev *input_dev = data->input_dev;
1332
1333 mutex_lock(&input_dev->mutex);
1334
1335 if (input_dev->users)
1336 qt602240_stop(data);
1337
1338 mutex_unlock(&input_dev->mutex);
1339
1340 return 0;
1341}
1342
1343static int qt602240_resume(struct device *dev)
1344{
1345 struct i2c_client *client = to_i2c_client(dev);
1346 struct qt602240_data *data = i2c_get_clientdata(client);
1347 struct input_dev *input_dev = data->input_dev;
1348
1349 /* Soft reset */
1350 qt602240_write_object(data, QT602240_GEN_COMMAND,
1351 QT602240_COMMAND_RESET, 1);
1352
1353 msleep(QT602240_RESET_TIME);
1354
1355 mutex_lock(&input_dev->mutex);
1356
1357 if (input_dev->users)
1358 qt602240_start(data);
1359
1360 mutex_unlock(&input_dev->mutex);
1361
1362 return 0;
1363}
1364
1365static const struct dev_pm_ops qt602240_pm_ops = {
1366 .suspend = qt602240_suspend,
1367 .resume = qt602240_resume,
1368};
1369#endif
1370
1371static const struct i2c_device_id qt602240_id[] = {
1372 { "qt602240_ts", 0 },
1373 { }
1374};
1375MODULE_DEVICE_TABLE(i2c, qt602240_id);
1376
1377static struct i2c_driver qt602240_driver = {
1378 .driver = {
1379 .name = "qt602240_ts",
1380 .owner = THIS_MODULE,
1381#ifdef CONFIG_PM
1382 .pm = &qt602240_pm_ops,
1383#endif
1384 },
1385 .probe = qt602240_probe,
1386 .remove = __devexit_p(qt602240_remove),
1387 .id_table = qt602240_id,
1388};
1389
1390static int __init qt602240_init(void)
1391{
1392 return i2c_add_driver(&qt602240_driver);
1393}
1394
1395static void __exit qt602240_exit(void)
1396{
1397 i2c_del_driver(&qt602240_driver);
1398}
1399
1400module_init(qt602240_init);
1401module_exit(qt602240_exit);
1402
1403/* Module information */
1404MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>");
1405MODULE_DESCRIPTION("AT42QT602240/ATMXT224 Touchscreen driver");
1406MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c
new file mode 100644
index 000000000000..cbf0ff322676
--- /dev/null
+++ b/drivers/input/touchscreen/tsc2005.c
@@ -0,0 +1,764 @@
1/*
2 * TSC2005 touchscreen driver
3 *
4 * Copyright (C) 2006-2010 Nokia Corporation
5 *
6 * Author: Lauri Leukkunen <lauri.leukkunen@nokia.com>
7 * based on TSC2301 driver by Klaus K. Pedersen <klaus.k.pedersen@nokia.com>
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 as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
25#include <linux/kernel.h>
26#include <linux/module.h>
27#include <linux/input.h>
28#include <linux/interrupt.h>
29#include <linux/delay.h>
30#include <linux/pm.h>
31#include <linux/spi/spi.h>
32#include <linux/spi/tsc2005.h>
33
34/*
35 * The touchscreen interface operates as follows:
36 *
37 * 1) Pen is pressed against the touchscreen.
38 * 2) TSC2005 performs AD conversion.
39 * 3) After the conversion is done TSC2005 drives DAV line down.
40 * 4) GPIO IRQ is received and tsc2005_irq_thread() is scheduled.
41 * 5) tsc2005_irq_thread() queues up an spi transfer to fetch the x, y, z1, z2
42 * values.
43 * 6) tsc2005_irq_thread() reports coordinates to input layer and sets up
44 * tsc2005_penup_timer() to be called after TSC2005_PENUP_TIME_MS (40ms).
45 * 7) When the penup timer expires, there have not been touch or DAV interrupts
46 * during the last 40ms which means the pen has been lifted.
47 *
48 * ESD recovery via a hardware reset is done if the TSC2005 doesn't respond
49 * after a configurable period (in ms) of activity. If esd_timeout is 0, the
50 * watchdog is disabled.
51 */
52
53/* control byte 1 */
54#define TSC2005_CMD 0x80
55#define TSC2005_CMD_NORMAL 0x00
56#define TSC2005_CMD_STOP 0x01
57#define TSC2005_CMD_12BIT 0x04
58
59/* control byte 0 */
60#define TSC2005_REG_READ 0x0001
61#define TSC2005_REG_PND0 0x0002
62#define TSC2005_REG_X 0x0000
63#define TSC2005_REG_Y 0x0008
64#define TSC2005_REG_Z1 0x0010
65#define TSC2005_REG_Z2 0x0018
66#define TSC2005_REG_TEMP_HIGH 0x0050
67#define TSC2005_REG_CFR0 0x0060
68#define TSC2005_REG_CFR1 0x0068
69#define TSC2005_REG_CFR2 0x0070
70
71/* configuration register 0 */
72#define TSC2005_CFR0_PRECHARGE_276US 0x0040
73#define TSC2005_CFR0_STABTIME_1MS 0x0300
74#define TSC2005_CFR0_CLOCK_1MHZ 0x1000
75#define TSC2005_CFR0_RESOLUTION12 0x2000
76#define TSC2005_CFR0_PENMODE 0x8000
77#define TSC2005_CFR0_INITVALUE (TSC2005_CFR0_STABTIME_1MS | \
78 TSC2005_CFR0_CLOCK_1MHZ | \
79 TSC2005_CFR0_RESOLUTION12 | \
80 TSC2005_CFR0_PRECHARGE_276US | \
81 TSC2005_CFR0_PENMODE)
82
83/* bits common to both read and write of configuration register 0 */
84#define TSC2005_CFR0_RW_MASK 0x3fff
85
86/* configuration register 1 */
87#define TSC2005_CFR1_BATCHDELAY_4MS 0x0003
88#define TSC2005_CFR1_INITVALUE TSC2005_CFR1_BATCHDELAY_4MS
89
90/* configuration register 2 */
91#define TSC2005_CFR2_MAVE_Z 0x0004
92#define TSC2005_CFR2_MAVE_Y 0x0008
93#define TSC2005_CFR2_MAVE_X 0x0010
94#define TSC2005_CFR2_AVG_7 0x0800
95#define TSC2005_CFR2_MEDIUM_15 0x3000
96#define TSC2005_CFR2_INITVALUE (TSC2005_CFR2_MAVE_X | \
97 TSC2005_CFR2_MAVE_Y | \
98 TSC2005_CFR2_MAVE_Z | \
99 TSC2005_CFR2_MEDIUM_15 | \
100 TSC2005_CFR2_AVG_7)
101
102#define MAX_12BIT 0xfff
103#define TSC2005_SPI_MAX_SPEED_HZ 10000000
104#define TSC2005_PENUP_TIME_MS 40
105
106struct tsc2005_spi_rd {
107 struct spi_transfer spi_xfer;
108 u32 spi_tx;
109 u32 spi_rx;
110};
111
112struct tsc2005 {
113 struct spi_device *spi;
114
115 struct spi_message spi_read_msg;
116 struct tsc2005_spi_rd spi_x;
117 struct tsc2005_spi_rd spi_y;
118 struct tsc2005_spi_rd spi_z1;
119 struct tsc2005_spi_rd spi_z2;
120
121 struct input_dev *idev;
122 char phys[32];
123
124 struct mutex mutex;
125
126 /* raw copy of previous x,y,z */
127 int in_x;
128 int in_y;
129 int in_z1;
130 int in_z2;
131
132 spinlock_t lock;
133 struct timer_list penup_timer;
134
135 unsigned int esd_timeout;
136 struct delayed_work esd_work;
137 unsigned long last_valid_interrupt;
138
139 unsigned int x_plate_ohm;
140
141 bool opened;
142 bool suspended;
143
144 bool pen_down;
145
146 void (*set_reset)(bool enable);
147};
148
149static int tsc2005_cmd(struct tsc2005 *ts, u8 cmd)
150{
151 u8 tx = TSC2005_CMD | TSC2005_CMD_12BIT | cmd;
152 struct spi_transfer xfer = {
153 .tx_buf = &tx,
154 .len = 1,
155 .bits_per_word = 8,
156 };
157 struct spi_message msg;
158 int error;
159
160 spi_message_init(&msg);
161 spi_message_add_tail(&xfer, &msg);
162
163 error = spi_sync(ts->spi, &msg);
164 if (error) {
165 dev_err(&ts->spi->dev, "%s: failed, command: %x, error: %d\n",
166 __func__, cmd, error);
167 return error;
168 }
169
170 return 0;
171}
172
173static int tsc2005_write(struct tsc2005 *ts, u8 reg, u16 value)
174{
175 u32 tx = ((reg | TSC2005_REG_PND0) << 16) | value;
176 struct spi_transfer xfer = {
177 .tx_buf = &tx,
178 .len = 4,
179 .bits_per_word = 24,
180 };
181 struct spi_message msg;
182 int error;
183
184 spi_message_init(&msg);
185 spi_message_add_tail(&xfer, &msg);
186
187 error = spi_sync(ts->spi, &msg);
188 if (error) {
189 dev_err(&ts->spi->dev,
190 "%s: failed, register: %x, value: %x, error: %d\n",
191 __func__, reg, value, error);
192 return error;
193 }
194
195 return 0;
196}
197
198static void tsc2005_setup_read(struct tsc2005_spi_rd *rd, u8 reg, bool last)
199{
200 memset(rd, 0, sizeof(*rd));
201
202 rd->spi_tx = (reg | TSC2005_REG_READ) << 16;
203 rd->spi_xfer.tx_buf = &rd->spi_tx;
204 rd->spi_xfer.rx_buf = &rd->spi_rx;
205 rd->spi_xfer.len = 4;
206 rd->spi_xfer.bits_per_word = 24;
207 rd->spi_xfer.cs_change = !last;
208}
209
210static int tsc2005_read(struct tsc2005 *ts, u8 reg, u16 *value)
211{
212 struct tsc2005_spi_rd spi_rd;
213 struct spi_message msg;
214 int error;
215
216 tsc2005_setup_read(&spi_rd, reg, true);
217
218 spi_message_init(&msg);
219 spi_message_add_tail(&spi_rd.spi_xfer, &msg);
220
221 error = spi_sync(ts->spi, &msg);
222 if (error)
223 return error;
224
225 *value = spi_rd.spi_rx;
226 return 0;
227}
228
229static void tsc2005_update_pen_state(struct tsc2005 *ts,
230 int x, int y, int pressure)
231{
232 if (pressure) {
233 input_report_abs(ts->idev, ABS_X, x);
234 input_report_abs(ts->idev, ABS_Y, y);
235 input_report_abs(ts->idev, ABS_PRESSURE, pressure);
236 if (!ts->pen_down) {
237 input_report_key(ts->idev, BTN_TOUCH, !!pressure);
238 ts->pen_down = true;
239 }
240 } else {
241 input_report_abs(ts->idev, ABS_PRESSURE, 0);
242 if (ts->pen_down) {
243 input_report_key(ts->idev, BTN_TOUCH, 0);
244 ts->pen_down = false;
245 }
246 }
247 input_sync(ts->idev);
248 dev_dbg(&ts->spi->dev, "point(%4d,%4d), pressure (%4d)\n", x, y,
249 pressure);
250}
251
252static irqreturn_t tsc2005_irq_thread(int irq, void *_ts)
253{
254 struct tsc2005 *ts = _ts;
255 unsigned long flags;
256 unsigned int pressure;
257 u32 x, y;
258 u32 z1, z2;
259 int error;
260
261 /* read the coordinates */
262 error = spi_sync(ts->spi, &ts->spi_read_msg);
263 if (unlikely(error))
264 goto out;
265
266 x = ts->spi_x.spi_rx;
267 y = ts->spi_y.spi_rx;
268 z1 = ts->spi_z1.spi_rx;
269 z2 = ts->spi_z2.spi_rx;
270
271 /* validate position */
272 if (unlikely(x > MAX_12BIT || y > MAX_12BIT))
273 goto out;
274
275 /* Skip reading if the pressure components are out of range */
276 if (unlikely(z1 == 0 || z2 > MAX_12BIT || z1 >= z2))
277 goto out;
278
279 /*
280 * Skip point if this is a pen down with the exact same values as
281 * the value before pen-up - that implies SPI fed us stale data
282 */
283 if (!ts->pen_down &&
284 ts->in_x == x && ts->in_y == y &&
285 ts->in_z1 == z1 && ts->in_z2 == z2) {
286 goto out;
287 }
288
289 /*
290 * At this point we are happy we have a valid and useful reading.
291 * Remember it for later comparisons. We may now begin downsampling.
292 */
293 ts->in_x = x;
294 ts->in_y = y;
295 ts->in_z1 = z1;
296 ts->in_z2 = z2;
297
298 /* Compute touch pressure resistance using equation #1 */
299 pressure = x * (z2 - z1) / z1;
300 pressure = pressure * ts->x_plate_ohm / 4096;
301 if (unlikely(pressure > MAX_12BIT))
302 goto out;
303
304 spin_lock_irqsave(&ts->lock, flags);
305
306 tsc2005_update_pen_state(ts, x, y, pressure);
307 mod_timer(&ts->penup_timer,
308 jiffies + msecs_to_jiffies(TSC2005_PENUP_TIME_MS));
309
310 spin_unlock_irqrestore(&ts->lock, flags);
311
312 ts->last_valid_interrupt = jiffies;
313out:
314 return IRQ_HANDLED;
315}
316
317static void tsc2005_penup_timer(unsigned long data)
318{
319 struct tsc2005 *ts = (struct tsc2005 *)data;
320 unsigned long flags;
321
322 spin_lock_irqsave(&ts->lock, flags);
323 tsc2005_update_pen_state(ts, 0, 0, 0);
324 spin_unlock_irqrestore(&ts->lock, flags);
325}
326
327static void tsc2005_start_scan(struct tsc2005 *ts)
328{
329 tsc2005_write(ts, TSC2005_REG_CFR0, TSC2005_CFR0_INITVALUE);
330 tsc2005_write(ts, TSC2005_REG_CFR1, TSC2005_CFR1_INITVALUE);
331 tsc2005_write(ts, TSC2005_REG_CFR2, TSC2005_CFR2_INITVALUE);
332 tsc2005_cmd(ts, TSC2005_CMD_NORMAL);
333}
334
335static void tsc2005_stop_scan(struct tsc2005 *ts)
336{
337 tsc2005_cmd(ts, TSC2005_CMD_STOP);
338}
339
340/* must be called with ts->mutex held */
341static void __tsc2005_disable(struct tsc2005 *ts)
342{
343 tsc2005_stop_scan(ts);
344
345 disable_irq(ts->spi->irq);
346 del_timer_sync(&ts->penup_timer);
347
348 cancel_delayed_work_sync(&ts->esd_work);
349
350 enable_irq(ts->spi->irq);
351}
352
353/* must be called with ts->mutex held */
354static void __tsc2005_enable(struct tsc2005 *ts)
355{
356 tsc2005_start_scan(ts);
357
358 if (ts->esd_timeout && ts->set_reset) {
359 ts->last_valid_interrupt = jiffies;
360 schedule_delayed_work(&ts->esd_work,
361 round_jiffies_relative(
362 msecs_to_jiffies(ts->esd_timeout)));
363 }
364
365}
366
367static ssize_t tsc2005_selftest_show(struct device *dev,
368 struct device_attribute *attr,
369 char *buf)
370{
371 struct spi_device *spi = to_spi_device(dev);
372 struct tsc2005 *ts = spi_get_drvdata(spi);
373 u16 temp_high;
374 u16 temp_high_orig;
375 u16 temp_high_test;
376 bool success = true;
377 int error;
378
379 mutex_lock(&ts->mutex);
380
381 /*
382 * Test TSC2005 communications via temp high register.
383 */
384 __tsc2005_disable(ts);
385
386 error = tsc2005_read(ts, TSC2005_REG_TEMP_HIGH, &temp_high_orig);
387 if (error) {
388 dev_warn(dev, "selftest failed: read error %d\n", error);
389 success = false;
390 goto out;
391 }
392
393 temp_high_test = (temp_high_orig - 1) & MAX_12BIT;
394
395 error = tsc2005_write(ts, TSC2005_REG_TEMP_HIGH, temp_high_test);
396 if (error) {
397 dev_warn(dev, "selftest failed: write error %d\n", error);
398 success = false;
399 goto out;
400 }
401
402 error = tsc2005_read(ts, TSC2005_REG_TEMP_HIGH, &temp_high);
403 if (error) {
404 dev_warn(dev, "selftest failed: read error %d after write\n",
405 error);
406 success = false;
407 goto out;
408 }
409
410 if (temp_high != temp_high_test) {
411 dev_warn(dev, "selftest failed: %d != %d\n",
412 temp_high, temp_high_test);
413 success = false;
414 }
415
416 /* hardware reset */
417 ts->set_reset(false);
418 usleep_range(100, 500); /* only 10us required */
419 ts->set_reset(true);
420
421 if (!success)
422 goto out;
423
424 /* test that the reset really happened */
425 error = tsc2005_read(ts, TSC2005_REG_TEMP_HIGH, &temp_high);
426 if (error) {
427 dev_warn(dev, "selftest failed: read error %d after reset\n",
428 error);
429 success = false;
430 goto out;
431 }
432
433 if (temp_high != temp_high_orig) {
434 dev_warn(dev, "selftest failed after reset: %d != %d\n",
435 temp_high, temp_high_orig);
436 success = false;
437 }
438
439out:
440 __tsc2005_enable(ts);
441 mutex_unlock(&ts->mutex);
442
443 return sprintf(buf, "%d\n", success);
444}
445
446static DEVICE_ATTR(selftest, S_IRUGO, tsc2005_selftest_show, NULL);
447
448static struct attribute *tsc2005_attrs[] = {
449 &dev_attr_selftest.attr,
450 NULL
451};
452
453static mode_t tsc2005_attr_is_visible(struct kobject *kobj,
454 struct attribute *attr, int n)
455{
456 struct device *dev = container_of(kobj, struct device, kobj);
457 struct spi_device *spi = to_spi_device(dev);
458 struct tsc2005 *ts = spi_get_drvdata(spi);
459 mode_t mode = attr->mode;
460
461 if (attr == &dev_attr_selftest.attr) {
462 if (!ts->set_reset)
463 mode = 0;
464 }
465
466 return mode;
467}
468
469static const struct attribute_group tsc2005_attr_group = {
470 .is_visible = tsc2005_attr_is_visible,
471 .attrs = tsc2005_attrs,
472};
473
474static void tsc2005_esd_work(struct work_struct *work)
475{
476 struct tsc2005 *ts = container_of(work, struct tsc2005, esd_work.work);
477 int error;
478 u16 r;
479
480 if (!mutex_trylock(&ts->mutex)) {
481 /*
482 * If the mutex is taken, it means that disable or enable is in
483 * progress. In that case just reschedule the work. If the work
484 * is not needed, it will be canceled by disable.
485 */
486 goto reschedule;
487 }
488
489 if (time_is_after_jiffies(ts->last_valid_interrupt +
490 msecs_to_jiffies(ts->esd_timeout)))
491 goto out;
492
493 /* We should be able to read register without disabling interrupts. */
494 error = tsc2005_read(ts, TSC2005_REG_CFR0, &r);
495 if (!error &&
496 !((r ^ TSC2005_CFR0_INITVALUE) & TSC2005_CFR0_RW_MASK)) {
497 goto out;
498 }
499
500 /*
501 * If we could not read our known value from configuration register 0
502 * then we should reset the controller as if from power-up and start
503 * scanning again.
504 */
505 dev_info(&ts->spi->dev, "TSC2005 not responding - resetting\n");
506
507 disable_irq(ts->spi->irq);
508 del_timer_sync(&ts->penup_timer);
509
510 tsc2005_update_pen_state(ts, 0, 0, 0);
511
512 ts->set_reset(false);
513 usleep_range(100, 500); /* only 10us required */
514 ts->set_reset(true);
515
516 enable_irq(ts->spi->irq);
517 tsc2005_start_scan(ts);
518
519out:
520 mutex_unlock(&ts->mutex);
521reschedule:
522 /* re-arm the watchdog */
523 schedule_delayed_work(&ts->esd_work,
524 round_jiffies_relative(
525 msecs_to_jiffies(ts->esd_timeout)));
526}
527
528static int tsc2005_open(struct input_dev *input)
529{
530 struct tsc2005 *ts = input_get_drvdata(input);
531
532 mutex_lock(&ts->mutex);
533
534 if (!ts->suspended)
535 __tsc2005_enable(ts);
536
537 ts->opened = true;
538
539 mutex_unlock(&ts->mutex);
540
541 return 0;
542}
543
544static void tsc2005_close(struct input_dev *input)
545{
546 struct tsc2005 *ts = input_get_drvdata(input);
547
548 mutex_lock(&ts->mutex);
549
550 if (!ts->suspended)
551 __tsc2005_disable(ts);
552
553 ts->opened = false;
554
555 mutex_unlock(&ts->mutex);
556}
557
558static void __devinit tsc2005_setup_spi_xfer(struct tsc2005 *ts)
559{
560 tsc2005_setup_read(&ts->spi_x, TSC2005_REG_X, false);
561 tsc2005_setup_read(&ts->spi_y, TSC2005_REG_Y, false);
562 tsc2005_setup_read(&ts->spi_z1, TSC2005_REG_Z1, false);
563 tsc2005_setup_read(&ts->spi_z2, TSC2005_REG_Z2, true);
564
565 spi_message_init(&ts->spi_read_msg);
566 spi_message_add_tail(&ts->spi_x.spi_xfer, &ts->spi_read_msg);
567 spi_message_add_tail(&ts->spi_y.spi_xfer, &ts->spi_read_msg);
568 spi_message_add_tail(&ts->spi_z1.spi_xfer, &ts->spi_read_msg);
569 spi_message_add_tail(&ts->spi_z2.spi_xfer, &ts->spi_read_msg);
570}
571
572static int __devinit tsc2005_probe(struct spi_device *spi)
573{
574 const struct tsc2005_platform_data *pdata = spi->dev.platform_data;
575 struct tsc2005 *ts;
576 struct input_dev *input_dev;
577 unsigned int max_x, max_y, max_p;
578 unsigned int fudge_x, fudge_y, fudge_p;
579 int error;
580
581 if (!pdata) {
582 dev_dbg(&spi->dev, "no platform data\n");
583 return -ENODEV;
584 }
585
586 fudge_x = pdata->ts_x_fudge ? : 4;
587 fudge_y = pdata->ts_y_fudge ? : 8;
588 fudge_p = pdata->ts_pressure_fudge ? : 2;
589 max_x = pdata->ts_x_max ? : MAX_12BIT;
590 max_y = pdata->ts_y_max ? : MAX_12BIT;
591 max_p = pdata->ts_pressure_max ? : MAX_12BIT;
592
593 if (spi->irq <= 0) {
594 dev_dbg(&spi->dev, "no irq\n");
595 return -ENODEV;
596 }
597
598 spi->mode = SPI_MODE_0;
599 spi->bits_per_word = 8;
600 if (!spi->max_speed_hz)
601 spi->max_speed_hz = TSC2005_SPI_MAX_SPEED_HZ;
602
603 error = spi_setup(spi);
604 if (error)
605 return error;
606
607 ts = kzalloc(sizeof(*ts), GFP_KERNEL);
608 input_dev = input_allocate_device();
609 if (!ts || !input_dev) {
610 error = -ENOMEM;
611 goto err_free_mem;
612 }
613
614 ts->spi = spi;
615 ts->idev = input_dev;
616
617 ts->x_plate_ohm = pdata->ts_x_plate_ohm ? : 280;
618 ts->esd_timeout = pdata->esd_timeout_ms;
619 ts->set_reset = pdata->set_reset;
620
621 mutex_init(&ts->mutex);
622
623 spin_lock_init(&ts->lock);
624 setup_timer(&ts->penup_timer, tsc2005_penup_timer, (unsigned long)ts);
625
626 INIT_DELAYED_WORK(&ts->esd_work, tsc2005_esd_work);
627
628 tsc2005_setup_spi_xfer(ts);
629
630 snprintf(ts->phys, sizeof(ts->phys),
631 "%s/input-ts", dev_name(&spi->dev));
632
633 input_dev->name = "TSC2005 touchscreen";
634 input_dev->phys = ts->phys;
635 input_dev->id.bustype = BUS_SPI;
636 input_dev->dev.parent = &spi->dev;
637 input_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY);
638 input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
639
640 input_set_abs_params(input_dev, ABS_X, 0, max_x, fudge_x, 0);
641 input_set_abs_params(input_dev, ABS_Y, 0, max_y, fudge_y, 0);
642 input_set_abs_params(input_dev, ABS_PRESSURE, 0, max_p, fudge_p, 0);
643
644 input_dev->open = tsc2005_open;
645 input_dev->close = tsc2005_close;
646
647 input_set_drvdata(input_dev, ts);
648
649 /* Ensure the touchscreen is off */
650 tsc2005_stop_scan(ts);
651
652 error = request_threaded_irq(spi->irq, NULL, tsc2005_irq_thread,
653 IRQF_TRIGGER_RISING, "tsc2005", ts);
654 if (error) {
655 dev_err(&spi->dev, "Failed to request irq, err: %d\n", error);
656 goto err_free_mem;
657 }
658
659 spi_set_drvdata(spi, ts);
660 error = sysfs_create_group(&spi->dev.kobj, &tsc2005_attr_group);
661 if (error) {
662 dev_err(&spi->dev,
663 "Failed to create sysfs attributes, err: %d\n", error);
664 goto err_clear_drvdata;
665 }
666
667 error = input_register_device(ts->idev);
668 if (error) {
669 dev_err(&spi->dev,
670 "Failed to register input device, err: %d\n", error);
671 goto err_remove_sysfs;
672 }
673
674 irq_set_irq_wake(spi->irq, 1);
675 return 0;
676
677err_remove_sysfs:
678 sysfs_remove_group(&spi->dev.kobj, &tsc2005_attr_group);
679err_clear_drvdata:
680 spi_set_drvdata(spi, NULL);
681 free_irq(spi->irq, ts);
682err_free_mem:
683 input_free_device(input_dev);
684 kfree(ts);
685 return error;
686}
687
688static int __devexit tsc2005_remove(struct spi_device *spi)
689{
690 struct tsc2005 *ts = spi_get_drvdata(spi);
691
692 sysfs_remove_group(&ts->spi->dev.kobj, &tsc2005_attr_group);
693
694 free_irq(ts->spi->irq, ts);
695 input_unregister_device(ts->idev);
696 kfree(ts);
697
698 spi_set_drvdata(spi, NULL);
699 return 0;
700}
701
702#ifdef CONFIG_PM_SLEEP
703static int tsc2005_suspend(struct device *dev)
704{
705 struct spi_device *spi = to_spi_device(dev);
706 struct tsc2005 *ts = spi_get_drvdata(spi);
707
708 mutex_lock(&ts->mutex);
709
710 if (!ts->suspended && ts->opened)
711 __tsc2005_disable(ts);
712
713 ts->suspended = true;
714
715 mutex_unlock(&ts->mutex);
716
717 return 0;
718}
719
720static int tsc2005_resume(struct device *dev)
721{
722 struct spi_device *spi = to_spi_device(dev);
723 struct tsc2005 *ts = spi_get_drvdata(spi);
724
725 mutex_lock(&ts->mutex);
726
727 if (ts->suspended && ts->opened)
728 __tsc2005_enable(ts);
729
730 ts->suspended = false;
731
732 mutex_unlock(&ts->mutex);
733
734 return 0;
735}
736#endif
737
738static SIMPLE_DEV_PM_OPS(tsc2005_pm_ops, tsc2005_suspend, tsc2005_resume);
739
740static struct spi_driver tsc2005_driver = {
741 .driver = {
742 .name = "tsc2005",
743 .owner = THIS_MODULE,
744 .pm = &tsc2005_pm_ops,
745 },
746 .probe = tsc2005_probe,
747 .remove = __devexit_p(tsc2005_remove),
748};
749
750static int __init tsc2005_init(void)
751{
752 return spi_register_driver(&tsc2005_driver);
753}
754module_init(tsc2005_init);
755
756static void __exit tsc2005_exit(void)
757{
758 spi_unregister_driver(&tsc2005_driver);
759}
760module_exit(tsc2005_exit);
761
762MODULE_AUTHOR("Lauri Leukkunen <lauri.leukkunen@nokia.com>");
763MODULE_DESCRIPTION("TSC2005 Touchscreen Driver");
764MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/ucb1400_ts.c b/drivers/input/touchscreen/ucb1400_ts.c
index 028a5363eea1..3b5b5df04dd6 100644
--- a/drivers/input/touchscreen/ucb1400_ts.c
+++ b/drivers/input/touchscreen/ucb1400_ts.c
@@ -6,7 +6,7 @@
6 * Copyright: MontaVista Software, Inc. 6 * Copyright: MontaVista Software, Inc.
7 * 7 *
8 * Spliting done by: Marek Vasut <marek.vasut@gmail.com> 8 * Spliting done by: Marek Vasut <marek.vasut@gmail.com>
9 * If something doesnt work and it worked before spliting, e-mail me, 9 * If something doesn't work and it worked before spliting, e-mail me,
10 * dont bother Nicolas please ;-) 10 * dont bother Nicolas please ;-)
11 * 11 *
12 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
diff --git a/drivers/input/touchscreen/wm831x-ts.c b/drivers/input/touchscreen/wm831x-ts.c
new file mode 100644
index 000000000000..6ae054f8e0aa
--- /dev/null
+++ b/drivers/input/touchscreen/wm831x-ts.c
@@ -0,0 +1,368 @@
1/*
2 * Touchscreen driver for WM831x PMICs
3 *
4 * Copyright 2011 Wolfson Microelectronics plc.
5 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#include <linux/module.h>
14#include <linux/moduleparam.h>
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/string.h>
18#include <linux/pm.h>
19#include <linux/input.h>
20#include <linux/interrupt.h>
21#include <linux/io.h>
22#include <linux/mfd/wm831x/core.h>
23#include <linux/mfd/wm831x/irq.h>
24#include <linux/mfd/wm831x/pdata.h>
25#include <linux/platform_device.h>
26#include <linux/slab.h>
27#include <linux/types.h>
28
29/*
30 * R16424 (0x4028) - Touch Control 1
31 */
32#define WM831X_TCH_ENA 0x8000 /* TCH_ENA */
33#define WM831X_TCH_CVT_ENA 0x4000 /* TCH_CVT_ENA */
34#define WM831X_TCH_SLPENA 0x1000 /* TCH_SLPENA */
35#define WM831X_TCH_Z_ENA 0x0400 /* TCH_Z_ENA */
36#define WM831X_TCH_Y_ENA 0x0200 /* TCH_Y_ENA */
37#define WM831X_TCH_X_ENA 0x0100 /* TCH_X_ENA */
38#define WM831X_TCH_DELAY_MASK 0x00E0 /* TCH_DELAY - [7:5] */
39#define WM831X_TCH_DELAY_SHIFT 5 /* TCH_DELAY - [7:5] */
40#define WM831X_TCH_DELAY_WIDTH 3 /* TCH_DELAY - [7:5] */
41#define WM831X_TCH_RATE_MASK 0x001F /* TCH_RATE - [4:0] */
42#define WM831X_TCH_RATE_SHIFT 0 /* TCH_RATE - [4:0] */
43#define WM831X_TCH_RATE_WIDTH 5 /* TCH_RATE - [4:0] */
44
45/*
46 * R16425 (0x4029) - Touch Control 2
47 */
48#define WM831X_TCH_PD_WK 0x2000 /* TCH_PD_WK */
49#define WM831X_TCH_5WIRE 0x1000 /* TCH_5WIRE */
50#define WM831X_TCH_PDONLY 0x0800 /* TCH_PDONLY */
51#define WM831X_TCH_ISEL 0x0100 /* TCH_ISEL */
52#define WM831X_TCH_RPU_MASK 0x000F /* TCH_RPU - [3:0] */
53#define WM831X_TCH_RPU_SHIFT 0 /* TCH_RPU - [3:0] */
54#define WM831X_TCH_RPU_WIDTH 4 /* TCH_RPU - [3:0] */
55
56/*
57 * R16426-8 (0x402A-C) - Touch Data X/Y/X
58 */
59#define WM831X_TCH_PD 0x8000 /* TCH_PD1 */
60#define WM831X_TCH_DATA_MASK 0x0FFF /* TCH_DATA - [11:0] */
61#define WM831X_TCH_DATA_SHIFT 0 /* TCH_DATA - [11:0] */
62#define WM831X_TCH_DATA_WIDTH 12 /* TCH_DATA - [11:0] */
63
64struct wm831x_ts {
65 struct input_dev *input_dev;
66 struct wm831x *wm831x;
67 unsigned int data_irq;
68 unsigned int pd_irq;
69 bool pressure;
70 bool pen_down;
71};
72
73static irqreturn_t wm831x_ts_data_irq(int irq, void *irq_data)
74{
75 struct wm831x_ts *wm831x_ts = irq_data;
76 struct wm831x *wm831x = wm831x_ts->wm831x;
77 static int data_types[] = { ABS_X, ABS_Y, ABS_PRESSURE };
78 u16 data[3];
79 int count;
80 int i, ret;
81
82 if (wm831x_ts->pressure)
83 count = 3;
84 else
85 count = 2;
86
87 wm831x_set_bits(wm831x, WM831X_INTERRUPT_STATUS_1,
88 WM831X_TCHDATA_EINT, WM831X_TCHDATA_EINT);
89
90 ret = wm831x_bulk_read(wm831x, WM831X_TOUCH_DATA_X, count,
91 data);
92 if (ret != 0) {
93 dev_err(wm831x->dev, "Failed to read touch data: %d\n",
94 ret);
95 return IRQ_NONE;
96 }
97
98 /*
99 * We get a pen down reading on every reading, report pen up if any
100 * individual reading does so.
101 */
102 wm831x_ts->pen_down = true;
103 for (i = 0; i < count; i++) {
104 if (!(data[i] & WM831X_TCH_PD)) {
105 wm831x_ts->pen_down = false;
106 continue;
107 }
108 input_report_abs(wm831x_ts->input_dev, data_types[i],
109 data[i] & WM831X_TCH_DATA_MASK);
110 }
111
112 if (!wm831x_ts->pen_down) {
113 disable_irq_nosync(wm831x_ts->data_irq);
114
115 /* Don't need data any more */
116 wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1,
117 WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA |
118 WM831X_TCH_Z_ENA, 0);
119
120 /* Flush any final samples that arrived while reading */
121 wm831x_set_bits(wm831x, WM831X_INTERRUPT_STATUS_1,
122 WM831X_TCHDATA_EINT, WM831X_TCHDATA_EINT);
123
124 wm831x_bulk_read(wm831x, WM831X_TOUCH_DATA_X, count, data);
125
126 if (wm831x_ts->pressure)
127 input_report_abs(wm831x_ts->input_dev,
128 ABS_PRESSURE, 0);
129
130 input_report_key(wm831x_ts->input_dev, BTN_TOUCH, 0);
131 }
132
133 input_sync(wm831x_ts->input_dev);
134
135 return IRQ_HANDLED;
136}
137
138static irqreturn_t wm831x_ts_pen_down_irq(int irq, void *irq_data)
139{
140 struct wm831x_ts *wm831x_ts = irq_data;
141 struct wm831x *wm831x = wm831x_ts->wm831x;
142 int ena = 0;
143
144 /* Start collecting data */
145 if (wm831x_ts->pressure)
146 ena |= WM831X_TCH_Z_ENA;
147
148 wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1,
149 WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | WM831X_TCH_Z_ENA,
150 WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | ena);
151
152 input_report_key(wm831x_ts->input_dev, BTN_TOUCH, 1);
153 input_sync(wm831x_ts->input_dev);
154
155 wm831x_set_bits(wm831x, WM831X_INTERRUPT_STATUS_1,
156 WM831X_TCHPD_EINT, WM831X_TCHPD_EINT);
157
158 wm831x_ts->pen_down = true;
159 enable_irq(wm831x_ts->data_irq);
160
161 return IRQ_HANDLED;
162}
163
164static int wm831x_ts_input_open(struct input_dev *idev)
165{
166 struct wm831x_ts *wm831x_ts = input_get_drvdata(idev);
167 struct wm831x *wm831x = wm831x_ts->wm831x;
168
169 wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1,
170 WM831X_TCH_ENA | WM831X_TCH_CVT_ENA |
171 WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA |
172 WM831X_TCH_Z_ENA, WM831X_TCH_ENA);
173
174 wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1,
175 WM831X_TCH_CVT_ENA, WM831X_TCH_CVT_ENA);
176
177 return 0;
178}
179
180static void wm831x_ts_input_close(struct input_dev *idev)
181{
182 struct wm831x_ts *wm831x_ts = input_get_drvdata(idev);
183 struct wm831x *wm831x = wm831x_ts->wm831x;
184
185 wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1,
186 WM831X_TCH_ENA | WM831X_TCH_CVT_ENA |
187 WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA |
188 WM831X_TCH_Z_ENA, 0);
189
190 if (wm831x_ts->pen_down)
191 disable_irq(wm831x_ts->data_irq);
192}
193
194static __devinit int wm831x_ts_probe(struct platform_device *pdev)
195{
196 struct wm831x_ts *wm831x_ts;
197 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
198 struct wm831x_pdata *core_pdata = dev_get_platdata(pdev->dev.parent);
199 struct wm831x_touch_pdata *pdata = NULL;
200 struct input_dev *input_dev;
201 int error;
202
203 if (core_pdata)
204 pdata = core_pdata->touch;
205
206 wm831x_ts = kzalloc(sizeof(struct wm831x_ts), GFP_KERNEL);
207 input_dev = input_allocate_device();
208 if (!wm831x_ts || !input_dev) {
209 error = -ENOMEM;
210 goto err_alloc;
211 }
212
213 wm831x_ts->wm831x = wm831x;
214 wm831x_ts->input_dev = input_dev;
215
216 /*
217 * If we have a direct IRQ use it, otherwise use the interrupt
218 * from the WM831x IRQ controller.
219 */
220 if (pdata && pdata->data_irq)
221 wm831x_ts->data_irq = pdata->data_irq;
222 else
223 wm831x_ts->data_irq = platform_get_irq_byname(pdev, "TCHDATA");
224
225 if (pdata && pdata->pd_irq)
226 wm831x_ts->pd_irq = pdata->pd_irq;
227 else
228 wm831x_ts->pd_irq = platform_get_irq_byname(pdev, "TCHPD");
229
230 if (pdata)
231 wm831x_ts->pressure = pdata->pressure;
232 else
233 wm831x_ts->pressure = true;
234
235 /* Five wire touchscreens can't report pressure */
236 if (pdata && pdata->fivewire) {
237 wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_2,
238 WM831X_TCH_5WIRE, WM831X_TCH_5WIRE);
239
240 /* Pressure measurements are not possible for five wire mode */
241 WARN_ON(pdata->pressure && pdata->fivewire);
242 wm831x_ts->pressure = false;
243 } else {
244 wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_2,
245 WM831X_TCH_5WIRE, 0);
246 }
247
248 if (pdata) {
249 switch (pdata->isel) {
250 default:
251 dev_err(&pdev->dev, "Unsupported ISEL setting: %d\n",
252 pdata->isel);
253 /* Fall through */
254 case 200:
255 case 0:
256 wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_2,
257 WM831X_TCH_ISEL, 0);
258 break;
259 case 400:
260 wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_2,
261 WM831X_TCH_ISEL, WM831X_TCH_ISEL);
262 break;
263 }
264 }
265
266 wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_2,
267 WM831X_TCH_PDONLY, 0);
268
269 /* Default to 96 samples/sec */
270 wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1,
271 WM831X_TCH_RATE_MASK, 6);
272
273 error = request_threaded_irq(wm831x_ts->data_irq,
274 NULL, wm831x_ts_data_irq,
275 IRQF_ONESHOT,
276 "Touchscreen data", wm831x_ts);
277 if (error) {
278 dev_err(&pdev->dev, "Failed to request data IRQ %d: %d\n",
279 wm831x_ts->data_irq, error);
280 goto err_alloc;
281 }
282 disable_irq(wm831x_ts->data_irq);
283
284 error = request_threaded_irq(wm831x_ts->pd_irq,
285 NULL, wm831x_ts_pen_down_irq,
286 IRQF_ONESHOT,
287 "Touchscreen pen down", wm831x_ts);
288 if (error) {
289 dev_err(&pdev->dev, "Failed to request pen down IRQ %d: %d\n",
290 wm831x_ts->pd_irq, error);
291 goto err_data_irq;
292 }
293
294 /* set up touch configuration */
295 input_dev->name = "WM831x touchscreen";
296 input_dev->phys = "wm831x";
297 input_dev->open = wm831x_ts_input_open;
298 input_dev->close = wm831x_ts_input_close;
299
300 __set_bit(EV_ABS, input_dev->evbit);
301 __set_bit(EV_KEY, input_dev->evbit);
302 __set_bit(BTN_TOUCH, input_dev->keybit);
303
304 input_set_abs_params(input_dev, ABS_X, 0, 4095, 5, 0);
305 input_set_abs_params(input_dev, ABS_Y, 0, 4095, 5, 0);
306 if (wm831x_ts->pressure)
307 input_set_abs_params(input_dev, ABS_PRESSURE, 0, 4095, 5, 0);
308
309 input_set_drvdata(input_dev, wm831x_ts);
310 input_dev->dev.parent = &pdev->dev;
311
312 error = input_register_device(input_dev);
313 if (error)
314 goto err_pd_irq;
315
316 platform_set_drvdata(pdev, wm831x_ts);
317 return 0;
318
319err_pd_irq:
320 free_irq(wm831x_ts->pd_irq, wm831x_ts);
321err_data_irq:
322 free_irq(wm831x_ts->data_irq, wm831x_ts);
323err_alloc:
324 input_free_device(input_dev);
325 kfree(wm831x_ts);
326
327 return error;
328}
329
330static __devexit int wm831x_ts_remove(struct platform_device *pdev)
331{
332 struct wm831x_ts *wm831x_ts = platform_get_drvdata(pdev);
333
334 free_irq(wm831x_ts->pd_irq, wm831x_ts);
335 free_irq(wm831x_ts->data_irq, wm831x_ts);
336 input_unregister_device(wm831x_ts->input_dev);
337 kfree(wm831x_ts);
338
339 platform_set_drvdata(pdev, NULL);
340 return 0;
341}
342
343static struct platform_driver wm831x_ts_driver = {
344 .driver = {
345 .name = "wm831x-touch",
346 .owner = THIS_MODULE,
347 },
348 .probe = wm831x_ts_probe,
349 .remove = __devexit_p(wm831x_ts_remove),
350};
351
352static int __init wm831x_ts_init(void)
353{
354 return platform_driver_register(&wm831x_ts_driver);
355}
356module_init(wm831x_ts_init);
357
358static void __exit wm831x_ts_exit(void)
359{
360 platform_driver_unregister(&wm831x_ts_driver);
361}
362module_exit(wm831x_ts_exit);
363
364/* Module information */
365MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
366MODULE_DESCRIPTION("WM831x PMIC touchscreen driver");
367MODULE_LICENSE("GPL");
368MODULE_ALIAS("platform:wm831x-touch");
diff --git a/drivers/input/touchscreen/wm9705.c b/drivers/input/touchscreen/wm9705.c
index 6b5be742c27d..98e61175d3f5 100644
--- a/drivers/input/touchscreen/wm9705.c
+++ b/drivers/input/touchscreen/wm9705.c
@@ -306,7 +306,7 @@ static int wm9705_acc_enable(struct wm97xx *wm, int enable)
306 dig2 = wm->dig[2]; 306 dig2 = wm->dig[2];
307 307
308 if (enable) { 308 if (enable) {
309 /* continous mode */ 309 /* continuous mode */
310 if (wm->mach_ops->acc_startup && 310 if (wm->mach_ops->acc_startup &&
311 (ret = wm->mach_ops->acc_startup(wm)) < 0) 311 (ret = wm->mach_ops->acc_startup(wm)) < 0)
312 return ret; 312 return ret;
diff --git a/drivers/input/touchscreen/wm9712.c b/drivers/input/touchscreen/wm9712.c
index 7490b05c3566..2bc2fb801009 100644
--- a/drivers/input/touchscreen/wm9712.c
+++ b/drivers/input/touchscreen/wm9712.c
@@ -419,7 +419,7 @@ static int wm9712_acc_enable(struct wm97xx *wm, int enable)
419 dig2 = wm->dig[2]; 419 dig2 = wm->dig[2];
420 420
421 if (enable) { 421 if (enable) {
422 /* continous mode */ 422 /* continuous mode */
423 if (wm->mach_ops->acc_startup) { 423 if (wm->mach_ops->acc_startup) {
424 ret = wm->mach_ops->acc_startup(wm); 424 ret = wm->mach_ops->acc_startup(wm);
425 if (ret < 0) 425 if (ret < 0)
diff --git a/drivers/input/touchscreen/wm9713.c b/drivers/input/touchscreen/wm9713.c
index 238b5132712e..73ec99568f12 100644
--- a/drivers/input/touchscreen/wm9713.c
+++ b/drivers/input/touchscreen/wm9713.c
@@ -431,7 +431,7 @@ static int wm9713_acc_enable(struct wm97xx *wm, int enable)
431 dig3 = wm->dig[2]; 431 dig3 = wm->dig[2];
432 432
433 if (enable) { 433 if (enable) {
434 /* continous mode */ 434 /* continuous mode */
435 if (wm->mach_ops->acc_startup && 435 if (wm->mach_ops->acc_startup &&
436 (ret = wm->mach_ops->acc_startup(wm)) < 0) 436 (ret = wm->mach_ops->acc_startup(wm)) < 0)
437 return ret; 437 return ret;
diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
index 6b75c9f660ae..5dbe73af2f8f 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -335,7 +335,7 @@ static void wm97xx_pen_irq_worker(struct work_struct *work)
335 */ 335 */
336 if (!wm->mach_ops->acc_enabled || wm->mach_ops->acc_pen_down) { 336 if (!wm->mach_ops->acc_enabled || wm->mach_ops->acc_pen_down) {
337 if (wm->pen_is_down && !pen_was_down) { 337 if (wm->pen_is_down && !pen_was_down) {
338 /* Data is not availiable immediately on pen down */ 338 /* Data is not available immediately on pen down */
339 queue_delayed_work(wm->ts_workq, &wm->ts_reader, 1); 339 queue_delayed_work(wm->ts_workq, &wm->ts_reader, 1);
340 } 340 }
341 341
@@ -354,7 +354,7 @@ static void wm97xx_pen_irq_worker(struct work_struct *work)
354 * Codec PENDOWN irq handler 354 * Codec PENDOWN irq handler
355 * 355 *
356 * We have to disable the codec interrupt in the handler because it 356 * We have to disable the codec interrupt in the handler because it
357 * can take upto 1ms to clear the interrupt source. We schedule a task 357 * can take up to 1ms to clear the interrupt source. We schedule a task
358 * in a work queue to do the actual interaction with the chip. The 358 * in a work queue to do the actual interaction with the chip. The
359 * interrupt is then enabled again in the slow handler when the source 359 * interrupt is then enabled again in the slow handler when the source
360 * has been cleared. 360 * has been cleared.
diff --git a/drivers/input/touchscreen/zylonite-wm97xx.c b/drivers/input/touchscreen/zylonite-wm97xx.c
index 048849867643..5b0f15ec874a 100644
--- a/drivers/input/touchscreen/zylonite-wm97xx.c
+++ b/drivers/input/touchscreen/zylonite-wm97xx.c
@@ -193,7 +193,7 @@ static int zylonite_wm97xx_probe(struct platform_device *pdev)
193 gpio_touch_irq = mfp_to_gpio(MFP_PIN_GPIO26); 193 gpio_touch_irq = mfp_to_gpio(MFP_PIN_GPIO26);
194 194
195 wm->pen_irq = IRQ_GPIO(gpio_touch_irq); 195 wm->pen_irq = IRQ_GPIO(gpio_touch_irq);
196 set_irq_type(IRQ_GPIO(gpio_touch_irq), IRQ_TYPE_EDGE_BOTH); 196 irq_set_irq_type(IRQ_GPIO(gpio_touch_irq), IRQ_TYPE_EDGE_BOTH);
197 197
198 wm97xx_config_gpio(wm, WM97XX_GPIO_13, WM97XX_GPIO_IN, 198 wm97xx_config_gpio(wm, WM97XX_GPIO_13, WM97XX_GPIO_IN,
199 WM97XX_GPIO_POL_HIGH, 199 WM97XX_GPIO_POL_HIGH,