aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-04-10 14:30:45 -0400
committerDavid S. Miller <davem@davemloft.net>2012-04-10 14:30:45 -0400
commit06eb4eafbdc0796d741d139a44f1253278da8611 (patch)
treefbdb44317130c371928154c9e6903e699fe2b995 /drivers/input
parent32ed53b83ea5ec26a4dba90e18f5e0ff6c71eb48 (diff)
parentf68e556e23d1a4176b563bcb25d8baf2c5313f91 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/input-compat.c4
-rw-r--r--drivers/input/input-compat.h2
-rw-r--r--drivers/input/joydev.c1
-rw-r--r--drivers/input/joystick/amijoy.c4
-rw-r--r--drivers/input/keyboard/gpio_keys.c259
-rw-r--r--drivers/input/keyboard/jornada720_kbd.c1
-rw-r--r--drivers/input/keyboard/tegra-kbc.c1
-rw-r--r--drivers/input/misc/88pm860x_onkey.c26
-rw-r--r--drivers/input/mouse/amimouse.c1
-rw-r--r--drivers/input/mouse/atarimouse.c1
-rw-r--r--drivers/input/mouse/sentelic.c294
-rw-r--r--drivers/input/mouse/sentelic.h35
-rw-r--r--drivers/input/serio/ams_delta_serio.c2
-rw-r--r--drivers/input/serio/hp_sdc.c1
-rw-r--r--drivers/input/serio/maceps2.c1
-rw-r--r--drivers/input/serio/rpckbd.c45
-rw-r--r--drivers/input/serio/sa1111ps2.c60
-rw-r--r--drivers/input/tablet/Kconfig1
-rw-r--r--drivers/input/tablet/wacom.h9
-rw-r--r--drivers/input/tablet/wacom_sys.c231
-rw-r--r--drivers/input/tablet/wacom_wac.c49
-rw-r--r--drivers/input/tablet/wacom_wac.h6
-rw-r--r--drivers/input/touchscreen/jornada720_ts.c1
-rw-r--r--drivers/input/touchscreen/mc13783_ts.c11
24 files changed, 815 insertions, 231 deletions
diff --git a/drivers/input/input-compat.c b/drivers/input/input-compat.c
index e46a86776a6b..64ca7113ff28 100644
--- a/drivers/input/input-compat.c
+++ b/drivers/input/input-compat.c
@@ -17,7 +17,7 @@
17int input_event_from_user(const char __user *buffer, 17int input_event_from_user(const char __user *buffer,
18 struct input_event *event) 18 struct input_event *event)
19{ 19{
20 if (INPUT_COMPAT_TEST) { 20 if (INPUT_COMPAT_TEST && !COMPAT_USE_64BIT_TIME) {
21 struct input_event_compat compat_event; 21 struct input_event_compat compat_event;
22 22
23 if (copy_from_user(&compat_event, buffer, 23 if (copy_from_user(&compat_event, buffer,
@@ -41,7 +41,7 @@ int input_event_from_user(const char __user *buffer,
41int input_event_to_user(char __user *buffer, 41int input_event_to_user(char __user *buffer,
42 const struct input_event *event) 42 const struct input_event *event)
43{ 43{
44 if (INPUT_COMPAT_TEST) { 44 if (INPUT_COMPAT_TEST && !COMPAT_USE_64BIT_TIME) {
45 struct input_event_compat compat_event; 45 struct input_event_compat compat_event;
46 46
47 compat_event.time.tv_sec = event->time.tv_sec; 47 compat_event.time.tv_sec = event->time.tv_sec;
diff --git a/drivers/input/input-compat.h b/drivers/input/input-compat.h
index 22be27b424de..148f66fe3205 100644
--- a/drivers/input/input-compat.h
+++ b/drivers/input/input-compat.h
@@ -67,7 +67,7 @@ struct ff_effect_compat {
67 67
68static inline size_t input_event_size(void) 68static inline size_t input_event_size(void)
69{ 69{
70 return INPUT_COMPAT_TEST ? 70 return (INPUT_COMPAT_TEST && !COMPAT_USE_64BIT_TIME) ?
71 sizeof(struct input_event_compat) : sizeof(struct input_event); 71 sizeof(struct input_event_compat) : sizeof(struct input_event);
72} 72}
73 73
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index c24ec2d5f926..26043cc6a016 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -13,7 +13,6 @@
13#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 13#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
14 14
15#include <asm/io.h> 15#include <asm/io.h>
16#include <asm/system.h>
17#include <linux/delay.h> 16#include <linux/delay.h>
18#include <linux/errno.h> 17#include <linux/errno.h>
19#include <linux/joystick.h> 18#include <linux/joystick.h>
diff --git a/drivers/input/joystick/amijoy.c b/drivers/input/joystick/amijoy.c
index 0bc86204213e..c65b5fa69f1e 100644
--- a/drivers/input/joystick/amijoy.c
+++ b/drivers/input/joystick/amijoy.c
@@ -35,7 +35,6 @@
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37 37
38#include <asm/system.h>
39#include <asm/amigahw.h> 38#include <asm/amigahw.h>
40#include <asm/amigaints.h> 39#include <asm/amigaints.h>
41 40
@@ -108,6 +107,9 @@ static int __init amijoy_init(void)
108 int i, j; 107 int i, j;
109 int err; 108 int err;
110 109
110 if (!MACH_IS_AMIGA)
111 return -ENODEV;
112
111 for (i = 0; i < 2; i++) { 113 for (i = 0; i < 2; i++) {
112 if (!amijoy[i]) 114 if (!amijoy[i])
113 continue; 115 continue;
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index ed1ed469d085..62bfce468f9f 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -28,14 +28,18 @@
28#include <linux/gpio.h> 28#include <linux/gpio.h>
29#include <linux/of_platform.h> 29#include <linux/of_platform.h>
30#include <linux/of_gpio.h> 30#include <linux/of_gpio.h>
31#include <linux/spinlock.h>
31 32
32struct gpio_button_data { 33struct gpio_button_data {
33 struct gpio_keys_button *button; 34 const struct gpio_keys_button *button;
34 struct input_dev *input; 35 struct input_dev *input;
35 struct timer_list timer; 36 struct timer_list timer;
36 struct work_struct work; 37 struct work_struct work;
37 int timer_debounce; /* in msecs */ 38 unsigned int timer_debounce; /* in msecs */
39 unsigned int irq;
40 spinlock_t lock;
38 bool disabled; 41 bool disabled;
42 bool key_pressed;
39}; 43};
40 44
41struct gpio_keys_drvdata { 45struct gpio_keys_drvdata {
@@ -114,7 +118,7 @@ static void gpio_keys_disable_button(struct gpio_button_data *bdata)
114 /* 118 /*
115 * Disable IRQ and possible debouncing timer. 119 * Disable IRQ and possible debouncing timer.
116 */ 120 */
117 disable_irq(gpio_to_irq(bdata->button->gpio)); 121 disable_irq(bdata->irq);
118 if (bdata->timer_debounce) 122 if (bdata->timer_debounce)
119 del_timer_sync(&bdata->timer); 123 del_timer_sync(&bdata->timer);
120 124
@@ -135,7 +139,7 @@ static void gpio_keys_disable_button(struct gpio_button_data *bdata)
135static void gpio_keys_enable_button(struct gpio_button_data *bdata) 139static void gpio_keys_enable_button(struct gpio_button_data *bdata)
136{ 140{
137 if (bdata->disabled) { 141 if (bdata->disabled) {
138 enable_irq(gpio_to_irq(bdata->button->gpio)); 142 enable_irq(bdata->irq);
139 bdata->disabled = false; 143 bdata->disabled = false;
140 } 144 }
141} 145}
@@ -195,7 +199,7 @@ static ssize_t gpio_keys_attr_show_helper(struct gpio_keys_drvdata *ddata,
195 * @type: button type (%EV_KEY, %EV_SW) 199 * @type: button type (%EV_KEY, %EV_SW)
196 * 200 *
197 * This function parses stringified bitmap from @buf and disables/enables 201 * This function parses stringified bitmap from @buf and disables/enables
198 * GPIO buttons accordinly. Returns 0 on success and negative error 202 * GPIO buttons accordingly. Returns 0 on success and negative error
199 * on failure. 203 * on failure.
200 */ 204 */
201static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata, 205static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata,
@@ -320,9 +324,9 @@ static struct attribute_group gpio_keys_attr_group = {
320 .attrs = gpio_keys_attrs, 324 .attrs = gpio_keys_attrs,
321}; 325};
322 326
323static void gpio_keys_report_event(struct gpio_button_data *bdata) 327static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata)
324{ 328{
325 struct gpio_keys_button *button = bdata->button; 329 const struct gpio_keys_button *button = bdata->button;
326 struct input_dev *input = bdata->input; 330 struct input_dev *input = bdata->input;
327 unsigned int type = button->type ?: EV_KEY; 331 unsigned int type = button->type ?: EV_KEY;
328 int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low; 332 int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low;
@@ -336,27 +340,26 @@ static void gpio_keys_report_event(struct gpio_button_data *bdata)
336 input_sync(input); 340 input_sync(input);
337} 341}
338 342
339static void gpio_keys_work_func(struct work_struct *work) 343static void gpio_keys_gpio_work_func(struct work_struct *work)
340{ 344{
341 struct gpio_button_data *bdata = 345 struct gpio_button_data *bdata =
342 container_of(work, struct gpio_button_data, work); 346 container_of(work, struct gpio_button_data, work);
343 347
344 gpio_keys_report_event(bdata); 348 gpio_keys_gpio_report_event(bdata);
345} 349}
346 350
347static void gpio_keys_timer(unsigned long _data) 351static void gpio_keys_gpio_timer(unsigned long _data)
348{ 352{
349 struct gpio_button_data *data = (struct gpio_button_data *)_data; 353 struct gpio_button_data *bdata = (struct gpio_button_data *)_data;
350 354
351 schedule_work(&data->work); 355 schedule_work(&bdata->work);
352} 356}
353 357
354static irqreturn_t gpio_keys_isr(int irq, void *dev_id) 358static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id)
355{ 359{
356 struct gpio_button_data *bdata = dev_id; 360 struct gpio_button_data *bdata = dev_id;
357 struct gpio_keys_button *button = bdata->button;
358 361
359 BUG_ON(irq != gpio_to_irq(button->gpio)); 362 BUG_ON(irq != bdata->irq);
360 363
361 if (bdata->timer_debounce) 364 if (bdata->timer_debounce)
362 mod_timer(&bdata->timer, 365 mod_timer(&bdata->timer,
@@ -367,50 +370,133 @@ static irqreturn_t gpio_keys_isr(int irq, void *dev_id)
367 return IRQ_HANDLED; 370 return IRQ_HANDLED;
368} 371}
369 372
373static void gpio_keys_irq_timer(unsigned long _data)
374{
375 struct gpio_button_data *bdata = (struct gpio_button_data *)_data;
376 struct input_dev *input = bdata->input;
377 unsigned long flags;
378
379 spin_lock_irqsave(&bdata->lock, flags);
380 if (bdata->key_pressed) {
381 input_event(input, EV_KEY, bdata->button->code, 0);
382 input_sync(input);
383 bdata->key_pressed = false;
384 }
385 spin_unlock_irqrestore(&bdata->lock, flags);
386}
387
388static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id)
389{
390 struct gpio_button_data *bdata = dev_id;
391 const struct gpio_keys_button *button = bdata->button;
392 struct input_dev *input = bdata->input;
393 unsigned long flags;
394
395 BUG_ON(irq != bdata->irq);
396
397 spin_lock_irqsave(&bdata->lock, flags);
398
399 if (!bdata->key_pressed) {
400 input_event(input, EV_KEY, button->code, 1);
401 input_sync(input);
402
403 if (!bdata->timer_debounce) {
404 input_event(input, EV_KEY, button->code, 0);
405 input_sync(input);
406 goto out;
407 }
408
409 bdata->key_pressed = true;
410 }
411
412 if (bdata->timer_debounce)
413 mod_timer(&bdata->timer,
414 jiffies + msecs_to_jiffies(bdata->timer_debounce));
415out:
416 spin_unlock_irqrestore(&bdata->lock, flags);
417 return IRQ_HANDLED;
418}
419
370static int __devinit gpio_keys_setup_key(struct platform_device *pdev, 420static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
421 struct input_dev *input,
371 struct gpio_button_data *bdata, 422 struct gpio_button_data *bdata,
372 struct gpio_keys_button *button) 423 const struct gpio_keys_button *button)
373{ 424{
374 const char *desc = button->desc ? button->desc : "gpio_keys"; 425 const char *desc = button->desc ? button->desc : "gpio_keys";
375 struct device *dev = &pdev->dev; 426 struct device *dev = &pdev->dev;
427 irq_handler_t isr;
376 unsigned long irqflags; 428 unsigned long irqflags;
377 int irq, error; 429 int irq, error;
378 430
379 setup_timer(&bdata->timer, gpio_keys_timer, (unsigned long)bdata); 431 bdata->input = input;
380 INIT_WORK(&bdata->work, gpio_keys_work_func); 432 bdata->button = button;
433 spin_lock_init(&bdata->lock);
381 434
382 error = gpio_request(button->gpio, desc); 435 if (gpio_is_valid(button->gpio)) {
383 if (error < 0) {
384 dev_err(dev, "failed to request GPIO %d, error %d\n",
385 button->gpio, error);
386 goto fail2;
387 }
388 436
389 error = gpio_direction_input(button->gpio); 437 error = gpio_request(button->gpio, desc);
390 if (error < 0) { 438 if (error < 0) {
391 dev_err(dev, "failed to configure" 439 dev_err(dev, "Failed to request GPIO %d, error %d\n",
392 " direction for GPIO %d, error %d\n", 440 button->gpio, error);
393 button->gpio, error); 441 return error;
394 goto fail3; 442 }
395 }
396 443
397 if (button->debounce_interval) { 444 error = gpio_direction_input(button->gpio);
398 error = gpio_set_debounce(button->gpio, 445 if (error < 0) {
399 button->debounce_interval * 1000); 446 dev_err(dev,
400 /* use timer if gpiolib doesn't provide debounce */ 447 "Failed to configure direction for GPIO %d, error %d\n",
401 if (error < 0) 448 button->gpio, error);
402 bdata->timer_debounce = button->debounce_interval; 449 goto fail;
403 } 450 }
404 451
405 irq = gpio_to_irq(button->gpio); 452 if (button->debounce_interval) {
406 if (irq < 0) { 453 error = gpio_set_debounce(button->gpio,
407 error = irq; 454 button->debounce_interval * 1000);
408 dev_err(dev, "Unable to get irq number for GPIO %d, error %d\n", 455 /* use timer if gpiolib doesn't provide debounce */
409 button->gpio, error); 456 if (error < 0)
410 goto fail3; 457 bdata->timer_debounce =
458 button->debounce_interval;
459 }
460
461 irq = gpio_to_irq(button->gpio);
462 if (irq < 0) {
463 error = irq;
464 dev_err(dev,
465 "Unable to get irq number for GPIO %d, error %d\n",
466 button->gpio, error);
467 goto fail;
468 }
469 bdata->irq = irq;
470
471 INIT_WORK(&bdata->work, gpio_keys_gpio_work_func);
472 setup_timer(&bdata->timer,
473 gpio_keys_gpio_timer, (unsigned long)bdata);
474
475 isr = gpio_keys_gpio_isr;
476 irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
477
478 } else {
479 if (!button->irq) {
480 dev_err(dev, "No IRQ specified\n");
481 return -EINVAL;
482 }
483 bdata->irq = button->irq;
484
485 if (button->type && button->type != EV_KEY) {
486 dev_err(dev, "Only EV_KEY allowed for IRQ buttons.\n");
487 return -EINVAL;
488 }
489
490 bdata->timer_debounce = button->debounce_interval;
491 setup_timer(&bdata->timer,
492 gpio_keys_irq_timer, (unsigned long)bdata);
493
494 isr = gpio_keys_irq_isr;
495 irqflags = 0;
411 } 496 }
412 497
413 irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING; 498 input_set_capability(input, button->type ?: EV_KEY, button->code);
499
414 /* 500 /*
415 * If platform has specified that the button can be disabled, 501 * If platform has specified that the button can be disabled,
416 * we don't want it to share the interrupt line. 502 * we don't want it to share the interrupt line.
@@ -418,18 +504,19 @@ static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
418 if (!button->can_disable) 504 if (!button->can_disable)
419 irqflags |= IRQF_SHARED; 505 irqflags |= IRQF_SHARED;
420 506
421 error = request_threaded_irq(irq, NULL, gpio_keys_isr, irqflags, desc, bdata); 507 error = request_any_context_irq(bdata->irq, isr, irqflags, desc, bdata);
422 if (error < 0) { 508 if (error < 0) {
423 dev_err(dev, "Unable to claim irq %d; error %d\n", 509 dev_err(dev, "Unable to claim irq %d; error %d\n",
424 irq, error); 510 bdata->irq, error);
425 goto fail3; 511 goto fail;
426 } 512 }
427 513
428 return 0; 514 return 0;
429 515
430fail3: 516fail:
431 gpio_free(button->gpio); 517 if (gpio_is_valid(button->gpio))
432fail2: 518 gpio_free(button->gpio);
519
433 return error; 520 return error;
434} 521}
435 522
@@ -547,9 +634,19 @@ static int gpio_keys_get_devtree_pdata(struct device *dev,
547 634
548#endif 635#endif
549 636
637static void gpio_remove_key(struct gpio_button_data *bdata)
638{
639 free_irq(bdata->irq, bdata);
640 if (bdata->timer_debounce)
641 del_timer_sync(&bdata->timer);
642 cancel_work_sync(&bdata->work);
643 if (gpio_is_valid(bdata->button->gpio))
644 gpio_free(bdata->button->gpio);
645}
646
550static int __devinit gpio_keys_probe(struct platform_device *pdev) 647static int __devinit gpio_keys_probe(struct platform_device *pdev)
551{ 648{
552 struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; 649 const struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
553 struct gpio_keys_drvdata *ddata; 650 struct gpio_keys_drvdata *ddata;
554 struct device *dev = &pdev->dev; 651 struct device *dev = &pdev->dev;
555 struct gpio_keys_platform_data alt_pdata; 652 struct gpio_keys_platform_data alt_pdata;
@@ -599,21 +696,15 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
599 __set_bit(EV_REP, input->evbit); 696 __set_bit(EV_REP, input->evbit);
600 697
601 for (i = 0; i < pdata->nbuttons; i++) { 698 for (i = 0; i < pdata->nbuttons; i++) {
602 struct gpio_keys_button *button = &pdata->buttons[i]; 699 const struct gpio_keys_button *button = &pdata->buttons[i];
603 struct gpio_button_data *bdata = &ddata->data[i]; 700 struct gpio_button_data *bdata = &ddata->data[i];
604 unsigned int type = button->type ?: EV_KEY;
605
606 bdata->input = input;
607 bdata->button = button;
608 701
609 error = gpio_keys_setup_key(pdev, bdata, button); 702 error = gpio_keys_setup_key(pdev, input, bdata, button);
610 if (error) 703 if (error)
611 goto fail2; 704 goto fail2;
612 705
613 if (button->wakeup) 706 if (button->wakeup)
614 wakeup = 1; 707 wakeup = 1;
615
616 input_set_capability(input, type, button->code);
617 } 708 }
618 709
619 error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group); 710 error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group);
@@ -630,9 +721,12 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
630 goto fail3; 721 goto fail3;
631 } 722 }
632 723
633 /* get current state of buttons */ 724 /* get current state of buttons that are connected to GPIOs */
634 for (i = 0; i < pdata->nbuttons; i++) 725 for (i = 0; i < pdata->nbuttons; i++) {
635 gpio_keys_report_event(&ddata->data[i]); 726 struct gpio_button_data *bdata = &ddata->data[i];
727 if (gpio_is_valid(bdata->button->gpio))
728 gpio_keys_gpio_report_event(bdata);
729 }
636 input_sync(input); 730 input_sync(input);
637 731
638 device_init_wakeup(&pdev->dev, wakeup); 732 device_init_wakeup(&pdev->dev, wakeup);
@@ -642,13 +736,8 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
642 fail3: 736 fail3:
643 sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); 737 sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group);
644 fail2: 738 fail2:
645 while (--i >= 0) { 739 while (--i >= 0)
646 free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]); 740 gpio_remove_key(&ddata->data[i]);
647 if (ddata->data[i].timer_debounce)
648 del_timer_sync(&ddata->data[i].timer);
649 cancel_work_sync(&ddata->data[i].work);
650 gpio_free(pdata->buttons[i].gpio);
651 }
652 741
653 platform_set_drvdata(pdev, NULL); 742 platform_set_drvdata(pdev, NULL);
654 fail1: 743 fail1:
@@ -671,14 +760,8 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev)
671 760
672 device_init_wakeup(&pdev->dev, 0); 761 device_init_wakeup(&pdev->dev, 0);
673 762
674 for (i = 0; i < ddata->n_buttons; i++) { 763 for (i = 0; i < ddata->n_buttons; i++)
675 int irq = gpio_to_irq(ddata->data[i].button->gpio); 764 gpio_remove_key(&ddata->data[i]);
676 free_irq(irq, &ddata->data[i]);
677 if (ddata->data[i].timer_debounce)
678 del_timer_sync(&ddata->data[i].timer);
679 cancel_work_sync(&ddata->data[i].work);
680 gpio_free(ddata->data[i].button->gpio);
681 }
682 765
683 input_unregister_device(input); 766 input_unregister_device(input);
684 767
@@ -703,11 +786,9 @@ static int gpio_keys_suspend(struct device *dev)
703 786
704 if (device_may_wakeup(dev)) { 787 if (device_may_wakeup(dev)) {
705 for (i = 0; i < ddata->n_buttons; i++) { 788 for (i = 0; i < ddata->n_buttons; i++) {
706 struct gpio_keys_button *button = ddata->data[i].button; 789 struct gpio_button_data *bdata = &ddata->data[i];
707 if (button->wakeup) { 790 if (bdata->button->wakeup)
708 int irq = gpio_to_irq(button->gpio); 791 enable_irq_wake(bdata->irq);
709 enable_irq_wake(irq);
710 }
711 } 792 }
712 } 793 }
713 794
@@ -720,14 +801,12 @@ static int gpio_keys_resume(struct device *dev)
720 int i; 801 int i;
721 802
722 for (i = 0; i < ddata->n_buttons; i++) { 803 for (i = 0; i < ddata->n_buttons; i++) {
804 struct gpio_button_data *bdata = &ddata->data[i];
805 if (bdata->button->wakeup && device_may_wakeup(dev))
806 disable_irq_wake(bdata->irq);
723 807
724 struct gpio_keys_button *button = ddata->data[i].button; 808 if (gpio_is_valid(bdata->button->gpio))
725 if (button->wakeup && device_may_wakeup(dev)) { 809 gpio_keys_gpio_report_event(bdata);
726 int irq = gpio_to_irq(button->gpio);
727 disable_irq_wake(irq);
728 }
729
730 gpio_keys_report_event(&ddata->data[i]);
731 } 810 }
732 input_sync(ddata->input); 811 input_sync(ddata->input);
733 812
diff --git a/drivers/input/keyboard/jornada720_kbd.c b/drivers/input/keyboard/jornada720_kbd.c
index eeafc30b207b..9d639fa1afbd 100644
--- a/drivers/input/keyboard/jornada720_kbd.c
+++ b/drivers/input/keyboard/jornada720_kbd.c
@@ -27,6 +27,7 @@
27 27
28#include <mach/jornada720.h> 28#include <mach/jornada720.h>
29#include <mach/hardware.h> 29#include <mach/hardware.h>
30#include <mach/irqs.h>
30 31
31MODULE_AUTHOR("Kristoffer Ericson <Kristoffer.Ericson@gmail.com>"); 32MODULE_AUTHOR("Kristoffer Ericson <Kristoffer.Ericson@gmail.com>");
32MODULE_DESCRIPTION("HP Jornada 710/720/728 keyboard driver"); 33MODULE_DESCRIPTION("HP Jornada 710/720/728 keyboard driver");
diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c
index 21c42f852343..fe4ac95ca6c8 100644
--- a/drivers/input/keyboard/tegra-kbc.c
+++ b/drivers/input/keyboard/tegra-kbc.c
@@ -630,6 +630,7 @@ tegra_kbc_dt_parse_pdata(struct platform_device *pdev)
630 if (!np) 630 if (!np)
631 return NULL; 631 return NULL;
632 632
633 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
633 if (!pdata) 634 if (!pdata)
634 return NULL; 635 return NULL;
635 636
diff --git a/drivers/input/misc/88pm860x_onkey.c b/drivers/input/misc/88pm860x_onkey.c
index f2e0cbc5ab64..f9ce1835e4d7 100644
--- a/drivers/input/misc/88pm860x_onkey.c
+++ b/drivers/input/misc/88pm860x_onkey.c
@@ -105,6 +105,8 @@ static int __devinit pm860x_onkey_probe(struct platform_device *pdev)
105 } 105 }
106 106
107 platform_set_drvdata(pdev, info); 107 platform_set_drvdata(pdev, info);
108 device_init_wakeup(&pdev->dev, 1);
109
108 return 0; 110 return 0;
109 111
110out_irq: 112out_irq:
@@ -129,10 +131,34 @@ static int __devexit pm860x_onkey_remove(struct platform_device *pdev)
129 return 0; 131 return 0;
130} 132}
131 133
134#ifdef CONFIG_PM_SLEEP
135static int pm860x_onkey_suspend(struct device *dev)
136{
137 struct platform_device *pdev = to_platform_device(dev);
138 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
139
140 if (device_may_wakeup(dev))
141 chip->wakeup_flag |= 1 << PM8607_IRQ_ONKEY;
142 return 0;
143}
144static int pm860x_onkey_resume(struct device *dev)
145{
146 struct platform_device *pdev = to_platform_device(dev);
147 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
148
149 if (device_may_wakeup(dev))
150 chip->wakeup_flag &= ~(1 << PM8607_IRQ_ONKEY);
151 return 0;
152}
153#endif
154
155static SIMPLE_DEV_PM_OPS(pm860x_onkey_pm_ops, pm860x_onkey_suspend, pm860x_onkey_resume);
156
132static struct platform_driver pm860x_onkey_driver = { 157static struct platform_driver pm860x_onkey_driver = {
133 .driver = { 158 .driver = {
134 .name = "88pm860x-onkey", 159 .name = "88pm860x-onkey",
135 .owner = THIS_MODULE, 160 .owner = THIS_MODULE,
161 .pm = &pm860x_onkey_pm_ops,
136 }, 162 },
137 .probe = pm860x_onkey_probe, 163 .probe = pm860x_onkey_probe,
138 .remove = __devexit_p(pm860x_onkey_remove), 164 .remove = __devexit_p(pm860x_onkey_remove),
diff --git a/drivers/input/mouse/amimouse.c b/drivers/input/mouse/amimouse.c
index ff5f61a0fd3a..5fa99341a39d 100644
--- a/drivers/input/mouse/amimouse.c
+++ b/drivers/input/mouse/amimouse.c
@@ -25,7 +25,6 @@
25 25
26#include <asm/irq.h> 26#include <asm/irq.h>
27#include <asm/setup.h> 27#include <asm/setup.h>
28#include <asm/system.h>
29#include <asm/uaccess.h> 28#include <asm/uaccess.h>
30#include <asm/amigahw.h> 29#include <asm/amigahw.h>
31#include <asm/amigaints.h> 30#include <asm/amigaints.h>
diff --git a/drivers/input/mouse/atarimouse.c b/drivers/input/mouse/atarimouse.c
index 5c4a692bf73a..d1c43236b125 100644
--- a/drivers/input/mouse/atarimouse.c
+++ b/drivers/input/mouse/atarimouse.c
@@ -47,7 +47,6 @@
47 47
48#include <asm/irq.h> 48#include <asm/irq.h>
49#include <asm/setup.h> 49#include <asm/setup.h>
50#include <asm/system.h>
51#include <asm/uaccess.h> 50#include <asm/uaccess.h>
52#include <asm/atarihw.h> 51#include <asm/atarihw.h>
53#include <asm/atarikb.h> 52#include <asm/atarikb.h>
diff --git a/drivers/input/mouse/sentelic.c b/drivers/input/mouse/sentelic.c
index 2a77a52d2e62..a977bfaa6821 100644
--- a/drivers/input/mouse/sentelic.c
+++ b/drivers/input/mouse/sentelic.c
@@ -2,7 +2,7 @@
2 * Finger Sensing Pad PS/2 mouse driver. 2 * Finger Sensing Pad PS/2 mouse driver.
3 * 3 *
4 * Copyright (C) 2005-2007 Asia Vital Components Co., Ltd. 4 * Copyright (C) 2005-2007 Asia Vital Components Co., Ltd.
5 * Copyright (C) 2005-2011 Tai-hwa Liang, Sentelic Corporation. 5 * Copyright (C) 2005-2012 Tai-hwa Liang, Sentelic Corporation.
6 * 6 *
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License 8 * modify it under the terms of the GNU General Public License
@@ -21,6 +21,7 @@
21 21
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/input.h> 23#include <linux/input.h>
24#include <linux/input/mt.h>
24#include <linux/ctype.h> 25#include <linux/ctype.h>
25#include <linux/libps2.h> 26#include <linux/libps2.h>
26#include <linux/serio.h> 27#include <linux/serio.h>
@@ -36,6 +37,9 @@
36#define FSP_CMD_TIMEOUT 200 37#define FSP_CMD_TIMEOUT 200
37#define FSP_CMD_TIMEOUT2 30 38#define FSP_CMD_TIMEOUT2 30
38 39
40#define GET_ABS_X(packet) ((packet[1] << 2) | ((packet[3] >> 2) & 0x03))
41#define GET_ABS_Y(packet) ((packet[2] << 2) | (packet[3] & 0x03))
42
39/** Driver version. */ 43/** Driver version. */
40static const char fsp_drv_ver[] = "1.0.0-K"; 44static const char fsp_drv_ver[] = "1.0.0-K";
41 45
@@ -128,8 +132,9 @@ static int fsp_reg_read(struct psmouse *psmouse, int reg_addr, int *reg_val)
128 out: 132 out:
129 ps2_end_command(ps2dev); 133 ps2_end_command(ps2dev);
130 psmouse_activate(psmouse); 134 psmouse_activate(psmouse);
131 dev_dbg(&ps2dev->serio->dev, "READ REG: 0x%02x is 0x%02x (rc = %d)\n", 135 psmouse_dbg(psmouse,
132 reg_addr, *reg_val, rc); 136 "READ REG: 0x%02x is 0x%02x (rc = %d)\n",
137 reg_addr, *reg_val, rc);
133 return rc; 138 return rc;
134} 139}
135 140
@@ -179,8 +184,9 @@ static int fsp_reg_write(struct psmouse *psmouse, int reg_addr, int reg_val)
179 184
180 out: 185 out:
181 ps2_end_command(ps2dev); 186 ps2_end_command(ps2dev);
182 dev_dbg(&ps2dev->serio->dev, "WRITE REG: 0x%02x to 0x%02x (rc = %d)\n", 187 psmouse_dbg(psmouse,
183 reg_addr, reg_val, rc); 188 "WRITE REG: 0x%02x to 0x%02x (rc = %d)\n",
189 reg_addr, reg_val, rc);
184 return rc; 190 return rc;
185} 191}
186 192
@@ -237,8 +243,9 @@ static int fsp_page_reg_read(struct psmouse *psmouse, int *reg_val)
237 out: 243 out:
238 ps2_end_command(ps2dev); 244 ps2_end_command(ps2dev);
239 psmouse_activate(psmouse); 245 psmouse_activate(psmouse);
240 dev_dbg(&ps2dev->serio->dev, "READ PAGE REG: 0x%02x (rc = %d)\n", 246 psmouse_dbg(psmouse,
241 *reg_val, rc); 247 "READ PAGE REG: 0x%02x (rc = %d)\n",
248 *reg_val, rc);
242 return rc; 249 return rc;
243} 250}
244 251
@@ -274,8 +281,9 @@ static int fsp_page_reg_write(struct psmouse *psmouse, int reg_val)
274 281
275 out: 282 out:
276 ps2_end_command(ps2dev); 283 ps2_end_command(ps2dev);
277 dev_dbg(&ps2dev->serio->dev, "WRITE PAGE REG: to 0x%02x (rc = %d)\n", 284 psmouse_dbg(psmouse,
278 reg_val, rc); 285 "WRITE PAGE REG: to 0x%02x (rc = %d)\n",
286 reg_val, rc);
279 return rc; 287 return rc;
280} 288}
281 289
@@ -319,7 +327,7 @@ static int fsp_opc_tag_enable(struct psmouse *psmouse, bool enable)
319 int res = 0; 327 int res = 0;
320 328
321 if (fsp_reg_read(psmouse, FSP_REG_OPC_QDOWN, &v) == -1) { 329 if (fsp_reg_read(psmouse, FSP_REG_OPC_QDOWN, &v) == -1) {
322 dev_err(&psmouse->ps2dev.serio->dev, "Unable get OPC state.\n"); 330 psmouse_err(psmouse, "Unable get OPC state.\n");
323 return -EIO; 331 return -EIO;
324 } 332 }
325 333
@@ -336,8 +344,7 @@ static int fsp_opc_tag_enable(struct psmouse *psmouse, bool enable)
336 } 344 }
337 345
338 if (res != 0) { 346 if (res != 0) {
339 dev_err(&psmouse->ps2dev.serio->dev, 347 psmouse_err(psmouse, "Unable to enable OPC tag.\n");
340 "Unable to enable OPC tag.\n");
341 res = -EIO; 348 res = -EIO;
342 } 349 }
343 350
@@ -615,18 +622,40 @@ static struct attribute_group fsp_attribute_group = {
615 .attrs = fsp_attributes, 622 .attrs = fsp_attributes,
616}; 623};
617 624
618#ifdef FSP_DEBUG 625#ifdef FSP_DEBUG
619static void fsp_packet_debug(unsigned char packet[]) 626static void fsp_packet_debug(struct psmouse *psmouse, unsigned char packet[])
620{ 627{
621 static unsigned int ps2_packet_cnt; 628 static unsigned int ps2_packet_cnt;
622 static unsigned int ps2_last_second; 629 static unsigned int ps2_last_second;
623 unsigned int jiffies_msec; 630 unsigned int jiffies_msec;
631 const char *packet_type = "UNKNOWN";
632 unsigned short abs_x = 0, abs_y = 0;
633
634 /* Interpret & dump the packet data. */
635 switch (packet[0] >> FSP_PKT_TYPE_SHIFT) {
636 case FSP_PKT_TYPE_ABS:
637 packet_type = "Absolute";
638 abs_x = GET_ABS_X(packet);
639 abs_y = GET_ABS_Y(packet);
640 break;
641 case FSP_PKT_TYPE_NORMAL:
642 packet_type = "Normal";
643 break;
644 case FSP_PKT_TYPE_NOTIFY:
645 packet_type = "Notify";
646 break;
647 case FSP_PKT_TYPE_NORMAL_OPC:
648 packet_type = "Normal-OPC";
649 break;
650 }
624 651
625 ps2_packet_cnt++; 652 ps2_packet_cnt++;
626 jiffies_msec = jiffies_to_msecs(jiffies); 653 jiffies_msec = jiffies_to_msecs(jiffies);
627 psmouse_dbg(psmouse, 654 psmouse_dbg(psmouse,
628 "%08dms PS/2 packets: %02x, %02x, %02x, %02x\n", 655 "%08dms %s packets: %02x, %02x, %02x, %02x; "
629 jiffies_msec, packet[0], packet[1], packet[2], packet[3]); 656 "abs_x: %d, abs_y: %d\n",
657 jiffies_msec, packet_type,
658 packet[0], packet[1], packet[2], packet[3], abs_x, abs_y);
630 659
631 if (jiffies_msec - ps2_last_second > 1000) { 660 if (jiffies_msec - ps2_last_second > 1000) {
632 psmouse_dbg(psmouse, "PS/2 packets/sec = %d\n", ps2_packet_cnt); 661 psmouse_dbg(psmouse, "PS/2 packets/sec = %d\n", ps2_packet_cnt);
@@ -635,17 +664,29 @@ static void fsp_packet_debug(unsigned char packet[])
635 } 664 }
636} 665}
637#else 666#else
638static void fsp_packet_debug(unsigned char packet[]) 667static void fsp_packet_debug(struct psmouse *psmouse, unsigned char packet[])
639{ 668{
640} 669}
641#endif 670#endif
642 671
672static void fsp_set_slot(struct input_dev *dev, int slot, bool active,
673 unsigned int x, unsigned int y)
674{
675 input_mt_slot(dev, slot);
676 input_mt_report_slot_state(dev, MT_TOOL_FINGER, active);
677 if (active) {
678 input_report_abs(dev, ABS_MT_POSITION_X, x);
679 input_report_abs(dev, ABS_MT_POSITION_Y, y);
680 }
681}
682
643static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse) 683static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse)
644{ 684{
645 struct input_dev *dev = psmouse->dev; 685 struct input_dev *dev = psmouse->dev;
646 struct fsp_data *ad = psmouse->private; 686 struct fsp_data *ad = psmouse->private;
647 unsigned char *packet = psmouse->packet; 687 unsigned char *packet = psmouse->packet;
648 unsigned char button_status = 0, lscroll = 0, rscroll = 0; 688 unsigned char button_status = 0, lscroll = 0, rscroll = 0;
689 unsigned short abs_x, abs_y, fgrs = 0;
649 int rel_x, rel_y; 690 int rel_x, rel_y;
650 691
651 if (psmouse->pktcnt < 4) 692 if (psmouse->pktcnt < 4)
@@ -655,16 +696,76 @@ static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse)
655 * Full packet accumulated, process it 696 * Full packet accumulated, process it
656 */ 697 */
657 698
699 fsp_packet_debug(psmouse, packet);
700
658 switch (psmouse->packet[0] >> FSP_PKT_TYPE_SHIFT) { 701 switch (psmouse->packet[0] >> FSP_PKT_TYPE_SHIFT) {
659 case FSP_PKT_TYPE_ABS: 702 case FSP_PKT_TYPE_ABS:
660 dev_warn(&psmouse->ps2dev.serio->dev, 703 abs_x = GET_ABS_X(packet);
661 "Unexpected absolute mode packet, ignored.\n"); 704 abs_y = GET_ABS_Y(packet);
705
706 if (packet[0] & FSP_PB0_MFMC) {
707 /*
708 * MFMC packet: assume that there are two fingers on
709 * pad
710 */
711 fgrs = 2;
712
713 /* MFMC packet */
714 if (packet[0] & FSP_PB0_MFMC_FGR2) {
715 /* 2nd finger */
716 if (ad->last_mt_fgr == 2) {
717 /*
718 * workaround for buggy firmware
719 * which doesn't clear MFMC bit if
720 * the 1st finger is up
721 */
722 fgrs = 1;
723 fsp_set_slot(dev, 0, false, 0, 0);
724 }
725 ad->last_mt_fgr = 2;
726
727 fsp_set_slot(dev, 1, fgrs == 2, abs_x, abs_y);
728 } else {
729 /* 1st finger */
730 if (ad->last_mt_fgr == 1) {
731 /*
732 * workaround for buggy firmware
733 * which doesn't clear MFMC bit if
734 * the 2nd finger is up
735 */
736 fgrs = 1;
737 fsp_set_slot(dev, 1, false, 0, 0);
738 }
739 ad->last_mt_fgr = 1;
740 fsp_set_slot(dev, 0, fgrs != 0, abs_x, abs_y);
741 }
742 } else {
743 /* SFAC packet */
744
745 /* no multi-finger information */
746 ad->last_mt_fgr = 0;
747
748 if (abs_x != 0 && abs_y != 0)
749 fgrs = 1;
750
751 fsp_set_slot(dev, 0, fgrs > 0, abs_x, abs_y);
752 fsp_set_slot(dev, 1, false, 0, 0);
753 }
754 if (fgrs > 0) {
755 input_report_abs(dev, ABS_X, abs_x);
756 input_report_abs(dev, ABS_Y, abs_y);
757 }
758 input_report_key(dev, BTN_LEFT, packet[0] & 0x01);
759 input_report_key(dev, BTN_RIGHT, packet[0] & 0x02);
760 input_report_key(dev, BTN_TOUCH, fgrs);
761 input_report_key(dev, BTN_TOOL_FINGER, fgrs == 1);
762 input_report_key(dev, BTN_TOOL_DOUBLETAP, fgrs == 2);
662 break; 763 break;
663 764
664 case FSP_PKT_TYPE_NORMAL_OPC: 765 case FSP_PKT_TYPE_NORMAL_OPC:
665 /* on-pad click, filter it if necessary */ 766 /* on-pad click, filter it if necessary */
666 if ((ad->flags & FSPDRV_FLAG_EN_OPC) != FSPDRV_FLAG_EN_OPC) 767 if ((ad->flags & FSPDRV_FLAG_EN_OPC) != FSPDRV_FLAG_EN_OPC)
667 packet[0] &= ~BIT(0); 768 packet[0] &= ~FSP_PB0_LBTN;
668 /* fall through */ 769 /* fall through */
669 770
670 case FSP_PKT_TYPE_NORMAL: 771 case FSP_PKT_TYPE_NORMAL:
@@ -711,8 +812,6 @@ static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse)
711 812
712 input_sync(dev); 813 input_sync(dev);
713 814
714 fsp_packet_debug(packet);
715
716 return PSMOUSE_FULL_PACKET; 815 return PSMOUSE_FULL_PACKET;
717} 816}
718 817
@@ -736,42 +835,106 @@ static int fsp_activate_protocol(struct psmouse *psmouse)
736 835
737 ps2_command(ps2dev, param, PSMOUSE_CMD_GETID); 836 ps2_command(ps2dev, param, PSMOUSE_CMD_GETID);
738 if (param[0] != 0x04) { 837 if (param[0] != 0x04) {
739 dev_err(&psmouse->ps2dev.serio->dev, 838 psmouse_err(psmouse,
740 "Unable to enable 4 bytes packet format.\n"); 839 "Unable to enable 4 bytes packet format.\n");
741 return -EIO; 840 return -EIO;
742 } 841 }
743 842
744 if (fsp_reg_read(psmouse, FSP_REG_SYSCTL5, &val)) { 843 if (pad->ver < FSP_VER_STL3888_C0) {
745 dev_err(&psmouse->ps2dev.serio->dev, 844 /* Preparing relative coordinates output for older hardware */
746 "Unable to read SYSCTL5 register.\n"); 845 if (fsp_reg_read(psmouse, FSP_REG_SYSCTL5, &val)) {
747 return -EIO; 846 psmouse_err(psmouse,
748 } 847 "Unable to read SYSCTL5 register.\n");
848 return -EIO;
849 }
749 850
750 val &= ~(FSP_BIT_EN_MSID7 | FSP_BIT_EN_MSID8 | FSP_BIT_EN_AUTO_MSID8); 851 if (fsp_get_buttons(psmouse, &pad->buttons)) {
751 /* Ensure we are not in absolute mode */ 852 psmouse_err(psmouse,
752 val &= ~FSP_BIT_EN_PKT_G0; 853 "Unable to retrieve number of buttons.\n");
753 if (pad->buttons == 0x06) { 854 return -EIO;
754 /* Left/Middle/Right & Scroll Up/Down/Right/Left */ 855 }
755 val |= FSP_BIT_EN_MSID6;
756 }
757 856
758 if (fsp_reg_write(psmouse, FSP_REG_SYSCTL5, val)) { 857 val &= ~(FSP_BIT_EN_MSID7 | FSP_BIT_EN_MSID8 | FSP_BIT_EN_AUTO_MSID8);
759 dev_err(&psmouse->ps2dev.serio->dev, 858 /* Ensure we are not in absolute mode */
760 "Unable to set up required mode bits.\n"); 859 val &= ~FSP_BIT_EN_PKT_G0;
761 return -EIO; 860 if (pad->buttons == 0x06) {
861 /* Left/Middle/Right & Scroll Up/Down/Right/Left */
862 val |= FSP_BIT_EN_MSID6;
863 }
864
865 if (fsp_reg_write(psmouse, FSP_REG_SYSCTL5, val)) {
866 psmouse_err(psmouse,
867 "Unable to set up required mode bits.\n");
868 return -EIO;
869 }
870
871 /*
872 * Enable OPC tags such that driver can tell the difference
873 * between on-pad and real button click
874 */
875 if (fsp_opc_tag_enable(psmouse, true))
876 psmouse_warn(psmouse,
877 "Failed to enable OPC tag mode.\n");
878 /* enable on-pad click by default */
879 pad->flags |= FSPDRV_FLAG_EN_OPC;
880
881 /* Enable on-pad vertical and horizontal scrolling */
882 fsp_onpad_vscr(psmouse, true);
883 fsp_onpad_hscr(psmouse, true);
884 } else {
885 /* Enable absolute coordinates output for Cx/Dx hardware */
886 if (fsp_reg_write(psmouse, FSP_REG_SWC1,
887 FSP_BIT_SWC1_EN_ABS_1F |
888 FSP_BIT_SWC1_EN_ABS_2F |
889 FSP_BIT_SWC1_EN_FUP_OUT |
890 FSP_BIT_SWC1_EN_ABS_CON)) {
891 psmouse_err(psmouse,
892 "Unable to enable absolute coordinates output.\n");
893 return -EIO;
894 }
762 } 895 }
763 896
764 /* 897 return 0;
765 * Enable OPC tags such that driver can tell the difference between 898}
766 * on-pad and real button click
767 */
768 if (fsp_opc_tag_enable(psmouse, true))
769 dev_warn(&psmouse->ps2dev.serio->dev,
770 "Failed to enable OPC tag mode.\n");
771 899
772 /* Enable on-pad vertical and horizontal scrolling */ 900static int fsp_set_input_params(struct psmouse *psmouse)
773 fsp_onpad_vscr(psmouse, true); 901{
774 fsp_onpad_hscr(psmouse, true); 902 struct input_dev *dev = psmouse->dev;
903 struct fsp_data *pad = psmouse->private;
904
905 if (pad->ver < FSP_VER_STL3888_C0) {
906 __set_bit(BTN_MIDDLE, dev->keybit);
907 __set_bit(BTN_BACK, dev->keybit);
908 __set_bit(BTN_FORWARD, dev->keybit);
909 __set_bit(REL_WHEEL, dev->relbit);
910 __set_bit(REL_HWHEEL, dev->relbit);
911 } else {
912 /*
913 * Hardware prior to Cx performs much better in relative mode;
914 * hence, only enable absolute coordinates output as well as
915 * multi-touch output for the newer hardware.
916 *
917 * Maximum coordinates can be computed as:
918 *
919 * number of scanlines * 64 - 57
920 *
921 * where number of X/Y scanline lines are 16/12.
922 */
923 int abs_x = 967, abs_y = 711;
924
925 __set_bit(EV_ABS, dev->evbit);
926 __clear_bit(EV_REL, dev->evbit);
927 __set_bit(BTN_TOUCH, dev->keybit);
928 __set_bit(BTN_TOOL_FINGER, dev->keybit);
929 __set_bit(BTN_TOOL_DOUBLETAP, dev->keybit);
930 __set_bit(INPUT_PROP_SEMI_MT, dev->propbit);
931
932 input_set_abs_params(dev, ABS_X, 0, abs_x, 0, 0);
933 input_set_abs_params(dev, ABS_Y, 0, abs_y, 0, 0);
934 input_mt_init_slots(dev, 2);
935 input_set_abs_params(dev, ABS_MT_POSITION_X, 0, abs_x, 0, 0);
936 input_set_abs_params(dev, ABS_MT_POSITION_Y, 0, abs_y, 0, 0);
937 }
775 938
776 return 0; 939 return 0;
777} 940}
@@ -829,18 +992,16 @@ static int fsp_reconnect(struct psmouse *psmouse)
829int fsp_init(struct psmouse *psmouse) 992int fsp_init(struct psmouse *psmouse)
830{ 993{
831 struct fsp_data *priv; 994 struct fsp_data *priv;
832 int ver, rev, buttons; 995 int ver, rev;
833 int error; 996 int error;
834 997
835 if (fsp_get_version(psmouse, &ver) || 998 if (fsp_get_version(psmouse, &ver) ||
836 fsp_get_revision(psmouse, &rev) || 999 fsp_get_revision(psmouse, &rev)) {
837 fsp_get_buttons(psmouse, &buttons)) {
838 return -ENODEV; 1000 return -ENODEV;
839 } 1001 }
840 1002
841 psmouse_info(psmouse, 1003 psmouse_info(psmouse, "Finger Sensing Pad, hw: %d.%d.%d, sw: %s\n",
842 "Finger Sensing Pad, hw: %d.%d.%d, sw: %s, buttons: %d\n", 1004 ver >> 4, ver & 0x0F, rev, fsp_drv_ver);
843 ver >> 4, ver & 0x0F, rev, fsp_drv_ver, buttons & 7);
844 1005
845 psmouse->private = priv = kzalloc(sizeof(struct fsp_data), GFP_KERNEL); 1006 psmouse->private = priv = kzalloc(sizeof(struct fsp_data), GFP_KERNEL);
846 if (!priv) 1007 if (!priv)
@@ -848,17 +1009,6 @@ int fsp_init(struct psmouse *psmouse)
848 1009
849 priv->ver = ver; 1010 priv->ver = ver;
850 priv->rev = rev; 1011 priv->rev = rev;
851 priv->buttons = buttons;
852
853 /* enable on-pad click by default */
854 priv->flags |= FSPDRV_FLAG_EN_OPC;
855
856 /* Set up various supported input event bits */
857 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
858 __set_bit(BTN_BACK, psmouse->dev->keybit);
859 __set_bit(BTN_FORWARD, psmouse->dev->keybit);
860 __set_bit(REL_WHEEL, psmouse->dev->relbit);
861 __set_bit(REL_HWHEEL, psmouse->dev->relbit);
862 1012
863 psmouse->protocol_handler = fsp_process_byte; 1013 psmouse->protocol_handler = fsp_process_byte;
864 psmouse->disconnect = fsp_disconnect; 1014 psmouse->disconnect = fsp_disconnect;
@@ -866,16 +1016,20 @@ int fsp_init(struct psmouse *psmouse)
866 psmouse->cleanup = fsp_reset; 1016 psmouse->cleanup = fsp_reset;
867 psmouse->pktsize = 4; 1017 psmouse->pktsize = 4;
868 1018
869 /* set default packet output based on number of buttons we found */
870 error = fsp_activate_protocol(psmouse); 1019 error = fsp_activate_protocol(psmouse);
871 if (error) 1020 if (error)
872 goto err_out; 1021 goto err_out;
873 1022
1023 /* Set up various supported input event bits */
1024 error = fsp_set_input_params(psmouse);
1025 if (error)
1026 goto err_out;
1027
874 error = sysfs_create_group(&psmouse->ps2dev.serio->dev.kobj, 1028 error = sysfs_create_group(&psmouse->ps2dev.serio->dev.kobj,
875 &fsp_attribute_group); 1029 &fsp_attribute_group);
876 if (error) { 1030 if (error) {
877 dev_err(&psmouse->ps2dev.serio->dev, 1031 psmouse_err(psmouse,
878 "Failed to create sysfs attributes (%d)", error); 1032 "Failed to create sysfs attributes (%d)", error);
879 goto err_out; 1033 goto err_out;
880 } 1034 }
881 1035
diff --git a/drivers/input/mouse/sentelic.h b/drivers/input/mouse/sentelic.h
index 2e4af24f8c15..334de19e5ddb 100644
--- a/drivers/input/mouse/sentelic.h
+++ b/drivers/input/mouse/sentelic.h
@@ -2,7 +2,7 @@
2 * Finger Sensing Pad PS/2 mouse driver. 2 * Finger Sensing Pad PS/2 mouse driver.
3 * 3 *
4 * Copyright (C) 2005-2007 Asia Vital Components Co., Ltd. 4 * Copyright (C) 2005-2007 Asia Vital Components Co., Ltd.
5 * Copyright (C) 2005-2011 Tai-hwa Liang, Sentelic Corporation. 5 * Copyright (C) 2005-2012 Tai-hwa Liang, Sentelic Corporation.
6 * 6 *
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License 8 * modify it under the terms of the GNU General Public License
@@ -55,6 +55,16 @@
55#define FSP_BIT_FIX_HSCR BIT(5) 55#define FSP_BIT_FIX_HSCR BIT(5)
56#define FSP_BIT_DRAG_LOCK BIT(6) 56#define FSP_BIT_DRAG_LOCK BIT(6)
57 57
58#define FSP_REG_SWC1 (0x90)
59#define FSP_BIT_SWC1_EN_ABS_1F BIT(0)
60#define FSP_BIT_SWC1_EN_GID BIT(1)
61#define FSP_BIT_SWC1_EN_ABS_2F BIT(2)
62#define FSP_BIT_SWC1_EN_FUP_OUT BIT(3)
63#define FSP_BIT_SWC1_EN_ABS_CON BIT(4)
64#define FSP_BIT_SWC1_GST_GRP0 BIT(5)
65#define FSP_BIT_SWC1_GST_GRP1 BIT(6)
66#define FSP_BIT_SWC1_BX_COMPAT BIT(7)
67
58/* Finger-sensing Pad packet formating related definitions */ 68/* Finger-sensing Pad packet formating related definitions */
59 69
60/* absolute packet type */ 70/* absolute packet type */
@@ -64,12 +74,32 @@
64#define FSP_PKT_TYPE_NORMAL_OPC (0x03) 74#define FSP_PKT_TYPE_NORMAL_OPC (0x03)
65#define FSP_PKT_TYPE_SHIFT (6) 75#define FSP_PKT_TYPE_SHIFT (6)
66 76
77/* bit definitions for the first byte of report packet */
78#define FSP_PB0_LBTN BIT(0)
79#define FSP_PB0_RBTN BIT(1)
80#define FSP_PB0_MBTN BIT(2)
81#define FSP_PB0_MFMC_FGR2 FSP_PB0_MBTN
82#define FSP_PB0_MUST_SET BIT(3)
83#define FSP_PB0_PHY_BTN BIT(4)
84#define FSP_PB0_MFMC BIT(5)
85
86/* hardware revisions */
87#define FSP_VER_STL3888_A4 (0xC1)
88#define FSP_VER_STL3888_B0 (0xD0)
89#define FSP_VER_STL3888_B1 (0xD1)
90#define FSP_VER_STL3888_B2 (0xD2)
91#define FSP_VER_STL3888_C0 (0xE0)
92#define FSP_VER_STL3888_C1 (0xE1)
93#define FSP_VER_STL3888_D0 (0xE2)
94#define FSP_VER_STL3888_D1 (0xE3)
95#define FSP_VER_STL3888_E0 (0xE4)
96
67#ifdef __KERNEL__ 97#ifdef __KERNEL__
68 98
69struct fsp_data { 99struct fsp_data {
70 unsigned char ver; /* hardware version */ 100 unsigned char ver; /* hardware version */
71 unsigned char rev; /* hardware revison */ 101 unsigned char rev; /* hardware revison */
72 unsigned char buttons; /* Number of buttons */ 102 unsigned int buttons; /* Number of buttons */
73 unsigned int flags; 103 unsigned int flags;
74#define FSPDRV_FLAG_EN_OPC (0x001) /* enable on-pad clicking */ 104#define FSPDRV_FLAG_EN_OPC (0x001) /* enable on-pad clicking */
75 105
@@ -78,6 +108,7 @@ struct fsp_data {
78 108
79 unsigned char last_reg; /* Last register we requested read from */ 109 unsigned char last_reg; /* Last register we requested read from */
80 unsigned char last_val; 110 unsigned char last_val;
111 unsigned int last_mt_fgr; /* Last seen finger(multitouch) */
81}; 112};
82 113
83#ifdef CONFIG_MOUSE_PS2_SENTELIC 114#ifdef CONFIG_MOUSE_PS2_SENTELIC
diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c
index bd5b10eeeb40..f5fbdf94de3b 100644
--- a/drivers/input/serio/ams_delta_serio.c
+++ b/drivers/input/serio/ams_delta_serio.c
@@ -184,7 +184,7 @@ module_init(ams_delta_serio_init);
184static void __exit ams_delta_serio_exit(void) 184static void __exit ams_delta_serio_exit(void)
185{ 185{
186 serio_unregister_port(ams_delta_serio); 186 serio_unregister_port(ams_delta_serio);
187 free_irq(OMAP_GPIO_IRQ(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0); 187 free_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0);
188 gpio_free_array(ams_delta_gpios, 188 gpio_free_array(ams_delta_gpios,
189 ARRAY_SIZE(ams_delta_gpios)); 189 ARRAY_SIZE(ams_delta_gpios));
190} 190}
diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c
index be3316073ae7..09a089996ded 100644
--- a/drivers/input/serio/hp_sdc.c
+++ b/drivers/input/serio/hp_sdc.c
@@ -71,7 +71,6 @@
71#include <linux/slab.h> 71#include <linux/slab.h>
72#include <linux/hil.h> 72#include <linux/hil.h>
73#include <asm/io.h> 73#include <asm/io.h>
74#include <asm/system.h>
75 74
76/* Machine-specific abstraction */ 75/* Machine-specific abstraction */
77 76
diff --git a/drivers/input/serio/maceps2.c b/drivers/input/serio/maceps2.c
index 558200e96d0f..61da763b1209 100644
--- a/drivers/input/serio/maceps2.c
+++ b/drivers/input/serio/maceps2.c
@@ -21,7 +21,6 @@
21 21
22#include <asm/io.h> 22#include <asm/io.h>
23#include <asm/irq.h> 23#include <asm/irq.h>
24#include <asm/system.h>
25#include <asm/ip32/mace.h> 24#include <asm/ip32/mace.h>
26#include <asm/ip32/ip32_ints.h> 25#include <asm/ip32/ip32_ints.h>
27 26
diff --git a/drivers/input/serio/rpckbd.c b/drivers/input/serio/rpckbd.c
index 8b44ddc8041c..2af5df6a8fba 100644
--- a/drivers/input/serio/rpckbd.c
+++ b/drivers/input/serio/rpckbd.c
@@ -36,16 +36,19 @@
36#include <linux/io.h> 36#include <linux/io.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38 38
39#include <asm/irq.h>
40#include <mach/hardware.h> 39#include <mach/hardware.h>
41#include <asm/hardware/iomd.h> 40#include <asm/hardware/iomd.h>
42#include <asm/system.h>
43 41
44MODULE_AUTHOR("Vojtech Pavlik, Russell King"); 42MODULE_AUTHOR("Vojtech Pavlik, Russell King");
45MODULE_DESCRIPTION("Acorn RiscPC PS/2 keyboard controller driver"); 43MODULE_DESCRIPTION("Acorn RiscPC PS/2 keyboard controller driver");
46MODULE_LICENSE("GPL"); 44MODULE_LICENSE("GPL");
47MODULE_ALIAS("platform:kart"); 45MODULE_ALIAS("platform:kart");
48 46
47struct rpckbd_data {
48 int tx_irq;
49 int rx_irq;
50};
51
49static int rpckbd_write(struct serio *port, unsigned char val) 52static int rpckbd_write(struct serio *port, unsigned char val)
50{ 53{
51 while (!(iomd_readb(IOMD_KCTRL) & (1 << 7))) 54 while (!(iomd_readb(IOMD_KCTRL) & (1 << 7)))
@@ -78,19 +81,21 @@ static irqreturn_t rpckbd_tx(int irq, void *dev_id)
78 81
79static int rpckbd_open(struct serio *port) 82static int rpckbd_open(struct serio *port)
80{ 83{
84 struct rpckbd_data *rpckbd = port->port_data;
85
81 /* Reset the keyboard state machine. */ 86 /* Reset the keyboard state machine. */
82 iomd_writeb(0, IOMD_KCTRL); 87 iomd_writeb(0, IOMD_KCTRL);
83 iomd_writeb(8, IOMD_KCTRL); 88 iomd_writeb(8, IOMD_KCTRL);
84 iomd_readb(IOMD_KARTRX); 89 iomd_readb(IOMD_KARTRX);
85 90
86 if (request_irq(IRQ_KEYBOARDRX, rpckbd_rx, 0, "rpckbd", port) != 0) { 91 if (request_irq(rpckbd->rx_irq, rpckbd_rx, 0, "rpckbd", port) != 0) {
87 printk(KERN_ERR "rpckbd.c: Could not allocate keyboard receive IRQ\n"); 92 printk(KERN_ERR "rpckbd.c: Could not allocate keyboard receive IRQ\n");
88 return -EBUSY; 93 return -EBUSY;
89 } 94 }
90 95
91 if (request_irq(IRQ_KEYBOARDTX, rpckbd_tx, 0, "rpckbd", port) != 0) { 96 if (request_irq(rpckbd->tx_irq, rpckbd_tx, 0, "rpckbd", port) != 0) {
92 printk(KERN_ERR "rpckbd.c: Could not allocate keyboard transmit IRQ\n"); 97 printk(KERN_ERR "rpckbd.c: Could not allocate keyboard transmit IRQ\n");
93 free_irq(IRQ_KEYBOARDRX, port); 98 free_irq(rpckbd->rx_irq, port);
94 return -EBUSY; 99 return -EBUSY;
95 } 100 }
96 101
@@ -99,8 +104,10 @@ static int rpckbd_open(struct serio *port)
99 104
100static void rpckbd_close(struct serio *port) 105static void rpckbd_close(struct serio *port)
101{ 106{
102 free_irq(IRQ_KEYBOARDRX, port); 107 struct rpckbd_data *rpckbd = port->port_data;
103 free_irq(IRQ_KEYBOARDTX, port); 108
109 free_irq(rpckbd->rx_irq, port);
110 free_irq(rpckbd->tx_irq, port);
104} 111}
105 112
106/* 113/*
@@ -109,17 +116,35 @@ static void rpckbd_close(struct serio *port)
109 */ 116 */
110static int __devinit rpckbd_probe(struct platform_device *dev) 117static int __devinit rpckbd_probe(struct platform_device *dev)
111{ 118{
119 struct rpckbd_data *rpckbd;
112 struct serio *serio; 120 struct serio *serio;
121 int tx_irq, rx_irq;
122
123 rx_irq = platform_get_irq(dev, 0);
124 if (rx_irq <= 0)
125 return rx_irq < 0 ? rx_irq : -ENXIO;
126
127 tx_irq = platform_get_irq(dev, 1);
128 if (tx_irq <= 0)
129 return tx_irq < 0 ? tx_irq : -ENXIO;
113 130
114 serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 131 serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
115 if (!serio) 132 rpckbd = kzalloc(sizeof(*rpckbd), GFP_KERNEL);
133 if (!serio || !rpckbd) {
134 kfree(rpckbd);
135 kfree(serio);
116 return -ENOMEM; 136 return -ENOMEM;
137 }
138
139 rpckbd->rx_irq = rx_irq;
140 rpckbd->tx_irq = tx_irq;
117 141
118 serio->id.type = SERIO_8042; 142 serio->id.type = SERIO_8042;
119 serio->write = rpckbd_write; 143 serio->write = rpckbd_write;
120 serio->open = rpckbd_open; 144 serio->open = rpckbd_open;
121 serio->close = rpckbd_close; 145 serio->close = rpckbd_close;
122 serio->dev.parent = &dev->dev; 146 serio->dev.parent = &dev->dev;
147 serio->port_data = rpckbd;
123 strlcpy(serio->name, "RiscPC PS/2 kbd port", sizeof(serio->name)); 148 strlcpy(serio->name, "RiscPC PS/2 kbd port", sizeof(serio->name));
124 strlcpy(serio->phys, "rpckbd/serio0", sizeof(serio->phys)); 149 strlcpy(serio->phys, "rpckbd/serio0", sizeof(serio->phys));
125 150
@@ -131,7 +156,11 @@ static int __devinit rpckbd_probe(struct platform_device *dev)
131static int __devexit rpckbd_remove(struct platform_device *dev) 156static int __devexit rpckbd_remove(struct platform_device *dev)
132{ 157{
133 struct serio *serio = platform_get_drvdata(dev); 158 struct serio *serio = platform_get_drvdata(dev);
159 struct rpckbd_data *rpckbd = serio->port_data;
160
134 serio_unregister_port(serio); 161 serio_unregister_port(serio);
162 kfree(rpckbd);
163
135 return 0; 164 return 0;
136} 165}
137 166
diff --git a/drivers/input/serio/sa1111ps2.c b/drivers/input/serio/sa1111ps2.c
index 44fc8b4bcd81..389766707534 100644
--- a/drivers/input/serio/sa1111ps2.c
+++ b/drivers/input/serio/sa1111ps2.c
@@ -20,10 +20,29 @@
20#include <linux/spinlock.h> 20#include <linux/spinlock.h>
21 21
22#include <asm/io.h> 22#include <asm/io.h>
23#include <asm/system.h>
24 23
25#include <asm/hardware/sa1111.h> 24#include <asm/hardware/sa1111.h>
26 25
26#define PS2CR 0x0000
27#define PS2STAT 0x0004
28#define PS2DATA 0x0008
29#define PS2CLKDIV 0x000c
30#define PS2PRECNT 0x0010
31
32#define PS2CR_ENA 0x08
33#define PS2CR_FKD 0x02
34#define PS2CR_FKC 0x01
35
36#define PS2STAT_STP 0x0100
37#define PS2STAT_TXE 0x0080
38#define PS2STAT_TXB 0x0040
39#define PS2STAT_RXF 0x0020
40#define PS2STAT_RXB 0x0010
41#define PS2STAT_ENA 0x0008
42#define PS2STAT_RXP 0x0004
43#define PS2STAT_KBD 0x0002
44#define PS2STAT_KBC 0x0001
45
27struct ps2if { 46struct ps2if {
28 struct serio *io; 47 struct serio *io;
29 struct sa1111_dev *dev; 48 struct sa1111_dev *dev;
@@ -45,22 +64,22 @@ static irqreturn_t ps2_rxint(int irq, void *dev_id)
45 struct ps2if *ps2if = dev_id; 64 struct ps2if *ps2if = dev_id;
46 unsigned int scancode, flag, status; 65 unsigned int scancode, flag, status;
47 66
48 status = sa1111_readl(ps2if->base + SA1111_PS2STAT); 67 status = sa1111_readl(ps2if->base + PS2STAT);
49 while (status & PS2STAT_RXF) { 68 while (status & PS2STAT_RXF) {
50 if (status & PS2STAT_STP) 69 if (status & PS2STAT_STP)
51 sa1111_writel(PS2STAT_STP, ps2if->base + SA1111_PS2STAT); 70 sa1111_writel(PS2STAT_STP, ps2if->base + PS2STAT);
52 71
53 flag = (status & PS2STAT_STP ? SERIO_FRAME : 0) | 72 flag = (status & PS2STAT_STP ? SERIO_FRAME : 0) |
54 (status & PS2STAT_RXP ? 0 : SERIO_PARITY); 73 (status & PS2STAT_RXP ? 0 : SERIO_PARITY);
55 74
56 scancode = sa1111_readl(ps2if->base + SA1111_PS2DATA) & 0xff; 75 scancode = sa1111_readl(ps2if->base + PS2DATA) & 0xff;
57 76
58 if (hweight8(scancode) & 1) 77 if (hweight8(scancode) & 1)
59 flag ^= SERIO_PARITY; 78 flag ^= SERIO_PARITY;
60 79
61 serio_interrupt(ps2if->io, scancode, flag); 80 serio_interrupt(ps2if->io, scancode, flag);
62 81
63 status = sa1111_readl(ps2if->base + SA1111_PS2STAT); 82 status = sa1111_readl(ps2if->base + PS2STAT);
64 } 83 }
65 84
66 return IRQ_HANDLED; 85 return IRQ_HANDLED;
@@ -75,12 +94,12 @@ static irqreturn_t ps2_txint(int irq, void *dev_id)
75 unsigned int status; 94 unsigned int status;
76 95
77 spin_lock(&ps2if->lock); 96 spin_lock(&ps2if->lock);
78 status = sa1111_readl(ps2if->base + SA1111_PS2STAT); 97 status = sa1111_readl(ps2if->base + PS2STAT);
79 if (ps2if->head == ps2if->tail) { 98 if (ps2if->head == ps2if->tail) {
80 disable_irq_nosync(irq); 99 disable_irq_nosync(irq);
81 /* done */ 100 /* done */
82 } else if (status & PS2STAT_TXE) { 101 } else if (status & PS2STAT_TXE) {
83 sa1111_writel(ps2if->buf[ps2if->tail], ps2if->base + SA1111_PS2DATA); 102 sa1111_writel(ps2if->buf[ps2if->tail], ps2if->base + PS2DATA);
84 ps2if->tail = (ps2if->tail + 1) & (sizeof(ps2if->buf) - 1); 103 ps2if->tail = (ps2if->tail + 1) & (sizeof(ps2if->buf) - 1);
85 } 104 }
86 spin_unlock(&ps2if->lock); 105 spin_unlock(&ps2if->lock);
@@ -103,8 +122,8 @@ static int ps2_write(struct serio *io, unsigned char val)
103 /* 122 /*
104 * If the TX register is empty, we can go straight out. 123 * If the TX register is empty, we can go straight out.
105 */ 124 */
106 if (sa1111_readl(ps2if->base + SA1111_PS2STAT) & PS2STAT_TXE) { 125 if (sa1111_readl(ps2if->base + PS2STAT) & PS2STAT_TXE) {
107 sa1111_writel(val, ps2if->base + SA1111_PS2DATA); 126 sa1111_writel(val, ps2if->base + PS2DATA);
108 } else { 127 } else {
109 if (ps2if->head == ps2if->tail) 128 if (ps2if->head == ps2if->tail)
110 enable_irq(ps2if->dev->irq[1]); 129 enable_irq(ps2if->dev->irq[1]);
@@ -124,13 +143,16 @@ static int ps2_open(struct serio *io)
124 struct ps2if *ps2if = io->port_data; 143 struct ps2if *ps2if = io->port_data;
125 int ret; 144 int ret;
126 145
127 sa1111_enable_device(ps2if->dev); 146 ret = sa1111_enable_device(ps2if->dev);
147 if (ret)
148 return ret;
128 149
129 ret = request_irq(ps2if->dev->irq[0], ps2_rxint, 0, 150 ret = request_irq(ps2if->dev->irq[0], ps2_rxint, 0,
130 SA1111_DRIVER_NAME(ps2if->dev), ps2if); 151 SA1111_DRIVER_NAME(ps2if->dev), ps2if);
131 if (ret) { 152 if (ret) {
132 printk(KERN_ERR "sa1111ps2: could not allocate IRQ%d: %d\n", 153 printk(KERN_ERR "sa1111ps2: could not allocate IRQ%d: %d\n",
133 ps2if->dev->irq[0], ret); 154 ps2if->dev->irq[0], ret);
155 sa1111_disable_device(ps2if->dev);
134 return ret; 156 return ret;
135 } 157 }
136 158
@@ -140,6 +162,7 @@ static int ps2_open(struct serio *io)
140 printk(KERN_ERR "sa1111ps2: could not allocate IRQ%d: %d\n", 162 printk(KERN_ERR "sa1111ps2: could not allocate IRQ%d: %d\n",
141 ps2if->dev->irq[1], ret); 163 ps2if->dev->irq[1], ret);
142 free_irq(ps2if->dev->irq[0], ps2if); 164 free_irq(ps2if->dev->irq[0], ps2if);
165 sa1111_disable_device(ps2if->dev);
143 return ret; 166 return ret;
144 } 167 }
145 168
@@ -147,7 +170,7 @@ static int ps2_open(struct serio *io)
147 170
148 enable_irq_wake(ps2if->dev->irq[0]); 171 enable_irq_wake(ps2if->dev->irq[0]);
149 172
150 sa1111_writel(PS2CR_ENA, ps2if->base + SA1111_PS2CR); 173 sa1111_writel(PS2CR_ENA, ps2if->base + PS2CR);
151 return 0; 174 return 0;
152} 175}
153 176
@@ -155,7 +178,7 @@ static void ps2_close(struct serio *io)
155{ 178{
156 struct ps2if *ps2if = io->port_data; 179 struct ps2if *ps2if = io->port_data;
157 180
158 sa1111_writel(0, ps2if->base + SA1111_PS2CR); 181 sa1111_writel(0, ps2if->base + PS2CR);
159 182
160 disable_irq_wake(ps2if->dev->irq[0]); 183 disable_irq_wake(ps2if->dev->irq[0]);
161 184
@@ -175,7 +198,7 @@ static void __devinit ps2_clear_input(struct ps2if *ps2if)
175 int maxread = 100; 198 int maxread = 100;
176 199
177 while (maxread--) { 200 while (maxread--) {
178 if ((sa1111_readl(ps2if->base + SA1111_PS2DATA) & 0xff) == 0xff) 201 if ((sa1111_readl(ps2if->base + PS2DATA) & 0xff) == 0xff)
179 break; 202 break;
180 } 203 }
181} 204}
@@ -185,11 +208,11 @@ static unsigned int __devinit ps2_test_one(struct ps2if *ps2if,
185{ 208{
186 unsigned int val; 209 unsigned int val;
187 210
188 sa1111_writel(PS2CR_ENA | mask, ps2if->base + SA1111_PS2CR); 211 sa1111_writel(PS2CR_ENA | mask, ps2if->base + PS2CR);
189 212
190 udelay(2); 213 udelay(2);
191 214
192 val = sa1111_readl(ps2if->base + SA1111_PS2STAT); 215 val = sa1111_readl(ps2if->base + PS2STAT);
193 return val & (PS2STAT_KBC | PS2STAT_KBD); 216 return val & (PS2STAT_KBC | PS2STAT_KBD);
194} 217}
195 218
@@ -220,7 +243,7 @@ static int __devinit ps2_test(struct ps2if *ps2if)
220 ret = -ENODEV; 243 ret = -ENODEV;
221 } 244 }
222 245
223 sa1111_writel(0, ps2if->base + SA1111_PS2CR); 246 sa1111_writel(0, ps2if->base + PS2CR);
224 247
225 return ret; 248 return ret;
226} 249}
@@ -274,8 +297,8 @@ static int __devinit ps2_probe(struct sa1111_dev *dev)
274 sa1111_enable_device(ps2if->dev); 297 sa1111_enable_device(ps2if->dev);
275 298
276 /* Incoming clock is 8MHz */ 299 /* Incoming clock is 8MHz */
277 sa1111_writel(0, ps2if->base + SA1111_PS2CLKDIV); 300 sa1111_writel(0, ps2if->base + PS2CLKDIV);
278 sa1111_writel(127, ps2if->base + SA1111_PS2PRECNT); 301 sa1111_writel(127, ps2if->base + PS2PRECNT);
279 302
280 /* 303 /*
281 * Flush any pending input. 304 * Flush any pending input.
@@ -330,6 +353,7 @@ static int __devexit ps2_remove(struct sa1111_dev *dev)
330static struct sa1111_driver ps2_driver = { 353static struct sa1111_driver ps2_driver = {
331 .drv = { 354 .drv = {
332 .name = "sa1111-ps2", 355 .name = "sa1111-ps2",
356 .owner = THIS_MODULE,
333 }, 357 },
334 .devid = SA1111_DEVID_PS2, 358 .devid = SA1111_DEVID_PS2,
335 .probe = ps2_probe, 359 .probe = ps2_probe,
diff --git a/drivers/input/tablet/Kconfig b/drivers/input/tablet/Kconfig
index e53f4081a586..bed7cbf84cfd 100644
--- a/drivers/input/tablet/Kconfig
+++ b/drivers/input/tablet/Kconfig
@@ -76,6 +76,7 @@ config TABLET_USB_KBTAB
76config TABLET_USB_WACOM 76config TABLET_USB_WACOM
77 tristate "Wacom Intuos/Graphire tablet support (USB)" 77 tristate "Wacom Intuos/Graphire tablet support (USB)"
78 depends on USB_ARCH_HAS_HCD 78 depends on USB_ARCH_HAS_HCD
79 select POWER_SUPPLY
79 select USB 80 select USB
80 select NEW_LEDS 81 select NEW_LEDS
81 select LEDS_CLASS 82 select LEDS_CLASS
diff --git a/drivers/input/tablet/wacom.h b/drivers/input/tablet/wacom.h
index 0783864a7dc2..b4842d0e61dd 100644
--- a/drivers/input/tablet/wacom.h
+++ b/drivers/input/tablet/wacom.h
@@ -88,6 +88,7 @@
88#include <linux/mod_devicetable.h> 88#include <linux/mod_devicetable.h>
89#include <linux/init.h> 89#include <linux/init.h>
90#include <linux/usb/input.h> 90#include <linux/usb/input.h>
91#include <linux/power_supply.h>
91#include <asm/unaligned.h> 92#include <asm/unaligned.h>
92 93
93/* 94/*
@@ -112,6 +113,7 @@ struct wacom {
112 struct urb *irq; 113 struct urb *irq;
113 struct wacom_wac wacom_wac; 114 struct wacom_wac wacom_wac;
114 struct mutex lock; 115 struct mutex lock;
116 struct work_struct work;
115 bool open; 117 bool open;
116 char phys[32]; 118 char phys[32];
117 struct wacom_led { 119 struct wacom_led {
@@ -120,8 +122,15 @@ struct wacom {
120 u8 hlv; /* status led brightness button pressed (1..127) */ 122 u8 hlv; /* status led brightness button pressed (1..127) */
121 u8 img_lum; /* OLED matrix display brightness */ 123 u8 img_lum; /* OLED matrix display brightness */
122 } led; 124 } led;
125 struct power_supply battery;
123}; 126};
124 127
128static inline void wacom_schedule_work(struct wacom_wac *wacom_wac)
129{
130 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
131 schedule_work(&wacom->work);
132}
133
125extern const struct usb_device_id wacom_ids[]; 134extern const struct usb_device_id wacom_ids[];
126 135
127void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len); 136void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index ca28066dc81e..0d269212931e 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -167,6 +167,19 @@ static void wacom_close(struct input_dev *dev)
167 usb_autopm_put_interface(wacom->intf); 167 usb_autopm_put_interface(wacom->intf);
168} 168}
169 169
170/*
171 * Static values for max X/Y and resolution of Pen interface is stored in
172 * features. This mean physical size of active area can be computed.
173 * This is useful to do when Pen and Touch have same active area of tablet.
174 * This means for Touch device, we only need to find max X/Y value and we
175 * have enough information to compute resolution of touch.
176 */
177static void wacom_set_phy_from_res(struct wacom_features *features)
178{
179 features->x_phy = (features->x_max * 100) / features->x_resolution;
180 features->y_phy = (features->y_max * 100) / features->y_resolution;
181}
182
170static int wacom_parse_logical_collection(unsigned char *report, 183static int wacom_parse_logical_collection(unsigned char *report,
171 struct wacom_features *features) 184 struct wacom_features *features)
172{ 185{
@@ -178,15 +191,7 @@ static int wacom_parse_logical_collection(unsigned char *report,
178 features->pktlen = WACOM_PKGLEN_BBTOUCH3; 191 features->pktlen = WACOM_PKGLEN_BBTOUCH3;
179 features->device_type = BTN_TOOL_FINGER; 192 features->device_type = BTN_TOOL_FINGER;
180 193
181 /* 194 wacom_set_phy_from_res(features);
182 * Stylus and Touch have same active area
183 * so compute physical size based on stylus
184 * data before its overwritten.
185 */
186 features->x_phy =
187 (features->x_max * 100) / features->x_resolution;
188 features->y_phy =
189 (features->y_max * 100) / features->y_resolution;
190 195
191 features->x_max = features->y_max = 196 features->x_max = features->y_max =
192 get_unaligned_le16(&report[10]); 197 get_unaligned_le16(&report[10]);
@@ -422,6 +427,7 @@ static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_feat
422 report_id, rep_data, 4, 1); 427 report_id, rep_data, 4, 1);
423 } while ((error < 0 || rep_data[1] != 4) && limit++ < WAC_MSG_RETRIES); 428 } while ((error < 0 || rep_data[1] != 4) && limit++ < WAC_MSG_RETRIES);
424 } else if (features->type != TABLETPC && 429 } else if (features->type != TABLETPC &&
430 features->type != WIRELESS &&
425 features->device_type == BTN_TOOL_PEN) { 431 features->device_type == BTN_TOOL_PEN) {
426 do { 432 do {
427 rep_data[0] = 2; 433 rep_data[0] = 2;
@@ -454,6 +460,21 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
454 features->pressure_fuzz = 0; 460 features->pressure_fuzz = 0;
455 features->distance_fuzz = 0; 461 features->distance_fuzz = 0;
456 462
463 /*
464 * The wireless device HID is basic and layout conflicts with
465 * other tablets (monitor and touch interface can look like pen).
466 * Skip the query for this type and modify defaults based on
467 * interface number.
468 */
469 if (features->type == WIRELESS) {
470 if (intf->cur_altsetting->desc.bInterfaceNumber == 0) {
471 features->device_type = 0;
472 } else if (intf->cur_altsetting->desc.bInterfaceNumber == 2) {
473 features->device_type = BTN_TOOL_DOUBLETAP;
474 features->pktlen = WACOM_PKGLEN_BBTOUCH3;
475 }
476 }
477
457 /* only Tablet PCs and Bamboo P&T need to retrieve the info */ 478 /* only Tablet PCs and Bamboo P&T need to retrieve the info */
458 if ((features->type != TABLETPC) && (features->type != TABLETPC2FG) && 479 if ((features->type != TABLETPC) && (features->type != TABLETPC2FG) &&
459 (features->type != BAMBOO_PT)) 480 (features->type != BAMBOO_PT))
@@ -822,6 +843,152 @@ static void wacom_destroy_leds(struct wacom *wacom)
822 } 843 }
823} 844}
824 845
846static enum power_supply_property wacom_battery_props[] = {
847 POWER_SUPPLY_PROP_CAPACITY
848};
849
850static int wacom_battery_get_property(struct power_supply *psy,
851 enum power_supply_property psp,
852 union power_supply_propval *val)
853{
854 struct wacom *wacom = container_of(psy, struct wacom, battery);
855 int ret = 0;
856
857 switch (psp) {
858 case POWER_SUPPLY_PROP_CAPACITY:
859 val->intval =
860 wacom->wacom_wac.battery_capacity * 100 / 31;
861 break;
862 default:
863 ret = -EINVAL;
864 break;
865 }
866
867 return ret;
868}
869
870static int wacom_initialize_battery(struct wacom *wacom)
871{
872 int error = 0;
873
874 if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_MONITOR) {
875 wacom->battery.properties = wacom_battery_props;
876 wacom->battery.num_properties = ARRAY_SIZE(wacom_battery_props);
877 wacom->battery.get_property = wacom_battery_get_property;
878 wacom->battery.name = "wacom_battery";
879 wacom->battery.type = POWER_SUPPLY_TYPE_BATTERY;
880 wacom->battery.use_for_apm = 0;
881
882 error = power_supply_register(&wacom->usbdev->dev,
883 &wacom->battery);
884 }
885
886 return error;
887}
888
889static void wacom_destroy_battery(struct wacom *wacom)
890{
891 if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_MONITOR)
892 power_supply_unregister(&wacom->battery);
893}
894
895static int wacom_register_input(struct wacom *wacom)
896{
897 struct input_dev *input_dev;
898 struct usb_interface *intf = wacom->intf;
899 struct usb_device *dev = interface_to_usbdev(intf);
900 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
901 int error;
902
903 input_dev = input_allocate_device();
904 if (!input_dev)
905 return -ENOMEM;
906
907 input_dev->name = wacom_wac->name;
908 input_dev->dev.parent = &intf->dev;
909 input_dev->open = wacom_open;
910 input_dev->close = wacom_close;
911 usb_to_input_id(dev, &input_dev->id);
912 input_set_drvdata(input_dev, wacom);
913
914 wacom_wac->input = input_dev;
915 wacom_setup_input_capabilities(input_dev, wacom_wac);
916
917 error = input_register_device(input_dev);
918 if (error) {
919 input_free_device(input_dev);
920 wacom_wac->input = NULL;
921 }
922
923 return error;
924}
925
926static void wacom_wireless_work(struct work_struct *work)
927{
928 struct wacom *wacom = container_of(work, struct wacom, work);
929 struct usb_device *usbdev = wacom->usbdev;
930 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
931
932 /*
933 * Regardless if this is a disconnect or a new tablet,
934 * remove any existing input devices.
935 */
936
937 /* Stylus interface */
938 wacom = usb_get_intfdata(usbdev->config->interface[1]);
939 if (wacom->wacom_wac.input)
940 input_unregister_device(wacom->wacom_wac.input);
941 wacom->wacom_wac.input = 0;
942
943 /* Touch interface */
944 wacom = usb_get_intfdata(usbdev->config->interface[2]);
945 if (wacom->wacom_wac.input)
946 input_unregister_device(wacom->wacom_wac.input);
947 wacom->wacom_wac.input = 0;
948
949 if (wacom_wac->pid == 0) {
950 printk(KERN_INFO "wacom: wireless tablet disconnected\n");
951 } else {
952 const struct usb_device_id *id = wacom_ids;
953
954 printk(KERN_INFO
955 "wacom: wireless tablet connected with PID %x\n",
956 wacom_wac->pid);
957
958 while (id->match_flags) {
959 if (id->idVendor == USB_VENDOR_ID_WACOM &&
960 id->idProduct == wacom_wac->pid)
961 break;
962 id++;
963 }
964
965 if (!id->match_flags) {
966 printk(KERN_INFO
967 "wacom: ignorning unknown PID.\n");
968 return;
969 }
970
971 /* Stylus interface */
972 wacom = usb_get_intfdata(usbdev->config->interface[1]);
973 wacom_wac = &wacom->wacom_wac;
974 wacom_wac->features =
975 *((struct wacom_features *)id->driver_info);
976 wacom_wac->features.device_type = BTN_TOOL_PEN;
977 wacom_register_input(wacom);
978
979 /* Touch interface */
980 wacom = usb_get_intfdata(usbdev->config->interface[2]);
981 wacom_wac = &wacom->wacom_wac;
982 wacom_wac->features =
983 *((struct wacom_features *)id->driver_info);
984 wacom_wac->features.pktlen = WACOM_PKGLEN_BBTOUCH3;
985 wacom_wac->features.device_type = BTN_TOOL_FINGER;
986 wacom_set_phy_from_res(&wacom_wac->features);
987 wacom_wac->features.x_max = wacom_wac->features.y_max = 4096;
988 wacom_register_input(wacom);
989 }
990}
991
825static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) 992static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id)
826{ 993{
827 struct usb_device *dev = interface_to_usbdev(intf); 994 struct usb_device *dev = interface_to_usbdev(intf);
@@ -829,18 +996,14 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
829 struct wacom *wacom; 996 struct wacom *wacom;
830 struct wacom_wac *wacom_wac; 997 struct wacom_wac *wacom_wac;
831 struct wacom_features *features; 998 struct wacom_features *features;
832 struct input_dev *input_dev;
833 int error; 999 int error;
834 1000
835 if (!id->driver_info) 1001 if (!id->driver_info)
836 return -EINVAL; 1002 return -EINVAL;
837 1003
838 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); 1004 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
839 input_dev = input_allocate_device(); 1005 if (!wacom)
840 if (!wacom || !input_dev) { 1006 return -ENOMEM;
841 error = -ENOMEM;
842 goto fail1;
843 }
844 1007
845 wacom_wac = &wacom->wacom_wac; 1008 wacom_wac = &wacom->wacom_wac;
846 wacom_wac->features = *((struct wacom_features *)id->driver_info); 1009 wacom_wac->features = *((struct wacom_features *)id->driver_info);
@@ -866,11 +1029,10 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
866 wacom->usbdev = dev; 1029 wacom->usbdev = dev;
867 wacom->intf = intf; 1030 wacom->intf = intf;
868 mutex_init(&wacom->lock); 1031 mutex_init(&wacom->lock);
1032 INIT_WORK(&wacom->work, wacom_wireless_work);
869 usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); 1033 usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
870 strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); 1034 strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
871 1035
872 wacom_wac->input = input_dev;
873
874 endpoint = &intf->cur_altsetting->endpoint[0].desc; 1036 endpoint = &intf->cur_altsetting->endpoint[0].desc;
875 1037
876 /* Retrieve the physical and logical size for OEM devices */ 1038 /* Retrieve the physical and logical size for OEM devices */
@@ -894,15 +1056,6 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
894 goto fail3; 1056 goto fail3;
895 } 1057 }
896 1058
897 input_dev->name = wacom_wac->name;
898 input_dev->dev.parent = &intf->dev;
899 input_dev->open = wacom_open;
900 input_dev->close = wacom_close;
901 usb_to_input_id(dev, &input_dev->id);
902 input_set_drvdata(input_dev, wacom);
903
904 wacom_setup_input_capabilities(input_dev, wacom_wac);
905
906 usb_fill_int_urb(wacom->irq, dev, 1059 usb_fill_int_urb(wacom->irq, dev,
907 usb_rcvintpipe(dev, endpoint->bEndpointAddress), 1060 usb_rcvintpipe(dev, endpoint->bEndpointAddress),
908 wacom_wac->data, features->pktlen, 1061 wacom_wac->data, features->pktlen,
@@ -914,22 +1067,34 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
914 if (error) 1067 if (error)
915 goto fail4; 1068 goto fail4;
916 1069
917 error = input_register_device(input_dev); 1070 error = wacom_initialize_battery(wacom);
918 if (error) 1071 if (error)
919 goto fail5; 1072 goto fail5;
920 1073
1074 if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) {
1075 error = wacom_register_input(wacom);
1076 if (error)
1077 goto fail6;
1078 }
1079
921 /* Note that if query fails it is not a hard failure */ 1080 /* Note that if query fails it is not a hard failure */
922 wacom_query_tablet_data(intf, features); 1081 wacom_query_tablet_data(intf, features);
923 1082
924 usb_set_intfdata(intf, wacom); 1083 usb_set_intfdata(intf, wacom);
1084
1085 if (features->quirks & WACOM_QUIRK_MONITOR) {
1086 if (usb_submit_urb(wacom->irq, GFP_KERNEL))
1087 goto fail5;
1088 }
1089
925 return 0; 1090 return 0;
926 1091
1092 fail6: wacom_destroy_battery(wacom);
927 fail5: wacom_destroy_leds(wacom); 1093 fail5: wacom_destroy_leds(wacom);
928 fail4: wacom_remove_shared_data(wacom_wac); 1094 fail4: wacom_remove_shared_data(wacom_wac);
929 fail3: usb_free_urb(wacom->irq); 1095 fail3: usb_free_urb(wacom->irq);
930 fail2: usb_free_coherent(dev, WACOM_PKGLEN_MAX, wacom_wac->data, wacom->data_dma); 1096 fail2: usb_free_coherent(dev, WACOM_PKGLEN_MAX, wacom_wac->data, wacom->data_dma);
931 fail1: input_free_device(input_dev); 1097 fail1: kfree(wacom);
932 kfree(wacom);
933 return error; 1098 return error;
934} 1099}
935 1100
@@ -940,7 +1105,10 @@ static void wacom_disconnect(struct usb_interface *intf)
940 usb_set_intfdata(intf, NULL); 1105 usb_set_intfdata(intf, NULL);
941 1106
942 usb_kill_urb(wacom->irq); 1107 usb_kill_urb(wacom->irq);
943 input_unregister_device(wacom->wacom_wac.input); 1108 cancel_work_sync(&wacom->work);
1109 if (wacom->wacom_wac.input)
1110 input_unregister_device(wacom->wacom_wac.input);
1111 wacom_destroy_battery(wacom);
944 wacom_destroy_leds(wacom); 1112 wacom_destroy_leds(wacom);
945 usb_free_urb(wacom->irq); 1113 usb_free_urb(wacom->irq);
946 usb_free_coherent(interface_to_usbdev(intf), WACOM_PKGLEN_MAX, 1114 usb_free_coherent(interface_to_usbdev(intf), WACOM_PKGLEN_MAX,
@@ -972,7 +1140,8 @@ static int wacom_resume(struct usb_interface *intf)
972 wacom_query_tablet_data(intf, features); 1140 wacom_query_tablet_data(intf, features);
973 wacom_led_control(wacom); 1141 wacom_led_control(wacom);
974 1142
975 if (wacom->open && usb_submit_urb(wacom->irq, GFP_NOIO) < 0) 1143 if ((wacom->open || features->quirks & WACOM_QUIRK_MONITOR)
1144 && usb_submit_urb(wacom->irq, GFP_NOIO) < 0)
976 rv = -EIO; 1145 rv = -EIO;
977 1146
978 mutex_unlock(&wacom->lock); 1147 mutex_unlock(&wacom->lock);
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 89a96427faa0..cecd35c8f0b3 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -1044,6 +1044,35 @@ static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
1044 return 0; 1044 return 0;
1045} 1045}
1046 1046
1047static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
1048{
1049 unsigned char *data = wacom->data;
1050 int connected;
1051
1052 if (len != WACOM_PKGLEN_WIRELESS || data[0] != 0x80)
1053 return 0;
1054
1055 connected = data[1] & 0x01;
1056 if (connected) {
1057 int pid, battery;
1058
1059 pid = get_unaligned_be16(&data[6]);
1060 battery = data[5] & 0x3f;
1061 if (wacom->pid != pid) {
1062 wacom->pid = pid;
1063 wacom_schedule_work(wacom);
1064 }
1065 wacom->battery_capacity = battery;
1066 } else if (wacom->pid != 0) {
1067 /* disconnected while previously connected */
1068 wacom->pid = 0;
1069 wacom_schedule_work(wacom);
1070 wacom->battery_capacity = 0;
1071 }
1072
1073 return 0;
1074}
1075
1047void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len) 1076void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
1048{ 1077{
1049 bool sync; 1078 bool sync;
@@ -1094,6 +1123,10 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
1094 sync = wacom_bpt_irq(wacom_wac, len); 1123 sync = wacom_bpt_irq(wacom_wac, len);
1095 break; 1124 break;
1096 1125
1126 case WIRELESS:
1127 sync = wacom_wireless_irq(wacom_wac, len);
1128 break;
1129
1097 default: 1130 default:
1098 sync = false; 1131 sync = false;
1099 break; 1132 break;
@@ -1155,7 +1188,7 @@ void wacom_setup_device_quirks(struct wacom_features *features)
1155 1188
1156 /* these device have multiple inputs */ 1189 /* these device have multiple inputs */
1157 if (features->type == TABLETPC || features->type == TABLETPC2FG || 1190 if (features->type == TABLETPC || features->type == TABLETPC2FG ||
1158 features->type == BAMBOO_PT) 1191 features->type == BAMBOO_PT || features->type == WIRELESS)
1159 features->quirks |= WACOM_QUIRK_MULTI_INPUT; 1192 features->quirks |= WACOM_QUIRK_MULTI_INPUT;
1160 1193
1161 /* quirk for bamboo touch with 2 low res touches */ 1194 /* quirk for bamboo touch with 2 low res touches */
@@ -1167,6 +1200,16 @@ void wacom_setup_device_quirks(struct wacom_features *features)
1167 features->y_fuzz <<= 5; 1200 features->y_fuzz <<= 5;
1168 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES; 1201 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
1169 } 1202 }
1203
1204 if (features->type == WIRELESS) {
1205
1206 /* monitor never has input and pen/touch have delayed create */
1207 features->quirks |= WACOM_QUIRK_NO_INPUT;
1208
1209 /* must be monitor interface if no device_type set */
1210 if (!features->device_type)
1211 features->quirks |= WACOM_QUIRK_MONITOR;
1212 }
1170} 1213}
1171 1214
1172static unsigned int wacom_calculate_touch_res(unsigned int logical_max, 1215static unsigned int wacom_calculate_touch_res(unsigned int logical_max,
@@ -1640,6 +1683,9 @@ static const struct wacom_features wacom_features_0xEC =
1640static const struct wacom_features wacom_features_0x47 = 1683static const struct wacom_features wacom_features_0x47 =
1641 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 1684 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
1642 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 1685 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1686static const struct wacom_features wacom_features_0x84 =
1687 { "Wacom Wireless Receiver", WACOM_PKGLEN_WIRELESS, 0, 0, 0,
1688 0, WIRELESS, 0, 0 };
1643static const struct wacom_features wacom_features_0xD0 = 1689static const struct wacom_features wacom_features_0xD0 =
1644 { "Wacom Bamboo 2FG", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 1690 { "Wacom Bamboo 2FG", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
1645 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 1691 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
@@ -1766,6 +1812,7 @@ const struct usb_device_id wacom_ids[] = {
1766 { USB_DEVICE_DETAILED(0xCE, USB_CLASS_HID, 1812 { USB_DEVICE_DETAILED(0xCE, USB_CLASS_HID,
1767 USB_INTERFACE_SUBCLASS_BOOT, 1813 USB_INTERFACE_SUBCLASS_BOOT,
1768 USB_INTERFACE_PROTOCOL_MOUSE) }, 1814 USB_INTERFACE_PROTOCOL_MOUSE) },
1815 { USB_DEVICE_WACOM(0x84) },
1769 { USB_DEVICE_WACOM(0xD0) }, 1816 { USB_DEVICE_WACOM(0xD0) },
1770 { USB_DEVICE_WACOM(0xD1) }, 1817 { USB_DEVICE_WACOM(0xD1) },
1771 { USB_DEVICE_WACOM(0xD2) }, 1818 { USB_DEVICE_WACOM(0xD2) },
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index 4f0ba21b0196..ba5a334e54d6 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -24,6 +24,7 @@
24#define WACOM_PKGLEN_BBTOUCH 20 24#define WACOM_PKGLEN_BBTOUCH 20
25#define WACOM_PKGLEN_BBTOUCH3 64 25#define WACOM_PKGLEN_BBTOUCH3 64
26#define WACOM_PKGLEN_BBPEN 10 26#define WACOM_PKGLEN_BBPEN 10
27#define WACOM_PKGLEN_WIRELESS 32
27 28
28/* device IDs */ 29/* device IDs */
29#define STYLUS_DEVICE_ID 0x02 30#define STYLUS_DEVICE_ID 0x02
@@ -45,6 +46,8 @@
45/* device quirks */ 46/* device quirks */
46#define WACOM_QUIRK_MULTI_INPUT 0x0001 47#define WACOM_QUIRK_MULTI_INPUT 0x0001
47#define WACOM_QUIRK_BBTOUCH_LOWRES 0x0002 48#define WACOM_QUIRK_BBTOUCH_LOWRES 0x0002
49#define WACOM_QUIRK_NO_INPUT 0x0004
50#define WACOM_QUIRK_MONITOR 0x0008
48 51
49enum { 52enum {
50 PENPARTNER = 0, 53 PENPARTNER = 0,
@@ -54,6 +57,7 @@ enum {
54 PL, 57 PL,
55 DTU, 58 DTU,
56 BAMBOO_PT, 59 BAMBOO_PT,
60 WIRELESS,
57 INTUOS, 61 INTUOS,
58 INTUOS3S, 62 INTUOS3S,
59 INTUOS3, 63 INTUOS3,
@@ -107,6 +111,8 @@ struct wacom_wac {
107 struct wacom_features features; 111 struct wacom_features features;
108 struct wacom_shared *shared; 112 struct wacom_shared *shared;
109 struct input_dev *input; 113 struct input_dev *input;
114 int pid;
115 int battery_capacity;
110}; 116};
111 117
112#endif 118#endif
diff --git a/drivers/input/touchscreen/jornada720_ts.c b/drivers/input/touchscreen/jornada720_ts.c
index c3848ad2325b..d9be6eac99b1 100644
--- a/drivers/input/touchscreen/jornada720_ts.c
+++ b/drivers/input/touchscreen/jornada720_ts.c
@@ -22,6 +22,7 @@
22 22
23#include <mach/hardware.h> 23#include <mach/hardware.h>
24#include <mach/jornada720.h> 24#include <mach/jornada720.h>
25#include <mach/irqs.h>
25 26
26MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>"); 27MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>");
27MODULE_DESCRIPTION("HP Jornada 710/720/728 touchscreen driver"); 28MODULE_DESCRIPTION("HP Jornada 710/720/728 touchscreen driver");
diff --git a/drivers/input/touchscreen/mc13783_ts.c b/drivers/input/touchscreen/mc13783_ts.c
index ede02743eac1..48dc5b0d26f1 100644
--- a/drivers/input/touchscreen/mc13783_ts.c
+++ b/drivers/input/touchscreen/mc13783_ts.c
@@ -39,6 +39,7 @@ struct mc13783_ts_priv {
39 struct delayed_work work; 39 struct delayed_work work;
40 struct workqueue_struct *workq; 40 struct workqueue_struct *workq;
41 unsigned int sample[4]; 41 unsigned int sample[4];
42 struct mc13xxx_ts_platform_data *touch;
42}; 43};
43 44
44static irqreturn_t mc13783_ts_handler(int irq, void *data) 45static irqreturn_t mc13783_ts_handler(int irq, void *data)
@@ -125,7 +126,9 @@ static void mc13783_ts_work(struct work_struct *work)
125 unsigned int channel = 12; 126 unsigned int channel = 12;
126 127
127 if (mc13xxx_adc_do_conversion(priv->mc13xxx, 128 if (mc13xxx_adc_do_conversion(priv->mc13xxx,
128 mode, channel, priv->sample) == 0) 129 mode, channel,
130 priv->touch->ato, priv->touch->atox,
131 priv->sample) == 0)
129 mc13783_ts_report_sample(priv); 132 mc13783_ts_report_sample(priv);
130} 133}
131 134
@@ -179,6 +182,12 @@ static int __init mc13783_ts_probe(struct platform_device *pdev)
179 INIT_DELAYED_WORK(&priv->work, mc13783_ts_work); 182 INIT_DELAYED_WORK(&priv->work, mc13783_ts_work);
180 priv->mc13xxx = dev_get_drvdata(pdev->dev.parent); 183 priv->mc13xxx = dev_get_drvdata(pdev->dev.parent);
181 priv->idev = idev; 184 priv->idev = idev;
185 priv->touch = dev_get_platdata(&pdev->dev);
186 if (!priv->touch) {
187 dev_err(&pdev->dev, "missing platform data\n");
188 ret = -ENODEV;
189 goto err_free_mem;
190 }
182 191
183 /* 192 /*
184 * We need separate workqueue because mc13783_adc_do_conversion 193 * We need separate workqueue because mc13783_adc_do_conversion