diff options
Diffstat (limited to 'drivers/input')
23 files changed, 990 insertions, 1814 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index e3f7fc6f9565..68f09a868434 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c | |||
@@ -534,76 +534,73 @@ static int handle_eviocgbit(struct input_dev *dev, | |||
534 | } | 534 | } |
535 | #undef OLD_KEY_MAX | 535 | #undef OLD_KEY_MAX |
536 | 536 | ||
537 | static int evdev_handle_get_keycode(struct input_dev *dev, | 537 | static int evdev_handle_get_keycode(struct input_dev *dev, void __user *p) |
538 | void __user *p, size_t size) | ||
539 | { | 538 | { |
540 | struct input_keymap_entry ke; | 539 | struct input_keymap_entry ke = { |
540 | .len = sizeof(unsigned int), | ||
541 | .flags = 0, | ||
542 | }; | ||
543 | int __user *ip = (int __user *)p; | ||
541 | int error; | 544 | int error; |
542 | 545 | ||
543 | memset(&ke, 0, sizeof(ke)); | 546 | /* legacy case */ |
544 | 547 | if (copy_from_user(ke.scancode, p, sizeof(unsigned int))) | |
545 | if (size == sizeof(unsigned int[2])) { | 548 | return -EFAULT; |
546 | /* legacy case */ | ||
547 | int __user *ip = (int __user *)p; | ||
548 | 549 | ||
549 | if (copy_from_user(ke.scancode, p, sizeof(unsigned int))) | 550 | error = input_get_keycode(dev, &ke); |
550 | return -EFAULT; | 551 | if (error) |
552 | return error; | ||
551 | 553 | ||
552 | ke.len = sizeof(unsigned int); | 554 | if (put_user(ke.keycode, ip + 1)) |
553 | ke.flags = 0; | 555 | return -EFAULT; |
554 | 556 | ||
555 | error = input_get_keycode(dev, &ke); | 557 | return 0; |
556 | if (error) | 558 | } |
557 | return error; | ||
558 | 559 | ||
559 | if (put_user(ke.keycode, ip + 1)) | 560 | static int evdev_handle_get_keycode_v2(struct input_dev *dev, void __user *p) |
560 | return -EFAULT; | 561 | { |
562 | struct input_keymap_entry ke; | ||
563 | int error; | ||
561 | 564 | ||
562 | } else { | 565 | if (copy_from_user(&ke, p, sizeof(ke))) |
563 | size = min(size, sizeof(ke)); | 566 | return -EFAULT; |
564 | 567 | ||
565 | if (copy_from_user(&ke, p, size)) | 568 | error = input_get_keycode(dev, &ke); |
566 | return -EFAULT; | 569 | if (error) |
570 | return error; | ||
567 | 571 | ||
568 | error = input_get_keycode(dev, &ke); | 572 | if (copy_to_user(p, &ke, sizeof(ke))) |
569 | if (error) | 573 | return -EFAULT; |
570 | return error; | ||
571 | 574 | ||
572 | if (copy_to_user(p, &ke, size)) | ||
573 | return -EFAULT; | ||
574 | } | ||
575 | return 0; | 575 | return 0; |
576 | } | 576 | } |
577 | 577 | ||
578 | static int evdev_handle_set_keycode(struct input_dev *dev, | 578 | static int evdev_handle_set_keycode(struct input_dev *dev, void __user *p) |
579 | void __user *p, size_t size) | ||
580 | { | 579 | { |
581 | struct input_keymap_entry ke; | 580 | struct input_keymap_entry ke = { |
582 | 581 | .len = sizeof(unsigned int), | |
583 | memset(&ke, 0, sizeof(ke)); | 582 | .flags = 0, |
583 | }; | ||
584 | int __user *ip = (int __user *)p; | ||
584 | 585 | ||
585 | if (size == sizeof(unsigned int[2])) { | 586 | if (copy_from_user(ke.scancode, p, sizeof(unsigned int))) |
586 | /* legacy case */ | 587 | return -EFAULT; |
587 | int __user *ip = (int __user *)p; | ||
588 | 588 | ||
589 | if (copy_from_user(ke.scancode, p, sizeof(unsigned int))) | 589 | if (get_user(ke.keycode, ip + 1)) |
590 | return -EFAULT; | 590 | return -EFAULT; |
591 | 591 | ||
592 | if (get_user(ke.keycode, ip + 1)) | 592 | return input_set_keycode(dev, &ke); |
593 | return -EFAULT; | 593 | } |
594 | 594 | ||
595 | ke.len = sizeof(unsigned int); | 595 | static int evdev_handle_set_keycode_v2(struct input_dev *dev, void __user *p) |
596 | ke.flags = 0; | 596 | { |
597 | struct input_keymap_entry ke; | ||
597 | 598 | ||
598 | } else { | 599 | if (copy_from_user(&ke, p, sizeof(ke))) |
599 | size = min(size, sizeof(ke)); | 600 | return -EFAULT; |
600 | 601 | ||
601 | if (copy_from_user(&ke, p, size)) | 602 | if (ke.len > sizeof(ke.scancode)) |
602 | return -EFAULT; | 603 | return -EINVAL; |
603 | |||
604 | if (ke.len > sizeof(ke.scancode)) | ||
605 | return -EINVAL; | ||
606 | } | ||
607 | 604 | ||
608 | return input_set_keycode(dev, &ke); | 605 | return input_set_keycode(dev, &ke); |
609 | } | 606 | } |
@@ -669,6 +666,18 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd, | |||
669 | return evdev_grab(evdev, client); | 666 | return evdev_grab(evdev, client); |
670 | else | 667 | else |
671 | return evdev_ungrab(evdev, client); | 668 | return evdev_ungrab(evdev, client); |
669 | |||
670 | case EVIOCGKEYCODE: | ||
671 | return evdev_handle_get_keycode(dev, p); | ||
672 | |||
673 | case EVIOCSKEYCODE: | ||
674 | return evdev_handle_set_keycode(dev, p); | ||
675 | |||
676 | case EVIOCGKEYCODE_V2: | ||
677 | return evdev_handle_get_keycode_v2(dev, p); | ||
678 | |||
679 | case EVIOCSKEYCODE_V2: | ||
680 | return evdev_handle_set_keycode_v2(dev, p); | ||
672 | } | 681 | } |
673 | 682 | ||
674 | size = _IOC_SIZE(cmd); | 683 | size = _IOC_SIZE(cmd); |
@@ -708,12 +717,6 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd, | |||
708 | return -EFAULT; | 717 | return -EFAULT; |
709 | 718 | ||
710 | return error; | 719 | return error; |
711 | |||
712 | case EVIOC_MASK_SIZE(EVIOCGKEYCODE): | ||
713 | return evdev_handle_get_keycode(dev, p, size); | ||
714 | |||
715 | case EVIOC_MASK_SIZE(EVIOCSKEYCODE): | ||
716 | return evdev_handle_set_keycode(dev, p, size); | ||
717 | } | 720 | } |
718 | 721 | ||
719 | /* Multi-number variable-length handlers */ | 722 | /* Multi-number variable-length handlers */ |
diff --git a/drivers/input/input.c b/drivers/input/input.c index d092ef9291da..db409d6bd5d2 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <linux/device.h> | 24 | #include <linux/device.h> |
25 | #include <linux/mutex.h> | 25 | #include <linux/mutex.h> |
26 | #include <linux/rcupdate.h> | 26 | #include <linux/rcupdate.h> |
27 | #include <linux/smp_lock.h> | ||
28 | #include "input-compat.h" | 27 | #include "input-compat.h" |
29 | 28 | ||
30 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); | 29 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); |
@@ -74,6 +73,7 @@ static int input_defuzz_abs_event(int value, int old_val, int fuzz) | |||
74 | * dev->event_lock held and interrupts disabled. | 73 | * dev->event_lock held and interrupts disabled. |
75 | */ | 74 | */ |
76 | static void input_pass_event(struct input_dev *dev, | 75 | static void input_pass_event(struct input_dev *dev, |
76 | struct input_handler *src_handler, | ||
77 | unsigned int type, unsigned int code, int value) | 77 | unsigned int type, unsigned int code, int value) |
78 | { | 78 | { |
79 | struct input_handler *handler; | 79 | struct input_handler *handler; |
@@ -92,6 +92,15 @@ static void input_pass_event(struct input_dev *dev, | |||
92 | continue; | 92 | continue; |
93 | 93 | ||
94 | handler = handle->handler; | 94 | handler = handle->handler; |
95 | |||
96 | /* | ||
97 | * If this is the handler that injected this | ||
98 | * particular event we want to skip it to avoid | ||
99 | * filters firing again and again. | ||
100 | */ | ||
101 | if (handler == src_handler) | ||
102 | continue; | ||
103 | |||
95 | if (!handler->filter) { | 104 | if (!handler->filter) { |
96 | if (filtered) | 105 | if (filtered) |
97 | break; | 106 | break; |
@@ -121,7 +130,7 @@ static void input_repeat_key(unsigned long data) | |||
121 | if (test_bit(dev->repeat_key, dev->key) && | 130 | if (test_bit(dev->repeat_key, dev->key) && |
122 | is_event_supported(dev->repeat_key, dev->keybit, KEY_MAX)) { | 131 | is_event_supported(dev->repeat_key, dev->keybit, KEY_MAX)) { |
123 | 132 | ||
124 | input_pass_event(dev, EV_KEY, dev->repeat_key, 2); | 133 | input_pass_event(dev, NULL, EV_KEY, dev->repeat_key, 2); |
125 | 134 | ||
126 | if (dev->sync) { | 135 | if (dev->sync) { |
127 | /* | 136 | /* |
@@ -130,7 +139,7 @@ static void input_repeat_key(unsigned long data) | |||
130 | * Otherwise assume that the driver will send | 139 | * Otherwise assume that the driver will send |
131 | * SYN_REPORT once it's done. | 140 | * SYN_REPORT once it's done. |
132 | */ | 141 | */ |
133 | input_pass_event(dev, EV_SYN, SYN_REPORT, 1); | 142 | input_pass_event(dev, NULL, EV_SYN, SYN_REPORT, 1); |
134 | } | 143 | } |
135 | 144 | ||
136 | if (dev->rep[REP_PERIOD]) | 145 | if (dev->rep[REP_PERIOD]) |
@@ -163,6 +172,7 @@ static void input_stop_autorepeat(struct input_dev *dev) | |||
163 | #define INPUT_PASS_TO_ALL (INPUT_PASS_TO_HANDLERS | INPUT_PASS_TO_DEVICE) | 172 | #define INPUT_PASS_TO_ALL (INPUT_PASS_TO_HANDLERS | INPUT_PASS_TO_DEVICE) |
164 | 173 | ||
165 | static int input_handle_abs_event(struct input_dev *dev, | 174 | static int input_handle_abs_event(struct input_dev *dev, |
175 | struct input_handler *src_handler, | ||
166 | unsigned int code, int *pval) | 176 | unsigned int code, int *pval) |
167 | { | 177 | { |
168 | bool is_mt_event; | 178 | bool is_mt_event; |
@@ -206,13 +216,15 @@ static int input_handle_abs_event(struct input_dev *dev, | |||
206 | /* Flush pending "slot" event */ | 216 | /* Flush pending "slot" event */ |
207 | if (is_mt_event && dev->slot != input_abs_get_val(dev, ABS_MT_SLOT)) { | 217 | if (is_mt_event && dev->slot != input_abs_get_val(dev, ABS_MT_SLOT)) { |
208 | input_abs_set_val(dev, ABS_MT_SLOT, dev->slot); | 218 | input_abs_set_val(dev, ABS_MT_SLOT, dev->slot); |
209 | input_pass_event(dev, EV_ABS, ABS_MT_SLOT, dev->slot); | 219 | input_pass_event(dev, src_handler, |
220 | EV_ABS, ABS_MT_SLOT, dev->slot); | ||
210 | } | 221 | } |
211 | 222 | ||
212 | return INPUT_PASS_TO_HANDLERS; | 223 | return INPUT_PASS_TO_HANDLERS; |
213 | } | 224 | } |
214 | 225 | ||
215 | static void input_handle_event(struct input_dev *dev, | 226 | static void input_handle_event(struct input_dev *dev, |
227 | struct input_handler *src_handler, | ||
216 | unsigned int type, unsigned int code, int value) | 228 | unsigned int type, unsigned int code, int value) |
217 | { | 229 | { |
218 | int disposition = INPUT_IGNORE_EVENT; | 230 | int disposition = INPUT_IGNORE_EVENT; |
@@ -265,7 +277,8 @@ static void input_handle_event(struct input_dev *dev, | |||
265 | 277 | ||
266 | case EV_ABS: | 278 | case EV_ABS: |
267 | if (is_event_supported(code, dev->absbit, ABS_MAX)) | 279 | if (is_event_supported(code, dev->absbit, ABS_MAX)) |
268 | disposition = input_handle_abs_event(dev, code, &value); | 280 | disposition = input_handle_abs_event(dev, src_handler, |
281 | code, &value); | ||
269 | 282 | ||
270 | break; | 283 | break; |
271 | 284 | ||
@@ -323,7 +336,7 @@ static void input_handle_event(struct input_dev *dev, | |||
323 | dev->event(dev, type, code, value); | 336 | dev->event(dev, type, code, value); |
324 | 337 | ||
325 | if (disposition & INPUT_PASS_TO_HANDLERS) | 338 | if (disposition & INPUT_PASS_TO_HANDLERS) |
326 | input_pass_event(dev, type, code, value); | 339 | input_pass_event(dev, src_handler, type, code, value); |
327 | } | 340 | } |
328 | 341 | ||
329 | /** | 342 | /** |
@@ -352,7 +365,7 @@ void input_event(struct input_dev *dev, | |||
352 | 365 | ||
353 | spin_lock_irqsave(&dev->event_lock, flags); | 366 | spin_lock_irqsave(&dev->event_lock, flags); |
354 | add_input_randomness(type, code, value); | 367 | add_input_randomness(type, code, value); |
355 | input_handle_event(dev, type, code, value); | 368 | input_handle_event(dev, NULL, type, code, value); |
356 | spin_unlock_irqrestore(&dev->event_lock, flags); | 369 | spin_unlock_irqrestore(&dev->event_lock, flags); |
357 | } | 370 | } |
358 | } | 371 | } |
@@ -382,7 +395,8 @@ void input_inject_event(struct input_handle *handle, | |||
382 | rcu_read_lock(); | 395 | rcu_read_lock(); |
383 | grab = rcu_dereference(dev->grab); | 396 | grab = rcu_dereference(dev->grab); |
384 | if (!grab || grab == handle) | 397 | if (!grab || grab == handle) |
385 | input_handle_event(dev, type, code, value); | 398 | input_handle_event(dev, handle->handler, |
399 | type, code, value); | ||
386 | rcu_read_unlock(); | 400 | rcu_read_unlock(); |
387 | 401 | ||
388 | spin_unlock_irqrestore(&dev->event_lock, flags); | 402 | spin_unlock_irqrestore(&dev->event_lock, flags); |
@@ -595,10 +609,10 @@ static void input_dev_release_keys(struct input_dev *dev) | |||
595 | for (code = 0; code <= KEY_MAX; code++) { | 609 | for (code = 0; code <= KEY_MAX; code++) { |
596 | if (is_event_supported(code, dev->keybit, KEY_MAX) && | 610 | if (is_event_supported(code, dev->keybit, KEY_MAX) && |
597 | __test_and_clear_bit(code, dev->key)) { | 611 | __test_and_clear_bit(code, dev->key)) { |
598 | input_pass_event(dev, EV_KEY, code, 0); | 612 | input_pass_event(dev, NULL, EV_KEY, code, 0); |
599 | } | 613 | } |
600 | } | 614 | } |
601 | input_pass_event(dev, EV_SYN, SYN_REPORT, 1); | 615 | input_pass_event(dev, NULL, EV_SYN, SYN_REPORT, 1); |
602 | } | 616 | } |
603 | } | 617 | } |
604 | 618 | ||
@@ -738,7 +752,7 @@ static int input_default_setkeycode(struct input_dev *dev, | |||
738 | if (index >= dev->keycodemax) | 752 | if (index >= dev->keycodemax) |
739 | return -EINVAL; | 753 | return -EINVAL; |
740 | 754 | ||
741 | if (dev->keycodesize < sizeof(dev->keycode) && | 755 | if (dev->keycodesize < sizeof(ke->keycode) && |
742 | (ke->keycode >> (dev->keycodesize * 8))) | 756 | (ke->keycode >> (dev->keycodesize * 8))) |
743 | return -EINVAL; | 757 | return -EINVAL; |
744 | 758 | ||
@@ -873,9 +887,9 @@ int input_set_keycode(struct input_dev *dev, | |||
873 | !is_event_supported(old_keycode, dev->keybit, KEY_MAX) && | 887 | !is_event_supported(old_keycode, dev->keybit, KEY_MAX) && |
874 | __test_and_clear_bit(old_keycode, dev->key)) { | 888 | __test_and_clear_bit(old_keycode, dev->key)) { |
875 | 889 | ||
876 | input_pass_event(dev, EV_KEY, old_keycode, 0); | 890 | input_pass_event(dev, NULL, EV_KEY, old_keycode, 0); |
877 | if (dev->sync) | 891 | if (dev->sync) |
878 | input_pass_event(dev, EV_SYN, SYN_REPORT, 1); | 892 | input_pass_event(dev, NULL, EV_SYN, SYN_REPORT, 1); |
879 | } | 893 | } |
880 | 894 | ||
881 | out: | 895 | out: |
@@ -1565,8 +1579,7 @@ static int input_dev_uevent(struct device *device, struct kobj_uevent_env *env) | |||
1565 | } \ | 1579 | } \ |
1566 | } while (0) | 1580 | } while (0) |
1567 | 1581 | ||
1568 | #ifdef CONFIG_PM | 1582 | static void input_dev_toggle(struct input_dev *dev, bool activate) |
1569 | static void input_dev_reset(struct input_dev *dev, bool activate) | ||
1570 | { | 1583 | { |
1571 | if (!dev->event) | 1584 | if (!dev->event) |
1572 | return; | 1585 | return; |
@@ -1580,12 +1593,44 @@ static void input_dev_reset(struct input_dev *dev, bool activate) | |||
1580 | } | 1593 | } |
1581 | } | 1594 | } |
1582 | 1595 | ||
1596 | /** | ||
1597 | * input_reset_device() - reset/restore the state of input device | ||
1598 | * @dev: input device whose state needs to be reset | ||
1599 | * | ||
1600 | * This function tries to reset the state of an opened input device and | ||
1601 | * bring internal state and state if the hardware in sync with each other. | ||
1602 | * We mark all keys as released, restore LED state, repeat rate, etc. | ||
1603 | */ | ||
1604 | void input_reset_device(struct input_dev *dev) | ||
1605 | { | ||
1606 | mutex_lock(&dev->mutex); | ||
1607 | |||
1608 | if (dev->users) { | ||
1609 | input_dev_toggle(dev, true); | ||
1610 | |||
1611 | /* | ||
1612 | * Keys that have been pressed at suspend time are unlikely | ||
1613 | * to be still pressed when we resume. | ||
1614 | */ | ||
1615 | spin_lock_irq(&dev->event_lock); | ||
1616 | input_dev_release_keys(dev); | ||
1617 | spin_unlock_irq(&dev->event_lock); | ||
1618 | } | ||
1619 | |||
1620 | mutex_unlock(&dev->mutex); | ||
1621 | } | ||
1622 | EXPORT_SYMBOL(input_reset_device); | ||
1623 | |||
1624 | #ifdef CONFIG_PM | ||
1583 | static int input_dev_suspend(struct device *dev) | 1625 | static int input_dev_suspend(struct device *dev) |
1584 | { | 1626 | { |
1585 | struct input_dev *input_dev = to_input_dev(dev); | 1627 | struct input_dev *input_dev = to_input_dev(dev); |
1586 | 1628 | ||
1587 | mutex_lock(&input_dev->mutex); | 1629 | mutex_lock(&input_dev->mutex); |
1588 | input_dev_reset(input_dev, false); | 1630 | |
1631 | if (input_dev->users) | ||
1632 | input_dev_toggle(input_dev, false); | ||
1633 | |||
1589 | mutex_unlock(&input_dev->mutex); | 1634 | mutex_unlock(&input_dev->mutex); |
1590 | 1635 | ||
1591 | return 0; | 1636 | return 0; |
@@ -1595,18 +1640,7 @@ static int input_dev_resume(struct device *dev) | |||
1595 | { | 1640 | { |
1596 | struct input_dev *input_dev = to_input_dev(dev); | 1641 | struct input_dev *input_dev = to_input_dev(dev); |
1597 | 1642 | ||
1598 | mutex_lock(&input_dev->mutex); | 1643 | input_reset_device(input_dev); |
1599 | input_dev_reset(input_dev, true); | ||
1600 | |||
1601 | /* | ||
1602 | * Keys that have been pressed at suspend time are unlikely | ||
1603 | * to be still pressed when we resume. | ||
1604 | */ | ||
1605 | spin_lock_irq(&input_dev->event_lock); | ||
1606 | input_dev_release_keys(input_dev); | ||
1607 | spin_unlock_irq(&input_dev->event_lock); | ||
1608 | |||
1609 | mutex_unlock(&input_dev->mutex); | ||
1610 | 1644 | ||
1611 | return 0; | 1645 | return 0; |
1612 | } | 1646 | } |
diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c index d53b9e900234..27b6a3ce18ca 100644 --- a/drivers/input/joystick/turbografx.c +++ b/drivers/input/joystick/turbografx.c | |||
@@ -245,6 +245,7 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs) | |||
245 | goto err_free_tgfx; | 245 | goto err_free_tgfx; |
246 | } | 246 | } |
247 | 247 | ||
248 | parport_put_port(pp); | ||
248 | return tgfx; | 249 | return tgfx; |
249 | 250 | ||
250 | err_free_dev: | 251 | err_free_dev: |
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index b8c51b9781db..c76bd3183beb 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig | |||
@@ -179,6 +179,22 @@ config KEYBOARD_GPIO | |||
179 | To compile this driver as a module, choose M here: the | 179 | To compile this driver as a module, choose M here: the |
180 | module will be called gpio_keys. | 180 | module will be called gpio_keys. |
181 | 181 | ||
182 | config KEYBOARD_GPIO_POLLED | ||
183 | tristate "Polled GPIO buttons" | ||
184 | depends on GENERIC_GPIO | ||
185 | select INPUT_POLLDEV | ||
186 | help | ||
187 | This driver implements support for buttons connected | ||
188 | to GPIO pins that are not capable of generating interrupts. | ||
189 | |||
190 | Say Y here if your device has buttons connected | ||
191 | directly to such GPIO pins. Your board-specific | ||
192 | setup logic must also provide a platform device, | ||
193 | with configuration data saying which GPIOs are used. | ||
194 | |||
195 | To compile this driver as a module, choose M here: the | ||
196 | module will be called gpio_keys_polled. | ||
197 | |||
182 | config KEYBOARD_TCA6416 | 198 | config KEYBOARD_TCA6416 |
183 | tristate "TCA6416 Keypad Support" | 199 | tristate "TCA6416 Keypad Support" |
184 | depends on I2C | 200 | depends on I2C |
@@ -443,6 +459,16 @@ config KEYBOARD_OMAP4 | |||
443 | To compile this driver as a module, choose M here: the | 459 | To compile this driver as a module, choose M here: the |
444 | module will be called omap4-keypad. | 460 | module will be called omap4-keypad. |
445 | 461 | ||
462 | config KEYBOARD_TC3589X | ||
463 | tristate "TC3589X Keypad support" | ||
464 | depends on MFD_TC3589X | ||
465 | help | ||
466 | Say Y here if you want to use the keypad controller on | ||
467 | TC35892/3 I/O expander. | ||
468 | |||
469 | To compile this driver as a module, choose M here: the | ||
470 | module will be called tc3589x-keypad. | ||
471 | |||
446 | config KEYBOARD_TNETV107X | 472 | config KEYBOARD_TNETV107X |
447 | tristate "TI TNETV107X keypad support" | 473 | tristate "TI TNETV107X keypad support" |
448 | depends on ARCH_DAVINCI_TNETV107X | 474 | depends on ARCH_DAVINCI_TNETV107X |
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index a34452e8ebe2..2aa6ce248b71 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile | |||
@@ -14,6 +14,7 @@ obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o | |||
14 | obj-$(CONFIG_KEYBOARD_DAVINCI) += davinci_keyscan.o | 14 | obj-$(CONFIG_KEYBOARD_DAVINCI) += davinci_keyscan.o |
15 | obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o | 15 | obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o |
16 | obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o | 16 | obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o |
17 | obj-$(CONFIG_KEYBOARD_GPIO_POLLED) += gpio_keys_polled.o | ||
17 | obj-$(CONFIG_KEYBOARD_TCA6416) += tca6416-keypad.o | 18 | obj-$(CONFIG_KEYBOARD_TCA6416) += tca6416-keypad.o |
18 | obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o | 19 | obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o |
19 | obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o | 20 | obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o |
@@ -40,6 +41,7 @@ obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o | |||
40 | obj-$(CONFIG_KEYBOARD_STMPE) += stmpe-keypad.o | 41 | obj-$(CONFIG_KEYBOARD_STMPE) += stmpe-keypad.o |
41 | obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o | 42 | obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o |
42 | obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o | 43 | obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o |
44 | obj-$(CONFIG_KEYBOARD_TC3589X) += tc3589x-keypad.o | ||
43 | obj-$(CONFIG_KEYBOARD_TNETV107X) += tnetv107x-keypad.o | 45 | obj-$(CONFIG_KEYBOARD_TNETV107X) += tnetv107x-keypad.o |
44 | obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o | 46 | obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o |
45 | obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o | 47 | obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o |
diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c index b92d1cd5cba1..af45d275f686 100644 --- a/drivers/input/keyboard/adp5588-keys.c +++ b/drivers/input/keyboard/adp5588-keys.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * I2C QWERTY Keypad and IO Expander | 4 | * I2C QWERTY Keypad and IO Expander |
5 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ | 5 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ |
6 | * | 6 | * |
7 | * Copyright (C) 2008-2009 Analog Devices Inc. | 7 | * Copyright (C) 2008-2010 Analog Devices Inc. |
8 | * Licensed under the GPL-2 or later. | 8 | * Licensed under the GPL-2 or later. |
9 | */ | 9 | */ |
10 | 10 | ||
@@ -24,29 +24,6 @@ | |||
24 | 24 | ||
25 | #include <linux/i2c/adp5588.h> | 25 | #include <linux/i2c/adp5588.h> |
26 | 26 | ||
27 | /* Configuration Register1 */ | ||
28 | #define AUTO_INC (1 << 7) | ||
29 | #define GPIEM_CFG (1 << 6) | ||
30 | #define OVR_FLOW_M (1 << 5) | ||
31 | #define INT_CFG (1 << 4) | ||
32 | #define OVR_FLOW_IEN (1 << 3) | ||
33 | #define K_LCK_IM (1 << 2) | ||
34 | #define GPI_IEN (1 << 1) | ||
35 | #define KE_IEN (1 << 0) | ||
36 | |||
37 | /* Interrupt Status Register */ | ||
38 | #define CMP2_INT (1 << 5) | ||
39 | #define CMP1_INT (1 << 4) | ||
40 | #define OVR_FLOW_INT (1 << 3) | ||
41 | #define K_LCK_INT (1 << 2) | ||
42 | #define GPI_INT (1 << 1) | ||
43 | #define KE_INT (1 << 0) | ||
44 | |||
45 | /* Key Lock and Event Counter Register */ | ||
46 | #define K_LCK_EN (1 << 6) | ||
47 | #define LCK21 0x30 | ||
48 | #define KEC 0xF | ||
49 | |||
50 | /* Key Event Register xy */ | 27 | /* Key Event Register xy */ |
51 | #define KEY_EV_PRESSED (1 << 7) | 28 | #define KEY_EV_PRESSED (1 << 7) |
52 | #define KEY_EV_MASK (0x7F) | 29 | #define KEY_EV_MASK (0x7F) |
@@ -55,10 +32,6 @@ | |||
55 | 32 | ||
56 | #define KEYP_MAX_EVENT 10 | 33 | #define KEYP_MAX_EVENT 10 |
57 | 34 | ||
58 | #define MAXGPIO 18 | ||
59 | #define ADP_BANK(offs) ((offs) >> 3) | ||
60 | #define ADP_BIT(offs) (1u << ((offs) & 0x7)) | ||
61 | |||
62 | /* | 35 | /* |
63 | * Early pre 4.0 Silicon required to delay readout by at least 25ms, | 36 | * Early pre 4.0 Silicon required to delay readout by at least 25ms, |
64 | * since the Event Counter Register updated 25ms after the interrupt | 37 | * since the Event Counter Register updated 25ms after the interrupt |
@@ -75,7 +48,7 @@ struct adp5588_kpad { | |||
75 | const struct adp5588_gpi_map *gpimap; | 48 | const struct adp5588_gpi_map *gpimap; |
76 | unsigned short gpimapsize; | 49 | unsigned short gpimapsize; |
77 | #ifdef CONFIG_GPIOLIB | 50 | #ifdef CONFIG_GPIOLIB |
78 | unsigned char gpiomap[MAXGPIO]; | 51 | unsigned char gpiomap[ADP5588_MAXGPIO]; |
79 | bool export_gpio; | 52 | bool export_gpio; |
80 | struct gpio_chip gc; | 53 | struct gpio_chip gc; |
81 | struct mutex gpio_lock; /* Protect cached dir, dat_out */ | 54 | struct mutex gpio_lock; /* Protect cached dir, dat_out */ |
@@ -103,8 +76,8 @@ static int adp5588_write(struct i2c_client *client, u8 reg, u8 val) | |||
103 | static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off) | 76 | static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off) |
104 | { | 77 | { |
105 | struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); | 78 | struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); |
106 | unsigned int bank = ADP_BANK(kpad->gpiomap[off]); | 79 | unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); |
107 | unsigned int bit = ADP_BIT(kpad->gpiomap[off]); | 80 | unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]); |
108 | 81 | ||
109 | return !!(adp5588_read(kpad->client, GPIO_DAT_STAT1 + bank) & bit); | 82 | return !!(adp5588_read(kpad->client, GPIO_DAT_STAT1 + bank) & bit); |
110 | } | 83 | } |
@@ -113,8 +86,8 @@ static void adp5588_gpio_set_value(struct gpio_chip *chip, | |||
113 | unsigned off, int val) | 86 | unsigned off, int val) |
114 | { | 87 | { |
115 | struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); | 88 | struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); |
116 | unsigned int bank = ADP_BANK(kpad->gpiomap[off]); | 89 | unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); |
117 | unsigned int bit = ADP_BIT(kpad->gpiomap[off]); | 90 | unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]); |
118 | 91 | ||
119 | mutex_lock(&kpad->gpio_lock); | 92 | mutex_lock(&kpad->gpio_lock); |
120 | 93 | ||
@@ -132,8 +105,8 @@ static void adp5588_gpio_set_value(struct gpio_chip *chip, | |||
132 | static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned off) | 105 | static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned off) |
133 | { | 106 | { |
134 | struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); | 107 | struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); |
135 | unsigned int bank = ADP_BANK(kpad->gpiomap[off]); | 108 | unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); |
136 | unsigned int bit = ADP_BIT(kpad->gpiomap[off]); | 109 | unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]); |
137 | int ret; | 110 | int ret; |
138 | 111 | ||
139 | mutex_lock(&kpad->gpio_lock); | 112 | mutex_lock(&kpad->gpio_lock); |
@@ -150,8 +123,8 @@ static int adp5588_gpio_direction_output(struct gpio_chip *chip, | |||
150 | unsigned off, int val) | 123 | unsigned off, int val) |
151 | { | 124 | { |
152 | struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); | 125 | struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); |
153 | unsigned int bank = ADP_BANK(kpad->gpiomap[off]); | 126 | unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); |
154 | unsigned int bit = ADP_BIT(kpad->gpiomap[off]); | 127 | unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]); |
155 | int ret; | 128 | int ret; |
156 | 129 | ||
157 | mutex_lock(&kpad->gpio_lock); | 130 | mutex_lock(&kpad->gpio_lock); |
@@ -176,7 +149,7 @@ static int adp5588_gpio_direction_output(struct gpio_chip *chip, | |||
176 | static int __devinit adp5588_build_gpiomap(struct adp5588_kpad *kpad, | 149 | static int __devinit adp5588_build_gpiomap(struct adp5588_kpad *kpad, |
177 | const struct adp5588_kpad_platform_data *pdata) | 150 | const struct adp5588_kpad_platform_data *pdata) |
178 | { | 151 | { |
179 | bool pin_used[MAXGPIO]; | 152 | bool pin_used[ADP5588_MAXGPIO]; |
180 | int n_unused = 0; | 153 | int n_unused = 0; |
181 | int i; | 154 | int i; |
182 | 155 | ||
@@ -191,7 +164,7 @@ static int __devinit adp5588_build_gpiomap(struct adp5588_kpad *kpad, | |||
191 | for (i = 0; i < kpad->gpimapsize; i++) | 164 | for (i = 0; i < kpad->gpimapsize; i++) |
192 | pin_used[kpad->gpimap[i].pin - GPI_PIN_BASE] = true; | 165 | pin_used[kpad->gpimap[i].pin - GPI_PIN_BASE] = true; |
193 | 166 | ||
194 | for (i = 0; i < MAXGPIO; i++) | 167 | for (i = 0; i < ADP5588_MAXGPIO; i++) |
195 | if (!pin_used[i]) | 168 | if (!pin_used[i]) |
196 | kpad->gpiomap[n_unused++] = i; | 169 | kpad->gpiomap[n_unused++] = i; |
197 | 170 | ||
@@ -234,7 +207,7 @@ static int __devinit adp5588_gpio_add(struct adp5588_kpad *kpad) | |||
234 | return error; | 207 | return error; |
235 | } | 208 | } |
236 | 209 | ||
237 | for (i = 0; i <= ADP_BANK(MAXGPIO); i++) { | 210 | for (i = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) { |
238 | kpad->dat_out[i] = adp5588_read(kpad->client, | 211 | kpad->dat_out[i] = adp5588_read(kpad->client, |
239 | GPIO_DAT_OUT1 + i); | 212 | GPIO_DAT_OUT1 + i); |
240 | kpad->dir[i] = adp5588_read(kpad->client, GPIO_DIR1 + i); | 213 | kpad->dir[i] = adp5588_read(kpad->client, GPIO_DIR1 + i); |
@@ -318,11 +291,11 @@ static void adp5588_work(struct work_struct *work) | |||
318 | 291 | ||
319 | status = adp5588_read(client, INT_STAT); | 292 | status = adp5588_read(client, INT_STAT); |
320 | 293 | ||
321 | if (status & OVR_FLOW_INT) /* Unlikely and should never happen */ | 294 | if (status & ADP5588_OVR_FLOW_INT) /* Unlikely and should never happen */ |
322 | dev_err(&client->dev, "Event Overflow Error\n"); | 295 | dev_err(&client->dev, "Event Overflow Error\n"); |
323 | 296 | ||
324 | if (status & KE_INT) { | 297 | if (status & ADP5588_KE_INT) { |
325 | ev_cnt = adp5588_read(client, KEY_LCK_EC_STAT) & KEC; | 298 | ev_cnt = adp5588_read(client, KEY_LCK_EC_STAT) & ADP5588_KEC; |
326 | if (ev_cnt) { | 299 | if (ev_cnt) { |
327 | adp5588_report_events(kpad, ev_cnt); | 300 | adp5588_report_events(kpad, ev_cnt); |
328 | input_sync(kpad->input); | 301 | input_sync(kpad->input); |
@@ -360,7 +333,7 @@ static int __devinit adp5588_setup(struct i2c_client *client) | |||
360 | if (pdata->en_keylock) { | 333 | if (pdata->en_keylock) { |
361 | ret |= adp5588_write(client, UNLOCK1, pdata->unlock_key1); | 334 | ret |= adp5588_write(client, UNLOCK1, pdata->unlock_key1); |
362 | ret |= adp5588_write(client, UNLOCK2, pdata->unlock_key2); | 335 | ret |= adp5588_write(client, UNLOCK2, pdata->unlock_key2); |
363 | ret |= adp5588_write(client, KEY_LCK_EC_STAT, K_LCK_EN); | 336 | ret |= adp5588_write(client, KEY_LCK_EC_STAT, ADP5588_K_LCK_EN); |
364 | } | 337 | } |
365 | 338 | ||
366 | for (i = 0; i < KEYP_MAX_EVENT; i++) | 339 | for (i = 0; i < KEYP_MAX_EVENT; i++) |
@@ -384,7 +357,7 @@ static int __devinit adp5588_setup(struct i2c_client *client) | |||
384 | } | 357 | } |
385 | 358 | ||
386 | if (gpio_data) { | 359 | if (gpio_data) { |
387 | for (i = 0; i <= ADP_BANK(MAXGPIO); i++) { | 360 | for (i = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) { |
388 | int pull_mask = gpio_data->pullup_dis_mask; | 361 | int pull_mask = gpio_data->pullup_dis_mask; |
389 | 362 | ||
390 | ret |= adp5588_write(client, GPIO_PULL1 + i, | 363 | ret |= adp5588_write(client, GPIO_PULL1 + i, |
@@ -392,11 +365,14 @@ static int __devinit adp5588_setup(struct i2c_client *client) | |||
392 | } | 365 | } |
393 | } | 366 | } |
394 | 367 | ||
395 | ret |= adp5588_write(client, INT_STAT, CMP2_INT | CMP1_INT | | 368 | ret |= adp5588_write(client, INT_STAT, |
396 | OVR_FLOW_INT | K_LCK_INT | | 369 | ADP5588_CMP2_INT | ADP5588_CMP1_INT | |
397 | GPI_INT | KE_INT); /* Status is W1C */ | 370 | ADP5588_OVR_FLOW_INT | ADP5588_K_LCK_INT | |
371 | ADP5588_GPI_INT | ADP5588_KE_INT); /* Status is W1C */ | ||
398 | 372 | ||
399 | ret |= adp5588_write(client, CFG, INT_CFG | OVR_FLOW_IEN | KE_IEN); | 373 | ret |= adp5588_write(client, CFG, ADP5588_INT_CFG | |
374 | ADP5588_OVR_FLOW_IEN | | ||
375 | ADP5588_KE_IEN); | ||
400 | 376 | ||
401 | if (ret < 0) { | 377 | if (ret < 0) { |
402 | dev_err(&client->dev, "Write Error\n"); | 378 | dev_err(&client->dev, "Write Error\n"); |
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index d358ef8623f4..11478eb2c27d 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c | |||
@@ -63,6 +63,10 @@ static bool atkbd_extra; | |||
63 | module_param_named(extra, atkbd_extra, bool, 0); | 63 | module_param_named(extra, atkbd_extra, bool, 0); |
64 | MODULE_PARM_DESC(extra, "Enable extra LEDs and keys on IBM RapidAcces, EzKey and similar keyboards"); | 64 | MODULE_PARM_DESC(extra, "Enable extra LEDs and keys on IBM RapidAcces, EzKey and similar keyboards"); |
65 | 65 | ||
66 | static bool atkbd_terminal; | ||
67 | module_param_named(terminal, atkbd_terminal, bool, 0); | ||
68 | MODULE_PARM_DESC(terminal, "Enable break codes on an IBM Terminal keyboard connected via AT/PS2"); | ||
69 | |||
66 | /* | 70 | /* |
67 | * Scancode to keycode tables. These are just the default setting, and | 71 | * Scancode to keycode tables. These are just the default setting, and |
68 | * are loadable via a userland utility. | 72 | * are loadable via a userland utility. |
@@ -136,7 +140,8 @@ static const unsigned short atkbd_unxlate_table[128] = { | |||
136 | #define ATKBD_CMD_ENABLE 0x00f4 | 140 | #define ATKBD_CMD_ENABLE 0x00f4 |
137 | #define ATKBD_CMD_RESET_DIS 0x00f5 /* Reset to defaults and disable */ | 141 | #define ATKBD_CMD_RESET_DIS 0x00f5 /* Reset to defaults and disable */ |
138 | #define ATKBD_CMD_RESET_DEF 0x00f6 /* Reset to defaults */ | 142 | #define ATKBD_CMD_RESET_DEF 0x00f6 /* Reset to defaults */ |
139 | #define ATKBD_CMD_SETALL_MBR 0x00fa | 143 | #define ATKBD_CMD_SETALL_MB 0x00f8 /* Set all keys to give break codes */ |
144 | #define ATKBD_CMD_SETALL_MBR 0x00fa /* ... and repeat */ | ||
140 | #define ATKBD_CMD_RESET_BAT 0x02ff | 145 | #define ATKBD_CMD_RESET_BAT 0x02ff |
141 | #define ATKBD_CMD_RESEND 0x00fe | 146 | #define ATKBD_CMD_RESEND 0x00fe |
142 | #define ATKBD_CMD_EX_ENABLE 0x10ea | 147 | #define ATKBD_CMD_EX_ENABLE 0x10ea |
@@ -764,6 +769,11 @@ static int atkbd_select_set(struct atkbd *atkbd, int target_set, int allow_extra | |||
764 | } | 769 | } |
765 | } | 770 | } |
766 | 771 | ||
772 | if (atkbd_terminal) { | ||
773 | ps2_command(ps2dev, param, ATKBD_CMD_SETALL_MB); | ||
774 | return 3; | ||
775 | } | ||
776 | |||
767 | if (target_set != 3) | 777 | if (target_set != 3) |
768 | return 2; | 778 | return 2; |
769 | 779 | ||
diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c new file mode 100644 index 000000000000..4c17aff20657 --- /dev/null +++ b/drivers/input/keyboard/gpio_keys_polled.c | |||
@@ -0,0 +1,261 @@ | |||
1 | /* | ||
2 | * Driver for buttons on GPIO lines not capable of generating interrupts | ||
3 | * | ||
4 | * Copyright (C) 2007-2010 Gabor Juhos <juhosg@openwrt.org> | ||
5 | * Copyright (C) 2010 Nuno Goncalves <nunojpg@gmail.com> | ||
6 | * | ||
7 | * This file was based on: /drivers/input/misc/cobalt_btns.c | ||
8 | * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> | ||
9 | * | ||
10 | * also was based on: /drivers/input/keyboard/gpio_keys.c | ||
11 | * Copyright 2005 Phil Blundell | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify | ||
14 | * it under the terms of the GNU General Public License version 2 as | ||
15 | * published by the Free Software Foundation. | ||
16 | */ | ||
17 | |||
18 | #include <linux/kernel.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/slab.h> | ||
22 | #include <linux/input.h> | ||
23 | #include <linux/input-polldev.h> | ||
24 | #include <linux/ioport.h> | ||
25 | #include <linux/platform_device.h> | ||
26 | #include <linux/gpio.h> | ||
27 | #include <linux/gpio_keys.h> | ||
28 | |||
29 | #define DRV_NAME "gpio-keys-polled" | ||
30 | |||
31 | struct gpio_keys_button_data { | ||
32 | int last_state; | ||
33 | int count; | ||
34 | int threshold; | ||
35 | int can_sleep; | ||
36 | }; | ||
37 | |||
38 | struct gpio_keys_polled_dev { | ||
39 | struct input_polled_dev *poll_dev; | ||
40 | struct device *dev; | ||
41 | struct gpio_keys_platform_data *pdata; | ||
42 | struct gpio_keys_button_data data[0]; | ||
43 | }; | ||
44 | |||
45 | static void gpio_keys_polled_check_state(struct input_dev *input, | ||
46 | struct gpio_keys_button *button, | ||
47 | struct gpio_keys_button_data *bdata) | ||
48 | { | ||
49 | int state; | ||
50 | |||
51 | if (bdata->can_sleep) | ||
52 | state = !!gpio_get_value_cansleep(button->gpio); | ||
53 | else | ||
54 | state = !!gpio_get_value(button->gpio); | ||
55 | |||
56 | if (state != bdata->last_state) { | ||
57 | unsigned int type = button->type ?: EV_KEY; | ||
58 | |||
59 | input_event(input, type, button->code, | ||
60 | !!(state ^ button->active_low)); | ||
61 | input_sync(input); | ||
62 | bdata->count = 0; | ||
63 | bdata->last_state = state; | ||
64 | } | ||
65 | } | ||
66 | |||
67 | static void gpio_keys_polled_poll(struct input_polled_dev *dev) | ||
68 | { | ||
69 | struct gpio_keys_polled_dev *bdev = dev->private; | ||
70 | struct gpio_keys_platform_data *pdata = bdev->pdata; | ||
71 | struct input_dev *input = dev->input; | ||
72 | int i; | ||
73 | |||
74 | for (i = 0; i < bdev->pdata->nbuttons; i++) { | ||
75 | struct gpio_keys_button_data *bdata = &bdev->data[i]; | ||
76 | |||
77 | if (bdata->count < bdata->threshold) | ||
78 | bdata->count++; | ||
79 | else | ||
80 | gpio_keys_polled_check_state(input, &pdata->buttons[i], | ||
81 | bdata); | ||
82 | } | ||
83 | } | ||
84 | |||
85 | static void gpio_keys_polled_open(struct input_polled_dev *dev) | ||
86 | { | ||
87 | struct gpio_keys_polled_dev *bdev = dev->private; | ||
88 | struct gpio_keys_platform_data *pdata = bdev->pdata; | ||
89 | |||
90 | if (pdata->enable) | ||
91 | pdata->enable(bdev->dev); | ||
92 | } | ||
93 | |||
94 | static void gpio_keys_polled_close(struct input_polled_dev *dev) | ||
95 | { | ||
96 | struct gpio_keys_polled_dev *bdev = dev->private; | ||
97 | struct gpio_keys_platform_data *pdata = bdev->pdata; | ||
98 | |||
99 | if (pdata->disable) | ||
100 | pdata->disable(bdev->dev); | ||
101 | } | ||
102 | |||
103 | static int __devinit gpio_keys_polled_probe(struct platform_device *pdev) | ||
104 | { | ||
105 | struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; | ||
106 | struct device *dev = &pdev->dev; | ||
107 | struct gpio_keys_polled_dev *bdev; | ||
108 | struct input_polled_dev *poll_dev; | ||
109 | struct input_dev *input; | ||
110 | int error; | ||
111 | int i; | ||
112 | |||
113 | if (!pdata || !pdata->poll_interval) | ||
114 | return -EINVAL; | ||
115 | |||
116 | bdev = kzalloc(sizeof(struct gpio_keys_polled_dev) + | ||
117 | pdata->nbuttons * sizeof(struct gpio_keys_button_data), | ||
118 | GFP_KERNEL); | ||
119 | if (!bdev) { | ||
120 | dev_err(dev, "no memory for private data\n"); | ||
121 | return -ENOMEM; | ||
122 | } | ||
123 | |||
124 | poll_dev = input_allocate_polled_device(); | ||
125 | if (!poll_dev) { | ||
126 | dev_err(dev, "no memory for polled device\n"); | ||
127 | error = -ENOMEM; | ||
128 | goto err_free_bdev; | ||
129 | } | ||
130 | |||
131 | poll_dev->private = bdev; | ||
132 | poll_dev->poll = gpio_keys_polled_poll; | ||
133 | poll_dev->poll_interval = pdata->poll_interval; | ||
134 | poll_dev->open = gpio_keys_polled_open; | ||
135 | poll_dev->close = gpio_keys_polled_close; | ||
136 | |||
137 | input = poll_dev->input; | ||
138 | |||
139 | input->evbit[0] = BIT(EV_KEY); | ||
140 | input->name = pdev->name; | ||
141 | input->phys = DRV_NAME"/input0"; | ||
142 | input->dev.parent = &pdev->dev; | ||
143 | |||
144 | input->id.bustype = BUS_HOST; | ||
145 | input->id.vendor = 0x0001; | ||
146 | input->id.product = 0x0001; | ||
147 | input->id.version = 0x0100; | ||
148 | |||
149 | for (i = 0; i < pdata->nbuttons; i++) { | ||
150 | struct gpio_keys_button *button = &pdata->buttons[i]; | ||
151 | struct gpio_keys_button_data *bdata = &bdev->data[i]; | ||
152 | unsigned int gpio = button->gpio; | ||
153 | unsigned int type = button->type ?: EV_KEY; | ||
154 | |||
155 | if (button->wakeup) { | ||
156 | dev_err(dev, DRV_NAME " does not support wakeup\n"); | ||
157 | error = -EINVAL; | ||
158 | goto err_free_gpio; | ||
159 | } | ||
160 | |||
161 | error = gpio_request(gpio, | ||
162 | button->desc ? button->desc : DRV_NAME); | ||
163 | if (error) { | ||
164 | dev_err(dev, "unable to claim gpio %u, err=%d\n", | ||
165 | gpio, error); | ||
166 | goto err_free_gpio; | ||
167 | } | ||
168 | |||
169 | error = gpio_direction_input(gpio); | ||
170 | if (error) { | ||
171 | dev_err(dev, | ||
172 | "unable to set direction on gpio %u, err=%d\n", | ||
173 | gpio, error); | ||
174 | goto err_free_gpio; | ||
175 | } | ||
176 | |||
177 | bdata->can_sleep = gpio_cansleep(gpio); | ||
178 | bdata->last_state = -1; | ||
179 | bdata->threshold = DIV_ROUND_UP(button->debounce_interval, | ||
180 | pdata->poll_interval); | ||
181 | |||
182 | input_set_capability(input, type, button->code); | ||
183 | } | ||
184 | |||
185 | bdev->poll_dev = poll_dev; | ||
186 | bdev->dev = dev; | ||
187 | bdev->pdata = pdata; | ||
188 | platform_set_drvdata(pdev, bdev); | ||
189 | |||
190 | error = input_register_polled_device(poll_dev); | ||
191 | if (error) { | ||
192 | dev_err(dev, "unable to register polled device, err=%d\n", | ||
193 | error); | ||
194 | goto err_free_gpio; | ||
195 | } | ||
196 | |||
197 | /* report initial state of the buttons */ | ||
198 | for (i = 0; i < pdata->nbuttons; i++) | ||
199 | gpio_keys_polled_check_state(input, &pdata->buttons[i], | ||
200 | &bdev->data[i]); | ||
201 | |||
202 | return 0; | ||
203 | |||
204 | err_free_gpio: | ||
205 | while (--i >= 0) | ||
206 | gpio_free(pdata->buttons[i].gpio); | ||
207 | |||
208 | input_free_polled_device(poll_dev); | ||
209 | |||
210 | err_free_bdev: | ||
211 | kfree(bdev); | ||
212 | |||
213 | platform_set_drvdata(pdev, NULL); | ||
214 | return error; | ||
215 | } | ||
216 | |||
217 | static int __devexit gpio_keys_polled_remove(struct platform_device *pdev) | ||
218 | { | ||
219 | struct gpio_keys_polled_dev *bdev = platform_get_drvdata(pdev); | ||
220 | struct gpio_keys_platform_data *pdata = bdev->pdata; | ||
221 | int i; | ||
222 | |||
223 | input_unregister_polled_device(bdev->poll_dev); | ||
224 | |||
225 | for (i = 0; i < pdata->nbuttons; i++) | ||
226 | gpio_free(pdata->buttons[i].gpio); | ||
227 | |||
228 | input_free_polled_device(bdev->poll_dev); | ||
229 | |||
230 | kfree(bdev); | ||
231 | platform_set_drvdata(pdev, NULL); | ||
232 | |||
233 | return 0; | ||
234 | } | ||
235 | |||
236 | static struct platform_driver gpio_keys_polled_driver = { | ||
237 | .probe = gpio_keys_polled_probe, | ||
238 | .remove = __devexit_p(gpio_keys_polled_remove), | ||
239 | .driver = { | ||
240 | .name = DRV_NAME, | ||
241 | .owner = THIS_MODULE, | ||
242 | }, | ||
243 | }; | ||
244 | |||
245 | static int __init gpio_keys_polled_init(void) | ||
246 | { | ||
247 | return platform_driver_register(&gpio_keys_polled_driver); | ||
248 | } | ||
249 | |||
250 | static void __exit gpio_keys_polled_exit(void) | ||
251 | { | ||
252 | platform_driver_unregister(&gpio_keys_polled_driver); | ||
253 | } | ||
254 | |||
255 | module_init(gpio_keys_polled_init); | ||
256 | module_exit(gpio_keys_polled_exit); | ||
257 | |||
258 | MODULE_LICENSE("GPL v2"); | ||
259 | MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>"); | ||
260 | MODULE_DESCRIPTION("Polled GPIO Buttons driver"); | ||
261 | MODULE_ALIAS("platform:" DRV_NAME); | ||
diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c index a72e61ddca91..0e2a19cb43d8 100644 --- a/drivers/input/keyboard/omap-keypad.c +++ b/drivers/input/keyboard/omap-keypad.c | |||
@@ -65,7 +65,6 @@ struct omap_kp { | |||
65 | 65 | ||
66 | static DECLARE_TASKLET_DISABLED(kp_tasklet, omap_kp_tasklet, 0); | 66 | static DECLARE_TASKLET_DISABLED(kp_tasklet, omap_kp_tasklet, 0); |
67 | 67 | ||
68 | static int *keymap; | ||
69 | static unsigned int *row_gpios; | 68 | static unsigned int *row_gpios; |
70 | static unsigned int *col_gpios; | 69 | static unsigned int *col_gpios; |
71 | 70 | ||
@@ -162,20 +161,11 @@ static void omap_kp_scan_keypad(struct omap_kp *omap_kp, unsigned char *state) | |||
162 | } | 161 | } |
163 | } | 162 | } |
164 | 163 | ||
165 | static inline int omap_kp_find_key(int col, int row) | ||
166 | { | ||
167 | int i, key; | ||
168 | |||
169 | key = KEY(col, row, 0); | ||
170 | for (i = 0; keymap[i] != 0; i++) | ||
171 | if ((keymap[i] & 0xff000000) == key) | ||
172 | return keymap[i] & 0x00ffffff; | ||
173 | return -1; | ||
174 | } | ||
175 | |||
176 | static void omap_kp_tasklet(unsigned long data) | 164 | static void omap_kp_tasklet(unsigned long data) |
177 | { | 165 | { |
178 | struct omap_kp *omap_kp_data = (struct omap_kp *) data; | 166 | struct omap_kp *omap_kp_data = (struct omap_kp *) data; |
167 | unsigned short *keycodes = omap_kp_data->input->keycode; | ||
168 | unsigned int row_shift = get_count_order(omap_kp_data->cols); | ||
179 | unsigned char new_state[8], changed, key_down = 0; | 169 | unsigned char new_state[8], changed, key_down = 0; |
180 | int col, row; | 170 | int col, row; |
181 | int spurious = 0; | 171 | int spurious = 0; |
@@ -199,7 +189,7 @@ static void omap_kp_tasklet(unsigned long data) | |||
199 | row, (new_state[col] & (1 << row)) ? | 189 | row, (new_state[col] & (1 << row)) ? |
200 | "pressed" : "released"); | 190 | "pressed" : "released"); |
201 | #else | 191 | #else |
202 | key = omap_kp_find_key(col, row); | 192 | key = keycodes[MATRIX_SCAN_CODE(row, col, row_shift)]; |
203 | if (key < 0) { | 193 | if (key < 0) { |
204 | printk(KERN_WARNING | 194 | printk(KERN_WARNING |
205 | "omap-keypad: Spurious key event %d-%d\n", | 195 | "omap-keypad: Spurious key event %d-%d\n", |
@@ -298,13 +288,18 @@ static int __devinit omap_kp_probe(struct platform_device *pdev) | |||
298 | struct input_dev *input_dev; | 288 | struct input_dev *input_dev; |
299 | struct omap_kp_platform_data *pdata = pdev->dev.platform_data; | 289 | struct omap_kp_platform_data *pdata = pdev->dev.platform_data; |
300 | int i, col_idx, row_idx, irq_idx, ret; | 290 | int i, col_idx, row_idx, irq_idx, ret; |
291 | unsigned int row_shift, keycodemax; | ||
301 | 292 | ||
302 | if (!pdata->rows || !pdata->cols || !pdata->keymap) { | 293 | if (!pdata->rows || !pdata->cols || !pdata->keymap_data) { |
303 | printk(KERN_ERR "No rows, cols or keymap from pdata\n"); | 294 | printk(KERN_ERR "No rows, cols or keymap_data from pdata\n"); |
304 | return -EINVAL; | 295 | return -EINVAL; |
305 | } | 296 | } |
306 | 297 | ||
307 | omap_kp = kzalloc(sizeof(struct omap_kp), GFP_KERNEL); | 298 | row_shift = get_count_order(pdata->cols); |
299 | keycodemax = pdata->rows << row_shift; | ||
300 | |||
301 | omap_kp = kzalloc(sizeof(struct omap_kp) + | ||
302 | keycodemax * sizeof(unsigned short), GFP_KERNEL); | ||
308 | input_dev = input_allocate_device(); | 303 | input_dev = input_allocate_device(); |
309 | if (!omap_kp || !input_dev) { | 304 | if (!omap_kp || !input_dev) { |
310 | kfree(omap_kp); | 305 | kfree(omap_kp); |
@@ -320,7 +315,9 @@ static int __devinit omap_kp_probe(struct platform_device *pdev) | |||
320 | if (!cpu_is_omap24xx()) | 315 | if (!cpu_is_omap24xx()) |
321 | omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT); | 316 | omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT); |
322 | 317 | ||
323 | keymap = pdata->keymap; | 318 | input_dev->keycode = &omap_kp[1]; |
319 | input_dev->keycodesize = sizeof(unsigned short); | ||
320 | input_dev->keycodemax = keycodemax; | ||
324 | 321 | ||
325 | if (pdata->rep) | 322 | if (pdata->rep) |
326 | __set_bit(EV_REP, input_dev->evbit); | 323 | __set_bit(EV_REP, input_dev->evbit); |
@@ -374,8 +371,8 @@ static int __devinit omap_kp_probe(struct platform_device *pdev) | |||
374 | 371 | ||
375 | /* setup input device */ | 372 | /* setup input device */ |
376 | __set_bit(EV_KEY, input_dev->evbit); | 373 | __set_bit(EV_KEY, input_dev->evbit); |
377 | for (i = 0; keymap[i] != 0; i++) | 374 | matrix_keypad_build_keymap(pdata->keymap_data, row_shift, |
378 | __set_bit(keymap[i] & KEY_MAX, input_dev->keybit); | 375 | input_dev->keycode, input_dev->keybit); |
379 | input_dev->name = "omap-keypad"; | 376 | input_dev->name = "omap-keypad"; |
380 | input_dev->phys = "omap-keypad/input0"; | 377 | input_dev->phys = "omap-keypad/input0"; |
381 | input_dev->dev.parent = &pdev->dev; | 378 | input_dev->dev.parent = &pdev->dev; |
@@ -416,7 +413,7 @@ static int __devinit omap_kp_probe(struct platform_device *pdev) | |||
416 | return 0; | 413 | return 0; |
417 | err5: | 414 | err5: |
418 | for (i = irq_idx - 1; i >=0; i--) | 415 | for (i = irq_idx - 1; i >=0; i--) |
419 | free_irq(row_gpios[i], 0); | 416 | free_irq(row_gpios[i], NULL); |
420 | err4: | 417 | err4: |
421 | input_unregister_device(omap_kp->input); | 418 | input_unregister_device(omap_kp->input); |
422 | input_dev = NULL; | 419 | input_dev = NULL; |
@@ -447,11 +444,11 @@ static int __devexit omap_kp_remove(struct platform_device *pdev) | |||
447 | gpio_free(col_gpios[i]); | 444 | gpio_free(col_gpios[i]); |
448 | for (i = 0; i < omap_kp->rows; i++) { | 445 | for (i = 0; i < omap_kp->rows; i++) { |
449 | gpio_free(row_gpios[i]); | 446 | gpio_free(row_gpios[i]); |
450 | free_irq(gpio_to_irq(row_gpios[i]), 0); | 447 | free_irq(gpio_to_irq(row_gpios[i]), NULL); |
451 | } | 448 | } |
452 | } else { | 449 | } else { |
453 | omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT); | 450 | omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT); |
454 | free_irq(omap_kp->irq, 0); | 451 | free_irq(omap_kp->irq, NULL); |
455 | } | 452 | } |
456 | 453 | ||
457 | del_timer_sync(&omap_kp->timer); | 454 | del_timer_sync(&omap_kp->timer); |
diff --git a/drivers/input/keyboard/tc3589x-keypad.c b/drivers/input/keyboard/tc3589x-keypad.c new file mode 100644 index 000000000000..dbbe761778d2 --- /dev/null +++ b/drivers/input/keyboard/tc3589x-keypad.c | |||
@@ -0,0 +1,472 @@ | |||
1 | /* | ||
2 | * Copyright (C) ST-Ericsson SA 2010 | ||
3 | * | ||
4 | * Author: Jayeeta Banerjee <jayeeta.banerjee@stericsson.com> | ||
5 | * Author: Sundar Iyer <sundar.iyer@stericsson.com> | ||
6 | * | ||
7 | * License Terms: GNU General Public License, version 2 | ||
8 | * | ||
9 | * TC35893 MFD Keypad Controller driver | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/input.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/input/matrix_keypad.h> | ||
18 | #include <linux/i2c.h> | ||
19 | #include <linux/slab.h> | ||
20 | #include <linux/mfd/tc3589x.h> | ||
21 | |||
22 | /* Maximum supported keypad matrix row/columns size */ | ||
23 | #define TC3589x_MAX_KPROW 8 | ||
24 | #define TC3589x_MAX_KPCOL 12 | ||
25 | |||
26 | /* keypad related Constants */ | ||
27 | #define TC3589x_MAX_DEBOUNCE_SETTLE 0xFF | ||
28 | #define DEDICATED_KEY_VAL 0xFF | ||
29 | |||
30 | /* Pull up/down masks */ | ||
31 | #define TC3589x_NO_PULL_MASK 0x0 | ||
32 | #define TC3589x_PULL_DOWN_MASK 0x1 | ||
33 | #define TC3589x_PULL_UP_MASK 0x2 | ||
34 | #define TC3589x_PULLUP_ALL_MASK 0xAA | ||
35 | #define TC3589x_IO_PULL_VAL(index, mask) ((mask)<<((index)%4)*2)) | ||
36 | |||
37 | /* Bit masks for IOCFG register */ | ||
38 | #define IOCFG_BALLCFG 0x01 | ||
39 | #define IOCFG_IG 0x08 | ||
40 | |||
41 | #define KP_EVCODE_COL_MASK 0x0F | ||
42 | #define KP_EVCODE_ROW_MASK 0x70 | ||
43 | #define KP_RELEASE_EVT_MASK 0x80 | ||
44 | |||
45 | #define KP_ROW_SHIFT 4 | ||
46 | |||
47 | #define KP_NO_VALID_KEY_MASK 0x7F | ||
48 | |||
49 | /* bit masks for RESTCTRL register */ | ||
50 | #define TC3589x_KBDRST 0x2 | ||
51 | #define TC3589x_IRQRST 0x10 | ||
52 | #define TC3589x_RESET_ALL 0x1B | ||
53 | |||
54 | /* KBDMFS register bit mask */ | ||
55 | #define TC3589x_KBDMFS_EN 0x1 | ||
56 | |||
57 | /* CLKEN register bitmask */ | ||
58 | #define KPD_CLK_EN 0x1 | ||
59 | |||
60 | /* RSTINTCLR register bit mask */ | ||
61 | #define IRQ_CLEAR 0x1 | ||
62 | |||
63 | /* bit masks for keyboard interrupts*/ | ||
64 | #define TC3589x_EVT_LOSS_INT 0x8 | ||
65 | #define TC3589x_EVT_INT 0x4 | ||
66 | #define TC3589x_KBD_LOSS_INT 0x2 | ||
67 | #define TC3589x_KBD_INT 0x1 | ||
68 | |||
69 | /* bit masks for keyboard interrupt clear*/ | ||
70 | #define TC3589x_EVT_INT_CLR 0x2 | ||
71 | #define TC3589x_KBD_INT_CLR 0x1 | ||
72 | |||
73 | #define TC3589x_KBD_KEYMAP_SIZE 64 | ||
74 | |||
75 | /** | ||
76 | * struct tc_keypad - data structure used by keypad driver | ||
77 | * @input: pointer to input device object | ||
78 | * @board: keypad platform device | ||
79 | * @krow: number of rows | ||
80 | * @kcol: number of coloumns | ||
81 | * @keymap: matrix scan code table for keycodes | ||
82 | */ | ||
83 | struct tc_keypad { | ||
84 | struct tc3589x *tc3589x; | ||
85 | struct input_dev *input; | ||
86 | const struct tc3589x_keypad_platform_data *board; | ||
87 | unsigned int krow; | ||
88 | unsigned int kcol; | ||
89 | unsigned short keymap[TC3589x_KBD_KEYMAP_SIZE]; | ||
90 | bool keypad_stopped; | ||
91 | }; | ||
92 | |||
93 | static int __devinit tc3589x_keypad_init_key_hardware(struct tc_keypad *keypad) | ||
94 | { | ||
95 | int ret; | ||
96 | struct tc3589x *tc3589x = keypad->tc3589x; | ||
97 | u8 settle_time = keypad->board->settle_time; | ||
98 | u8 dbounce_period = keypad->board->debounce_period; | ||
99 | u8 rows = keypad->board->krow & 0xf; /* mask out the nibble */ | ||
100 | u8 column = keypad->board->kcol & 0xf; /* mask out the nibble */ | ||
101 | |||
102 | /* validate platform configurations */ | ||
103 | if (keypad->board->kcol > TC3589x_MAX_KPCOL || | ||
104 | keypad->board->krow > TC3589x_MAX_KPROW || | ||
105 | keypad->board->debounce_period > TC3589x_MAX_DEBOUNCE_SETTLE || | ||
106 | keypad->board->settle_time > TC3589x_MAX_DEBOUNCE_SETTLE) | ||
107 | return -EINVAL; | ||
108 | |||
109 | /* configure KBDSIZE 4 LSbits for cols and 4 MSbits for rows */ | ||
110 | ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSIZE, | ||
111 | (rows << KP_ROW_SHIFT) | column); | ||
112 | if (ret < 0) | ||
113 | return ret; | ||
114 | |||
115 | /* configure dedicated key config, no dedicated key selected */ | ||
116 | ret = tc3589x_reg_write(tc3589x, TC3589x_KBCFG_LSB, DEDICATED_KEY_VAL); | ||
117 | if (ret < 0) | ||
118 | return ret; | ||
119 | |||
120 | ret = tc3589x_reg_write(tc3589x, TC3589x_KBCFG_MSB, DEDICATED_KEY_VAL); | ||
121 | if (ret < 0) | ||
122 | return ret; | ||
123 | |||
124 | /* Configure settle time */ | ||
125 | ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSETTLE_REG, settle_time); | ||
126 | if (ret < 0) | ||
127 | return ret; | ||
128 | |||
129 | /* Configure debounce time */ | ||
130 | ret = tc3589x_reg_write(tc3589x, TC3589x_KBDBOUNCE, dbounce_period); | ||
131 | if (ret < 0) | ||
132 | return ret; | ||
133 | |||
134 | /* Start of initialise keypad GPIOs */ | ||
135 | ret = tc3589x_set_bits(tc3589x, TC3589x_IOCFG, 0x0, IOCFG_IG); | ||
136 | if (ret < 0) | ||
137 | return ret; | ||
138 | |||
139 | /* Configure pull-up resistors for all row GPIOs */ | ||
140 | ret = tc3589x_reg_write(tc3589x, TC3589x_IOPULLCFG0_LSB, | ||
141 | TC3589x_PULLUP_ALL_MASK); | ||
142 | if (ret < 0) | ||
143 | return ret; | ||
144 | |||
145 | ret = tc3589x_reg_write(tc3589x, TC3589x_IOPULLCFG0_MSB, | ||
146 | TC3589x_PULLUP_ALL_MASK); | ||
147 | if (ret < 0) | ||
148 | return ret; | ||
149 | |||
150 | /* Configure pull-up resistors for all column GPIOs */ | ||
151 | ret = tc3589x_reg_write(tc3589x, TC3589x_IOPULLCFG1_LSB, | ||
152 | TC3589x_PULLUP_ALL_MASK); | ||
153 | if (ret < 0) | ||
154 | return ret; | ||
155 | |||
156 | ret = tc3589x_reg_write(tc3589x, TC3589x_IOPULLCFG1_MSB, | ||
157 | TC3589x_PULLUP_ALL_MASK); | ||
158 | if (ret < 0) | ||
159 | return ret; | ||
160 | |||
161 | ret = tc3589x_reg_write(tc3589x, TC3589x_IOPULLCFG2_LSB, | ||
162 | TC3589x_PULLUP_ALL_MASK); | ||
163 | |||
164 | return ret; | ||
165 | } | ||
166 | |||
167 | #define TC35893_DATA_REGS 4 | ||
168 | #define TC35893_KEYCODE_FIFO_EMPTY 0x7f | ||
169 | #define TC35893_KEYCODE_FIFO_CLEAR 0xff | ||
170 | #define TC35893_KEYPAD_ROW_SHIFT 0x3 | ||
171 | |||
172 | static irqreturn_t tc3589x_keypad_irq(int irq, void *dev) | ||
173 | { | ||
174 | struct tc_keypad *keypad = dev; | ||
175 | struct tc3589x *tc3589x = keypad->tc3589x; | ||
176 | u8 i, row_index, col_index, kbd_code, up; | ||
177 | u8 code; | ||
178 | |||
179 | for (i = 0; i < TC35893_DATA_REGS * 2; i++) { | ||
180 | kbd_code = tc3589x_reg_read(tc3589x, TC3589x_EVTCODE_FIFO); | ||
181 | |||
182 | /* loop till fifo is empty and no more keys are pressed */ | ||
183 | if (kbd_code == TC35893_KEYCODE_FIFO_EMPTY || | ||
184 | kbd_code == TC35893_KEYCODE_FIFO_CLEAR) | ||
185 | continue; | ||
186 | |||
187 | /* valid key is found */ | ||
188 | col_index = kbd_code & KP_EVCODE_COL_MASK; | ||
189 | row_index = (kbd_code & KP_EVCODE_ROW_MASK) >> KP_ROW_SHIFT; | ||
190 | code = MATRIX_SCAN_CODE(row_index, col_index, | ||
191 | TC35893_KEYPAD_ROW_SHIFT); | ||
192 | up = kbd_code & KP_RELEASE_EVT_MASK; | ||
193 | |||
194 | input_event(keypad->input, EV_MSC, MSC_SCAN, code); | ||
195 | input_report_key(keypad->input, keypad->keymap[code], !up); | ||
196 | input_sync(keypad->input); | ||
197 | } | ||
198 | |||
199 | /* clear IRQ */ | ||
200 | tc3589x_set_bits(tc3589x, TC3589x_KBDIC, | ||
201 | 0x0, TC3589x_EVT_INT_CLR | TC3589x_KBD_INT_CLR); | ||
202 | /* enable IRQ */ | ||
203 | tc3589x_set_bits(tc3589x, TC3589x_KBDMSK, | ||
204 | 0x0, TC3589x_EVT_LOSS_INT | TC3589x_EVT_INT); | ||
205 | |||
206 | return IRQ_HANDLED; | ||
207 | } | ||
208 | |||
209 | static int tc3589x_keypad_enable(struct tc_keypad *keypad) | ||
210 | { | ||
211 | struct tc3589x *tc3589x = keypad->tc3589x; | ||
212 | int ret; | ||
213 | |||
214 | /* pull the keypad module out of reset */ | ||
215 | ret = tc3589x_set_bits(tc3589x, TC3589x_RSTCTRL, TC3589x_KBDRST, 0x0); | ||
216 | if (ret < 0) | ||
217 | return ret; | ||
218 | |||
219 | /* configure KBDMFS */ | ||
220 | ret = tc3589x_set_bits(tc3589x, TC3589x_KBDMFS, 0x0, TC3589x_KBDMFS_EN); | ||
221 | if (ret < 0) | ||
222 | return ret; | ||
223 | |||
224 | /* enable the keypad clock */ | ||
225 | ret = tc3589x_set_bits(tc3589x, TC3589x_CLKEN, 0x0, KPD_CLK_EN); | ||
226 | if (ret < 0) | ||
227 | return ret; | ||
228 | |||
229 | /* clear pending IRQs */ | ||
230 | ret = tc3589x_set_bits(tc3589x, TC3589x_RSTINTCLR, 0x0, 0x1); | ||
231 | if (ret < 0) | ||
232 | return ret; | ||
233 | |||
234 | /* enable the IRQs */ | ||
235 | ret = tc3589x_set_bits(tc3589x, TC3589x_KBDMSK, 0x0, | ||
236 | TC3589x_EVT_LOSS_INT | TC3589x_EVT_INT); | ||
237 | if (ret < 0) | ||
238 | return ret; | ||
239 | |||
240 | keypad->keypad_stopped = false; | ||
241 | |||
242 | return ret; | ||
243 | } | ||
244 | |||
245 | static int tc3589x_keypad_disable(struct tc_keypad *keypad) | ||
246 | { | ||
247 | struct tc3589x *tc3589x = keypad->tc3589x; | ||
248 | int ret; | ||
249 | |||
250 | /* clear IRQ */ | ||
251 | ret = tc3589x_set_bits(tc3589x, TC3589x_KBDIC, | ||
252 | 0x0, TC3589x_EVT_INT_CLR | TC3589x_KBD_INT_CLR); | ||
253 | if (ret < 0) | ||
254 | return ret; | ||
255 | |||
256 | /* disable all interrupts */ | ||
257 | ret = tc3589x_set_bits(tc3589x, TC3589x_KBDMSK, | ||
258 | ~(TC3589x_EVT_LOSS_INT | TC3589x_EVT_INT), 0x0); | ||
259 | if (ret < 0) | ||
260 | return ret; | ||
261 | |||
262 | /* disable the keypad module */ | ||
263 | ret = tc3589x_set_bits(tc3589x, TC3589x_CLKEN, 0x1, 0x0); | ||
264 | if (ret < 0) | ||
265 | return ret; | ||
266 | |||
267 | /* put the keypad module into reset */ | ||
268 | ret = tc3589x_set_bits(tc3589x, TC3589x_RSTCTRL, TC3589x_KBDRST, 0x1); | ||
269 | |||
270 | keypad->keypad_stopped = true; | ||
271 | |||
272 | return ret; | ||
273 | } | ||
274 | |||
275 | static int tc3589x_keypad_open(struct input_dev *input) | ||
276 | { | ||
277 | int error; | ||
278 | struct tc_keypad *keypad = input_get_drvdata(input); | ||
279 | |||
280 | /* enable the keypad module */ | ||
281 | error = tc3589x_keypad_enable(keypad); | ||
282 | if (error < 0) { | ||
283 | dev_err(&input->dev, "failed to enable keypad module\n"); | ||
284 | return error; | ||
285 | } | ||
286 | |||
287 | error = tc3589x_keypad_init_key_hardware(keypad); | ||
288 | if (error < 0) { | ||
289 | dev_err(&input->dev, "failed to configure keypad module\n"); | ||
290 | return error; | ||
291 | } | ||
292 | |||
293 | return 0; | ||
294 | } | ||
295 | |||
296 | static void tc3589x_keypad_close(struct input_dev *input) | ||
297 | { | ||
298 | struct tc_keypad *keypad = input_get_drvdata(input); | ||
299 | |||
300 | /* disable the keypad module */ | ||
301 | tc3589x_keypad_disable(keypad); | ||
302 | } | ||
303 | |||
304 | static int __devinit tc3589x_keypad_probe(struct platform_device *pdev) | ||
305 | { | ||
306 | struct tc3589x *tc3589x = dev_get_drvdata(pdev->dev.parent); | ||
307 | struct tc_keypad *keypad; | ||
308 | struct input_dev *input; | ||
309 | const struct tc3589x_keypad_platform_data *plat; | ||
310 | int error, irq; | ||
311 | |||
312 | plat = tc3589x->pdata->keypad; | ||
313 | if (!plat) { | ||
314 | dev_err(&pdev->dev, "invalid keypad platform data\n"); | ||
315 | return -EINVAL; | ||
316 | } | ||
317 | |||
318 | irq = platform_get_irq(pdev, 0); | ||
319 | if (irq < 0) | ||
320 | return irq; | ||
321 | |||
322 | keypad = kzalloc(sizeof(struct tc_keypad), GFP_KERNEL); | ||
323 | input = input_allocate_device(); | ||
324 | if (!keypad || !input) { | ||
325 | dev_err(&pdev->dev, "failed to allocate keypad memory\n"); | ||
326 | error = -ENOMEM; | ||
327 | goto err_free_mem; | ||
328 | } | ||
329 | |||
330 | keypad->board = plat; | ||
331 | keypad->input = input; | ||
332 | keypad->tc3589x = tc3589x; | ||
333 | |||
334 | input->id.bustype = BUS_I2C; | ||
335 | input->name = pdev->name; | ||
336 | input->dev.parent = &pdev->dev; | ||
337 | |||
338 | input->keycode = keypad->keymap; | ||
339 | input->keycodesize = sizeof(keypad->keymap[0]); | ||
340 | input->keycodemax = ARRAY_SIZE(keypad->keymap); | ||
341 | |||
342 | input->open = tc3589x_keypad_open; | ||
343 | input->close = tc3589x_keypad_close; | ||
344 | |||
345 | input_set_drvdata(input, keypad); | ||
346 | |||
347 | input_set_capability(input, EV_MSC, MSC_SCAN); | ||
348 | |||
349 | __set_bit(EV_KEY, input->evbit); | ||
350 | if (!plat->no_autorepeat) | ||
351 | __set_bit(EV_REP, input->evbit); | ||
352 | |||
353 | matrix_keypad_build_keymap(plat->keymap_data, 0x3, | ||
354 | input->keycode, input->keybit); | ||
355 | |||
356 | error = request_threaded_irq(irq, NULL, | ||
357 | tc3589x_keypad_irq, plat->irqtype, | ||
358 | "tc3589x-keypad", keypad); | ||
359 | if (error < 0) { | ||
360 | dev_err(&pdev->dev, | ||
361 | "Could not allocate irq %d,error %d\n", | ||
362 | irq, error); | ||
363 | goto err_free_mem; | ||
364 | } | ||
365 | |||
366 | error = input_register_device(input); | ||
367 | if (error) { | ||
368 | dev_err(&pdev->dev, "Could not register input device\n"); | ||
369 | goto err_free_irq; | ||
370 | } | ||
371 | |||
372 | /* let platform decide if keypad is a wakeup source or not */ | ||
373 | device_init_wakeup(&pdev->dev, plat->enable_wakeup); | ||
374 | device_set_wakeup_capable(&pdev->dev, plat->enable_wakeup); | ||
375 | |||
376 | platform_set_drvdata(pdev, keypad); | ||
377 | |||
378 | return 0; | ||
379 | |||
380 | err_free_irq: | ||
381 | free_irq(irq, keypad); | ||
382 | err_free_mem: | ||
383 | input_free_device(input); | ||
384 | kfree(keypad); | ||
385 | return error; | ||
386 | } | ||
387 | |||
388 | static int __devexit tc3589x_keypad_remove(struct platform_device *pdev) | ||
389 | { | ||
390 | struct tc_keypad *keypad = platform_get_drvdata(pdev); | ||
391 | int irq = platform_get_irq(pdev, 0); | ||
392 | |||
393 | if (!keypad->keypad_stopped) | ||
394 | tc3589x_keypad_disable(keypad); | ||
395 | |||
396 | free_irq(irq, keypad); | ||
397 | |||
398 | input_unregister_device(keypad->input); | ||
399 | |||
400 | kfree(keypad); | ||
401 | |||
402 | return 0; | ||
403 | } | ||
404 | |||
405 | #ifdef CONFIG_PM | ||
406 | static int tc3589x_keypad_suspend(struct device *dev) | ||
407 | { | ||
408 | struct platform_device *pdev = to_platform_device(dev); | ||
409 | struct tc_keypad *keypad = platform_get_drvdata(pdev); | ||
410 | int irq = platform_get_irq(pdev, 0); | ||
411 | |||
412 | /* keypad is already off; we do nothing */ | ||
413 | if (keypad->keypad_stopped) | ||
414 | return 0; | ||
415 | |||
416 | /* if device is not a wakeup source, disable it for powersave */ | ||
417 | if (!device_may_wakeup(&pdev->dev)) | ||
418 | tc3589x_keypad_disable(keypad); | ||
419 | else | ||
420 | enable_irq_wake(irq); | ||
421 | |||
422 | return 0; | ||
423 | } | ||
424 | |||
425 | static int tc3589x_keypad_resume(struct device *dev) | ||
426 | { | ||
427 | struct platform_device *pdev = to_platform_device(dev); | ||
428 | struct tc_keypad *keypad = platform_get_drvdata(pdev); | ||
429 | int irq = platform_get_irq(pdev, 0); | ||
430 | |||
431 | if (!keypad->keypad_stopped) | ||
432 | return 0; | ||
433 | |||
434 | /* enable the device to resume normal operations */ | ||
435 | if (!device_may_wakeup(&pdev->dev)) | ||
436 | tc3589x_keypad_enable(keypad); | ||
437 | else | ||
438 | disable_irq_wake(irq); | ||
439 | |||
440 | return 0; | ||
441 | } | ||
442 | |||
443 | static const SIMPLE_DEV_PM_OPS(tc3589x_keypad_dev_pm_ops, | ||
444 | tc3589x_keypad_suspend, tc3589x_keypad_resume); | ||
445 | #endif | ||
446 | |||
447 | static struct platform_driver tc3589x_keypad_driver = { | ||
448 | .driver.name = "tc3589x-keypad", | ||
449 | .driver.owner = THIS_MODULE, | ||
450 | #ifdef CONFIG_PM | ||
451 | .driver.pm = &tc3589x_keypad_dev_pm_ops, | ||
452 | #endif | ||
453 | .probe = tc3589x_keypad_probe, | ||
454 | .remove = __devexit_p(tc3589x_keypad_remove), | ||
455 | }; | ||
456 | |||
457 | static int __init tc3589x_keypad_init(void) | ||
458 | { | ||
459 | return platform_driver_register(&tc3589x_keypad_driver); | ||
460 | } | ||
461 | module_init(tc3589x_keypad_init); | ||
462 | |||
463 | static void __exit tc3589x_keypad_exit(void) | ||
464 | { | ||
465 | return platform_driver_unregister(&tc3589x_keypad_driver); | ||
466 | } | ||
467 | module_exit(tc3589x_keypad_exit); | ||
468 | |||
469 | MODULE_LICENSE("GPL v2"); | ||
470 | MODULE_AUTHOR("Jayeeta Banerjee/Sundar Iyer"); | ||
471 | MODULE_DESCRIPTION("TC35893 Keypad Driver"); | ||
472 | MODULE_ALIAS("platform:tc3589x-keypad"); | ||
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index b99b8cbde02f..c1a81bcdb319 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig | |||
@@ -294,24 +294,6 @@ config INPUT_SGI_BTNS | |||
294 | To compile this driver as a module, choose M here: the | 294 | To compile this driver as a module, choose M here: the |
295 | module will be called sgi_btns. | 295 | module will be called sgi_btns. |
296 | 296 | ||
297 | config INPUT_WINBOND_CIR | ||
298 | tristate "Winbond IR remote control" | ||
299 | depends on X86 && PNP | ||
300 | select NEW_LEDS | ||
301 | select LEDS_CLASS | ||
302 | select LEDS_TRIGGERS | ||
303 | select BITREVERSE | ||
304 | help | ||
305 | Say Y here if you want to use the IR remote functionality found | ||
306 | in some Winbond SuperI/O chips. Currently only the WPCD376I | ||
307 | chip is supported (included in some Intel Media series motherboards). | ||
308 | |||
309 | IR Receive and wake-on-IR from suspend and power-off is currently | ||
310 | supported. | ||
311 | |||
312 | To compile this driver as a module, choose M here: the module will be | ||
313 | called winbond_cir. | ||
314 | |||
315 | config HP_SDC_RTC | 297 | config HP_SDC_RTC |
316 | tristate "HP SDC Real Time Clock" | 298 | tristate "HP SDC Real Time Clock" |
317 | depends on (GSC || HP300) && SERIO | 299 | depends on (GSC || HP300) && SERIO |
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 1fe1f6c8b737..06b2b5154038 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile | |||
@@ -38,7 +38,6 @@ obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o | |||
38 | obj-$(CONFIG_INPUT_TWL4030_PWRBUTTON) += twl4030-pwrbutton.o | 38 | obj-$(CONFIG_INPUT_TWL4030_PWRBUTTON) += twl4030-pwrbutton.o |
39 | obj-$(CONFIG_INPUT_TWL4030_VIBRA) += twl4030-vibra.o | 39 | obj-$(CONFIG_INPUT_TWL4030_VIBRA) += twl4030-vibra.o |
40 | obj-$(CONFIG_INPUT_UINPUT) += uinput.o | 40 | obj-$(CONFIG_INPUT_UINPUT) += uinput.o |
41 | obj-$(CONFIG_INPUT_WINBOND_CIR) += winbond-cir.o | ||
42 | obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o | 41 | obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o |
43 | obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o | 42 | obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o |
44 | obj-$(CONFIG_INPUT_YEALINK) += yealink.o | 43 | obj-$(CONFIG_INPUT_YEALINK) += yealink.o |
diff --git a/drivers/input/misc/pcf8574_keypad.c b/drivers/input/misc/pcf8574_keypad.c index 4b42ffc0532a..d1583aea1721 100644 --- a/drivers/input/misc/pcf8574_keypad.c +++ b/drivers/input/misc/pcf8574_keypad.c | |||
@@ -127,14 +127,6 @@ static int __devinit pcf8574_kp_probe(struct i2c_client *client, const struct i2 | |||
127 | idev->id.product = 0x0001; | 127 | idev->id.product = 0x0001; |
128 | idev->id.version = 0x0100; | 128 | idev->id.version = 0x0100; |
129 | 129 | ||
130 | input_set_drvdata(idev, lp); | ||
131 | |||
132 | ret = input_register_device(idev); | ||
133 | if (ret) { | ||
134 | dev_err(&client->dev, "input_register_device() failed\n"); | ||
135 | goto fail_register; | ||
136 | } | ||
137 | |||
138 | lp->laststate = read_state(lp); | 130 | lp->laststate = read_state(lp); |
139 | 131 | ||
140 | ret = request_threaded_irq(client->irq, NULL, pcf8574_kp_irq_handler, | 132 | ret = request_threaded_irq(client->irq, NULL, pcf8574_kp_irq_handler, |
@@ -142,16 +134,21 @@ static int __devinit pcf8574_kp_probe(struct i2c_client *client, const struct i2 | |||
142 | DRV_NAME, lp); | 134 | DRV_NAME, lp); |
143 | if (ret) { | 135 | if (ret) { |
144 | dev_err(&client->dev, "IRQ %d is not free\n", client->irq); | 136 | dev_err(&client->dev, "IRQ %d is not free\n", client->irq); |
145 | goto fail_irq; | 137 | goto fail_free_device; |
138 | } | ||
139 | |||
140 | ret = input_register_device(idev); | ||
141 | if (ret) { | ||
142 | dev_err(&client->dev, "input_register_device() failed\n"); | ||
143 | goto fail_free_irq; | ||
146 | } | 144 | } |
147 | 145 | ||
148 | i2c_set_clientdata(client, lp); | 146 | i2c_set_clientdata(client, lp); |
149 | return 0; | 147 | return 0; |
150 | 148 | ||
151 | fail_irq: | 149 | fail_free_irq: |
152 | input_unregister_device(idev); | 150 | free_irq(client->irq, lp); |
153 | fail_register: | 151 | fail_free_device: |
154 | input_set_drvdata(idev, NULL); | ||
155 | input_free_device(idev); | 152 | input_free_device(idev); |
156 | fail_allocate: | 153 | fail_allocate: |
157 | kfree(lp); | 154 | kfree(lp); |
diff --git a/drivers/input/misc/winbond-cir.c b/drivers/input/misc/winbond-cir.c deleted file mode 100644 index 64f1de7960c6..000000000000 --- a/drivers/input/misc/winbond-cir.c +++ /dev/null | |||
@@ -1,1608 +0,0 @@ | |||
1 | /* | ||
2 | * winbond-cir.c - Driver for the Consumer IR functionality of Winbond | ||
3 | * SuperI/O chips. | ||
4 | * | ||
5 | * Currently supports the Winbond WPCD376i chip (PNP id WEC1022), but | ||
6 | * could probably support others (Winbond WEC102X, NatSemi, etc) | ||
7 | * with minor modifications. | ||
8 | * | ||
9 | * Original Author: David Härdeman <david@hardeman.nu> | ||
10 | * Copyright (C) 2009 David Härdeman <david@hardeman.nu> | ||
11 | * | ||
12 | * Dedicated to Matilda, my newborn daughter, without whose loving attention | ||
13 | * this driver would have been finished in half the time and with a fraction | ||
14 | * of the bugs. | ||
15 | * | ||
16 | * Written using: | ||
17 | * o Winbond WPCD376I datasheet helpfully provided by Jesse Barnes at Intel | ||
18 | * o NatSemi PC87338/PC97338 datasheet (for the serial port stuff) | ||
19 | * o DSDT dumps | ||
20 | * | ||
21 | * Supported features: | ||
22 | * o RC6 | ||
23 | * o Wake-On-CIR functionality | ||
24 | * | ||
25 | * To do: | ||
26 | * o Test NEC and RC5 | ||
27 | * | ||
28 | * Left as an exercise for the reader: | ||
29 | * o Learning (I have neither the hardware, nor the need) | ||
30 | * o IR Transmit (ibid) | ||
31 | * | ||
32 | * This program is free software; you can redistribute it and/or modify | ||
33 | * it under the terms of the GNU General Public License as published by | ||
34 | * the Free Software Foundation; either version 2 of the License, or | ||
35 | * (at your option) any later version. | ||
36 | * | ||
37 | * This program is distributed in the hope that it will be useful, | ||
38 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
39 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
40 | * GNU General Public License for more details. | ||
41 | * | ||
42 | * You should have received a copy of the GNU General Public License | ||
43 | * along with this program; if not, write to the Free Software | ||
44 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
45 | */ | ||
46 | |||
47 | #include <linux/module.h> | ||
48 | #include <linux/pnp.h> | ||
49 | #include <linux/interrupt.h> | ||
50 | #include <linux/timer.h> | ||
51 | #include <linux/input.h> | ||
52 | #include <linux/leds.h> | ||
53 | #include <linux/list.h> | ||
54 | #include <linux/spinlock.h> | ||
55 | #include <linux/pci_ids.h> | ||
56 | #include <linux/io.h> | ||
57 | #include <linux/bitrev.h> | ||
58 | #include <linux/bitops.h> | ||
59 | #include <linux/slab.h> | ||
60 | |||
61 | #define DRVNAME "winbond-cir" | ||
62 | |||
63 | /* CEIR Wake-Up Registers, relative to data->wbase */ | ||
64 | #define WBCIR_REG_WCEIR_CTL 0x03 /* CEIR Receiver Control */ | ||
65 | #define WBCIR_REG_WCEIR_STS 0x04 /* CEIR Receiver Status */ | ||
66 | #define WBCIR_REG_WCEIR_EV_EN 0x05 /* CEIR Receiver Event Enable */ | ||
67 | #define WBCIR_REG_WCEIR_CNTL 0x06 /* CEIR Receiver Counter Low */ | ||
68 | #define WBCIR_REG_WCEIR_CNTH 0x07 /* CEIR Receiver Counter High */ | ||
69 | #define WBCIR_REG_WCEIR_INDEX 0x08 /* CEIR Receiver Index */ | ||
70 | #define WBCIR_REG_WCEIR_DATA 0x09 /* CEIR Receiver Data */ | ||
71 | #define WBCIR_REG_WCEIR_CSL 0x0A /* CEIR Re. Compare Strlen */ | ||
72 | #define WBCIR_REG_WCEIR_CFG1 0x0B /* CEIR Re. Configuration 1 */ | ||
73 | #define WBCIR_REG_WCEIR_CFG2 0x0C /* CEIR Re. Configuration 2 */ | ||
74 | |||
75 | /* CEIR Enhanced Functionality Registers, relative to data->ebase */ | ||
76 | #define WBCIR_REG_ECEIR_CTS 0x00 /* Enhanced IR Control Status */ | ||
77 | #define WBCIR_REG_ECEIR_CCTL 0x01 /* Infrared Counter Control */ | ||
78 | #define WBCIR_REG_ECEIR_CNT_LO 0x02 /* Infrared Counter LSB */ | ||
79 | #define WBCIR_REG_ECEIR_CNT_HI 0x03 /* Infrared Counter MSB */ | ||
80 | #define WBCIR_REG_ECEIR_IREM 0x04 /* Infrared Emitter Status */ | ||
81 | |||
82 | /* SP3 Banked Registers, relative to data->sbase */ | ||
83 | #define WBCIR_REG_SP3_BSR 0x03 /* Bank Select, all banks */ | ||
84 | /* Bank 0 */ | ||
85 | #define WBCIR_REG_SP3_RXDATA 0x00 /* FIFO RX data (r) */ | ||
86 | #define WBCIR_REG_SP3_TXDATA 0x00 /* FIFO TX data (w) */ | ||
87 | #define WBCIR_REG_SP3_IER 0x01 /* Interrupt Enable */ | ||
88 | #define WBCIR_REG_SP3_EIR 0x02 /* Event Identification (r) */ | ||
89 | #define WBCIR_REG_SP3_FCR 0x02 /* FIFO Control (w) */ | ||
90 | #define WBCIR_REG_SP3_MCR 0x04 /* Mode Control */ | ||
91 | #define WBCIR_REG_SP3_LSR 0x05 /* Link Status */ | ||
92 | #define WBCIR_REG_SP3_MSR 0x06 /* Modem Status */ | ||
93 | #define WBCIR_REG_SP3_ASCR 0x07 /* Aux Status and Control */ | ||
94 | /* Bank 2 */ | ||
95 | #define WBCIR_REG_SP3_BGDL 0x00 /* Baud Divisor LSB */ | ||
96 | #define WBCIR_REG_SP3_BGDH 0x01 /* Baud Divisor MSB */ | ||
97 | #define WBCIR_REG_SP3_EXCR1 0x02 /* Extended Control 1 */ | ||
98 | #define WBCIR_REG_SP3_EXCR2 0x04 /* Extended Control 2 */ | ||
99 | #define WBCIR_REG_SP3_TXFLV 0x06 /* TX FIFO Level */ | ||
100 | #define WBCIR_REG_SP3_RXFLV 0x07 /* RX FIFO Level */ | ||
101 | /* Bank 3 */ | ||
102 | #define WBCIR_REG_SP3_MRID 0x00 /* Module Identification */ | ||
103 | #define WBCIR_REG_SP3_SH_LCR 0x01 /* LCR Shadow */ | ||
104 | #define WBCIR_REG_SP3_SH_FCR 0x02 /* FCR Shadow */ | ||
105 | /* Bank 4 */ | ||
106 | #define WBCIR_REG_SP3_IRCR1 0x02 /* Infrared Control 1 */ | ||
107 | /* Bank 5 */ | ||
108 | #define WBCIR_REG_SP3_IRCR2 0x04 /* Infrared Control 2 */ | ||
109 | /* Bank 6 */ | ||
110 | #define WBCIR_REG_SP3_IRCR3 0x00 /* Infrared Control 3 */ | ||
111 | #define WBCIR_REG_SP3_SIR_PW 0x02 /* SIR Pulse Width */ | ||
112 | /* Bank 7 */ | ||
113 | #define WBCIR_REG_SP3_IRRXDC 0x00 /* IR RX Demod Control */ | ||
114 | #define WBCIR_REG_SP3_IRTXMC 0x01 /* IR TX Mod Control */ | ||
115 | #define WBCIR_REG_SP3_RCCFG 0x02 /* CEIR Config */ | ||
116 | #define WBCIR_REG_SP3_IRCFG1 0x04 /* Infrared Config 1 */ | ||
117 | #define WBCIR_REG_SP3_IRCFG4 0x07 /* Infrared Config 4 */ | ||
118 | |||
119 | /* | ||
120 | * Magic values follow | ||
121 | */ | ||
122 | |||
123 | /* No interrupts for WBCIR_REG_SP3_IER and WBCIR_REG_SP3_EIR */ | ||
124 | #define WBCIR_IRQ_NONE 0x00 | ||
125 | /* RX data bit for WBCIR_REG_SP3_IER and WBCIR_REG_SP3_EIR */ | ||
126 | #define WBCIR_IRQ_RX 0x01 | ||
127 | /* Over/Under-flow bit for WBCIR_REG_SP3_IER and WBCIR_REG_SP3_EIR */ | ||
128 | #define WBCIR_IRQ_ERR 0x04 | ||
129 | /* Led enable/disable bit for WBCIR_REG_ECEIR_CTS */ | ||
130 | #define WBCIR_LED_ENABLE 0x80 | ||
131 | /* RX data available bit for WBCIR_REG_SP3_LSR */ | ||
132 | #define WBCIR_RX_AVAIL 0x01 | ||
133 | /* RX disable bit for WBCIR_REG_SP3_ASCR */ | ||
134 | #define WBCIR_RX_DISABLE 0x20 | ||
135 | /* Extended mode enable bit for WBCIR_REG_SP3_EXCR1 */ | ||
136 | #define WBCIR_EXT_ENABLE 0x01 | ||
137 | /* Select compare register in WBCIR_REG_WCEIR_INDEX (bits 5 & 6) */ | ||
138 | #define WBCIR_REGSEL_COMPARE 0x10 | ||
139 | /* Select mask register in WBCIR_REG_WCEIR_INDEX (bits 5 & 6) */ | ||
140 | #define WBCIR_REGSEL_MASK 0x20 | ||
141 | /* Starting address of selected register in WBCIR_REG_WCEIR_INDEX */ | ||
142 | #define WBCIR_REG_ADDR0 0x00 | ||
143 | |||
144 | /* Valid banks for the SP3 UART */ | ||
145 | enum wbcir_bank { | ||
146 | WBCIR_BANK_0 = 0x00, | ||
147 | WBCIR_BANK_1 = 0x80, | ||
148 | WBCIR_BANK_2 = 0xE0, | ||
149 | WBCIR_BANK_3 = 0xE4, | ||
150 | WBCIR_BANK_4 = 0xE8, | ||
151 | WBCIR_BANK_5 = 0xEC, | ||
152 | WBCIR_BANK_6 = 0xF0, | ||
153 | WBCIR_BANK_7 = 0xF4, | ||
154 | }; | ||
155 | |||
156 | /* Supported IR Protocols */ | ||
157 | enum wbcir_protocol { | ||
158 | IR_PROTOCOL_RC5 = 0x0, | ||
159 | IR_PROTOCOL_NEC = 0x1, | ||
160 | IR_PROTOCOL_RC6 = 0x2, | ||
161 | }; | ||
162 | |||
163 | /* Misc */ | ||
164 | #define WBCIR_NAME "Winbond CIR" | ||
165 | #define WBCIR_ID_FAMILY 0xF1 /* Family ID for the WPCD376I */ | ||
166 | #define WBCIR_ID_CHIP 0x04 /* Chip ID for the WPCD376I */ | ||
167 | #define IR_KEYPRESS_TIMEOUT 250 /* FIXME: should be per-protocol? */ | ||
168 | #define INVALID_SCANCODE 0x7FFFFFFF /* Invalid with all protos */ | ||
169 | #define WAKEUP_IOMEM_LEN 0x10 /* Wake-Up I/O Reg Len */ | ||
170 | #define EHFUNC_IOMEM_LEN 0x10 /* Enhanced Func I/O Reg Len */ | ||
171 | #define SP_IOMEM_LEN 0x08 /* Serial Port 3 (IR) Reg Len */ | ||
172 | #define WBCIR_MAX_IDLE_BYTES 10 | ||
173 | |||
174 | static DEFINE_SPINLOCK(wbcir_lock); | ||
175 | static DEFINE_RWLOCK(keytable_lock); | ||
176 | |||
177 | struct wbcir_key { | ||
178 | u32 scancode; | ||
179 | unsigned int keycode; | ||
180 | }; | ||
181 | |||
182 | struct wbcir_keyentry { | ||
183 | struct wbcir_key key; | ||
184 | struct list_head list; | ||
185 | }; | ||
186 | |||
187 | static struct wbcir_key rc6_def_keymap[] = { | ||
188 | { 0x800F0400, KEY_NUMERIC_0 }, | ||
189 | { 0x800F0401, KEY_NUMERIC_1 }, | ||
190 | { 0x800F0402, KEY_NUMERIC_2 }, | ||
191 | { 0x800F0403, KEY_NUMERIC_3 }, | ||
192 | { 0x800F0404, KEY_NUMERIC_4 }, | ||
193 | { 0x800F0405, KEY_NUMERIC_5 }, | ||
194 | { 0x800F0406, KEY_NUMERIC_6 }, | ||
195 | { 0x800F0407, KEY_NUMERIC_7 }, | ||
196 | { 0x800F0408, KEY_NUMERIC_8 }, | ||
197 | { 0x800F0409, KEY_NUMERIC_9 }, | ||
198 | { 0x800F041D, KEY_NUMERIC_STAR }, | ||
199 | { 0x800F041C, KEY_NUMERIC_POUND }, | ||
200 | { 0x800F0410, KEY_VOLUMEUP }, | ||
201 | { 0x800F0411, KEY_VOLUMEDOWN }, | ||
202 | { 0x800F0412, KEY_CHANNELUP }, | ||
203 | { 0x800F0413, KEY_CHANNELDOWN }, | ||
204 | { 0x800F040E, KEY_MUTE }, | ||
205 | { 0x800F040D, KEY_VENDOR }, /* Vista Logo Key */ | ||
206 | { 0x800F041E, KEY_UP }, | ||
207 | { 0x800F041F, KEY_DOWN }, | ||
208 | { 0x800F0420, KEY_LEFT }, | ||
209 | { 0x800F0421, KEY_RIGHT }, | ||
210 | { 0x800F0422, KEY_OK }, | ||
211 | { 0x800F0423, KEY_ESC }, | ||
212 | { 0x800F040F, KEY_INFO }, | ||
213 | { 0x800F040A, KEY_CLEAR }, | ||
214 | { 0x800F040B, KEY_ENTER }, | ||
215 | { 0x800F045B, KEY_RED }, | ||
216 | { 0x800F045C, KEY_GREEN }, | ||
217 | { 0x800F045D, KEY_YELLOW }, | ||
218 | { 0x800F045E, KEY_BLUE }, | ||
219 | { 0x800F045A, KEY_TEXT }, | ||
220 | { 0x800F0427, KEY_SWITCHVIDEOMODE }, | ||
221 | { 0x800F040C, KEY_POWER }, | ||
222 | { 0x800F0450, KEY_RADIO }, | ||
223 | { 0x800F0448, KEY_PVR }, | ||
224 | { 0x800F0447, KEY_AUDIO }, | ||
225 | { 0x800F0426, KEY_EPG }, | ||
226 | { 0x800F0449, KEY_CAMERA }, | ||
227 | { 0x800F0425, KEY_TV }, | ||
228 | { 0x800F044A, KEY_VIDEO }, | ||
229 | { 0x800F0424, KEY_DVD }, | ||
230 | { 0x800F0416, KEY_PLAY }, | ||
231 | { 0x800F0418, KEY_PAUSE }, | ||
232 | { 0x800F0419, KEY_STOP }, | ||
233 | { 0x800F0414, KEY_FASTFORWARD }, | ||
234 | { 0x800F041A, KEY_NEXT }, | ||
235 | { 0x800F041B, KEY_PREVIOUS }, | ||
236 | { 0x800F0415, KEY_REWIND }, | ||
237 | { 0x800F0417, KEY_RECORD }, | ||
238 | }; | ||
239 | |||
240 | /* Registers and other state is protected by wbcir_lock */ | ||
241 | struct wbcir_data { | ||
242 | unsigned long wbase; /* Wake-Up Baseaddr */ | ||
243 | unsigned long ebase; /* Enhanced Func. Baseaddr */ | ||
244 | unsigned long sbase; /* Serial Port Baseaddr */ | ||
245 | unsigned int irq; /* Serial Port IRQ */ | ||
246 | |||
247 | struct input_dev *input_dev; | ||
248 | struct timer_list timer_keyup; | ||
249 | struct led_trigger *rxtrigger; | ||
250 | struct led_trigger *txtrigger; | ||
251 | struct led_classdev led; | ||
252 | |||
253 | u32 last_scancode; | ||
254 | unsigned int last_keycode; | ||
255 | u8 last_toggle; | ||
256 | u8 keypressed; | ||
257 | unsigned long keyup_jiffies; | ||
258 | unsigned int idle_count; | ||
259 | |||
260 | /* RX irdata and parsing state */ | ||
261 | unsigned long irdata[30]; | ||
262 | unsigned int irdata_count; | ||
263 | unsigned int irdata_idle; | ||
264 | unsigned int irdata_off; | ||
265 | unsigned int irdata_error; | ||
266 | |||
267 | /* Protected by keytable_lock */ | ||
268 | struct list_head keytable; | ||
269 | }; | ||
270 | |||
271 | static enum wbcir_protocol protocol = IR_PROTOCOL_RC6; | ||
272 | module_param(protocol, uint, 0444); | ||
273 | MODULE_PARM_DESC(protocol, "IR protocol to use " | ||
274 | "(0 = RC5, 1 = NEC, 2 = RC6A, default)"); | ||
275 | |||
276 | static int invert; /* default = 0 */ | ||
277 | module_param(invert, bool, 0444); | ||
278 | MODULE_PARM_DESC(invert, "Invert the signal from the IR receiver"); | ||
279 | |||
280 | static unsigned int wake_sc = 0x800F040C; | ||
281 | module_param(wake_sc, uint, 0644); | ||
282 | MODULE_PARM_DESC(wake_sc, "Scancode of the power-on IR command"); | ||
283 | |||
284 | static unsigned int wake_rc6mode = 6; | ||
285 | module_param(wake_rc6mode, uint, 0644); | ||
286 | MODULE_PARM_DESC(wake_rc6mode, "RC6 mode for the power-on command " | ||
287 | "(0 = 0, 6 = 6A, default)"); | ||
288 | |||
289 | |||
290 | |||
291 | /***************************************************************************** | ||
292 | * | ||
293 | * UTILITY FUNCTIONS | ||
294 | * | ||
295 | *****************************************************************************/ | ||
296 | |||
297 | /* Caller needs to hold wbcir_lock */ | ||
298 | static void | ||
299 | wbcir_set_bits(unsigned long addr, u8 bits, u8 mask) | ||
300 | { | ||
301 | u8 val; | ||
302 | |||
303 | val = inb(addr); | ||
304 | val = ((val & ~mask) | (bits & mask)); | ||
305 | outb(val, addr); | ||
306 | } | ||
307 | |||
308 | /* Selects the register bank for the serial port */ | ||
309 | static inline void | ||
310 | wbcir_select_bank(struct wbcir_data *data, enum wbcir_bank bank) | ||
311 | { | ||
312 | outb(bank, data->sbase + WBCIR_REG_SP3_BSR); | ||
313 | } | ||
314 | |||
315 | static enum led_brightness | ||
316 | wbcir_led_brightness_get(struct led_classdev *led_cdev) | ||
317 | { | ||
318 | struct wbcir_data *data = container_of(led_cdev, | ||
319 | struct wbcir_data, | ||
320 | led); | ||
321 | |||
322 | if (inb(data->ebase + WBCIR_REG_ECEIR_CTS) & WBCIR_LED_ENABLE) | ||
323 | return LED_FULL; | ||
324 | else | ||
325 | return LED_OFF; | ||
326 | } | ||
327 | |||
328 | static void | ||
329 | wbcir_led_brightness_set(struct led_classdev *led_cdev, | ||
330 | enum led_brightness brightness) | ||
331 | { | ||
332 | struct wbcir_data *data = container_of(led_cdev, | ||
333 | struct wbcir_data, | ||
334 | led); | ||
335 | |||
336 | wbcir_set_bits(data->ebase + WBCIR_REG_ECEIR_CTS, | ||
337 | brightness == LED_OFF ? 0x00 : WBCIR_LED_ENABLE, | ||
338 | WBCIR_LED_ENABLE); | ||
339 | } | ||
340 | |||
341 | /* Manchester encodes bits to RC6 message cells (see wbcir_parse_rc6) */ | ||
342 | static u8 | ||
343 | wbcir_to_rc6cells(u8 val) | ||
344 | { | ||
345 | u8 coded = 0x00; | ||
346 | int i; | ||
347 | |||
348 | val &= 0x0F; | ||
349 | for (i = 0; i < 4; i++) { | ||
350 | if (val & 0x01) | ||
351 | coded |= 0x02 << (i * 2); | ||
352 | else | ||
353 | coded |= 0x01 << (i * 2); | ||
354 | val >>= 1; | ||
355 | } | ||
356 | |||
357 | return coded; | ||
358 | } | ||
359 | |||
360 | |||
361 | |||
362 | /***************************************************************************** | ||
363 | * | ||
364 | * INPUT FUNCTIONS | ||
365 | * | ||
366 | *****************************************************************************/ | ||
367 | |||
368 | static unsigned int | ||
369 | wbcir_do_getkeycode(struct wbcir_data *data, u32 scancode) | ||
370 | { | ||
371 | struct wbcir_keyentry *keyentry; | ||
372 | unsigned int keycode = KEY_RESERVED; | ||
373 | unsigned long flags; | ||
374 | |||
375 | read_lock_irqsave(&keytable_lock, flags); | ||
376 | |||
377 | list_for_each_entry(keyentry, &data->keytable, list) { | ||
378 | if (keyentry->key.scancode == scancode) { | ||
379 | keycode = keyentry->key.keycode; | ||
380 | break; | ||
381 | } | ||
382 | } | ||
383 | |||
384 | read_unlock_irqrestore(&keytable_lock, flags); | ||
385 | return keycode; | ||
386 | } | ||
387 | |||
388 | static int | ||
389 | wbcir_getkeycode(struct input_dev *dev, | ||
390 | unsigned int scancode, unsigned int *keycode) | ||
391 | { | ||
392 | struct wbcir_data *data = input_get_drvdata(dev); | ||
393 | |||
394 | *keycode = wbcir_do_getkeycode(data, scancode); | ||
395 | return 0; | ||
396 | } | ||
397 | |||
398 | static int | ||
399 | wbcir_setkeycode(struct input_dev *dev, | ||
400 | unsigned int scancode, unsigned int keycode) | ||
401 | { | ||
402 | struct wbcir_data *data = input_get_drvdata(dev); | ||
403 | struct wbcir_keyentry *keyentry; | ||
404 | struct wbcir_keyentry *new_keyentry; | ||
405 | unsigned long flags; | ||
406 | unsigned int old_keycode = KEY_RESERVED; | ||
407 | |||
408 | new_keyentry = kmalloc(sizeof(*new_keyentry), GFP_KERNEL); | ||
409 | if (!new_keyentry) | ||
410 | return -ENOMEM; | ||
411 | |||
412 | write_lock_irqsave(&keytable_lock, flags); | ||
413 | |||
414 | list_for_each_entry(keyentry, &data->keytable, list) { | ||
415 | if (keyentry->key.scancode != scancode) | ||
416 | continue; | ||
417 | |||
418 | old_keycode = keyentry->key.keycode; | ||
419 | keyentry->key.keycode = keycode; | ||
420 | |||
421 | if (keyentry->key.keycode == KEY_RESERVED) { | ||
422 | list_del(&keyentry->list); | ||
423 | kfree(keyentry); | ||
424 | } | ||
425 | |||
426 | break; | ||
427 | } | ||
428 | |||
429 | set_bit(keycode, dev->keybit); | ||
430 | |||
431 | if (old_keycode == KEY_RESERVED) { | ||
432 | new_keyentry->key.scancode = scancode; | ||
433 | new_keyentry->key.keycode = keycode; | ||
434 | list_add(&new_keyentry->list, &data->keytable); | ||
435 | } else { | ||
436 | kfree(new_keyentry); | ||
437 | clear_bit(old_keycode, dev->keybit); | ||
438 | list_for_each_entry(keyentry, &data->keytable, list) { | ||
439 | if (keyentry->key.keycode == old_keycode) { | ||
440 | set_bit(old_keycode, dev->keybit); | ||
441 | break; | ||
442 | } | ||
443 | } | ||
444 | } | ||
445 | |||
446 | write_unlock_irqrestore(&keytable_lock, flags); | ||
447 | return 0; | ||
448 | } | ||
449 | |||
450 | /* | ||
451 | * Timer function to report keyup event some time after keydown is | ||
452 | * reported by the ISR. | ||
453 | */ | ||
454 | static void | ||
455 | wbcir_keyup(unsigned long cookie) | ||
456 | { | ||
457 | struct wbcir_data *data = (struct wbcir_data *)cookie; | ||
458 | unsigned long flags; | ||
459 | |||
460 | /* | ||
461 | * data->keyup_jiffies is used to prevent a race condition if a | ||
462 | * hardware interrupt occurs at this point and the keyup timer | ||
463 | * event is moved further into the future as a result. | ||
464 | * | ||
465 | * The timer will then be reactivated and this function called | ||
466 | * again in the future. We need to exit gracefully in that case | ||
467 | * to allow the input subsystem to do its auto-repeat magic or | ||
468 | * a keyup event might follow immediately after the keydown. | ||
469 | */ | ||
470 | |||
471 | spin_lock_irqsave(&wbcir_lock, flags); | ||
472 | |||
473 | if (time_is_after_eq_jiffies(data->keyup_jiffies) && data->keypressed) { | ||
474 | data->keypressed = 0; | ||
475 | led_trigger_event(data->rxtrigger, LED_OFF); | ||
476 | input_report_key(data->input_dev, data->last_keycode, 0); | ||
477 | input_sync(data->input_dev); | ||
478 | } | ||
479 | |||
480 | spin_unlock_irqrestore(&wbcir_lock, flags); | ||
481 | } | ||
482 | |||
483 | static void | ||
484 | wbcir_keydown(struct wbcir_data *data, u32 scancode, u8 toggle) | ||
485 | { | ||
486 | unsigned int keycode; | ||
487 | |||
488 | /* Repeat? */ | ||
489 | if (data->last_scancode == scancode && | ||
490 | data->last_toggle == toggle && | ||
491 | data->keypressed) | ||
492 | goto set_timer; | ||
493 | data->last_scancode = scancode; | ||
494 | |||
495 | /* Do we need to release an old keypress? */ | ||
496 | if (data->keypressed) { | ||
497 | input_report_key(data->input_dev, data->last_keycode, 0); | ||
498 | input_sync(data->input_dev); | ||
499 | data->keypressed = 0; | ||
500 | } | ||
501 | |||
502 | /* Report scancode */ | ||
503 | input_event(data->input_dev, EV_MSC, MSC_SCAN, (int)scancode); | ||
504 | |||
505 | /* Do we know this scancode? */ | ||
506 | keycode = wbcir_do_getkeycode(data, scancode); | ||
507 | if (keycode == KEY_RESERVED) | ||
508 | goto set_timer; | ||
509 | |||
510 | /* Register a keypress */ | ||
511 | input_report_key(data->input_dev, keycode, 1); | ||
512 | data->keypressed = 1; | ||
513 | data->last_keycode = keycode; | ||
514 | data->last_toggle = toggle; | ||
515 | |||
516 | set_timer: | ||
517 | input_sync(data->input_dev); | ||
518 | led_trigger_event(data->rxtrigger, | ||
519 | data->keypressed ? LED_FULL : LED_OFF); | ||
520 | data->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT); | ||
521 | mod_timer(&data->timer_keyup, data->keyup_jiffies); | ||
522 | } | ||
523 | |||
524 | |||
525 | |||
526 | /***************************************************************************** | ||
527 | * | ||
528 | * IR PARSING FUNCTIONS | ||
529 | * | ||
530 | *****************************************************************************/ | ||
531 | |||
532 | /* Resets all irdata */ | ||
533 | static void | ||
534 | wbcir_reset_irdata(struct wbcir_data *data) | ||
535 | { | ||
536 | memset(data->irdata, 0, sizeof(data->irdata)); | ||
537 | data->irdata_count = 0; | ||
538 | data->irdata_off = 0; | ||
539 | data->irdata_error = 0; | ||
540 | data->idle_count = 0; | ||
541 | } | ||
542 | |||
543 | /* Adds one bit of irdata */ | ||
544 | static void | ||
545 | add_irdata_bit(struct wbcir_data *data, int set) | ||
546 | { | ||
547 | if (data->irdata_count >= sizeof(data->irdata) * 8) { | ||
548 | data->irdata_error = 1; | ||
549 | return; | ||
550 | } | ||
551 | |||
552 | if (set) | ||
553 | __set_bit(data->irdata_count, data->irdata); | ||
554 | data->irdata_count++; | ||
555 | } | ||
556 | |||
557 | /* Gets count bits of irdata */ | ||
558 | static u16 | ||
559 | get_bits(struct wbcir_data *data, int count) | ||
560 | { | ||
561 | u16 val = 0x0; | ||
562 | |||
563 | if (data->irdata_count - data->irdata_off < count) { | ||
564 | data->irdata_error = 1; | ||
565 | return 0x0; | ||
566 | } | ||
567 | |||
568 | while (count > 0) { | ||
569 | val <<= 1; | ||
570 | if (test_bit(data->irdata_off, data->irdata)) | ||
571 | val |= 0x1; | ||
572 | count--; | ||
573 | data->irdata_off++; | ||
574 | } | ||
575 | |||
576 | return val; | ||
577 | } | ||
578 | |||
579 | /* Reads 16 cells and converts them to a byte */ | ||
580 | static u8 | ||
581 | wbcir_rc6cells_to_byte(struct wbcir_data *data) | ||
582 | { | ||
583 | u16 raw = get_bits(data, 16); | ||
584 | u8 val = 0x00; | ||
585 | int bit; | ||
586 | |||
587 | for (bit = 0; bit < 8; bit++) { | ||
588 | switch (raw & 0x03) { | ||
589 | case 0x01: | ||
590 | break; | ||
591 | case 0x02: | ||
592 | val |= (0x01 << bit); | ||
593 | break; | ||
594 | default: | ||
595 | data->irdata_error = 1; | ||
596 | break; | ||
597 | } | ||
598 | raw >>= 2; | ||
599 | } | ||
600 | |||
601 | return val; | ||
602 | } | ||
603 | |||
604 | /* Decodes a number of bits from raw RC5 data */ | ||
605 | static u8 | ||
606 | wbcir_get_rc5bits(struct wbcir_data *data, unsigned int count) | ||
607 | { | ||
608 | u16 raw = get_bits(data, count * 2); | ||
609 | u8 val = 0x00; | ||
610 | int bit; | ||
611 | |||
612 | for (bit = 0; bit < count; bit++) { | ||
613 | switch (raw & 0x03) { | ||
614 | case 0x01: | ||
615 | val |= (0x01 << bit); | ||
616 | break; | ||
617 | case 0x02: | ||
618 | break; | ||
619 | default: | ||
620 | data->irdata_error = 1; | ||
621 | break; | ||
622 | } | ||
623 | raw >>= 2; | ||
624 | } | ||
625 | |||
626 | return val; | ||
627 | } | ||
628 | |||
629 | static void | ||
630 | wbcir_parse_rc6(struct device *dev, struct wbcir_data *data) | ||
631 | { | ||
632 | /* | ||
633 | * Normal bits are manchester coded as follows: | ||
634 | * cell0 + cell1 = logic "0" | ||
635 | * cell1 + cell0 = logic "1" | ||
636 | * | ||
637 | * The IR pulse has the following components: | ||
638 | * | ||
639 | * Leader - 6 * cell1 - discarded | ||
640 | * Gap - 2 * cell0 - discarded | ||
641 | * Start bit - Normal Coding - always "1" | ||
642 | * Mode Bit 2 - 0 - Normal Coding | ||
643 | * Toggle bit - Normal Coding with double bit time, | ||
644 | * e.g. cell0 + cell0 + cell1 + cell1 | ||
645 | * means logic "0". | ||
646 | * | ||
647 | * The rest depends on the mode, the following modes are known: | ||
648 | * | ||
649 | * MODE 0: | ||
650 | * Address Bit 7 - 0 - Normal Coding | ||
651 | * Command Bit 7 - 0 - Normal Coding | ||
652 | * | ||
653 | * MODE 6: | ||
654 | * The above Toggle Bit is used as a submode bit, 0 = A, 1 = B. | ||
655 | * Submode B is for pointing devices, only remotes using submode A | ||
656 | * are supported. | ||
657 | * | ||
658 | * Customer range bit - 0 => Customer = 7 bits, 0...127 | ||
659 | * 1 => Customer = 15 bits, 32768...65535 | ||
660 | * Customer Bits - Normal Coding | ||
661 | * | ||
662 | * Customer codes are allocated by Philips. The rest of the bits | ||
663 | * are customer dependent. The following is commonly used (and the | ||
664 | * only supported config): | ||
665 | * | ||
666 | * Toggle Bit - Normal Coding | ||
667 | * Address Bit 6 - 0 - Normal Coding | ||
668 | * Command Bit 7 - 0 - Normal Coding | ||
669 | * | ||
670 | * All modes are followed by at least 6 * cell0. | ||
671 | * | ||
672 | * MODE 0 msglen: | ||
673 | * 1 * 2 (start bit) + 3 * 2 (mode) + 2 * 2 (toggle) + | ||
674 | * 8 * 2 (address) + 8 * 2 (command) = | ||
675 | * 44 cells | ||
676 | * | ||
677 | * MODE 6A msglen: | ||
678 | * 1 * 2 (start bit) + 3 * 2 (mode) + 2 * 2 (submode) + | ||
679 | * 1 * 2 (customer range bit) + 7/15 * 2 (customer bits) + | ||
680 | * 1 * 2 (toggle bit) + 7 * 2 (address) + 8 * 2 (command) = | ||
681 | * 60 - 76 cells | ||
682 | */ | ||
683 | u8 mode; | ||
684 | u8 toggle; | ||
685 | u16 customer = 0x0; | ||
686 | u8 address; | ||
687 | u8 command; | ||
688 | u32 scancode; | ||
689 | |||
690 | /* Leader mark */ | ||
691 | while (get_bits(data, 1) && !data->irdata_error) | ||
692 | /* Do nothing */; | ||
693 | |||
694 | /* Leader space */ | ||
695 | if (get_bits(data, 1)) { | ||
696 | dev_dbg(dev, "RC6 - Invalid leader space\n"); | ||
697 | return; | ||
698 | } | ||
699 | |||
700 | /* Start bit */ | ||
701 | if (get_bits(data, 2) != 0x02) { | ||
702 | dev_dbg(dev, "RC6 - Invalid start bit\n"); | ||
703 | return; | ||
704 | } | ||
705 | |||
706 | /* Mode */ | ||
707 | mode = get_bits(data, 6); | ||
708 | switch (mode) { | ||
709 | case 0x15: /* 010101 = b000 */ | ||
710 | mode = 0; | ||
711 | break; | ||
712 | case 0x29: /* 101001 = b110 */ | ||
713 | mode = 6; | ||
714 | break; | ||
715 | default: | ||
716 | dev_dbg(dev, "RC6 - Invalid mode\n"); | ||
717 | return; | ||
718 | } | ||
719 | |||
720 | /* Toggle bit / Submode bit */ | ||
721 | toggle = get_bits(data, 4); | ||
722 | switch (toggle) { | ||
723 | case 0x03: | ||
724 | toggle = 0; | ||
725 | break; | ||
726 | case 0x0C: | ||
727 | toggle = 1; | ||
728 | break; | ||
729 | default: | ||
730 | dev_dbg(dev, "RC6 - Toggle bit error\n"); | ||
731 | break; | ||
732 | } | ||
733 | |||
734 | /* Customer */ | ||
735 | if (mode == 6) { | ||
736 | if (toggle != 0) { | ||
737 | dev_dbg(dev, "RC6B - Not Supported\n"); | ||
738 | return; | ||
739 | } | ||
740 | |||
741 | customer = wbcir_rc6cells_to_byte(data); | ||
742 | |||
743 | if (customer & 0x80) { | ||
744 | /* 15 bit customer value */ | ||
745 | customer <<= 8; | ||
746 | customer |= wbcir_rc6cells_to_byte(data); | ||
747 | } | ||
748 | } | ||
749 | |||
750 | /* Address */ | ||
751 | address = wbcir_rc6cells_to_byte(data); | ||
752 | if (mode == 6) { | ||
753 | toggle = address >> 7; | ||
754 | address &= 0x7F; | ||
755 | } | ||
756 | |||
757 | /* Command */ | ||
758 | command = wbcir_rc6cells_to_byte(data); | ||
759 | |||
760 | /* Create scancode */ | ||
761 | scancode = command; | ||
762 | scancode |= address << 8; | ||
763 | scancode |= customer << 16; | ||
764 | |||
765 | /* Last sanity check */ | ||
766 | if (data->irdata_error) { | ||
767 | dev_dbg(dev, "RC6 - Cell error(s)\n"); | ||
768 | return; | ||
769 | } | ||
770 | |||
771 | dev_dbg(dev, "IR-RC6 ad 0x%02X cm 0x%02X cu 0x%04X " | ||
772 | "toggle %u mode %u scan 0x%08X\n", | ||
773 | address, | ||
774 | command, | ||
775 | customer, | ||
776 | (unsigned int)toggle, | ||
777 | (unsigned int)mode, | ||
778 | scancode); | ||
779 | |||
780 | wbcir_keydown(data, scancode, toggle); | ||
781 | } | ||
782 | |||
783 | static void | ||
784 | wbcir_parse_rc5(struct device *dev, struct wbcir_data *data) | ||
785 | { | ||
786 | /* | ||
787 | * Bits are manchester coded as follows: | ||
788 | * cell1 + cell0 = logic "0" | ||
789 | * cell0 + cell1 = logic "1" | ||
790 | * (i.e. the reverse of RC6) | ||
791 | * | ||
792 | * Start bit 1 - "1" - discarded | ||
793 | * Start bit 2 - Must be inverted to get command bit 6 | ||
794 | * Toggle bit | ||
795 | * Address Bit 4 - 0 | ||
796 | * Command Bit 5 - 0 | ||
797 | */ | ||
798 | u8 toggle; | ||
799 | u8 address; | ||
800 | u8 command; | ||
801 | u32 scancode; | ||
802 | |||
803 | /* Start bit 1 */ | ||
804 | if (!get_bits(data, 1)) { | ||
805 | dev_dbg(dev, "RC5 - Invalid start bit\n"); | ||
806 | return; | ||
807 | } | ||
808 | |||
809 | /* Start bit 2 */ | ||
810 | if (!wbcir_get_rc5bits(data, 1)) | ||
811 | command = 0x40; | ||
812 | else | ||
813 | command = 0x00; | ||
814 | |||
815 | toggle = wbcir_get_rc5bits(data, 1); | ||
816 | address = wbcir_get_rc5bits(data, 5); | ||
817 | command |= wbcir_get_rc5bits(data, 6); | ||
818 | scancode = address << 7 | command; | ||
819 | |||
820 | /* Last sanity check */ | ||
821 | if (data->irdata_error) { | ||
822 | dev_dbg(dev, "RC5 - Invalid message\n"); | ||
823 | return; | ||
824 | } | ||
825 | |||
826 | dev_dbg(dev, "IR-RC5 ad %u cm %u t %u s %u\n", | ||
827 | (unsigned int)address, | ||
828 | (unsigned int)command, | ||
829 | (unsigned int)toggle, | ||
830 | (unsigned int)scancode); | ||
831 | |||
832 | wbcir_keydown(data, scancode, toggle); | ||
833 | } | ||
834 | |||
835 | static void | ||
836 | wbcir_parse_nec(struct device *dev, struct wbcir_data *data) | ||
837 | { | ||
838 | /* | ||
839 | * Each bit represents 560 us. | ||
840 | * | ||
841 | * Leader - 9 ms burst | ||
842 | * Gap - 4.5 ms silence | ||
843 | * Address1 bit 0 - 7 - Address 1 | ||
844 | * Address2 bit 0 - 7 - Address 2 | ||
845 | * Command1 bit 0 - 7 - Command 1 | ||
846 | * Command2 bit 0 - 7 - Command 2 | ||
847 | * | ||
848 | * Note the bit order! | ||
849 | * | ||
850 | * With the old NEC protocol, Address2 was the inverse of Address1 | ||
851 | * and Command2 was the inverse of Command1 and were used as | ||
852 | * an error check. | ||
853 | * | ||
854 | * With NEC extended, Address1 is the LSB of the Address and | ||
855 | * Address2 is the MSB, Command parsing remains unchanged. | ||
856 | * | ||
857 | * A repeat message is coded as: | ||
858 | * Leader - 9 ms burst | ||
859 | * Gap - 2.25 ms silence | ||
860 | * Repeat - 560 us active | ||
861 | */ | ||
862 | u8 address1; | ||
863 | u8 address2; | ||
864 | u8 command1; | ||
865 | u8 command2; | ||
866 | u16 address; | ||
867 | u32 scancode; | ||
868 | |||
869 | /* Leader mark */ | ||
870 | while (get_bits(data, 1) && !data->irdata_error) | ||
871 | /* Do nothing */; | ||
872 | |||
873 | /* Leader space */ | ||
874 | if (get_bits(data, 4)) { | ||
875 | dev_dbg(dev, "NEC - Invalid leader space\n"); | ||
876 | return; | ||
877 | } | ||
878 | |||
879 | /* Repeat? */ | ||
880 | if (get_bits(data, 1)) { | ||
881 | if (!data->keypressed) { | ||
882 | dev_dbg(dev, "NEC - Stray repeat message\n"); | ||
883 | return; | ||
884 | } | ||
885 | |||
886 | dev_dbg(dev, "IR-NEC repeat s %u\n", | ||
887 | (unsigned int)data->last_scancode); | ||
888 | |||
889 | wbcir_keydown(data, data->last_scancode, data->last_toggle); | ||
890 | return; | ||
891 | } | ||
892 | |||
893 | /* Remaining leader space */ | ||
894 | if (get_bits(data, 3)) { | ||
895 | dev_dbg(dev, "NEC - Invalid leader space\n"); | ||
896 | return; | ||
897 | } | ||
898 | |||
899 | address1 = bitrev8(get_bits(data, 8)); | ||
900 | address2 = bitrev8(get_bits(data, 8)); | ||
901 | command1 = bitrev8(get_bits(data, 8)); | ||
902 | command2 = bitrev8(get_bits(data, 8)); | ||
903 | |||
904 | /* Sanity check */ | ||
905 | if (data->irdata_error) { | ||
906 | dev_dbg(dev, "NEC - Invalid message\n"); | ||
907 | return; | ||
908 | } | ||
909 | |||
910 | /* Check command validity */ | ||
911 | if (command1 != ~command2) { | ||
912 | dev_dbg(dev, "NEC - Command bytes mismatch\n"); | ||
913 | return; | ||
914 | } | ||
915 | |||
916 | /* Check for extended NEC protocol */ | ||
917 | address = address1; | ||
918 | if (address1 != ~address2) | ||
919 | address |= address2 << 8; | ||
920 | |||
921 | scancode = address << 8 | command1; | ||
922 | |||
923 | dev_dbg(dev, "IR-NEC ad %u cm %u s %u\n", | ||
924 | (unsigned int)address, | ||
925 | (unsigned int)command1, | ||
926 | (unsigned int)scancode); | ||
927 | |||
928 | wbcir_keydown(data, scancode, !data->last_toggle); | ||
929 | } | ||
930 | |||
931 | |||
932 | |||
933 | /***************************************************************************** | ||
934 | * | ||
935 | * INTERRUPT FUNCTIONS | ||
936 | * | ||
937 | *****************************************************************************/ | ||
938 | |||
939 | static irqreturn_t | ||
940 | wbcir_irq_handler(int irqno, void *cookie) | ||
941 | { | ||
942 | struct pnp_dev *device = cookie; | ||
943 | struct wbcir_data *data = pnp_get_drvdata(device); | ||
944 | struct device *dev = &device->dev; | ||
945 | u8 status; | ||
946 | unsigned long flags; | ||
947 | u8 irdata[8]; | ||
948 | int i; | ||
949 | unsigned int hw; | ||
950 | |||
951 | spin_lock_irqsave(&wbcir_lock, flags); | ||
952 | |||
953 | wbcir_select_bank(data, WBCIR_BANK_0); | ||
954 | |||
955 | status = inb(data->sbase + WBCIR_REG_SP3_EIR); | ||
956 | |||
957 | if (!(status & (WBCIR_IRQ_RX | WBCIR_IRQ_ERR))) { | ||
958 | spin_unlock_irqrestore(&wbcir_lock, flags); | ||
959 | return IRQ_NONE; | ||
960 | } | ||
961 | |||
962 | if (status & WBCIR_IRQ_ERR) | ||
963 | data->irdata_error = 1; | ||
964 | |||
965 | if (!(status & WBCIR_IRQ_RX)) | ||
966 | goto out; | ||
967 | |||
968 | /* Since RXHDLEV is set, at least 8 bytes are in the FIFO */ | ||
969 | insb(data->sbase + WBCIR_REG_SP3_RXDATA, &irdata[0], 8); | ||
970 | |||
971 | for (i = 0; i < sizeof(irdata); i++) { | ||
972 | hw = hweight8(irdata[i]); | ||
973 | if (hw > 4) | ||
974 | add_irdata_bit(data, 0); | ||
975 | else | ||
976 | add_irdata_bit(data, 1); | ||
977 | |||
978 | if (hw == 8) | ||
979 | data->idle_count++; | ||
980 | else | ||
981 | data->idle_count = 0; | ||
982 | } | ||
983 | |||
984 | if (data->idle_count > WBCIR_MAX_IDLE_BYTES) { | ||
985 | /* Set RXINACTIVE... */ | ||
986 | outb(WBCIR_RX_DISABLE, data->sbase + WBCIR_REG_SP3_ASCR); | ||
987 | |||
988 | /* ...and drain the FIFO */ | ||
989 | while (inb(data->sbase + WBCIR_REG_SP3_LSR) & WBCIR_RX_AVAIL) | ||
990 | inb(data->sbase + WBCIR_REG_SP3_RXDATA); | ||
991 | |||
992 | dev_dbg(dev, "IRDATA:\n"); | ||
993 | for (i = 0; i < data->irdata_count; i += BITS_PER_LONG) | ||
994 | dev_dbg(dev, "0x%08lX\n", data->irdata[i/BITS_PER_LONG]); | ||
995 | |||
996 | switch (protocol) { | ||
997 | case IR_PROTOCOL_RC5: | ||
998 | wbcir_parse_rc5(dev, data); | ||
999 | break; | ||
1000 | case IR_PROTOCOL_RC6: | ||
1001 | wbcir_parse_rc6(dev, data); | ||
1002 | break; | ||
1003 | case IR_PROTOCOL_NEC: | ||
1004 | wbcir_parse_nec(dev, data); | ||
1005 | break; | ||
1006 | } | ||
1007 | |||
1008 | wbcir_reset_irdata(data); | ||
1009 | } | ||
1010 | |||
1011 | out: | ||
1012 | spin_unlock_irqrestore(&wbcir_lock, flags); | ||
1013 | return IRQ_HANDLED; | ||
1014 | } | ||
1015 | |||
1016 | |||
1017 | |||
1018 | /***************************************************************************** | ||
1019 | * | ||
1020 | * SETUP/INIT/SUSPEND/RESUME FUNCTIONS | ||
1021 | * | ||
1022 | *****************************************************************************/ | ||
1023 | |||
1024 | static void | ||
1025 | wbcir_shutdown(struct pnp_dev *device) | ||
1026 | { | ||
1027 | struct device *dev = &device->dev; | ||
1028 | struct wbcir_data *data = pnp_get_drvdata(device); | ||
1029 | int do_wake = 1; | ||
1030 | u8 match[11]; | ||
1031 | u8 mask[11]; | ||
1032 | u8 rc6_csl = 0; | ||
1033 | int i; | ||
1034 | |||
1035 | memset(match, 0, sizeof(match)); | ||
1036 | memset(mask, 0, sizeof(mask)); | ||
1037 | |||
1038 | if (wake_sc == INVALID_SCANCODE || !device_may_wakeup(dev)) { | ||
1039 | do_wake = 0; | ||
1040 | goto finish; | ||
1041 | } | ||
1042 | |||
1043 | switch (protocol) { | ||
1044 | case IR_PROTOCOL_RC5: | ||
1045 | if (wake_sc > 0xFFF) { | ||
1046 | do_wake = 0; | ||
1047 | dev_err(dev, "RC5 - Invalid wake scancode\n"); | ||
1048 | break; | ||
1049 | } | ||
1050 | |||
1051 | /* Mask = 13 bits, ex toggle */ | ||
1052 | mask[0] = 0xFF; | ||
1053 | mask[1] = 0x17; | ||
1054 | |||
1055 | match[0] = (wake_sc & 0x003F); /* 6 command bits */ | ||
1056 | match[0] |= (wake_sc & 0x0180) >> 1; /* 2 address bits */ | ||
1057 | match[1] = (wake_sc & 0x0E00) >> 9; /* 3 address bits */ | ||
1058 | if (!(wake_sc & 0x0040)) /* 2nd start bit */ | ||
1059 | match[1] |= 0x10; | ||
1060 | |||
1061 | break; | ||
1062 | |||
1063 | case IR_PROTOCOL_NEC: | ||
1064 | if (wake_sc > 0xFFFFFF) { | ||
1065 | do_wake = 0; | ||
1066 | dev_err(dev, "NEC - Invalid wake scancode\n"); | ||
1067 | break; | ||
1068 | } | ||
1069 | |||
1070 | mask[0] = mask[1] = mask[2] = mask[3] = 0xFF; | ||
1071 | |||
1072 | match[1] = bitrev8((wake_sc & 0xFF)); | ||
1073 | match[0] = ~match[1]; | ||
1074 | |||
1075 | match[3] = bitrev8((wake_sc & 0xFF00) >> 8); | ||
1076 | if (wake_sc > 0xFFFF) | ||
1077 | match[2] = bitrev8((wake_sc & 0xFF0000) >> 16); | ||
1078 | else | ||
1079 | match[2] = ~match[3]; | ||
1080 | |||
1081 | break; | ||
1082 | |||
1083 | case IR_PROTOCOL_RC6: | ||
1084 | |||
1085 | if (wake_rc6mode == 0) { | ||
1086 | if (wake_sc > 0xFFFF) { | ||
1087 | do_wake = 0; | ||
1088 | dev_err(dev, "RC6 - Invalid wake scancode\n"); | ||
1089 | break; | ||
1090 | } | ||
1091 | |||
1092 | /* Command */ | ||
1093 | match[0] = wbcir_to_rc6cells(wake_sc >> 0); | ||
1094 | mask[0] = 0xFF; | ||
1095 | match[1] = wbcir_to_rc6cells(wake_sc >> 4); | ||
1096 | mask[1] = 0xFF; | ||
1097 | |||
1098 | /* Address */ | ||
1099 | match[2] = wbcir_to_rc6cells(wake_sc >> 8); | ||
1100 | mask[2] = 0xFF; | ||
1101 | match[3] = wbcir_to_rc6cells(wake_sc >> 12); | ||
1102 | mask[3] = 0xFF; | ||
1103 | |||
1104 | /* Header */ | ||
1105 | match[4] = 0x50; /* mode1 = mode0 = 0, ignore toggle */ | ||
1106 | mask[4] = 0xF0; | ||
1107 | match[5] = 0x09; /* start bit = 1, mode2 = 0 */ | ||
1108 | mask[5] = 0x0F; | ||
1109 | |||
1110 | rc6_csl = 44; | ||
1111 | |||
1112 | } else if (wake_rc6mode == 6) { | ||
1113 | i = 0; | ||
1114 | |||
1115 | /* Command */ | ||
1116 | match[i] = wbcir_to_rc6cells(wake_sc >> 0); | ||
1117 | mask[i++] = 0xFF; | ||
1118 | match[i] = wbcir_to_rc6cells(wake_sc >> 4); | ||
1119 | mask[i++] = 0xFF; | ||
1120 | |||
1121 | /* Address + Toggle */ | ||
1122 | match[i] = wbcir_to_rc6cells(wake_sc >> 8); | ||
1123 | mask[i++] = 0xFF; | ||
1124 | match[i] = wbcir_to_rc6cells(wake_sc >> 12); | ||
1125 | mask[i++] = 0x3F; | ||
1126 | |||
1127 | /* Customer bits 7 - 0 */ | ||
1128 | match[i] = wbcir_to_rc6cells(wake_sc >> 16); | ||
1129 | mask[i++] = 0xFF; | ||
1130 | match[i] = wbcir_to_rc6cells(wake_sc >> 20); | ||
1131 | mask[i++] = 0xFF; | ||
1132 | |||
1133 | if (wake_sc & 0x80000000) { | ||
1134 | /* Customer range bit and bits 15 - 8 */ | ||
1135 | match[i] = wbcir_to_rc6cells(wake_sc >> 24); | ||
1136 | mask[i++] = 0xFF; | ||
1137 | match[i] = wbcir_to_rc6cells(wake_sc >> 28); | ||
1138 | mask[i++] = 0xFF; | ||
1139 | rc6_csl = 76; | ||
1140 | } else if (wake_sc <= 0x007FFFFF) { | ||
1141 | rc6_csl = 60; | ||
1142 | } else { | ||
1143 | do_wake = 0; | ||
1144 | dev_err(dev, "RC6 - Invalid wake scancode\n"); | ||
1145 | break; | ||
1146 | } | ||
1147 | |||
1148 | /* Header */ | ||
1149 | match[i] = 0x93; /* mode1 = mode0 = 1, submode = 0 */ | ||
1150 | mask[i++] = 0xFF; | ||
1151 | match[i] = 0x0A; /* start bit = 1, mode2 = 1 */ | ||
1152 | mask[i++] = 0x0F; | ||
1153 | |||
1154 | } else { | ||
1155 | do_wake = 0; | ||
1156 | dev_err(dev, "RC6 - Invalid wake mode\n"); | ||
1157 | } | ||
1158 | |||
1159 | break; | ||
1160 | |||
1161 | default: | ||
1162 | do_wake = 0; | ||
1163 | break; | ||
1164 | } | ||
1165 | |||
1166 | finish: | ||
1167 | if (do_wake) { | ||
1168 | /* Set compare and compare mask */ | ||
1169 | wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_INDEX, | ||
1170 | WBCIR_REGSEL_COMPARE | WBCIR_REG_ADDR0, | ||
1171 | 0x3F); | ||
1172 | outsb(data->wbase + WBCIR_REG_WCEIR_DATA, match, 11); | ||
1173 | wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_INDEX, | ||
1174 | WBCIR_REGSEL_MASK | WBCIR_REG_ADDR0, | ||
1175 | 0x3F); | ||
1176 | outsb(data->wbase + WBCIR_REG_WCEIR_DATA, mask, 11); | ||
1177 | |||
1178 | /* RC6 Compare String Len */ | ||
1179 | outb(rc6_csl, data->wbase + WBCIR_REG_WCEIR_CSL); | ||
1180 | |||
1181 | /* Clear status bits NEC_REP, BUFF, MSG_END, MATCH */ | ||
1182 | wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_STS, 0x17, 0x17); | ||
1183 | |||
1184 | /* Clear BUFF_EN, Clear END_EN, Set MATCH_EN */ | ||
1185 | wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_EV_EN, 0x01, 0x07); | ||
1186 | |||
1187 | /* Set CEIR_EN */ | ||
1188 | wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_CTL, 0x01, 0x01); | ||
1189 | |||
1190 | } else { | ||
1191 | /* Clear BUFF_EN, Clear END_EN, Clear MATCH_EN */ | ||
1192 | wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_EV_EN, 0x00, 0x07); | ||
1193 | |||
1194 | /* Clear CEIR_EN */ | ||
1195 | wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_CTL, 0x00, 0x01); | ||
1196 | } | ||
1197 | |||
1198 | /* Disable interrupts */ | ||
1199 | wbcir_select_bank(data, WBCIR_BANK_0); | ||
1200 | outb(WBCIR_IRQ_NONE, data->sbase + WBCIR_REG_SP3_IER); | ||
1201 | |||
1202 | /* | ||
1203 | * ACPI will set the HW disable bit for SP3 which means that the | ||
1204 | * output signals are left in an undefined state which may cause | ||
1205 | * spurious interrupts which we need to ignore until the hardware | ||
1206 | * is reinitialized. | ||
1207 | */ | ||
1208 | disable_irq(data->irq); | ||
1209 | } | ||
1210 | |||
1211 | static int | ||
1212 | wbcir_suspend(struct pnp_dev *device, pm_message_t state) | ||
1213 | { | ||
1214 | wbcir_shutdown(device); | ||
1215 | return 0; | ||
1216 | } | ||
1217 | |||
1218 | static void | ||
1219 | wbcir_init_hw(struct wbcir_data *data) | ||
1220 | { | ||
1221 | u8 tmp; | ||
1222 | |||
1223 | /* Disable interrupts */ | ||
1224 | wbcir_select_bank(data, WBCIR_BANK_0); | ||
1225 | outb(WBCIR_IRQ_NONE, data->sbase + WBCIR_REG_SP3_IER); | ||
1226 | |||
1227 | /* Set PROT_SEL, RX_INV, Clear CEIR_EN (needed for the led) */ | ||
1228 | tmp = protocol << 4; | ||
1229 | if (invert) | ||
1230 | tmp |= 0x08; | ||
1231 | outb(tmp, data->wbase + WBCIR_REG_WCEIR_CTL); | ||
1232 | |||
1233 | /* Clear status bits NEC_REP, BUFF, MSG_END, MATCH */ | ||
1234 | wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_STS, 0x17, 0x17); | ||
1235 | |||
1236 | /* Clear BUFF_EN, Clear END_EN, Clear MATCH_EN */ | ||
1237 | wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_EV_EN, 0x00, 0x07); | ||
1238 | |||
1239 | /* Set RC5 cell time to correspond to 36 kHz */ | ||
1240 | wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_CFG1, 0x4A, 0x7F); | ||
1241 | |||
1242 | /* Set IRTX_INV */ | ||
1243 | if (invert) | ||
1244 | outb(0x04, data->ebase + WBCIR_REG_ECEIR_CCTL); | ||
1245 | else | ||
1246 | outb(0x00, data->ebase + WBCIR_REG_ECEIR_CCTL); | ||
1247 | |||
1248 | /* | ||
1249 | * Clear IR LED, set SP3 clock to 24Mhz | ||
1250 | * set SP3_IRRX_SW to binary 01, helpfully not documented | ||
1251 | */ | ||
1252 | outb(0x10, data->ebase + WBCIR_REG_ECEIR_CTS); | ||
1253 | |||
1254 | /* Enable extended mode */ | ||
1255 | wbcir_select_bank(data, WBCIR_BANK_2); | ||
1256 | outb(WBCIR_EXT_ENABLE, data->sbase + WBCIR_REG_SP3_EXCR1); | ||
1257 | |||
1258 | /* | ||
1259 | * Configure baud generator, IR data will be sampled at | ||
1260 | * a bitrate of: (24Mhz * prescaler) / (divisor * 16). | ||
1261 | * | ||
1262 | * The ECIR registers include a flag to change the | ||
1263 | * 24Mhz clock freq to 48Mhz. | ||
1264 | * | ||
1265 | * It's not documented in the specs, but fifo levels | ||
1266 | * other than 16 seems to be unsupported. | ||
1267 | */ | ||
1268 | |||
1269 | /* prescaler 1.0, tx/rx fifo lvl 16 */ | ||
1270 | outb(0x30, data->sbase + WBCIR_REG_SP3_EXCR2); | ||
1271 | |||
1272 | /* Set baud divisor to generate one byte per bit/cell */ | ||
1273 | switch (protocol) { | ||
1274 | case IR_PROTOCOL_RC5: | ||
1275 | outb(0xA7, data->sbase + WBCIR_REG_SP3_BGDL); | ||
1276 | break; | ||
1277 | case IR_PROTOCOL_RC6: | ||
1278 | outb(0x53, data->sbase + WBCIR_REG_SP3_BGDL); | ||
1279 | break; | ||
1280 | case IR_PROTOCOL_NEC: | ||
1281 | outb(0x69, data->sbase + WBCIR_REG_SP3_BGDL); | ||
1282 | break; | ||
1283 | } | ||
1284 | outb(0x00, data->sbase + WBCIR_REG_SP3_BGDH); | ||
1285 | |||
1286 | /* Set CEIR mode */ | ||
1287 | wbcir_select_bank(data, WBCIR_BANK_0); | ||
1288 | outb(0xC0, data->sbase + WBCIR_REG_SP3_MCR); | ||
1289 | inb(data->sbase + WBCIR_REG_SP3_LSR); /* Clear LSR */ | ||
1290 | inb(data->sbase + WBCIR_REG_SP3_MSR); /* Clear MSR */ | ||
1291 | |||
1292 | /* Disable RX demod, run-length encoding/decoding, set freq span */ | ||
1293 | wbcir_select_bank(data, WBCIR_BANK_7); | ||
1294 | outb(0x10, data->sbase + WBCIR_REG_SP3_RCCFG); | ||
1295 | |||
1296 | /* Disable timer */ | ||
1297 | wbcir_select_bank(data, WBCIR_BANK_4); | ||
1298 | outb(0x00, data->sbase + WBCIR_REG_SP3_IRCR1); | ||
1299 | |||
1300 | /* Enable MSR interrupt, Clear AUX_IRX */ | ||
1301 | wbcir_select_bank(data, WBCIR_BANK_5); | ||
1302 | outb(0x00, data->sbase + WBCIR_REG_SP3_IRCR2); | ||
1303 | |||
1304 | /* Disable CRC */ | ||
1305 | wbcir_select_bank(data, WBCIR_BANK_6); | ||
1306 | outb(0x20, data->sbase + WBCIR_REG_SP3_IRCR3); | ||
1307 | |||
1308 | /* Set RX/TX (de)modulation freq, not really used */ | ||
1309 | wbcir_select_bank(data, WBCIR_BANK_7); | ||
1310 | outb(0xF2, data->sbase + WBCIR_REG_SP3_IRRXDC); | ||
1311 | outb(0x69, data->sbase + WBCIR_REG_SP3_IRTXMC); | ||
1312 | |||
1313 | /* Set invert and pin direction */ | ||
1314 | if (invert) | ||
1315 | outb(0x10, data->sbase + WBCIR_REG_SP3_IRCFG4); | ||
1316 | else | ||
1317 | outb(0x00, data->sbase + WBCIR_REG_SP3_IRCFG4); | ||
1318 | |||
1319 | /* Set FIFO thresholds (RX = 8, TX = 3), reset RX/TX */ | ||
1320 | wbcir_select_bank(data, WBCIR_BANK_0); | ||
1321 | outb(0x97, data->sbase + WBCIR_REG_SP3_FCR); | ||
1322 | |||
1323 | /* Clear AUX status bits */ | ||
1324 | outb(0xE0, data->sbase + WBCIR_REG_SP3_ASCR); | ||
1325 | |||
1326 | /* Enable interrupts */ | ||
1327 | wbcir_reset_irdata(data); | ||
1328 | outb(WBCIR_IRQ_RX | WBCIR_IRQ_ERR, data->sbase + WBCIR_REG_SP3_IER); | ||
1329 | } | ||
1330 | |||
1331 | static int | ||
1332 | wbcir_resume(struct pnp_dev *device) | ||
1333 | { | ||
1334 | struct wbcir_data *data = pnp_get_drvdata(device); | ||
1335 | |||
1336 | wbcir_init_hw(data); | ||
1337 | enable_irq(data->irq); | ||
1338 | |||
1339 | return 0; | ||
1340 | } | ||
1341 | |||
1342 | static int __devinit | ||
1343 | wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id) | ||
1344 | { | ||
1345 | struct device *dev = &device->dev; | ||
1346 | struct wbcir_data *data; | ||
1347 | int err; | ||
1348 | |||
1349 | if (!(pnp_port_len(device, 0) == EHFUNC_IOMEM_LEN && | ||
1350 | pnp_port_len(device, 1) == WAKEUP_IOMEM_LEN && | ||
1351 | pnp_port_len(device, 2) == SP_IOMEM_LEN)) { | ||
1352 | dev_err(dev, "Invalid resources\n"); | ||
1353 | return -ENODEV; | ||
1354 | } | ||
1355 | |||
1356 | data = kzalloc(sizeof(*data), GFP_KERNEL); | ||
1357 | if (!data) { | ||
1358 | err = -ENOMEM; | ||
1359 | goto exit; | ||
1360 | } | ||
1361 | |||
1362 | pnp_set_drvdata(device, data); | ||
1363 | |||
1364 | data->ebase = pnp_port_start(device, 0); | ||
1365 | data->wbase = pnp_port_start(device, 1); | ||
1366 | data->sbase = pnp_port_start(device, 2); | ||
1367 | data->irq = pnp_irq(device, 0); | ||
1368 | |||
1369 | if (data->wbase == 0 || data->ebase == 0 || | ||
1370 | data->sbase == 0 || data->irq == 0) { | ||
1371 | err = -ENODEV; | ||
1372 | dev_err(dev, "Invalid resources\n"); | ||
1373 | goto exit_free_data; | ||
1374 | } | ||
1375 | |||
1376 | dev_dbg(&device->dev, "Found device " | ||
1377 | "(w: 0x%lX, e: 0x%lX, s: 0x%lX, i: %u)\n", | ||
1378 | data->wbase, data->ebase, data->sbase, data->irq); | ||
1379 | |||
1380 | if (!request_region(data->wbase, WAKEUP_IOMEM_LEN, DRVNAME)) { | ||
1381 | dev_err(dev, "Region 0x%lx-0x%lx already in use!\n", | ||
1382 | data->wbase, data->wbase + WAKEUP_IOMEM_LEN - 1); | ||
1383 | err = -EBUSY; | ||
1384 | goto exit_free_data; | ||
1385 | } | ||
1386 | |||
1387 | if (!request_region(data->ebase, EHFUNC_IOMEM_LEN, DRVNAME)) { | ||
1388 | dev_err(dev, "Region 0x%lx-0x%lx already in use!\n", | ||
1389 | data->ebase, data->ebase + EHFUNC_IOMEM_LEN - 1); | ||
1390 | err = -EBUSY; | ||
1391 | goto exit_release_wbase; | ||
1392 | } | ||
1393 | |||
1394 | if (!request_region(data->sbase, SP_IOMEM_LEN, DRVNAME)) { | ||
1395 | dev_err(dev, "Region 0x%lx-0x%lx already in use!\n", | ||
1396 | data->sbase, data->sbase + SP_IOMEM_LEN - 1); | ||
1397 | err = -EBUSY; | ||
1398 | goto exit_release_ebase; | ||
1399 | } | ||
1400 | |||
1401 | err = request_irq(data->irq, wbcir_irq_handler, | ||
1402 | IRQF_DISABLED, DRVNAME, device); | ||
1403 | if (err) { | ||
1404 | dev_err(dev, "Failed to claim IRQ %u\n", data->irq); | ||
1405 | err = -EBUSY; | ||
1406 | goto exit_release_sbase; | ||
1407 | } | ||
1408 | |||
1409 | led_trigger_register_simple("cir-tx", &data->txtrigger); | ||
1410 | if (!data->txtrigger) { | ||
1411 | err = -ENOMEM; | ||
1412 | goto exit_free_irq; | ||
1413 | } | ||
1414 | |||
1415 | led_trigger_register_simple("cir-rx", &data->rxtrigger); | ||
1416 | if (!data->rxtrigger) { | ||
1417 | err = -ENOMEM; | ||
1418 | goto exit_unregister_txtrigger; | ||
1419 | } | ||
1420 | |||
1421 | data->led.name = "cir::activity"; | ||
1422 | data->led.default_trigger = "cir-rx"; | ||
1423 | data->led.brightness_set = wbcir_led_brightness_set; | ||
1424 | data->led.brightness_get = wbcir_led_brightness_get; | ||
1425 | err = led_classdev_register(&device->dev, &data->led); | ||
1426 | if (err) | ||
1427 | goto exit_unregister_rxtrigger; | ||
1428 | |||
1429 | data->input_dev = input_allocate_device(); | ||
1430 | if (!data->input_dev) { | ||
1431 | err = -ENOMEM; | ||
1432 | goto exit_unregister_led; | ||
1433 | } | ||
1434 | |||
1435 | data->input_dev->evbit[0] = BIT(EV_KEY); | ||
1436 | data->input_dev->name = WBCIR_NAME; | ||
1437 | data->input_dev->phys = "wbcir/cir0"; | ||
1438 | data->input_dev->id.bustype = BUS_HOST; | ||
1439 | data->input_dev->id.vendor = PCI_VENDOR_ID_WINBOND; | ||
1440 | data->input_dev->id.product = WBCIR_ID_FAMILY; | ||
1441 | data->input_dev->id.version = WBCIR_ID_CHIP; | ||
1442 | data->input_dev->getkeycode = wbcir_getkeycode; | ||
1443 | data->input_dev->setkeycode = wbcir_setkeycode; | ||
1444 | input_set_capability(data->input_dev, EV_MSC, MSC_SCAN); | ||
1445 | input_set_drvdata(data->input_dev, data); | ||
1446 | |||
1447 | err = input_register_device(data->input_dev); | ||
1448 | if (err) | ||
1449 | goto exit_free_input; | ||
1450 | |||
1451 | data->last_scancode = INVALID_SCANCODE; | ||
1452 | INIT_LIST_HEAD(&data->keytable); | ||
1453 | setup_timer(&data->timer_keyup, wbcir_keyup, (unsigned long)data); | ||
1454 | |||
1455 | /* Load default keymaps */ | ||
1456 | if (protocol == IR_PROTOCOL_RC6) { | ||
1457 | int i; | ||
1458 | for (i = 0; i < ARRAY_SIZE(rc6_def_keymap); i++) { | ||
1459 | err = wbcir_setkeycode(data->input_dev, | ||
1460 | (int)rc6_def_keymap[i].scancode, | ||
1461 | (int)rc6_def_keymap[i].keycode); | ||
1462 | if (err) | ||
1463 | goto exit_unregister_keys; | ||
1464 | } | ||
1465 | } | ||
1466 | |||
1467 | device_init_wakeup(&device->dev, 1); | ||
1468 | |||
1469 | wbcir_init_hw(data); | ||
1470 | |||
1471 | return 0; | ||
1472 | |||
1473 | exit_unregister_keys: | ||
1474 | if (!list_empty(&data->keytable)) { | ||
1475 | struct wbcir_keyentry *key; | ||
1476 | struct wbcir_keyentry *keytmp; | ||
1477 | |||
1478 | list_for_each_entry_safe(key, keytmp, &data->keytable, list) { | ||
1479 | list_del(&key->list); | ||
1480 | kfree(key); | ||
1481 | } | ||
1482 | } | ||
1483 | input_unregister_device(data->input_dev); | ||
1484 | /* Can't call input_free_device on an unregistered device */ | ||
1485 | data->input_dev = NULL; | ||
1486 | exit_free_input: | ||
1487 | input_free_device(data->input_dev); | ||
1488 | exit_unregister_led: | ||
1489 | led_classdev_unregister(&data->led); | ||
1490 | exit_unregister_rxtrigger: | ||
1491 | led_trigger_unregister_simple(data->rxtrigger); | ||
1492 | exit_unregister_txtrigger: | ||
1493 | led_trigger_unregister_simple(data->txtrigger); | ||
1494 | exit_free_irq: | ||
1495 | free_irq(data->irq, device); | ||
1496 | exit_release_sbase: | ||
1497 | release_region(data->sbase, SP_IOMEM_LEN); | ||
1498 | exit_release_ebase: | ||
1499 | release_region(data->ebase, EHFUNC_IOMEM_LEN); | ||
1500 | exit_release_wbase: | ||
1501 | release_region(data->wbase, WAKEUP_IOMEM_LEN); | ||
1502 | exit_free_data: | ||
1503 | kfree(data); | ||
1504 | pnp_set_drvdata(device, NULL); | ||
1505 | exit: | ||
1506 | return err; | ||
1507 | } | ||
1508 | |||
1509 | static void __devexit | ||
1510 | wbcir_remove(struct pnp_dev *device) | ||
1511 | { | ||
1512 | struct wbcir_data *data = pnp_get_drvdata(device); | ||
1513 | struct wbcir_keyentry *key; | ||
1514 | struct wbcir_keyentry *keytmp; | ||
1515 | |||
1516 | /* Disable interrupts */ | ||
1517 | wbcir_select_bank(data, WBCIR_BANK_0); | ||
1518 | outb(WBCIR_IRQ_NONE, data->sbase + WBCIR_REG_SP3_IER); | ||
1519 | |||
1520 | del_timer_sync(&data->timer_keyup); | ||
1521 | |||
1522 | free_irq(data->irq, device); | ||
1523 | |||
1524 | /* Clear status bits NEC_REP, BUFF, MSG_END, MATCH */ | ||
1525 | wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_STS, 0x17, 0x17); | ||
1526 | |||
1527 | /* Clear CEIR_EN */ | ||
1528 | wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_CTL, 0x00, 0x01); | ||
1529 | |||
1530 | /* Clear BUFF_EN, END_EN, MATCH_EN */ | ||
1531 | wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_EV_EN, 0x00, 0x07); | ||
1532 | |||
1533 | /* This will generate a keyup event if necessary */ | ||
1534 | input_unregister_device(data->input_dev); | ||
1535 | |||
1536 | led_trigger_unregister_simple(data->rxtrigger); | ||
1537 | led_trigger_unregister_simple(data->txtrigger); | ||
1538 | led_classdev_unregister(&data->led); | ||
1539 | |||
1540 | /* This is ok since &data->led isn't actually used */ | ||
1541 | wbcir_led_brightness_set(&data->led, LED_OFF); | ||
1542 | |||
1543 | release_region(data->wbase, WAKEUP_IOMEM_LEN); | ||
1544 | release_region(data->ebase, EHFUNC_IOMEM_LEN); | ||
1545 | release_region(data->sbase, SP_IOMEM_LEN); | ||
1546 | |||
1547 | list_for_each_entry_safe(key, keytmp, &data->keytable, list) { | ||
1548 | list_del(&key->list); | ||
1549 | kfree(key); | ||
1550 | } | ||
1551 | |||
1552 | kfree(data); | ||
1553 | |||
1554 | pnp_set_drvdata(device, NULL); | ||
1555 | } | ||
1556 | |||
1557 | static const struct pnp_device_id wbcir_ids[] = { | ||
1558 | { "WEC1022", 0 }, | ||
1559 | { "", 0 } | ||
1560 | }; | ||
1561 | MODULE_DEVICE_TABLE(pnp, wbcir_ids); | ||
1562 | |||
1563 | static struct pnp_driver wbcir_driver = { | ||
1564 | .name = WBCIR_NAME, | ||
1565 | .id_table = wbcir_ids, | ||
1566 | .probe = wbcir_probe, | ||
1567 | .remove = __devexit_p(wbcir_remove), | ||
1568 | .suspend = wbcir_suspend, | ||
1569 | .resume = wbcir_resume, | ||
1570 | .shutdown = wbcir_shutdown | ||
1571 | }; | ||
1572 | |||
1573 | static int __init | ||
1574 | wbcir_init(void) | ||
1575 | { | ||
1576 | int ret; | ||
1577 | |||
1578 | switch (protocol) { | ||
1579 | case IR_PROTOCOL_RC5: | ||
1580 | case IR_PROTOCOL_NEC: | ||
1581 | case IR_PROTOCOL_RC6: | ||
1582 | break; | ||
1583 | default: | ||
1584 | printk(KERN_ERR DRVNAME ": Invalid protocol argument\n"); | ||
1585 | return -EINVAL; | ||
1586 | } | ||
1587 | |||
1588 | ret = pnp_register_driver(&wbcir_driver); | ||
1589 | if (ret) | ||
1590 | printk(KERN_ERR DRVNAME ": Unable to register driver\n"); | ||
1591 | |||
1592 | return ret; | ||
1593 | } | ||
1594 | |||
1595 | static void __exit | ||
1596 | wbcir_exit(void) | ||
1597 | { | ||
1598 | pnp_unregister_driver(&wbcir_driver); | ||
1599 | } | ||
1600 | |||
1601 | MODULE_AUTHOR("David Härdeman <david@hardeman.nu>"); | ||
1602 | MODULE_DESCRIPTION("Winbond SuperI/O Consumer IR Driver"); | ||
1603 | MODULE_LICENSE("GPL"); | ||
1604 | |||
1605 | module_init(wbcir_init); | ||
1606 | module_exit(wbcir_exit); | ||
1607 | |||
1608 | |||
diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h index 613a3652f98f..0aefaa885871 100644 --- a/drivers/input/mouse/synaptics.h +++ b/drivers/input/mouse/synaptics.h | |||
@@ -51,7 +51,8 @@ | |||
51 | #define SYN_EXT_CAP_REQUESTS(c) (((c) & 0x700000) >> 20) | 51 | #define SYN_EXT_CAP_REQUESTS(c) (((c) & 0x700000) >> 20) |
52 | #define SYN_CAP_MULTI_BUTTON_NO(ec) (((ec) & 0x00f000) >> 12) | 52 | #define SYN_CAP_MULTI_BUTTON_NO(ec) (((ec) & 0x00f000) >> 12) |
53 | #define SYN_CAP_PRODUCT_ID(ec) (((ec) & 0xff0000) >> 16) | 53 | #define SYN_CAP_PRODUCT_ID(ec) (((ec) & 0xff0000) >> 16) |
54 | #define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & 0x100100) | 54 | #define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & 0x100000) /* 1-button ClickPad */ |
55 | #define SYN_CAP_CLICKPAD2BTN(ex0c) ((ex0c) & 0x000100) /* 2-button ClickPad */ | ||
55 | #define SYN_CAP_MAX_DIMENSIONS(ex0c) ((ex0c) & 0x020000) | 56 | #define SYN_CAP_MAX_DIMENSIONS(ex0c) ((ex0c) & 0x020000) |
56 | 57 | ||
57 | /* synaptics modes query bits */ | 58 | /* synaptics modes query bits */ |
diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig index 6256233d2bfb..bcb1fdedb595 100644 --- a/drivers/input/serio/Kconfig +++ b/drivers/input/serio/Kconfig | |||
@@ -214,7 +214,6 @@ config SERIO_AMS_DELTA | |||
214 | tristate "Amstrad Delta (E3) mailboard support" | 214 | tristate "Amstrad Delta (E3) mailboard support" |
215 | depends on MACH_AMS_DELTA | 215 | depends on MACH_AMS_DELTA |
216 | default y | 216 | default y |
217 | select AMS_DELTA_FIQ | ||
218 | ---help--- | 217 | ---help--- |
219 | Say Y here if you have an E3 and want to use its mailboard, | 218 | Say Y here if you have an E3 and want to use its mailboard, |
220 | or any standard AT keyboard connected to the mailboard port. | 219 | or any standard AT keyboard connected to the mailboard port. |
diff --git a/drivers/input/serio/gscps2.c b/drivers/input/serio/gscps2.c index 3c287dd879d3..4225f5d6b15f 100644 --- a/drivers/input/serio/gscps2.c +++ b/drivers/input/serio/gscps2.c | |||
@@ -358,7 +358,7 @@ static int __devinit gscps2_probe(struct parisc_device *dev) | |||
358 | gscps2_reset(ps2port); | 358 | gscps2_reset(ps2port); |
359 | ps2port->id = readb(ps2port->addr + GSC_ID) & 0x0f; | 359 | ps2port->id = readb(ps2port->addr + GSC_ID) & 0x0f; |
360 | 360 | ||
361 | snprintf(serio->name, sizeof(serio->name), "GSC PS/2 %s", | 361 | snprintf(serio->name, sizeof(serio->name), "gsc-ps2-%s", |
362 | (ps2port->id == GSC_ID_KEYBOARD) ? "keyboard" : "mouse"); | 362 | (ps2port->id == GSC_ID_KEYBOARD) ? "keyboard" : "mouse"); |
363 | strlcpy(serio->phys, dev_name(&dev->dev), sizeof(serio->phys)); | 363 | strlcpy(serio->phys, dev_name(&dev->dev), sizeof(serio->phys)); |
364 | serio->id.type = SERIO_8042; | 364 | serio->id.type = SERIO_8042; |
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index ed7ad7416b24..a5475b577086 100644 --- a/drivers/input/serio/i8042-x86ia64io.h +++ b/drivers/input/serio/i8042-x86ia64io.h | |||
@@ -351,6 +351,17 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = { | |||
351 | }, | 351 | }, |
352 | }, | 352 | }, |
353 | { | 353 | { |
354 | /* | ||
355 | * Most (all?) VAIOs do not have external PS/2 ports nor | ||
356 | * they implement active multiplexing properly, and | ||
357 | * MUX discovery usually messes up keyboard/touchpad. | ||
358 | */ | ||
359 | .matches = { | ||
360 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), | ||
361 | DMI_MATCH(DMI_BOARD_NAME, "VAIO"), | ||
362 | }, | ||
363 | }, | ||
364 | { | ||
354 | /* Amoi M636/A737 */ | 365 | /* Amoi M636/A737 */ |
355 | .matches = { | 366 | .matches = { |
356 | DMI_MATCH(DMI_SYS_VENDOR, "Amoi Electronics CO.,LTD."), | 367 | DMI_MATCH(DMI_SYS_VENDOR, "Amoi Electronics CO.,LTD."), |
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c index cd82bb125915..b7ba4597f7f0 100644 --- a/drivers/input/serio/serio_raw.c +++ b/drivers/input/serio/serio_raw.c | |||
@@ -11,7 +11,6 @@ | |||
11 | 11 | ||
12 | #include <linux/sched.h> | 12 | #include <linux/sched.h> |
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/smp_lock.h> | ||
15 | #include <linux/poll.h> | 14 | #include <linux/poll.h> |
16 | #include <linux/module.h> | 15 | #include <linux/module.h> |
17 | #include <linux/serio.h> | 16 | #include <linux/serio.h> |
diff --git a/drivers/input/tablet/acecad.c b/drivers/input/tablet/acecad.c index aea9a9399a36..d94f7e9aa997 100644 --- a/drivers/input/tablet/acecad.c +++ b/drivers/input/tablet/acecad.c | |||
@@ -229,12 +229,13 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
229 | 229 | ||
230 | err = input_register_device(acecad->input); | 230 | err = input_register_device(acecad->input); |
231 | if (err) | 231 | if (err) |
232 | goto fail2; | 232 | goto fail3; |
233 | 233 | ||
234 | usb_set_intfdata(intf, acecad); | 234 | usb_set_intfdata(intf, acecad); |
235 | 235 | ||
236 | return 0; | 236 | return 0; |
237 | 237 | ||
238 | fail3: usb_free_urb(acecad->irq); | ||
238 | fail2: usb_free_coherent(dev, 8, acecad->data, acecad->data_dma); | 239 | fail2: usb_free_coherent(dev, 8, acecad->data, acecad->data_dma); |
239 | fail1: input_free_device(input_dev); | 240 | fail1: input_free_device(input_dev); |
240 | kfree(acecad); | 241 | kfree(acecad); |
diff --git a/drivers/input/tablet/aiptek.c b/drivers/input/tablet/aiptek.c index 57b25b84d1fc..0a619c558bfb 100644 --- a/drivers/input/tablet/aiptek.c +++ b/drivers/input/tablet/aiptek.c | |||
@@ -1097,7 +1097,7 @@ store_tabletPointerMode(struct device *dev, struct device_attribute *attr, const | |||
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | static DEVICE_ATTR(pointer_mode, | 1099 | static DEVICE_ATTR(pointer_mode, |
1100 | S_IRUGO | S_IWUGO, | 1100 | S_IRUGO | S_IWUSR, |
1101 | show_tabletPointerMode, store_tabletPointerMode); | 1101 | show_tabletPointerMode, store_tabletPointerMode); |
1102 | 1102 | ||
1103 | /*********************************************************************** | 1103 | /*********************************************************************** |
@@ -1134,7 +1134,7 @@ store_tabletCoordinateMode(struct device *dev, struct device_attribute *attr, co | |||
1134 | } | 1134 | } |
1135 | 1135 | ||
1136 | static DEVICE_ATTR(coordinate_mode, | 1136 | static DEVICE_ATTR(coordinate_mode, |
1137 | S_IRUGO | S_IWUGO, | 1137 | S_IRUGO | S_IWUSR, |
1138 | show_tabletCoordinateMode, store_tabletCoordinateMode); | 1138 | show_tabletCoordinateMode, store_tabletCoordinateMode); |
1139 | 1139 | ||
1140 | /*********************************************************************** | 1140 | /*********************************************************************** |
@@ -1176,7 +1176,7 @@ store_tabletToolMode(struct device *dev, struct device_attribute *attr, const ch | |||
1176 | } | 1176 | } |
1177 | 1177 | ||
1178 | static DEVICE_ATTR(tool_mode, | 1178 | static DEVICE_ATTR(tool_mode, |
1179 | S_IRUGO | S_IWUGO, | 1179 | S_IRUGO | S_IWUSR, |
1180 | show_tabletToolMode, store_tabletToolMode); | 1180 | show_tabletToolMode, store_tabletToolMode); |
1181 | 1181 | ||
1182 | /*********************************************************************** | 1182 | /*********************************************************************** |
@@ -1219,7 +1219,7 @@ store_tabletXtilt(struct device *dev, struct device_attribute *attr, const char | |||
1219 | } | 1219 | } |
1220 | 1220 | ||
1221 | static DEVICE_ATTR(xtilt, | 1221 | static DEVICE_ATTR(xtilt, |
1222 | S_IRUGO | S_IWUGO, show_tabletXtilt, store_tabletXtilt); | 1222 | S_IRUGO | S_IWUSR, show_tabletXtilt, store_tabletXtilt); |
1223 | 1223 | ||
1224 | /*********************************************************************** | 1224 | /*********************************************************************** |
1225 | * support routines for the 'ytilt' file. Note that this file | 1225 | * support routines for the 'ytilt' file. Note that this file |
@@ -1261,7 +1261,7 @@ store_tabletYtilt(struct device *dev, struct device_attribute *attr, const char | |||
1261 | } | 1261 | } |
1262 | 1262 | ||
1263 | static DEVICE_ATTR(ytilt, | 1263 | static DEVICE_ATTR(ytilt, |
1264 | S_IRUGO | S_IWUGO, show_tabletYtilt, store_tabletYtilt); | 1264 | S_IRUGO | S_IWUSR, show_tabletYtilt, store_tabletYtilt); |
1265 | 1265 | ||
1266 | /*********************************************************************** | 1266 | /*********************************************************************** |
1267 | * support routines for the 'jitter' file. Note that this file | 1267 | * support routines for the 'jitter' file. Note that this file |
@@ -1288,7 +1288,7 @@ store_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const | |||
1288 | } | 1288 | } |
1289 | 1289 | ||
1290 | static DEVICE_ATTR(jitter, | 1290 | static DEVICE_ATTR(jitter, |
1291 | S_IRUGO | S_IWUGO, | 1291 | S_IRUGO | S_IWUSR, |
1292 | show_tabletJitterDelay, store_tabletJitterDelay); | 1292 | show_tabletJitterDelay, store_tabletJitterDelay); |
1293 | 1293 | ||
1294 | /*********************************************************************** | 1294 | /*********************************************************************** |
@@ -1317,7 +1317,7 @@ store_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr, | |||
1317 | } | 1317 | } |
1318 | 1318 | ||
1319 | static DEVICE_ATTR(delay, | 1319 | static DEVICE_ATTR(delay, |
1320 | S_IRUGO | S_IWUGO, | 1320 | S_IRUGO | S_IWUSR, |
1321 | show_tabletProgrammableDelay, store_tabletProgrammableDelay); | 1321 | show_tabletProgrammableDelay, store_tabletProgrammableDelay); |
1322 | 1322 | ||
1323 | /*********************************************************************** | 1323 | /*********************************************************************** |
@@ -1406,7 +1406,7 @@ store_tabletStylusUpper(struct device *dev, struct device_attribute *attr, const | |||
1406 | } | 1406 | } |
1407 | 1407 | ||
1408 | static DEVICE_ATTR(stylus_upper, | 1408 | static DEVICE_ATTR(stylus_upper, |
1409 | S_IRUGO | S_IWUGO, | 1409 | S_IRUGO | S_IWUSR, |
1410 | show_tabletStylusUpper, store_tabletStylusUpper); | 1410 | show_tabletStylusUpper, store_tabletStylusUpper); |
1411 | 1411 | ||
1412 | /*********************************************************************** | 1412 | /*********************************************************************** |
@@ -1437,7 +1437,7 @@ store_tabletStylusLower(struct device *dev, struct device_attribute *attr, const | |||
1437 | } | 1437 | } |
1438 | 1438 | ||
1439 | static DEVICE_ATTR(stylus_lower, | 1439 | static DEVICE_ATTR(stylus_lower, |
1440 | S_IRUGO | S_IWUGO, | 1440 | S_IRUGO | S_IWUSR, |
1441 | show_tabletStylusLower, store_tabletStylusLower); | 1441 | show_tabletStylusLower, store_tabletStylusLower); |
1442 | 1442 | ||
1443 | /*********************************************************************** | 1443 | /*********************************************************************** |
@@ -1475,7 +1475,7 @@ store_tabletMouseLeft(struct device *dev, struct device_attribute *attr, const c | |||
1475 | } | 1475 | } |
1476 | 1476 | ||
1477 | static DEVICE_ATTR(mouse_left, | 1477 | static DEVICE_ATTR(mouse_left, |
1478 | S_IRUGO | S_IWUGO, | 1478 | S_IRUGO | S_IWUSR, |
1479 | show_tabletMouseLeft, store_tabletMouseLeft); | 1479 | show_tabletMouseLeft, store_tabletMouseLeft); |
1480 | 1480 | ||
1481 | /*********************************************************************** | 1481 | /*********************************************************************** |
@@ -1505,7 +1505,7 @@ store_tabletMouseMiddle(struct device *dev, struct device_attribute *attr, const | |||
1505 | } | 1505 | } |
1506 | 1506 | ||
1507 | static DEVICE_ATTR(mouse_middle, | 1507 | static DEVICE_ATTR(mouse_middle, |
1508 | S_IRUGO | S_IWUGO, | 1508 | S_IRUGO | S_IWUSR, |
1509 | show_tabletMouseMiddle, store_tabletMouseMiddle); | 1509 | show_tabletMouseMiddle, store_tabletMouseMiddle); |
1510 | 1510 | ||
1511 | /*********************************************************************** | 1511 | /*********************************************************************** |
@@ -1535,7 +1535,7 @@ store_tabletMouseRight(struct device *dev, struct device_attribute *attr, const | |||
1535 | } | 1535 | } |
1536 | 1536 | ||
1537 | static DEVICE_ATTR(mouse_right, | 1537 | static DEVICE_ATTR(mouse_right, |
1538 | S_IRUGO | S_IWUGO, | 1538 | S_IRUGO | S_IWUSR, |
1539 | show_tabletMouseRight, store_tabletMouseRight); | 1539 | show_tabletMouseRight, store_tabletMouseRight); |
1540 | 1540 | ||
1541 | /*********************************************************************** | 1541 | /*********************************************************************** |
@@ -1567,7 +1567,7 @@ store_tabletWheel(struct device *dev, struct device_attribute *attr, const char | |||
1567 | } | 1567 | } |
1568 | 1568 | ||
1569 | static DEVICE_ATTR(wheel, | 1569 | static DEVICE_ATTR(wheel, |
1570 | S_IRUGO | S_IWUGO, show_tabletWheel, store_tabletWheel); | 1570 | S_IRUGO | S_IWUSR, show_tabletWheel, store_tabletWheel); |
1571 | 1571 | ||
1572 | /*********************************************************************** | 1572 | /*********************************************************************** |
1573 | * support routines for the 'execute' file. Note that this file | 1573 | * support routines for the 'execute' file. Note that this file |
@@ -1600,7 +1600,7 @@ store_tabletExecute(struct device *dev, struct device_attribute *attr, const cha | |||
1600 | } | 1600 | } |
1601 | 1601 | ||
1602 | static DEVICE_ATTR(execute, | 1602 | static DEVICE_ATTR(execute, |
1603 | S_IRUGO | S_IWUGO, show_tabletExecute, store_tabletExecute); | 1603 | S_IRUGO | S_IWUSR, show_tabletExecute, store_tabletExecute); |
1604 | 1604 | ||
1605 | /*********************************************************************** | 1605 | /*********************************************************************** |
1606 | * support routines for the 'odm_code' file. Note that this file | 1606 | * support routines for the 'odm_code' file. Note that this file |
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index b3252ef1e279..435b0af401e4 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c | |||
@@ -1436,6 +1436,14 @@ static struct wacom_features wacom_features_0xD2 = | |||
1436 | { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT }; | 1436 | { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT }; |
1437 | static struct wacom_features wacom_features_0xD3 = | 1437 | static struct wacom_features wacom_features_0xD3 = |
1438 | { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT }; | 1438 | { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT }; |
1439 | static const struct wacom_features wacom_features_0xD4 = | ||
1440 | { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 255, 63, BAMBOO_PT }; | ||
1441 | static struct wacom_features wacom_features_0xD8 = | ||
1442 | { "Wacom Bamboo Comic 2FG", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT }; | ||
1443 | static struct wacom_features wacom_features_0xDA = | ||
1444 | { "Wacom Bamboo 2FG 4x5 SE", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT }; | ||
1445 | static struct wacom_features wacom_features_0xDB = | ||
1446 | { "Wacom Bamboo 2FG 6x8 SE", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT }; | ||
1439 | 1447 | ||
1440 | #define USB_DEVICE_WACOM(prod) \ | 1448 | #define USB_DEVICE_WACOM(prod) \ |
1441 | USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \ | 1449 | USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \ |
@@ -1504,6 +1512,10 @@ const struct usb_device_id wacom_ids[] = { | |||
1504 | { USB_DEVICE_WACOM(0xD1) }, | 1512 | { USB_DEVICE_WACOM(0xD1) }, |
1505 | { USB_DEVICE_WACOM(0xD2) }, | 1513 | { USB_DEVICE_WACOM(0xD2) }, |
1506 | { USB_DEVICE_WACOM(0xD3) }, | 1514 | { USB_DEVICE_WACOM(0xD3) }, |
1515 | { USB_DEVICE_WACOM(0xD4) }, | ||
1516 | { USB_DEVICE_WACOM(0xD8) }, | ||
1517 | { USB_DEVICE_WACOM(0xDA) }, | ||
1518 | { USB_DEVICE_WACOM(0xDB) }, | ||
1507 | { USB_DEVICE_WACOM(0xF0) }, | 1519 | { USB_DEVICE_WACOM(0xF0) }, |
1508 | { USB_DEVICE_WACOM(0xCC) }, | 1520 | { USB_DEVICE_WACOM(0xCC) }, |
1509 | { USB_DEVICE_WACOM(0x90) }, | 1521 | { USB_DEVICE_WACOM(0x90) }, |
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c index f45f80f6d336..73fd6642b681 100644 --- a/drivers/input/touchscreen/usbtouchscreen.c +++ b/drivers/input/touchscreen/usbtouchscreen.c | |||
@@ -178,6 +178,7 @@ static const struct usb_device_id usbtouch_devices[] = { | |||
178 | 178 | ||
179 | #ifdef CONFIG_TOUCHSCREEN_USB_ITM | 179 | #ifdef CONFIG_TOUCHSCREEN_USB_ITM |
180 | {USB_DEVICE(0x0403, 0xf9e9), .driver_info = DEVTYPE_ITM}, | 180 | {USB_DEVICE(0x0403, 0xf9e9), .driver_info = DEVTYPE_ITM}, |
181 | {USB_DEVICE(0x16e3, 0xf9e9), .driver_info = DEVTYPE_ITM}, | ||
181 | #endif | 182 | #endif |
182 | 183 | ||
183 | #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO | 184 | #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO |