diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-05-24 03:06:26 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-05-24 03:06:26 -0400 |
commit | b73077eb03f510a84b102fb97640e595a958403c (patch) | |
tree | 8b639000418e2756bf6baece4e00e07d2534bccc /drivers/input | |
parent | 28350e330cfab46b60a1dbf763b678d859f9f3d9 (diff) | |
parent | 9d2e173644bb5c42ff1b280fbdda3f195a7cf1f7 (diff) |
Merge branch 'next' into for-linus
Diffstat (limited to 'drivers/input')
58 files changed, 1932 insertions, 392 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 88d8e4cb419a..be0921ef6b52 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c | |||
@@ -41,6 +41,7 @@ struct evdev { | |||
41 | struct evdev_client { | 41 | struct evdev_client { |
42 | unsigned int head; | 42 | unsigned int head; |
43 | unsigned int tail; | 43 | unsigned int tail; |
44 | unsigned int packet_head; /* [future] position of the first element of next packet */ | ||
44 | spinlock_t buffer_lock; /* protects access to buffer, head and tail */ | 45 | spinlock_t buffer_lock; /* protects access to buffer, head and tail */ |
45 | struct fasync_struct *fasync; | 46 | struct fasync_struct *fasync; |
46 | struct evdev *evdev; | 47 | struct evdev *evdev; |
@@ -72,12 +73,16 @@ static void evdev_pass_event(struct evdev_client *client, | |||
72 | client->buffer[client->tail].type = EV_SYN; | 73 | client->buffer[client->tail].type = EV_SYN; |
73 | client->buffer[client->tail].code = SYN_DROPPED; | 74 | client->buffer[client->tail].code = SYN_DROPPED; |
74 | client->buffer[client->tail].value = 0; | 75 | client->buffer[client->tail].value = 0; |
75 | } | ||
76 | 76 | ||
77 | spin_unlock(&client->buffer_lock); | 77 | client->packet_head = client->tail; |
78 | } | ||
78 | 79 | ||
79 | if (event->type == EV_SYN) | 80 | if (event->type == EV_SYN && event->code == SYN_REPORT) { |
81 | client->packet_head = client->head; | ||
80 | kill_fasync(&client->fasync, SIGIO, POLL_IN); | 82 | kill_fasync(&client->fasync, SIGIO, POLL_IN); |
83 | } | ||
84 | |||
85 | spin_unlock(&client->buffer_lock); | ||
81 | } | 86 | } |
82 | 87 | ||
83 | /* | 88 | /* |
@@ -159,7 +164,6 @@ static int evdev_grab(struct evdev *evdev, struct evdev_client *client) | |||
159 | return error; | 164 | return error; |
160 | 165 | ||
161 | rcu_assign_pointer(evdev->grab, client); | 166 | rcu_assign_pointer(evdev->grab, client); |
162 | synchronize_rcu(); | ||
163 | 167 | ||
164 | return 0; | 168 | return 0; |
165 | } | 169 | } |
@@ -182,7 +186,6 @@ static void evdev_attach_client(struct evdev *evdev, | |||
182 | spin_lock(&evdev->client_lock); | 186 | spin_lock(&evdev->client_lock); |
183 | list_add_tail_rcu(&client->node, &evdev->client_list); | 187 | list_add_tail_rcu(&client->node, &evdev->client_list); |
184 | spin_unlock(&evdev->client_lock); | 188 | spin_unlock(&evdev->client_lock); |
185 | synchronize_rcu(); | ||
186 | } | 189 | } |
187 | 190 | ||
188 | static void evdev_detach_client(struct evdev *evdev, | 191 | static void evdev_detach_client(struct evdev *evdev, |
@@ -387,12 +390,12 @@ static ssize_t evdev_read(struct file *file, char __user *buffer, | |||
387 | if (count < input_event_size()) | 390 | if (count < input_event_size()) |
388 | return -EINVAL; | 391 | return -EINVAL; |
389 | 392 | ||
390 | if (client->head == client->tail && evdev->exist && | 393 | if (client->packet_head == client->tail && evdev->exist && |
391 | (file->f_flags & O_NONBLOCK)) | 394 | (file->f_flags & O_NONBLOCK)) |
392 | return -EAGAIN; | 395 | return -EAGAIN; |
393 | 396 | ||
394 | retval = wait_event_interruptible(evdev->wait, | 397 | retval = wait_event_interruptible(evdev->wait, |
395 | client->head != client->tail || !evdev->exist); | 398 | client->packet_head != client->tail || !evdev->exist); |
396 | if (retval) | 399 | if (retval) |
397 | return retval; | 400 | return retval; |
398 | 401 | ||
@@ -421,7 +424,7 @@ static unsigned int evdev_poll(struct file *file, poll_table *wait) | |||
421 | poll_wait(file, &evdev->wait, wait); | 424 | poll_wait(file, &evdev->wait, wait); |
422 | 425 | ||
423 | mask = evdev->exist ? POLLOUT | POLLWRNORM : POLLHUP | POLLERR; | 426 | mask = evdev->exist ? POLLOUT | POLLWRNORM : POLLHUP | POLLERR; |
424 | if (client->head != client->tail) | 427 | if (client->packet_head != client->tail) |
425 | mask |= POLLIN | POLLRDNORM; | 428 | mask |= POLLIN | POLLRDNORM; |
426 | 429 | ||
427 | return mask; | 430 | return mask; |
diff --git a/drivers/input/input-polldev.c b/drivers/input/input-polldev.c index 3037842a60d8..b1aabde87523 100644 --- a/drivers/input/input-polldev.c +++ b/drivers/input/input-polldev.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/jiffies.h> | 13 | #include <linux/jiffies.h> |
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/mutex.h> | 15 | #include <linux/mutex.h> |
16 | #include <linux/workqueue.h> | ||
16 | #include <linux/input-polldev.h> | 17 | #include <linux/input-polldev.h> |
17 | 18 | ||
18 | MODULE_AUTHOR("Dmitry Torokhov <dtor@mail.ru>"); | 19 | MODULE_AUTHOR("Dmitry Torokhov <dtor@mail.ru>"); |
@@ -20,44 +21,6 @@ MODULE_DESCRIPTION("Generic implementation of a polled input device"); | |||
20 | MODULE_LICENSE("GPL v2"); | 21 | MODULE_LICENSE("GPL v2"); |
21 | MODULE_VERSION("0.1"); | 22 | MODULE_VERSION("0.1"); |
22 | 23 | ||
23 | static DEFINE_MUTEX(polldev_mutex); | ||
24 | static int polldev_users; | ||
25 | static struct workqueue_struct *polldev_wq; | ||
26 | |||
27 | static int input_polldev_start_workqueue(void) | ||
28 | { | ||
29 | int retval; | ||
30 | |||
31 | retval = mutex_lock_interruptible(&polldev_mutex); | ||
32 | if (retval) | ||
33 | return retval; | ||
34 | |||
35 | if (!polldev_users) { | ||
36 | polldev_wq = create_singlethread_workqueue("ipolldevd"); | ||
37 | if (!polldev_wq) { | ||
38 | pr_err("failed to create ipolldevd workqueue\n"); | ||
39 | retval = -ENOMEM; | ||
40 | goto out; | ||
41 | } | ||
42 | } | ||
43 | |||
44 | polldev_users++; | ||
45 | |||
46 | out: | ||
47 | mutex_unlock(&polldev_mutex); | ||
48 | return retval; | ||
49 | } | ||
50 | |||
51 | static void input_polldev_stop_workqueue(void) | ||
52 | { | ||
53 | mutex_lock(&polldev_mutex); | ||
54 | |||
55 | if (!--polldev_users) | ||
56 | destroy_workqueue(polldev_wq); | ||
57 | |||
58 | mutex_unlock(&polldev_mutex); | ||
59 | } | ||
60 | |||
61 | static void input_polldev_queue_work(struct input_polled_dev *dev) | 24 | static void input_polldev_queue_work(struct input_polled_dev *dev) |
62 | { | 25 | { |
63 | unsigned long delay; | 26 | unsigned long delay; |
@@ -66,7 +29,7 @@ static void input_polldev_queue_work(struct input_polled_dev *dev) | |||
66 | if (delay >= HZ) | 29 | if (delay >= HZ) |
67 | delay = round_jiffies_relative(delay); | 30 | delay = round_jiffies_relative(delay); |
68 | 31 | ||
69 | queue_delayed_work(polldev_wq, &dev->work, delay); | 32 | queue_delayed_work(system_freezable_wq, &dev->work, delay); |
70 | } | 33 | } |
71 | 34 | ||
72 | static void input_polled_device_work(struct work_struct *work) | 35 | static void input_polled_device_work(struct work_struct *work) |
@@ -81,18 +44,13 @@ static void input_polled_device_work(struct work_struct *work) | |||
81 | static int input_open_polled_device(struct input_dev *input) | 44 | static int input_open_polled_device(struct input_dev *input) |
82 | { | 45 | { |
83 | struct input_polled_dev *dev = input_get_drvdata(input); | 46 | struct input_polled_dev *dev = input_get_drvdata(input); |
84 | int error; | ||
85 | |||
86 | error = input_polldev_start_workqueue(); | ||
87 | if (error) | ||
88 | return error; | ||
89 | 47 | ||
90 | if (dev->open) | 48 | if (dev->open) |
91 | dev->open(dev); | 49 | dev->open(dev); |
92 | 50 | ||
93 | /* Only start polling if polling is enabled */ | 51 | /* Only start polling if polling is enabled */ |
94 | if (dev->poll_interval > 0) | 52 | if (dev->poll_interval > 0) |
95 | queue_delayed_work(polldev_wq, &dev->work, 0); | 53 | queue_delayed_work(system_freezable_wq, &dev->work, 0); |
96 | 54 | ||
97 | return 0; | 55 | return 0; |
98 | } | 56 | } |
@@ -102,13 +60,6 @@ static void input_close_polled_device(struct input_dev *input) | |||
102 | struct input_polled_dev *dev = input_get_drvdata(input); | 60 | struct input_polled_dev *dev = input_get_drvdata(input); |
103 | 61 | ||
104 | cancel_delayed_work_sync(&dev->work); | 62 | cancel_delayed_work_sync(&dev->work); |
105 | /* | ||
106 | * Clean up work struct to remove references to the workqueue. | ||
107 | * It may be destroyed by the next call. This causes problems | ||
108 | * at next device open-close in case of poll_interval == 0. | ||
109 | */ | ||
110 | INIT_DELAYED_WORK(&dev->work, dev->work.work.func); | ||
111 | input_polldev_stop_workqueue(); | ||
112 | 63 | ||
113 | if (dev->close) | 64 | if (dev->close) |
114 | dev->close(dev); | 65 | dev->close(dev); |
@@ -295,4 +246,3 @@ void input_unregister_polled_device(struct input_polled_dev *dev) | |||
295 | input_unregister_device(dev->input); | 246 | input_unregister_device(dev->input); |
296 | } | 247 | } |
297 | EXPORT_SYMBOL(input_unregister_polled_device); | 248 | EXPORT_SYMBOL(input_unregister_polled_device); |
298 | |||
diff --git a/drivers/input/input.c b/drivers/input/input.c index ebbceedc92f4..75e11c7b70fd 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -451,7 +451,6 @@ int input_grab_device(struct input_handle *handle) | |||
451 | } | 451 | } |
452 | 452 | ||
453 | rcu_assign_pointer(dev->grab, handle); | 453 | rcu_assign_pointer(dev->grab, handle); |
454 | synchronize_rcu(); | ||
455 | 454 | ||
456 | out: | 455 | out: |
457 | mutex_unlock(&dev->mutex); | 456 | mutex_unlock(&dev->mutex); |
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c index 3182c9cd1b0e..c24ec2d5f926 100644 --- a/drivers/input/joydev.c +++ b/drivers/input/joydev.c | |||
@@ -180,7 +180,6 @@ static void joydev_attach_client(struct joydev *joydev, | |||
180 | spin_lock(&joydev->client_lock); | 180 | spin_lock(&joydev->client_lock); |
181 | list_add_tail_rcu(&client->node, &joydev->client_list); | 181 | list_add_tail_rcu(&client->node, &joydev->client_list); |
182 | spin_unlock(&joydev->client_lock); | 182 | spin_unlock(&joydev->client_lock); |
183 | synchronize_rcu(); | ||
184 | } | 183 | } |
185 | 184 | ||
186 | static void joydev_detach_client(struct joydev *joydev, | 185 | static void joydev_detach_client(struct joydev *joydev, |
@@ -758,7 +757,7 @@ static void joydev_remove_chrdev(struct joydev *joydev) | |||
758 | } | 757 | } |
759 | 758 | ||
760 | /* | 759 | /* |
761 | * Mark device non-existant. This disables writes, ioctls and | 760 | * Mark device non-existent. This disables writes, ioctls and |
762 | * prevents new users from opening the device. Already posted | 761 | * prevents new users from opening the device. Already posted |
763 | * blocking reads will stay, however new ones will fail. | 762 | * blocking reads will stay, however new ones will fail. |
764 | */ | 763 | */ |
@@ -777,7 +776,7 @@ static void joydev_cleanup(struct joydev *joydev) | |||
777 | joydev_hangup(joydev); | 776 | joydev_hangup(joydev); |
778 | joydev_remove_chrdev(joydev); | 777 | joydev_remove_chrdev(joydev); |
779 | 778 | ||
780 | /* joydev is marked dead so noone else accesses joydev->open */ | 779 | /* joydev is marked dead so no one else accesses joydev->open */ |
781 | if (joydev->open) | 780 | if (joydev->open) |
782 | input_close_device(handle); | 781 | input_close_device(handle); |
783 | } | 782 | } |
diff --git a/drivers/input/joystick/a3d.c b/drivers/input/joystick/a3d.c index d259b41354b8..1639ab2b94b7 100644 --- a/drivers/input/joystick/a3d.c +++ b/drivers/input/joystick/a3d.c | |||
@@ -3,7 +3,7 @@ | |||
3 | */ | 3 | */ |
4 | 4 | ||
5 | /* | 5 | /* |
6 | * FP-Gaming Assasin 3D joystick driver for Linux | 6 | * FP-Gaming Assassin 3D joystick driver for Linux |
7 | */ | 7 | */ |
8 | 8 | ||
9 | /* | 9 | /* |
@@ -34,7 +34,7 @@ | |||
34 | #include <linux/input.h> | 34 | #include <linux/input.h> |
35 | #include <linux/jiffies.h> | 35 | #include <linux/jiffies.h> |
36 | 36 | ||
37 | #define DRIVER_DESC "FP-Gaming Assasin 3D joystick driver" | 37 | #define DRIVER_DESC "FP-Gaming Assassin 3D joystick driver" |
38 | 38 | ||
39 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); | 39 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); |
40 | MODULE_DESCRIPTION(DRIVER_DESC); | 40 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index b16bed038f72..69badb4e06aa 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig | |||
@@ -32,6 +32,16 @@ config KEYBOARD_ADP5588 | |||
32 | To compile this driver as a module, choose M here: the | 32 | To compile this driver as a module, choose M here: the |
33 | module will be called adp5588-keys. | 33 | module will be called adp5588-keys. |
34 | 34 | ||
35 | config KEYBOARD_ADP5589 | ||
36 | tristate "ADP5589 I2C QWERTY Keypad and IO Expander" | ||
37 | depends on I2C | ||
38 | help | ||
39 | Say Y here if you want to use a ADP5589 attached to your | ||
40 | system I2C bus. | ||
41 | |||
42 | To compile this driver as a module, choose M here: the | ||
43 | module will be called adp5589-keys. | ||
44 | |||
35 | config KEYBOARD_AMIGA | 45 | config KEYBOARD_AMIGA |
36 | tristate "Amiga keyboard" | 46 | tristate "Amiga keyboard" |
37 | depends on AMIGA | 47 | depends on AMIGA |
@@ -325,6 +335,18 @@ config KEYBOARD_MCS | |||
325 | To compile this driver as a module, choose M here: the | 335 | To compile this driver as a module, choose M here: the |
326 | module will be called mcs_touchkey. | 336 | module will be called mcs_touchkey. |
327 | 337 | ||
338 | config KEYBOARD_MPR121 | ||
339 | tristate "Freescale MPR121 Touchkey" | ||
340 | depends on I2C | ||
341 | help | ||
342 | Say Y here if you have Freescale MPR121 touchkey controller | ||
343 | chip in your system. | ||
344 | |||
345 | If unsure, say N. | ||
346 | |||
347 | To compile this driver as a module, choose M here: the | ||
348 | module will be called mpr121_touchkey. | ||
349 | |||
328 | config KEYBOARD_IMX | 350 | config KEYBOARD_IMX |
329 | tristate "IMX keypad support" | 351 | tristate "IMX keypad support" |
330 | depends on ARCH_MXC | 352 | depends on ARCH_MXC |
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index 878e6c20deb0..c49cf8e04cd7 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile | |||
@@ -6,6 +6,7 @@ | |||
6 | 6 | ||
7 | obj-$(CONFIG_KEYBOARD_ADP5520) += adp5520-keys.o | 7 | obj-$(CONFIG_KEYBOARD_ADP5520) += adp5520-keys.o |
8 | obj-$(CONFIG_KEYBOARD_ADP5588) += adp5588-keys.o | 8 | obj-$(CONFIG_KEYBOARD_ADP5588) += adp5588-keys.o |
9 | obj-$(CONFIG_KEYBOARD_ADP5589) += adp5589-keys.o | ||
9 | obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o | 10 | obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o |
10 | obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o | 11 | obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o |
11 | obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o | 12 | obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o |
@@ -27,6 +28,7 @@ obj-$(CONFIG_KEYBOARD_MAPLE) += maple_keyb.o | |||
27 | obj-$(CONFIG_KEYBOARD_MATRIX) += matrix_keypad.o | 28 | obj-$(CONFIG_KEYBOARD_MATRIX) += matrix_keypad.o |
28 | obj-$(CONFIG_KEYBOARD_MAX7359) += max7359_keypad.o | 29 | obj-$(CONFIG_KEYBOARD_MAX7359) += max7359_keypad.o |
29 | obj-$(CONFIG_KEYBOARD_MCS) += mcs_touchkey.o | 30 | obj-$(CONFIG_KEYBOARD_MCS) += mcs_touchkey.o |
31 | obj-$(CONFIG_KEYBOARD_MPR121) += mpr121_touchkey.o | ||
30 | obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o | 32 | obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o |
31 | obj-$(CONFIG_KEYBOARD_NOMADIK) += nomadik-ske-keypad.o | 33 | obj-$(CONFIG_KEYBOARD_NOMADIK) += nomadik-ske-keypad.o |
32 | obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o | 34 | obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o |
diff --git a/drivers/input/keyboard/adp5589-keys.c b/drivers/input/keyboard/adp5589-keys.c new file mode 100644 index 000000000000..631598663aab --- /dev/null +++ b/drivers/input/keyboard/adp5589-keys.c | |||
@@ -0,0 +1,771 @@ | |||
1 | /* | ||
2 | * Description: keypad driver for ADP5589 | ||
3 | * I2C QWERTY Keypad and IO Expander | ||
4 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ | ||
5 | * | ||
6 | * Copyright (C) 2010-2011 Analog Devices Inc. | ||
7 | * Licensed under the GPL-2. | ||
8 | */ | ||
9 | |||
10 | #include <linux/module.h> | ||
11 | #include <linux/version.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/interrupt.h> | ||
14 | #include <linux/irq.h> | ||
15 | #include <linux/workqueue.h> | ||
16 | #include <linux/errno.h> | ||
17 | #include <linux/pm.h> | ||
18 | #include <linux/platform_device.h> | ||
19 | #include <linux/input.h> | ||
20 | #include <linux/i2c.h> | ||
21 | #include <linux/gpio.h> | ||
22 | #include <linux/slab.h> | ||
23 | |||
24 | #include <linux/input/adp5589.h> | ||
25 | |||
26 | /* GENERAL_CFG Register */ | ||
27 | #define OSC_EN (1 << 7) | ||
28 | #define CORE_CLK(x) (((x) & 0x3) << 5) | ||
29 | #define LCK_TRK_LOGIC (1 << 4) | ||
30 | #define LCK_TRK_GPI (1 << 3) | ||
31 | #define INT_CFG (1 << 1) | ||
32 | #define RST_CFG (1 << 0) | ||
33 | |||
34 | /* INT_EN Register */ | ||
35 | #define LOGIC2_IEN (1 << 5) | ||
36 | #define LOGIC1_IEN (1 << 4) | ||
37 | #define LOCK_IEN (1 << 3) | ||
38 | #define OVRFLOW_IEN (1 << 2) | ||
39 | #define GPI_IEN (1 << 1) | ||
40 | #define EVENT_IEN (1 << 0) | ||
41 | |||
42 | /* Interrupt Status Register */ | ||
43 | #define LOGIC2_INT (1 << 5) | ||
44 | #define LOGIC1_INT (1 << 4) | ||
45 | #define LOCK_INT (1 << 3) | ||
46 | #define OVRFLOW_INT (1 << 2) | ||
47 | #define GPI_INT (1 << 1) | ||
48 | #define EVENT_INT (1 << 0) | ||
49 | |||
50 | /* STATUS Register */ | ||
51 | |||
52 | #define LOGIC2_STAT (1 << 7) | ||
53 | #define LOGIC1_STAT (1 << 6) | ||
54 | #define LOCK_STAT (1 << 5) | ||
55 | #define KEC 0xF | ||
56 | |||
57 | /* PIN_CONFIG_D Register */ | ||
58 | #define C4_EXTEND_CFG (1 << 6) /* RESET2 */ | ||
59 | #define R4_EXTEND_CFG (1 << 5) /* RESET1 */ | ||
60 | |||
61 | /* LOCK_CFG */ | ||
62 | #define LOCK_EN (1 << 0) | ||
63 | |||
64 | #define PTIME_MASK 0x3 | ||
65 | #define LTIME_MASK 0x3 | ||
66 | |||
67 | /* Key Event Register xy */ | ||
68 | #define KEY_EV_PRESSED (1 << 7) | ||
69 | #define KEY_EV_MASK (0x7F) | ||
70 | |||
71 | #define KEYP_MAX_EVENT 16 | ||
72 | |||
73 | #define MAXGPIO 19 | ||
74 | #define ADP_BANK(offs) ((offs) >> 3) | ||
75 | #define ADP_BIT(offs) (1u << ((offs) & 0x7)) | ||
76 | |||
77 | struct adp5589_kpad { | ||
78 | struct i2c_client *client; | ||
79 | struct input_dev *input; | ||
80 | unsigned short keycode[ADP5589_KEYMAPSIZE]; | ||
81 | const struct adp5589_gpi_map *gpimap; | ||
82 | unsigned short gpimapsize; | ||
83 | unsigned extend_cfg; | ||
84 | #ifdef CONFIG_GPIOLIB | ||
85 | unsigned char gpiomap[MAXGPIO]; | ||
86 | bool export_gpio; | ||
87 | struct gpio_chip gc; | ||
88 | struct mutex gpio_lock; /* Protect cached dir, dat_out */ | ||
89 | u8 dat_out[3]; | ||
90 | u8 dir[3]; | ||
91 | #endif | ||
92 | }; | ||
93 | |||
94 | static int adp5589_read(struct i2c_client *client, u8 reg) | ||
95 | { | ||
96 | int ret = i2c_smbus_read_byte_data(client, reg); | ||
97 | |||
98 | if (ret < 0) | ||
99 | dev_err(&client->dev, "Read Error\n"); | ||
100 | |||
101 | return ret; | ||
102 | } | ||
103 | |||
104 | static int adp5589_write(struct i2c_client *client, u8 reg, u8 val) | ||
105 | { | ||
106 | return i2c_smbus_write_byte_data(client, reg, val); | ||
107 | } | ||
108 | |||
109 | #ifdef CONFIG_GPIOLIB | ||
110 | static int adp5589_gpio_get_value(struct gpio_chip *chip, unsigned off) | ||
111 | { | ||
112 | struct adp5589_kpad *kpad = container_of(chip, struct adp5589_kpad, gc); | ||
113 | unsigned int bank = ADP_BANK(kpad->gpiomap[off]); | ||
114 | unsigned int bit = ADP_BIT(kpad->gpiomap[off]); | ||
115 | |||
116 | return !!(adp5589_read(kpad->client, ADP5589_GPI_STATUS_A + bank) & | ||
117 | bit); | ||
118 | } | ||
119 | |||
120 | static void adp5589_gpio_set_value(struct gpio_chip *chip, | ||
121 | unsigned off, int val) | ||
122 | { | ||
123 | struct adp5589_kpad *kpad = container_of(chip, struct adp5589_kpad, gc); | ||
124 | unsigned int bank = ADP_BANK(kpad->gpiomap[off]); | ||
125 | unsigned int bit = ADP_BIT(kpad->gpiomap[off]); | ||
126 | |||
127 | mutex_lock(&kpad->gpio_lock); | ||
128 | |||
129 | if (val) | ||
130 | kpad->dat_out[bank] |= bit; | ||
131 | else | ||
132 | kpad->dat_out[bank] &= ~bit; | ||
133 | |||
134 | adp5589_write(kpad->client, ADP5589_GPO_DATA_OUT_A + bank, | ||
135 | kpad->dat_out[bank]); | ||
136 | |||
137 | mutex_unlock(&kpad->gpio_lock); | ||
138 | } | ||
139 | |||
140 | static int adp5589_gpio_direction_input(struct gpio_chip *chip, unsigned off) | ||
141 | { | ||
142 | struct adp5589_kpad *kpad = container_of(chip, struct adp5589_kpad, gc); | ||
143 | unsigned int bank = ADP_BANK(kpad->gpiomap[off]); | ||
144 | unsigned int bit = ADP_BIT(kpad->gpiomap[off]); | ||
145 | int ret; | ||
146 | |||
147 | mutex_lock(&kpad->gpio_lock); | ||
148 | |||
149 | kpad->dir[bank] &= ~bit; | ||
150 | ret = adp5589_write(kpad->client, ADP5589_GPIO_DIRECTION_A + bank, | ||
151 | kpad->dir[bank]); | ||
152 | |||
153 | mutex_unlock(&kpad->gpio_lock); | ||
154 | |||
155 | return ret; | ||
156 | } | ||
157 | |||
158 | static int adp5589_gpio_direction_output(struct gpio_chip *chip, | ||
159 | unsigned off, int val) | ||
160 | { | ||
161 | struct adp5589_kpad *kpad = container_of(chip, struct adp5589_kpad, gc); | ||
162 | unsigned int bank = ADP_BANK(kpad->gpiomap[off]); | ||
163 | unsigned int bit = ADP_BIT(kpad->gpiomap[off]); | ||
164 | int ret; | ||
165 | |||
166 | mutex_lock(&kpad->gpio_lock); | ||
167 | |||
168 | kpad->dir[bank] |= bit; | ||
169 | |||
170 | if (val) | ||
171 | kpad->dat_out[bank] |= bit; | ||
172 | else | ||
173 | kpad->dat_out[bank] &= ~bit; | ||
174 | |||
175 | ret = adp5589_write(kpad->client, ADP5589_GPO_DATA_OUT_A + bank, | ||
176 | kpad->dat_out[bank]); | ||
177 | ret |= adp5589_write(kpad->client, ADP5589_GPIO_DIRECTION_A + bank, | ||
178 | kpad->dir[bank]); | ||
179 | |||
180 | mutex_unlock(&kpad->gpio_lock); | ||
181 | |||
182 | return ret; | ||
183 | } | ||
184 | |||
185 | static int __devinit adp5589_build_gpiomap(struct adp5589_kpad *kpad, | ||
186 | const struct adp5589_kpad_platform_data *pdata) | ||
187 | { | ||
188 | bool pin_used[MAXGPIO]; | ||
189 | int n_unused = 0; | ||
190 | int i; | ||
191 | |||
192 | memset(pin_used, false, sizeof(pin_used)); | ||
193 | |||
194 | for (i = 0; i < MAXGPIO; i++) | ||
195 | if (pdata->keypad_en_mask & (1 << i)) | ||
196 | pin_used[i] = true; | ||
197 | |||
198 | for (i = 0; i < kpad->gpimapsize; i++) | ||
199 | pin_used[kpad->gpimap[i].pin - ADP5589_GPI_PIN_BASE] = true; | ||
200 | |||
201 | if (kpad->extend_cfg & R4_EXTEND_CFG) | ||
202 | pin_used[4] = true; | ||
203 | |||
204 | if (kpad->extend_cfg & C4_EXTEND_CFG) | ||
205 | pin_used[12] = true; | ||
206 | |||
207 | for (i = 0; i < MAXGPIO; i++) | ||
208 | if (!pin_used[i]) | ||
209 | kpad->gpiomap[n_unused++] = i; | ||
210 | |||
211 | return n_unused; | ||
212 | } | ||
213 | |||
214 | static int __devinit adp5589_gpio_add(struct adp5589_kpad *kpad) | ||
215 | { | ||
216 | struct device *dev = &kpad->client->dev; | ||
217 | const struct adp5589_kpad_platform_data *pdata = dev->platform_data; | ||
218 | const struct adp5589_gpio_platform_data *gpio_data = pdata->gpio_data; | ||
219 | int i, error; | ||
220 | |||
221 | if (!gpio_data) | ||
222 | return 0; | ||
223 | |||
224 | kpad->gc.ngpio = adp5589_build_gpiomap(kpad, pdata); | ||
225 | if (kpad->gc.ngpio == 0) { | ||
226 | dev_info(dev, "No unused gpios left to export\n"); | ||
227 | return 0; | ||
228 | } | ||
229 | |||
230 | kpad->export_gpio = true; | ||
231 | |||
232 | kpad->gc.direction_input = adp5589_gpio_direction_input; | ||
233 | kpad->gc.direction_output = adp5589_gpio_direction_output; | ||
234 | kpad->gc.get = adp5589_gpio_get_value; | ||
235 | kpad->gc.set = adp5589_gpio_set_value; | ||
236 | kpad->gc.can_sleep = 1; | ||
237 | |||
238 | kpad->gc.base = gpio_data->gpio_start; | ||
239 | kpad->gc.label = kpad->client->name; | ||
240 | kpad->gc.owner = THIS_MODULE; | ||
241 | |||
242 | mutex_init(&kpad->gpio_lock); | ||
243 | |||
244 | error = gpiochip_add(&kpad->gc); | ||
245 | if (error) { | ||
246 | dev_err(dev, "gpiochip_add failed, err: %d\n", error); | ||
247 | return error; | ||
248 | } | ||
249 | |||
250 | for (i = 0; i <= ADP_BANK(MAXGPIO); i++) { | ||
251 | kpad->dat_out[i] = adp5589_read(kpad->client, | ||
252 | ADP5589_GPO_DATA_OUT_A + i); | ||
253 | kpad->dir[i] = adp5589_read(kpad->client, | ||
254 | ADP5589_GPIO_DIRECTION_A + i); | ||
255 | } | ||
256 | |||
257 | if (gpio_data->setup) { | ||
258 | error = gpio_data->setup(kpad->client, | ||
259 | kpad->gc.base, kpad->gc.ngpio, | ||
260 | gpio_data->context); | ||
261 | if (error) | ||
262 | dev_warn(dev, "setup failed, %d\n", error); | ||
263 | } | ||
264 | |||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | static void __devexit adp5589_gpio_remove(struct adp5589_kpad *kpad) | ||
269 | { | ||
270 | struct device *dev = &kpad->client->dev; | ||
271 | const struct adp5589_kpad_platform_data *pdata = dev->platform_data; | ||
272 | const struct adp5589_gpio_platform_data *gpio_data = pdata->gpio_data; | ||
273 | int error; | ||
274 | |||
275 | if (!kpad->export_gpio) | ||
276 | return; | ||
277 | |||
278 | if (gpio_data->teardown) { | ||
279 | error = gpio_data->teardown(kpad->client, | ||
280 | kpad->gc.base, kpad->gc.ngpio, | ||
281 | gpio_data->context); | ||
282 | if (error) | ||
283 | dev_warn(dev, "teardown failed %d\n", error); | ||
284 | } | ||
285 | |||
286 | error = gpiochip_remove(&kpad->gc); | ||
287 | if (error) | ||
288 | dev_warn(dev, "gpiochip_remove failed %d\n", error); | ||
289 | } | ||
290 | #else | ||
291 | static inline int adp5589_gpio_add(struct adp5589_kpad *kpad) | ||
292 | { | ||
293 | return 0; | ||
294 | } | ||
295 | |||
296 | static inline void adp5589_gpio_remove(struct adp5589_kpad *kpad) | ||
297 | { | ||
298 | } | ||
299 | #endif | ||
300 | |||
301 | static void adp5589_report_switches(struct adp5589_kpad *kpad, | ||
302 | int key, int key_val) | ||
303 | { | ||
304 | int i; | ||
305 | |||
306 | for (i = 0; i < kpad->gpimapsize; i++) { | ||
307 | if (key_val == kpad->gpimap[i].pin) { | ||
308 | input_report_switch(kpad->input, | ||
309 | kpad->gpimap[i].sw_evt, | ||
310 | key & KEY_EV_PRESSED); | ||
311 | break; | ||
312 | } | ||
313 | } | ||
314 | } | ||
315 | |||
316 | static void adp5589_report_events(struct adp5589_kpad *kpad, int ev_cnt) | ||
317 | { | ||
318 | int i; | ||
319 | |||
320 | for (i = 0; i < ev_cnt; i++) { | ||
321 | int key = adp5589_read(kpad->client, ADP5589_FIFO_1 + i); | ||
322 | int key_val = key & KEY_EV_MASK; | ||
323 | |||
324 | if (key_val >= ADP5589_GPI_PIN_BASE && | ||
325 | key_val <= ADP5589_GPI_PIN_END) { | ||
326 | adp5589_report_switches(kpad, key, key_val); | ||
327 | } else { | ||
328 | input_report_key(kpad->input, | ||
329 | kpad->keycode[key_val - 1], | ||
330 | key & KEY_EV_PRESSED); | ||
331 | } | ||
332 | } | ||
333 | } | ||
334 | |||
335 | static irqreturn_t adp5589_irq(int irq, void *handle) | ||
336 | { | ||
337 | struct adp5589_kpad *kpad = handle; | ||
338 | struct i2c_client *client = kpad->client; | ||
339 | int status, ev_cnt; | ||
340 | |||
341 | status = adp5589_read(client, ADP5589_INT_STATUS); | ||
342 | |||
343 | if (status & OVRFLOW_INT) /* Unlikely and should never happen */ | ||
344 | dev_err(&client->dev, "Event Overflow Error\n"); | ||
345 | |||
346 | if (status & EVENT_INT) { | ||
347 | ev_cnt = adp5589_read(client, ADP5589_STATUS) & KEC; | ||
348 | if (ev_cnt) { | ||
349 | adp5589_report_events(kpad, ev_cnt); | ||
350 | input_sync(kpad->input); | ||
351 | } | ||
352 | } | ||
353 | |||
354 | adp5589_write(client, ADP5589_INT_STATUS, status); /* Status is W1C */ | ||
355 | |||
356 | return IRQ_HANDLED; | ||
357 | } | ||
358 | |||
359 | static int __devinit adp5589_get_evcode(struct adp5589_kpad *kpad, unsigned short key) | ||
360 | { | ||
361 | int i; | ||
362 | |||
363 | for (i = 0; i < ADP5589_KEYMAPSIZE; i++) | ||
364 | if (key == kpad->keycode[i]) | ||
365 | return (i + 1) | KEY_EV_PRESSED; | ||
366 | |||
367 | dev_err(&kpad->client->dev, "RESET/UNLOCK key not in keycode map\n"); | ||
368 | |||
369 | return -EINVAL; | ||
370 | } | ||
371 | |||
372 | static int __devinit adp5589_setup(struct adp5589_kpad *kpad) | ||
373 | { | ||
374 | struct i2c_client *client = kpad->client; | ||
375 | const struct adp5589_kpad_platform_data *pdata = | ||
376 | client->dev.platform_data; | ||
377 | int i, ret; | ||
378 | unsigned char evt_mode1 = 0, evt_mode2 = 0, evt_mode3 = 0; | ||
379 | unsigned char pull_mask = 0; | ||
380 | |||
381 | ret = adp5589_write(client, ADP5589_PIN_CONFIG_A, | ||
382 | pdata->keypad_en_mask & 0xFF); | ||
383 | ret |= adp5589_write(client, ADP5589_PIN_CONFIG_B, | ||
384 | (pdata->keypad_en_mask >> 8) & 0xFF); | ||
385 | ret |= adp5589_write(client, ADP5589_PIN_CONFIG_C, | ||
386 | (pdata->keypad_en_mask >> 16) & 0xFF); | ||
387 | |||
388 | if (pdata->en_keylock) { | ||
389 | ret |= adp5589_write(client, ADP5589_UNLOCK1, | ||
390 | pdata->unlock_key1); | ||
391 | ret |= adp5589_write(client, ADP5589_UNLOCK2, | ||
392 | pdata->unlock_key2); | ||
393 | ret |= adp5589_write(client, ADP5589_UNLOCK_TIMERS, | ||
394 | pdata->unlock_timer & LTIME_MASK); | ||
395 | ret |= adp5589_write(client, ADP5589_LOCK_CFG, LOCK_EN); | ||
396 | } | ||
397 | |||
398 | for (i = 0; i < KEYP_MAX_EVENT; i++) | ||
399 | ret |= adp5589_read(client, ADP5589_FIFO_1 + i); | ||
400 | |||
401 | for (i = 0; i < pdata->gpimapsize; i++) { | ||
402 | unsigned short pin = pdata->gpimap[i].pin; | ||
403 | |||
404 | if (pin <= ADP5589_GPI_PIN_ROW_END) { | ||
405 | evt_mode1 |= (1 << (pin - ADP5589_GPI_PIN_ROW_BASE)); | ||
406 | } else { | ||
407 | evt_mode2 |= | ||
408 | ((1 << (pin - ADP5589_GPI_PIN_COL_BASE)) & 0xFF); | ||
409 | evt_mode3 |= | ||
410 | ((1 << (pin - ADP5589_GPI_PIN_COL_BASE)) >> 8); | ||
411 | } | ||
412 | } | ||
413 | |||
414 | if (pdata->gpimapsize) { | ||
415 | ret |= adp5589_write(client, ADP5589_GPI_EVENT_EN_A, evt_mode1); | ||
416 | ret |= adp5589_write(client, ADP5589_GPI_EVENT_EN_B, evt_mode2); | ||
417 | ret |= adp5589_write(client, ADP5589_GPI_EVENT_EN_C, evt_mode3); | ||
418 | } | ||
419 | |||
420 | if (pdata->pull_dis_mask & pdata->pullup_en_100k & | ||
421 | pdata->pullup_en_300k & pdata->pulldown_en_300k) | ||
422 | dev_warn(&client->dev, "Conflicting pull resistor config\n"); | ||
423 | |||
424 | for (i = 0; i < MAXGPIO; i++) { | ||
425 | unsigned val = 0; | ||
426 | |||
427 | if (pdata->pullup_en_300k & (1 << i)) | ||
428 | val = 0; | ||
429 | else if (pdata->pulldown_en_300k & (1 << i)) | ||
430 | val = 1; | ||
431 | else if (pdata->pullup_en_100k & (1 << i)) | ||
432 | val = 2; | ||
433 | else if (pdata->pull_dis_mask & (1 << i)) | ||
434 | val = 3; | ||
435 | |||
436 | pull_mask |= val << (2 * (i & 0x3)); | ||
437 | |||
438 | if ((i & 0x3) == 0x3 || i == MAXGPIO - 1) { | ||
439 | ret |= adp5589_write(client, | ||
440 | ADP5589_RPULL_CONFIG_A + (i >> 2), | ||
441 | pull_mask); | ||
442 | pull_mask = 0; | ||
443 | } | ||
444 | } | ||
445 | |||
446 | if (pdata->reset1_key_1 && pdata->reset1_key_2 && pdata->reset1_key_3) { | ||
447 | ret |= adp5589_write(client, ADP5589_RESET1_EVENT_A, | ||
448 | adp5589_get_evcode(kpad, | ||
449 | pdata->reset1_key_1)); | ||
450 | ret |= adp5589_write(client, ADP5589_RESET1_EVENT_B, | ||
451 | adp5589_get_evcode(kpad, | ||
452 | pdata->reset1_key_2)); | ||
453 | ret |= adp5589_write(client, ADP5589_RESET1_EVENT_C, | ||
454 | adp5589_get_evcode(kpad, | ||
455 | pdata->reset1_key_3)); | ||
456 | kpad->extend_cfg |= R4_EXTEND_CFG; | ||
457 | } | ||
458 | |||
459 | if (pdata->reset2_key_1 && pdata->reset2_key_2) { | ||
460 | ret |= adp5589_write(client, ADP5589_RESET2_EVENT_A, | ||
461 | adp5589_get_evcode(kpad, | ||
462 | pdata->reset2_key_1)); | ||
463 | ret |= adp5589_write(client, ADP5589_RESET2_EVENT_B, | ||
464 | adp5589_get_evcode(kpad, | ||
465 | pdata->reset2_key_2)); | ||
466 | kpad->extend_cfg |= C4_EXTEND_CFG; | ||
467 | } | ||
468 | |||
469 | if (kpad->extend_cfg) { | ||
470 | ret |= adp5589_write(client, ADP5589_RESET_CFG, | ||
471 | pdata->reset_cfg); | ||
472 | ret |= adp5589_write(client, ADP5589_PIN_CONFIG_D, | ||
473 | kpad->extend_cfg); | ||
474 | } | ||
475 | |||
476 | for (i = 0; i <= ADP_BANK(MAXGPIO); i++) | ||
477 | ret |= adp5589_write(client, ADP5589_DEBOUNCE_DIS_A + i, | ||
478 | pdata->debounce_dis_mask >> (i * 8)); | ||
479 | |||
480 | ret |= adp5589_write(client, ADP5589_POLL_PTIME_CFG, | ||
481 | pdata->scan_cycle_time & PTIME_MASK); | ||
482 | ret |= adp5589_write(client, ADP5589_INT_STATUS, LOGIC2_INT | | ||
483 | LOGIC1_INT | OVRFLOW_INT | LOCK_INT | | ||
484 | GPI_INT | EVENT_INT); /* Status is W1C */ | ||
485 | |||
486 | ret |= adp5589_write(client, ADP5589_GENERAL_CFG, | ||
487 | INT_CFG | OSC_EN | CORE_CLK(3)); | ||
488 | ret |= adp5589_write(client, ADP5589_INT_EN, | ||
489 | OVRFLOW_IEN | GPI_IEN | EVENT_IEN); | ||
490 | |||
491 | if (ret < 0) { | ||
492 | dev_err(&client->dev, "Write Error\n"); | ||
493 | return ret; | ||
494 | } | ||
495 | |||
496 | return 0; | ||
497 | } | ||
498 | |||
499 | static void __devinit adp5589_report_switch_state(struct adp5589_kpad *kpad) | ||
500 | { | ||
501 | int gpi_stat1 = adp5589_read(kpad->client, ADP5589_GPI_STATUS_A); | ||
502 | int gpi_stat2 = adp5589_read(kpad->client, ADP5589_GPI_STATUS_B); | ||
503 | int gpi_stat3 = adp5589_read(kpad->client, ADP5589_GPI_STATUS_C); | ||
504 | int gpi_stat_tmp, pin_loc; | ||
505 | int i; | ||
506 | |||
507 | for (i = 0; i < kpad->gpimapsize; i++) { | ||
508 | unsigned short pin = kpad->gpimap[i].pin; | ||
509 | |||
510 | if (pin <= ADP5589_GPI_PIN_ROW_END) { | ||
511 | gpi_stat_tmp = gpi_stat1; | ||
512 | pin_loc = pin - ADP5589_GPI_PIN_ROW_BASE; | ||
513 | } else if ((pin - ADP5589_GPI_PIN_COL_BASE) < 8) { | ||
514 | gpi_stat_tmp = gpi_stat2; | ||
515 | pin_loc = pin - ADP5589_GPI_PIN_COL_BASE; | ||
516 | } else { | ||
517 | gpi_stat_tmp = gpi_stat3; | ||
518 | pin_loc = pin - ADP5589_GPI_PIN_COL_BASE - 8; | ||
519 | } | ||
520 | |||
521 | if (gpi_stat_tmp < 0) { | ||
522 | dev_err(&kpad->client->dev, | ||
523 | "Can't read GPIO_DAT_STAT switch" | ||
524 | " %d default to OFF\n", pin); | ||
525 | gpi_stat_tmp = 0; | ||
526 | } | ||
527 | |||
528 | input_report_switch(kpad->input, | ||
529 | kpad->gpimap[i].sw_evt, | ||
530 | !(gpi_stat_tmp & (1 << pin_loc))); | ||
531 | } | ||
532 | |||
533 | input_sync(kpad->input); | ||
534 | } | ||
535 | |||
536 | static int __devinit adp5589_probe(struct i2c_client *client, | ||
537 | const struct i2c_device_id *id) | ||
538 | { | ||
539 | struct adp5589_kpad *kpad; | ||
540 | const struct adp5589_kpad_platform_data *pdata; | ||
541 | struct input_dev *input; | ||
542 | unsigned int revid; | ||
543 | int ret, i; | ||
544 | int error; | ||
545 | |||
546 | if (!i2c_check_functionality(client->adapter, | ||
547 | I2C_FUNC_SMBUS_BYTE_DATA)) { | ||
548 | dev_err(&client->dev, "SMBUS Byte Data not Supported\n"); | ||
549 | return -EIO; | ||
550 | } | ||
551 | |||
552 | pdata = client->dev.platform_data; | ||
553 | if (!pdata) { | ||
554 | dev_err(&client->dev, "no platform data?\n"); | ||
555 | return -EINVAL; | ||
556 | } | ||
557 | |||
558 | if (!((pdata->keypad_en_mask & 0xFF) && | ||
559 | (pdata->keypad_en_mask >> 8)) || !pdata->keymap) { | ||
560 | dev_err(&client->dev, "no rows, cols or keymap from pdata\n"); | ||
561 | return -EINVAL; | ||
562 | } | ||
563 | |||
564 | if (pdata->keymapsize != ADP5589_KEYMAPSIZE) { | ||
565 | dev_err(&client->dev, "invalid keymapsize\n"); | ||
566 | return -EINVAL; | ||
567 | } | ||
568 | |||
569 | if (!pdata->gpimap && pdata->gpimapsize) { | ||
570 | dev_err(&client->dev, "invalid gpimap from pdata\n"); | ||
571 | return -EINVAL; | ||
572 | } | ||
573 | |||
574 | if (pdata->gpimapsize > ADP5589_GPIMAPSIZE_MAX) { | ||
575 | dev_err(&client->dev, "invalid gpimapsize\n"); | ||
576 | return -EINVAL; | ||
577 | } | ||
578 | |||
579 | for (i = 0; i < pdata->gpimapsize; i++) { | ||
580 | unsigned short pin = pdata->gpimap[i].pin; | ||
581 | |||
582 | if (pin < ADP5589_GPI_PIN_BASE || pin > ADP5589_GPI_PIN_END) { | ||
583 | dev_err(&client->dev, "invalid gpi pin data\n"); | ||
584 | return -EINVAL; | ||
585 | } | ||
586 | |||
587 | if ((1 << (pin - ADP5589_GPI_PIN_ROW_BASE)) & | ||
588 | pdata->keypad_en_mask) { | ||
589 | dev_err(&client->dev, "invalid gpi row/col data\n"); | ||
590 | return -EINVAL; | ||
591 | } | ||
592 | } | ||
593 | |||
594 | if (!client->irq) { | ||
595 | dev_err(&client->dev, "no IRQ?\n"); | ||
596 | return -EINVAL; | ||
597 | } | ||
598 | |||
599 | kpad = kzalloc(sizeof(*kpad), GFP_KERNEL); | ||
600 | input = input_allocate_device(); | ||
601 | if (!kpad || !input) { | ||
602 | error = -ENOMEM; | ||
603 | goto err_free_mem; | ||
604 | } | ||
605 | |||
606 | kpad->client = client; | ||
607 | kpad->input = input; | ||
608 | |||
609 | ret = adp5589_read(client, ADP5589_ID); | ||
610 | if (ret < 0) { | ||
611 | error = ret; | ||
612 | goto err_free_mem; | ||
613 | } | ||
614 | |||
615 | revid = (u8) ret & ADP5589_DEVICE_ID_MASK; | ||
616 | |||
617 | input->name = client->name; | ||
618 | input->phys = "adp5589-keys/input0"; | ||
619 | input->dev.parent = &client->dev; | ||
620 | |||
621 | input_set_drvdata(input, kpad); | ||
622 | |||
623 | input->id.bustype = BUS_I2C; | ||
624 | input->id.vendor = 0x0001; | ||
625 | input->id.product = 0x0001; | ||
626 | input->id.version = revid; | ||
627 | |||
628 | input->keycodesize = sizeof(kpad->keycode[0]); | ||
629 | input->keycodemax = pdata->keymapsize; | ||
630 | input->keycode = kpad->keycode; | ||
631 | |||
632 | memcpy(kpad->keycode, pdata->keymap, | ||
633 | pdata->keymapsize * input->keycodesize); | ||
634 | |||
635 | kpad->gpimap = pdata->gpimap; | ||
636 | kpad->gpimapsize = pdata->gpimapsize; | ||
637 | |||
638 | /* setup input device */ | ||
639 | __set_bit(EV_KEY, input->evbit); | ||
640 | |||
641 | if (pdata->repeat) | ||
642 | __set_bit(EV_REP, input->evbit); | ||
643 | |||
644 | for (i = 0; i < input->keycodemax; i++) | ||
645 | __set_bit(kpad->keycode[i] & KEY_MAX, input->keybit); | ||
646 | __clear_bit(KEY_RESERVED, input->keybit); | ||
647 | |||
648 | if (kpad->gpimapsize) | ||
649 | __set_bit(EV_SW, input->evbit); | ||
650 | for (i = 0; i < kpad->gpimapsize; i++) | ||
651 | __set_bit(kpad->gpimap[i].sw_evt, input->swbit); | ||
652 | |||
653 | error = input_register_device(input); | ||
654 | if (error) { | ||
655 | dev_err(&client->dev, "unable to register input device\n"); | ||
656 | goto err_free_mem; | ||
657 | } | ||
658 | |||
659 | error = request_threaded_irq(client->irq, NULL, adp5589_irq, | ||
660 | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, | ||
661 | client->dev.driver->name, kpad); | ||
662 | if (error) { | ||
663 | dev_err(&client->dev, "irq %d busy?\n", client->irq); | ||
664 | goto err_unreg_dev; | ||
665 | } | ||
666 | |||
667 | error = adp5589_setup(kpad); | ||
668 | if (error) | ||
669 | goto err_free_irq; | ||
670 | |||
671 | if (kpad->gpimapsize) | ||
672 | adp5589_report_switch_state(kpad); | ||
673 | |||
674 | error = adp5589_gpio_add(kpad); | ||
675 | if (error) | ||
676 | goto err_free_irq; | ||
677 | |||
678 | device_init_wakeup(&client->dev, 1); | ||
679 | i2c_set_clientdata(client, kpad); | ||
680 | |||
681 | dev_info(&client->dev, "Rev.%d keypad, irq %d\n", revid, client->irq); | ||
682 | return 0; | ||
683 | |||
684 | err_free_irq: | ||
685 | free_irq(client->irq, kpad); | ||
686 | err_unreg_dev: | ||
687 | input_unregister_device(input); | ||
688 | input = NULL; | ||
689 | err_free_mem: | ||
690 | input_free_device(input); | ||
691 | kfree(kpad); | ||
692 | |||
693 | return error; | ||
694 | } | ||
695 | |||
696 | static int __devexit adp5589_remove(struct i2c_client *client) | ||
697 | { | ||
698 | struct adp5589_kpad *kpad = i2c_get_clientdata(client); | ||
699 | |||
700 | adp5589_write(client, ADP5589_GENERAL_CFG, 0); | ||
701 | free_irq(client->irq, kpad); | ||
702 | input_unregister_device(kpad->input); | ||
703 | adp5589_gpio_remove(kpad); | ||
704 | kfree(kpad); | ||
705 | |||
706 | return 0; | ||
707 | } | ||
708 | |||
709 | #ifdef CONFIG_PM_SLEEP | ||
710 | static int adp5589_suspend(struct device *dev) | ||
711 | { | ||
712 | struct adp5589_kpad *kpad = dev_get_drvdata(dev); | ||
713 | struct i2c_client *client = kpad->client; | ||
714 | |||
715 | disable_irq(client->irq); | ||
716 | |||
717 | if (device_may_wakeup(&client->dev)) | ||
718 | enable_irq_wake(client->irq); | ||
719 | |||
720 | return 0; | ||
721 | } | ||
722 | |||
723 | static int adp5589_resume(struct device *dev) | ||
724 | { | ||
725 | struct adp5589_kpad *kpad = dev_get_drvdata(dev); | ||
726 | struct i2c_client *client = kpad->client; | ||
727 | |||
728 | if (device_may_wakeup(&client->dev)) | ||
729 | disable_irq_wake(client->irq); | ||
730 | |||
731 | enable_irq(client->irq); | ||
732 | |||
733 | return 0; | ||
734 | } | ||
735 | #endif | ||
736 | |||
737 | static SIMPLE_DEV_PM_OPS(adp5589_dev_pm_ops, adp5589_suspend, adp5589_resume); | ||
738 | |||
739 | static const struct i2c_device_id adp5589_id[] = { | ||
740 | {"adp5589-keys", 0}, | ||
741 | {} | ||
742 | }; | ||
743 | |||
744 | MODULE_DEVICE_TABLE(i2c, adp5589_id); | ||
745 | |||
746 | static struct i2c_driver adp5589_driver = { | ||
747 | .driver = { | ||
748 | .name = KBUILD_MODNAME, | ||
749 | .owner = THIS_MODULE, | ||
750 | .pm = &adp5589_dev_pm_ops, | ||
751 | }, | ||
752 | .probe = adp5589_probe, | ||
753 | .remove = __devexit_p(adp5589_remove), | ||
754 | .id_table = adp5589_id, | ||
755 | }; | ||
756 | |||
757 | static int __init adp5589_init(void) | ||
758 | { | ||
759 | return i2c_add_driver(&adp5589_driver); | ||
760 | } | ||
761 | module_init(adp5589_init); | ||
762 | |||
763 | static void __exit adp5589_exit(void) | ||
764 | { | ||
765 | i2c_del_driver(&adp5589_driver); | ||
766 | } | ||
767 | module_exit(adp5589_exit); | ||
768 | |||
769 | MODULE_LICENSE("GPL"); | ||
770 | MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); | ||
771 | MODULE_DESCRIPTION("ADP5589 Keypad driver"); | ||
diff --git a/drivers/input/keyboard/davinci_keyscan.c b/drivers/input/keyboard/davinci_keyscan.c index a91ee941b5c1..cd89d17162a3 100644 --- a/drivers/input/keyboard/davinci_keyscan.c +++ b/drivers/input/keyboard/davinci_keyscan.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * Author: Miguel Aguilar <miguel.aguilar@ridgerun.com> | 6 | * Author: Miguel Aguilar <miguel.aguilar@ridgerun.com> |
7 | * | 7 | * |
8 | * Intial Code: Sandeep Paulraj <s-paulraj@ti.com> | 8 | * Initial Code: Sandeep Paulraj <s-paulraj@ti.com> |
9 | * | 9 | * |
10 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index eb3006361ee4..6e6145b9a4c1 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c | |||
@@ -324,7 +324,12 @@ static void gpio_keys_report_event(struct gpio_button_data *bdata) | |||
324 | unsigned int type = button->type ?: EV_KEY; | 324 | unsigned int type = button->type ?: EV_KEY; |
325 | int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low; | 325 | int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low; |
326 | 326 | ||
327 | input_event(input, type, button->code, !!state); | 327 | if (type == EV_ABS) { |
328 | if (state) | ||
329 | input_event(input, type, button->code, button->value); | ||
330 | } else { | ||
331 | input_event(input, type, button->code, !!state); | ||
332 | } | ||
328 | input_sync(input); | 333 | input_sync(input); |
329 | } | 334 | } |
330 | 335 | ||
@@ -363,7 +368,7 @@ static int __devinit gpio_keys_setup_key(struct platform_device *pdev, | |||
363 | struct gpio_button_data *bdata, | 368 | struct gpio_button_data *bdata, |
364 | struct gpio_keys_button *button) | 369 | struct gpio_keys_button *button) |
365 | { | 370 | { |
366 | char *desc = button->desc ? button->desc : "gpio_keys"; | 371 | const char *desc = button->desc ? button->desc : "gpio_keys"; |
367 | struct device *dev = &pdev->dev; | 372 | struct device *dev = &pdev->dev; |
368 | unsigned long irqflags; | 373 | unsigned long irqflags; |
369 | int irq, error; | 374 | int irq, error; |
@@ -468,7 +473,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) | |||
468 | platform_set_drvdata(pdev, ddata); | 473 | platform_set_drvdata(pdev, ddata); |
469 | input_set_drvdata(input, ddata); | 474 | input_set_drvdata(input, ddata); |
470 | 475 | ||
471 | input->name = pdev->name; | 476 | input->name = pdata->name ? : pdev->name; |
472 | input->phys = "gpio-keys/input0"; | 477 | input->phys = "gpio-keys/input0"; |
473 | input->dev.parent = &pdev->dev; | 478 | input->dev.parent = &pdev->dev; |
474 | input->open = gpio_keys_open; | 479 | input->open = gpio_keys_open; |
diff --git a/drivers/input/keyboard/lm8323.c b/drivers/input/keyboard/lm8323.c index b732870ecc89..71f744a8e686 100644 --- a/drivers/input/keyboard/lm8323.c +++ b/drivers/input/keyboard/lm8323.c | |||
@@ -809,7 +809,7 @@ static int lm8323_suspend(struct device *dev) | |||
809 | struct lm8323_chip *lm = i2c_get_clientdata(client); | 809 | struct lm8323_chip *lm = i2c_get_clientdata(client); |
810 | int i; | 810 | int i; |
811 | 811 | ||
812 | set_irq_wake(client->irq, 0); | 812 | irq_set_irq_wake(client->irq, 0); |
813 | disable_irq(client->irq); | 813 | disable_irq(client->irq); |
814 | 814 | ||
815 | mutex_lock(&lm->lock); | 815 | mutex_lock(&lm->lock); |
@@ -838,7 +838,7 @@ static int lm8323_resume(struct device *dev) | |||
838 | led_classdev_resume(&lm->pwm[i].cdev); | 838 | led_classdev_resume(&lm->pwm[i].cdev); |
839 | 839 | ||
840 | enable_irq(client->irq); | 840 | enable_irq(client->irq); |
841 | set_irq_wake(client->irq, 1); | 841 | irq_set_irq_wake(client->irq, 1); |
842 | 842 | ||
843 | return 0; | 843 | return 0; |
844 | } | 844 | } |
diff --git a/drivers/input/keyboard/mpr121_touchkey.c b/drivers/input/keyboard/mpr121_touchkey.c new file mode 100644 index 000000000000..0a9e81194888 --- /dev/null +++ b/drivers/input/keyboard/mpr121_touchkey.c | |||
@@ -0,0 +1,339 @@ | |||
1 | /* | ||
2 | * Touchkey driver for Freescale MPR121 Controllor | ||
3 | * | ||
4 | * Copyright (C) 2011 Freescale Semiconductor, Inc. | ||
5 | * Author: Zhang Jiejing <jiejing.zhang@freescale.com> | ||
6 | * | ||
7 | * Based on mcs_touchkey.c | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/module.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/input.h> | ||
18 | #include <linux/i2c.h> | ||
19 | #include <linux/slab.h> | ||
20 | #include <linux/delay.h> | ||
21 | #include <linux/bitops.h> | ||
22 | #include <linux/interrupt.h> | ||
23 | #include <linux/i2c/mpr121_touchkey.h> | ||
24 | |||
25 | /* Register definitions */ | ||
26 | #define ELE_TOUCH_STATUS_0_ADDR 0x0 | ||
27 | #define ELE_TOUCH_STATUS_1_ADDR 0X1 | ||
28 | #define MHD_RISING_ADDR 0x2b | ||
29 | #define NHD_RISING_ADDR 0x2c | ||
30 | #define NCL_RISING_ADDR 0x2d | ||
31 | #define FDL_RISING_ADDR 0x2e | ||
32 | #define MHD_FALLING_ADDR 0x2f | ||
33 | #define NHD_FALLING_ADDR 0x30 | ||
34 | #define NCL_FALLING_ADDR 0x31 | ||
35 | #define FDL_FALLING_ADDR 0x32 | ||
36 | #define ELE0_TOUCH_THRESHOLD_ADDR 0x41 | ||
37 | #define ELE0_RELEASE_THRESHOLD_ADDR 0x42 | ||
38 | #define AFE_CONF_ADDR 0x5c | ||
39 | #define FILTER_CONF_ADDR 0x5d | ||
40 | |||
41 | /* | ||
42 | * ELECTRODE_CONF_ADDR: This register configures the number of | ||
43 | * enabled capacitance sensing inputs and its run/suspend mode. | ||
44 | */ | ||
45 | #define ELECTRODE_CONF_ADDR 0x5e | ||
46 | #define AUTO_CONFIG_CTRL_ADDR 0x7b | ||
47 | #define AUTO_CONFIG_USL_ADDR 0x7d | ||
48 | #define AUTO_CONFIG_LSL_ADDR 0x7e | ||
49 | #define AUTO_CONFIG_TL_ADDR 0x7f | ||
50 | |||
51 | /* Threshold of touch/release trigger */ | ||
52 | #define TOUCH_THRESHOLD 0x0f | ||
53 | #define RELEASE_THRESHOLD 0x0a | ||
54 | /* Masks for touch and release triggers */ | ||
55 | #define TOUCH_STATUS_MASK 0xfff | ||
56 | /* MPR121 has 12 keys */ | ||
57 | #define MPR121_MAX_KEY_COUNT 12 | ||
58 | |||
59 | struct mpr121_touchkey { | ||
60 | struct i2c_client *client; | ||
61 | struct input_dev *input_dev; | ||
62 | unsigned int key_val; | ||
63 | unsigned int statusbits; | ||
64 | unsigned int keycount; | ||
65 | u16 keycodes[MPR121_MAX_KEY_COUNT]; | ||
66 | }; | ||
67 | |||
68 | struct mpr121_init_register { | ||
69 | int addr; | ||
70 | u8 val; | ||
71 | }; | ||
72 | |||
73 | static const struct mpr121_init_register init_reg_table[] __devinitconst = { | ||
74 | { MHD_RISING_ADDR, 0x1 }, | ||
75 | { NHD_RISING_ADDR, 0x1 }, | ||
76 | { MHD_FALLING_ADDR, 0x1 }, | ||
77 | { NHD_FALLING_ADDR, 0x1 }, | ||
78 | { NCL_FALLING_ADDR, 0xff }, | ||
79 | { FDL_FALLING_ADDR, 0x02 }, | ||
80 | { FILTER_CONF_ADDR, 0x04 }, | ||
81 | { AFE_CONF_ADDR, 0x0b }, | ||
82 | { AUTO_CONFIG_CTRL_ADDR, 0x0b }, | ||
83 | }; | ||
84 | |||
85 | static irqreturn_t mpr_touchkey_interrupt(int irq, void *dev_id) | ||
86 | { | ||
87 | struct mpr121_touchkey *mpr121 = dev_id; | ||
88 | struct i2c_client *client = mpr121->client; | ||
89 | struct input_dev *input = mpr121->input_dev; | ||
90 | unsigned int key_num, key_val, pressed; | ||
91 | int reg; | ||
92 | |||
93 | reg = i2c_smbus_read_byte_data(client, ELE_TOUCH_STATUS_1_ADDR); | ||
94 | if (reg < 0) { | ||
95 | dev_err(&client->dev, "i2c read error [%d]\n", reg); | ||
96 | goto out; | ||
97 | } | ||
98 | |||
99 | reg <<= 8; | ||
100 | reg |= i2c_smbus_read_byte_data(client, ELE_TOUCH_STATUS_0_ADDR); | ||
101 | if (reg < 0) { | ||
102 | dev_err(&client->dev, "i2c read error [%d]\n", reg); | ||
103 | goto out; | ||
104 | } | ||
105 | |||
106 | reg &= TOUCH_STATUS_MASK; | ||
107 | /* use old press bit to figure out which bit changed */ | ||
108 | key_num = ffs(reg ^ mpr121->statusbits) - 1; | ||
109 | pressed = reg & (1 << key_num); | ||
110 | mpr121->statusbits = reg; | ||
111 | |||
112 | key_val = mpr121->keycodes[key_num]; | ||
113 | |||
114 | input_event(input, EV_MSC, MSC_SCAN, key_num); | ||
115 | input_report_key(input, key_val, pressed); | ||
116 | input_sync(input); | ||
117 | |||
118 | dev_dbg(&client->dev, "key %d %d %s\n", key_num, key_val, | ||
119 | pressed ? "pressed" : "released"); | ||
120 | |||
121 | out: | ||
122 | return IRQ_HANDLED; | ||
123 | } | ||
124 | |||
125 | static int __devinit mpr121_phys_init(const struct mpr121_platform_data *pdata, | ||
126 | struct mpr121_touchkey *mpr121, | ||
127 | struct i2c_client *client) | ||
128 | { | ||
129 | const struct mpr121_init_register *reg; | ||
130 | unsigned char usl, lsl, tl; | ||
131 | int i, t, vdd, ret; | ||
132 | |||
133 | /* Set up touch/release threshold for ele0-ele11 */ | ||
134 | for (i = 0; i <= MPR121_MAX_KEY_COUNT; i++) { | ||
135 | t = ELE0_TOUCH_THRESHOLD_ADDR + (i * 2); | ||
136 | ret = i2c_smbus_write_byte_data(client, t, TOUCH_THRESHOLD); | ||
137 | if (ret < 0) | ||
138 | goto err_i2c_write; | ||
139 | ret = i2c_smbus_write_byte_data(client, t + 1, | ||
140 | RELEASE_THRESHOLD); | ||
141 | if (ret < 0) | ||
142 | goto err_i2c_write; | ||
143 | } | ||
144 | |||
145 | /* Set up init register */ | ||
146 | for (i = 0; i < ARRAY_SIZE(init_reg_table); i++) { | ||
147 | reg = &init_reg_table[i]; | ||
148 | ret = i2c_smbus_write_byte_data(client, reg->addr, reg->val); | ||
149 | if (ret < 0) | ||
150 | goto err_i2c_write; | ||
151 | } | ||
152 | |||
153 | |||
154 | /* | ||
155 | * Capacitance on sensing input varies and needs to be compensated. | ||
156 | * The internal MPR121-auto-configuration can do this if it's | ||
157 | * registers are set properly (based on pdata->vdd_uv). | ||
158 | */ | ||
159 | vdd = pdata->vdd_uv / 1000; | ||
160 | usl = ((vdd - 700) * 256) / vdd; | ||
161 | lsl = (usl * 65) / 100; | ||
162 | tl = (usl * 90) / 100; | ||
163 | ret = i2c_smbus_write_byte_data(client, AUTO_CONFIG_USL_ADDR, usl); | ||
164 | ret |= i2c_smbus_write_byte_data(client, AUTO_CONFIG_LSL_ADDR, lsl); | ||
165 | ret |= i2c_smbus_write_byte_data(client, AUTO_CONFIG_TL_ADDR, tl); | ||
166 | ret |= i2c_smbus_write_byte_data(client, ELECTRODE_CONF_ADDR, | ||
167 | mpr121->keycount); | ||
168 | if (ret != 0) | ||
169 | goto err_i2c_write; | ||
170 | |||
171 | dev_dbg(&client->dev, "set up with %x keys.\n", mpr121->keycount); | ||
172 | |||
173 | return 0; | ||
174 | |||
175 | err_i2c_write: | ||
176 | dev_err(&client->dev, "i2c write error: %d\n", ret); | ||
177 | return ret; | ||
178 | } | ||
179 | |||
180 | static int __devinit mpr_touchkey_probe(struct i2c_client *client, | ||
181 | const struct i2c_device_id *id) | ||
182 | { | ||
183 | const struct mpr121_platform_data *pdata = client->dev.platform_data; | ||
184 | struct mpr121_touchkey *mpr121; | ||
185 | struct input_dev *input_dev; | ||
186 | int error; | ||
187 | int i; | ||
188 | |||
189 | if (!pdata) { | ||
190 | dev_err(&client->dev, "no platform data defined\n"); | ||
191 | return -EINVAL; | ||
192 | } | ||
193 | |||
194 | if (!pdata->keymap || !pdata->keymap_size) { | ||
195 | dev_err(&client->dev, "missing keymap data\n"); | ||
196 | return -EINVAL; | ||
197 | } | ||
198 | |||
199 | if (pdata->keymap_size > MPR121_MAX_KEY_COUNT) { | ||
200 | dev_err(&client->dev, "too many keys defined\n"); | ||
201 | return -EINVAL; | ||
202 | } | ||
203 | |||
204 | if (!client->irq) { | ||
205 | dev_err(&client->dev, "irq number should not be zero\n"); | ||
206 | return -EINVAL; | ||
207 | } | ||
208 | |||
209 | mpr121 = kzalloc(sizeof(struct mpr121_touchkey), GFP_KERNEL); | ||
210 | input_dev = input_allocate_device(); | ||
211 | if (!mpr121 || !input_dev) { | ||
212 | dev_err(&client->dev, "Failed to allocate memory\n"); | ||
213 | error = -ENOMEM; | ||
214 | goto err_free_mem; | ||
215 | } | ||
216 | |||
217 | mpr121->client = client; | ||
218 | mpr121->input_dev = input_dev; | ||
219 | mpr121->keycount = pdata->keymap_size; | ||
220 | |||
221 | input_dev->name = "Freescale MPR121 Touchkey"; | ||
222 | input_dev->id.bustype = BUS_I2C; | ||
223 | input_dev->dev.parent = &client->dev; | ||
224 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); | ||
225 | |||
226 | input_dev->keycode = mpr121->keycodes; | ||
227 | input_dev->keycodesize = sizeof(mpr121->keycodes[0]); | ||
228 | input_dev->keycodemax = mpr121->keycount; | ||
229 | |||
230 | for (i = 0; i < pdata->keymap_size; i++) { | ||
231 | input_set_capability(input_dev, EV_KEY, pdata->keymap[i]); | ||
232 | mpr121->keycodes[i] = pdata->keymap[i]; | ||
233 | } | ||
234 | |||
235 | error = mpr121_phys_init(pdata, mpr121, client); | ||
236 | if (error) { | ||
237 | dev_err(&client->dev, "Failed to init register\n"); | ||
238 | goto err_free_mem; | ||
239 | } | ||
240 | |||
241 | error = request_threaded_irq(client->irq, NULL, | ||
242 | mpr_touchkey_interrupt, | ||
243 | IRQF_TRIGGER_FALLING, | ||
244 | client->dev.driver->name, mpr121); | ||
245 | if (error) { | ||
246 | dev_err(&client->dev, "Failed to register interrupt\n"); | ||
247 | goto err_free_mem; | ||
248 | } | ||
249 | |||
250 | error = input_register_device(input_dev); | ||
251 | if (error) | ||
252 | goto err_free_irq; | ||
253 | |||
254 | i2c_set_clientdata(client, mpr121); | ||
255 | device_init_wakeup(&client->dev, pdata->wakeup); | ||
256 | |||
257 | return 0; | ||
258 | |||
259 | err_free_irq: | ||
260 | free_irq(client->irq, mpr121); | ||
261 | err_free_mem: | ||
262 | input_free_device(input_dev); | ||
263 | kfree(mpr121); | ||
264 | return error; | ||
265 | } | ||
266 | |||
267 | static int __devexit mpr_touchkey_remove(struct i2c_client *client) | ||
268 | { | ||
269 | struct mpr121_touchkey *mpr121 = i2c_get_clientdata(client); | ||
270 | |||
271 | free_irq(client->irq, mpr121); | ||
272 | input_unregister_device(mpr121->input_dev); | ||
273 | kfree(mpr121); | ||
274 | |||
275 | return 0; | ||
276 | } | ||
277 | |||
278 | #ifdef CONFIG_PM_SLEEP | ||
279 | static int mpr_suspend(struct device *dev) | ||
280 | { | ||
281 | struct i2c_client *client = to_i2c_client(dev); | ||
282 | |||
283 | if (device_may_wakeup(&client->dev)) | ||
284 | enable_irq_wake(client->irq); | ||
285 | |||
286 | i2c_smbus_write_byte_data(client, ELECTRODE_CONF_ADDR, 0x00); | ||
287 | |||
288 | return 0; | ||
289 | } | ||
290 | |||
291 | static int mpr_resume(struct device *dev) | ||
292 | { | ||
293 | struct i2c_client *client = to_i2c_client(dev); | ||
294 | struct mpr121_touchkey *mpr121 = i2c_get_clientdata(client); | ||
295 | |||
296 | if (device_may_wakeup(&client->dev)) | ||
297 | disable_irq_wake(client->irq); | ||
298 | |||
299 | i2c_smbus_write_byte_data(client, ELECTRODE_CONF_ADDR, | ||
300 | mpr121->keycount); | ||
301 | |||
302 | return 0; | ||
303 | } | ||
304 | #endif | ||
305 | |||
306 | static SIMPLE_DEV_PM_OPS(mpr121_touchkey_pm_ops, mpr_suspend, mpr_resume); | ||
307 | |||
308 | static const struct i2c_device_id mpr121_id[] = { | ||
309 | { "mpr121_touchkey", 0 }, | ||
310 | { } | ||
311 | }; | ||
312 | MODULE_DEVICE_TABLE(i2c, mpr121_id); | ||
313 | |||
314 | static struct i2c_driver mpr_touchkey_driver = { | ||
315 | .driver = { | ||
316 | .name = "mpr121", | ||
317 | .owner = THIS_MODULE, | ||
318 | .pm = &mpr121_touchkey_pm_ops, | ||
319 | }, | ||
320 | .id_table = mpr121_id, | ||
321 | .probe = mpr_touchkey_probe, | ||
322 | .remove = __devexit_p(mpr_touchkey_remove), | ||
323 | }; | ||
324 | |||
325 | static int __init mpr_touchkey_init(void) | ||
326 | { | ||
327 | return i2c_add_driver(&mpr_touchkey_driver); | ||
328 | } | ||
329 | module_init(mpr_touchkey_init); | ||
330 | |||
331 | static void __exit mpr_touchkey_exit(void) | ||
332 | { | ||
333 | i2c_del_driver(&mpr_touchkey_driver); | ||
334 | } | ||
335 | module_exit(mpr_touchkey_exit); | ||
336 | |||
337 | MODULE_LICENSE("GPL"); | ||
338 | MODULE_AUTHOR("Zhang Jiejing <jiejing.zhang@freescale.com>"); | ||
339 | MODULE_DESCRIPTION("Touch Key driver for Freescale MPR121 Chip"); | ||
diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c index 0e2a19cb43d8..f23a743817db 100644 --- a/drivers/input/keyboard/omap-keypad.c +++ b/drivers/input/keyboard/omap-keypad.c | |||
@@ -413,7 +413,7 @@ static int __devinit omap_kp_probe(struct platform_device *pdev) | |||
413 | return 0; | 413 | return 0; |
414 | err5: | 414 | err5: |
415 | for (i = irq_idx - 1; i >=0; i--) | 415 | for (i = irq_idx - 1; i >=0; i--) |
416 | free_irq(row_gpios[i], NULL); | 416 | free_irq(row_gpios[i], omap_kp); |
417 | err4: | 417 | err4: |
418 | input_unregister_device(omap_kp->input); | 418 | input_unregister_device(omap_kp->input); |
419 | input_dev = NULL; | 419 | input_dev = NULL; |
@@ -444,11 +444,11 @@ static int __devexit omap_kp_remove(struct platform_device *pdev) | |||
444 | gpio_free(col_gpios[i]); | 444 | gpio_free(col_gpios[i]); |
445 | for (i = 0; i < omap_kp->rows; i++) { | 445 | for (i = 0; i < omap_kp->rows; i++) { |
446 | gpio_free(row_gpios[i]); | 446 | gpio_free(row_gpios[i]); |
447 | free_irq(gpio_to_irq(row_gpios[i]), NULL); | 447 | free_irq(gpio_to_irq(row_gpios[i]), omap_kp); |
448 | } | 448 | } |
449 | } else { | 449 | } else { |
450 | omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT); | 450 | omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT); |
451 | free_irq(omap_kp->irq, NULL); | 451 | free_irq(omap_kp->irq, omap_kp); |
452 | } | 452 | } |
453 | 453 | ||
454 | del_timer_sync(&omap_kp->timer); | 454 | del_timer_sync(&omap_kp->timer); |
diff --git a/drivers/input/keyboard/qt1070.c b/drivers/input/keyboard/qt1070.c index fba8404c7297..ca7b89196ab7 100644 --- a/drivers/input/keyboard/qt1070.c +++ b/drivers/input/keyboard/qt1070.c | |||
@@ -248,6 +248,7 @@ static const struct i2c_device_id qt1070_id[] = { | |||
248 | { "qt1070", 0 }, | 248 | { "qt1070", 0 }, |
249 | { }, | 249 | { }, |
250 | }; | 250 | }; |
251 | MODULE_DEVICE_TABLE(i2c, qt1070_id); | ||
251 | 252 | ||
252 | static struct i2c_driver qt1070_driver = { | 253 | static struct i2c_driver qt1070_driver = { |
253 | .driver = { | 254 | .driver = { |
diff --git a/drivers/input/keyboard/sh_keysc.c b/drivers/input/keyboard/sh_keysc.c index d7dafd9425b6..834cf98e7efb 100644 --- a/drivers/input/keyboard/sh_keysc.c +++ b/drivers/input/keyboard/sh_keysc.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/input.h> | 20 | #include <linux/input.h> |
21 | #include <linux/input/sh_keysc.h> | 21 | #include <linux/input/sh_keysc.h> |
22 | #include <linux/bitmap.h> | 22 | #include <linux/bitmap.h> |
23 | #include <linux/clk.h> | 23 | #include <linux/pm_runtime.h> |
24 | #include <linux/io.h> | 24 | #include <linux/io.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | 26 | ||
@@ -37,7 +37,6 @@ static const struct { | |||
37 | 37 | ||
38 | struct sh_keysc_priv { | 38 | struct sh_keysc_priv { |
39 | void __iomem *iomem_base; | 39 | void __iomem *iomem_base; |
40 | struct clk *clk; | ||
41 | DECLARE_BITMAP(last_keys, SH_KEYSC_MAXKEYS); | 40 | DECLARE_BITMAP(last_keys, SH_KEYSC_MAXKEYS); |
42 | struct input_dev *input; | 41 | struct input_dev *input; |
43 | struct sh_keysc_info pdata; | 42 | struct sh_keysc_info pdata; |
@@ -169,7 +168,6 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev) | |||
169 | struct sh_keysc_info *pdata; | 168 | struct sh_keysc_info *pdata; |
170 | struct resource *res; | 169 | struct resource *res; |
171 | struct input_dev *input; | 170 | struct input_dev *input; |
172 | char clk_name[8]; | ||
173 | int i; | 171 | int i; |
174 | int irq, error; | 172 | int irq, error; |
175 | 173 | ||
@@ -210,19 +208,11 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev) | |||
210 | goto err1; | 208 | goto err1; |
211 | } | 209 | } |
212 | 210 | ||
213 | snprintf(clk_name, sizeof(clk_name), "keysc%d", pdev->id); | ||
214 | priv->clk = clk_get(&pdev->dev, clk_name); | ||
215 | if (IS_ERR(priv->clk)) { | ||
216 | dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name); | ||
217 | error = PTR_ERR(priv->clk); | ||
218 | goto err2; | ||
219 | } | ||
220 | |||
221 | priv->input = input_allocate_device(); | 211 | priv->input = input_allocate_device(); |
222 | if (!priv->input) { | 212 | if (!priv->input) { |
223 | dev_err(&pdev->dev, "failed to allocate input device\n"); | 213 | dev_err(&pdev->dev, "failed to allocate input device\n"); |
224 | error = -ENOMEM; | 214 | error = -ENOMEM; |
225 | goto err3; | 215 | goto err2; |
226 | } | 216 | } |
227 | 217 | ||
228 | input = priv->input; | 218 | input = priv->input; |
@@ -241,10 +231,11 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev) | |||
241 | input->keycodesize = sizeof(pdata->keycodes[0]); | 231 | input->keycodesize = sizeof(pdata->keycodes[0]); |
242 | input->keycodemax = ARRAY_SIZE(pdata->keycodes); | 232 | input->keycodemax = ARRAY_SIZE(pdata->keycodes); |
243 | 233 | ||
244 | error = request_irq(irq, sh_keysc_isr, 0, pdev->name, pdev); | 234 | error = request_threaded_irq(irq, NULL, sh_keysc_isr, IRQF_ONESHOT, |
235 | dev_name(&pdev->dev), pdev); | ||
245 | if (error) { | 236 | if (error) { |
246 | dev_err(&pdev->dev, "failed to request IRQ\n"); | 237 | dev_err(&pdev->dev, "failed to request IRQ\n"); |
247 | goto err4; | 238 | goto err3; |
248 | } | 239 | } |
249 | 240 | ||
250 | for (i = 0; i < SH_KEYSC_MAXKEYS; i++) | 241 | for (i = 0; i < SH_KEYSC_MAXKEYS; i++) |
@@ -254,10 +245,11 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev) | |||
254 | error = input_register_device(input); | 245 | error = input_register_device(input); |
255 | if (error) { | 246 | if (error) { |
256 | dev_err(&pdev->dev, "failed to register input device\n"); | 247 | dev_err(&pdev->dev, "failed to register input device\n"); |
257 | goto err5; | 248 | goto err4; |
258 | } | 249 | } |
259 | 250 | ||
260 | clk_enable(priv->clk); | 251 | pm_runtime_enable(&pdev->dev); |
252 | pm_runtime_get_sync(&pdev->dev); | ||
261 | 253 | ||
262 | sh_keysc_write(priv, KYCR1, (sh_keysc_mode[pdata->mode].kymd << 8) | | 254 | sh_keysc_write(priv, KYCR1, (sh_keysc_mode[pdata->mode].kymd << 8) | |
263 | pdata->scan_timing); | 255 | pdata->scan_timing); |
@@ -267,12 +259,10 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev) | |||
267 | 259 | ||
268 | return 0; | 260 | return 0; |
269 | 261 | ||
270 | err5: | ||
271 | free_irq(irq, pdev); | ||
272 | err4: | 262 | err4: |
273 | input_free_device(input); | 263 | free_irq(irq, pdev); |
274 | err3: | 264 | err3: |
275 | clk_put(priv->clk); | 265 | input_free_device(input); |
276 | err2: | 266 | err2: |
277 | iounmap(priv->iomem_base); | 267 | iounmap(priv->iomem_base); |
278 | err1: | 268 | err1: |
@@ -292,8 +282,8 @@ static int __devexit sh_keysc_remove(struct platform_device *pdev) | |||
292 | free_irq(platform_get_irq(pdev, 0), pdev); | 282 | free_irq(platform_get_irq(pdev, 0), pdev); |
293 | iounmap(priv->iomem_base); | 283 | iounmap(priv->iomem_base); |
294 | 284 | ||
295 | clk_disable(priv->clk); | 285 | pm_runtime_put_sync(&pdev->dev); |
296 | clk_put(priv->clk); | 286 | pm_runtime_disable(&pdev->dev); |
297 | 287 | ||
298 | platform_set_drvdata(pdev, NULL); | 288 | platform_set_drvdata(pdev, NULL); |
299 | kfree(priv); | 289 | kfree(priv); |
@@ -301,6 +291,7 @@ static int __devexit sh_keysc_remove(struct platform_device *pdev) | |||
301 | return 0; | 291 | return 0; |
302 | } | 292 | } |
303 | 293 | ||
294 | #if CONFIG_PM_SLEEP | ||
304 | static int sh_keysc_suspend(struct device *dev) | 295 | static int sh_keysc_suspend(struct device *dev) |
305 | { | 296 | { |
306 | struct platform_device *pdev = to_platform_device(dev); | 297 | struct platform_device *pdev = to_platform_device(dev); |
@@ -311,14 +302,13 @@ static int sh_keysc_suspend(struct device *dev) | |||
311 | value = sh_keysc_read(priv, KYCR1); | 302 | value = sh_keysc_read(priv, KYCR1); |
312 | 303 | ||
313 | if (device_may_wakeup(dev)) { | 304 | if (device_may_wakeup(dev)) { |
314 | value |= 0x80; | 305 | sh_keysc_write(priv, KYCR1, value | 0x80); |
315 | enable_irq_wake(irq); | 306 | enable_irq_wake(irq); |
316 | } else { | 307 | } else { |
317 | value &= ~0x80; | 308 | sh_keysc_write(priv, KYCR1, value & ~0x80); |
309 | pm_runtime_put_sync(dev); | ||
318 | } | 310 | } |
319 | 311 | ||
320 | sh_keysc_write(priv, KYCR1, value); | ||
321 | |||
322 | return 0; | 312 | return 0; |
323 | } | 313 | } |
324 | 314 | ||
@@ -329,16 +319,17 @@ static int sh_keysc_resume(struct device *dev) | |||
329 | 319 | ||
330 | if (device_may_wakeup(dev)) | 320 | if (device_may_wakeup(dev)) |
331 | disable_irq_wake(irq); | 321 | disable_irq_wake(irq); |
322 | else | ||
323 | pm_runtime_get_sync(dev); | ||
332 | 324 | ||
333 | return 0; | 325 | return 0; |
334 | } | 326 | } |
327 | #endif | ||
335 | 328 | ||
336 | static const struct dev_pm_ops sh_keysc_dev_pm_ops = { | 329 | static SIMPLE_DEV_PM_OPS(sh_keysc_dev_pm_ops, |
337 | .suspend = sh_keysc_suspend, | 330 | sh_keysc_suspend, sh_keysc_resume); |
338 | .resume = sh_keysc_resume, | ||
339 | }; | ||
340 | 331 | ||
341 | struct platform_driver sh_keysc_device_driver = { | 332 | static struct platform_driver sh_keysc_device_driver = { |
342 | .probe = sh_keysc_probe, | 333 | .probe = sh_keysc_probe, |
343 | .remove = __devexit_p(sh_keysc_remove), | 334 | .remove = __devexit_p(sh_keysc_remove), |
344 | .driver = { | 335 | .driver = { |
diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c index 99ce9032d08c..2b3b73ec6689 100644 --- a/drivers/input/keyboard/tegra-kbc.c +++ b/drivers/input/keyboard/tegra-kbc.c | |||
@@ -66,12 +66,11 @@ struct tegra_kbc { | |||
66 | void __iomem *mmio; | 66 | void __iomem *mmio; |
67 | struct input_dev *idev; | 67 | struct input_dev *idev; |
68 | unsigned int irq; | 68 | unsigned int irq; |
69 | unsigned int wake_enable_rows; | ||
70 | unsigned int wake_enable_cols; | ||
71 | spinlock_t lock; | 69 | spinlock_t lock; |
72 | unsigned int repoll_dly; | 70 | unsigned int repoll_dly; |
73 | unsigned long cp_dly_jiffies; | 71 | unsigned long cp_dly_jiffies; |
74 | bool use_fn_map; | 72 | bool use_fn_map; |
73 | bool use_ghost_filter; | ||
75 | const struct tegra_kbc_platform_data *pdata; | 74 | const struct tegra_kbc_platform_data *pdata; |
76 | unsigned short keycode[KBC_MAX_KEY * 2]; | 75 | unsigned short keycode[KBC_MAX_KEY * 2]; |
77 | unsigned short current_keys[KBC_MAX_KPENT]; | 76 | unsigned short current_keys[KBC_MAX_KPENT]; |
@@ -260,6 +259,8 @@ static void tegra_kbc_report_keys(struct tegra_kbc *kbc) | |||
260 | unsigned int num_down = 0; | 259 | unsigned int num_down = 0; |
261 | unsigned long flags; | 260 | unsigned long flags; |
262 | bool fn_keypress = false; | 261 | bool fn_keypress = false; |
262 | bool key_in_same_row = false; | ||
263 | bool key_in_same_col = false; | ||
263 | 264 | ||
264 | spin_lock_irqsave(&kbc->lock, flags); | 265 | spin_lock_irqsave(&kbc->lock, flags); |
265 | for (i = 0; i < KBC_MAX_KPENT; i++) { | 266 | for (i = 0; i < KBC_MAX_KPENT; i++) { |
@@ -285,6 +286,34 @@ static void tegra_kbc_report_keys(struct tegra_kbc *kbc) | |||
285 | } | 286 | } |
286 | 287 | ||
287 | /* | 288 | /* |
289 | * Matrix keyboard designs are prone to keyboard ghosting. | ||
290 | * Ghosting occurs if there are 3 keys such that - | ||
291 | * any 2 of the 3 keys share a row, and any 2 of them share a column. | ||
292 | * If so ignore the key presses for this iteration. | ||
293 | */ | ||
294 | if ((kbc->use_ghost_filter) && (num_down >= 3)) { | ||
295 | for (i = 0; i < num_down; i++) { | ||
296 | unsigned int j; | ||
297 | u8 curr_col = scancodes[i] & 0x07; | ||
298 | u8 curr_row = scancodes[i] >> KBC_ROW_SHIFT; | ||
299 | |||
300 | /* | ||
301 | * Find 2 keys such that one key is in the same row | ||
302 | * and the other is in the same column as the i-th key. | ||
303 | */ | ||
304 | for (j = i + 1; j < num_down; j++) { | ||
305 | u8 col = scancodes[j] & 0x07; | ||
306 | u8 row = scancodes[j] >> KBC_ROW_SHIFT; | ||
307 | |||
308 | if (col == curr_col) | ||
309 | key_in_same_col = true; | ||
310 | if (row == curr_row) | ||
311 | key_in_same_row = true; | ||
312 | } | ||
313 | } | ||
314 | } | ||
315 | |||
316 | /* | ||
288 | * If the platform uses Fn keymaps, translate keys on a Fn keypress. | 317 | * If the platform uses Fn keymaps, translate keys on a Fn keypress. |
289 | * Function keycodes are KBC_MAX_KEY apart from the plain keycodes. | 318 | * Function keycodes are KBC_MAX_KEY apart from the plain keycodes. |
290 | */ | 319 | */ |
@@ -297,6 +326,10 @@ static void tegra_kbc_report_keys(struct tegra_kbc *kbc) | |||
297 | 326 | ||
298 | spin_unlock_irqrestore(&kbc->lock, flags); | 327 | spin_unlock_irqrestore(&kbc->lock, flags); |
299 | 328 | ||
329 | /* Ignore the key presses for this iteration? */ | ||
330 | if (key_in_same_col && key_in_same_row) | ||
331 | return; | ||
332 | |||
300 | tegra_kbc_report_released_keys(kbc->idev, | 333 | tegra_kbc_report_released_keys(kbc->idev, |
301 | kbc->current_keys, kbc->num_pressed_keys, | 334 | kbc->current_keys, kbc->num_pressed_keys, |
302 | keycodes, num_down); | 335 | keycodes, num_down); |
@@ -383,21 +416,11 @@ static void tegra_kbc_setup_wakekeys(struct tegra_kbc *kbc, bool filter) | |||
383 | int i; | 416 | int i; |
384 | unsigned int rst_val; | 417 | unsigned int rst_val; |
385 | 418 | ||
386 | BUG_ON(pdata->wake_cnt > KBC_MAX_KEY); | 419 | /* Either mask all keys or none. */ |
387 | rst_val = (filter && pdata->wake_cnt) ? ~0 : 0; | 420 | rst_val = (filter && !pdata->wakeup) ? ~0 : 0; |
388 | 421 | ||
389 | for (i = 0; i < KBC_MAX_ROW; i++) | 422 | for (i = 0; i < KBC_MAX_ROW; i++) |
390 | writel(rst_val, kbc->mmio + KBC_ROW0_MASK_0 + i * 4); | 423 | writel(rst_val, kbc->mmio + KBC_ROW0_MASK_0 + i * 4); |
391 | |||
392 | if (filter) { | ||
393 | for (i = 0; i < pdata->wake_cnt; i++) { | ||
394 | u32 val, addr; | ||
395 | addr = pdata->wake_cfg[i].row * 4 + KBC_ROW0_MASK_0; | ||
396 | val = readl(kbc->mmio + addr); | ||
397 | val &= ~(1 << pdata->wake_cfg[i].col); | ||
398 | writel(val, kbc->mmio + addr); | ||
399 | } | ||
400 | } | ||
401 | } | 424 | } |
402 | 425 | ||
403 | static void tegra_kbc_config_pins(struct tegra_kbc *kbc) | 426 | static void tegra_kbc_config_pins(struct tegra_kbc *kbc) |
@@ -559,7 +582,6 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev) | |||
559 | struct resource *res; | 582 | struct resource *res; |
560 | int irq; | 583 | int irq; |
561 | int err; | 584 | int err; |
562 | int i; | ||
563 | int num_rows = 0; | 585 | int num_rows = 0; |
564 | unsigned int debounce_cnt; | 586 | unsigned int debounce_cnt; |
565 | unsigned int scan_time_rows; | 587 | unsigned int scan_time_rows; |
@@ -616,13 +638,6 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev) | |||
616 | goto err_iounmap; | 638 | goto err_iounmap; |
617 | } | 639 | } |
618 | 640 | ||
619 | kbc->wake_enable_rows = 0; | ||
620 | kbc->wake_enable_cols = 0; | ||
621 | for (i = 0; i < pdata->wake_cnt; i++) { | ||
622 | kbc->wake_enable_rows |= (1 << pdata->wake_cfg[i].row); | ||
623 | kbc->wake_enable_cols |= (1 << pdata->wake_cfg[i].col); | ||
624 | } | ||
625 | |||
626 | /* | 641 | /* |
627 | * The time delay between two consecutive reads of the FIFO is | 642 | * The time delay between two consecutive reads of the FIFO is |
628 | * the sum of the repeat time and the time taken for scanning | 643 | * the sum of the repeat time and the time taken for scanning |
@@ -652,6 +667,7 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev) | |||
652 | input_dev->keycodemax *= 2; | 667 | input_dev->keycodemax *= 2; |
653 | 668 | ||
654 | kbc->use_fn_map = pdata->use_fn_map; | 669 | kbc->use_fn_map = pdata->use_fn_map; |
670 | kbc->use_ghost_filter = pdata->use_ghost_filter; | ||
655 | keymap_data = pdata->keymap_data ?: &tegra_kbc_default_keymap_data; | 671 | keymap_data = pdata->keymap_data ?: &tegra_kbc_default_keymap_data; |
656 | matrix_keypad_build_keymap(keymap_data, KBC_ROW_SHIFT, | 672 | matrix_keypad_build_keymap(keymap_data, KBC_ROW_SHIFT, |
657 | input_dev->keycode, input_dev->keybit); | 673 | input_dev->keycode, input_dev->keybit); |
diff --git a/drivers/input/misc/88pm860x_onkey.c b/drivers/input/misc/88pm860x_onkey.c index 4cc82826ea6b..3dca3c14510e 100644 --- a/drivers/input/misc/88pm860x_onkey.c +++ b/drivers/input/misc/88pm860x_onkey.c | |||
@@ -74,7 +74,7 @@ static int __devinit pm860x_onkey_probe(struct platform_device *pdev) | |||
74 | info->chip = chip; | 74 | info->chip = chip; |
75 | info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion; | 75 | info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion; |
76 | info->dev = &pdev->dev; | 76 | info->dev = &pdev->dev; |
77 | info->irq = irq + chip->irq_base; | 77 | info->irq = irq; |
78 | 78 | ||
79 | info->idev = input_allocate_device(); | 79 | info->idev = input_allocate_device(); |
80 | if (!info->idev) { | 80 | if (!info->idev) { |
diff --git a/drivers/input/misc/ad714x.c b/drivers/input/misc/ad714x.c index c431d09e401a..c3a62c42cd28 100644 --- a/drivers/input/misc/ad714x.c +++ b/drivers/input/misc/ad714x.c | |||
@@ -79,13 +79,7 @@ struct ad714x_slider_drv { | |||
79 | struct ad714x_wheel_drv { | 79 | struct ad714x_wheel_drv { |
80 | int abs_pos; | 80 | int abs_pos; |
81 | int flt_pos; | 81 | int flt_pos; |
82 | int pre_mean_value; | ||
83 | int pre_highest_stage; | 82 | int pre_highest_stage; |
84 | int pre_mean_value_no_offset; | ||
85 | int mean_value; | ||
86 | int mean_value_no_offset; | ||
87 | int pos_offset; | ||
88 | int pos_ratio; | ||
89 | int highest_stage; | 83 | int highest_stage; |
90 | enum ad714x_device_state state; | 84 | enum ad714x_device_state state; |
91 | struct input_dev *input; | 85 | struct input_dev *input; |
@@ -158,10 +152,10 @@ static void ad714x_use_com_int(struct ad714x_chip *ad714x, | |||
158 | unsigned short data; | 152 | unsigned short data; |
159 | unsigned short mask; | 153 | unsigned short mask; |
160 | 154 | ||
161 | mask = ((1 << (end_stage + 1)) - 1) - (1 << start_stage); | 155 | mask = ((1 << (end_stage + 1)) - 1) - ((1 << start_stage) - 1); |
162 | 156 | ||
163 | ad714x->read(ad714x->dev, STG_COM_INT_EN_REG, &data); | 157 | ad714x->read(ad714x->dev, STG_COM_INT_EN_REG, &data); |
164 | data |= 1 << start_stage; | 158 | data |= 1 << end_stage; |
165 | ad714x->write(ad714x->dev, STG_COM_INT_EN_REG, data); | 159 | ad714x->write(ad714x->dev, STG_COM_INT_EN_REG, data); |
166 | 160 | ||
167 | ad714x->read(ad714x->dev, STG_HIGH_INT_EN_REG, &data); | 161 | ad714x->read(ad714x->dev, STG_HIGH_INT_EN_REG, &data); |
@@ -175,10 +169,10 @@ static void ad714x_use_thr_int(struct ad714x_chip *ad714x, | |||
175 | unsigned short data; | 169 | unsigned short data; |
176 | unsigned short mask; | 170 | unsigned short mask; |
177 | 171 | ||
178 | mask = ((1 << (end_stage + 1)) - 1) - (1 << start_stage); | 172 | mask = ((1 << (end_stage + 1)) - 1) - ((1 << start_stage) - 1); |
179 | 173 | ||
180 | ad714x->read(ad714x->dev, STG_COM_INT_EN_REG, &data); | 174 | ad714x->read(ad714x->dev, STG_COM_INT_EN_REG, &data); |
181 | data &= ~(1 << start_stage); | 175 | data &= ~(1 << end_stage); |
182 | ad714x->write(ad714x->dev, STG_COM_INT_EN_REG, data); | 176 | ad714x->write(ad714x->dev, STG_COM_INT_EN_REG, data); |
183 | 177 | ||
184 | ad714x->read(ad714x->dev, STG_HIGH_INT_EN_REG, &data); | 178 | ad714x->read(ad714x->dev, STG_HIGH_INT_EN_REG, &data); |
@@ -404,7 +398,6 @@ static void ad714x_slider_state_machine(struct ad714x_chip *ad714x, int idx) | |||
404 | ad714x_slider_cal_highest_stage(ad714x, idx); | 398 | ad714x_slider_cal_highest_stage(ad714x, idx); |
405 | ad714x_slider_cal_abs_pos(ad714x, idx); | 399 | ad714x_slider_cal_abs_pos(ad714x, idx); |
406 | ad714x_slider_cal_flt_pos(ad714x, idx); | 400 | ad714x_slider_cal_flt_pos(ad714x, idx); |
407 | |||
408 | input_report_abs(sw->input, ABS_X, sw->flt_pos); | 401 | input_report_abs(sw->input, ABS_X, sw->flt_pos); |
409 | input_report_key(sw->input, BTN_TOUCH, 1); | 402 | input_report_key(sw->input, BTN_TOUCH, 1); |
410 | } else { | 403 | } else { |
@@ -468,104 +461,41 @@ static void ad714x_wheel_cal_sensor_val(struct ad714x_chip *ad714x, int idx) | |||
468 | /* | 461 | /* |
469 | * When the scroll wheel is activated, we compute the absolute position based | 462 | * When the scroll wheel is activated, we compute the absolute position based |
470 | * on the sensor values. To calculate the position, we first determine the | 463 | * on the sensor values. To calculate the position, we first determine the |
471 | * sensor that has the greatest response among the 8 sensors that constitutes | 464 | * sensor that has the greatest response among the sensors that constitutes |
472 | * the scrollwheel. Then we determined the 2 sensors on either sides of the | 465 | * the scrollwheel. Then we determined the sensors on either sides of the |
473 | * sensor with the highest response and we apply weights to these sensors. The | 466 | * sensor with the highest response and we apply weights to these sensors. The |
474 | * result of this computation gives us the mean value which defined by the | 467 | * result of this computation gives us the mean value. |
475 | * following formula: | ||
476 | * For i= second_before_highest_stage to i= second_after_highest_stage | ||
477 | * v += Sensor response(i)*WEIGHT*(i+3) | ||
478 | * w += Sensor response(i) | ||
479 | * Mean_Value=v/w | ||
480 | * pos_on_scrollwheel = (Mean_Value - position_offset) / position_ratio | ||
481 | */ | 468 | */ |
482 | 469 | ||
483 | #define WEIGHT_FACTOR 30 | ||
484 | /* This constant prevents the "PositionOffset" from reaching a big value */ | ||
485 | #define OFFSET_POSITION_CLAMP 120 | ||
486 | static void ad714x_wheel_cal_abs_pos(struct ad714x_chip *ad714x, int idx) | 470 | static void ad714x_wheel_cal_abs_pos(struct ad714x_chip *ad714x, int idx) |
487 | { | 471 | { |
488 | struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx]; | 472 | struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx]; |
489 | struct ad714x_wheel_drv *sw = &ad714x->sw->wheel[idx]; | 473 | struct ad714x_wheel_drv *sw = &ad714x->sw->wheel[idx]; |
490 | int stage_num = hw->end_stage - hw->start_stage + 1; | 474 | int stage_num = hw->end_stage - hw->start_stage + 1; |
491 | int second_before, first_before, highest, first_after, second_after; | 475 | int first_before, highest, first_after; |
492 | int a_param, b_param; | 476 | int a_param, b_param; |
493 | 477 | ||
494 | /* Calculate Mean value */ | ||
495 | |||
496 | second_before = (sw->highest_stage + stage_num - 2) % stage_num; | ||
497 | first_before = (sw->highest_stage + stage_num - 1) % stage_num; | 478 | first_before = (sw->highest_stage + stage_num - 1) % stage_num; |
498 | highest = sw->highest_stage; | 479 | highest = sw->highest_stage; |
499 | first_after = (sw->highest_stage + stage_num + 1) % stage_num; | 480 | first_after = (sw->highest_stage + stage_num + 1) % stage_num; |
500 | second_after = (sw->highest_stage + stage_num + 2) % stage_num; | ||
501 | |||
502 | if (((sw->highest_stage - hw->start_stage) > 1) && | ||
503 | ((hw->end_stage - sw->highest_stage) > 1)) { | ||
504 | a_param = ad714x->sensor_val[second_before] * | ||
505 | (second_before - hw->start_stage + 3) + | ||
506 | ad714x->sensor_val[first_before] * | ||
507 | (second_before - hw->start_stage + 3) + | ||
508 | ad714x->sensor_val[highest] * | ||
509 | (second_before - hw->start_stage + 3) + | ||
510 | ad714x->sensor_val[first_after] * | ||
511 | (first_after - hw->start_stage + 3) + | ||
512 | ad714x->sensor_val[second_after] * | ||
513 | (second_after - hw->start_stage + 3); | ||
514 | } else { | ||
515 | a_param = ad714x->sensor_val[second_before] * | ||
516 | (second_before - hw->start_stage + 1) + | ||
517 | ad714x->sensor_val[first_before] * | ||
518 | (second_before - hw->start_stage + 2) + | ||
519 | ad714x->sensor_val[highest] * | ||
520 | (second_before - hw->start_stage + 3) + | ||
521 | ad714x->sensor_val[first_after] * | ||
522 | (first_after - hw->start_stage + 4) + | ||
523 | ad714x->sensor_val[second_after] * | ||
524 | (second_after - hw->start_stage + 5); | ||
525 | } | ||
526 | a_param *= WEIGHT_FACTOR; | ||
527 | 481 | ||
528 | b_param = ad714x->sensor_val[second_before] + | 482 | a_param = ad714x->sensor_val[highest] * |
483 | (highest - hw->start_stage) + | ||
484 | ad714x->sensor_val[first_before] * | ||
485 | (highest - hw->start_stage - 1) + | ||
486 | ad714x->sensor_val[first_after] * | ||
487 | (highest - hw->start_stage + 1); | ||
488 | b_param = ad714x->sensor_val[highest] + | ||
529 | ad714x->sensor_val[first_before] + | 489 | ad714x->sensor_val[first_before] + |
530 | ad714x->sensor_val[highest] + | 490 | ad714x->sensor_val[first_after]; |
531 | ad714x->sensor_val[first_after] + | 491 | |
532 | ad714x->sensor_val[second_after]; | 492 | sw->abs_pos = ((hw->max_coord / (hw->end_stage - hw->start_stage)) * |
533 | 493 | a_param) / b_param; | |
534 | sw->pre_mean_value = sw->mean_value; | 494 | |
535 | sw->mean_value = a_param / b_param; | ||
536 | |||
537 | /* Calculate the offset */ | ||
538 | |||
539 | if ((sw->pre_highest_stage == hw->end_stage) && | ||
540 | (sw->highest_stage == hw->start_stage)) | ||
541 | sw->pos_offset = sw->mean_value; | ||
542 | else if ((sw->pre_highest_stage == hw->start_stage) && | ||
543 | (sw->highest_stage == hw->end_stage)) | ||
544 | sw->pos_offset = sw->pre_mean_value; | ||
545 | |||
546 | if (sw->pos_offset > OFFSET_POSITION_CLAMP) | ||
547 | sw->pos_offset = OFFSET_POSITION_CLAMP; | ||
548 | |||
549 | /* Calculate the mean value without the offset */ | ||
550 | |||
551 | sw->pre_mean_value_no_offset = sw->mean_value_no_offset; | ||
552 | sw->mean_value_no_offset = sw->mean_value - sw->pos_offset; | ||
553 | if (sw->mean_value_no_offset < 0) | ||
554 | sw->mean_value_no_offset = 0; | ||
555 | |||
556 | /* Calculate ratio to scale down to NUMBER_OF_WANTED_POSITIONS */ | ||
557 | |||
558 | if ((sw->pre_highest_stage == hw->end_stage) && | ||
559 | (sw->highest_stage == hw->start_stage)) | ||
560 | sw->pos_ratio = (sw->pre_mean_value_no_offset * 100) / | ||
561 | hw->max_coord; | ||
562 | else if ((sw->pre_highest_stage == hw->start_stage) && | ||
563 | (sw->highest_stage == hw->end_stage)) | ||
564 | sw->pos_ratio = (sw->mean_value_no_offset * 100) / | ||
565 | hw->max_coord; | ||
566 | sw->abs_pos = (sw->mean_value_no_offset * 100) / sw->pos_ratio; | ||
567 | if (sw->abs_pos > hw->max_coord) | 495 | if (sw->abs_pos > hw->max_coord) |
568 | sw->abs_pos = hw->max_coord; | 496 | sw->abs_pos = hw->max_coord; |
497 | else if (sw->abs_pos < 0) | ||
498 | sw->abs_pos = 0; | ||
569 | } | 499 | } |
570 | 500 | ||
571 | static void ad714x_wheel_cal_flt_pos(struct ad714x_chip *ad714x, int idx) | 501 | static void ad714x_wheel_cal_flt_pos(struct ad714x_chip *ad714x, int idx) |
@@ -639,9 +569,8 @@ static void ad714x_wheel_state_machine(struct ad714x_chip *ad714x, int idx) | |||
639 | ad714x_wheel_cal_highest_stage(ad714x, idx); | 569 | ad714x_wheel_cal_highest_stage(ad714x, idx); |
640 | ad714x_wheel_cal_abs_pos(ad714x, idx); | 570 | ad714x_wheel_cal_abs_pos(ad714x, idx); |
641 | ad714x_wheel_cal_flt_pos(ad714x, idx); | 571 | ad714x_wheel_cal_flt_pos(ad714x, idx); |
642 | |||
643 | input_report_abs(sw->input, ABS_WHEEL, | 572 | input_report_abs(sw->input, ABS_WHEEL, |
644 | sw->abs_pos); | 573 | sw->flt_pos); |
645 | input_report_key(sw->input, BTN_TOUCH, 1); | 574 | input_report_key(sw->input, BTN_TOUCH, 1); |
646 | } else { | 575 | } else { |
647 | /* When the user lifts off the sensor, configure | 576 | /* When the user lifts off the sensor, configure |
@@ -1149,6 +1078,8 @@ struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq, | |||
1149 | input[alloc_idx]->id.bustype = bus_type; | 1078 | input[alloc_idx]->id.bustype = bus_type; |
1150 | input[alloc_idx]->id.product = ad714x->product; | 1079 | input[alloc_idx]->id.product = ad714x->product; |
1151 | input[alloc_idx]->id.version = ad714x->version; | 1080 | input[alloc_idx]->id.version = ad714x->version; |
1081 | input[alloc_idx]->name = "ad714x_captouch_slider"; | ||
1082 | input[alloc_idx]->dev.parent = dev; | ||
1152 | 1083 | ||
1153 | error = input_register_device(input[alloc_idx]); | 1084 | error = input_register_device(input[alloc_idx]); |
1154 | if (error) | 1085 | if (error) |
@@ -1179,6 +1110,8 @@ struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq, | |||
1179 | input[alloc_idx]->id.bustype = bus_type; | 1110 | input[alloc_idx]->id.bustype = bus_type; |
1180 | input[alloc_idx]->id.product = ad714x->product; | 1111 | input[alloc_idx]->id.product = ad714x->product; |
1181 | input[alloc_idx]->id.version = ad714x->version; | 1112 | input[alloc_idx]->id.version = ad714x->version; |
1113 | input[alloc_idx]->name = "ad714x_captouch_wheel"; | ||
1114 | input[alloc_idx]->dev.parent = dev; | ||
1182 | 1115 | ||
1183 | error = input_register_device(input[alloc_idx]); | 1116 | error = input_register_device(input[alloc_idx]); |
1184 | if (error) | 1117 | if (error) |
@@ -1212,6 +1145,8 @@ struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq, | |||
1212 | input[alloc_idx]->id.bustype = bus_type; | 1145 | input[alloc_idx]->id.bustype = bus_type; |
1213 | input[alloc_idx]->id.product = ad714x->product; | 1146 | input[alloc_idx]->id.product = ad714x->product; |
1214 | input[alloc_idx]->id.version = ad714x->version; | 1147 | input[alloc_idx]->id.version = ad714x->version; |
1148 | input[alloc_idx]->name = "ad714x_captouch_pad"; | ||
1149 | input[alloc_idx]->dev.parent = dev; | ||
1215 | 1150 | ||
1216 | error = input_register_device(input[alloc_idx]); | 1151 | error = input_register_device(input[alloc_idx]); |
1217 | if (error) | 1152 | if (error) |
@@ -1240,6 +1175,8 @@ struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq, | |||
1240 | input[alloc_idx]->id.bustype = bus_type; | 1175 | input[alloc_idx]->id.bustype = bus_type; |
1241 | input[alloc_idx]->id.product = ad714x->product; | 1176 | input[alloc_idx]->id.product = ad714x->product; |
1242 | input[alloc_idx]->id.version = ad714x->version; | 1177 | input[alloc_idx]->id.version = ad714x->version; |
1178 | input[alloc_idx]->name = "ad714x_captouch_button"; | ||
1179 | input[alloc_idx]->dev.parent = dev; | ||
1243 | 1180 | ||
1244 | error = input_register_device(input[alloc_idx]); | 1181 | error = input_register_device(input[alloc_idx]); |
1245 | if (error) | 1182 | if (error) |
@@ -1249,7 +1186,9 @@ struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq, | |||
1249 | } | 1186 | } |
1250 | 1187 | ||
1251 | error = request_threaded_irq(ad714x->irq, NULL, ad714x_interrupt_thread, | 1188 | error = request_threaded_irq(ad714x->irq, NULL, ad714x_interrupt_thread, |
1252 | IRQF_TRIGGER_FALLING, "ad714x_captouch", ad714x); | 1189 | plat_data->irqflags ? |
1190 | plat_data->irqflags : IRQF_TRIGGER_FALLING, | ||
1191 | "ad714x_captouch", ad714x); | ||
1253 | if (error) { | 1192 | if (error) { |
1254 | dev_err(dev, "can't allocate irq %d\n", ad714x->irq); | 1193 | dev_err(dev, "can't allocate irq %d\n", ad714x->irq); |
1255 | goto err_unreg_dev; | 1194 | goto err_unreg_dev; |
diff --git a/drivers/input/misc/adxl34x.c b/drivers/input/misc/adxl34x.c index de5900d50788..144ddbdeb9b3 100644 --- a/drivers/input/misc/adxl34x.c +++ b/drivers/input/misc/adxl34x.c | |||
@@ -716,7 +716,7 @@ struct adxl34x *adxl34x_probe(struct device *dev, int irq, | |||
716 | pdata = dev->platform_data; | 716 | pdata = dev->platform_data; |
717 | if (!pdata) { | 717 | if (!pdata) { |
718 | dev_dbg(dev, | 718 | dev_dbg(dev, |
719 | "No platfrom data: Using default initialization\n"); | 719 | "No platform data: Using default initialization\n"); |
720 | pdata = &adxl34x_default_init; | 720 | pdata = &adxl34x_default_init; |
721 | } | 721 | } |
722 | 722 | ||
diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c index 9ccdb82d869a..1de58e8a1b71 100644 --- a/drivers/input/misc/ati_remote2.c +++ b/drivers/input/misc/ati_remote2.c | |||
@@ -737,14 +737,17 @@ static ssize_t ati_remote2_store_channel_mask(struct device *dev, | |||
737 | 737 | ||
738 | mutex_lock(&ati_remote2_mutex); | 738 | mutex_lock(&ati_remote2_mutex); |
739 | 739 | ||
740 | if (mask != ar2->channel_mask && !ati_remote2_setup(ar2, mask)) | 740 | if (mask != ar2->channel_mask) { |
741 | ar2->channel_mask = mask; | 741 | r = ati_remote2_setup(ar2, mask); |
742 | if (!r) | ||
743 | ar2->channel_mask = mask; | ||
744 | } | ||
742 | 745 | ||
743 | mutex_unlock(&ati_remote2_mutex); | 746 | mutex_unlock(&ati_remote2_mutex); |
744 | 747 | ||
745 | usb_autopm_put_interface(ar2->intf[0]); | 748 | usb_autopm_put_interface(ar2->intf[0]); |
746 | 749 | ||
747 | return count; | 750 | return r ? r : count; |
748 | } | 751 | } |
749 | 752 | ||
750 | static ssize_t ati_remote2_show_mode_mask(struct device *dev, | 753 | static ssize_t ati_remote2_show_mode_mask(struct device *dev, |
diff --git a/drivers/input/misc/ixp4xx-beeper.c b/drivers/input/misc/ixp4xx-beeper.c index 9dfd6e5f786f..1f38302a5951 100644 --- a/drivers/input/misc/ixp4xx-beeper.c +++ b/drivers/input/misc/ixp4xx-beeper.c | |||
@@ -69,11 +69,7 @@ static int ixp4xx_spkr_event(struct input_dev *dev, unsigned int type, unsigned | |||
69 | } | 69 | } |
70 | 70 | ||
71 | if (value > 20 && value < 32767) | 71 | if (value > 20 && value < 32767) |
72 | #ifndef FREQ | 72 | count = (IXP4XX_TIMER_FREQ / (value * 4)) - 1; |
73 | count = (ixp4xx_get_board_tick_rate() / (value * 4)) - 1; | ||
74 | #else | ||
75 | count = (FREQ / (value * 4)) - 1; | ||
76 | #endif | ||
77 | 73 | ||
78 | ixp4xx_spkr_control(pin, count); | 74 | ixp4xx_spkr_control(pin, count); |
79 | 75 | ||
diff --git a/drivers/input/misc/keyspan_remote.c b/drivers/input/misc/keyspan_remote.c index a93c525475c6..fc62256c963f 100644 --- a/drivers/input/misc/keyspan_remote.c +++ b/drivers/input/misc/keyspan_remote.c | |||
@@ -312,7 +312,7 @@ static void keyspan_check_data(struct usb_keyspan *remote) | |||
312 | remote->data.tester = remote->data.tester >> 5; | 312 | remote->data.tester = remote->data.tester >> 5; |
313 | remote->data.bits_left -= 5; | 313 | remote->data.bits_left -= 5; |
314 | } else { | 314 | } else { |
315 | err("Bad message recieved, no stop bit found.\n"); | 315 | err("Bad message received, no stop bit found.\n"); |
316 | } | 316 | } |
317 | 317 | ||
318 | dev_dbg(&remote->udev->dev, | 318 | dev_dbg(&remote->udev->dev, |
diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c index 7e64d01da2be..2c8b84dd9dac 100644 --- a/drivers/input/misc/rotary_encoder.c +++ b/drivers/input/misc/rotary_encoder.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * rotary_encoder.c | 2 | * rotary_encoder.c |
3 | * | 3 | * |
4 | * (c) 2009 Daniel Mack <daniel@caiaq.de> | 4 | * (c) 2009 Daniel Mack <daniel@caiaq.de> |
5 | * Copyright (C) 2011 Johan Hovold <jhovold@gmail.com> | ||
5 | * | 6 | * |
6 | * state machine code inspired by code from Tim Ruetz | 7 | * state machine code inspired by code from Tim Ruetz |
7 | * | 8 | * |
@@ -38,52 +39,66 @@ struct rotary_encoder { | |||
38 | 39 | ||
39 | bool armed; | 40 | bool armed; |
40 | unsigned char dir; /* 0 - clockwise, 1 - CCW */ | 41 | unsigned char dir; /* 0 - clockwise, 1 - CCW */ |
42 | |||
43 | char last_stable; | ||
41 | }; | 44 | }; |
42 | 45 | ||
43 | static irqreturn_t rotary_encoder_irq(int irq, void *dev_id) | 46 | static int rotary_encoder_get_state(struct rotary_encoder_platform_data *pdata) |
44 | { | 47 | { |
45 | struct rotary_encoder *encoder = dev_id; | ||
46 | struct rotary_encoder_platform_data *pdata = encoder->pdata; | ||
47 | int a = !!gpio_get_value(pdata->gpio_a); | 48 | int a = !!gpio_get_value(pdata->gpio_a); |
48 | int b = !!gpio_get_value(pdata->gpio_b); | 49 | int b = !!gpio_get_value(pdata->gpio_b); |
49 | int state; | ||
50 | 50 | ||
51 | a ^= pdata->inverted_a; | 51 | a ^= pdata->inverted_a; |
52 | b ^= pdata->inverted_b; | 52 | b ^= pdata->inverted_b; |
53 | state = (a << 1) | b; | ||
54 | 53 | ||
55 | switch (state) { | 54 | return ((a << 1) | b); |
55 | } | ||
56 | 56 | ||
57 | case 0x0: | 57 | static void rotary_encoder_report_event(struct rotary_encoder *encoder) |
58 | if (!encoder->armed) | 58 | { |
59 | break; | 59 | struct rotary_encoder_platform_data *pdata = encoder->pdata; |
60 | 60 | ||
61 | if (pdata->relative_axis) { | 61 | if (pdata->relative_axis) { |
62 | input_report_rel(encoder->input, pdata->axis, | 62 | input_report_rel(encoder->input, |
63 | encoder->dir ? -1 : 1); | 63 | pdata->axis, encoder->dir ? -1 : 1); |
64 | } else { | 64 | } else { |
65 | unsigned int pos = encoder->pos; | 65 | unsigned int pos = encoder->pos; |
66 | 66 | ||
67 | if (encoder->dir) { | 67 | if (encoder->dir) { |
68 | /* turning counter-clockwise */ | 68 | /* turning counter-clockwise */ |
69 | if (pdata->rollover) | ||
70 | pos += pdata->steps; | ||
71 | if (pos) | ||
72 | pos--; | ||
73 | } else { | ||
74 | /* turning clockwise */ | ||
75 | if (pdata->rollover || pos < pdata->steps) | ||
76 | pos++; | ||
77 | } | ||
78 | if (pdata->rollover) | 69 | if (pdata->rollover) |
79 | pos %= pdata->steps; | 70 | pos += pdata->steps; |
80 | encoder->pos = pos; | 71 | if (pos) |
81 | input_report_abs(encoder->input, pdata->axis, | 72 | pos--; |
82 | encoder->pos); | 73 | } else { |
74 | /* turning clockwise */ | ||
75 | if (pdata->rollover || pos < pdata->steps) | ||
76 | pos++; | ||
83 | } | 77 | } |
84 | input_sync(encoder->input); | ||
85 | 78 | ||
86 | encoder->armed = false; | 79 | if (pdata->rollover) |
80 | pos %= pdata->steps; | ||
81 | |||
82 | encoder->pos = pos; | ||
83 | input_report_abs(encoder->input, pdata->axis, encoder->pos); | ||
84 | } | ||
85 | |||
86 | input_sync(encoder->input); | ||
87 | } | ||
88 | |||
89 | static irqreturn_t rotary_encoder_irq(int irq, void *dev_id) | ||
90 | { | ||
91 | struct rotary_encoder *encoder = dev_id; | ||
92 | int state; | ||
93 | |||
94 | state = rotary_encoder_get_state(encoder->pdata); | ||
95 | |||
96 | switch (state) { | ||
97 | case 0x0: | ||
98 | if (encoder->armed) { | ||
99 | rotary_encoder_report_event(encoder); | ||
100 | encoder->armed = false; | ||
101 | } | ||
87 | break; | 102 | break; |
88 | 103 | ||
89 | case 0x1: | 104 | case 0x1: |
@@ -100,11 +115,37 @@ static irqreturn_t rotary_encoder_irq(int irq, void *dev_id) | |||
100 | return IRQ_HANDLED; | 115 | return IRQ_HANDLED; |
101 | } | 116 | } |
102 | 117 | ||
118 | static irqreturn_t rotary_encoder_half_period_irq(int irq, void *dev_id) | ||
119 | { | ||
120 | struct rotary_encoder *encoder = dev_id; | ||
121 | int state; | ||
122 | |||
123 | state = rotary_encoder_get_state(encoder->pdata); | ||
124 | |||
125 | switch (state) { | ||
126 | case 0x00: | ||
127 | case 0x03: | ||
128 | if (state != encoder->last_stable) { | ||
129 | rotary_encoder_report_event(encoder); | ||
130 | encoder->last_stable = state; | ||
131 | } | ||
132 | break; | ||
133 | |||
134 | case 0x01: | ||
135 | case 0x02: | ||
136 | encoder->dir = (encoder->last_stable + state) & 0x01; | ||
137 | break; | ||
138 | } | ||
139 | |||
140 | return IRQ_HANDLED; | ||
141 | } | ||
142 | |||
103 | static int __devinit rotary_encoder_probe(struct platform_device *pdev) | 143 | static int __devinit rotary_encoder_probe(struct platform_device *pdev) |
104 | { | 144 | { |
105 | struct rotary_encoder_platform_data *pdata = pdev->dev.platform_data; | 145 | struct rotary_encoder_platform_data *pdata = pdev->dev.platform_data; |
106 | struct rotary_encoder *encoder; | 146 | struct rotary_encoder *encoder; |
107 | struct input_dev *input; | 147 | struct input_dev *input; |
148 | irq_handler_t handler; | ||
108 | int err; | 149 | int err; |
109 | 150 | ||
110 | if (!pdata) { | 151 | if (!pdata) { |
@@ -175,7 +216,14 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev) | |||
175 | } | 216 | } |
176 | 217 | ||
177 | /* request the IRQs */ | 218 | /* request the IRQs */ |
178 | err = request_irq(encoder->irq_a, &rotary_encoder_irq, | 219 | if (pdata->half_period) { |
220 | handler = &rotary_encoder_half_period_irq; | ||
221 | encoder->last_stable = rotary_encoder_get_state(pdata); | ||
222 | } else { | ||
223 | handler = &rotary_encoder_irq; | ||
224 | } | ||
225 | |||
226 | err = request_irq(encoder->irq_a, handler, | ||
179 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | 227 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
180 | DRV_NAME, encoder); | 228 | DRV_NAME, encoder); |
181 | if (err) { | 229 | if (err) { |
@@ -184,7 +232,7 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev) | |||
184 | goto exit_free_gpio_b; | 232 | goto exit_free_gpio_b; |
185 | } | 233 | } |
186 | 234 | ||
187 | err = request_irq(encoder->irq_b, &rotary_encoder_irq, | 235 | err = request_irq(encoder->irq_b, handler, |
188 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | 236 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
189 | DRV_NAME, encoder); | 237 | DRV_NAME, encoder); |
190 | if (err) { | 238 | if (err) { |
@@ -252,6 +300,5 @@ module_exit(rotary_encoder_exit); | |||
252 | 300 | ||
253 | MODULE_ALIAS("platform:" DRV_NAME); | 301 | MODULE_ALIAS("platform:" DRV_NAME); |
254 | MODULE_DESCRIPTION("GPIO rotary encoder driver"); | 302 | MODULE_DESCRIPTION("GPIO rotary encoder driver"); |
255 | MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); | 303 | MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>, Johan Hovold"); |
256 | MODULE_LICENSE("GPL v2"); | 304 | MODULE_LICENSE("GPL v2"); |
257 | |||
diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c index 8e130bf7d32b..0122f5351577 100644 --- a/drivers/input/misc/sparcspkr.c +++ b/drivers/input/misc/sparcspkr.c | |||
@@ -173,18 +173,16 @@ static int __devinit sparcspkr_probe(struct device *dev) | |||
173 | return 0; | 173 | return 0; |
174 | } | 174 | } |
175 | 175 | ||
176 | static int sparcspkr_shutdown(struct platform_device *dev) | 176 | static void sparcspkr_shutdown(struct platform_device *dev) |
177 | { | 177 | { |
178 | struct sparcspkr_state *state = dev_get_drvdata(&dev->dev); | 178 | struct sparcspkr_state *state = dev_get_drvdata(&dev->dev); |
179 | struct input_dev *input_dev = state->input_dev; | 179 | struct input_dev *input_dev = state->input_dev; |
180 | 180 | ||
181 | /* turn off the speaker */ | 181 | /* turn off the speaker */ |
182 | state->event(input_dev, EV_SND, SND_BELL, 0); | 182 | state->event(input_dev, EV_SND, SND_BELL, 0); |
183 | |||
184 | return 0; | ||
185 | } | 183 | } |
186 | 184 | ||
187 | static int __devinit bbc_beep_probe(struct platform_device *op, const struct of_device_id *match) | 185 | static int __devinit bbc_beep_probe(struct platform_device *op) |
188 | { | 186 | { |
189 | struct sparcspkr_state *state; | 187 | struct sparcspkr_state *state; |
190 | struct bbc_beep_info *info; | 188 | struct bbc_beep_info *info; |
@@ -258,7 +256,7 @@ static const struct of_device_id bbc_beep_match[] = { | |||
258 | {}, | 256 | {}, |
259 | }; | 257 | }; |
260 | 258 | ||
261 | static struct of_platform_driver bbc_beep_driver = { | 259 | static struct platform_driver bbc_beep_driver = { |
262 | .driver = { | 260 | .driver = { |
263 | .name = "bbcbeep", | 261 | .name = "bbcbeep", |
264 | .owner = THIS_MODULE, | 262 | .owner = THIS_MODULE, |
@@ -269,7 +267,7 @@ static struct of_platform_driver bbc_beep_driver = { | |||
269 | .shutdown = sparcspkr_shutdown, | 267 | .shutdown = sparcspkr_shutdown, |
270 | }; | 268 | }; |
271 | 269 | ||
272 | static int __devinit grover_beep_probe(struct platform_device *op, const struct of_device_id *match) | 270 | static int __devinit grover_beep_probe(struct platform_device *op) |
273 | { | 271 | { |
274 | struct sparcspkr_state *state; | 272 | struct sparcspkr_state *state; |
275 | struct grover_beep_info *info; | 273 | struct grover_beep_info *info; |
@@ -340,7 +338,7 @@ static const struct of_device_id grover_beep_match[] = { | |||
340 | {}, | 338 | {}, |
341 | }; | 339 | }; |
342 | 340 | ||
343 | static struct of_platform_driver grover_beep_driver = { | 341 | static struct platform_driver grover_beep_driver = { |
344 | .driver = { | 342 | .driver = { |
345 | .name = "groverbeep", | 343 | .name = "groverbeep", |
346 | .owner = THIS_MODULE, | 344 | .owner = THIS_MODULE, |
@@ -353,12 +351,12 @@ static struct of_platform_driver grover_beep_driver = { | |||
353 | 351 | ||
354 | static int __init sparcspkr_init(void) | 352 | static int __init sparcspkr_init(void) |
355 | { | 353 | { |
356 | int err = of_register_platform_driver(&bbc_beep_driver); | 354 | int err = platform_driver_register(&bbc_beep_driver); |
357 | 355 | ||
358 | if (!err) { | 356 | if (!err) { |
359 | err = of_register_platform_driver(&grover_beep_driver); | 357 | err = platform_driver_register(&grover_beep_driver); |
360 | if (err) | 358 | if (err) |
361 | of_unregister_platform_driver(&bbc_beep_driver); | 359 | platform_driver_unregister(&bbc_beep_driver); |
362 | } | 360 | } |
363 | 361 | ||
364 | return err; | 362 | return err; |
@@ -366,8 +364,8 @@ static int __init sparcspkr_init(void) | |||
366 | 364 | ||
367 | static void __exit sparcspkr_exit(void) | 365 | static void __exit sparcspkr_exit(void) |
368 | { | 366 | { |
369 | of_unregister_platform_driver(&bbc_beep_driver); | 367 | platform_driver_unregister(&bbc_beep_driver); |
370 | of_unregister_platform_driver(&grover_beep_driver); | 368 | platform_driver_unregister(&grover_beep_driver); |
371 | } | 369 | } |
372 | 370 | ||
373 | module_init(sparcspkr_init); | 371 | module_init(sparcspkr_init); |
diff --git a/drivers/input/misc/twl4030-pwrbutton.c b/drivers/input/misc/twl4030-pwrbutton.c index f16972bddca4..38e4b507b94c 100644 --- a/drivers/input/misc/twl4030-pwrbutton.c +++ b/drivers/input/misc/twl4030-pwrbutton.c | |||
@@ -89,7 +89,7 @@ static int __init twl4030_pwrbutton_probe(struct platform_device *pdev) | |||
89 | return 0; | 89 | return 0; |
90 | 90 | ||
91 | free_irq: | 91 | free_irq: |
92 | free_irq(irq, NULL); | 92 | free_irq(irq, pwr); |
93 | free_input_dev: | 93 | free_input_dev: |
94 | input_free_device(pwr); | 94 | input_free_device(pwr); |
95 | return err; | 95 | return err; |
diff --git a/drivers/input/misc/twl4030-vibra.c b/drivers/input/misc/twl4030-vibra.c index 014dd4ad0d4f..6a11694e3fc7 100644 --- a/drivers/input/misc/twl4030-vibra.c +++ b/drivers/input/misc/twl4030-vibra.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/workqueue.h> | 29 | #include <linux/workqueue.h> |
30 | #include <linux/i2c/twl.h> | 30 | #include <linux/i2c/twl.h> |
31 | #include <linux/mfd/twl4030-codec.h> | 31 | #include <linux/mfd/twl4030-codec.h> |
32 | #include <linux/mfd/core.h> | ||
32 | #include <linux/input.h> | 33 | #include <linux/input.h> |
33 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
34 | 35 | ||
@@ -196,7 +197,7 @@ static SIMPLE_DEV_PM_OPS(twl4030_vibra_pm_ops, | |||
196 | 197 | ||
197 | static int __devinit twl4030_vibra_probe(struct platform_device *pdev) | 198 | static int __devinit twl4030_vibra_probe(struct platform_device *pdev) |
198 | { | 199 | { |
199 | struct twl4030_codec_vibra_data *pdata = pdev->dev.platform_data; | 200 | struct twl4030_codec_vibra_data *pdata = mfd_get_data(pdev); |
200 | struct vibra_info *info; | 201 | struct vibra_info *info; |
201 | int ret; | 202 | int ret; |
202 | 203 | ||
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c index 12501de0c5cd..52b419348983 100644 --- a/drivers/input/misc/wistron_btns.c +++ b/drivers/input/misc/wistron_btns.c | |||
@@ -274,7 +274,7 @@ static struct key_entry keymap_fs_amilo_pro_v3505[] __initdata = { | |||
274 | { KE_BLUETOOTH, 0x30 }, /* Fn+F10 */ | 274 | { KE_BLUETOOTH, 0x30 }, /* Fn+F10 */ |
275 | { KE_KEY, 0x31, {KEY_MAIL} }, /* mail button */ | 275 | { KE_KEY, 0x31, {KEY_MAIL} }, /* mail button */ |
276 | { KE_KEY, 0x36, {KEY_WWW} }, /* www button */ | 276 | { KE_KEY, 0x36, {KEY_WWW} }, /* www button */ |
277 | { KE_WIFI, 0x78 }, /* satelite dish button */ | 277 | { KE_WIFI, 0x78 }, /* satellite dish button */ |
278 | { KE_END, 0 } | 278 | { KE_END, 0 } |
279 | }; | 279 | }; |
280 | 280 | ||
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c index 3aead91bacc8..3126983c004a 100644 --- a/drivers/input/mouse/bcm5974.c +++ b/drivers/input/mouse/bcm5974.c | |||
@@ -639,7 +639,7 @@ exit: | |||
639 | * device, resulting in trackpad malfunction under certain | 639 | * device, resulting in trackpad malfunction under certain |
640 | * circumstances. To get around this problem, there is at least one | 640 | * circumstances. To get around this problem, there is at least one |
641 | * example that utilizes the USB_QUIRK_RESET_RESUME quirk in order to | 641 | * example that utilizes the USB_QUIRK_RESET_RESUME quirk in order to |
642 | * recieve a reset_resume request rather than the normal resume. | 642 | * receive a reset_resume request rather than the normal resume. |
643 | * Since the implementation of reset_resume is equal to mode switch | 643 | * Since the implementation of reset_resume is equal to mode switch |
644 | * plus start_traffic, it seems easier to always do the switch when | 644 | * plus start_traffic, it seems easier to always do the switch when |
645 | * starting traffic on the device. | 645 | * starting traffic on the device. |
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index 04d9bf320a4f..32503565faf9 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/input.h> | 18 | #include <linux/input.h> |
19 | #include <linux/input/mt.h> | ||
19 | #include <linux/serio.h> | 20 | #include <linux/serio.h> |
20 | #include <linux/libps2.h> | 21 | #include <linux/libps2.h> |
21 | #include "psmouse.h" | 22 | #include "psmouse.h" |
@@ -242,15 +243,37 @@ static void elantech_report_absolute_v1(struct psmouse *psmouse) | |||
242 | input_sync(dev); | 243 | input_sync(dev); |
243 | } | 244 | } |
244 | 245 | ||
246 | static void elantech_set_slot(struct input_dev *dev, int slot, bool active, | ||
247 | unsigned int x, unsigned int y) | ||
248 | { | ||
249 | input_mt_slot(dev, slot); | ||
250 | input_mt_report_slot_state(dev, MT_TOOL_FINGER, active); | ||
251 | if (active) { | ||
252 | input_report_abs(dev, ABS_MT_POSITION_X, x); | ||
253 | input_report_abs(dev, ABS_MT_POSITION_Y, y); | ||
254 | } | ||
255 | } | ||
256 | |||
257 | /* x1 < x2 and y1 < y2 when two fingers, x = y = 0 when not pressed */ | ||
258 | static void elantech_report_semi_mt_data(struct input_dev *dev, | ||
259 | unsigned int num_fingers, | ||
260 | unsigned int x1, unsigned int y1, | ||
261 | unsigned int x2, unsigned int y2) | ||
262 | { | ||
263 | elantech_set_slot(dev, 0, num_fingers != 0, x1, y1); | ||
264 | elantech_set_slot(dev, 1, num_fingers == 2, x2, y2); | ||
265 | } | ||
266 | |||
245 | /* | 267 | /* |
246 | * Interpret complete data packets and report absolute mode input events for | 268 | * Interpret complete data packets and report absolute mode input events for |
247 | * hardware version 2. (6 byte packets) | 269 | * hardware version 2. (6 byte packets) |
248 | */ | 270 | */ |
249 | static void elantech_report_absolute_v2(struct psmouse *psmouse) | 271 | static void elantech_report_absolute_v2(struct psmouse *psmouse) |
250 | { | 272 | { |
273 | struct elantech_data *etd = psmouse->private; | ||
251 | struct input_dev *dev = psmouse->dev; | 274 | struct input_dev *dev = psmouse->dev; |
252 | unsigned char *packet = psmouse->packet; | 275 | unsigned char *packet = psmouse->packet; |
253 | int fingers, x1, y1, x2, y2; | 276 | unsigned int fingers, x1 = 0, y1 = 0, x2 = 0, y2 = 0, width = 0, pres = 0; |
254 | 277 | ||
255 | /* byte 0: n1 n0 . . . . R L */ | 278 | /* byte 0: n1 n0 . . . . R L */ |
256 | fingers = (packet[0] & 0xc0) >> 6; | 279 | fingers = (packet[0] & 0xc0) >> 6; |
@@ -270,14 +293,18 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse) | |||
270 | * byte 1: . . . . . x10 x9 x8 | 293 | * byte 1: . . . . . x10 x9 x8 |
271 | * byte 2: x7 x6 x5 x4 x4 x2 x1 x0 | 294 | * byte 2: x7 x6 x5 x4 x4 x2 x1 x0 |
272 | */ | 295 | */ |
273 | input_report_abs(dev, ABS_X, | 296 | x1 = ((packet[1] & 0x07) << 8) | packet[2]; |
274 | ((packet[1] & 0x07) << 8) | packet[2]); | ||
275 | /* | 297 | /* |
276 | * byte 4: . . . . . . y9 y8 | 298 | * byte 4: . . . . . . y9 y8 |
277 | * byte 5: y7 y6 y5 y4 y3 y2 y1 y0 | 299 | * byte 5: y7 y6 y5 y4 y3 y2 y1 y0 |
278 | */ | 300 | */ |
279 | input_report_abs(dev, ABS_Y, | 301 | y1 = ETP_YMAX_V2 - (((packet[4] & 0x03) << 8) | packet[5]); |
280 | ETP_YMAX_V2 - (((packet[4] & 0x03) << 8) | packet[5])); | 302 | |
303 | input_report_abs(dev, ABS_X, x1); | ||
304 | input_report_abs(dev, ABS_Y, y1); | ||
305 | |||
306 | pres = (packet[1] & 0xf0) | ((packet[4] & 0xf0) >> 4); | ||
307 | width = ((packet[0] & 0x30) >> 2) | ((packet[3] & 0x30) >> 4); | ||
281 | break; | 308 | break; |
282 | 309 | ||
283 | case 2: | 310 | case 2: |
@@ -303,23 +330,24 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse) | |||
303 | */ | 330 | */ |
304 | input_report_abs(dev, ABS_X, x1 << 2); | 331 | input_report_abs(dev, ABS_X, x1 << 2); |
305 | input_report_abs(dev, ABS_Y, y1 << 2); | 332 | input_report_abs(dev, ABS_Y, y1 << 2); |
306 | /* | 333 | |
307 | * For compatibility with the proprietary X Elantech driver | 334 | /* Unknown so just report sensible values */ |
308 | * report both coordinates as hat coordinates | 335 | pres = 127; |
309 | */ | 336 | width = 7; |
310 | input_report_abs(dev, ABS_HAT0X, x1); | ||
311 | input_report_abs(dev, ABS_HAT0Y, y1); | ||
312 | input_report_abs(dev, ABS_HAT1X, x2); | ||
313 | input_report_abs(dev, ABS_HAT1Y, y2); | ||
314 | break; | 337 | break; |
315 | } | 338 | } |
316 | 339 | ||
340 | elantech_report_semi_mt_data(dev, fingers, x1, y1, x2, y2); | ||
317 | input_report_key(dev, BTN_TOOL_FINGER, fingers == 1); | 341 | input_report_key(dev, BTN_TOOL_FINGER, fingers == 1); |
318 | input_report_key(dev, BTN_TOOL_DOUBLETAP, fingers == 2); | 342 | input_report_key(dev, BTN_TOOL_DOUBLETAP, fingers == 2); |
319 | input_report_key(dev, BTN_TOOL_TRIPLETAP, fingers == 3); | 343 | input_report_key(dev, BTN_TOOL_TRIPLETAP, fingers == 3); |
320 | input_report_key(dev, BTN_TOOL_QUADTAP, fingers == 4); | 344 | input_report_key(dev, BTN_TOOL_QUADTAP, fingers == 4); |
321 | input_report_key(dev, BTN_LEFT, packet[0] & 0x01); | 345 | input_report_key(dev, BTN_LEFT, packet[0] & 0x01); |
322 | input_report_key(dev, BTN_RIGHT, packet[0] & 0x02); | 346 | input_report_key(dev, BTN_RIGHT, packet[0] & 0x02); |
347 | if (etd->reports_pressure) { | ||
348 | input_report_abs(dev, ABS_PRESSURE, pres); | ||
349 | input_report_abs(dev, ABS_TOOL_WIDTH, width); | ||
350 | } | ||
323 | 351 | ||
324 | input_sync(dev); | 352 | input_sync(dev); |
325 | } | 353 | } |
@@ -478,10 +506,16 @@ static void elantech_set_input_params(struct psmouse *psmouse) | |||
478 | __set_bit(BTN_TOOL_QUADTAP, dev->keybit); | 506 | __set_bit(BTN_TOOL_QUADTAP, dev->keybit); |
479 | input_set_abs_params(dev, ABS_X, ETP_XMIN_V2, ETP_XMAX_V2, 0, 0); | 507 | input_set_abs_params(dev, ABS_X, ETP_XMIN_V2, ETP_XMAX_V2, 0, 0); |
480 | input_set_abs_params(dev, ABS_Y, ETP_YMIN_V2, ETP_YMAX_V2, 0, 0); | 508 | input_set_abs_params(dev, ABS_Y, ETP_YMIN_V2, ETP_YMAX_V2, 0, 0); |
481 | input_set_abs_params(dev, ABS_HAT0X, ETP_2FT_XMIN, ETP_2FT_XMAX, 0, 0); | 509 | if (etd->reports_pressure) { |
482 | input_set_abs_params(dev, ABS_HAT0Y, ETP_2FT_YMIN, ETP_2FT_YMAX, 0, 0); | 510 | input_set_abs_params(dev, ABS_PRESSURE, ETP_PMIN_V2, |
483 | input_set_abs_params(dev, ABS_HAT1X, ETP_2FT_XMIN, ETP_2FT_XMAX, 0, 0); | 511 | ETP_PMAX_V2, 0, 0); |
484 | input_set_abs_params(dev, ABS_HAT1Y, ETP_2FT_YMIN, ETP_2FT_YMAX, 0, 0); | 512 | input_set_abs_params(dev, ABS_TOOL_WIDTH, ETP_WMIN_V2, |
513 | ETP_WMAX_V2, 0, 0); | ||
514 | } | ||
515 | __set_bit(INPUT_PROP_SEMI_MT, dev->propbit); | ||
516 | input_mt_init_slots(dev, 2); | ||
517 | input_set_abs_params(dev, ABS_MT_POSITION_X, ETP_XMIN_V2, ETP_XMAX_V2, 0, 0); | ||
518 | input_set_abs_params(dev, ABS_MT_POSITION_Y, ETP_YMIN_V2, ETP_YMAX_V2, 0, 0); | ||
485 | break; | 519 | break; |
486 | } | 520 | } |
487 | } | 521 | } |
@@ -725,6 +759,10 @@ int elantech_init(struct psmouse *psmouse) | |||
725 | etd->debug = 1; | 759 | etd->debug = 1; |
726 | /* Don't know how to do parity checking for version 2 */ | 760 | /* Don't know how to do parity checking for version 2 */ |
727 | etd->paritycheck = 0; | 761 | etd->paritycheck = 0; |
762 | |||
763 | if (etd->fw_version >= 0x020800) | ||
764 | etd->reports_pressure = true; | ||
765 | |||
728 | } else { | 766 | } else { |
729 | etd->hw_version = 1; | 767 | etd->hw_version = 1; |
730 | etd->paritycheck = 1; | 768 | etd->paritycheck = 1; |
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h index aa4aac5d2198..fabb2b99615c 100644 --- a/drivers/input/mouse/elantech.h +++ b/drivers/input/mouse/elantech.h | |||
@@ -77,6 +77,11 @@ | |||
77 | #define ETP_YMIN_V2 ( 0 + ETP_EDGE_FUZZ_V2) | 77 | #define ETP_YMIN_V2 ( 0 + ETP_EDGE_FUZZ_V2) |
78 | #define ETP_YMAX_V2 ( 768 - ETP_EDGE_FUZZ_V2) | 78 | #define ETP_YMAX_V2 ( 768 - ETP_EDGE_FUZZ_V2) |
79 | 79 | ||
80 | #define ETP_PMIN_V2 0 | ||
81 | #define ETP_PMAX_V2 255 | ||
82 | #define ETP_WMIN_V2 0 | ||
83 | #define ETP_WMAX_V2 15 | ||
84 | |||
80 | /* | 85 | /* |
81 | * For two finger touches the coordinate of each finger gets reported | 86 | * For two finger touches the coordinate of each finger gets reported |
82 | * separately but with reduced resolution. | 87 | * separately but with reduced resolution. |
@@ -102,6 +107,7 @@ struct elantech_data { | |||
102 | unsigned char capabilities; | 107 | unsigned char capabilities; |
103 | bool paritycheck; | 108 | bool paritycheck; |
104 | bool jumpy_cursor; | 109 | bool jumpy_cursor; |
110 | bool reports_pressure; | ||
105 | unsigned char hw_version; | 111 | unsigned char hw_version; |
106 | unsigned int fw_version; | 112 | unsigned int fw_version; |
107 | unsigned int single_finger_reports; | 113 | unsigned int single_finger_reports; |
diff --git a/drivers/input/mouse/synaptics_i2c.c b/drivers/input/mouse/synaptics_i2c.c index f6aa26d305ed..cba3c84d2f21 100644 --- a/drivers/input/mouse/synaptics_i2c.c +++ b/drivers/input/mouse/synaptics_i2c.c | |||
@@ -462,7 +462,7 @@ static void synaptics_i2c_work_handler(struct work_struct *work) | |||
462 | * While interrupt driven, there is no real need to poll the device. | 462 | * While interrupt driven, there is no real need to poll the device. |
463 | * But touchpads are very sensitive, so there could be errors | 463 | * But touchpads are very sensitive, so there could be errors |
464 | * related to physical environment and the attention line isn't | 464 | * related to physical environment and the attention line isn't |
465 | * neccesarily asserted. In such case we can lose the touchpad. | 465 | * necessarily asserted. In such case we can lose the touchpad. |
466 | * We poll the device once in THREAD_IRQ_SLEEP_SECS and | 466 | * We poll the device once in THREAD_IRQ_SLEEP_SECS and |
467 | * if error is detected, we try to reset and reconfigure the touchpad. | 467 | * if error is detected, we try to reset and reconfigure the touchpad. |
468 | */ | 468 | */ |
diff --git a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c index bf2c0c80d6cc..eb9a3cfbeefa 100644 --- a/drivers/input/mouse/vsxxxaa.c +++ b/drivers/input/mouse/vsxxxaa.c | |||
@@ -334,7 +334,7 @@ static void vsxxxaa_handle_POR_packet(struct vsxxxaa *mouse) | |||
334 | * M: manufacturer location code | 334 | * M: manufacturer location code |
335 | * R: revision code | 335 | * R: revision code |
336 | * E: Error code. If it's in the range of 0x00..0x1f, only some | 336 | * E: Error code. If it's in the range of 0x00..0x1f, only some |
337 | * minor problem occured. Errors >= 0x20 are considered bad | 337 | * minor problem occurred. Errors >= 0x20 are considered bad |
338 | * and the device may not work properly... | 338 | * and the device may not work properly... |
339 | * D: <0010> == mouse, <0100> == tablet | 339 | * D: <0010> == mouse, <0100> == tablet |
340 | */ | 340 | */ |
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c index 7630273e9474..257e033986e4 100644 --- a/drivers/input/mousedev.c +++ b/drivers/input/mousedev.c | |||
@@ -508,7 +508,6 @@ static void mousedev_attach_client(struct mousedev *mousedev, | |||
508 | spin_lock(&mousedev->client_lock); | 508 | spin_lock(&mousedev->client_lock); |
509 | list_add_tail_rcu(&client->node, &mousedev->client_list); | 509 | list_add_tail_rcu(&client->node, &mousedev->client_list); |
510 | spin_unlock(&mousedev->client_lock); | 510 | spin_unlock(&mousedev->client_lock); |
511 | synchronize_rcu(); | ||
512 | } | 511 | } |
513 | 512 | ||
514 | static void mousedev_detach_client(struct mousedev *mousedev, | 513 | static void mousedev_detach_client(struct mousedev *mousedev, |
diff --git a/drivers/input/serio/altera_ps2.c b/drivers/input/serio/altera_ps2.c index 7998560a1904..d363dc4571a3 100644 --- a/drivers/input/serio/altera_ps2.c +++ b/drivers/input/serio/altera_ps2.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/io.h> | 20 | #include <linux/io.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/of.h> | ||
22 | 23 | ||
23 | #define DRV_NAME "altera_ps2" | 24 | #define DRV_NAME "altera_ps2" |
24 | 25 | ||
@@ -173,6 +174,16 @@ static int __devexit altera_ps2_remove(struct platform_device *pdev) | |||
173 | return 0; | 174 | return 0; |
174 | } | 175 | } |
175 | 176 | ||
177 | #ifdef CONFIG_OF | ||
178 | static const struct of_device_id altera_ps2_match[] = { | ||
179 | { .compatible = "ALTR,ps2-1.0", }, | ||
180 | {}, | ||
181 | }; | ||
182 | MODULE_DEVICE_TABLE(of, altera_ps2_match); | ||
183 | #else /* CONFIG_OF */ | ||
184 | #define altera_ps2_match NULL | ||
185 | #endif /* CONFIG_OF */ | ||
186 | |||
176 | /* | 187 | /* |
177 | * Our device driver structure | 188 | * Our device driver structure |
178 | */ | 189 | */ |
@@ -182,6 +193,7 @@ static struct platform_driver altera_ps2_driver = { | |||
182 | .driver = { | 193 | .driver = { |
183 | .name = DRV_NAME, | 194 | .name = DRV_NAME, |
184 | .owner = THIS_MODULE, | 195 | .owner = THIS_MODULE, |
196 | .of_match_table = altera_ps2_match, | ||
185 | }, | 197 | }, |
186 | }; | 198 | }; |
187 | 199 | ||
@@ -189,13 +201,12 @@ static int __init altera_ps2_init(void) | |||
189 | { | 201 | { |
190 | return platform_driver_register(&altera_ps2_driver); | 202 | return platform_driver_register(&altera_ps2_driver); |
191 | } | 203 | } |
204 | module_init(altera_ps2_init); | ||
192 | 205 | ||
193 | static void __exit altera_ps2_exit(void) | 206 | static void __exit altera_ps2_exit(void) |
194 | { | 207 | { |
195 | platform_driver_unregister(&altera_ps2_driver); | 208 | platform_driver_unregister(&altera_ps2_driver); |
196 | } | 209 | } |
197 | |||
198 | module_init(altera_ps2_init); | ||
199 | module_exit(altera_ps2_exit); | 210 | module_exit(altera_ps2_exit); |
200 | 211 | ||
201 | MODULE_DESCRIPTION("Altera University Program PS2 controller driver"); | 212 | MODULE_DESCRIPTION("Altera University Program PS2 controller driver"); |
diff --git a/drivers/input/serio/ambakmi.c b/drivers/input/serio/ambakmi.c index 92563a681d65..12abc50508e5 100644 --- a/drivers/input/serio/ambakmi.c +++ b/drivers/input/serio/ambakmi.c | |||
@@ -107,7 +107,8 @@ static void amba_kmi_close(struct serio *io) | |||
107 | clk_disable(kmi->clk); | 107 | clk_disable(kmi->clk); |
108 | } | 108 | } |
109 | 109 | ||
110 | static int __devinit amba_kmi_probe(struct amba_device *dev, struct amba_id *id) | 110 | static int __devinit amba_kmi_probe(struct amba_device *dev, |
111 | const struct amba_id *id) | ||
111 | { | 112 | { |
112 | struct amba_kmi_port *kmi; | 113 | struct amba_kmi_port *kmi; |
113 | struct serio *io; | 114 | struct serio *io; |
diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c index ebe955325677..4b2a42f9f0bb 100644 --- a/drivers/input/serio/ams_delta_serio.c +++ b/drivers/input/serio/ams_delta_serio.c | |||
@@ -149,7 +149,7 @@ static int __init ams_delta_serio_init(void) | |||
149 | * at FIQ level, switch back from edge to simple interrupt handler | 149 | * at FIQ level, switch back from edge to simple interrupt handler |
150 | * to avoid bad interaction. | 150 | * to avoid bad interaction. |
151 | */ | 151 | */ |
152 | set_irq_handler(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), | 152 | irq_set_handler(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), |
153 | handle_simple_irq); | 153 | handle_simple_irq); |
154 | 154 | ||
155 | serio_register_port(ams_delta_serio); | 155 | serio_register_port(ams_delta_serio); |
diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c index 8c0b51c31424..42206205e4f5 100644 --- a/drivers/input/serio/hp_sdc.c +++ b/drivers/input/serio/hp_sdc.c | |||
@@ -955,7 +955,7 @@ static int __init hp_sdc_init_hppa(struct parisc_device *d) | |||
955 | INIT_DELAYED_WORK(&moduleloader_work, request_module_delayed); | 955 | INIT_DELAYED_WORK(&moduleloader_work, request_module_delayed); |
956 | 956 | ||
957 | ret = hp_sdc_init(); | 957 | ret = hp_sdc_init(); |
958 | /* after successfull initialization give SDC some time to settle | 958 | /* after successful initialization give SDC some time to settle |
959 | * and then load the hp_sdc_mlc upper layer driver */ | 959 | * and then load the hp_sdc_mlc upper layer driver */ |
960 | if (!ret) | 960 | if (!ret) |
961 | schedule_delayed_work(&moduleloader_work, | 961 | schedule_delayed_work(&moduleloader_work, |
diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h index c5cc4508d6df..395a9af3adcd 100644 --- a/drivers/input/serio/i8042-sparcio.h +++ b/drivers/input/serio/i8042-sparcio.h | |||
@@ -49,7 +49,7 @@ static inline void i8042_write_command(int val) | |||
49 | #define OBP_PS2MS_NAME1 "kdmouse" | 49 | #define OBP_PS2MS_NAME1 "kdmouse" |
50 | #define OBP_PS2MS_NAME2 "mouse" | 50 | #define OBP_PS2MS_NAME2 "mouse" |
51 | 51 | ||
52 | static int __devinit sparc_i8042_probe(struct platform_device *op, const struct of_device_id *match) | 52 | static int __devinit sparc_i8042_probe(struct platform_device *op) |
53 | { | 53 | { |
54 | struct device_node *dp = op->dev.of_node; | 54 | struct device_node *dp = op->dev.of_node; |
55 | 55 | ||
@@ -95,7 +95,7 @@ static const struct of_device_id sparc_i8042_match[] = { | |||
95 | }; | 95 | }; |
96 | MODULE_DEVICE_TABLE(of, sparc_i8042_match); | 96 | MODULE_DEVICE_TABLE(of, sparc_i8042_match); |
97 | 97 | ||
98 | static struct of_platform_driver sparc_i8042_driver = { | 98 | static struct platform_driver sparc_i8042_driver = { |
99 | .driver = { | 99 | .driver = { |
100 | .name = "i8042", | 100 | .name = "i8042", |
101 | .owner = THIS_MODULE, | 101 | .owner = THIS_MODULE, |
@@ -116,7 +116,7 @@ static int __init i8042_platform_init(void) | |||
116 | if (!kbd_iobase) | 116 | if (!kbd_iobase) |
117 | return -ENODEV; | 117 | return -ENODEV; |
118 | } else { | 118 | } else { |
119 | int err = of_register_platform_driver(&sparc_i8042_driver); | 119 | int err = platform_driver_register(&sparc_i8042_driver); |
120 | if (err) | 120 | if (err) |
121 | return err; | 121 | return err; |
122 | 122 | ||
@@ -140,7 +140,7 @@ static inline void i8042_platform_exit(void) | |||
140 | struct device_node *root = of_find_node_by_path("/"); | 140 | struct device_node *root = of_find_node_by_path("/"); |
141 | 141 | ||
142 | if (strcmp(root->name, "SUNW,JavaStation-1")) | 142 | if (strcmp(root->name, "SUNW,JavaStation-1")) |
143 | of_unregister_platform_driver(&sparc_i8042_driver); | 143 | platform_driver_unregister(&sparc_i8042_driver); |
144 | } | 144 | } |
145 | 145 | ||
146 | #else /* !CONFIG_PCI */ | 146 | #else /* !CONFIG_PCI */ |
diff --git a/drivers/input/serio/i8042-unicore32io.h b/drivers/input/serio/i8042-unicore32io.h new file mode 100644 index 000000000000..73f5cc124a36 --- /dev/null +++ b/drivers/input/serio/i8042-unicore32io.h | |||
@@ -0,0 +1,73 @@ | |||
1 | /* | ||
2 | * Code specific to PKUnity SoC and UniCore ISA | ||
3 | * | ||
4 | * Maintained by GUAN Xue-tao <gxt@mprc.pku.edu.cn> | ||
5 | * Copyright (C) 2001-2011 Guan Xuetao | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | #ifndef _I8042_UNICORE32_H | ||
12 | #define _I8042_UNICORE32_H | ||
13 | |||
14 | #include <mach/hardware.h> | ||
15 | |||
16 | /* | ||
17 | * Names. | ||
18 | */ | ||
19 | #define I8042_KBD_PHYS_DESC "isa0060/serio0" | ||
20 | #define I8042_AUX_PHYS_DESC "isa0060/serio1" | ||
21 | #define I8042_MUX_PHYS_DESC "isa0060/serio%d" | ||
22 | |||
23 | /* | ||
24 | * IRQs. | ||
25 | */ | ||
26 | #define I8042_KBD_IRQ IRQ_PS2_KBD | ||
27 | #define I8042_AUX_IRQ IRQ_PS2_AUX | ||
28 | |||
29 | /* | ||
30 | * Register numbers. | ||
31 | */ | ||
32 | #define I8042_COMMAND_REG PS2_COMMAND | ||
33 | #define I8042_STATUS_REG PS2_STATUS | ||
34 | #define I8042_DATA_REG PS2_DATA | ||
35 | |||
36 | #define I8042_REGION_START (resource_size_t)(PS2_DATA) | ||
37 | #define I8042_REGION_SIZE (resource_size_t)(16) | ||
38 | |||
39 | static inline int i8042_read_data(void) | ||
40 | { | ||
41 | return readb(I8042_DATA_REG); | ||
42 | } | ||
43 | |||
44 | static inline int i8042_read_status(void) | ||
45 | { | ||
46 | return readb(I8042_STATUS_REG); | ||
47 | } | ||
48 | |||
49 | static inline void i8042_write_data(int val) | ||
50 | { | ||
51 | writeb(val, I8042_DATA_REG); | ||
52 | } | ||
53 | |||
54 | static inline void i8042_write_command(int val) | ||
55 | { | ||
56 | writeb(val, I8042_COMMAND_REG); | ||
57 | } | ||
58 | |||
59 | static inline int i8042_platform_init(void) | ||
60 | { | ||
61 | if (!request_mem_region(I8042_REGION_START, I8042_REGION_SIZE, "i8042")) | ||
62 | return -EBUSY; | ||
63 | |||
64 | i8042_reset = 1; | ||
65 | return 0; | ||
66 | } | ||
67 | |||
68 | static inline void i8042_platform_exit(void) | ||
69 | { | ||
70 | release_mem_region(I8042_REGION_START, I8042_REGION_SIZE); | ||
71 | } | ||
72 | |||
73 | #endif /* _I8042_UNICORE32_H */ | ||
diff --git a/drivers/input/serio/i8042.h b/drivers/input/serio/i8042.h index ac1d759d0f55..3452708fbe3b 100644 --- a/drivers/input/serio/i8042.h +++ b/drivers/input/serio/i8042.h | |||
@@ -26,6 +26,8 @@ | |||
26 | #include "i8042-sparcio.h" | 26 | #include "i8042-sparcio.h" |
27 | #elif defined(CONFIG_X86) || defined(CONFIG_IA64) | 27 | #elif defined(CONFIG_X86) || defined(CONFIG_IA64) |
28 | #include "i8042-x86ia64io.h" | 28 | #include "i8042-x86ia64io.h" |
29 | #elif defined(CONFIG_UNICORE32) | ||
30 | #include "i8042-unicore32io.h" | ||
29 | #else | 31 | #else |
30 | #include "i8042-io.h" | 32 | #include "i8042-io.h" |
31 | #endif | 33 | #endif |
diff --git a/drivers/input/serio/xilinx_ps2.c b/drivers/input/serio/xilinx_ps2.c index bb14449fb022..80baa53da5b1 100644 --- a/drivers/input/serio/xilinx_ps2.c +++ b/drivers/input/serio/xilinx_ps2.c | |||
@@ -225,15 +225,14 @@ static void sxps2_close(struct serio *pserio) | |||
225 | /** | 225 | /** |
226 | * xps2_of_probe - probe method for the PS/2 device. | 226 | * xps2_of_probe - probe method for the PS/2 device. |
227 | * @of_dev: pointer to OF device structure | 227 | * @of_dev: pointer to OF device structure |
228 | * @match: pointer to the stucture used for matching a device | 228 | * @match: pointer to the structure used for matching a device |
229 | * | 229 | * |
230 | * This function probes the PS/2 device in the device tree. | 230 | * This function probes the PS/2 device in the device tree. |
231 | * It initializes the driver data structure and the hardware. | 231 | * It initializes the driver data structure and the hardware. |
232 | * It returns 0, if the driver is bound to the PS/2 device, or a negative | 232 | * It returns 0, if the driver is bound to the PS/2 device, or a negative |
233 | * value if there is an error. | 233 | * value if there is an error. |
234 | */ | 234 | */ |
235 | static int __devinit xps2_of_probe(struct platform_device *ofdev, | 235 | static int __devinit xps2_of_probe(struct platform_device *ofdev) |
236 | const struct of_device_id *match) | ||
237 | { | 236 | { |
238 | struct resource r_irq; /* Interrupt resources */ | 237 | struct resource r_irq; /* Interrupt resources */ |
239 | struct resource r_mem; /* IO mem resources */ | 238 | struct resource r_mem; /* IO mem resources */ |
@@ -361,7 +360,7 @@ static const struct of_device_id xps2_of_match[] __devinitconst = { | |||
361 | }; | 360 | }; |
362 | MODULE_DEVICE_TABLE(of, xps2_of_match); | 361 | MODULE_DEVICE_TABLE(of, xps2_of_match); |
363 | 362 | ||
364 | static struct of_platform_driver xps2_of_driver = { | 363 | static struct platform_driver xps2_of_driver = { |
365 | .driver = { | 364 | .driver = { |
366 | .name = DRIVER_NAME, | 365 | .name = DRIVER_NAME, |
367 | .owner = THIS_MODULE, | 366 | .owner = THIS_MODULE, |
@@ -373,12 +372,12 @@ static struct of_platform_driver xps2_of_driver = { | |||
373 | 372 | ||
374 | static int __init xps2_init(void) | 373 | static int __init xps2_init(void) |
375 | { | 374 | { |
376 | return of_register_platform_driver(&xps2_of_driver); | 375 | return platform_driver_register(&xps2_of_driver); |
377 | } | 376 | } |
378 | 377 | ||
379 | static void __exit xps2_cleanup(void) | 378 | static void __exit xps2_cleanup(void) |
380 | { | 379 | { |
381 | of_unregister_platform_driver(&xps2_of_driver); | 380 | platform_driver_unregister(&xps2_of_driver); |
382 | } | 381 | } |
383 | 382 | ||
384 | module_init(xps2_init); | 383 | module_init(xps2_init); |
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 434fd800cd24..cabd9e54863f 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig | |||
@@ -248,6 +248,18 @@ config TOUCHSCREEN_LPC32XX | |||
248 | To compile this driver as a module, choose M here: the | 248 | To compile this driver as a module, choose M here: the |
249 | module will be called lpc32xx_ts. | 249 | module will be called lpc32xx_ts. |
250 | 250 | ||
251 | config TOUCHSCREEN_MAX11801 | ||
252 | tristate "MAX11801 based touchscreens" | ||
253 | depends on I2C | ||
254 | help | ||
255 | Say Y here if you have a MAX11801 based touchscreen | ||
256 | controller. | ||
257 | |||
258 | If unsure, say N. | ||
259 | |||
260 | To compile this driver as a module, choose M here: the | ||
261 | module will be called max11801_ts. | ||
262 | |||
251 | config TOUCHSCREEN_MCS5000 | 263 | config TOUCHSCREEN_MCS5000 |
252 | tristate "MELFAS MCS-5000 touchscreen" | 264 | tristate "MELFAS MCS-5000 touchscreen" |
253 | depends on I2C | 265 | depends on I2C |
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index ca94098d4c92..282d6f76ae26 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile | |||
@@ -27,6 +27,7 @@ obj-$(CONFIG_TOUCHSCREEN_FUJITSU) += fujitsu_ts.o | |||
27 | obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o | 27 | obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o |
28 | obj-$(CONFIG_TOUCHSCREEN_INTEL_MID) += intel-mid-touch.o | 28 | obj-$(CONFIG_TOUCHSCREEN_INTEL_MID) += intel-mid-touch.o |
29 | obj-$(CONFIG_TOUCHSCREEN_LPC32XX) += lpc32xx_ts.o | 29 | obj-$(CONFIG_TOUCHSCREEN_LPC32XX) += lpc32xx_ts.o |
30 | obj-$(CONFIG_TOUCHSCREEN_MAX11801) += max11801_ts.o | ||
30 | obj-$(CONFIG_TOUCHSCREEN_MC13783) += mc13783_ts.o | 31 | obj-$(CONFIG_TOUCHSCREEN_MC13783) += mc13783_ts.o |
31 | obj-$(CONFIG_TOUCHSCREEN_MCS5000) += mcs5000_ts.o | 32 | obj-$(CONFIG_TOUCHSCREEN_MCS5000) += mcs5000_ts.o |
32 | obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o | 33 | obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o |
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 1de1c19dad30..5196861b86ef 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
@@ -109,6 +109,7 @@ struct ads7846 { | |||
109 | u16 pressure_max; | 109 | u16 pressure_max; |
110 | 110 | ||
111 | bool swap_xy; | 111 | bool swap_xy; |
112 | bool use_internal; | ||
112 | 113 | ||
113 | struct ads7846_packet *packet; | 114 | struct ads7846_packet *packet; |
114 | 115 | ||
@@ -307,7 +308,6 @@ static int ads7846_read12_ser(struct device *dev, unsigned command) | |||
307 | struct ads7846 *ts = dev_get_drvdata(dev); | 308 | struct ads7846 *ts = dev_get_drvdata(dev); |
308 | struct ser_req *req; | 309 | struct ser_req *req; |
309 | int status; | 310 | int status; |
310 | int use_internal; | ||
311 | 311 | ||
312 | req = kzalloc(sizeof *req, GFP_KERNEL); | 312 | req = kzalloc(sizeof *req, GFP_KERNEL); |
313 | if (!req) | 313 | if (!req) |
@@ -315,11 +315,8 @@ static int ads7846_read12_ser(struct device *dev, unsigned command) | |||
315 | 315 | ||
316 | spi_message_init(&req->msg); | 316 | spi_message_init(&req->msg); |
317 | 317 | ||
318 | /* FIXME boards with ads7846 might use external vref instead ... */ | ||
319 | use_internal = (ts->model == 7846); | ||
320 | |||
321 | /* maybe turn on internal vREF, and let it settle */ | 318 | /* maybe turn on internal vREF, and let it settle */ |
322 | if (use_internal) { | 319 | if (ts->use_internal) { |
323 | req->ref_on = REF_ON; | 320 | req->ref_on = REF_ON; |
324 | req->xfer[0].tx_buf = &req->ref_on; | 321 | req->xfer[0].tx_buf = &req->ref_on; |
325 | req->xfer[0].len = 1; | 322 | req->xfer[0].len = 1; |
@@ -331,8 +328,14 @@ static int ads7846_read12_ser(struct device *dev, unsigned command) | |||
331 | /* for 1uF, settle for 800 usec; no cap, 100 usec. */ | 328 | /* for 1uF, settle for 800 usec; no cap, 100 usec. */ |
332 | req->xfer[1].delay_usecs = ts->vref_delay_usecs; | 329 | req->xfer[1].delay_usecs = ts->vref_delay_usecs; |
333 | spi_message_add_tail(&req->xfer[1], &req->msg); | 330 | spi_message_add_tail(&req->xfer[1], &req->msg); |
331 | |||
332 | /* Enable reference voltage */ | ||
333 | command |= ADS_PD10_REF_ON; | ||
334 | } | 334 | } |
335 | 335 | ||
336 | /* Enable ADC in every case */ | ||
337 | command |= ADS_PD10_ADC_ON; | ||
338 | |||
336 | /* take sample */ | 339 | /* take sample */ |
337 | req->command = (u8) command; | 340 | req->command = (u8) command; |
338 | req->xfer[2].tx_buf = &req->command; | 341 | req->xfer[2].tx_buf = &req->command; |
@@ -416,7 +419,7 @@ name ## _show(struct device *dev, struct device_attribute *attr, char *buf) \ | |||
416 | { \ | 419 | { \ |
417 | struct ads7846 *ts = dev_get_drvdata(dev); \ | 420 | struct ads7846 *ts = dev_get_drvdata(dev); \ |
418 | ssize_t v = ads7846_read12_ser(dev, \ | 421 | ssize_t v = ads7846_read12_ser(dev, \ |
419 | READ_12BIT_SER(var) | ADS_PD10_ALL_ON); \ | 422 | READ_12BIT_SER(var)); \ |
420 | if (v < 0) \ | 423 | if (v < 0) \ |
421 | return v; \ | 424 | return v; \ |
422 | return sprintf(buf, "%u\n", adjust(ts, v)); \ | 425 | return sprintf(buf, "%u\n", adjust(ts, v)); \ |
@@ -509,6 +512,7 @@ static int ads784x_hwmon_register(struct spi_device *spi, struct ads7846 *ts) | |||
509 | if (!ts->vref_mv) { | 512 | if (!ts->vref_mv) { |
510 | dev_dbg(&spi->dev, "assuming 2.5V internal vREF\n"); | 513 | dev_dbg(&spi->dev, "assuming 2.5V internal vREF\n"); |
511 | ts->vref_mv = 2500; | 514 | ts->vref_mv = 2500; |
515 | ts->use_internal = true; | ||
512 | } | 516 | } |
513 | break; | 517 | break; |
514 | case 7845: | 518 | case 7845: |
@@ -969,6 +973,13 @@ static int __devinit ads7846_setup_pendown(struct spi_device *spi, struct ads784 | |||
969 | pdata->gpio_pendown); | 973 | pdata->gpio_pendown); |
970 | return err; | 974 | return err; |
971 | } | 975 | } |
976 | err = gpio_direction_input(pdata->gpio_pendown); | ||
977 | if (err) { | ||
978 | dev_err(&spi->dev, "failed to setup pendown GPIO%d\n", | ||
979 | pdata->gpio_pendown); | ||
980 | gpio_free(pdata->gpio_pendown); | ||
981 | return err; | ||
982 | } | ||
972 | 983 | ||
973 | ts->gpio_pendown = pdata->gpio_pendown; | 984 | ts->gpio_pendown = pdata->gpio_pendown; |
974 | 985 | ||
@@ -1340,8 +1351,7 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
1340 | if (ts->model == 7845) | 1351 | if (ts->model == 7845) |
1341 | ads7845_read12_ser(&spi->dev, PWRDOWN); | 1352 | ads7845_read12_ser(&spi->dev, PWRDOWN); |
1342 | else | 1353 | else |
1343 | (void) ads7846_read12_ser(&spi->dev, | 1354 | (void) ads7846_read12_ser(&spi->dev, READ_12BIT_SER(vaux)); |
1344 | READ_12BIT_SER(vaux) | ADS_PD10_ALL_ON); | ||
1345 | 1355 | ||
1346 | err = sysfs_create_group(&spi->dev.kobj, &ads784x_attr_group); | 1356 | err = sysfs_create_group(&spi->dev.kobj, &ads784x_attr_group); |
1347 | if (err) | 1357 | if (err) |
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 4012436633b1..1e61387c73ca 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/firmware.h> | 17 | #include <linux/firmware.h> |
18 | #include <linux/i2c.h> | 18 | #include <linux/i2c.h> |
19 | #include <linux/i2c/atmel_mxt_ts.h> | 19 | #include <linux/i2c/atmel_mxt_ts.h> |
20 | #include <linux/input.h> | 20 | #include <linux/input/mt.h> |
21 | #include <linux/interrupt.h> | 21 | #include <linux/interrupt.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | 23 | ||
@@ -196,9 +196,12 @@ | |||
196 | #define MXT_PRESS (1 << 6) | 196 | #define MXT_PRESS (1 << 6) |
197 | #define MXT_DETECT (1 << 7) | 197 | #define MXT_DETECT (1 << 7) |
198 | 198 | ||
199 | /* Touch orient bits */ | ||
200 | #define MXT_XY_SWITCH (1 << 0) | ||
201 | #define MXT_X_INVERT (1 << 1) | ||
202 | #define MXT_Y_INVERT (1 << 2) | ||
203 | |||
199 | /* Touchscreen absolute values */ | 204 | /* Touchscreen absolute values */ |
200 | #define MXT_MAX_XC 0x3ff | ||
201 | #define MXT_MAX_YC 0x3ff | ||
202 | #define MXT_MAX_AREA 0xff | 205 | #define MXT_MAX_AREA 0xff |
203 | 206 | ||
204 | #define MXT_MAX_FINGER 10 | 207 | #define MXT_MAX_FINGER 10 |
@@ -246,6 +249,8 @@ struct mxt_data { | |||
246 | struct mxt_info info; | 249 | struct mxt_info info; |
247 | struct mxt_finger finger[MXT_MAX_FINGER]; | 250 | struct mxt_finger finger[MXT_MAX_FINGER]; |
248 | unsigned int irq; | 251 | unsigned int irq; |
252 | unsigned int max_x; | ||
253 | unsigned int max_y; | ||
249 | }; | 254 | }; |
250 | 255 | ||
251 | static bool mxt_object_readable(unsigned int type) | 256 | static bool mxt_object_readable(unsigned int type) |
@@ -499,19 +504,21 @@ static void mxt_input_report(struct mxt_data *data, int single_id) | |||
499 | if (!finger[id].status) | 504 | if (!finger[id].status) |
500 | continue; | 505 | continue; |
501 | 506 | ||
502 | input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, | 507 | input_mt_slot(input_dev, id); |
503 | finger[id].status != MXT_RELEASE ? | 508 | input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, |
504 | finger[id].area : 0); | 509 | finger[id].status != MXT_RELEASE); |
505 | input_report_abs(input_dev, ABS_MT_POSITION_X, | ||
506 | finger[id].x); | ||
507 | input_report_abs(input_dev, ABS_MT_POSITION_Y, | ||
508 | finger[id].y); | ||
509 | input_mt_sync(input_dev); | ||
510 | 510 | ||
511 | if (finger[id].status == MXT_RELEASE) | 511 | if (finger[id].status != MXT_RELEASE) { |
512 | finger[id].status = 0; | ||
513 | else | ||
514 | finger_num++; | 512 | finger_num++; |
513 | input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, | ||
514 | finger[id].area); | ||
515 | input_report_abs(input_dev, ABS_MT_POSITION_X, | ||
516 | finger[id].x); | ||
517 | input_report_abs(input_dev, ABS_MT_POSITION_Y, | ||
518 | finger[id].y); | ||
519 | } else { | ||
520 | finger[id].status = 0; | ||
521 | } | ||
515 | } | 522 | } |
516 | 523 | ||
517 | input_report_key(input_dev, BTN_TOUCH, finger_num > 0); | 524 | input_report_key(input_dev, BTN_TOUCH, finger_num > 0); |
@@ -549,8 +556,13 @@ static void mxt_input_touchevent(struct mxt_data *data, | |||
549 | if (!(status & (MXT_PRESS | MXT_MOVE))) | 556 | if (!(status & (MXT_PRESS | MXT_MOVE))) |
550 | return; | 557 | return; |
551 | 558 | ||
552 | x = (message->message[1] << 2) | ((message->message[3] & ~0x3f) >> 6); | 559 | x = (message->message[1] << 4) | ((message->message[3] >> 4) & 0xf); |
553 | y = (message->message[2] << 2) | ((message->message[3] & ~0xf3) >> 2); | 560 | y = (message->message[2] << 4) | ((message->message[3] & 0xf)); |
561 | if (data->max_x < 1024) | ||
562 | x = x >> 2; | ||
563 | if (data->max_y < 1024) | ||
564 | y = y >> 2; | ||
565 | |||
554 | area = message->message[4]; | 566 | area = message->message[4]; |
555 | 567 | ||
556 | dev_dbg(dev, "[%d] %s x: %d, y: %d, area: %d\n", id, | 568 | dev_dbg(dev, "[%d] %s x: %d, y: %d, area: %d\n", id, |
@@ -804,10 +816,6 @@ static int mxt_initialize(struct mxt_data *data) | |||
804 | if (error) | 816 | if (error) |
805 | return error; | 817 | return error; |
806 | 818 | ||
807 | error = mxt_make_highchg(data); | ||
808 | if (error) | ||
809 | return error; | ||
810 | |||
811 | mxt_handle_pdata(data); | 819 | mxt_handle_pdata(data); |
812 | 820 | ||
813 | /* Backup to memory */ | 821 | /* Backup to memory */ |
@@ -845,6 +853,20 @@ static int mxt_initialize(struct mxt_data *data) | |||
845 | return 0; | 853 | return 0; |
846 | } | 854 | } |
847 | 855 | ||
856 | static void mxt_calc_resolution(struct mxt_data *data) | ||
857 | { | ||
858 | unsigned int max_x = data->pdata->x_size - 1; | ||
859 | unsigned int max_y = data->pdata->y_size - 1; | ||
860 | |||
861 | if (data->pdata->orient & MXT_XY_SWITCH) { | ||
862 | data->max_x = max_y; | ||
863 | data->max_y = max_x; | ||
864 | } else { | ||
865 | data->max_x = max_x; | ||
866 | data->max_y = max_y; | ||
867 | } | ||
868 | } | ||
869 | |||
848 | static ssize_t mxt_object_show(struct device *dev, | 870 | static ssize_t mxt_object_show(struct device *dev, |
849 | struct device_attribute *attr, char *buf) | 871 | struct device_attribute *attr, char *buf) |
850 | { | 872 | { |
@@ -981,6 +1003,10 @@ static ssize_t mxt_update_fw_store(struct device *dev, | |||
981 | 1003 | ||
982 | enable_irq(data->irq); | 1004 | enable_irq(data->irq); |
983 | 1005 | ||
1006 | error = mxt_make_highchg(data); | ||
1007 | if (error) | ||
1008 | return error; | ||
1009 | |||
984 | return count; | 1010 | return count; |
985 | } | 1011 | } |
986 | 1012 | ||
@@ -1052,31 +1078,33 @@ static int __devinit mxt_probe(struct i2c_client *client, | |||
1052 | input_dev->open = mxt_input_open; | 1078 | input_dev->open = mxt_input_open; |
1053 | input_dev->close = mxt_input_close; | 1079 | input_dev->close = mxt_input_close; |
1054 | 1080 | ||
1081 | data->client = client; | ||
1082 | data->input_dev = input_dev; | ||
1083 | data->pdata = pdata; | ||
1084 | data->irq = client->irq; | ||
1085 | |||
1086 | mxt_calc_resolution(data); | ||
1087 | |||
1055 | __set_bit(EV_ABS, input_dev->evbit); | 1088 | __set_bit(EV_ABS, input_dev->evbit); |
1056 | __set_bit(EV_KEY, input_dev->evbit); | 1089 | __set_bit(EV_KEY, input_dev->evbit); |
1057 | __set_bit(BTN_TOUCH, input_dev->keybit); | 1090 | __set_bit(BTN_TOUCH, input_dev->keybit); |
1058 | 1091 | ||
1059 | /* For single touch */ | 1092 | /* For single touch */ |
1060 | input_set_abs_params(input_dev, ABS_X, | 1093 | input_set_abs_params(input_dev, ABS_X, |
1061 | 0, MXT_MAX_XC, 0, 0); | 1094 | 0, data->max_x, 0, 0); |
1062 | input_set_abs_params(input_dev, ABS_Y, | 1095 | input_set_abs_params(input_dev, ABS_Y, |
1063 | 0, MXT_MAX_YC, 0, 0); | 1096 | 0, data->max_y, 0, 0); |
1064 | 1097 | ||
1065 | /* For multi touch */ | 1098 | /* For multi touch */ |
1099 | input_mt_init_slots(input_dev, MXT_MAX_FINGER); | ||
1066 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, | 1100 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, |
1067 | 0, MXT_MAX_AREA, 0, 0); | 1101 | 0, MXT_MAX_AREA, 0, 0); |
1068 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, | 1102 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, |
1069 | 0, MXT_MAX_XC, 0, 0); | 1103 | 0, data->max_x, 0, 0); |
1070 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, | 1104 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, |
1071 | 0, MXT_MAX_YC, 0, 0); | 1105 | 0, data->max_y, 0, 0); |
1072 | 1106 | ||
1073 | input_set_drvdata(input_dev, data); | 1107 | input_set_drvdata(input_dev, data); |
1074 | |||
1075 | data->client = client; | ||
1076 | data->input_dev = input_dev; | ||
1077 | data->pdata = pdata; | ||
1078 | data->irq = client->irq; | ||
1079 | |||
1080 | i2c_set_clientdata(client, data); | 1108 | i2c_set_clientdata(client, data); |
1081 | 1109 | ||
1082 | error = mxt_initialize(data); | 1110 | error = mxt_initialize(data); |
@@ -1090,6 +1118,10 @@ static int __devinit mxt_probe(struct i2c_client *client, | |||
1090 | goto err_free_object; | 1118 | goto err_free_object; |
1091 | } | 1119 | } |
1092 | 1120 | ||
1121 | error = mxt_make_highchg(data); | ||
1122 | if (error) | ||
1123 | goto err_free_irq; | ||
1124 | |||
1093 | error = input_register_device(input_dev); | 1125 | error = input_register_device(input_dev); |
1094 | if (error) | 1126 | if (error) |
1095 | goto err_free_irq; | 1127 | goto err_free_irq; |
diff --git a/drivers/input/touchscreen/atmel_tsadcc.c b/drivers/input/touchscreen/atmel_tsadcc.c index 3d9b5166ebe9..432c69be6ac6 100644 --- a/drivers/input/touchscreen/atmel_tsadcc.c +++ b/drivers/input/touchscreen/atmel_tsadcc.c | |||
@@ -317,7 +317,7 @@ err_unmap_regs: | |||
317 | err_release_mem: | 317 | err_release_mem: |
318 | release_mem_region(res->start, resource_size(res)); | 318 | release_mem_region(res->start, resource_size(res)); |
319 | err_free_dev: | 319 | err_free_dev: |
320 | input_free_device(ts_dev->input); | 320 | input_free_device(input_dev); |
321 | err_free_mem: | 321 | err_free_mem: |
322 | kfree(ts_dev); | 322 | kfree(ts_dev); |
323 | return err; | 323 | return err; |
diff --git a/drivers/input/touchscreen/h3600_ts_input.c b/drivers/input/touchscreen/h3600_ts_input.c index 45f93d0f5592..211811ae5525 100644 --- a/drivers/input/touchscreen/h3600_ts_input.c +++ b/drivers/input/touchscreen/h3600_ts_input.c | |||
@@ -396,14 +396,14 @@ static int h3600ts_connect(struct serio *serio, struct serio_driver *drv) | |||
396 | set_GPIO_IRQ_edge(GPIO_BITSY_NPOWER_BUTTON, GPIO_RISING_EDGE); | 396 | set_GPIO_IRQ_edge(GPIO_BITSY_NPOWER_BUTTON, GPIO_RISING_EDGE); |
397 | 397 | ||
398 | if (request_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, action_button_handler, | 398 | if (request_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, action_button_handler, |
399 | IRQF_SHARED | IRQF_DISABLED, "h3600_action", &ts->dev)) { | 399 | IRQF_SHARED | IRQF_DISABLED, "h3600_action", ts->dev)) { |
400 | printk(KERN_ERR "h3600ts.c: Could not allocate Action Button IRQ!\n"); | 400 | printk(KERN_ERR "h3600ts.c: Could not allocate Action Button IRQ!\n"); |
401 | err = -EBUSY; | 401 | err = -EBUSY; |
402 | goto fail1; | 402 | goto fail1; |
403 | } | 403 | } |
404 | 404 | ||
405 | if (request_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, npower_button_handler, | 405 | if (request_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, npower_button_handler, |
406 | IRQF_SHARED | IRQF_DISABLED, "h3600_suspend", &ts->dev)) { | 406 | IRQF_SHARED | IRQF_DISABLED, "h3600_suspend", ts->dev)) { |
407 | printk(KERN_ERR "h3600ts.c: Could not allocate Power Button IRQ!\n"); | 407 | printk(KERN_ERR "h3600ts.c: Could not allocate Power Button IRQ!\n"); |
408 | err = -EBUSY; | 408 | err = -EBUSY; |
409 | goto fail2; | 409 | goto fail2; |
@@ -439,8 +439,8 @@ static void h3600ts_disconnect(struct serio *serio) | |||
439 | { | 439 | { |
440 | struct h3600_dev *ts = serio_get_drvdata(serio); | 440 | struct h3600_dev *ts = serio_get_drvdata(serio); |
441 | 441 | ||
442 | free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev); | 442 | free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts->dev); |
443 | free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, &ts->dev); | 443 | free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, ts->dev); |
444 | input_get_device(ts->dev); | 444 | input_get_device(ts->dev); |
445 | input_unregister_device(ts->dev); | 445 | input_unregister_device(ts->dev); |
446 | serio_close(serio); | 446 | serio_close(serio); |
diff --git a/drivers/input/touchscreen/intel-mid-touch.c b/drivers/input/touchscreen/intel-mid-touch.c index c0307b22d86f..66c96bfc5522 100644 --- a/drivers/input/touchscreen/intel-mid-touch.c +++ b/drivers/input/touchscreen/intel-mid-touch.c | |||
@@ -542,7 +542,7 @@ static int __devinit mrstouch_adc_init(struct mrstouch_dev *tsdev) | |||
542 | * ADC power on, start, enable PENDET and set loop delay | 542 | * ADC power on, start, enable PENDET and set loop delay |
543 | * ADC loop delay is set to 4.5 ms approximately | 543 | * ADC loop delay is set to 4.5 ms approximately |
544 | * Loop delay more than this results in jitter in adc readings | 544 | * Loop delay more than this results in jitter in adc readings |
545 | * Setting loop delay to 0 (continous loop) in MAXIM stops PENDET | 545 | * Setting loop delay to 0 (continuous loop) in MAXIM stops PENDET |
546 | * interrupt generation sometimes. | 546 | * interrupt generation sometimes. |
547 | */ | 547 | */ |
548 | 548 | ||
diff --git a/drivers/input/touchscreen/mainstone-wm97xx.c b/drivers/input/touchscreen/mainstone-wm97xx.c index b6b8b1c7ecea..3242e7076258 100644 --- a/drivers/input/touchscreen/mainstone-wm97xx.c +++ b/drivers/input/touchscreen/mainstone-wm97xx.c | |||
@@ -219,7 +219,7 @@ static int wm97xx_acc_startup(struct wm97xx *wm) | |||
219 | } | 219 | } |
220 | 220 | ||
221 | wm->pen_irq = gpio_to_irq(irq); | 221 | wm->pen_irq = gpio_to_irq(irq); |
222 | set_irq_type(wm->pen_irq, IRQ_TYPE_EDGE_BOTH); | 222 | irq_set_irq_type(wm->pen_irq, IRQ_TYPE_EDGE_BOTH); |
223 | } else /* pen irq not supported */ | 223 | } else /* pen irq not supported */ |
224 | pen_int = 0; | 224 | pen_int = 0; |
225 | 225 | ||
diff --git a/drivers/input/touchscreen/max11801_ts.c b/drivers/input/touchscreen/max11801_ts.c new file mode 100644 index 000000000000..4f2713d92791 --- /dev/null +++ b/drivers/input/touchscreen/max11801_ts.c | |||
@@ -0,0 +1,272 @@ | |||
1 | /* | ||
2 | * Driver for MAXI MAX11801 - A Resistive touch screen controller with | ||
3 | * i2c interface | ||
4 | * | ||
5 | * Copyright (C) 2011 Freescale Semiconductor, Inc. | ||
6 | * Author: Zhang Jiejing <jiejing.zhang@freescale.com> | ||
7 | * | ||
8 | * Based on mcs5000_ts.c | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License. | ||
13 | */ | ||
14 | |||
15 | /* | ||
16 | * This driver aims to support the series of MAXI touch chips max11801 | ||
17 | * through max11803. The main difference between these 4 chips can be | ||
18 | * found in the table below: | ||
19 | * ----------------------------------------------------- | ||
20 | * | CHIP | AUTO MODE SUPPORT(FIFO) | INTERFACE | | ||
21 | * |----------------------------------------------------| | ||
22 | * | max11800 | YES | SPI | | ||
23 | * | max11801 | YES | I2C | | ||
24 | * | max11802 | NO | SPI | | ||
25 | * | max11803 | NO | I2C | | ||
26 | * ------------------------------------------------------ | ||
27 | * | ||
28 | * Currently, this driver only supports max11801. | ||
29 | * | ||
30 | * Data Sheet: | ||
31 | * http://www.maxim-ic.com/datasheet/index.mvp/id/5943 | ||
32 | */ | ||
33 | |||
34 | #include <linux/module.h> | ||
35 | #include <linux/init.h> | ||
36 | #include <linux/i2c.h> | ||
37 | #include <linux/interrupt.h> | ||
38 | #include <linux/input.h> | ||
39 | #include <linux/slab.h> | ||
40 | #include <linux/bitops.h> | ||
41 | |||
42 | /* Register Address define */ | ||
43 | #define GENERNAL_STATUS_REG 0x00 | ||
44 | #define GENERNAL_CONF_REG 0x01 | ||
45 | #define MESURE_RES_CONF_REG 0x02 | ||
46 | #define MESURE_AVER_CONF_REG 0x03 | ||
47 | #define ADC_SAMPLE_TIME_CONF_REG 0x04 | ||
48 | #define PANEL_SETUPTIME_CONF_REG 0x05 | ||
49 | #define DELAY_CONVERSION_CONF_REG 0x06 | ||
50 | #define TOUCH_DETECT_PULLUP_CONF_REG 0x07 | ||
51 | #define AUTO_MODE_TIME_CONF_REG 0x08 /* only for max11800/max11801 */ | ||
52 | #define APERTURE_CONF_REG 0x09 /* only for max11800/max11801 */ | ||
53 | #define AUX_MESURE_CONF_REG 0x0a | ||
54 | #define OP_MODE_CONF_REG 0x0b | ||
55 | |||
56 | /* FIFO is found only in max11800 and max11801 */ | ||
57 | #define FIFO_RD_CMD (0x50 << 1) | ||
58 | #define MAX11801_FIFO_INT (1 << 2) | ||
59 | #define MAX11801_FIFO_OVERFLOW (1 << 3) | ||
60 | |||
61 | #define XY_BUFSIZE 4 | ||
62 | #define XY_BUF_OFFSET 4 | ||
63 | |||
64 | #define MAX11801_MAX_X 0xfff | ||
65 | #define MAX11801_MAX_Y 0xfff | ||
66 | |||
67 | #define MEASURE_TAG_OFFSET 2 | ||
68 | #define MEASURE_TAG_MASK (3 << MEASURE_TAG_OFFSET) | ||
69 | #define EVENT_TAG_OFFSET 0 | ||
70 | #define EVENT_TAG_MASK (3 << EVENT_TAG_OFFSET) | ||
71 | #define MEASURE_X_TAG (0 << MEASURE_TAG_OFFSET) | ||
72 | #define MEASURE_Y_TAG (1 << MEASURE_TAG_OFFSET) | ||
73 | |||
74 | /* These are the state of touch event state machine */ | ||
75 | enum { | ||
76 | EVENT_INIT, | ||
77 | EVENT_MIDDLE, | ||
78 | EVENT_RELEASE, | ||
79 | EVENT_FIFO_END | ||
80 | }; | ||
81 | |||
82 | struct max11801_data { | ||
83 | struct i2c_client *client; | ||
84 | struct input_dev *input_dev; | ||
85 | }; | ||
86 | |||
87 | static u8 read_register(struct i2c_client *client, int addr) | ||
88 | { | ||
89 | /* XXX: The chip ignores LSB of register address */ | ||
90 | return i2c_smbus_read_byte_data(client, addr << 1); | ||
91 | } | ||
92 | |||
93 | static int max11801_write_reg(struct i2c_client *client, int addr, int data) | ||
94 | { | ||
95 | /* XXX: The chip ignores LSB of register address */ | ||
96 | return i2c_smbus_write_byte_data(client, addr << 1, data); | ||
97 | } | ||
98 | |||
99 | static irqreturn_t max11801_ts_interrupt(int irq, void *dev_id) | ||
100 | { | ||
101 | struct max11801_data *data = dev_id; | ||
102 | struct i2c_client *client = data->client; | ||
103 | int status, i, ret; | ||
104 | u8 buf[XY_BUFSIZE]; | ||
105 | int x = -1; | ||
106 | int y = -1; | ||
107 | |||
108 | status = read_register(data->client, GENERNAL_STATUS_REG); | ||
109 | |||
110 | if (status & (MAX11801_FIFO_INT | MAX11801_FIFO_OVERFLOW)) { | ||
111 | status = read_register(data->client, GENERNAL_STATUS_REG); | ||
112 | |||
113 | ret = i2c_smbus_read_i2c_block_data(client, FIFO_RD_CMD, | ||
114 | XY_BUFSIZE, buf); | ||
115 | |||
116 | /* | ||
117 | * We should get 4 bytes buffer that contains X,Y | ||
118 | * and event tag | ||
119 | */ | ||
120 | if (ret < XY_BUFSIZE) | ||
121 | goto out; | ||
122 | |||
123 | for (i = 0; i < XY_BUFSIZE; i += XY_BUFSIZE / 2) { | ||
124 | if ((buf[i + 1] & MEASURE_TAG_MASK) == MEASURE_X_TAG) | ||
125 | x = (buf[i] << XY_BUF_OFFSET) + | ||
126 | (buf[i + 1] >> XY_BUF_OFFSET); | ||
127 | else if ((buf[i + 1] & MEASURE_TAG_MASK) == MEASURE_Y_TAG) | ||
128 | y = (buf[i] << XY_BUF_OFFSET) + | ||
129 | (buf[i + 1] >> XY_BUF_OFFSET); | ||
130 | } | ||
131 | |||
132 | if ((buf[1] & EVENT_TAG_MASK) != (buf[3] & EVENT_TAG_MASK)) | ||
133 | goto out; | ||
134 | |||
135 | switch (buf[1] & EVENT_TAG_MASK) { | ||
136 | case EVENT_INIT: | ||
137 | /* fall through */ | ||
138 | case EVENT_MIDDLE: | ||
139 | input_report_abs(data->input_dev, ABS_X, x); | ||
140 | input_report_abs(data->input_dev, ABS_Y, y); | ||
141 | input_event(data->input_dev, EV_KEY, BTN_TOUCH, 1); | ||
142 | input_sync(data->input_dev); | ||
143 | break; | ||
144 | |||
145 | case EVENT_RELEASE: | ||
146 | input_event(data->input_dev, EV_KEY, BTN_TOUCH, 0); | ||
147 | input_sync(data->input_dev); | ||
148 | break; | ||
149 | |||
150 | case EVENT_FIFO_END: | ||
151 | break; | ||
152 | } | ||
153 | } | ||
154 | out: | ||
155 | return IRQ_HANDLED; | ||
156 | } | ||
157 | |||
158 | static void __devinit max11801_ts_phy_init(struct max11801_data *data) | ||
159 | { | ||
160 | struct i2c_client *client = data->client; | ||
161 | |||
162 | /* Average X,Y, take 16 samples, average eight media sample */ | ||
163 | max11801_write_reg(client, MESURE_AVER_CONF_REG, 0xff); | ||
164 | /* X,Y panel setup time set to 20us */ | ||
165 | max11801_write_reg(client, PANEL_SETUPTIME_CONF_REG, 0x11); | ||
166 | /* Rough pullup time (2uS), Fine pullup time (10us) */ | ||
167 | max11801_write_reg(client, TOUCH_DETECT_PULLUP_CONF_REG, 0x10); | ||
168 | /* Auto mode init period = 5ms , scan period = 5ms*/ | ||
169 | max11801_write_reg(client, AUTO_MODE_TIME_CONF_REG, 0xaa); | ||
170 | /* Aperture X,Y set to +- 4LSB */ | ||
171 | max11801_write_reg(client, APERTURE_CONF_REG, 0x33); | ||
172 | /* Enable Power, enable Automode, enable Aperture, enable Average X,Y */ | ||
173 | max11801_write_reg(client, OP_MODE_CONF_REG, 0x36); | ||
174 | } | ||
175 | |||
176 | static int __devinit max11801_ts_probe(struct i2c_client *client, | ||
177 | const struct i2c_device_id *id) | ||
178 | { | ||
179 | struct max11801_data *data; | ||
180 | struct input_dev *input_dev; | ||
181 | int error; | ||
182 | |||
183 | data = kzalloc(sizeof(struct max11801_data), GFP_KERNEL); | ||
184 | input_dev = input_allocate_device(); | ||
185 | if (!data || !input_dev) { | ||
186 | dev_err(&client->dev, "Failed to allocate memory\n"); | ||
187 | error = -ENOMEM; | ||
188 | goto err_free_mem; | ||
189 | } | ||
190 | |||
191 | data->client = client; | ||
192 | data->input_dev = input_dev; | ||
193 | |||
194 | input_dev->name = "max11801_ts"; | ||
195 | input_dev->id.bustype = BUS_I2C; | ||
196 | input_dev->dev.parent = &client->dev; | ||
197 | |||
198 | __set_bit(EV_ABS, input_dev->evbit); | ||
199 | __set_bit(EV_KEY, input_dev->evbit); | ||
200 | __set_bit(BTN_TOUCH, input_dev->keybit); | ||
201 | input_set_abs_params(input_dev, ABS_X, 0, MAX11801_MAX_X, 0, 0); | ||
202 | input_set_abs_params(input_dev, ABS_Y, 0, MAX11801_MAX_Y, 0, 0); | ||
203 | input_set_drvdata(input_dev, data); | ||
204 | |||
205 | max11801_ts_phy_init(data); | ||
206 | |||
207 | error = request_threaded_irq(client->irq, NULL, max11801_ts_interrupt, | ||
208 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, | ||
209 | "max11801_ts", data); | ||
210 | if (error) { | ||
211 | dev_err(&client->dev, "Failed to register interrupt\n"); | ||
212 | goto err_free_mem; | ||
213 | } | ||
214 | |||
215 | error = input_register_device(data->input_dev); | ||
216 | if (error) | ||
217 | goto err_free_irq; | ||
218 | |||
219 | i2c_set_clientdata(client, data); | ||
220 | return 0; | ||
221 | |||
222 | err_free_irq: | ||
223 | free_irq(client->irq, data); | ||
224 | err_free_mem: | ||
225 | input_free_device(input_dev); | ||
226 | kfree(data); | ||
227 | return error; | ||
228 | } | ||
229 | |||
230 | static __devexit int max11801_ts_remove(struct i2c_client *client) | ||
231 | { | ||
232 | struct max11801_data *data = i2c_get_clientdata(client); | ||
233 | |||
234 | free_irq(client->irq, data); | ||
235 | input_unregister_device(data->input_dev); | ||
236 | kfree(data); | ||
237 | |||
238 | return 0; | ||
239 | } | ||
240 | |||
241 | static const struct i2c_device_id max11801_ts_id[] = { | ||
242 | {"max11801", 0}, | ||
243 | { } | ||
244 | }; | ||
245 | MODULE_DEVICE_TABLE(i2c, max11801_ts_id); | ||
246 | |||
247 | static struct i2c_driver max11801_ts_driver = { | ||
248 | .driver = { | ||
249 | .name = "max11801_ts", | ||
250 | .owner = THIS_MODULE, | ||
251 | }, | ||
252 | .id_table = max11801_ts_id, | ||
253 | .probe = max11801_ts_probe, | ||
254 | .remove = __devexit_p(max11801_ts_remove), | ||
255 | }; | ||
256 | |||
257 | static int __init max11801_ts_init(void) | ||
258 | { | ||
259 | return i2c_add_driver(&max11801_ts_driver); | ||
260 | } | ||
261 | |||
262 | static void __exit max11801_ts_exit(void) | ||
263 | { | ||
264 | i2c_del_driver(&max11801_ts_driver); | ||
265 | } | ||
266 | |||
267 | module_init(max11801_ts_init); | ||
268 | module_exit(max11801_ts_exit); | ||
269 | |||
270 | MODULE_AUTHOR("Zhang Jiejing <jiejing.zhang@freescale.com>"); | ||
271 | MODULE_DESCRIPTION("Touchscreen driver for MAXI MAX11801 controller"); | ||
272 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/input/touchscreen/tps6507x-ts.c b/drivers/input/touchscreen/tps6507x-ts.c index c8c136cf7bbc..43031492d733 100644 --- a/drivers/input/touchscreen/tps6507x-ts.c +++ b/drivers/input/touchscreen/tps6507x-ts.c | |||
@@ -43,7 +43,6 @@ struct tps6507x_ts { | |||
43 | struct input_dev *input_dev; | 43 | struct input_dev *input_dev; |
44 | struct device *dev; | 44 | struct device *dev; |
45 | char phys[32]; | 45 | char phys[32]; |
46 | struct workqueue_struct *wq; | ||
47 | struct delayed_work work; | 46 | struct delayed_work work; |
48 | unsigned polling; /* polling is active */ | 47 | unsigned polling; /* polling is active */ |
49 | struct ts_event tc; | 48 | struct ts_event tc; |
@@ -220,8 +219,8 @@ done: | |||
220 | poll = 1; | 219 | poll = 1; |
221 | 220 | ||
222 | if (poll) { | 221 | if (poll) { |
223 | schd = queue_delayed_work(tsc->wq, &tsc->work, | 222 | schd = schedule_delayed_work(&tsc->work, |
224 | msecs_to_jiffies(tsc->poll_period)); | 223 | msecs_to_jiffies(tsc->poll_period)); |
225 | if (schd) | 224 | if (schd) |
226 | tsc->polling = 1; | 225 | tsc->polling = 1; |
227 | else { | 226 | else { |
@@ -303,7 +302,6 @@ static int tps6507x_ts_probe(struct platform_device *pdev) | |||
303 | tsc->input_dev = input_dev; | 302 | tsc->input_dev = input_dev; |
304 | 303 | ||
305 | INIT_DELAYED_WORK(&tsc->work, tps6507x_ts_handler); | 304 | INIT_DELAYED_WORK(&tsc->work, tps6507x_ts_handler); |
306 | tsc->wq = create_workqueue("TPS6507x Touchscreen"); | ||
307 | 305 | ||
308 | if (init_data) { | 306 | if (init_data) { |
309 | tsc->poll_period = init_data->poll_period; | 307 | tsc->poll_period = init_data->poll_period; |
@@ -325,8 +323,8 @@ static int tps6507x_ts_probe(struct platform_device *pdev) | |||
325 | if (error) | 323 | if (error) |
326 | goto err2; | 324 | goto err2; |
327 | 325 | ||
328 | schd = queue_delayed_work(tsc->wq, &tsc->work, | 326 | schd = schedule_delayed_work(&tsc->work, |
329 | msecs_to_jiffies(tsc->poll_period)); | 327 | msecs_to_jiffies(tsc->poll_period)); |
330 | 328 | ||
331 | if (schd) | 329 | if (schd) |
332 | tsc->polling = 1; | 330 | tsc->polling = 1; |
@@ -341,7 +339,6 @@ static int tps6507x_ts_probe(struct platform_device *pdev) | |||
341 | 339 | ||
342 | err2: | 340 | err2: |
343 | cancel_delayed_work_sync(&tsc->work); | 341 | cancel_delayed_work_sync(&tsc->work); |
344 | destroy_workqueue(tsc->wq); | ||
345 | input_free_device(input_dev); | 342 | input_free_device(input_dev); |
346 | err1: | 343 | err1: |
347 | kfree(tsc); | 344 | kfree(tsc); |
@@ -357,7 +354,6 @@ static int __devexit tps6507x_ts_remove(struct platform_device *pdev) | |||
357 | struct input_dev *input_dev = tsc->input_dev; | 354 | struct input_dev *input_dev = tsc->input_dev; |
358 | 355 | ||
359 | cancel_delayed_work_sync(&tsc->work); | 356 | cancel_delayed_work_sync(&tsc->work); |
360 | destroy_workqueue(tsc->wq); | ||
361 | 357 | ||
362 | input_unregister_device(input_dev); | 358 | input_unregister_device(input_dev); |
363 | 359 | ||
diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c index 80467f262331..fadc11545b1e 100644 --- a/drivers/input/touchscreen/tsc2007.c +++ b/drivers/input/touchscreen/tsc2007.c | |||
@@ -27,9 +27,6 @@ | |||
27 | #include <linux/i2c.h> | 27 | #include <linux/i2c.h> |
28 | #include <linux/i2c/tsc2007.h> | 28 | #include <linux/i2c/tsc2007.h> |
29 | 29 | ||
30 | #define TS_POLL_DELAY 1 /* ms delay between samples */ | ||
31 | #define TS_POLL_PERIOD 1 /* ms delay between samples */ | ||
32 | |||
33 | #define TSC2007_MEASURE_TEMP0 (0x0 << 4) | 30 | #define TSC2007_MEASURE_TEMP0 (0x0 << 4) |
34 | #define TSC2007_MEASURE_AUX (0x2 << 4) | 31 | #define TSC2007_MEASURE_AUX (0x2 << 4) |
35 | #define TSC2007_MEASURE_TEMP1 (0x4 << 4) | 32 | #define TSC2007_MEASURE_TEMP1 (0x4 << 4) |
@@ -75,6 +72,9 @@ struct tsc2007 { | |||
75 | 72 | ||
76 | u16 model; | 73 | u16 model; |
77 | u16 x_plate_ohms; | 74 | u16 x_plate_ohms; |
75 | u16 max_rt; | ||
76 | unsigned long poll_delay; | ||
77 | unsigned long poll_period; | ||
78 | 78 | ||
79 | bool pendown; | 79 | bool pendown; |
80 | int irq; | 80 | int irq; |
@@ -156,6 +156,7 @@ static void tsc2007_work(struct work_struct *work) | |||
156 | { | 156 | { |
157 | struct tsc2007 *ts = | 157 | struct tsc2007 *ts = |
158 | container_of(to_delayed_work(work), struct tsc2007, work); | 158 | container_of(to_delayed_work(work), struct tsc2007, work); |
159 | bool debounced = false; | ||
159 | struct ts_event tc; | 160 | struct ts_event tc; |
160 | u32 rt; | 161 | u32 rt; |
161 | 162 | ||
@@ -184,13 +185,14 @@ static void tsc2007_work(struct work_struct *work) | |||
184 | tsc2007_read_values(ts, &tc); | 185 | tsc2007_read_values(ts, &tc); |
185 | 186 | ||
186 | rt = tsc2007_calculate_pressure(ts, &tc); | 187 | rt = tsc2007_calculate_pressure(ts, &tc); |
187 | if (rt > MAX_12BIT) { | 188 | if (rt > ts->max_rt) { |
188 | /* | 189 | /* |
189 | * Sample found inconsistent by debouncing or pressure is | 190 | * Sample found inconsistent by debouncing or pressure is |
190 | * beyond the maximum. Don't report it to user space, | 191 | * beyond the maximum. Don't report it to user space, |
191 | * repeat at least once more the measurement. | 192 | * repeat at least once more the measurement. |
192 | */ | 193 | */ |
193 | dev_dbg(&ts->client->dev, "ignored pressure %d\n", rt); | 194 | dev_dbg(&ts->client->dev, "ignored pressure %d\n", rt); |
195 | debounced = true; | ||
194 | goto out; | 196 | goto out; |
195 | 197 | ||
196 | } | 198 | } |
@@ -225,9 +227,9 @@ static void tsc2007_work(struct work_struct *work) | |||
225 | } | 227 | } |
226 | 228 | ||
227 | out: | 229 | out: |
228 | if (ts->pendown) | 230 | if (ts->pendown || debounced) |
229 | schedule_delayed_work(&ts->work, | 231 | schedule_delayed_work(&ts->work, |
230 | msecs_to_jiffies(TS_POLL_PERIOD)); | 232 | msecs_to_jiffies(ts->poll_period)); |
231 | else | 233 | else |
232 | enable_irq(ts->irq); | 234 | enable_irq(ts->irq); |
233 | } | 235 | } |
@@ -239,7 +241,7 @@ static irqreturn_t tsc2007_irq(int irq, void *handle) | |||
239 | if (!ts->get_pendown_state || likely(ts->get_pendown_state())) { | 241 | if (!ts->get_pendown_state || likely(ts->get_pendown_state())) { |
240 | disable_irq_nosync(ts->irq); | 242 | disable_irq_nosync(ts->irq); |
241 | schedule_delayed_work(&ts->work, | 243 | schedule_delayed_work(&ts->work, |
242 | msecs_to_jiffies(TS_POLL_DELAY)); | 244 | msecs_to_jiffies(ts->poll_delay)); |
243 | } | 245 | } |
244 | 246 | ||
245 | if (ts->clear_penirq) | 247 | if (ts->clear_penirq) |
@@ -292,6 +294,9 @@ static int __devinit tsc2007_probe(struct i2c_client *client, | |||
292 | 294 | ||
293 | ts->model = pdata->model; | 295 | ts->model = pdata->model; |
294 | ts->x_plate_ohms = pdata->x_plate_ohms; | 296 | ts->x_plate_ohms = pdata->x_plate_ohms; |
297 | ts->max_rt = pdata->max_rt ? : MAX_12BIT; | ||
298 | ts->poll_delay = pdata->poll_delay ? : 1; | ||
299 | ts->poll_period = pdata->poll_period ? : 1; | ||
295 | ts->get_pendown_state = pdata->get_pendown_state; | 300 | ts->get_pendown_state = pdata->get_pendown_state; |
296 | ts->clear_penirq = pdata->clear_penirq; | 301 | ts->clear_penirq = pdata->clear_penirq; |
297 | 302 | ||
@@ -305,9 +310,10 @@ static int __devinit tsc2007_probe(struct i2c_client *client, | |||
305 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | 310 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
306 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); | 311 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
307 | 312 | ||
308 | input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0); | 313 | input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, pdata->fuzzx, 0); |
309 | input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0); | 314 | input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, pdata->fuzzy, 0); |
310 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT, 0, 0); | 315 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT, |
316 | pdata->fuzzz, 0); | ||
311 | 317 | ||
312 | if (pdata->init_platform_hw) | 318 | if (pdata->init_platform_hw) |
313 | pdata->init_platform_hw(); | 319 | pdata->init_platform_hw(); |
diff --git a/drivers/input/touchscreen/ucb1400_ts.c b/drivers/input/touchscreen/ucb1400_ts.c index 028a5363eea1..3b5b5df04dd6 100644 --- a/drivers/input/touchscreen/ucb1400_ts.c +++ b/drivers/input/touchscreen/ucb1400_ts.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * Copyright: MontaVista Software, Inc. | 6 | * Copyright: MontaVista Software, Inc. |
7 | * | 7 | * |
8 | * Spliting done by: Marek Vasut <marek.vasut@gmail.com> | 8 | * Spliting done by: Marek Vasut <marek.vasut@gmail.com> |
9 | * If something doesnt work and it worked before spliting, e-mail me, | 9 | * If something doesn't work and it worked before spliting, e-mail me, |
10 | * dont bother Nicolas please ;-) | 10 | * dont bother Nicolas please ;-) |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or modify | 12 | * This program is free software; you can redistribute it and/or modify |
diff --git a/drivers/input/touchscreen/wm9705.c b/drivers/input/touchscreen/wm9705.c index 6b5be742c27d..98e61175d3f5 100644 --- a/drivers/input/touchscreen/wm9705.c +++ b/drivers/input/touchscreen/wm9705.c | |||
@@ -306,7 +306,7 @@ static int wm9705_acc_enable(struct wm97xx *wm, int enable) | |||
306 | dig2 = wm->dig[2]; | 306 | dig2 = wm->dig[2]; |
307 | 307 | ||
308 | if (enable) { | 308 | if (enable) { |
309 | /* continous mode */ | 309 | /* continuous mode */ |
310 | if (wm->mach_ops->acc_startup && | 310 | if (wm->mach_ops->acc_startup && |
311 | (ret = wm->mach_ops->acc_startup(wm)) < 0) | 311 | (ret = wm->mach_ops->acc_startup(wm)) < 0) |
312 | return ret; | 312 | return ret; |
diff --git a/drivers/input/touchscreen/wm9712.c b/drivers/input/touchscreen/wm9712.c index 7490b05c3566..2bc2fb801009 100644 --- a/drivers/input/touchscreen/wm9712.c +++ b/drivers/input/touchscreen/wm9712.c | |||
@@ -419,7 +419,7 @@ static int wm9712_acc_enable(struct wm97xx *wm, int enable) | |||
419 | dig2 = wm->dig[2]; | 419 | dig2 = wm->dig[2]; |
420 | 420 | ||
421 | if (enable) { | 421 | if (enable) { |
422 | /* continous mode */ | 422 | /* continuous mode */ |
423 | if (wm->mach_ops->acc_startup) { | 423 | if (wm->mach_ops->acc_startup) { |
424 | ret = wm->mach_ops->acc_startup(wm); | 424 | ret = wm->mach_ops->acc_startup(wm); |
425 | if (ret < 0) | 425 | if (ret < 0) |
diff --git a/drivers/input/touchscreen/wm9713.c b/drivers/input/touchscreen/wm9713.c index 238b5132712e..73ec99568f12 100644 --- a/drivers/input/touchscreen/wm9713.c +++ b/drivers/input/touchscreen/wm9713.c | |||
@@ -431,7 +431,7 @@ static int wm9713_acc_enable(struct wm97xx *wm, int enable) | |||
431 | dig3 = wm->dig[2]; | 431 | dig3 = wm->dig[2]; |
432 | 432 | ||
433 | if (enable) { | 433 | if (enable) { |
434 | /* continous mode */ | 434 | /* continuous mode */ |
435 | if (wm->mach_ops->acc_startup && | 435 | if (wm->mach_ops->acc_startup && |
436 | (ret = wm->mach_ops->acc_startup(wm)) < 0) | 436 | (ret = wm->mach_ops->acc_startup(wm)) < 0) |
437 | return ret; | 437 | return ret; |
diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c index 6b75c9f660ae..5dbe73af2f8f 100644 --- a/drivers/input/touchscreen/wm97xx-core.c +++ b/drivers/input/touchscreen/wm97xx-core.c | |||
@@ -335,7 +335,7 @@ static void wm97xx_pen_irq_worker(struct work_struct *work) | |||
335 | */ | 335 | */ |
336 | if (!wm->mach_ops->acc_enabled || wm->mach_ops->acc_pen_down) { | 336 | if (!wm->mach_ops->acc_enabled || wm->mach_ops->acc_pen_down) { |
337 | if (wm->pen_is_down && !pen_was_down) { | 337 | if (wm->pen_is_down && !pen_was_down) { |
338 | /* Data is not availiable immediately on pen down */ | 338 | /* Data is not available immediately on pen down */ |
339 | queue_delayed_work(wm->ts_workq, &wm->ts_reader, 1); | 339 | queue_delayed_work(wm->ts_workq, &wm->ts_reader, 1); |
340 | } | 340 | } |
341 | 341 | ||
@@ -354,7 +354,7 @@ static void wm97xx_pen_irq_worker(struct work_struct *work) | |||
354 | * Codec PENDOWN irq handler | 354 | * Codec PENDOWN irq handler |
355 | * | 355 | * |
356 | * We have to disable the codec interrupt in the handler because it | 356 | * We have to disable the codec interrupt in the handler because it |
357 | * can take upto 1ms to clear the interrupt source. We schedule a task | 357 | * can take up to 1ms to clear the interrupt source. We schedule a task |
358 | * in a work queue to do the actual interaction with the chip. The | 358 | * in a work queue to do the actual interaction with the chip. The |
359 | * interrupt is then enabled again in the slow handler when the source | 359 | * interrupt is then enabled again in the slow handler when the source |
360 | * has been cleared. | 360 | * has been cleared. |
diff --git a/drivers/input/touchscreen/zylonite-wm97xx.c b/drivers/input/touchscreen/zylonite-wm97xx.c index 048849867643..5b0f15ec874a 100644 --- a/drivers/input/touchscreen/zylonite-wm97xx.c +++ b/drivers/input/touchscreen/zylonite-wm97xx.c | |||
@@ -193,7 +193,7 @@ static int zylonite_wm97xx_probe(struct platform_device *pdev) | |||
193 | gpio_touch_irq = mfp_to_gpio(MFP_PIN_GPIO26); | 193 | gpio_touch_irq = mfp_to_gpio(MFP_PIN_GPIO26); |
194 | 194 | ||
195 | wm->pen_irq = IRQ_GPIO(gpio_touch_irq); | 195 | wm->pen_irq = IRQ_GPIO(gpio_touch_irq); |
196 | set_irq_type(IRQ_GPIO(gpio_touch_irq), IRQ_TYPE_EDGE_BOTH); | 196 | irq_set_irq_type(IRQ_GPIO(gpio_touch_irq), IRQ_TYPE_EDGE_BOTH); |
197 | 197 | ||
198 | wm97xx_config_gpio(wm, WM97XX_GPIO_13, WM97XX_GPIO_IN, | 198 | wm97xx_config_gpio(wm, WM97XX_GPIO_13, WM97XX_GPIO_IN, |
199 | WM97XX_GPIO_POL_HIGH, | 199 | WM97XX_GPIO_POL_HIGH, |