aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-03-20 01:27:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-20 01:27:06 -0400
commita952baa034ae7c2e4a66932005cbc7ebbccfe28d (patch)
treeff5abe0c77f5b129946300677d9b57b00d926a1e
parent5bab188a316718a26346cdb25c4cc6b319f8f907 (diff)
parent97eb3f24352ec6632c2127b35d8087d2a809a9b9 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (64 commits) Input: tsc2005 - remove 'disable' sysfs attribute Input: tsc2005 - add open/close Input: tsc2005 - handle read errors from SPI layer Input: tsc2005 - do not rearm timer in hardirq handler Input: tsc2005 - don't use work for 'pen up' handling Input: tsc2005 - do not use 0 in place of NULL Input: tsc2005 - use true/false for boolean variables Input: tsc2005 - hide selftest attribute if we can't reset Input: tsc2005 - rework driver initialization code Input: tsc2005 - set up bus type in input device Input: tsc2005 - set up parent device Input: tsc2005 - clear driver data after unbinding Input: tsc2005 - add module description Input: tsc2005 - remove driver banner message Input: tsc2005 - remove incorrect module alias Input: tsc2005 - convert to using dev_pm_ops Input: tsc2005 - use spi_get/set_drvdata() Input: introduce tsc2005 driver Input: xen-kbdfront - move to drivers/input/misc Input: xen-kbdfront - add grant reference for shared page ...
-rw-r--r--arch/arm/mach-s5pv210/mach-goni.c8
-rw-r--r--drivers/hid/hid-apple.c6
-rw-r--r--drivers/hid/hid-core.c6
-rw-r--r--drivers/hid/hid-ids.h3
-rw-r--r--drivers/hid/hid-input.c4
-rw-r--r--drivers/input/Kconfig10
-rw-r--r--drivers/input/Makefile2
-rw-r--r--drivers/input/evdev.c10
-rw-r--r--drivers/input/input-polldev.c4
-rw-r--r--drivers/input/input.c55
-rw-r--r--drivers/input/keyboard/Kconfig10
-rw-r--r--drivers/input/keyboard/Makefile1
-rw-r--r--drivers/input/keyboard/lm8323.c15
-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/tc3589x-keypad.c22
-rw-r--r--drivers/input/keyboard/tca6416-keypad.c28
-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/ati_remote2.c4
-rw-r--r--drivers/input/misc/uinput.c48
-rw-r--r--drivers/input/misc/xen-kbdfront.c (renamed from drivers/input/xen-kbdfront.c)83
-rw-r--r--drivers/input/mouse/bcm5974.c28
-rw-r--r--drivers/input/mouse/synaptics_i2c.c16
-rw-r--r--drivers/input/sparse-keymap.c4
-rw-r--r--drivers/input/tablet/wacom_sys.c12
-rw-r--r--drivers/input/tablet/wacom_wac.c247
-rw-r--r--drivers/input/tablet/wacom_wac.h6
-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/qt602240_ts.c1406
-rw-r--r--drivers/input/touchscreen/tsc2005.c756
-rw-r--r--drivers/input/touchscreen/wm831x-ts.c368
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-remote.c109
-rw-r--r--drivers/media/rc/rc-main.c4
-rw-r--r--include/linux/i2c/atmel_mxt_ts.h (renamed from include/linux/i2c/qt602240_ts.h)34
-rw-r--r--include/linux/i2c/mcs.h1
-rw-r--r--include/linux/input-polldev.h4
-rw-r--r--include/linux/input.h12
-rw-r--r--include/linux/mfd/wm831x/pdata.h3
-rw-r--r--include/linux/spi/tsc2005.h41
51 files changed, 3284 insertions, 1906 deletions
diff --git a/arch/arm/mach-s5pv210/mach-goni.c b/arch/arm/mach-s5pv210/mach-goni.c
index 243291722c66..31d5aa769753 100644
--- a/arch/arm/mach-s5pv210/mach-goni.c
+++ b/arch/arm/mach-s5pv210/mach-goni.c
@@ -15,7 +15,7 @@
15#include <linux/fb.h> 15#include <linux/fb.h>
16#include <linux/i2c.h> 16#include <linux/i2c.h>
17#include <linux/i2c-gpio.h> 17#include <linux/i2c-gpio.h>
18#include <linux/i2c/qt602240_ts.h> 18#include <linux/i2c/atmel_mxt_ts.h>
19#include <linux/mfd/max8998.h> 19#include <linux/mfd/max8998.h>
20#include <linux/mfd/wm8994/pdata.h> 20#include <linux/mfd/wm8994/pdata.h>
21#include <linux/regulator/fixed.h> 21#include <linux/regulator/fixed.h>
@@ -25,6 +25,7 @@
25#include <linux/gpio_keys.h> 25#include <linux/gpio_keys.h>
26#include <linux/input.h> 26#include <linux/input.h>
27#include <linux/gpio.h> 27#include <linux/gpio.h>
28#include <linux/interrupt.h>
28 29
29#include <asm/mach/arch.h> 30#include <asm/mach/arch.h>
30#include <asm/mach/map.h> 31#include <asm/mach/map.h>
@@ -225,7 +226,7 @@ static void __init goni_radio_init(void)
225} 226}
226 227
227/* TSP */ 228/* TSP */
228static struct qt602240_platform_data qt602240_platform_data = { 229static struct mxt_platform_data qt602240_platform_data = {
229 .x_line = 17, 230 .x_line = 17,
230 .y_line = 11, 231 .y_line = 11,
231 .x_size = 800, 232 .x_size = 800,
@@ -233,7 +234,8 @@ static struct qt602240_platform_data qt602240_platform_data = {
233 .blen = 0x21, 234 .blen = 0x21,
234 .threshold = 0x28, 235 .threshold = 0x28,
235 .voltage = 2800000, /* 2.8V */ 236 .voltage = 2800000, /* 2.8V */
236 .orient = QT602240_DIAGONAL, 237 .orient = MXT_DIAGONAL,
238 .irqflags = IRQF_TRIGGER_FALLING,
237}; 239};
238 240
239static struct s3c2410_platform_i2c i2c2_data __initdata = { 241static struct s3c2410_platform_i2c i2c2_data __initdata = {
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index 61aa71233392..b85744fe8464 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -481,6 +481,12 @@ static const struct hid_device_id apple_devices[] = {
481 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, 481 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
482 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS), 482 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS),
483 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, 483 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
484 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI),
485 .driver_data = APPLE_HAS_FN },
486 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO),
487 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
488 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS),
489 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
484 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI), 490 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
485 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, 491 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
486 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO), 492 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index c3d66269ed7d..e9687768a335 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1333,6 +1333,9 @@ static const struct hid_device_id hid_have_special_driver[] = {
1333 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, 1333 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) },
1334 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, 1334 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) },
1335 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, 1335 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) },
1336 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) },
1337 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) },
1338 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) },
1336 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) }, 1339 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
1337 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) }, 1340 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
1338 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, 1341 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
@@ -1840,6 +1843,9 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {
1840 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, 1843 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) },
1841 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, 1844 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) },
1842 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, 1845 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) },
1846 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) },
1847 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) },
1848 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) },
1843 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 1849 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1844 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1850 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
1845 { } 1851 { }
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index d485894ff4db..65ac53d7aecc 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -103,6 +103,9 @@
103#define USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI 0x0242 103#define USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI 0x0242
104#define USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO 0x0243 104#define USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO 0x0243
105#define USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS 0x0244 105#define USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS 0x0244
106#define USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI 0x0245
107#define USB_DEVICE_ID_APPLE_WELLSPRING5_ISO 0x0246
108#define USB_DEVICE_ID_APPLE_WELLSPRING5_JIS 0x0247
106#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI 0x0239 109#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI 0x0239
107#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO 0x023a 110#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO 0x023a
108#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b 111#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index cd74203c8178..33dde8724e02 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -900,8 +900,8 @@ int hidinput_connect(struct hid_device *hid, unsigned int force)
900 hid->ll_driver->hidinput_input_event; 900 hid->ll_driver->hidinput_input_event;
901 input_dev->open = hidinput_open; 901 input_dev->open = hidinput_open;
902 input_dev->close = hidinput_close; 902 input_dev->close = hidinput_close;
903 input_dev->setkeycode_new = hidinput_setkeycode; 903 input_dev->setkeycode = hidinput_setkeycode;
904 input_dev->getkeycode_new = hidinput_getkeycode; 904 input_dev->getkeycode = hidinput_getkeycode;
905 905
906 input_dev->name = hid->name; 906 input_dev->name = hid->name;
907 input_dev->phys = hid->phys; 907 input_dev->phys = hid->phys;
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..7f42d3a454d2 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -321,6 +321,9 @@ static ssize_t evdev_write(struct file *file, const char __user *buffer,
321 struct input_event event; 321 struct input_event event;
322 int retval; 322 int retval;
323 323
324 if (count < input_event_size())
325 return -EINVAL;
326
324 retval = mutex_lock_interruptible(&evdev->mutex); 327 retval = mutex_lock_interruptible(&evdev->mutex);
325 if (retval) 328 if (retval)
326 return retval; 329 return retval;
@@ -330,17 +333,16 @@ static ssize_t evdev_write(struct file *file, const char __user *buffer,
330 goto out; 333 goto out;
331 } 334 }
332 335
333 while (retval < count) { 336 do {
334
335 if (input_event_from_user(buffer + retval, &event)) { 337 if (input_event_from_user(buffer + retval, &event)) {
336 retval = -EFAULT; 338 retval = -EFAULT;
337 goto out; 339 goto out;
338 } 340 }
341 retval += input_event_size();
339 342
340 input_inject_event(&evdev->handle, 343 input_inject_event(&evdev->handle,
341 event.type, event.code, event.value); 344 event.type, event.code, event.value);
342 retval += input_event_size(); 345 } while (retval + input_event_size() <= count);
343 }
344 346
345 out: 347 out:
346 mutex_unlock(&evdev->mutex); 348 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..d6e8bd8a851c 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
@@ -1846,11 +1805,11 @@ int input_register_device(struct input_dev *dev)
1846 dev->rep[REP_PERIOD] = 33; 1805 dev->rep[REP_PERIOD] = 33;
1847 } 1806 }
1848 1807
1849 if (!dev->getkeycode && !dev->getkeycode_new) 1808 if (!dev->getkeycode)
1850 dev->getkeycode_new = input_default_getkeycode; 1809 dev->getkeycode = input_default_getkeycode;
1851 1810
1852 if (!dev->setkeycode && !dev->setkeycode_new) 1811 if (!dev->setkeycode)
1853 dev->setkeycode_new = input_default_setkeycode; 1812 dev->setkeycode = input_default_setkeycode;
1854 1813
1855 dev_set_name(&dev->dev, "input%ld", 1814 dev_set_name(&dev->dev, "input%ld",
1856 (unsigned long) atomic_inc_return(&input_no) - 1); 1815 (unsigned long) atomic_inc_return(&input_no) - 1);
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/lm8323.c b/drivers/input/keyboard/lm8323.c
index f7c2a166576b..b732870ecc89 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,8 +803,9 @@ 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
@@ -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
@@ -839,11 +842,10 @@ static int lm8323_resume(struct i2c_client *client)
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/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/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/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/uinput.c b/drivers/input/misc/uinput.c
index 82542a1c1098..364bdf43a381 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -347,8 +347,7 @@ static int uinput_setup_device(struct uinput_device *udev, const char __user *bu
347{ 347{
348 struct uinput_user_dev *user_dev; 348 struct uinput_user_dev *user_dev;
349 struct input_dev *dev; 349 struct input_dev *dev;
350 char *name; 350 int i;
351 int i, size;
352 int retval; 351 int retval;
353 352
354 if (count != sizeof(struct uinput_user_dev)) 353 if (count != sizeof(struct uinput_user_dev))
@@ -362,30 +361,25 @@ static int uinput_setup_device(struct uinput_device *udev, const char __user *bu
362 361
363 dev = udev->dev; 362 dev = udev->dev;
364 363
365 user_dev = kmalloc(sizeof(struct uinput_user_dev), GFP_KERNEL); 364 user_dev = memdup_user(buffer, sizeof(struct uinput_user_dev));
366 if (!user_dev) 365 if (IS_ERR(user_dev))
367 return -ENOMEM; 366 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 367
374 udev->ff_effects_max = user_dev->ff_effects_max; 368 udev->ff_effects_max = user_dev->ff_effects_max;
375 369
376 size = strnlen(user_dev->name, UINPUT_MAX_NAME_SIZE) + 1; 370 /* Ensure name is filled in */
377 if (!size) { 371 if (!user_dev->name[0]) {
378 retval = -EINVAL; 372 retval = -EINVAL;
379 goto exit; 373 goto exit;
380 } 374 }
381 375
382 kfree(dev->name); 376 kfree(dev->name);
383 dev->name = name = kmalloc(size, GFP_KERNEL); 377 dev->name = kstrndup(user_dev->name, UINPUT_MAX_NAME_SIZE,
384 if (!name) { 378 GFP_KERNEL);
379 if (!dev->name) {
385 retval = -ENOMEM; 380 retval = -ENOMEM;
386 goto exit; 381 goto exit;
387 } 382 }
388 strlcpy(name, user_dev->name, size);
389 383
390 dev->id.bustype = user_dev->id.bustype; 384 dev->id.bustype = user_dev->id.bustype;
391 dev->id.vendor = user_dev->id.vendor; 385 dev->id.vendor = user_dev->id.vendor;
@@ -622,7 +616,6 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
622 struct uinput_ff_upload ff_up; 616 struct uinput_ff_upload ff_up;
623 struct uinput_ff_erase ff_erase; 617 struct uinput_ff_erase ff_erase;
624 struct uinput_request *req; 618 struct uinput_request *req;
625 int length;
626 char *phys; 619 char *phys;
627 620
628 retval = mutex_lock_interruptible(&udev->mutex); 621 retval = mutex_lock_interruptible(&udev->mutex);
@@ -689,24 +682,15 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
689 retval = -EINVAL; 682 retval = -EINVAL;
690 goto out; 683 goto out;
691 } 684 }
692 length = strnlen_user(p, 1024); 685
693 if (length <= 0) { 686 phys = strndup_user(p, 1024);
694 retval = -EFAULT; 687 if (IS_ERR(phys)) {
695 break; 688 retval = PTR_ERR(phys);
689 goto out;
696 } 690 }
691
697 kfree(udev->dev->phys); 692 kfree(udev->dev->phys);
698 udev->dev->phys = phys = kmalloc(length, GFP_KERNEL); 693 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; 694 break;
711 695
712 case UI_BEGIN_FF_UPLOAD: 696 case UI_BEGIN_FF_UPLOAD:
diff --git a/drivers/input/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
index 7f85a862ad11..7077f9bf5ead 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,13 +294,16 @@ 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,
272 enum xenbus_state backend_state) 303 enum xenbus_state backend_state)
273{ 304{
274 struct xenkbd_info *info = dev_get_drvdata(&dev->dev); 305 struct xenkbd_info *info = dev_get_drvdata(&dev->dev);
275 int ret, val; 306 int val;
276 307
277 switch (backend_state) { 308 switch (backend_state) {
278 case XenbusStateInitialising: 309 case XenbusStateInitialising:
@@ -285,16 +316,6 @@ static void xenkbd_backend_changed(struct xenbus_device *dev,
285 316
286 case XenbusStateInitWait: 317 case XenbusStateInitWait:
287InitWait: 318InitWait:
288 ret = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
289 "feature-abs-pointer", "%d", &val);
290 if (ret < 0)
291 val = 0;
292 if (val) {
293 ret = xenbus_printf(XBT_NIL, info->xbdev->nodename,
294 "request-abs-pointer", "1");
295 if (ret)
296 pr_warning("can't request abs-pointer\n");
297 }
298 xenbus_switch_state(dev, XenbusStateConnected); 319 xenbus_switch_state(dev, XenbusStateConnected);
299 break; 320 break;
300 321
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
index ee82851afe3e..3aead91bacc8 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)
diff --git a/drivers/input/mouse/synaptics_i2c.c b/drivers/input/mouse/synaptics_i2c.c
index 0ae62f0bcb32..f6aa26d305ed 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 */
@@ -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/sparse-keymap.c b/drivers/input/sparse-keymap.c
index 7729e547ba65..337bf51bc984 100644
--- a/drivers/input/sparse-keymap.c
+++ b/drivers/input/sparse-keymap.c
@@ -210,8 +210,8 @@ int sparse_keymap_setup(struct input_dev *dev,
210 210
211 dev->keycode = map; 211 dev->keycode = map;
212 dev->keycodemax = map_size; 212 dev->keycodemax = map_size;
213 dev->getkeycode_new = sparse_keymap_getkeycode; 213 dev->getkeycode = sparse_keymap_getkeycode;
214 dev->setkeycode_new = sparse_keymap_setkeycode; 214 dev->setkeycode = sparse_keymap_setkeycode;
215 215
216 return 0; 216 return 0;
217 217
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..5597637cfd41 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -675,169 +675,87 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
675 return 1; 675 return 1;
676} 676}
677 677
678 678static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
679static void wacom_tpc_finger_in(struct wacom_wac *wacom, char *data, int idx)
680{ 679{
681 struct input_dev *input = wacom->input; 680 struct input_dev *input = wacom->input;
682 int finger = idx + 1; 681 unsigned char *data = wacom->data;
683 int x = le16_to_cpup((__le16 *)&data[finger * 2]) & 0x7fff; 682 int contact_with_no_pen_down_count = 0;
684 int y = le16_to_cpup((__le16 *)&data[4 + finger * 2]) & 0x7fff; 683 int i;
685 684
686 /* 685 for (i = 0; i < 2; i++) {
687 * Work around input core suppressing "duplicate" events since 686 int p = data[1] & (1 << i);
688 * we are abusing ABS_X/ABS_Y to transmit multi-finger data. 687 bool touch = p && !wacom->shared->stylus_in_proximity;
689 * This should go away once we switch to true multitouch 688
690 * protocol. 689 input_mt_slot(input, i);
691 */ 690 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
692 if (wacom->last_finger != finger) { 691 if (touch) {
693 if (x == input_abs_get_val(input, ABS_X)) 692 int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
694 x++; 693 int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
695 694
696 if (y == input_abs_get_val(input, ABS_Y)) 695 input_report_abs(input, ABS_MT_POSITION_X, x);
697 y++; 696 input_report_abs(input, ABS_MT_POSITION_Y, y);
697 contact_with_no_pen_down_count++;
698 }
698 } 699 }
699 700
700 input_report_abs(input, ABS_X, x); 701 /* keep touch state for pen event */
701 input_report_abs(input, ABS_Y, y); 702 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 703
709 wacom->last_finger = finger; 704 input_mt_report_pointer_emulation(input, true);
710}
711 705
712static void wacom_tpc_touch_out(struct wacom_wac *wacom, int idx) 706 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} 707}
726 708
727static void wacom_tpc_touch_in(struct wacom_wac *wacom, size_t len) 709static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
728{ 710{
729 char *data = wacom->data; 711 char *data = wacom->data;
730 struct input_dev *input = wacom->input; 712 struct input_dev *input = wacom->input;
713 bool prox;
714 int x = 0, y = 0;
731 715
732 wacom->tool[1] = BTN_TOOL_DOUBLETAP; 716 if (!wacom->shared->stylus_in_proximity) {
733 wacom->id[0] = TOUCH_DEVICE_ID; 717 if (len == WACOM_PKGLEN_TPC1FG) {
734 wacom->tool[2] = BTN_TOOL_TRIPLETAP; 718 prox = data[0] & 0x01;
735 719 x = get_unaligned_le16(&data[1]);
736 if (len != WACOM_PKGLEN_TPC1FG) { 720 y = get_unaligned_le16(&data[3]);
737 721 } else { /* with capacity */
738 switch (data[0]) { 722 prox = data[1] & 0x01;
723 x = le16_to_cpup((__le16 *)&data[2]);
724 y = le16_to_cpup((__le16 *)&data[4]);
725 }
726 } else
727 /* force touch out when pen is in prox */
728 prox = 0;
739 729
740 case WACOM_REPORT_TPC1FG: 730 if (prox) {
741 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); 731 input_report_abs(input, ABS_X, x);
742 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); 732 input_report_abs(input, ABS_Y, y);
743 input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6])); 733 }
744 input_report_key(input, BTN_TOUCH, le16_to_cpup((__le16 *)&data[6])); 734 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 735
750 case WACOM_REPORT_TPC2FG: 736 /* keep touch state for pen events */
751 if (data[1] & 0x01) 737 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 738
756 if (data[1] & 0x02) 739 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} 740}
771 741
772static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len) 742static int wacom_tpc_pen(struct wacom_wac *wacom)
773{ 743{
774 struct wacom_features *features = &wacom->features; 744 struct wacom_features *features = &wacom->features;
775 char *data = wacom->data; 745 char *data = wacom->data;
776 struct input_dev *input = wacom->input; 746 struct input_dev *input = wacom->input;
777 int prox = 0, pressure; 747 int pressure;
778 int retval = 0; 748 bool prox = data[1] & 0x20;
779 749
780 dbg("wacom_tpc_irq: received report #%d", data[0]); 750 if (!wacom->shared->stylus_in_proximity) /* first in prox */
781 751 /* Going into proximity select tool */
782 if (len == WACOM_PKGLEN_TPC1FG || /* single touch */ 752 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
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
793 wacom->id[1] = 0;
794 return 0;
795 }
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 753
818 if (wacom->id[1] & 0x02) 754 /* keep pen state for touch events */
819 wacom_tpc_touch_out(wacom, 1); 755 wacom->shared->stylus_in_proximity = prox;
820 } else
821 /* one finger touch */
822 wacom_tpc_touch_out(wacom, 0);
823 756
824 wacom->id[0] = 0; 757 /* send pen events only when touch is up or forced out */
825 } 758 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); 759 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
842 input_report_key(input, BTN_STYLUS2, data[1] & 0x10); 760 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
843 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); 761 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
@@ -847,15 +765,27 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
847 pressure = features->pressure_max + pressure + 1; 765 pressure = features->pressure_max + pressure + 1;
848 input_report_abs(input, ABS_PRESSURE, pressure); 766 input_report_abs(input, ABS_PRESSURE, pressure);
849 input_report_key(input, BTN_TOUCH, data[1] & 0x05); 767 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); 768 input_report_key(input, wacom->tool[0], prox);
855 input_report_abs(input, ABS_MISC, wacom->id[0]); 769 return 1;
856 retval = 1;
857 } 770 }
858 return retval; 771
772 return 0;
773}
774
775static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
776{
777 char *data = wacom->data;
778
779 dbg("wacom_tpc_irq: received report #%d", data[0]);
780
781 if (len == WACOM_PKGLEN_TPC1FG || data[0] == WACOM_REPORT_TPC1FG)
782 return wacom_tpc_single_touch(wacom, len);
783 else if (data[0] == WACOM_REPORT_TPC2FG)
784 return wacom_tpc_mt_touch(wacom);
785 else if (data[0] == WACOM_REPORT_PENABLED)
786 return wacom_tpc_pen(wacom);
787
788 return 0;
859} 789}
860 790
861static int wacom_bpt_touch(struct wacom_wac *wacom) 791static int wacom_bpt_touch(struct wacom_wac *wacom)
@@ -1078,7 +1008,7 @@ void wacom_setup_device_quirks(struct wacom_features *features)
1078{ 1008{
1079 1009
1080 /* touch device found but size is not defined. use default */ 1010 /* touch device found but size is not defined. use default */
1081 if (features->device_type == BTN_TOOL_DOUBLETAP && !features->x_max) { 1011 if (features->device_type == BTN_TOOL_FINGER && !features->x_max) {
1082 features->x_max = 1023; 1012 features->x_max = 1023;
1083 features->y_max = 1023; 1013 features->y_max = 1023;
1084 } 1014 }
@@ -1090,7 +1020,7 @@ void wacom_setup_device_quirks(struct wacom_features *features)
1090 1020
1091 /* quirks for bamboo touch */ 1021 /* quirks for bamboo touch */
1092 if (features->type == BAMBOO_PT && 1022 if (features->type == BAMBOO_PT &&
1093 features->device_type == BTN_TOOL_TRIPLETAP) { 1023 features->device_type == BTN_TOOL_DOUBLETAP) {
1094 features->x_max <<= 5; 1024 features->x_max <<= 5;
1095 features->y_max <<= 5; 1025 features->y_max <<= 5;
1096 features->x_fuzz <<= 5; 1026 features->x_fuzz <<= 5;
@@ -1226,27 +1156,30 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
1226 break; 1156 break;
1227 1157
1228 case TABLETPC2FG: 1158 case TABLETPC2FG:
1229 if (features->device_type == BTN_TOOL_TRIPLETAP) { 1159 if (features->device_type == BTN_TOOL_DOUBLETAP) {
1230 __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); 1160
1231 input_set_capability(input_dev, EV_MSC, MSC_SERIAL); 1161 input_mt_init_slots(input_dev, 2);
1162 input_set_abs_params(input_dev, ABS_MT_TOOL_TYPE,
1163 0, MT_TOOL_MAX, 0, 0);
1164 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1165 0, features->x_max, 0, 0);
1166 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1167 0, features->y_max, 0, 0);
1232 } 1168 }
1233 /* fall through */ 1169 /* fall through */
1234 1170
1235 case TABLETPC: 1171 case TABLETPC:
1236 if (features->device_type == BTN_TOOL_DOUBLETAP || 1172 __clear_bit(ABS_MISC, input_dev->absbit);
1237 features->device_type == BTN_TOOL_TRIPLETAP) { 1173
1174 if (features->device_type != BTN_TOOL_PEN) {
1238 input_abs_set_res(input_dev, ABS_X, 1175 input_abs_set_res(input_dev, ABS_X,
1239 wacom_calculate_touch_res(features->x_max, 1176 wacom_calculate_touch_res(features->x_max,
1240 features->x_phy)); 1177 features->x_phy));
1241 input_abs_set_res(input_dev, ABS_Y, 1178 input_abs_set_res(input_dev, ABS_Y,
1242 wacom_calculate_touch_res(features->y_max, 1179 wacom_calculate_touch_res(features->y_max,
1243 features->y_phy)); 1180 features->y_phy));
1244 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
1245 }
1246
1247 if (features->device_type != BTN_TOOL_PEN)
1248 break; /* no need to process stylus stuff */ 1181 break; /* no need to process stylus stuff */
1249 1182 }
1250 /* fall through */ 1183 /* fall through */
1251 1184
1252 case PL: 1185 case PL:
@@ -1264,7 +1197,7 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
1264 case BAMBOO_PT: 1197 case BAMBOO_PT:
1265 __clear_bit(ABS_MISC, input_dev->absbit); 1198 __clear_bit(ABS_MISC, input_dev->absbit);
1266 1199
1267 if (features->device_type == BTN_TOOL_TRIPLETAP) { 1200 if (features->device_type == BTN_TOOL_DOUBLETAP) {
1268 __set_bit(BTN_LEFT, input_dev->keybit); 1201 __set_bit(BTN_LEFT, input_dev->keybit);
1269 __set_bit(BTN_FORWARD, input_dev->keybit); 1202 __set_bit(BTN_FORWARD, input_dev->keybit);
1270 __set_bit(BTN_BACK, input_dev->keybit); 1203 __set_bit(BTN_BACK, input_dev->keybit);
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index b1310ec9720c..835f756b150c 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -88,15 +88,15 @@ struct wacom_features {
88 88
89struct wacom_shared { 89struct wacom_shared {
90 bool stylus_in_proximity; 90 bool stylus_in_proximity;
91 bool touch_down;
91}; 92};
92 93
93struct wacom_wac { 94struct wacom_wac {
94 char name[64]; 95 char name[64];
95 unsigned char *data; 96 unsigned char *data;
96 int tool[3]; 97 int tool[2];
97 int id[3]; 98 int id[2];
98 __u32 serial[2]; 99 __u32 serial[2];
99 int last_finger;
100 struct wacom_features features; 100 struct wacom_features features;
101 struct wacom_shared *shared; 101 struct wacom_shared *shared;
102 struct input_dev *input; 102 struct input_dev *input;
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 61834ae282e1..112ec55f2939 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
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/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..87420616efa4
--- /dev/null
+++ b/drivers/input/touchscreen/tsc2005.c
@@ -0,0 +1,756 @@
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(jiffies +
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 mutex_lock(&ts->mutex);
481
482 if (time_is_after_jiffies(ts->last_valid_interrupt +
483 msecs_to_jiffies(ts->esd_timeout)))
484 goto out;
485
486 /* We should be able to read register without disabling interrupts. */
487 error = tsc2005_read(ts, TSC2005_REG_CFR0, &r);
488 if (!error &&
489 !((r ^ TSC2005_CFR0_INITVALUE) & TSC2005_CFR0_RW_MASK)) {
490 goto out;
491 }
492
493 /*
494 * If we could not read our known value from configuration register 0
495 * then we should reset the controller as if from power-up and start
496 * scanning again.
497 */
498 dev_info(&ts->spi->dev, "TSC2005 not responding - resetting\n");
499
500 disable_irq(ts->spi->irq);
501 del_timer_sync(&ts->penup_timer);
502
503 tsc2005_update_pen_state(ts, 0, 0, 0);
504
505 ts->set_reset(false);
506 usleep_range(100, 500); /* only 10us required */
507 ts->set_reset(true);
508
509 enable_irq(ts->spi->irq);
510 tsc2005_start_scan(ts);
511
512out:
513 /* re-arm the watchdog */
514 schedule_delayed_work(&ts->esd_work,
515 round_jiffies(jiffies +
516 msecs_to_jiffies(ts->esd_timeout)));
517 mutex_unlock(&ts->mutex);
518}
519
520static int tsc2005_open(struct input_dev *input)
521{
522 struct tsc2005 *ts = input_get_drvdata(input);
523
524 mutex_lock(&ts->mutex);
525
526 if (!ts->suspended)
527 __tsc2005_enable(ts);
528
529 ts->opened = true;
530
531 mutex_unlock(&ts->mutex);
532
533 return 0;
534}
535
536static void tsc2005_close(struct input_dev *input)
537{
538 struct tsc2005 *ts = input_get_drvdata(input);
539
540 mutex_lock(&ts->mutex);
541
542 if (!ts->suspended)
543 __tsc2005_disable(ts);
544
545 ts->opened = false;
546
547 mutex_unlock(&ts->mutex);
548}
549
550static void __devinit tsc2005_setup_spi_xfer(struct tsc2005 *ts)
551{
552 tsc2005_setup_read(&ts->spi_x, TSC2005_REG_X, false);
553 tsc2005_setup_read(&ts->spi_y, TSC2005_REG_Y, false);
554 tsc2005_setup_read(&ts->spi_z1, TSC2005_REG_Z1, false);
555 tsc2005_setup_read(&ts->spi_z2, TSC2005_REG_Z2, true);
556
557 spi_message_init(&ts->spi_read_msg);
558 spi_message_add_tail(&ts->spi_x.spi_xfer, &ts->spi_read_msg);
559 spi_message_add_tail(&ts->spi_y.spi_xfer, &ts->spi_read_msg);
560 spi_message_add_tail(&ts->spi_z1.spi_xfer, &ts->spi_read_msg);
561 spi_message_add_tail(&ts->spi_z2.spi_xfer, &ts->spi_read_msg);
562}
563
564static int __devinit tsc2005_probe(struct spi_device *spi)
565{
566 const struct tsc2005_platform_data *pdata = spi->dev.platform_data;
567 struct tsc2005 *ts;
568 struct input_dev *input_dev;
569 unsigned int max_x, max_y, max_p;
570 unsigned int fudge_x, fudge_y, fudge_p;
571 int error;
572
573 if (!pdata) {
574 dev_dbg(&spi->dev, "no platform data\n");
575 return -ENODEV;
576 }
577
578 fudge_x = pdata->ts_x_fudge ? : 4;
579 fudge_y = pdata->ts_y_fudge ? : 8;
580 fudge_p = pdata->ts_pressure_fudge ? : 2;
581 max_x = pdata->ts_x_max ? : MAX_12BIT;
582 max_y = pdata->ts_y_max ? : MAX_12BIT;
583 max_p = pdata->ts_pressure_max ? : MAX_12BIT;
584
585 if (spi->irq <= 0) {
586 dev_dbg(&spi->dev, "no irq\n");
587 return -ENODEV;
588 }
589
590 spi->mode = SPI_MODE_0;
591 spi->bits_per_word = 8;
592 if (!spi->max_speed_hz)
593 spi->max_speed_hz = TSC2005_SPI_MAX_SPEED_HZ;
594
595 error = spi_setup(spi);
596 if (error)
597 return error;
598
599 ts = kzalloc(sizeof(*ts), GFP_KERNEL);
600 input_dev = input_allocate_device();
601 if (!ts || !input_dev) {
602 error = -ENOMEM;
603 goto err_free_mem;
604 }
605
606 ts->spi = spi;
607 ts->idev = input_dev;
608
609 ts->x_plate_ohm = pdata->ts_x_plate_ohm ? : 280;
610 ts->esd_timeout = pdata->esd_timeout_ms;
611 ts->set_reset = pdata->set_reset;
612
613 mutex_init(&ts->mutex);
614
615 spin_lock_init(&ts->lock);
616 setup_timer(&ts->penup_timer, tsc2005_penup_timer, (unsigned long)ts);
617
618 INIT_DELAYED_WORK(&ts->esd_work, tsc2005_esd_work);
619
620 tsc2005_setup_spi_xfer(ts);
621
622 snprintf(ts->phys, sizeof(ts->phys),
623 "%s/input-ts", dev_name(&spi->dev));
624
625 input_dev->name = "TSC2005 touchscreen";
626 input_dev->phys = ts->phys;
627 input_dev->id.bustype = BUS_SPI;
628 input_dev->dev.parent = &spi->dev;
629 input_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY);
630 input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
631
632 input_set_abs_params(input_dev, ABS_X, 0, max_x, fudge_x, 0);
633 input_set_abs_params(input_dev, ABS_Y, 0, max_y, fudge_y, 0);
634 input_set_abs_params(input_dev, ABS_PRESSURE, 0, max_p, fudge_p, 0);
635
636 input_dev->open = tsc2005_open;
637 input_dev->close = tsc2005_close;
638
639 input_set_drvdata(input_dev, ts);
640
641 /* Ensure the touchscreen is off */
642 tsc2005_stop_scan(ts);
643
644 error = request_threaded_irq(spi->irq, NULL, tsc2005_irq_thread,
645 IRQF_TRIGGER_RISING, "tsc2005", ts);
646 if (error) {
647 dev_err(&spi->dev, "Failed to request irq, err: %d\n", error);
648 goto err_free_mem;
649 }
650
651 spi_set_drvdata(spi, ts);
652 error = sysfs_create_group(&spi->dev.kobj, &tsc2005_attr_group);
653 if (error) {
654 dev_err(&spi->dev,
655 "Failed to create sysfs attributes, err: %d\n", error);
656 goto err_clear_drvdata;
657 }
658
659 error = input_register_device(ts->idev);
660 if (error) {
661 dev_err(&spi->dev,
662 "Failed to register input device, err: %d\n", error);
663 goto err_remove_sysfs;
664 }
665
666 set_irq_wake(spi->irq, 1);
667 return 0;
668
669err_remove_sysfs:
670 sysfs_remove_group(&spi->dev.kobj, &tsc2005_attr_group);
671err_clear_drvdata:
672 spi_set_drvdata(spi, NULL);
673 free_irq(spi->irq, ts);
674err_free_mem:
675 input_free_device(input_dev);
676 kfree(ts);
677 return error;
678}
679
680static int __devexit tsc2005_remove(struct spi_device *spi)
681{
682 struct tsc2005 *ts = spi_get_drvdata(spi);
683
684 sysfs_remove_group(&ts->spi->dev.kobj, &tsc2005_attr_group);
685
686 free_irq(ts->spi->irq, ts);
687 input_unregister_device(ts->idev);
688 kfree(ts);
689
690 spi_set_drvdata(spi, NULL);
691 return 0;
692}
693
694#ifdef CONFIG_PM_SLEEP
695static int tsc2005_suspend(struct device *dev)
696{
697 struct spi_device *spi = to_spi_device(dev);
698 struct tsc2005 *ts = spi_get_drvdata(spi);
699
700 mutex_lock(&ts->mutex);
701
702 if (!ts->suspended && ts->opened)
703 __tsc2005_disable(ts);
704
705 ts->suspended = true;
706
707 mutex_unlock(&ts->mutex);
708
709 return 0;
710}
711
712static int tsc2005_resume(struct device *dev)
713{
714 struct spi_device *spi = to_spi_device(dev);
715 struct tsc2005 *ts = spi_get_drvdata(spi);
716
717 mutex_lock(&ts->mutex);
718
719 if (ts->suspended && ts->opened)
720 __tsc2005_enable(ts);
721
722 ts->suspended = false;
723
724 mutex_unlock(&ts->mutex);
725
726 return 0;
727}
728#endif
729
730static SIMPLE_DEV_PM_OPS(tsc2005_pm_ops, tsc2005_suspend, tsc2005_resume);
731
732static struct spi_driver tsc2005_driver = {
733 .driver = {
734 .name = "tsc2005",
735 .owner = THIS_MODULE,
736 .pm = &tsc2005_pm_ops,
737 },
738 .probe = tsc2005_probe,
739 .remove = __devexit_p(tsc2005_remove),
740};
741
742static int __init tsc2005_init(void)
743{
744 return spi_register_driver(&tsc2005_driver);
745}
746module_init(tsc2005_init);
747
748static void __exit tsc2005_exit(void)
749{
750 spi_unregister_driver(&tsc2005_driver);
751}
752module_exit(tsc2005_exit);
753
754MODULE_AUTHOR("Lauri Leukkunen <lauri.leukkunen@nokia.com>");
755MODULE_DESCRIPTION("TSC2005 Touchscreen Driver");
756MODULE_LICENSE("GPL");
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/media/dvb/dvb-usb/dvb-usb-remote.c b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
index 23005b3cf30b..b2b9415d874d 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
@@ -8,60 +8,71 @@
8#include "dvb-usb-common.h" 8#include "dvb-usb-common.h"
9#include <linux/usb/input.h> 9#include <linux/usb/input.h>
10 10
11static unsigned int
12legacy_dvb_usb_get_keymap_index(const struct input_keymap_entry *ke,
13 struct rc_map_table *keymap,
14 unsigned int keymap_size)
15{
16 unsigned int index;
17 unsigned int scancode;
18
19 if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
20 index = ke->index;
21 } else {
22 if (input_scancode_to_scalar(ke, &scancode))
23 return keymap_size;
24
25 /* See if we can match the raw key code. */
26 for (index = 0; index < keymap_size; index++)
27 if (keymap[index].scancode == scancode)
28 break;
29
30 /* See if there is an unused hole in the map */
31 if (index >= keymap_size) {
32 for (index = 0; index < keymap_size; index++) {
33 if (keymap[index].keycode == KEY_RESERVED ||
34 keymap[index].keycode == KEY_UNKNOWN) {
35 break;
36 }
37 }
38 }
39 }
40
41 return index;
42}
43
11static int legacy_dvb_usb_getkeycode(struct input_dev *dev, 44static int legacy_dvb_usb_getkeycode(struct input_dev *dev,
12 unsigned int scancode, unsigned int *keycode) 45 struct input_keymap_entry *ke)
13{ 46{
14 struct dvb_usb_device *d = input_get_drvdata(dev); 47 struct dvb_usb_device *d = input_get_drvdata(dev);
15
16 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table; 48 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
17 int i; 49 unsigned int keymap_size = d->props.rc.legacy.rc_map_size;
50 unsigned int index;
18 51
19 /* See if we can match the raw key code. */ 52 index = legacy_dvb_usb_get_keymap_index(ke, keymap, keymap_size);
20 for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) 53 if (index >= keymap_size)
21 if (keymap[i].scancode == scancode) { 54 return -EINVAL;
22 *keycode = keymap[i].keycode;
23 return 0;
24 }
25 55
26 /* 56 ke->keycode = keymap[index].keycode;
27 * If is there extra space, returns KEY_RESERVED, 57 if (ke->keycode == KEY_UNKNOWN)
28 * otherwise, input core won't let legacy_dvb_usb_setkeycode 58 ke->keycode = KEY_RESERVED;
29 * to work 59 ke->len = sizeof(keymap[index].scancode);
30 */ 60 memcpy(&ke->scancode, &keymap[index].scancode, ke->len);
31 for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) 61 ke->index = index;
32 if (keymap[i].keycode == KEY_RESERVED ||
33 keymap[i].keycode == KEY_UNKNOWN) {
34 *keycode = KEY_RESERVED;
35 return 0;
36 }
37 62
38 return -EINVAL; 63 return 0;
39} 64}
40 65
41static int legacy_dvb_usb_setkeycode(struct input_dev *dev, 66static int legacy_dvb_usb_setkeycode(struct input_dev *dev,
42 unsigned int scancode, unsigned int keycode) 67 const struct input_keymap_entry *ke,
68 unsigned int *old_keycode)
43{ 69{
44 struct dvb_usb_device *d = input_get_drvdata(dev); 70 struct dvb_usb_device *d = input_get_drvdata(dev);
45
46 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table; 71 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
47 int i; 72 unsigned int keymap_size = d->props.rc.legacy.rc_map_size;
48 73 unsigned int index;
49 /* Search if it is replacing an existing keycode */
50 for (i = 0; i < d->props.rc.legacy.rc_map_size; i++)
51 if (keymap[i].scancode == scancode) {
52 keymap[i].keycode = keycode;
53 return 0;
54 }
55
56 /* Search if is there a clean entry. If so, use it */
57 for (i = 0; i < d->props.rc.legacy.rc_map_size; i++)
58 if (keymap[i].keycode == KEY_RESERVED ||
59 keymap[i].keycode == KEY_UNKNOWN) {
60 keymap[i].scancode = scancode;
61 keymap[i].keycode = keycode;
62 return 0;
63 }
64 74
75 index = legacy_dvb_usb_get_keymap_index(ke, keymap, keymap_size);
65 /* 76 /*
66 * FIXME: Currently, it is not possible to increase the size of 77 * FIXME: Currently, it is not possible to increase the size of
67 * scancode table. For it to happen, one possibility 78 * scancode table. For it to happen, one possibility
@@ -69,8 +80,24 @@ static int legacy_dvb_usb_setkeycode(struct input_dev *dev,
69 * copying data, appending the new key on it, and freeing 80 * copying data, appending the new key on it, and freeing
70 * the old one - or maybe just allocating some spare space 81 * the old one - or maybe just allocating some spare space
71 */ 82 */
83 if (index >= keymap_size)
84 return -EINVAL;
85
86 *old_keycode = keymap[index].keycode;
87 keymap->keycode = ke->keycode;
88 __set_bit(ke->keycode, dev->keybit);
89
90 if (*old_keycode != KEY_RESERVED) {
91 __clear_bit(*old_keycode, dev->keybit);
92 for (index = 0; index < keymap_size; index++) {
93 if (keymap[index].keycode == *old_keycode) {
94 __set_bit(*old_keycode, dev->keybit);
95 break;
96 }
97 }
98 }
72 99
73 return -EINVAL; 100 return 0;
74} 101}
75 102
76/* Remote-control poll function - called every dib->rc_query_interval ms to see 103/* Remote-control poll function - called every dib->rc_query_interval ms to see
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 5b4422ef4e6d..5ac1baf45c8e 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -966,8 +966,8 @@ struct rc_dev *rc_allocate_device(void)
966 return NULL; 966 return NULL;
967 } 967 }
968 968
969 dev->input_dev->getkeycode_new = ir_getkeycode; 969 dev->input_dev->getkeycode = ir_getkeycode;
970 dev->input_dev->setkeycode_new = ir_setkeycode; 970 dev->input_dev->setkeycode = ir_setkeycode;
971 input_set_drvdata(dev->input_dev, dev); 971 input_set_drvdata(dev->input_dev, dev);
972 972
973 spin_lock_init(&dev->rc_map.lock); 973 spin_lock_init(&dev->rc_map.lock);
diff --git a/include/linux/i2c/qt602240_ts.h b/include/linux/i2c/atmel_mxt_ts.h
index c5033e101094..f027f7a63511 100644
--- a/include/linux/i2c/qt602240_ts.h
+++ b/include/linux/i2c/atmel_mxt_ts.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * AT42QT602240/ATMXT224 Touchscreen driver 2 * Atmel maXTouch Touchscreen driver
3 * 3 *
4 * Copyright (C) 2010 Samsung Electronics Co.Ltd 4 * Copyright (C) 2010 Samsung Electronics Co.Ltd
5 * Author: Joonyoung Shim <jy0922.shim@samsung.com> 5 * Author: Joonyoung Shim <jy0922.shim@samsung.com>
@@ -10,21 +10,26 @@
10 * option) any later version. 10 * option) any later version.
11 */ 11 */
12 12
13#ifndef __LINUX_QT602240_TS_H 13#ifndef __LINUX_ATMEL_MXT_TS_H
14#define __LINUX_QT602240_TS_H 14#define __LINUX_ATMEL_MXT_TS_H
15
16#include <linux/types.h>
15 17
16/* Orient */ 18/* Orient */
17#define QT602240_NORMAL 0x0 19#define MXT_NORMAL 0x0
18#define QT602240_DIAGONAL 0x1 20#define MXT_DIAGONAL 0x1
19#define QT602240_HORIZONTAL_FLIP 0x2 21#define MXT_HORIZONTAL_FLIP 0x2
20#define QT602240_ROTATED_90_COUNTER 0x3 22#define MXT_ROTATED_90_COUNTER 0x3
21#define QT602240_VERTICAL_FLIP 0x4 23#define MXT_VERTICAL_FLIP 0x4
22#define QT602240_ROTATED_90 0x5 24#define MXT_ROTATED_90 0x5
23#define QT602240_ROTATED_180 0x6 25#define MXT_ROTATED_180 0x6
24#define QT602240_DIAGONAL_COUNTER 0x7 26#define MXT_DIAGONAL_COUNTER 0x7
27
28/* The platform data for the Atmel maXTouch touchscreen driver */
29struct mxt_platform_data {
30 const u8 *config;
31 size_t config_length;
25 32
26/* The platform data for the AT42QT602240/ATMXT224 touchscreen driver */
27struct qt602240_platform_data {
28 unsigned int x_line; 33 unsigned int x_line;
29 unsigned int y_line; 34 unsigned int y_line;
30 unsigned int x_size; 35 unsigned int x_size;
@@ -33,6 +38,7 @@ struct qt602240_platform_data {
33 unsigned int threshold; 38 unsigned int threshold;
34 unsigned int voltage; 39 unsigned int voltage;
35 unsigned char orient; 40 unsigned char orient;
41 unsigned long irqflags;
36}; 42};
37 43
38#endif /* __LINUX_QT602240_TS_H */ 44#endif /* __LINUX_ATMEL_MXT_TS_H */
diff --git a/include/linux/i2c/mcs.h b/include/linux/i2c/mcs.h
index 725ae7c313ff..61bb18a4fd3c 100644
--- a/include/linux/i2c/mcs.h
+++ b/include/linux/i2c/mcs.h
@@ -18,6 +18,7 @@
18#define MCS_KEY_CODE(v) ((v) & 0xffff) 18#define MCS_KEY_CODE(v) ((v) & 0xffff)
19 19
20struct mcs_platform_data { 20struct mcs_platform_data {
21 void (*poweron)(bool);
21 void (*cfg_pin)(void); 22 void (*cfg_pin)(void);
22 23
23 /* touchscreen */ 24 /* touchscreen */
diff --git a/include/linux/input-polldev.h b/include/linux/input-polldev.h
index 5e3dddf8f562..ce0b72464eb8 100644
--- a/include/linux/input-polldev.h
+++ b/include/linux/input-polldev.h
@@ -22,12 +22,12 @@
22 * @poll: driver-supplied method that polls the device and posts 22 * @poll: driver-supplied method that polls the device and posts
23 * input events (mandatory). 23 * input events (mandatory).
24 * @poll_interval: specifies how often the poll() method should be called. 24 * @poll_interval: specifies how often the poll() method should be called.
25 * Defaults to 500 msec unless overriden when registering the device. 25 * Defaults to 500 msec unless overridden when registering the device.
26 * @poll_interval_max: specifies upper bound for the poll interval. 26 * @poll_interval_max: specifies upper bound for the poll interval.
27 * Defaults to the initial value of @poll_interval. 27 * Defaults to the initial value of @poll_interval.
28 * @poll_interval_min: specifies lower bound for the poll interval. 28 * @poll_interval_min: specifies lower bound for the poll interval.
29 * Defaults to 0. 29 * Defaults to 0.
30 * @input: input device structire associated with the polled device. 30 * @input: input device structure associated with the polled device.
31 * Must be properly initialized by the driver (id, name, phys, bits). 31 * Must be properly initialized by the driver (id, name, phys, bits).
32 * 32 *
33 * Polled input device provides a skeleton for supporting simple input 33 * Polled input device provides a skeleton for supporting simple input
diff --git a/include/linux/input.h b/include/linux/input.h
index e428382ca28a..056ae8a5bd9b 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -1154,8 +1154,6 @@ struct ff_effect {
1154 * sparse keymaps. If not supplied default mechanism will be used. 1154 * sparse keymaps. If not supplied default mechanism will be used.
1155 * The method is being called while holding event_lock and thus must 1155 * The method is being called while holding event_lock and thus must
1156 * not sleep 1156 * not sleep
1157 * @getkeycode_new: transition method
1158 * @setkeycode_new: transition method
1159 * @ff: force feedback structure associated with the device if device 1157 * @ff: force feedback structure associated with the device if device
1160 * supports force feedback effects 1158 * supports force feedback effects
1161 * @repeat_key: stores key code of the last key pressed; used to implement 1159 * @repeat_key: stores key code of the last key pressed; used to implement
@@ -1234,14 +1232,10 @@ struct input_dev {
1234 void *keycode; 1232 void *keycode;
1235 1233
1236 int (*setkeycode)(struct input_dev *dev, 1234 int (*setkeycode)(struct input_dev *dev,
1237 unsigned int scancode, unsigned int keycode); 1235 const struct input_keymap_entry *ke,
1236 unsigned int *old_keycode);
1238 int (*getkeycode)(struct input_dev *dev, 1237 int (*getkeycode)(struct input_dev *dev,
1239 unsigned int scancode, unsigned int *keycode); 1238 struct input_keymap_entry *ke);
1240 int (*setkeycode_new)(struct input_dev *dev,
1241 const struct input_keymap_entry *ke,
1242 unsigned int *old_keycode);
1243 int (*getkeycode_new)(struct input_dev *dev,
1244 struct input_keymap_entry *ke);
1245 1239
1246 struct ff_device *ff; 1240 struct ff_device *ff;
1247 1241
diff --git a/include/linux/mfd/wm831x/pdata.h b/include/linux/mfd/wm831x/pdata.h
index fd322aca33ba..173086d42af4 100644
--- a/include/linux/mfd/wm831x/pdata.h
+++ b/include/linux/mfd/wm831x/pdata.h
@@ -80,7 +80,8 @@ struct wm831x_touch_pdata {
80 int isel; /** Current for pen down (uA) */ 80 int isel; /** Current for pen down (uA) */
81 int rpu; /** Pen down sensitivity resistor divider */ 81 int rpu; /** Pen down sensitivity resistor divider */
82 int pressure; /** Report pressure (boolean) */ 82 int pressure; /** Report pressure (boolean) */
83 int data_irq; /** Touch data ready IRQ */ 83 unsigned int data_irq; /** Touch data ready IRQ */
84 unsigned int pd_irq; /** Touch pendown detect IRQ */
84}; 85};
85 86
86enum wm831x_watchdog_action { 87enum wm831x_watchdog_action {
diff --git a/include/linux/spi/tsc2005.h b/include/linux/spi/tsc2005.h
new file mode 100644
index 000000000000..d9b0c84220c7
--- /dev/null
+++ b/include/linux/spi/tsc2005.h
@@ -0,0 +1,41 @@
1/*
2 * This file is part of TSC2005 touchscreen driver
3 *
4 * Copyright (C) 2009-2010 Nokia Corporation
5 *
6 * Contact: Aaro Koskinen <aaro.koskinen@nokia.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#ifndef _LINUX_SPI_TSC2005_H
25#define _LINUX_SPI_TSC2005_H
26
27#include <linux/types.h>
28
29struct tsc2005_platform_data {
30 int ts_pressure_max;
31 int ts_pressure_fudge;
32 int ts_x_max;
33 int ts_x_fudge;
34 int ts_y_max;
35 int ts_y_fudge;
36 int ts_x_plate_ohm;
37 unsigned int esd_timeout_ms;
38 void (*set_reset)(bool enable);
39};
40
41#endif