diff options
132 files changed, 1843 insertions, 2196 deletions
diff --git a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt new file mode 100644 index 000000000000..635f62c756ee --- /dev/null +++ b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt | |||
@@ -0,0 +1,27 @@ | |||
1 | Samsung tm2-touchkey | ||
2 | |||
3 | Required properties: | ||
4 | - compatible: must be "cypress,tm2-touchkey" | ||
5 | - reg: I2C address of the chip. | ||
6 | - interrupt-parent: a phandle for the interrupt controller (see interrupt | ||
7 | binding[0]). | ||
8 | - interrupts: interrupt to which the chip is connected (see interrupt | ||
9 | binding[0]). | ||
10 | - vcc-supply : internal regulator output. 1.8V | ||
11 | - vdd-supply : power supply for IC 3.3V | ||
12 | |||
13 | [0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt | ||
14 | |||
15 | Example: | ||
16 | &i2c0 { | ||
17 | /* ... */ | ||
18 | |||
19 | touchkey@20 { | ||
20 | compatible = "cypress,tm2-touchkey"; | ||
21 | reg = <0x20>; | ||
22 | interrupt-parent = <&gpa3>; | ||
23 | interrupts = <2 IRQ_TYPE_EDGE_FALLING>; | ||
24 | vcc-supply=<&ldo32_reg>; | ||
25 | vdd-supply=<&ldo33_reg>; | ||
26 | }; | ||
27 | }; | ||
diff --git a/Documentation/devicetree/bindings/input/mpr121-touchkey.txt b/Documentation/devicetree/bindings/input/mpr121-touchkey.txt new file mode 100644 index 000000000000..b7c61ee5841b --- /dev/null +++ b/Documentation/devicetree/bindings/input/mpr121-touchkey.txt | |||
@@ -0,0 +1,30 @@ | |||
1 | * Freescale MPR121 Controllor | ||
2 | |||
3 | Required Properties: | ||
4 | - compatible: Should be "fsl,mpr121-touchkey" | ||
5 | - reg: The I2C slave address of the device. | ||
6 | - interrupts: The interrupt number to the cpu. | ||
7 | - vdd-supply: Phandle to the Vdd power supply. | ||
8 | - linux,keycodes: Specifies an array of numeric keycode values to | ||
9 | be used for reporting button presses. The array can | ||
10 | contain up to 12 entries. | ||
11 | |||
12 | Optional Properties: | ||
13 | - wakeup-source: Use any event on keypad as wakeup event. | ||
14 | - autorepeat: Enable autorepeat feature. | ||
15 | |||
16 | Example: | ||
17 | |||
18 | #include "dt-bindings/input/input.h" | ||
19 | |||
20 | touchkey: mpr121@5a { | ||
21 | compatible = "fsl,mpr121-touchkey"; | ||
22 | reg = <0x5a>; | ||
23 | interrupt-parent = <&gpio1>; | ||
24 | interrupts = <28 2>; | ||
25 | autorepeat; | ||
26 | vdd-supply = <&ldo4_reg>; | ||
27 | linux,keycodes = <KEY_0>, <KEY_1>, <KEY_2>, <KEY_3>, | ||
28 | <KEY_4> <KEY_5>, <KEY_6>, <KEY_7>, | ||
29 | <KEY_8>, <KEY_9>, <KEY_A>, <KEY_B>; | ||
30 | }; | ||
diff --git a/Documentation/devicetree/bindings/input/pwm-beeper.txt b/Documentation/devicetree/bindings/input/pwm-beeper.txt index be332ae4f2d6..529408b4431a 100644 --- a/Documentation/devicetree/bindings/input/pwm-beeper.txt +++ b/Documentation/devicetree/bindings/input/pwm-beeper.txt | |||
@@ -5,3 +5,19 @@ Registers a PWM device as beeper. | |||
5 | Required properties: | 5 | Required properties: |
6 | - compatible: should be "pwm-beeper" | 6 | - compatible: should be "pwm-beeper" |
7 | - pwms: phandle to the physical PWM device | 7 | - pwms: phandle to the physical PWM device |
8 | |||
9 | Optional properties: | ||
10 | - amp-supply: phandle to a regulator that acts as an amplifier for the beeper | ||
11 | |||
12 | Example: | ||
13 | |||
14 | beeper_amp: amplifier { | ||
15 | compatible = "fixed-regulator"; | ||
16 | gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>; | ||
17 | }; | ||
18 | |||
19 | beeper { | ||
20 | compatible = "pwm-beeper"; | ||
21 | pwms = <&pwm0>; | ||
22 | amp-supply = <&beeper_amp>; | ||
23 | }; | ||
diff --git a/Documentation/devicetree/bindings/input/touchscreen/zet6223.txt b/Documentation/devicetree/bindings/input/touchscreen/zet6223.txt new file mode 100644 index 000000000000..fe6a1feef703 --- /dev/null +++ b/Documentation/devicetree/bindings/input/touchscreen/zet6223.txt | |||
@@ -0,0 +1,32 @@ | |||
1 | Zeitec ZET6223 I2C touchscreen controller | ||
2 | |||
3 | Required properties: | ||
4 | - compatible : "zeitec,zet6223" | ||
5 | - reg : I2C slave address of the chip (0x76) | ||
6 | - interrupt-parent : a phandle pointing to the interrupt controller | ||
7 | serving the interrupt for this chip | ||
8 | - interrupts : interrupt specification for the zet6223 interrupt | ||
9 | |||
10 | Optional properties: | ||
11 | |||
12 | - vio-supply : Specification for VIO supply (1.8V or 3.3V, | ||
13 | depending on system interface needs). | ||
14 | - vcc-supply : Specification for 3.3V VCC supply. | ||
15 | - touchscreen-size-x : See touchscreen.txt | ||
16 | - touchscreen-size-y : See touchscreen.txt | ||
17 | - touchscreen-inverted-x : See touchscreen.txt | ||
18 | - touchscreen-inverted-y : See touchscreen.txt | ||
19 | - touchscreen-swapped-x-y : See touchscreen.txt | ||
20 | |||
21 | Example: | ||
22 | |||
23 | i2c@00000000 { | ||
24 | |||
25 | zet6223: touchscreen@76 { | ||
26 | compatible = "zeitec,zet6223"; | ||
27 | reg = <0x76>; | ||
28 | interrupt-parent = <&pio>; | ||
29 | interrupts = <6 11 IRQ_TYPE_EDGE_FALLING> | ||
30 | }; | ||
31 | |||
32 | }; | ||
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index 1d0bb2c9def4..ebd46f2eef24 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt | |||
@@ -334,6 +334,7 @@ xes Extreme Engineering Solutions (X-ES) | |||
334 | xillybus Xillybus Ltd. | 334 | xillybus Xillybus Ltd. |
335 | xlnx Xilinx | 335 | xlnx Xilinx |
336 | zarlink Zarlink Semiconductor | 336 | zarlink Zarlink Semiconductor |
337 | zeitec ZEITEC Semiconductor Co., LTD. | ||
337 | zii Zodiac Inflight Innovations | 338 | zii Zodiac Inflight Innovations |
338 | zte ZTE Corp. | 339 | zte ZTE Corp. |
339 | zyxel ZyXEL Communications Corp. | 340 | zyxel ZyXEL Communications Corp. |
diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig index 6261874c07c9..ff8037798779 100644 --- a/drivers/input/Kconfig +++ b/drivers/input/Kconfig | |||
@@ -94,7 +94,6 @@ comment "Userland interfaces" | |||
94 | 94 | ||
95 | config INPUT_MOUSEDEV | 95 | config INPUT_MOUSEDEV |
96 | tristate "Mouse interface" | 96 | tristate "Mouse interface" |
97 | default y | ||
98 | help | 97 | help |
99 | Say Y here if you want your mouse to be accessible as char devices | 98 | Say Y here if you want your mouse to be accessible as char devices |
100 | 13:32+ - /dev/input/mouseX and 13:63 - /dev/input/mice as an | 99 | 13:32+ - /dev/input/mouseX and 13:63 - /dev/input/mice as an |
@@ -109,7 +108,6 @@ config INPUT_MOUSEDEV | |||
109 | 108 | ||
110 | config INPUT_MOUSEDEV_PSAUX | 109 | config INPUT_MOUSEDEV_PSAUX |
111 | bool "Provide legacy /dev/psaux device" | 110 | bool "Provide legacy /dev/psaux device" |
112 | default y | ||
113 | depends on INPUT_MOUSEDEV | 111 | depends on INPUT_MOUSEDEV |
114 | help | 112 | help |
115 | Say Y here if you want your mouse also be accessible as char device | 113 | Say Y here if you want your mouse also be accessible as char device |
@@ -118,7 +116,6 @@ config INPUT_MOUSEDEV_PSAUX | |||
118 | 116 | ||
119 | If unsure, say Y. | 117 | If unsure, say Y. |
120 | 118 | ||
121 | |||
122 | config INPUT_MOUSEDEV_SCREEN_X | 119 | config INPUT_MOUSEDEV_SCREEN_X |
123 | int "Horizontal screen resolution" | 120 | int "Horizontal screen resolution" |
124 | depends on INPUT_MOUSEDEV | 121 | depends on INPUT_MOUSEDEV |
diff --git a/drivers/input/input.c b/drivers/input/input.c index d95c34ee5dc1..067d648028a2 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -1749,7 +1749,7 @@ static const struct dev_pm_ops input_dev_pm_ops = { | |||
1749 | }; | 1749 | }; |
1750 | #endif /* CONFIG_PM */ | 1750 | #endif /* CONFIG_PM */ |
1751 | 1751 | ||
1752 | static struct device_type input_dev_type = { | 1752 | static const struct device_type input_dev_type = { |
1753 | .groups = input_dev_attr_groups, | 1753 | .groups = input_dev_attr_groups, |
1754 | .release = input_dev_release, | 1754 | .release = input_dev_release, |
1755 | .uevent = input_dev_uevent, | 1755 | .uevent = input_dev_uevent, |
@@ -2091,6 +2091,12 @@ int input_register_device(struct input_dev *dev) | |||
2091 | const char *path; | 2091 | const char *path; |
2092 | int error; | 2092 | int error; |
2093 | 2093 | ||
2094 | if (test_bit(EV_ABS, dev->evbit) && !dev->absinfo) { | ||
2095 | dev_err(&dev->dev, | ||
2096 | "Absolute device without dev->absinfo, refusing to register\n"); | ||
2097 | return -EINVAL; | ||
2098 | } | ||
2099 | |||
2094 | if (dev->devres_managed) { | 2100 | if (dev->devres_managed) { |
2095 | devres = devres_alloc(devm_input_device_unregister, | 2101 | devres = devres_alloc(devm_input_device_unregister, |
2096 | sizeof(struct input_devres), GFP_KERNEL); | 2102 | sizeof(struct input_devres), GFP_KERNEL); |
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c index abd18f31b24f..065e67bf56dd 100644 --- a/drivers/input/joydev.c +++ b/drivers/input/joydev.c | |||
@@ -87,7 +87,7 @@ static int joydev_correct(int value, struct js_corr *corr) | |||
87 | return 0; | 87 | return 0; |
88 | } | 88 | } |
89 | 89 | ||
90 | return value < -32767 ? -32767 : (value > 32767 ? 32767 : value); | 90 | return clamp(value, -32767, 32767); |
91 | } | 91 | } |
92 | 92 | ||
93 | static void joydev_pass_event(struct joydev_client *client, | 93 | static void joydev_pass_event(struct joydev_client *client, |
@@ -187,6 +187,17 @@ static void joydev_detach_client(struct joydev *joydev, | |||
187 | synchronize_rcu(); | 187 | synchronize_rcu(); |
188 | } | 188 | } |
189 | 189 | ||
190 | static void joydev_refresh_state(struct joydev *joydev) | ||
191 | { | ||
192 | struct input_dev *dev = joydev->handle.dev; | ||
193 | int i, val; | ||
194 | |||
195 | for (i = 0; i < joydev->nabs; i++) { | ||
196 | val = input_abs_get_val(dev, joydev->abspam[i]); | ||
197 | joydev->abs[i] = joydev_correct(val, &joydev->corr[i]); | ||
198 | } | ||
199 | } | ||
200 | |||
190 | static int joydev_open_device(struct joydev *joydev) | 201 | static int joydev_open_device(struct joydev *joydev) |
191 | { | 202 | { |
192 | int retval; | 203 | int retval; |
@@ -201,6 +212,8 @@ static int joydev_open_device(struct joydev *joydev) | |||
201 | retval = input_open_device(&joydev->handle); | 212 | retval = input_open_device(&joydev->handle); |
202 | if (retval) | 213 | if (retval) |
203 | joydev->open--; | 214 | joydev->open--; |
215 | else | ||
216 | joydev_refresh_state(joydev); | ||
204 | } | 217 | } |
205 | 218 | ||
206 | mutex_unlock(&joydev->mutex); | 219 | mutex_unlock(&joydev->mutex); |
@@ -872,7 +885,6 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev, | |||
872 | j = joydev->abspam[i]; | 885 | j = joydev->abspam[i]; |
873 | if (input_abs_get_max(dev, j) == input_abs_get_min(dev, j)) { | 886 | if (input_abs_get_max(dev, j) == input_abs_get_min(dev, j)) { |
874 | joydev->corr[i].type = JS_CORR_NONE; | 887 | joydev->corr[i].type = JS_CORR_NONE; |
875 | joydev->abs[i] = input_abs_get_val(dev, j); | ||
876 | continue; | 888 | continue; |
877 | } | 889 | } |
878 | joydev->corr[i].type = JS_CORR_BROKEN; | 890 | joydev->corr[i].type = JS_CORR_BROKEN; |
@@ -887,10 +899,6 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev, | |||
887 | if (t) { | 899 | if (t) { |
888 | joydev->corr[i].coef[2] = (1 << 29) / t; | 900 | joydev->corr[i].coef[2] = (1 << 29) / t; |
889 | joydev->corr[i].coef[3] = (1 << 29) / t; | 901 | joydev->corr[i].coef[3] = (1 << 29) / t; |
890 | |||
891 | joydev->abs[i] = | ||
892 | joydev_correct(input_abs_get_val(dev, j), | ||
893 | joydev->corr + i); | ||
894 | } | 902 | } |
895 | } | 903 | } |
896 | 904 | ||
diff --git a/drivers/input/joystick/maplecontrol.c b/drivers/input/joystick/maplecontrol.c index 8aa6e4c497da..ff54e195d42c 100644 --- a/drivers/input/joystick/maplecontrol.c +++ b/drivers/input/joystick/maplecontrol.c | |||
@@ -139,7 +139,6 @@ static int probe_maple_controller(struct device *dev) | |||
139 | idev->dev.parent = &mdev->dev; | 139 | idev->dev.parent = &mdev->dev; |
140 | idev->name = mdev->product_name; | 140 | idev->name = mdev->product_name; |
141 | idev->id.bustype = BUS_HOST; | 141 | idev->id.bustype = BUS_HOST; |
142 | input_set_drvdata(idev, pad); | ||
143 | 142 | ||
144 | error = input_register_device(idev); | 143 | error = input_register_device(idev); |
145 | if (error) | 144 | if (error) |
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index c7d5b2b643d1..155fcb3b6230 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c | |||
@@ -320,18 +320,18 @@ static struct usb_device_id xpad_table[] = { | |||
320 | XPAD_XBOXONE_VENDOR(0x0738), /* Mad Catz FightStick TE 2 */ | 320 | XPAD_XBOXONE_VENDOR(0x0738), /* Mad Catz FightStick TE 2 */ |
321 | XPAD_XBOX360_VENDOR(0x0e6f), /* 0x0e6f X-Box 360 controllers */ | 321 | XPAD_XBOX360_VENDOR(0x0e6f), /* 0x0e6f X-Box 360 controllers */ |
322 | XPAD_XBOXONE_VENDOR(0x0e6f), /* 0x0e6f X-Box One controllers */ | 322 | XPAD_XBOXONE_VENDOR(0x0e6f), /* 0x0e6f X-Box One controllers */ |
323 | XPAD_XBOX360_VENDOR(0x0f0d), /* Hori Controllers */ | ||
324 | XPAD_XBOXONE_VENDOR(0x0f0d), /* Hori Controllers */ | ||
323 | XPAD_XBOX360_VENDOR(0x12ab), /* X-Box 360 dance pads */ | 325 | XPAD_XBOX360_VENDOR(0x12ab), /* X-Box 360 dance pads */ |
324 | XPAD_XBOX360_VENDOR(0x1430), /* RedOctane X-Box 360 controllers */ | 326 | XPAD_XBOX360_VENDOR(0x1430), /* RedOctane X-Box 360 controllers */ |
325 | XPAD_XBOX360_VENDOR(0x146b), /* BigBen Interactive Controllers */ | 327 | XPAD_XBOX360_VENDOR(0x146b), /* BigBen Interactive Controllers */ |
326 | XPAD_XBOX360_VENDOR(0x1bad), /* Harminix Rock Band Guitar and Drums */ | ||
327 | XPAD_XBOX360_VENDOR(0x0f0d), /* Hori Controllers */ | ||
328 | XPAD_XBOXONE_VENDOR(0x0f0d), /* Hori Controllers */ | ||
329 | XPAD_XBOX360_VENDOR(0x1689), /* Razer Onza */ | ||
330 | XPAD_XBOX360_VENDOR(0x24c6), /* PowerA Controllers */ | ||
331 | XPAD_XBOXONE_VENDOR(0x24c6), /* PowerA Controllers */ | ||
332 | XPAD_XBOX360_VENDOR(0x1532), /* Razer Sabertooth */ | 328 | XPAD_XBOX360_VENDOR(0x1532), /* Razer Sabertooth */ |
333 | XPAD_XBOX360_VENDOR(0x15e4), /* Numark X-Box 360 controllers */ | 329 | XPAD_XBOX360_VENDOR(0x15e4), /* Numark X-Box 360 controllers */ |
334 | XPAD_XBOX360_VENDOR(0x162e), /* Joytech X-Box 360 controllers */ | 330 | XPAD_XBOX360_VENDOR(0x162e), /* Joytech X-Box 360 controllers */ |
331 | XPAD_XBOX360_VENDOR(0x1689), /* Razer Onza */ | ||
332 | XPAD_XBOX360_VENDOR(0x1bad), /* Harminix Rock Band Guitar and Drums */ | ||
333 | XPAD_XBOX360_VENDOR(0x24c6), /* PowerA Controllers */ | ||
334 | XPAD_XBOXONE_VENDOR(0x24c6), /* PowerA Controllers */ | ||
335 | { } | 335 | { } |
336 | }; | 336 | }; |
337 | 337 | ||
@@ -389,6 +389,7 @@ struct usb_xpad { | |||
389 | 389 | ||
390 | static int xpad_init_input(struct usb_xpad *xpad); | 390 | static int xpad_init_input(struct usb_xpad *xpad); |
391 | static void xpad_deinit_input(struct usb_xpad *xpad); | 391 | static void xpad_deinit_input(struct usb_xpad *xpad); |
392 | static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num); | ||
392 | 393 | ||
393 | /* | 394 | /* |
394 | * xpad_process_packet | 395 | * xpad_process_packet |
@@ -608,14 +609,36 @@ static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned cha | |||
608 | } | 609 | } |
609 | 610 | ||
610 | /* | 611 | /* |
611 | * xpadone_process_buttons | 612 | * xpadone_process_packet |
613 | * | ||
614 | * Completes a request by converting the data into events for the | ||
615 | * input subsystem. This version is for the Xbox One controller. | ||
612 | * | 616 | * |
613 | * Process a button update packet from an Xbox one controller. | 617 | * The report format was gleaned from |
618 | * https://github.com/kylelemons/xbox/blob/master/xbox.go | ||
614 | */ | 619 | */ |
615 | static void xpadone_process_buttons(struct usb_xpad *xpad, | 620 | static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) |
616 | struct input_dev *dev, | ||
617 | unsigned char *data) | ||
618 | { | 621 | { |
622 | struct input_dev *dev = xpad->dev; | ||
623 | |||
624 | /* the xbox button has its own special report */ | ||
625 | if (data[0] == 0X07) { | ||
626 | /* | ||
627 | * The Xbox One S controller requires these reports to be | ||
628 | * acked otherwise it continues sending them forever and | ||
629 | * won't report further mode button events. | ||
630 | */ | ||
631 | if (data[1] == 0x30) | ||
632 | xpadone_ack_mode_report(xpad, data[2]); | ||
633 | |||
634 | input_report_key(dev, BTN_MODE, data[4] & 0x01); | ||
635 | input_sync(dev); | ||
636 | return; | ||
637 | } | ||
638 | /* check invalid packet */ | ||
639 | else if (data[0] != 0X20) | ||
640 | return; | ||
641 | |||
619 | /* menu/view buttons */ | 642 | /* menu/view buttons */ |
620 | input_report_key(dev, BTN_START, data[4] & 0x04); | 643 | input_report_key(dev, BTN_START, data[4] & 0x04); |
621 | input_report_key(dev, BTN_SELECT, data[4] & 0x08); | 644 | input_report_key(dev, BTN_SELECT, data[4] & 0x08); |
@@ -678,34 +701,6 @@ static void xpadone_process_buttons(struct usb_xpad *xpad, | |||
678 | input_sync(dev); | 701 | input_sync(dev); |
679 | } | 702 | } |
680 | 703 | ||
681 | /* | ||
682 | * xpadone_process_packet | ||
683 | * | ||
684 | * Completes a request by converting the data into events for the | ||
685 | * input subsystem. This version is for the Xbox One controller. | ||
686 | * | ||
687 | * The report format was gleaned from | ||
688 | * https://github.com/kylelemons/xbox/blob/master/xbox.go | ||
689 | */ | ||
690 | |||
691 | static void xpadone_process_packet(struct usb_xpad *xpad, | ||
692 | u16 cmd, unsigned char *data) | ||
693 | { | ||
694 | struct input_dev *dev = xpad->dev; | ||
695 | |||
696 | switch (data[0]) { | ||
697 | case 0x20: | ||
698 | xpadone_process_buttons(xpad, dev, data); | ||
699 | break; | ||
700 | |||
701 | case 0x07: | ||
702 | /* the xbox button has its own special report */ | ||
703 | input_report_key(dev, BTN_MODE, data[4] & 0x01); | ||
704 | input_sync(dev); | ||
705 | break; | ||
706 | } | ||
707 | } | ||
708 | |||
709 | static void xpad_irq_in(struct urb *urb) | 704 | static void xpad_irq_in(struct urb *urb) |
710 | { | 705 | { |
711 | struct usb_xpad *xpad = urb->context; | 706 | struct usb_xpad *xpad = urb->context; |
@@ -850,10 +845,9 @@ static void xpad_irq_out(struct urb *urb) | |||
850 | spin_unlock_irqrestore(&xpad->odata_lock, flags); | 845 | spin_unlock_irqrestore(&xpad->odata_lock, flags); |
851 | } | 846 | } |
852 | 847 | ||
853 | static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad) | 848 | static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad, |
849 | struct usb_endpoint_descriptor *ep_irq_out) | ||
854 | { | 850 | { |
855 | struct usb_endpoint_descriptor *ep_irq_out; | ||
856 | int ep_irq_out_idx; | ||
857 | int error; | 851 | int error; |
858 | 852 | ||
859 | if (xpad->xtype == XTYPE_UNKNOWN) | 853 | if (xpad->xtype == XTYPE_UNKNOWN) |
@@ -863,23 +857,17 @@ static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad) | |||
863 | 857 | ||
864 | xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN, | 858 | xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN, |
865 | GFP_KERNEL, &xpad->odata_dma); | 859 | GFP_KERNEL, &xpad->odata_dma); |
866 | if (!xpad->odata) { | 860 | if (!xpad->odata) |
867 | error = -ENOMEM; | 861 | return -ENOMEM; |
868 | goto fail1; | ||
869 | } | ||
870 | 862 | ||
871 | spin_lock_init(&xpad->odata_lock); | 863 | spin_lock_init(&xpad->odata_lock); |
872 | 864 | ||
873 | xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL); | 865 | xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL); |
874 | if (!xpad->irq_out) { | 866 | if (!xpad->irq_out) { |
875 | error = -ENOMEM; | 867 | error = -ENOMEM; |
876 | goto fail2; | 868 | goto err_free_coherent; |
877 | } | 869 | } |
878 | 870 | ||
879 | /* Xbox One controller has in/out endpoints swapped. */ | ||
880 | ep_irq_out_idx = xpad->xtype == XTYPE_XBOXONE ? 0 : 1; | ||
881 | ep_irq_out = &intf->cur_altsetting->endpoint[ep_irq_out_idx].desc; | ||
882 | |||
883 | usb_fill_int_urb(xpad->irq_out, xpad->udev, | 871 | usb_fill_int_urb(xpad->irq_out, xpad->udev, |
884 | usb_sndintpipe(xpad->udev, ep_irq_out->bEndpointAddress), | 872 | usb_sndintpipe(xpad->udev, ep_irq_out->bEndpointAddress), |
885 | xpad->odata, XPAD_PKT_LEN, | 873 | xpad->odata, XPAD_PKT_LEN, |
@@ -889,8 +877,9 @@ static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad) | |||
889 | 877 | ||
890 | return 0; | 878 | return 0; |
891 | 879 | ||
892 | fail2: usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma); | 880 | err_free_coherent: |
893 | fail1: return error; | 881 | usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma); |
882 | return error; | ||
894 | } | 883 | } |
895 | 884 | ||
896 | static void xpad_stop_output(struct usb_xpad *xpad) | 885 | static void xpad_stop_output(struct usb_xpad *xpad) |
@@ -974,6 +963,30 @@ static int xpad_start_xbox_one(struct usb_xpad *xpad) | |||
974 | return retval; | 963 | return retval; |
975 | } | 964 | } |
976 | 965 | ||
966 | static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num) | ||
967 | { | ||
968 | unsigned long flags; | ||
969 | struct xpad_output_packet *packet = | ||
970 | &xpad->out_packets[XPAD_OUT_CMD_IDX]; | ||
971 | static const u8 mode_report_ack[] = { | ||
972 | 0x01, 0x20, 0x00, 0x09, 0x00, 0x07, 0x20, 0x02, | ||
973 | 0x00, 0x00, 0x00, 0x00, 0x00 | ||
974 | }; | ||
975 | |||
976 | spin_lock_irqsave(&xpad->odata_lock, flags); | ||
977 | |||
978 | packet->len = sizeof(mode_report_ack); | ||
979 | memcpy(packet->data, mode_report_ack, packet->len); | ||
980 | packet->data[2] = seq_num; | ||
981 | packet->pending = true; | ||
982 | |||
983 | /* Reset the sequence so we send out the ack now */ | ||
984 | xpad->last_out_packet = -1; | ||
985 | xpad_try_sending_next_out_packet(xpad); | ||
986 | |||
987 | spin_unlock_irqrestore(&xpad->odata_lock, flags); | ||
988 | } | ||
989 | |||
977 | #ifdef CONFIG_JOYSTICK_XPAD_FF | 990 | #ifdef CONFIG_JOYSTICK_XPAD_FF |
978 | static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect) | 991 | static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect) |
979 | { | 992 | { |
@@ -1198,6 +1211,7 @@ static int xpad_led_probe(struct usb_xpad *xpad) | |||
1198 | led_cdev = &led->led_cdev; | 1211 | led_cdev = &led->led_cdev; |
1199 | led_cdev->name = led->name; | 1212 | led_cdev->name = led->name; |
1200 | led_cdev->brightness_set = xpad_led_set; | 1213 | led_cdev->brightness_set = xpad_led_set; |
1214 | led_cdev->flags = LED_CORE_SUSPENDRESUME; | ||
1201 | 1215 | ||
1202 | error = led_classdev_register(&xpad->udev->dev, led_cdev); | 1216 | error = led_classdev_register(&xpad->udev->dev, led_cdev); |
1203 | if (error) | 1217 | if (error) |
@@ -1468,8 +1482,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
1468 | { | 1482 | { |
1469 | struct usb_device *udev = interface_to_usbdev(intf); | 1483 | struct usb_device *udev = interface_to_usbdev(intf); |
1470 | struct usb_xpad *xpad; | 1484 | struct usb_xpad *xpad; |
1471 | struct usb_endpoint_descriptor *ep_irq_in; | 1485 | struct usb_endpoint_descriptor *ep_irq_in, *ep_irq_out; |
1472 | int ep_irq_in_idx; | ||
1473 | int i, error; | 1486 | int i, error; |
1474 | 1487 | ||
1475 | if (intf->cur_altsetting->desc.bNumEndpoints != 2) | 1488 | if (intf->cur_altsetting->desc.bNumEndpoints != 2) |
@@ -1539,13 +1552,26 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
1539 | goto err_free_in_urb; | 1552 | goto err_free_in_urb; |
1540 | } | 1553 | } |
1541 | 1554 | ||
1542 | error = xpad_init_output(intf, xpad); | 1555 | ep_irq_in = ep_irq_out = NULL; |
1543 | if (error) | 1556 | |
1557 | for (i = 0; i < 2; i++) { | ||
1558 | struct usb_endpoint_descriptor *ep = | ||
1559 | &intf->cur_altsetting->endpoint[i].desc; | ||
1560 | |||
1561 | if (usb_endpoint_dir_in(ep)) | ||
1562 | ep_irq_in = ep; | ||
1563 | else | ||
1564 | ep_irq_out = ep; | ||
1565 | } | ||
1566 | |||
1567 | if (!ep_irq_in || !ep_irq_out) { | ||
1568 | error = -ENODEV; | ||
1544 | goto err_free_in_urb; | 1569 | goto err_free_in_urb; |
1570 | } | ||
1545 | 1571 | ||
1546 | /* Xbox One controller has in/out endpoints swapped. */ | 1572 | error = xpad_init_output(intf, xpad, ep_irq_out); |
1547 | ep_irq_in_idx = xpad->xtype == XTYPE_XBOXONE ? 1 : 0; | 1573 | if (error) |
1548 | ep_irq_in = &intf->cur_altsetting->endpoint[ep_irq_in_idx].desc; | 1574 | goto err_free_in_urb; |
1549 | 1575 | ||
1550 | usb_fill_int_urb(xpad->irq_in, udev, | 1576 | usb_fill_int_urb(xpad->irq_in, udev, |
1551 | usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), | 1577 | usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), |
@@ -1662,8 +1688,16 @@ static int xpad_resume(struct usb_interface *intf) | |||
1662 | retval = xpad360w_start_input(xpad); | 1688 | retval = xpad360w_start_input(xpad); |
1663 | } else { | 1689 | } else { |
1664 | mutex_lock(&input->mutex); | 1690 | mutex_lock(&input->mutex); |
1665 | if (input->users) | 1691 | if (input->users) { |
1666 | retval = xpad_start_input(xpad); | 1692 | retval = xpad_start_input(xpad); |
1693 | } else if (xpad->xtype == XTYPE_XBOXONE) { | ||
1694 | /* | ||
1695 | * Even if there are no users, we'll send Xbox One pads | ||
1696 | * the startup sequence so they don't sit there and | ||
1697 | * blink until somebody opens the input device again. | ||
1698 | */ | ||
1699 | retval = xpad_start_xbox_one(xpad); | ||
1700 | } | ||
1667 | mutex_unlock(&input->mutex); | 1701 | mutex_unlock(&input->mutex); |
1668 | } | 1702 | } |
1669 | 1703 | ||
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index cbd75cf44739..97acd6524ad7 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig | |||
@@ -666,6 +666,17 @@ config KEYBOARD_TC3589X | |||
666 | To compile this driver as a module, choose M here: the | 666 | To compile this driver as a module, choose M here: the |
667 | module will be called tc3589x-keypad. | 667 | module will be called tc3589x-keypad. |
668 | 668 | ||
669 | config KEYBOARD_TM2_TOUCHKEY | ||
670 | tristate "TM2 touchkey support" | ||
671 | depends on I2C | ||
672 | depends on LEDS_CLASS | ||
673 | help | ||
674 | Say Y here to enable device driver for tm2-touchkey with | ||
675 | LED control for the Exynos5433 TM2 board. | ||
676 | |||
677 | To compile this driver as a module, choose M here. | ||
678 | module will be called tm2-touchkey. | ||
679 | |||
669 | config KEYBOARD_TWL4030 | 680 | config KEYBOARD_TWL4030 |
670 | tristate "TI TWL4030/TWL5030/TPS659x0 keypad support" | 681 | tristate "TI TWL4030/TWL5030/TPS659x0 keypad support" |
671 | depends on TWL4030_CORE | 682 | depends on TWL4030_CORE |
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index d9f4cfcf3410..7d9acff819a7 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile | |||
@@ -61,6 +61,7 @@ obj-$(CONFIG_KEYBOARD_SUN4I_LRADC) += sun4i-lradc-keys.o | |||
61 | obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o | 61 | obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o |
62 | obj-$(CONFIG_KEYBOARD_TC3589X) += tc3589x-keypad.o | 62 | obj-$(CONFIG_KEYBOARD_TC3589X) += tc3589x-keypad.o |
63 | obj-$(CONFIG_KEYBOARD_TEGRA) += tegra-kbc.o | 63 | obj-$(CONFIG_KEYBOARD_TEGRA) += tegra-kbc.o |
64 | obj-$(CONFIG_KEYBOARD_TM2_TOUCHKEY) += tm2-touchkey.o | ||
64 | obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o | 65 | obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o |
65 | obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o | 66 | obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o |
66 | obj-$(CONFIG_KEYBOARD_W90P910) += w90p910_keypad.o | 67 | obj-$(CONFIG_KEYBOARD_W90P910) += w90p910_keypad.o |
diff --git a/drivers/input/keyboard/adc-keys.c b/drivers/input/keyboard/adc-keys.c index f8cf2ccacefd..c255af21e71a 100644 --- a/drivers/input/keyboard/adc-keys.c +++ b/drivers/input/keyboard/adc-keys.c | |||
@@ -148,8 +148,6 @@ static int adc_keys_probe(struct platform_device *pdev) | |||
148 | if (error) | 148 | if (error) |
149 | return error; | 149 | return error; |
150 | 150 | ||
151 | platform_set_drvdata(pdev, st); | ||
152 | |||
153 | poll_dev = devm_input_allocate_polled_device(dev); | 151 | poll_dev = devm_input_allocate_polled_device(dev); |
154 | if (!poll_dev) { | 152 | if (!poll_dev) { |
155 | dev_err(dev, "failed to allocate input device\n"); | 153 | dev_err(dev, "failed to allocate input device\n"); |
diff --git a/drivers/input/keyboard/adp5520-keys.c b/drivers/input/keyboard/adp5520-keys.c index db1004dad108..f0b9b37bde58 100644 --- a/drivers/input/keyboard/adp5520-keys.c +++ b/drivers/input/keyboard/adp5520-keys.c | |||
@@ -107,8 +107,6 @@ static int adp5520_keys_probe(struct platform_device *pdev) | |||
107 | input->phys = "adp5520-keys/input0"; | 107 | input->phys = "adp5520-keys/input0"; |
108 | input->dev.parent = &pdev->dev; | 108 | input->dev.parent = &pdev->dev; |
109 | 109 | ||
110 | input_set_drvdata(input, dev); | ||
111 | |||
112 | input->id.bustype = BUS_I2C; | 110 | input->id.bustype = BUS_I2C; |
113 | input->id.vendor = 0x0001; | 111 | input->id.vendor = 0x0001; |
114 | input->id.product = 0x5520; | 112 | input->id.product = 0x5520; |
diff --git a/drivers/input/keyboard/bcm-keypad.c b/drivers/input/keyboard/bcm-keypad.c index 86a8b723ae15..e1cf63ee148f 100644 --- a/drivers/input/keyboard/bcm-keypad.c +++ b/drivers/input/keyboard/bcm-keypad.c | |||
@@ -213,7 +213,7 @@ static int bcm_kp_matrix_key_parse_dt(struct bcm_kp *kp) | |||
213 | /* Initialize the KPCR Keypad Configuration Register */ | 213 | /* Initialize the KPCR Keypad Configuration Register */ |
214 | kp->kpcr = KPCR_STATUSFILTERENABLE | KPCR_COLFILTERENABLE; | 214 | kp->kpcr = KPCR_STATUSFILTERENABLE | KPCR_COLFILTERENABLE; |
215 | 215 | ||
216 | error = matrix_keypad_parse_of_params(dev, &kp->n_rows, &kp->n_cols); | 216 | error = matrix_keypad_parse_properties(dev, &kp->n_rows, &kp->n_cols); |
217 | if (error) { | 217 | if (error) { |
218 | dev_err(dev, "failed to parse kp params\n"); | 218 | dev_err(dev, "failed to parse kp params\n"); |
219 | return error; | 219 | return error; |
@@ -352,8 +352,6 @@ static int bcm_kp_probe(struct platform_device *pdev) | |||
352 | 352 | ||
353 | kp->input_dev = input_dev; | 353 | kp->input_dev = input_dev; |
354 | 354 | ||
355 | platform_set_drvdata(pdev, kp); | ||
356 | |||
357 | error = bcm_kp_matrix_key_parse_dt(kp); | 355 | error = bcm_kp_matrix_key_parse_dt(kp); |
358 | if (error) | 356 | if (error) |
359 | return error; | 357 | return error; |
diff --git a/drivers/input/keyboard/bf54x-keys.c b/drivers/input/keyboard/bf54x-keys.c index 81b07dddae86..39bcbc38997f 100644 --- a/drivers/input/keyboard/bf54x-keys.c +++ b/drivers/input/keyboard/bf54x-keys.c | |||
@@ -268,8 +268,6 @@ static int bfin_kpad_probe(struct platform_device *pdev) | |||
268 | input->phys = "bf54x-keys/input0"; | 268 | input->phys = "bf54x-keys/input0"; |
269 | input->dev.parent = &pdev->dev; | 269 | input->dev.parent = &pdev->dev; |
270 | 270 | ||
271 | input_set_drvdata(input, bf54x_kpad); | ||
272 | |||
273 | input->id.bustype = BUS_HOST; | 271 | input->id.bustype = BUS_HOST; |
274 | input->id.vendor = 0x0001; | 272 | input->id.vendor = 0x0001; |
275 | input->id.product = 0x0001; | 273 | input->id.product = 0x0001; |
diff --git a/drivers/input/keyboard/cap11xx.c b/drivers/input/keyboard/cap11xx.c index 4401be225d64..1a1eacae3ea1 100644 --- a/drivers/input/keyboard/cap11xx.c +++ b/drivers/input/keyboard/cap11xx.c | |||
@@ -392,7 +392,6 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client, | |||
392 | return error; | 392 | return error; |
393 | 393 | ||
394 | dev_info(dev, "CAP11XX detected, revision 0x%02x\n", rev); | 394 | dev_info(dev, "CAP11XX detected, revision 0x%02x\n", rev); |
395 | i2c_set_clientdata(i2c_client, priv); | ||
396 | node = dev->of_node; | 395 | node = dev->of_node; |
397 | 396 | ||
398 | if (!of_property_read_u32(node, "microchip,sensor-gain", &gain32)) { | 397 | if (!of_property_read_u32(node, "microchip,sensor-gain", &gain32)) { |
diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c index 604c7ade8df2..6a250d65f8fe 100644 --- a/drivers/input/keyboard/cros_ec_keyb.c +++ b/drivers/input/keyboard/cros_ec_keyb.c | |||
@@ -535,7 +535,7 @@ static int cros_ec_keyb_register_matrix(struct cros_ec_keyb *ckdev) | |||
535 | const char *phys; | 535 | const char *phys; |
536 | int err; | 536 | int err; |
537 | 537 | ||
538 | err = matrix_keypad_parse_of_params(dev, &ckdev->rows, &ckdev->cols); | 538 | err = matrix_keypad_parse_properties(dev, &ckdev->rows, &ckdev->cols); |
539 | if (err) | 539 | if (err) |
540 | return err; | 540 | return err; |
541 | 541 | ||
diff --git a/drivers/input/keyboard/davinci_keyscan.c b/drivers/input/keyboard/davinci_keyscan.c index f363d1d2907a..b20a5d044caa 100644 --- a/drivers/input/keyboard/davinci_keyscan.c +++ b/drivers/input/keyboard/davinci_keyscan.c | |||
@@ -172,7 +172,7 @@ static int __init davinci_ks_probe(struct platform_device *pdev) | |||
172 | struct input_dev *key_dev; | 172 | struct input_dev *key_dev; |
173 | struct resource *res, *mem; | 173 | struct resource *res, *mem; |
174 | struct device *dev = &pdev->dev; | 174 | struct device *dev = &pdev->dev; |
175 | struct davinci_ks_platform_data *pdata = dev_get_platdata(&pdev->dev); | 175 | struct davinci_ks_platform_data *pdata = dev_get_platdata(dev); |
176 | int error, i; | 176 | int error, i; |
177 | 177 | ||
178 | if (pdata->device_enable) { | 178 | if (pdata->device_enable) { |
@@ -255,7 +255,7 @@ static int __init davinci_ks_probe(struct platform_device *pdev) | |||
255 | 255 | ||
256 | key_dev->name = "davinci_keyscan"; | 256 | key_dev->name = "davinci_keyscan"; |
257 | key_dev->phys = "davinci_keyscan/input0"; | 257 | key_dev->phys = "davinci_keyscan/input0"; |
258 | key_dev->dev.parent = &pdev->dev; | 258 | key_dev->dev.parent = dev; |
259 | key_dev->id.bustype = BUS_HOST; | 259 | key_dev->id.bustype = BUS_HOST; |
260 | key_dev->id.vendor = 0x0001; | 260 | key_dev->id.vendor = 0x0001; |
261 | key_dev->id.product = 0x0001; | 261 | key_dev->id.product = 0x0001; |
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 582462d0af75..9c92cdf196e3 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c | |||
@@ -36,6 +36,8 @@ struct gpio_button_data { | |||
36 | struct input_dev *input; | 36 | struct input_dev *input; |
37 | struct gpio_desc *gpiod; | 37 | struct gpio_desc *gpiod; |
38 | 38 | ||
39 | unsigned short *code; | ||
40 | |||
39 | struct timer_list release_timer; | 41 | struct timer_list release_timer; |
40 | unsigned int release_delay; /* in msecs, for IRQ-only buttons */ | 42 | unsigned int release_delay; /* in msecs, for IRQ-only buttons */ |
41 | 43 | ||
@@ -52,6 +54,7 @@ struct gpio_keys_drvdata { | |||
52 | const struct gpio_keys_platform_data *pdata; | 54 | const struct gpio_keys_platform_data *pdata; |
53 | struct input_dev *input; | 55 | struct input_dev *input; |
54 | struct mutex disable_lock; | 56 | struct mutex disable_lock; |
57 | unsigned short *keymap; | ||
55 | struct gpio_button_data data[0]; | 58 | struct gpio_button_data data[0]; |
56 | }; | 59 | }; |
57 | 60 | ||
@@ -203,7 +206,7 @@ static ssize_t gpio_keys_attr_show_helper(struct gpio_keys_drvdata *ddata, | |||
203 | if (only_disabled && !bdata->disabled) | 206 | if (only_disabled && !bdata->disabled) |
204 | continue; | 207 | continue; |
205 | 208 | ||
206 | __set_bit(bdata->button->code, bits); | 209 | __set_bit(*bdata->code, bits); |
207 | } | 210 | } |
208 | 211 | ||
209 | ret = scnprintf(buf, PAGE_SIZE - 1, "%*pbl", n_events, bits); | 212 | ret = scnprintf(buf, PAGE_SIZE - 1, "%*pbl", n_events, bits); |
@@ -254,7 +257,7 @@ static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata, | |||
254 | if (bdata->button->type != type) | 257 | if (bdata->button->type != type) |
255 | continue; | 258 | continue; |
256 | 259 | ||
257 | if (test_bit(bdata->button->code, bits) && | 260 | if (test_bit(*bdata->code, bits) && |
258 | !bdata->button->can_disable) { | 261 | !bdata->button->can_disable) { |
259 | error = -EINVAL; | 262 | error = -EINVAL; |
260 | goto out; | 263 | goto out; |
@@ -269,7 +272,7 @@ static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata, | |||
269 | if (bdata->button->type != type) | 272 | if (bdata->button->type != type) |
270 | continue; | 273 | continue; |
271 | 274 | ||
272 | if (test_bit(bdata->button->code, bits)) | 275 | if (test_bit(*bdata->code, bits)) |
273 | gpio_keys_disable_button(bdata); | 276 | gpio_keys_disable_button(bdata); |
274 | else | 277 | else |
275 | gpio_keys_enable_button(bdata); | 278 | gpio_keys_enable_button(bdata); |
@@ -371,7 +374,7 @@ static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata) | |||
371 | if (state) | 374 | if (state) |
372 | input_event(input, type, button->code, button->value); | 375 | input_event(input, type, button->code, button->value); |
373 | } else { | 376 | } else { |
374 | input_event(input, type, button->code, state); | 377 | input_event(input, type, *bdata->code, state); |
375 | } | 378 | } |
376 | input_sync(input); | 379 | input_sync(input); |
377 | } | 380 | } |
@@ -411,7 +414,7 @@ static void gpio_keys_irq_timer(unsigned long _data) | |||
411 | 414 | ||
412 | spin_lock_irqsave(&bdata->lock, flags); | 415 | spin_lock_irqsave(&bdata->lock, flags); |
413 | if (bdata->key_pressed) { | 416 | if (bdata->key_pressed) { |
414 | input_event(input, EV_KEY, bdata->button->code, 0); | 417 | input_event(input, EV_KEY, *bdata->code, 0); |
415 | input_sync(input); | 418 | input_sync(input); |
416 | bdata->key_pressed = false; | 419 | bdata->key_pressed = false; |
417 | } | 420 | } |
@@ -421,7 +424,6 @@ static void gpio_keys_irq_timer(unsigned long _data) | |||
421 | static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id) | 424 | static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id) |
422 | { | 425 | { |
423 | struct gpio_button_data *bdata = dev_id; | 426 | struct gpio_button_data *bdata = dev_id; |
424 | const struct gpio_keys_button *button = bdata->button; | ||
425 | struct input_dev *input = bdata->input; | 427 | struct input_dev *input = bdata->input; |
426 | unsigned long flags; | 428 | unsigned long flags; |
427 | 429 | ||
@@ -433,11 +435,11 @@ static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id) | |||
433 | if (bdata->button->wakeup) | 435 | if (bdata->button->wakeup) |
434 | pm_wakeup_event(bdata->input->dev.parent, 0); | 436 | pm_wakeup_event(bdata->input->dev.parent, 0); |
435 | 437 | ||
436 | input_event(input, EV_KEY, button->code, 1); | 438 | input_event(input, EV_KEY, *bdata->code, 1); |
437 | input_sync(input); | 439 | input_sync(input); |
438 | 440 | ||
439 | if (!bdata->release_delay) { | 441 | if (!bdata->release_delay) { |
440 | input_event(input, EV_KEY, button->code, 0); | 442 | input_event(input, EV_KEY, *bdata->code, 0); |
441 | input_sync(input); | 443 | input_sync(input); |
442 | goto out; | 444 | goto out; |
443 | } | 445 | } |
@@ -465,12 +467,14 @@ static void gpio_keys_quiesce_key(void *data) | |||
465 | 467 | ||
466 | static int gpio_keys_setup_key(struct platform_device *pdev, | 468 | static int gpio_keys_setup_key(struct platform_device *pdev, |
467 | struct input_dev *input, | 469 | struct input_dev *input, |
468 | struct gpio_button_data *bdata, | 470 | struct gpio_keys_drvdata *ddata, |
469 | const struct gpio_keys_button *button, | 471 | const struct gpio_keys_button *button, |
472 | int idx, | ||
470 | struct fwnode_handle *child) | 473 | struct fwnode_handle *child) |
471 | { | 474 | { |
472 | const char *desc = button->desc ? button->desc : "gpio_keys"; | 475 | const char *desc = button->desc ? button->desc : "gpio_keys"; |
473 | struct device *dev = &pdev->dev; | 476 | struct device *dev = &pdev->dev; |
477 | struct gpio_button_data *bdata = &ddata->data[idx]; | ||
474 | irq_handler_t isr; | 478 | irq_handler_t isr; |
475 | unsigned long irqflags; | 479 | unsigned long irqflags; |
476 | int irq; | 480 | int irq; |
@@ -514,8 +518,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev, | |||
514 | if (button->active_low) | 518 | if (button->active_low) |
515 | flags |= GPIOF_ACTIVE_LOW; | 519 | flags |= GPIOF_ACTIVE_LOW; |
516 | 520 | ||
517 | error = devm_gpio_request_one(&pdev->dev, button->gpio, flags, | 521 | error = devm_gpio_request_one(dev, button->gpio, flags, desc); |
518 | desc); | ||
519 | if (error < 0) { | 522 | if (error < 0) { |
520 | dev_err(dev, "Failed to request GPIO %d, error %d\n", | 523 | dev_err(dev, "Failed to request GPIO %d, error %d\n", |
521 | button->gpio, error); | 524 | button->gpio, error); |
@@ -577,16 +580,17 @@ static int gpio_keys_setup_key(struct platform_device *pdev, | |||
577 | irqflags = 0; | 580 | irqflags = 0; |
578 | } | 581 | } |
579 | 582 | ||
580 | input_set_capability(input, button->type ?: EV_KEY, button->code); | 583 | bdata->code = &ddata->keymap[idx]; |
584 | *bdata->code = button->code; | ||
585 | input_set_capability(input, button->type ?: EV_KEY, *bdata->code); | ||
581 | 586 | ||
582 | /* | 587 | /* |
583 | * Install custom action to cancel release timer and | 588 | * Install custom action to cancel release timer and |
584 | * workqueue item. | 589 | * workqueue item. |
585 | */ | 590 | */ |
586 | error = devm_add_action(&pdev->dev, gpio_keys_quiesce_key, bdata); | 591 | error = devm_add_action(dev, gpio_keys_quiesce_key, bdata); |
587 | if (error) { | 592 | if (error) { |
588 | dev_err(&pdev->dev, | 593 | dev_err(dev, "failed to register quiesce action, error: %d\n", |
589 | "failed to register quiesce action, error: %d\n", | ||
590 | error); | 594 | error); |
591 | return error; | 595 | return error; |
592 | } | 596 | } |
@@ -598,8 +602,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev, | |||
598 | if (!button->can_disable) | 602 | if (!button->can_disable) |
599 | irqflags |= IRQF_SHARED; | 603 | irqflags |= IRQF_SHARED; |
600 | 604 | ||
601 | error = devm_request_any_context_irq(&pdev->dev, bdata->irq, | 605 | error = devm_request_any_context_irq(dev, bdata->irq, isr, irqflags, |
602 | isr, irqflags, desc, bdata); | 606 | desc, bdata); |
603 | if (error < 0) { | 607 | if (error < 0) { |
604 | dev_err(dev, "Unable to claim irq %d; error %d\n", | 608 | dev_err(dev, "Unable to claim irq %d; error %d\n", |
605 | bdata->irq, error); | 609 | bdata->irq, error); |
@@ -750,6 +754,12 @@ static int gpio_keys_probe(struct platform_device *pdev) | |||
750 | return -ENOMEM; | 754 | return -ENOMEM; |
751 | } | 755 | } |
752 | 756 | ||
757 | ddata->keymap = devm_kcalloc(dev, | ||
758 | pdata->nbuttons, sizeof(ddata->keymap[0]), | ||
759 | GFP_KERNEL); | ||
760 | if (!ddata->keymap) | ||
761 | return -ENOMEM; | ||
762 | |||
753 | input = devm_input_allocate_device(dev); | 763 | input = devm_input_allocate_device(dev); |
754 | if (!input) { | 764 | if (!input) { |
755 | dev_err(dev, "failed to allocate input device\n"); | 765 | dev_err(dev, "failed to allocate input device\n"); |
@@ -765,7 +775,7 @@ static int gpio_keys_probe(struct platform_device *pdev) | |||
765 | 775 | ||
766 | input->name = pdata->name ? : pdev->name; | 776 | input->name = pdata->name ? : pdev->name; |
767 | input->phys = "gpio-keys/input0"; | 777 | input->phys = "gpio-keys/input0"; |
768 | input->dev.parent = &pdev->dev; | 778 | input->dev.parent = dev; |
769 | input->open = gpio_keys_open; | 779 | input->open = gpio_keys_open; |
770 | input->close = gpio_keys_close; | 780 | input->close = gpio_keys_close; |
771 | 781 | ||
@@ -774,25 +784,29 @@ static int gpio_keys_probe(struct platform_device *pdev) | |||
774 | input->id.product = 0x0001; | 784 | input->id.product = 0x0001; |
775 | input->id.version = 0x0100; | 785 | input->id.version = 0x0100; |
776 | 786 | ||
787 | input->keycode = ddata->keymap; | ||
788 | input->keycodesize = sizeof(ddata->keymap[0]); | ||
789 | input->keycodemax = pdata->nbuttons; | ||
790 | |||
777 | /* Enable auto repeat feature of Linux input subsystem */ | 791 | /* Enable auto repeat feature of Linux input subsystem */ |
778 | if (pdata->rep) | 792 | if (pdata->rep) |
779 | __set_bit(EV_REP, input->evbit); | 793 | __set_bit(EV_REP, input->evbit); |
780 | 794 | ||
781 | for (i = 0; i < pdata->nbuttons; i++) { | 795 | for (i = 0; i < pdata->nbuttons; i++) { |
782 | const struct gpio_keys_button *button = &pdata->buttons[i]; | 796 | const struct gpio_keys_button *button = &pdata->buttons[i]; |
783 | struct gpio_button_data *bdata = &ddata->data[i]; | ||
784 | 797 | ||
785 | if (!dev_get_platdata(dev)) { | 798 | if (!dev_get_platdata(dev)) { |
786 | child = device_get_next_child_node(&pdev->dev, child); | 799 | child = device_get_next_child_node(dev, child); |
787 | if (!child) { | 800 | if (!child) { |
788 | dev_err(&pdev->dev, | 801 | dev_err(dev, |
789 | "missing child device node for entry %d\n", | 802 | "missing child device node for entry %d\n", |
790 | i); | 803 | i); |
791 | return -EINVAL; | 804 | return -EINVAL; |
792 | } | 805 | } |
793 | } | 806 | } |
794 | 807 | ||
795 | error = gpio_keys_setup_key(pdev, input, bdata, button, child); | 808 | error = gpio_keys_setup_key(pdev, input, ddata, |
809 | button, i, child); | ||
796 | if (error) { | 810 | if (error) { |
797 | fwnode_handle_put(child); | 811 | fwnode_handle_put(child); |
798 | return error; | 812 | return error; |
@@ -804,7 +818,7 @@ static int gpio_keys_probe(struct platform_device *pdev) | |||
804 | 818 | ||
805 | fwnode_handle_put(child); | 819 | fwnode_handle_put(child); |
806 | 820 | ||
807 | error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group); | 821 | error = sysfs_create_group(&dev->kobj, &gpio_keys_attr_group); |
808 | if (error) { | 822 | if (error) { |
809 | dev_err(dev, "Unable to export keys/switches, error: %d\n", | 823 | dev_err(dev, "Unable to export keys/switches, error: %d\n", |
810 | error); | 824 | error); |
@@ -818,12 +832,12 @@ static int gpio_keys_probe(struct platform_device *pdev) | |||
818 | goto err_remove_group; | 832 | goto err_remove_group; |
819 | } | 833 | } |
820 | 834 | ||
821 | device_init_wakeup(&pdev->dev, wakeup); | 835 | device_init_wakeup(dev, wakeup); |
822 | 836 | ||
823 | return 0; | 837 | return 0; |
824 | 838 | ||
825 | err_remove_group: | 839 | err_remove_group: |
826 | sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); | 840 | sysfs_remove_group(&dev->kobj, &gpio_keys_attr_group); |
827 | return error; | 841 | return error; |
828 | } | 842 | } |
829 | 843 | ||
@@ -831,8 +845,6 @@ static int gpio_keys_remove(struct platform_device *pdev) | |||
831 | { | 845 | { |
832 | sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); | 846 | sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); |
833 | 847 | ||
834 | device_init_wakeup(&pdev->dev, 0); | ||
835 | |||
836 | return 0; | 848 | return 0; |
837 | } | 849 | } |
838 | 850 | ||
diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c index bed4f2086158..4fce43a6a0e0 100644 --- a/drivers/input/keyboard/gpio_keys_polled.c +++ b/drivers/input/keyboard/gpio_keys_polled.c | |||
@@ -252,13 +252,13 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) | |||
252 | 252 | ||
253 | size = sizeof(struct gpio_keys_polled_dev) + | 253 | size = sizeof(struct gpio_keys_polled_dev) + |
254 | pdata->nbuttons * sizeof(struct gpio_keys_button_data); | 254 | pdata->nbuttons * sizeof(struct gpio_keys_button_data); |
255 | bdev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL); | 255 | bdev = devm_kzalloc(dev, size, GFP_KERNEL); |
256 | if (!bdev) { | 256 | if (!bdev) { |
257 | dev_err(dev, "no memory for private data\n"); | 257 | dev_err(dev, "no memory for private data\n"); |
258 | return -ENOMEM; | 258 | return -ENOMEM; |
259 | } | 259 | } |
260 | 260 | ||
261 | poll_dev = devm_input_allocate_polled_device(&pdev->dev); | 261 | poll_dev = devm_input_allocate_polled_device(dev); |
262 | if (!poll_dev) { | 262 | if (!poll_dev) { |
263 | dev_err(dev, "no memory for polled device\n"); | 263 | dev_err(dev, "no memory for polled device\n"); |
264 | return -ENOMEM; | 264 | return -ENOMEM; |
@@ -332,7 +332,7 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) | |||
332 | if (button->active_low) | 332 | if (button->active_low) |
333 | flags |= GPIOF_ACTIVE_LOW; | 333 | flags |= GPIOF_ACTIVE_LOW; |
334 | 334 | ||
335 | error = devm_gpio_request_one(&pdev->dev, button->gpio, | 335 | error = devm_gpio_request_one(dev, button->gpio, |
336 | flags, button->desc ? : DRV_NAME); | 336 | flags, button->desc ? : DRV_NAME); |
337 | if (error) { | 337 | if (error) { |
338 | dev_err(dev, | 338 | dev_err(dev, |
@@ -365,7 +365,6 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) | |||
365 | bdev->poll_dev = poll_dev; | 365 | bdev->poll_dev = poll_dev; |
366 | bdev->dev = dev; | 366 | bdev->dev = dev; |
367 | bdev->pdata = pdata; | 367 | bdev->pdata = pdata; |
368 | platform_set_drvdata(pdev, bdev); | ||
369 | 368 | ||
370 | error = input_register_polled_device(poll_dev); | 369 | error = input_register_polled_device(poll_dev); |
371 | if (error) { | 370 | if (error) { |
diff --git a/drivers/input/keyboard/jornada680_kbd.c b/drivers/input/keyboard/jornada680_kbd.c index 80c81278ad2c..0116ac99f44c 100644 --- a/drivers/input/keyboard/jornada680_kbd.c +++ b/drivers/input/keyboard/jornada680_kbd.c | |||
@@ -197,8 +197,6 @@ static int jornada680kbd_probe(struct platform_device *pdev) | |||
197 | return -ENOMEM; | 197 | return -ENOMEM; |
198 | } | 198 | } |
199 | 199 | ||
200 | platform_set_drvdata(pdev, jornadakbd); | ||
201 | |||
202 | jornadakbd->poll_dev = poll_dev; | 200 | jornadakbd->poll_dev = poll_dev; |
203 | 201 | ||
204 | memcpy(jornadakbd->keymap, jornada_scancodes, | 202 | memcpy(jornadakbd->keymap, jornada_scancodes, |
diff --git a/drivers/input/keyboard/lpc32xx-keys.c b/drivers/input/keyboard/lpc32xx-keys.c index 632523d4f5dc..1dd57ac0e7a2 100644 --- a/drivers/input/keyboard/lpc32xx-keys.c +++ b/drivers/input/keyboard/lpc32xx-keys.c | |||
@@ -145,7 +145,7 @@ static int lpc32xx_parse_dt(struct device *dev, | |||
145 | u32 rows = 0, columns = 0; | 145 | u32 rows = 0, columns = 0; |
146 | int err; | 146 | int err; |
147 | 147 | ||
148 | err = matrix_keypad_parse_of_params(dev, &rows, &columns); | 148 | err = matrix_keypad_parse_properties(dev, &rows, &columns); |
149 | if (err) | 149 | if (err) |
150 | return err; | 150 | return err; |
151 | if (rows != columns) { | 151 | if (rows != columns) { |
diff --git a/drivers/input/keyboard/maple_keyb.c b/drivers/input/keyboard/maple_keyb.c index 5aa2361aef95..78e3567ec18c 100644 --- a/drivers/input/keyboard/maple_keyb.c +++ b/drivers/input/keyboard/maple_keyb.c | |||
@@ -196,7 +196,6 @@ static int probe_maple_kbd(struct device *dev) | |||
196 | __clear_bit(KEY_RESERVED, idev->keybit); | 196 | __clear_bit(KEY_RESERVED, idev->keybit); |
197 | 197 | ||
198 | input_set_capability(idev, EV_MSC, MSC_SCAN); | 198 | input_set_capability(idev, EV_MSC, MSC_SCAN); |
199 | input_set_drvdata(idev, kbd); | ||
200 | 199 | ||
201 | error = input_register_device(idev); | 200 | error = input_register_device(idev); |
202 | if (error) | 201 | if (error) |
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c index 7f12b6579f82..18839cd5f76e 100644 --- a/drivers/input/keyboard/matrix_keypad.c +++ b/drivers/input/keyboard/matrix_keypad.c | |||
@@ -545,8 +545,6 @@ static int matrix_keypad_remove(struct platform_device *pdev) | |||
545 | { | 545 | { |
546 | struct matrix_keypad *keypad = platform_get_drvdata(pdev); | 546 | struct matrix_keypad *keypad = platform_get_drvdata(pdev); |
547 | 547 | ||
548 | device_init_wakeup(&pdev->dev, 0); | ||
549 | |||
550 | matrix_keypad_free_gpio(keypad); | 548 | matrix_keypad_free_gpio(keypad); |
551 | input_unregister_device(keypad->input_dev); | 549 | input_unregister_device(keypad->input_dev); |
552 | kfree(keypad); | 550 | kfree(keypad); |
diff --git a/drivers/input/keyboard/max7359_keypad.c b/drivers/input/keyboard/max7359_keypad.c index 5091133b7b8e..cd44d22d8770 100644 --- a/drivers/input/keyboard/max7359_keypad.c +++ b/drivers/input/keyboard/max7359_keypad.c | |||
@@ -241,7 +241,6 @@ static int max7359_probe(struct i2c_client *client, | |||
241 | /* Initialize MAX7359 */ | 241 | /* Initialize MAX7359 */ |
242 | max7359_initialize(client); | 242 | max7359_initialize(client); |
243 | 243 | ||
244 | i2c_set_clientdata(client, keypad); | ||
245 | device_init_wakeup(&client->dev, 1); | 244 | device_init_wakeup(&client->dev, 1); |
246 | 245 | ||
247 | return 0; | 246 | return 0; |
diff --git a/drivers/input/keyboard/mpr121_touchkey.c b/drivers/input/keyboard/mpr121_touchkey.c index 0fd612dd76ed..884a74d8a7ed 100644 --- a/drivers/input/keyboard/mpr121_touchkey.c +++ b/drivers/input/keyboard/mpr121_touchkey.c | |||
@@ -12,14 +12,16 @@ | |||
12 | * | 12 | * |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/input.h> | ||
17 | #include <linux/i2c.h> | ||
18 | #include <linux/slab.h> | ||
19 | #include <linux/delay.h> | ||
20 | #include <linux/bitops.h> | 15 | #include <linux/bitops.h> |
16 | #include <linux/delay.h> | ||
17 | #include <linux/i2c.h> | ||
18 | #include <linux/input.h> | ||
21 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
22 | #include <linux/i2c/mpr121_touchkey.h> | 20 | #include <linux/module.h> |
21 | #include <linux/of.h> | ||
22 | #include <linux/property.h> | ||
23 | #include <linux/regulator/consumer.h> | ||
24 | #include <linux/slab.h> | ||
23 | 25 | ||
24 | /* Register definitions */ | 26 | /* Register definitions */ |
25 | #define ELE_TOUCH_STATUS_0_ADDR 0x0 | 27 | #define ELE_TOUCH_STATUS_0_ADDR 0x0 |
@@ -59,10 +61,9 @@ | |||
59 | struct mpr121_touchkey { | 61 | struct mpr121_touchkey { |
60 | struct i2c_client *client; | 62 | struct i2c_client *client; |
61 | struct input_dev *input_dev; | 63 | struct input_dev *input_dev; |
62 | unsigned int key_val; | ||
63 | unsigned int statusbits; | 64 | unsigned int statusbits; |
64 | unsigned int keycount; | 65 | unsigned int keycount; |
65 | u16 keycodes[MPR121_MAX_KEY_COUNT]; | 66 | u32 keycodes[MPR121_MAX_KEY_COUNT]; |
66 | }; | 67 | }; |
67 | 68 | ||
68 | struct mpr121_init_register { | 69 | struct mpr121_init_register { |
@@ -82,12 +83,49 @@ static const struct mpr121_init_register init_reg_table[] = { | |||
82 | { AUTO_CONFIG_CTRL_ADDR, 0x0b }, | 83 | { AUTO_CONFIG_CTRL_ADDR, 0x0b }, |
83 | }; | 84 | }; |
84 | 85 | ||
86 | static void mpr121_vdd_supply_disable(void *data) | ||
87 | { | ||
88 | struct regulator *vdd_supply = data; | ||
89 | |||
90 | regulator_disable(vdd_supply); | ||
91 | } | ||
92 | |||
93 | static struct regulator *mpr121_vdd_supply_init(struct device *dev) | ||
94 | { | ||
95 | struct regulator *vdd_supply; | ||
96 | int err; | ||
97 | |||
98 | vdd_supply = devm_regulator_get(dev, "vdd"); | ||
99 | if (IS_ERR(vdd_supply)) { | ||
100 | dev_err(dev, "failed to get vdd regulator: %ld\n", | ||
101 | PTR_ERR(vdd_supply)); | ||
102 | return vdd_supply; | ||
103 | } | ||
104 | |||
105 | err = regulator_enable(vdd_supply); | ||
106 | if (err) { | ||
107 | dev_err(dev, "failed to enable vdd regulator: %d\n", err); | ||
108 | return ERR_PTR(err); | ||
109 | } | ||
110 | |||
111 | err = devm_add_action(dev, mpr121_vdd_supply_disable, vdd_supply); | ||
112 | if (err) { | ||
113 | regulator_disable(vdd_supply); | ||
114 | dev_err(dev, "failed to add disable regulator action: %d\n", | ||
115 | err); | ||
116 | return ERR_PTR(err); | ||
117 | } | ||
118 | |||
119 | return vdd_supply; | ||
120 | } | ||
121 | |||
85 | static irqreturn_t mpr_touchkey_interrupt(int irq, void *dev_id) | 122 | static irqreturn_t mpr_touchkey_interrupt(int irq, void *dev_id) |
86 | { | 123 | { |
87 | struct mpr121_touchkey *mpr121 = dev_id; | 124 | struct mpr121_touchkey *mpr121 = dev_id; |
88 | struct i2c_client *client = mpr121->client; | 125 | struct i2c_client *client = mpr121->client; |
89 | struct input_dev *input = mpr121->input_dev; | 126 | struct input_dev *input = mpr121->input_dev; |
90 | unsigned int key_num, key_val, pressed; | 127 | unsigned long bit_changed; |
128 | unsigned int key_num; | ||
91 | int reg; | 129 | int reg; |
92 | 130 | ||
93 | reg = i2c_smbus_read_byte_data(client, ELE_TOUCH_STATUS_1_ADDR); | 131 | reg = i2c_smbus_read_byte_data(client, ELE_TOUCH_STATUS_1_ADDR); |
@@ -105,26 +143,29 @@ static irqreturn_t mpr_touchkey_interrupt(int irq, void *dev_id) | |||
105 | 143 | ||
106 | reg &= TOUCH_STATUS_MASK; | 144 | reg &= TOUCH_STATUS_MASK; |
107 | /* use old press bit to figure out which bit changed */ | 145 | /* use old press bit to figure out which bit changed */ |
108 | key_num = ffs(reg ^ mpr121->statusbits) - 1; | 146 | bit_changed = reg ^ mpr121->statusbits; |
109 | pressed = reg & (1 << key_num); | ||
110 | mpr121->statusbits = reg; | 147 | mpr121->statusbits = reg; |
148 | for_each_set_bit(key_num, &bit_changed, mpr121->keycount) { | ||
149 | unsigned int key_val, pressed; | ||
111 | 150 | ||
112 | key_val = mpr121->keycodes[key_num]; | 151 | pressed = reg & BIT(key_num); |
152 | key_val = mpr121->keycodes[key_num]; | ||
113 | 153 | ||
114 | input_event(input, EV_MSC, MSC_SCAN, key_num); | 154 | input_event(input, EV_MSC, MSC_SCAN, key_num); |
115 | input_report_key(input, key_val, pressed); | 155 | input_report_key(input, key_val, pressed); |
116 | input_sync(input); | ||
117 | 156 | ||
118 | dev_dbg(&client->dev, "key %d %d %s\n", key_num, key_val, | 157 | dev_dbg(&client->dev, "key %d %d %s\n", key_num, key_val, |
119 | pressed ? "pressed" : "released"); | 158 | pressed ? "pressed" : "released"); |
159 | |||
160 | } | ||
161 | input_sync(input); | ||
120 | 162 | ||
121 | out: | 163 | out: |
122 | return IRQ_HANDLED; | 164 | return IRQ_HANDLED; |
123 | } | 165 | } |
124 | 166 | ||
125 | static int mpr121_phys_init(const struct mpr121_platform_data *pdata, | 167 | static int mpr121_phys_init(struct mpr121_touchkey *mpr121, |
126 | struct mpr121_touchkey *mpr121, | 168 | struct i2c_client *client, int vdd_uv) |
127 | struct i2c_client *client) | ||
128 | { | 169 | { |
129 | const struct mpr121_init_register *reg; | 170 | const struct mpr121_init_register *reg; |
130 | unsigned char usl, lsl, tl, eleconf; | 171 | unsigned char usl, lsl, tl, eleconf; |
@@ -154,9 +195,9 @@ static int mpr121_phys_init(const struct mpr121_platform_data *pdata, | |||
154 | /* | 195 | /* |
155 | * Capacitance on sensing input varies and needs to be compensated. | 196 | * Capacitance on sensing input varies and needs to be compensated. |
156 | * The internal MPR121-auto-configuration can do this if it's | 197 | * The internal MPR121-auto-configuration can do this if it's |
157 | * registers are set properly (based on pdata->vdd_uv). | 198 | * registers are set properly (based on vdd_uv). |
158 | */ | 199 | */ |
159 | vdd = pdata->vdd_uv / 1000; | 200 | vdd = vdd_uv / 1000; |
160 | usl = ((vdd - 700) * 256) / vdd; | 201 | usl = ((vdd - 700) * 256) / vdd; |
161 | lsl = (usl * 65) / 100; | 202 | lsl = (usl * 65) / 100; |
162 | tl = (usl * 90) / 100; | 203 | tl = (usl * 90) / 100; |
@@ -187,72 +228,77 @@ err_i2c_write: | |||
187 | static int mpr_touchkey_probe(struct i2c_client *client, | 228 | static int mpr_touchkey_probe(struct i2c_client *client, |
188 | const struct i2c_device_id *id) | 229 | const struct i2c_device_id *id) |
189 | { | 230 | { |
190 | const struct mpr121_platform_data *pdata = | 231 | struct device *dev = &client->dev; |
191 | dev_get_platdata(&client->dev); | 232 | struct regulator *vdd_supply; |
233 | int vdd_uv; | ||
192 | struct mpr121_touchkey *mpr121; | 234 | struct mpr121_touchkey *mpr121; |
193 | struct input_dev *input_dev; | 235 | struct input_dev *input_dev; |
194 | int error; | 236 | int error; |
195 | int i; | 237 | int i; |
196 | 238 | ||
197 | if (!pdata) { | 239 | if (!client->irq) { |
198 | dev_err(&client->dev, "no platform data defined\n"); | 240 | dev_err(dev, "irq number should not be zero\n"); |
199 | return -EINVAL; | ||
200 | } | ||
201 | |||
202 | if (!pdata->keymap || !pdata->keymap_size) { | ||
203 | dev_err(&client->dev, "missing keymap data\n"); | ||
204 | return -EINVAL; | 241 | return -EINVAL; |
205 | } | 242 | } |
206 | 243 | ||
207 | if (pdata->keymap_size > MPR121_MAX_KEY_COUNT) { | 244 | vdd_supply = mpr121_vdd_supply_init(dev); |
208 | dev_err(&client->dev, "too many keys defined\n"); | 245 | if (IS_ERR(vdd_supply)) |
209 | return -EINVAL; | 246 | return PTR_ERR(vdd_supply); |
210 | } | ||
211 | 247 | ||
212 | if (!client->irq) { | 248 | vdd_uv = regulator_get_voltage(vdd_supply); |
213 | dev_err(&client->dev, "irq number should not be zero\n"); | ||
214 | return -EINVAL; | ||
215 | } | ||
216 | 249 | ||
217 | mpr121 = devm_kzalloc(&client->dev, sizeof(*mpr121), | 250 | mpr121 = devm_kzalloc(dev, sizeof(*mpr121), GFP_KERNEL); |
218 | GFP_KERNEL); | ||
219 | if (!mpr121) | 251 | if (!mpr121) |
220 | return -ENOMEM; | 252 | return -ENOMEM; |
221 | 253 | ||
222 | input_dev = devm_input_allocate_device(&client->dev); | 254 | input_dev = devm_input_allocate_device(dev); |
223 | if (!input_dev) | 255 | if (!input_dev) |
224 | return -ENOMEM; | 256 | return -ENOMEM; |
225 | 257 | ||
226 | mpr121->client = client; | 258 | mpr121->client = client; |
227 | mpr121->input_dev = input_dev; | 259 | mpr121->input_dev = input_dev; |
228 | mpr121->keycount = pdata->keymap_size; | 260 | mpr121->keycount = device_property_read_u32_array(dev, "linux,keycodes", |
261 | NULL, 0); | ||
262 | if (mpr121->keycount > MPR121_MAX_KEY_COUNT) { | ||
263 | dev_err(dev, "too many keys defined (%d)\n", mpr121->keycount); | ||
264 | return -EINVAL; | ||
265 | } | ||
266 | |||
267 | error = device_property_read_u32_array(dev, "linux,keycodes", | ||
268 | mpr121->keycodes, | ||
269 | mpr121->keycount); | ||
270 | if (error) { | ||
271 | dev_err(dev, | ||
272 | "failed to read linux,keycode property: %d\n", error); | ||
273 | return error; | ||
274 | } | ||
229 | 275 | ||
230 | input_dev->name = "Freescale MPR121 Touchkey"; | 276 | input_dev->name = "Freescale MPR121 Touchkey"; |
231 | input_dev->id.bustype = BUS_I2C; | 277 | input_dev->id.bustype = BUS_I2C; |
232 | input_dev->dev.parent = &client->dev; | 278 | input_dev->dev.parent = dev; |
233 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); | 279 | if (device_property_read_bool(dev, "autorepeat")) |
280 | __set_bit(EV_REP, input_dev->evbit); | ||
281 | input_set_capability(input_dev, EV_MSC, MSC_SCAN); | ||
234 | 282 | ||
235 | input_dev->keycode = mpr121->keycodes; | 283 | input_dev->keycode = mpr121->keycodes; |
236 | input_dev->keycodesize = sizeof(mpr121->keycodes[0]); | 284 | input_dev->keycodesize = sizeof(mpr121->keycodes[0]); |
237 | input_dev->keycodemax = mpr121->keycount; | 285 | input_dev->keycodemax = mpr121->keycount; |
238 | 286 | ||
239 | for (i = 0; i < pdata->keymap_size; i++) { | 287 | for (i = 0; i < mpr121->keycount; i++) |
240 | input_set_capability(input_dev, EV_KEY, pdata->keymap[i]); | 288 | input_set_capability(input_dev, EV_KEY, mpr121->keycodes[i]); |
241 | mpr121->keycodes[i] = pdata->keymap[i]; | ||
242 | } | ||
243 | 289 | ||
244 | error = mpr121_phys_init(pdata, mpr121, client); | 290 | error = mpr121_phys_init(mpr121, client, vdd_uv); |
245 | if (error) { | 291 | if (error) { |
246 | dev_err(&client->dev, "Failed to init register\n"); | 292 | dev_err(dev, "Failed to init register\n"); |
247 | return error; | 293 | return error; |
248 | } | 294 | } |
249 | 295 | ||
250 | error = devm_request_threaded_irq(&client->dev, client->irq, NULL, | 296 | error = devm_request_threaded_irq(dev, client->irq, NULL, |
251 | mpr_touchkey_interrupt, | 297 | mpr_touchkey_interrupt, |
252 | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, | 298 | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, |
253 | client->dev.driver->name, mpr121); | 299 | dev->driver->name, mpr121); |
254 | if (error) { | 300 | if (error) { |
255 | dev_err(&client->dev, "Failed to register interrupt\n"); | 301 | dev_err(dev, "Failed to register interrupt\n"); |
256 | return error; | 302 | return error; |
257 | } | 303 | } |
258 | 304 | ||
@@ -261,13 +307,13 @@ static int mpr_touchkey_probe(struct i2c_client *client, | |||
261 | return error; | 307 | return error; |
262 | 308 | ||
263 | i2c_set_clientdata(client, mpr121); | 309 | i2c_set_clientdata(client, mpr121); |
264 | device_init_wakeup(&client->dev, pdata->wakeup); | 310 | device_init_wakeup(dev, |
311 | device_property_read_bool(dev, "wakeup-source")); | ||
265 | 312 | ||
266 | return 0; | 313 | return 0; |
267 | } | 314 | } |
268 | 315 | ||
269 | #ifdef CONFIG_PM_SLEEP | 316 | static int __maybe_unused mpr_suspend(struct device *dev) |
270 | static int mpr_suspend(struct device *dev) | ||
271 | { | 317 | { |
272 | struct i2c_client *client = to_i2c_client(dev); | 318 | struct i2c_client *client = to_i2c_client(dev); |
273 | 319 | ||
@@ -279,7 +325,7 @@ static int mpr_suspend(struct device *dev) | |||
279 | return 0; | 325 | return 0; |
280 | } | 326 | } |
281 | 327 | ||
282 | static int mpr_resume(struct device *dev) | 328 | static int __maybe_unused mpr_resume(struct device *dev) |
283 | { | 329 | { |
284 | struct i2c_client *client = to_i2c_client(dev); | 330 | struct i2c_client *client = to_i2c_client(dev); |
285 | struct mpr121_touchkey *mpr121 = i2c_get_clientdata(client); | 331 | struct mpr121_touchkey *mpr121 = i2c_get_clientdata(client); |
@@ -292,7 +338,6 @@ static int mpr_resume(struct device *dev) | |||
292 | 338 | ||
293 | return 0; | 339 | return 0; |
294 | } | 340 | } |
295 | #endif | ||
296 | 341 | ||
297 | static SIMPLE_DEV_PM_OPS(mpr121_touchkey_pm_ops, mpr_suspend, mpr_resume); | 342 | static SIMPLE_DEV_PM_OPS(mpr121_touchkey_pm_ops, mpr_suspend, mpr_resume); |
298 | 343 | ||
@@ -302,10 +347,19 @@ static const struct i2c_device_id mpr121_id[] = { | |||
302 | }; | 347 | }; |
303 | MODULE_DEVICE_TABLE(i2c, mpr121_id); | 348 | MODULE_DEVICE_TABLE(i2c, mpr121_id); |
304 | 349 | ||
350 | #ifdef CONFIG_OF | ||
351 | static const struct of_device_id mpr121_touchkey_dt_match_table[] = { | ||
352 | { .compatible = "fsl,mpr121-touchkey" }, | ||
353 | { }, | ||
354 | }; | ||
355 | MODULE_DEVICE_TABLE(of, mpr121_touchkey_dt_match_table); | ||
356 | #endif | ||
357 | |||
305 | static struct i2c_driver mpr_touchkey_driver = { | 358 | static struct i2c_driver mpr_touchkey_driver = { |
306 | .driver = { | 359 | .driver = { |
307 | .name = "mpr121", | 360 | .name = "mpr121", |
308 | .pm = &mpr121_touchkey_pm_ops, | 361 | .pm = &mpr121_touchkey_pm_ops, |
362 | .of_match_table = of_match_ptr(mpr121_touchkey_dt_match_table), | ||
309 | }, | 363 | }, |
310 | .id_table = mpr121_id, | 364 | .id_table = mpr121_id, |
311 | .probe = mpr_touchkey_probe, | 365 | .probe = mpr_touchkey_probe, |
diff --git a/drivers/input/keyboard/nspire-keypad.c b/drivers/input/keyboard/nspire-keypad.c index 7abfd34eb87e..c7f26fa3034c 100644 --- a/drivers/input/keyboard/nspire-keypad.c +++ b/drivers/input/keyboard/nspire-keypad.c | |||
@@ -249,8 +249,6 @@ static int nspire_keypad_probe(struct platform_device *pdev) | |||
249 | return error; | 249 | return error; |
250 | } | 250 | } |
251 | 251 | ||
252 | platform_set_drvdata(pdev, keypad); | ||
253 | |||
254 | dev_dbg(&pdev->dev, | 252 | dev_dbg(&pdev->dev, |
255 | "TI-NSPIRE keypad at %pR (scan_interval=%uus, row_delay=%uus%s)\n", | 253 | "TI-NSPIRE keypad at %pR (scan_interval=%uus, row_delay=%uus%s)\n", |
256 | res, keypad->row_delay, keypad->scan_interval, | 254 | res, keypad->row_delay, keypad->scan_interval, |
diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index 6639b2b8528a..ebc67ba41fe2 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c | |||
@@ -223,8 +223,8 @@ static int omap4_keypad_parse_dt(struct device *dev, | |||
223 | struct device_node *np = dev->of_node; | 223 | struct device_node *np = dev->of_node; |
224 | int err; | 224 | int err; |
225 | 225 | ||
226 | err = matrix_keypad_parse_of_params(dev, &keypad_data->rows, | 226 | err = matrix_keypad_parse_properties(dev, &keypad_data->rows, |
227 | &keypad_data->cols); | 227 | &keypad_data->cols); |
228 | if (err) | 228 | if (err) |
229 | return err; | 229 | return err; |
230 | 230 | ||
@@ -375,7 +375,6 @@ static int omap4_keypad_probe(struct platform_device *pdev) | |||
375 | 375 | ||
376 | err_pm_disable: | 376 | err_pm_disable: |
377 | pm_runtime_disable(&pdev->dev); | 377 | pm_runtime_disable(&pdev->dev); |
378 | device_init_wakeup(&pdev->dev, false); | ||
379 | free_irq(keypad_data->irq, keypad_data); | 378 | free_irq(keypad_data->irq, keypad_data); |
380 | err_free_keymap: | 379 | err_free_keymap: |
381 | kfree(keypad_data->keymap); | 380 | kfree(keypad_data->keymap); |
@@ -401,8 +400,6 @@ static int omap4_keypad_remove(struct platform_device *pdev) | |||
401 | 400 | ||
402 | pm_runtime_disable(&pdev->dev); | 401 | pm_runtime_disable(&pdev->dev); |
403 | 402 | ||
404 | device_init_wakeup(&pdev->dev, false); | ||
405 | |||
406 | input_unregister_device(keypad_data->input); | 403 | input_unregister_device(keypad_data->input); |
407 | 404 | ||
408 | iounmap(keypad_data->base); | 405 | iounmap(keypad_data->base); |
diff --git a/drivers/input/keyboard/opencores-kbd.c b/drivers/input/keyboard/opencores-kbd.c index f8502bb29176..d62b4068c077 100644 --- a/drivers/input/keyboard/opencores-kbd.c +++ b/drivers/input/keyboard/opencores-kbd.c | |||
@@ -75,8 +75,6 @@ static int opencores_kbd_probe(struct platform_device *pdev) | |||
75 | input->name = pdev->name; | 75 | input->name = pdev->name; |
76 | input->phys = "opencores-kbd/input0"; | 76 | input->phys = "opencores-kbd/input0"; |
77 | 77 | ||
78 | input_set_drvdata(input, opencores_kbd); | ||
79 | |||
80 | input->id.bustype = BUS_HOST; | 78 | input->id.bustype = BUS_HOST; |
81 | input->id.vendor = 0x0001; | 79 | input->id.vendor = 0x0001; |
82 | input->id.product = 0x0001; | 80 | input->id.product = 0x0001; |
@@ -112,8 +110,6 @@ static int opencores_kbd_probe(struct platform_device *pdev) | |||
112 | return error; | 110 | return error; |
113 | } | 111 | } |
114 | 112 | ||
115 | platform_set_drvdata(pdev, opencores_kbd); | ||
116 | |||
117 | return 0; | 113 | return 0; |
118 | } | 114 | } |
119 | 115 | ||
diff --git a/drivers/input/keyboard/pmic8xxx-keypad.c b/drivers/input/keyboard/pmic8xxx-keypad.c index 5c68e3f096bc..97c5424f49b9 100644 --- a/drivers/input/keyboard/pmic8xxx-keypad.c +++ b/drivers/input/keyboard/pmic8xxx-keypad.c | |||
@@ -515,7 +515,7 @@ static int pmic8xxx_kp_probe(struct platform_device *pdev) | |||
515 | int rc; | 515 | int rc; |
516 | unsigned int ctrl_val; | 516 | unsigned int ctrl_val; |
517 | 517 | ||
518 | rc = matrix_keypad_parse_of_params(&pdev->dev, &rows, &cols); | 518 | rc = matrix_keypad_parse_properties(&pdev->dev, &rows, &cols); |
519 | if (rc) | 519 | if (rc) |
520 | return rc; | 520 | return rc; |
521 | 521 | ||
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c index e24443376e75..3841fa30db33 100644 --- a/drivers/input/keyboard/pxa27x_keypad.c +++ b/drivers/input/keyboard/pxa27x_keypad.c | |||
@@ -126,7 +126,7 @@ static int pxa27x_keypad_matrix_key_parse_dt(struct pxa27x_keypad *keypad, | |||
126 | u32 rows, cols; | 126 | u32 rows, cols; |
127 | int error; | 127 | int error; |
128 | 128 | ||
129 | error = matrix_keypad_parse_of_params(dev, &rows, &cols); | 129 | error = matrix_keypad_parse_properties(dev, &rows, &cols); |
130 | if (error) | 130 | if (error) |
131 | return error; | 131 | return error; |
132 | 132 | ||
diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c index 4e319eb9e19d..316414465c77 100644 --- a/drivers/input/keyboard/samsung-keypad.c +++ b/drivers/input/keyboard/samsung-keypad.c | |||
@@ -445,7 +445,6 @@ static int samsung_keypad_probe(struct platform_device *pdev) | |||
445 | 445 | ||
446 | err_disable_runtime_pm: | 446 | err_disable_runtime_pm: |
447 | pm_runtime_disable(&pdev->dev); | 447 | pm_runtime_disable(&pdev->dev); |
448 | device_init_wakeup(&pdev->dev, 0); | ||
449 | err_unprepare_clk: | 448 | err_unprepare_clk: |
450 | clk_unprepare(keypad->clk); | 449 | clk_unprepare(keypad->clk); |
451 | return error; | 450 | return error; |
@@ -456,7 +455,6 @@ static int samsung_keypad_remove(struct platform_device *pdev) | |||
456 | struct samsung_keypad *keypad = platform_get_drvdata(pdev); | 455 | struct samsung_keypad *keypad = platform_get_drvdata(pdev); |
457 | 456 | ||
458 | pm_runtime_disable(&pdev->dev); | 457 | pm_runtime_disable(&pdev->dev); |
459 | device_init_wakeup(&pdev->dev, 0); | ||
460 | 458 | ||
461 | input_unregister_device(keypad->input_dev); | 459 | input_unregister_device(keypad->input_dev); |
462 | 460 | ||
diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c index 8083eaa0524a..7d25fa338ab4 100644 --- a/drivers/input/keyboard/spear-keyboard.c +++ b/drivers/input/keyboard/spear-keyboard.c | |||
@@ -283,8 +283,6 @@ static int spear_kbd_remove(struct platform_device *pdev) | |||
283 | input_unregister_device(kbd->input); | 283 | input_unregister_device(kbd->input); |
284 | clk_unprepare(kbd->clk); | 284 | clk_unprepare(kbd->clk); |
285 | 285 | ||
286 | device_init_wakeup(&pdev->dev, 0); | ||
287 | |||
288 | return 0; | 286 | return 0; |
289 | } | 287 | } |
290 | 288 | ||
diff --git a/drivers/input/keyboard/st-keyscan.c b/drivers/input/keyboard/st-keyscan.c index de7be4f03d91..babcfb165e4f 100644 --- a/drivers/input/keyboard/st-keyscan.c +++ b/drivers/input/keyboard/st-keyscan.c | |||
@@ -106,8 +106,8 @@ static int keypad_matrix_key_parse_dt(struct st_keyscan *keypad_data) | |||
106 | struct device_node *np = dev->of_node; | 106 | struct device_node *np = dev->of_node; |
107 | int error; | 107 | int error; |
108 | 108 | ||
109 | error = matrix_keypad_parse_of_params(dev, &keypad_data->n_rows, | 109 | error = matrix_keypad_parse_properties(dev, &keypad_data->n_rows, |
110 | &keypad_data->n_cols); | 110 | &keypad_data->n_cols); |
111 | if (error) { | 111 | if (error) { |
112 | dev_err(dev, "failed to parse keypad params\n"); | 112 | dev_err(dev, "failed to parse keypad params\n"); |
113 | return error; | 113 | return error; |
diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c index fe6e3f22eed7..8c6c0b9109c7 100644 --- a/drivers/input/keyboard/stmpe-keypad.c +++ b/drivers/input/keyboard/stmpe-keypad.c | |||
@@ -354,7 +354,7 @@ static int stmpe_keypad_probe(struct platform_device *pdev) | |||
354 | input->id.bustype = BUS_I2C; | 354 | input->id.bustype = BUS_I2C; |
355 | input->dev.parent = &pdev->dev; | 355 | input->dev.parent = &pdev->dev; |
356 | 356 | ||
357 | error = matrix_keypad_parse_of_params(&pdev->dev, &rows, &cols); | 357 | error = matrix_keypad_parse_properties(&pdev->dev, &rows, &cols); |
358 | if (error) | 358 | if (error) |
359 | return error; | 359 | return error; |
360 | 360 | ||
diff --git a/drivers/input/keyboard/sun4i-lradc-keys.c b/drivers/input/keyboard/sun4i-lradc-keys.c index cc8f7ddcee53..a37c172452e6 100644 --- a/drivers/input/keyboard/sun4i-lradc-keys.c +++ b/drivers/input/keyboard/sun4i-lradc-keys.c | |||
@@ -261,7 +261,6 @@ static int sun4i_lradc_probe(struct platform_device *pdev) | |||
261 | if (error) | 261 | if (error) |
262 | return error; | 262 | return error; |
263 | 263 | ||
264 | platform_set_drvdata(pdev, lradc); | ||
265 | return 0; | 264 | return 0; |
266 | } | 265 | } |
267 | 266 | ||
diff --git a/drivers/input/keyboard/tca8418_keypad.c b/drivers/input/keyboard/tca8418_keypad.c index 3048ef3e3e16..44dd7689c571 100644 --- a/drivers/input/keyboard/tca8418_keypad.c +++ b/drivers/input/keyboard/tca8418_keypad.c | |||
@@ -24,18 +24,17 @@ | |||
24 | * alternative licensing inquiries. | 24 | * alternative licensing inquiries. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <linux/types.h> | ||
28 | #include <linux/module.h> | ||
29 | #include <linux/init.h> | ||
30 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
31 | #include <linux/slab.h> | ||
32 | #include <linux/interrupt.h> | ||
33 | #include <linux/workqueue.h> | ||
34 | #include <linux/gpio.h> | ||
35 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/init.h> | ||
36 | #include <linux/input.h> | 30 | #include <linux/input.h> |
37 | #include <linux/input/tca8418_keypad.h> | 31 | #include <linux/input/matrix_keypad.h> |
32 | #include <linux/interrupt.h> | ||
33 | #include <linux/module.h> | ||
38 | #include <linux/of.h> | 34 | #include <linux/of.h> |
35 | #include <linux/property.h> | ||
36 | #include <linux/slab.h> | ||
37 | #include <linux/types.h> | ||
39 | 38 | ||
40 | /* TCA8418 hardware limits */ | 39 | /* TCA8418 hardware limits */ |
41 | #define TCA8418_MAX_ROWS 8 | 40 | #define TCA8418_MAX_ROWS 8 |
@@ -264,41 +263,25 @@ static int tca8418_configure(struct tca8418_keypad *keypad_data, | |||
264 | } | 263 | } |
265 | 264 | ||
266 | static int tca8418_keypad_probe(struct i2c_client *client, | 265 | static int tca8418_keypad_probe(struct i2c_client *client, |
267 | const struct i2c_device_id *id) | 266 | const struct i2c_device_id *id) |
268 | { | 267 | { |
269 | struct device *dev = &client->dev; | 268 | struct device *dev = &client->dev; |
270 | const struct tca8418_keypad_platform_data *pdata = | ||
271 | dev_get_platdata(dev); | ||
272 | struct tca8418_keypad *keypad_data; | 269 | struct tca8418_keypad *keypad_data; |
273 | struct input_dev *input; | 270 | struct input_dev *input; |
274 | const struct matrix_keymap_data *keymap_data = NULL; | ||
275 | u32 rows = 0, cols = 0; | 271 | u32 rows = 0, cols = 0; |
276 | bool rep = false; | ||
277 | bool irq_is_gpio = false; | ||
278 | int irq; | ||
279 | int error, row_shift, max_keys; | 272 | int error, row_shift, max_keys; |
280 | 273 | ||
281 | /* Copy the platform data */ | 274 | /* Check i2c driver capabilities */ |
282 | if (pdata) { | 275 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) { |
283 | if (!pdata->keymap_data) { | 276 | dev_err(dev, "%s adapter not supported\n", |
284 | dev_err(dev, "no keymap data defined\n"); | 277 | dev_driver_string(&client->adapter->dev)); |
285 | return -EINVAL; | 278 | return -ENODEV; |
286 | } | ||
287 | keymap_data = pdata->keymap_data; | ||
288 | rows = pdata->rows; | ||
289 | cols = pdata->cols; | ||
290 | rep = pdata->rep; | ||
291 | irq_is_gpio = pdata->irq_is_gpio; | ||
292 | } else { | ||
293 | struct device_node *np = dev->of_node; | ||
294 | int err; | ||
295 | |||
296 | err = matrix_keypad_parse_of_params(dev, &rows, &cols); | ||
297 | if (err) | ||
298 | return err; | ||
299 | rep = of_property_read_bool(np, "keypad,autorepeat"); | ||
300 | } | 279 | } |
301 | 280 | ||
281 | error = matrix_keypad_parse_properties(dev, &rows, &cols); | ||
282 | if (error) | ||
283 | return error; | ||
284 | |||
302 | if (!rows || rows > TCA8418_MAX_ROWS) { | 285 | if (!rows || rows > TCA8418_MAX_ROWS) { |
303 | dev_err(dev, "invalid rows\n"); | 286 | dev_err(dev, "invalid rows\n"); |
304 | return -EINVAL; | 287 | return -EINVAL; |
@@ -309,13 +292,6 @@ static int tca8418_keypad_probe(struct i2c_client *client, | |||
309 | return -EINVAL; | 292 | return -EINVAL; |
310 | } | 293 | } |
311 | 294 | ||
312 | /* Check i2c driver capabilities */ | ||
313 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) { | ||
314 | dev_err(dev, "%s adapter not supported\n", | ||
315 | dev_driver_string(&client->adapter->dev)); | ||
316 | return -ENODEV; | ||
317 | } | ||
318 | |||
319 | row_shift = get_count_order(cols); | 295 | row_shift = get_count_order(cols); |
320 | max_keys = rows << row_shift; | 296 | max_keys = rows << row_shift; |
321 | 297 | ||
@@ -345,27 +321,20 @@ static int tca8418_keypad_probe(struct i2c_client *client, | |||
345 | input->id.product = 0x001; | 321 | input->id.product = 0x001; |
346 | input->id.version = 0x0001; | 322 | input->id.version = 0x0001; |
347 | 323 | ||
348 | error = matrix_keypad_build_keymap(keymap_data, NULL, rows, cols, | 324 | error = matrix_keypad_build_keymap(NULL, NULL, rows, cols, NULL, input); |
349 | NULL, input); | ||
350 | if (error) { | 325 | if (error) { |
351 | dev_err(dev, "Failed to build keymap\n"); | 326 | dev_err(dev, "Failed to build keymap\n"); |
352 | return error; | 327 | return error; |
353 | } | 328 | } |
354 | 329 | ||
355 | if (rep) | 330 | if (device_property_read_bool(dev, "keypad,autorepeat")) |
356 | __set_bit(EV_REP, input->evbit); | 331 | __set_bit(EV_REP, input->evbit); |
357 | input_set_capability(input, EV_MSC, MSC_SCAN); | ||
358 | |||
359 | input_set_drvdata(input, keypad_data); | ||
360 | 332 | ||
361 | irq = client->irq; | 333 | input_set_capability(input, EV_MSC, MSC_SCAN); |
362 | if (irq_is_gpio) | ||
363 | irq = gpio_to_irq(irq); | ||
364 | 334 | ||
365 | error = devm_request_threaded_irq(dev, irq, NULL, tca8418_irq_handler, | 335 | error = devm_request_threaded_irq(dev, client->irq, |
366 | IRQF_TRIGGER_FALLING | | 336 | NULL, tca8418_irq_handler, |
367 | IRQF_SHARED | | 337 | IRQF_SHARED | IRQF_ONESHOT, |
368 | IRQF_ONESHOT, | ||
369 | client->name, keypad_data); | 338 | client->name, keypad_data); |
370 | if (error) { | 339 | if (error) { |
371 | dev_err(dev, "Unable to claim irq %d; error %d\n", | 340 | dev_err(dev, "Unable to claim irq %d; error %d\n", |
@@ -384,30 +353,21 @@ static int tca8418_keypad_probe(struct i2c_client *client, | |||
384 | } | 353 | } |
385 | 354 | ||
386 | static const struct i2c_device_id tca8418_id[] = { | 355 | static const struct i2c_device_id tca8418_id[] = { |
387 | { TCA8418_NAME, 8418, }, | 356 | { "tca8418", 8418, }, |
388 | { } | 357 | { } |
389 | }; | 358 | }; |
390 | MODULE_DEVICE_TABLE(i2c, tca8418_id); | 359 | MODULE_DEVICE_TABLE(i2c, tca8418_id); |
391 | 360 | ||
392 | #ifdef CONFIG_OF | ||
393 | static const struct of_device_id tca8418_dt_ids[] = { | 361 | static const struct of_device_id tca8418_dt_ids[] = { |
394 | { .compatible = "ti,tca8418", }, | 362 | { .compatible = "ti,tca8418", }, |
395 | { } | 363 | { } |
396 | }; | 364 | }; |
397 | MODULE_DEVICE_TABLE(of, tca8418_dt_ids); | 365 | MODULE_DEVICE_TABLE(of, tca8418_dt_ids); |
398 | 366 | ||
399 | /* | ||
400 | * The device tree based i2c loader looks for | ||
401 | * "i2c:" + second_component_of(property("compatible")) | ||
402 | * and therefore we need an alias to be found. | ||
403 | */ | ||
404 | MODULE_ALIAS("i2c:tca8418"); | ||
405 | #endif | ||
406 | |||
407 | static struct i2c_driver tca8418_keypad_driver = { | 367 | static struct i2c_driver tca8418_keypad_driver = { |
408 | .driver = { | 368 | .driver = { |
409 | .name = TCA8418_NAME, | 369 | .name = "tca8418_keypad", |
410 | .of_match_table = of_match_ptr(tca8418_dt_ids), | 370 | .of_match_table = tca8418_dt_ids, |
411 | }, | 371 | }, |
412 | .probe = tca8418_keypad_probe, | 372 | .probe = tca8418_keypad_probe, |
413 | .id_table = tca8418_id, | 373 | .id_table = tca8418_id, |
diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c new file mode 100644 index 000000000000..485900f953e0 --- /dev/null +++ b/drivers/input/keyboard/tm2-touchkey.c | |||
@@ -0,0 +1,284 @@ | |||
1 | /* | ||
2 | * TM2 touchkey device driver | ||
3 | * | ||
4 | * Copyright 2005 Phil Blundell | ||
5 | * Copyright 2016 Samsung Electronics Co., Ltd. | ||
6 | * | ||
7 | * Author: Beomho Seo <beomho.seo@samsung.com> | ||
8 | * Author: Jaechul Lee <jcsing.lee@samsung.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | */ | ||
14 | |||
15 | #include <linux/bitops.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/device.h> | ||
18 | #include <linux/i2c.h> | ||
19 | #include <linux/input.h> | ||
20 | #include <linux/interrupt.h> | ||
21 | #include <linux/irq.h> | ||
22 | #include <linux/leds.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/of.h> | ||
25 | #include <linux/pm.h> | ||
26 | #include <linux/regulator/consumer.h> | ||
27 | |||
28 | #define TM2_TOUCHKEY_DEV_NAME "tm2-touchkey" | ||
29 | #define TM2_TOUCHKEY_KEYCODE_REG 0x03 | ||
30 | #define TM2_TOUCHKEY_BASE_REG 0x00 | ||
31 | #define TM2_TOUCHKEY_CMD_LED_ON 0x10 | ||
32 | #define TM2_TOUCHKEY_CMD_LED_OFF 0x20 | ||
33 | #define TM2_TOUCHKEY_BIT_PRESS_EV BIT(3) | ||
34 | #define TM2_TOUCHKEY_BIT_KEYCODE GENMASK(2, 0) | ||
35 | #define TM2_TOUCHKEY_LED_VOLTAGE_MIN 2500000 | ||
36 | #define TM2_TOUCHKEY_LED_VOLTAGE_MAX 3300000 | ||
37 | |||
38 | enum { | ||
39 | TM2_TOUCHKEY_KEY_MENU = 0x1, | ||
40 | TM2_TOUCHKEY_KEY_BACK, | ||
41 | }; | ||
42 | |||
43 | struct tm2_touchkey_data { | ||
44 | struct i2c_client *client; | ||
45 | struct input_dev *input_dev; | ||
46 | struct led_classdev led_dev; | ||
47 | struct regulator *vdd; | ||
48 | struct regulator_bulk_data regulators[2]; | ||
49 | }; | ||
50 | |||
51 | static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev, | ||
52 | enum led_brightness brightness) | ||
53 | { | ||
54 | struct tm2_touchkey_data *touchkey = | ||
55 | container_of(led_dev, struct tm2_touchkey_data, led_dev); | ||
56 | u32 volt; | ||
57 | u8 data; | ||
58 | |||
59 | if (brightness == LED_OFF) { | ||
60 | volt = TM2_TOUCHKEY_LED_VOLTAGE_MIN; | ||
61 | data = TM2_TOUCHKEY_CMD_LED_OFF; | ||
62 | } else { | ||
63 | volt = TM2_TOUCHKEY_LED_VOLTAGE_MAX; | ||
64 | data = TM2_TOUCHKEY_CMD_LED_ON; | ||
65 | } | ||
66 | |||
67 | regulator_set_voltage(touchkey->vdd, volt, volt); | ||
68 | i2c_smbus_write_byte_data(touchkey->client, | ||
69 | TM2_TOUCHKEY_BASE_REG, data); | ||
70 | } | ||
71 | |||
72 | static int tm2_touchkey_power_enable(struct tm2_touchkey_data *touchkey) | ||
73 | { | ||
74 | int error; | ||
75 | |||
76 | error = regulator_bulk_enable(ARRAY_SIZE(touchkey->regulators), | ||
77 | touchkey->regulators); | ||
78 | if (error) | ||
79 | return error; | ||
80 | |||
81 | /* waiting for device initialization, at least 150ms */ | ||
82 | msleep(150); | ||
83 | |||
84 | return 0; | ||
85 | } | ||
86 | |||
87 | static void tm2_touchkey_power_disable(void *data) | ||
88 | { | ||
89 | struct tm2_touchkey_data *touchkey = data; | ||
90 | |||
91 | regulator_bulk_disable(ARRAY_SIZE(touchkey->regulators), | ||
92 | touchkey->regulators); | ||
93 | } | ||
94 | |||
95 | static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid) | ||
96 | { | ||
97 | struct tm2_touchkey_data *touchkey = devid; | ||
98 | int data; | ||
99 | int key; | ||
100 | |||
101 | data = i2c_smbus_read_byte_data(touchkey->client, | ||
102 | TM2_TOUCHKEY_KEYCODE_REG); | ||
103 | if (data < 0) { | ||
104 | dev_err(&touchkey->client->dev, | ||
105 | "failed to read i2c data: %d\n", data); | ||
106 | goto out; | ||
107 | } | ||
108 | |||
109 | switch (data & TM2_TOUCHKEY_BIT_KEYCODE) { | ||
110 | case TM2_TOUCHKEY_KEY_MENU: | ||
111 | key = KEY_PHONE; | ||
112 | break; | ||
113 | |||
114 | case TM2_TOUCHKEY_KEY_BACK: | ||
115 | key = KEY_BACK; | ||
116 | break; | ||
117 | |||
118 | default: | ||
119 | dev_warn(&touchkey->client->dev, | ||
120 | "unhandled keycode, data %#02x\n", data); | ||
121 | goto out; | ||
122 | } | ||
123 | |||
124 | if (data & TM2_TOUCHKEY_BIT_PRESS_EV) { | ||
125 | input_report_key(touchkey->input_dev, KEY_PHONE, 0); | ||
126 | input_report_key(touchkey->input_dev, KEY_BACK, 0); | ||
127 | } else { | ||
128 | input_report_key(touchkey->input_dev, key, 1); | ||
129 | } | ||
130 | |||
131 | input_sync(touchkey->input_dev); | ||
132 | |||
133 | out: | ||
134 | return IRQ_HANDLED; | ||
135 | } | ||
136 | |||
137 | static int tm2_touchkey_probe(struct i2c_client *client, | ||
138 | const struct i2c_device_id *id) | ||
139 | { | ||
140 | struct tm2_touchkey_data *touchkey; | ||
141 | int error; | ||
142 | |||
143 | if (!i2c_check_functionality(client->adapter, | ||
144 | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA)) { | ||
145 | dev_err(&client->dev, "incompatible I2C adapter\n"); | ||
146 | return -EIO; | ||
147 | } | ||
148 | |||
149 | touchkey = devm_kzalloc(&client->dev, sizeof(*touchkey), GFP_KERNEL); | ||
150 | if (!touchkey) | ||
151 | return -ENOMEM; | ||
152 | |||
153 | touchkey->client = client; | ||
154 | i2c_set_clientdata(client, touchkey); | ||
155 | |||
156 | touchkey->regulators[0].supply = "vcc"; | ||
157 | touchkey->regulators[1].supply = "vdd"; | ||
158 | error = devm_regulator_bulk_get(&client->dev, | ||
159 | ARRAY_SIZE(touchkey->regulators), | ||
160 | touchkey->regulators); | ||
161 | if (error) { | ||
162 | dev_err(&client->dev, "failed to get regulators: %d\n", error); | ||
163 | return error; | ||
164 | } | ||
165 | |||
166 | /* Save VDD for easy access */ | ||
167 | touchkey->vdd = touchkey->regulators[1].consumer; | ||
168 | |||
169 | error = tm2_touchkey_power_enable(touchkey); | ||
170 | if (error) { | ||
171 | dev_err(&client->dev, "failed to power up device: %d\n", error); | ||
172 | return error; | ||
173 | } | ||
174 | |||
175 | error = devm_add_action_or_reset(&client->dev, | ||
176 | tm2_touchkey_power_disable, touchkey); | ||
177 | if (error) { | ||
178 | dev_err(&client->dev, | ||
179 | "failed to install poweroff handler: %d\n", error); | ||
180 | return error; | ||
181 | } | ||
182 | |||
183 | /* input device */ | ||
184 | touchkey->input_dev = devm_input_allocate_device(&client->dev); | ||
185 | if (!touchkey->input_dev) { | ||
186 | dev_err(&client->dev, "failed to allocate input device\n"); | ||
187 | return -ENOMEM; | ||
188 | } | ||
189 | |||
190 | touchkey->input_dev->name = TM2_TOUCHKEY_DEV_NAME; | ||
191 | touchkey->input_dev->id.bustype = BUS_I2C; | ||
192 | |||
193 | input_set_capability(touchkey->input_dev, EV_KEY, KEY_PHONE); | ||
194 | input_set_capability(touchkey->input_dev, EV_KEY, KEY_BACK); | ||
195 | |||
196 | error = input_register_device(touchkey->input_dev); | ||
197 | if (error) { | ||
198 | dev_err(&client->dev, | ||
199 | "failed to register input device: %d\n", error); | ||
200 | return error; | ||
201 | } | ||
202 | |||
203 | error = devm_request_threaded_irq(&client->dev, client->irq, | ||
204 | NULL, tm2_touchkey_irq_handler, | ||
205 | IRQF_ONESHOT, | ||
206 | TM2_TOUCHKEY_DEV_NAME, touchkey); | ||
207 | if (error) { | ||
208 | dev_err(&client->dev, | ||
209 | "failed to request threaded irq: %d\n", error); | ||
210 | return error; | ||
211 | } | ||
212 | |||
213 | /* led device */ | ||
214 | touchkey->led_dev.name = TM2_TOUCHKEY_DEV_NAME; | ||
215 | touchkey->led_dev.brightness = LED_FULL; | ||
216 | touchkey->led_dev.max_brightness = LED_FULL; | ||
217 | touchkey->led_dev.brightness_set = tm2_touchkey_led_brightness_set; | ||
218 | |||
219 | error = devm_led_classdev_register(&client->dev, &touchkey->led_dev); | ||
220 | if (error) { | ||
221 | dev_err(&client->dev, | ||
222 | "failed to register touchkey led: %d\n", error); | ||
223 | return error; | ||
224 | } | ||
225 | |||
226 | return 0; | ||
227 | } | ||
228 | |||
229 | static int __maybe_unused tm2_touchkey_suspend(struct device *dev) | ||
230 | { | ||
231 | struct i2c_client *client = to_i2c_client(dev); | ||
232 | struct tm2_touchkey_data *touchkey = i2c_get_clientdata(client); | ||
233 | |||
234 | disable_irq(client->irq); | ||
235 | tm2_touchkey_power_disable(touchkey); | ||
236 | |||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | static int __maybe_unused tm2_touchkey_resume(struct device *dev) | ||
241 | { | ||
242 | struct i2c_client *client = to_i2c_client(dev); | ||
243 | struct tm2_touchkey_data *touchkey = i2c_get_clientdata(client); | ||
244 | int ret; | ||
245 | |||
246 | enable_irq(client->irq); | ||
247 | |||
248 | ret = tm2_touchkey_power_enable(touchkey); | ||
249 | if (ret) | ||
250 | dev_err(dev, "failed to enable power: %d\n", ret); | ||
251 | |||
252 | return ret; | ||
253 | } | ||
254 | |||
255 | static SIMPLE_DEV_PM_OPS(tm2_touchkey_pm_ops, | ||
256 | tm2_touchkey_suspend, tm2_touchkey_resume); | ||
257 | |||
258 | static const struct i2c_device_id tm2_touchkey_id_table[] = { | ||
259 | { TM2_TOUCHKEY_DEV_NAME, 0 }, | ||
260 | { }, | ||
261 | }; | ||
262 | MODULE_DEVICE_TABLE(i2c, tm2_touchkey_id_table); | ||
263 | |||
264 | static const struct of_device_id tm2_touchkey_of_match[] = { | ||
265 | { .compatible = "cypress,tm2-touchkey", }, | ||
266 | { }, | ||
267 | }; | ||
268 | MODULE_DEVICE_TABLE(of, tm2_touchkey_of_match); | ||
269 | |||
270 | static struct i2c_driver tm2_touchkey_driver = { | ||
271 | .driver = { | ||
272 | .name = TM2_TOUCHKEY_DEV_NAME, | ||
273 | .pm = &tm2_touchkey_pm_ops, | ||
274 | .of_match_table = of_match_ptr(tm2_touchkey_of_match), | ||
275 | }, | ||
276 | .probe = tm2_touchkey_probe, | ||
277 | .id_table = tm2_touchkey_id_table, | ||
278 | }; | ||
279 | module_i2c_driver(tm2_touchkey_driver); | ||
280 | |||
281 | MODULE_AUTHOR("Beomho Seo <beomho.seo@samsung.com>"); | ||
282 | MODULE_AUTHOR("Jaechul Lee <jcsing.lee@samsung.com>"); | ||
283 | MODULE_DESCRIPTION("Samsung touchkey driver"); | ||
284 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c index 323a0fb575a4..39e72b3219d8 100644 --- a/drivers/input/keyboard/twl4030_keypad.c +++ b/drivers/input/keyboard/twl4030_keypad.c | |||
@@ -374,8 +374,8 @@ static int twl4030_kp_probe(struct platform_device *pdev) | |||
374 | kp->autorepeat = pdata->rep; | 374 | kp->autorepeat = pdata->rep; |
375 | keymap_data = pdata->keymap_data; | 375 | keymap_data = pdata->keymap_data; |
376 | } else { | 376 | } else { |
377 | error = matrix_keypad_parse_of_params(&pdev->dev, &kp->n_rows, | 377 | error = matrix_keypad_parse_properties(&pdev->dev, &kp->n_rows, |
378 | &kp->n_cols); | 378 | &kp->n_cols); |
379 | if (error) | 379 | if (error) |
380 | return error; | 380 | return error; |
381 | 381 | ||
@@ -441,7 +441,6 @@ static int twl4030_kp_probe(struct platform_device *pdev) | |||
441 | return -EIO; | 441 | return -EIO; |
442 | } | 442 | } |
443 | 443 | ||
444 | platform_set_drvdata(pdev, kp); | ||
445 | return 0; | 444 | return 0; |
446 | } | 445 | } |
447 | 446 | ||
diff --git a/drivers/input/matrix-keymap.c b/drivers/input/matrix-keymap.c index 08b61f506db6..8ccefc15c7a4 100644 --- a/drivers/input/matrix-keymap.c +++ b/drivers/input/matrix-keymap.c | |||
@@ -14,18 +14,18 @@ | |||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. | 16 | * GNU General Public License for more details. |
17 | * | ||
18 | */ | 17 | */ |
19 | 18 | ||
20 | #include <linux/device.h> | 19 | #include <linux/device.h> |
20 | #include <linux/export.h> | ||
21 | #include <linux/gfp.h> | 21 | #include <linux/gfp.h> |
22 | #include <linux/kernel.h> | ||
23 | #include <linux/types.h> | ||
24 | #include <linux/input.h> | 22 | #include <linux/input.h> |
25 | #include <linux/of.h> | ||
26 | #include <linux/export.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <linux/input/matrix_keypad.h> | 23 | #include <linux/input/matrix_keypad.h> |
24 | #include <linux/kernel.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/property.h> | ||
27 | #include <linux/slab.h> | ||
28 | #include <linux/types.h> | ||
29 | 29 | ||
30 | static bool matrix_keypad_map_key(struct input_dev *input_dev, | 30 | static bool matrix_keypad_map_key(struct input_dev *input_dev, |
31 | unsigned int rows, unsigned int cols, | 31 | unsigned int rows, unsigned int cols, |
@@ -49,18 +49,22 @@ static bool matrix_keypad_map_key(struct input_dev *input_dev, | |||
49 | return true; | 49 | return true; |
50 | } | 50 | } |
51 | 51 | ||
52 | #ifdef CONFIG_OF | 52 | /** |
53 | int matrix_keypad_parse_of_params(struct device *dev, | 53 | * matrix_keypad_parse_properties() - Read properties of matrix keypad |
54 | unsigned int *rows, unsigned int *cols) | 54 | * |
55 | * @dev: Device containing properties | ||
56 | * @rows: Returns number of matrix rows | ||
57 | * @cols: Returns number of matrix columns | ||
58 | * @return 0 if OK, <0 on error | ||
59 | */ | ||
60 | int matrix_keypad_parse_properties(struct device *dev, | ||
61 | unsigned int *rows, unsigned int *cols) | ||
55 | { | 62 | { |
56 | struct device_node *np = dev->of_node; | 63 | *rows = *cols = 0; |
64 | |||
65 | device_property_read_u32(dev, "keypad,num-rows", rows); | ||
66 | device_property_read_u32(dev, "keypad,num-columns", cols); | ||
57 | 67 | ||
58 | if (!np) { | ||
59 | dev_err(dev, "missing DT data"); | ||
60 | return -EINVAL; | ||
61 | } | ||
62 | of_property_read_u32(np, "keypad,num-rows", rows); | ||
63 | of_property_read_u32(np, "keypad,num-columns", cols); | ||
64 | if (!*rows || !*cols) { | 68 | if (!*rows || !*cols) { |
65 | dev_err(dev, "number of keypad rows/columns not specified\n"); | 69 | dev_err(dev, "number of keypad rows/columns not specified\n"); |
66 | return -EINVAL; | 70 | return -EINVAL; |
@@ -68,62 +72,61 @@ int matrix_keypad_parse_of_params(struct device *dev, | |||
68 | 72 | ||
69 | return 0; | 73 | return 0; |
70 | } | 74 | } |
71 | EXPORT_SYMBOL_GPL(matrix_keypad_parse_of_params); | 75 | EXPORT_SYMBOL_GPL(matrix_keypad_parse_properties); |
72 | 76 | ||
73 | static int matrix_keypad_parse_of_keymap(const char *propname, | 77 | static int matrix_keypad_parse_keymap(const char *propname, |
74 | unsigned int rows, unsigned int cols, | 78 | unsigned int rows, unsigned int cols, |
75 | struct input_dev *input_dev) | 79 | struct input_dev *input_dev) |
76 | { | 80 | { |
77 | struct device *dev = input_dev->dev.parent; | 81 | struct device *dev = input_dev->dev.parent; |
78 | struct device_node *np = dev->of_node; | ||
79 | unsigned int row_shift = get_count_order(cols); | 82 | unsigned int row_shift = get_count_order(cols); |
80 | unsigned int max_keys = rows << row_shift; | 83 | unsigned int max_keys = rows << row_shift; |
81 | unsigned int proplen, i, size; | 84 | u32 *keys; |
82 | const __be32 *prop; | 85 | int i; |
83 | 86 | int size; | |
84 | if (!np) | 87 | int retval; |
85 | return -ENOENT; | ||
86 | 88 | ||
87 | if (!propname) | 89 | if (!propname) |
88 | propname = "linux,keymap"; | 90 | propname = "linux,keymap"; |
89 | 91 | ||
90 | prop = of_get_property(np, propname, &proplen); | 92 | size = device_property_read_u32_array(dev, propname, NULL, 0); |
91 | if (!prop) { | 93 | if (size <= 0) { |
92 | dev_err(dev, "OF: %s property not defined in %s\n", | 94 | dev_err(dev, "missing or malformed property %s: %d\n", |
93 | propname, np->full_name); | 95 | propname, size); |
94 | return -ENOENT; | 96 | return size < 0 ? size : -EINVAL; |
95 | } | 97 | } |
96 | 98 | ||
97 | if (proplen % sizeof(u32)) { | 99 | if (size > max_keys) { |
98 | dev_err(dev, "OF: Malformed keycode property %s in %s\n", | 100 | dev_err(dev, "%s size overflow (%d vs max %u)\n", |
99 | propname, np->full_name); | 101 | propname, size, max_keys); |
100 | return -EINVAL; | 102 | return -EINVAL; |
101 | } | 103 | } |
102 | 104 | ||
103 | size = proplen / sizeof(u32); | 105 | keys = kmalloc_array(size, sizeof(u32), GFP_KERNEL); |
104 | if (size > max_keys) { | 106 | if (!keys) |
105 | dev_err(dev, "OF: %s size overflow\n", propname); | 107 | return -ENOMEM; |
106 | return -EINVAL; | 108 | |
109 | retval = device_property_read_u32_array(dev, propname, keys, size); | ||
110 | if (retval) { | ||
111 | dev_err(dev, "failed to read %s property: %d\n", | ||
112 | propname, retval); | ||
113 | goto out; | ||
107 | } | 114 | } |
108 | 115 | ||
109 | for (i = 0; i < size; i++) { | 116 | for (i = 0; i < size; i++) { |
110 | unsigned int key = be32_to_cpup(prop + i); | ||
111 | |||
112 | if (!matrix_keypad_map_key(input_dev, rows, cols, | 117 | if (!matrix_keypad_map_key(input_dev, rows, cols, |
113 | row_shift, key)) | 118 | row_shift, keys[i])) { |
114 | return -EINVAL; | 119 | retval = -EINVAL; |
120 | goto out; | ||
121 | } | ||
115 | } | 122 | } |
116 | 123 | ||
117 | return 0; | 124 | retval = 0; |
118 | } | 125 | |
119 | #else | 126 | out: |
120 | static int matrix_keypad_parse_of_keymap(const char *propname, | 127 | kfree(keys); |
121 | unsigned int rows, unsigned int cols, | 128 | return retval; |
122 | struct input_dev *input_dev) | ||
123 | { | ||
124 | return -ENOSYS; | ||
125 | } | 129 | } |
126 | #endif | ||
127 | 130 | ||
128 | /** | 131 | /** |
129 | * matrix_keypad_build_keymap - convert platform keymap into matrix keymap | 132 | * matrix_keypad_build_keymap - convert platform keymap into matrix keymap |
@@ -192,8 +195,8 @@ int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data, | |||
192 | return -EINVAL; | 195 | return -EINVAL; |
193 | } | 196 | } |
194 | } else { | 197 | } else { |
195 | error = matrix_keypad_parse_of_keymap(keymap_name, rows, cols, | 198 | error = matrix_keypad_parse_keymap(keymap_name, rows, cols, |
196 | input_dev); | 199 | input_dev); |
197 | if (error) | 200 | if (error) |
198 | return error; | 201 | return error; |
199 | } | 202 | } |
diff --git a/drivers/input/misc/88pm80x_onkey.c b/drivers/input/misc/88pm80x_onkey.c index cf9908f1e5d5..45a09497f680 100644 --- a/drivers/input/misc/88pm80x_onkey.c +++ b/drivers/input/misc/88pm80x_onkey.c | |||
@@ -143,7 +143,6 @@ static int pm80x_onkey_remove(struct platform_device *pdev) | |||
143 | { | 143 | { |
144 | struct pm80x_onkey_info *info = platform_get_drvdata(pdev); | 144 | struct pm80x_onkey_info *info = platform_get_drvdata(pdev); |
145 | 145 | ||
146 | device_init_wakeup(&pdev->dev, 0); | ||
147 | pm80x_free_irq(info->pm80x, info->irq, info); | 146 | pm80x_free_irq(info->pm80x, info->irq, info); |
148 | input_unregister_device(info->idev); | 147 | input_unregister_device(info->idev); |
149 | kfree(info); | 148 | kfree(info); |
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 1ae4d9617ff8..5b6c52210d20 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig | |||
@@ -234,16 +234,6 @@ config INPUT_MMA8450 | |||
234 | To compile this driver as a module, choose M here: the | 234 | To compile this driver as a module, choose M here: the |
235 | module will be called mma8450. | 235 | module will be called mma8450. |
236 | 236 | ||
237 | config INPUT_MPU3050 | ||
238 | tristate "MPU3050 Triaxial gyroscope sensor" | ||
239 | depends on I2C | ||
240 | help | ||
241 | Say Y here if you want to support InvenSense MPU3050 | ||
242 | connected via an I2C bus. | ||
243 | |||
244 | To compile this driver as a module, choose M here: the | ||
245 | module will be called mpu3050. | ||
246 | |||
247 | config INPUT_APANEL | 237 | config INPUT_APANEL |
248 | tristate "Fujitsu Lifebook Application Panel buttons" | 238 | tristate "Fujitsu Lifebook Application Panel buttons" |
249 | depends on X86 && I2C && LEDS_CLASS | 239 | depends on X86 && I2C && LEDS_CLASS |
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 0b6d025f0487..b10523f2878e 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile | |||
@@ -48,7 +48,6 @@ obj-$(CONFIG_INPUT_MAX8925_ONKEY) += max8925_onkey.o | |||
48 | obj-$(CONFIG_INPUT_MAX8997_HAPTIC) += max8997_haptic.o | 48 | obj-$(CONFIG_INPUT_MAX8997_HAPTIC) += max8997_haptic.o |
49 | obj-$(CONFIG_INPUT_MC13783_PWRBUTTON) += mc13783-pwrbutton.o | 49 | obj-$(CONFIG_INPUT_MC13783_PWRBUTTON) += mc13783-pwrbutton.o |
50 | obj-$(CONFIG_INPUT_MMA8450) += mma8450.o | 50 | obj-$(CONFIG_INPUT_MMA8450) += mma8450.o |
51 | obj-$(CONFIG_INPUT_MPU3050) += mpu3050.o | ||
52 | obj-$(CONFIG_INPUT_PALMAS_PWRBUTTON) += palmas-pwrbutton.o | 51 | obj-$(CONFIG_INPUT_PALMAS_PWRBUTTON) += palmas-pwrbutton.o |
53 | obj-$(CONFIG_INPUT_PCAP) += pcap_keys.o | 52 | obj-$(CONFIG_INPUT_PCAP) += pcap_keys.o |
54 | obj-$(CONFIG_INPUT_PCF50633_PMU) += pcf50633-input.o | 53 | obj-$(CONFIG_INPUT_PCF50633_PMU) += pcf50633-input.o |
diff --git a/drivers/input/misc/ab8500-ponkey.c b/drivers/input/misc/ab8500-ponkey.c index 4f5ef5bb535b..a33ed5710b15 100644 --- a/drivers/input/misc/ab8500-ponkey.c +++ b/drivers/input/misc/ab8500-ponkey.c | |||
@@ -109,7 +109,6 @@ static int ab8500_ponkey_probe(struct platform_device *pdev) | |||
109 | return error; | 109 | return error; |
110 | } | 110 | } |
111 | 111 | ||
112 | platform_set_drvdata(pdev, ponkey); | ||
113 | return 0; | 112 | return 0; |
114 | } | 113 | } |
115 | 114 | ||
diff --git a/drivers/input/misc/arizona-haptics.c b/drivers/input/misc/arizona-haptics.c index 07ec465f1095..21dc1b8b2a4a 100644 --- a/drivers/input/misc/arizona-haptics.c +++ b/drivers/input/misc/arizona-haptics.c | |||
@@ -201,8 +201,6 @@ static int arizona_haptics_probe(struct platform_device *pdev) | |||
201 | return ret; | 201 | return ret; |
202 | } | 202 | } |
203 | 203 | ||
204 | platform_set_drvdata(pdev, haptics); | ||
205 | |||
206 | return 0; | 204 | return 0; |
207 | } | 205 | } |
208 | 206 | ||
diff --git a/drivers/input/misc/atmel_captouch.c b/drivers/input/misc/atmel_captouch.c index 941265415a89..c4c0f4bb7627 100644 --- a/drivers/input/misc/atmel_captouch.c +++ b/drivers/input/misc/atmel_captouch.c | |||
@@ -191,7 +191,6 @@ static int atmel_captouch_probe(struct i2c_client *client, | |||
191 | return -ENOMEM; | 191 | return -ENOMEM; |
192 | 192 | ||
193 | capdev->client = client; | 193 | capdev->client = client; |
194 | i2c_set_clientdata(client, capdev); | ||
195 | 194 | ||
196 | err = atmel_read(capdev, REG_KEY_STATE, | 195 | err = atmel_read(capdev, REG_KEY_STATE, |
197 | &capdev->prev_btn, sizeof(capdev->prev_btn)); | 196 | &capdev->prev_btn, sizeof(capdev->prev_btn)); |
diff --git a/drivers/input/misc/bfin_rotary.c b/drivers/input/misc/bfin_rotary.c index a0fc18fdfc0c..799ce3d2820e 100644 --- a/drivers/input/misc/bfin_rotary.c +++ b/drivers/input/misc/bfin_rotary.c | |||
@@ -147,19 +147,18 @@ static int bfin_rotary_probe(struct platform_device *pdev) | |||
147 | 147 | ||
148 | if (pdata->pin_list) { | 148 | if (pdata->pin_list) { |
149 | error = peripheral_request_list(pdata->pin_list, | 149 | error = peripheral_request_list(pdata->pin_list, |
150 | dev_name(&pdev->dev)); | 150 | dev_name(dev)); |
151 | if (error) { | 151 | if (error) { |
152 | dev_err(dev, "requesting peripherals failed: %d\n", | 152 | dev_err(dev, "requesting peripherals failed: %d\n", |
153 | error); | 153 | error); |
154 | return error; | 154 | return error; |
155 | } | 155 | } |
156 | 156 | ||
157 | error = devm_add_action(dev, bfin_rotary_free_action, | 157 | error = devm_add_action_or_reset(dev, bfin_rotary_free_action, |
158 | pdata->pin_list); | 158 | pdata->pin_list); |
159 | if (error) { | 159 | if (error) { |
160 | dev_err(dev, "setting cleanup action failed: %d\n", | 160 | dev_err(dev, "setting cleanup action failed: %d\n", |
161 | error); | 161 | error); |
162 | peripheral_free_list(pdata->pin_list); | ||
163 | return error; | 162 | return error; |
164 | } | 163 | } |
165 | } | 164 | } |
@@ -189,7 +188,7 @@ static int bfin_rotary_probe(struct platform_device *pdev) | |||
189 | 188 | ||
190 | input->name = pdev->name; | 189 | input->name = pdev->name; |
191 | input->phys = "bfin-rotary/input0"; | 190 | input->phys = "bfin-rotary/input0"; |
192 | input->dev.parent = &pdev->dev; | 191 | input->dev.parent = dev; |
193 | 192 | ||
194 | input_set_drvdata(input, rotary); | 193 | input_set_drvdata(input, rotary); |
195 | 194 | ||
@@ -239,7 +238,7 @@ static int bfin_rotary_probe(struct platform_device *pdev) | |||
239 | } | 238 | } |
240 | 239 | ||
241 | platform_set_drvdata(pdev, rotary); | 240 | platform_set_drvdata(pdev, rotary); |
242 | device_init_wakeup(&pdev->dev, 1); | 241 | device_init_wakeup(dev, 1); |
243 | 242 | ||
244 | return 0; | 243 | return 0; |
245 | } | 244 | } |
diff --git a/drivers/input/misc/bma150.c b/drivers/input/misc/bma150.c index 2124390ec38c..1fa85379f86c 100644 --- a/drivers/input/misc/bma150.c +++ b/drivers/input/misc/bma150.c | |||
@@ -207,7 +207,7 @@ static int bma150_set_mode(struct bma150_data *bma150, u8 mode) | |||
207 | return error; | 207 | return error; |
208 | 208 | ||
209 | if (mode == BMA150_MODE_NORMAL) | 209 | if (mode == BMA150_MODE_NORMAL) |
210 | msleep(2); | 210 | usleep_range(2000, 2100); |
211 | 211 | ||
212 | bma150->mode = mode; | 212 | bma150->mode = mode; |
213 | return 0; | 213 | return 0; |
@@ -222,7 +222,7 @@ static int bma150_soft_reset(struct bma150_data *bma150) | |||
222 | if (error) | 222 | if (error) |
223 | return error; | 223 | return error; |
224 | 224 | ||
225 | msleep(2); | 225 | usleep_range(2000, 2100); |
226 | return 0; | 226 | return 0; |
227 | } | 227 | } |
228 | 228 | ||
diff --git a/drivers/input/misc/da9063_onkey.c b/drivers/input/misc/da9063_onkey.c index b4ff1e86d3d3..3e9c353d82ef 100644 --- a/drivers/input/misc/da9063_onkey.c +++ b/drivers/input/misc/da9063_onkey.c | |||
@@ -287,7 +287,6 @@ static int da9063_onkey_probe(struct platform_device *pdev) | |||
287 | return error; | 287 | return error; |
288 | } | 288 | } |
289 | 289 | ||
290 | platform_set_drvdata(pdev, onkey); | ||
291 | return 0; | 290 | return 0; |
292 | } | 291 | } |
293 | 292 | ||
diff --git a/drivers/input/misc/dm355evm_keys.c b/drivers/input/misc/dm355evm_keys.c index b6b7bd4e5462..82e272ebc0ed 100644 --- a/drivers/input/misc/dm355evm_keys.c +++ b/drivers/input/misc/dm355evm_keys.c | |||
@@ -195,8 +195,6 @@ static int dm355evm_keys_probe(struct platform_device *pdev) | |||
195 | goto fail1; | 195 | goto fail1; |
196 | keys->irq = status; | 196 | keys->irq = status; |
197 | 197 | ||
198 | input_set_drvdata(input, keys); | ||
199 | |||
200 | input->name = "DM355 EVM Controls"; | 198 | input->name = "DM355 EVM Controls"; |
201 | input->phys = "dm355evm/input0"; | 199 | input->phys = "dm355evm/input0"; |
202 | input->dev.parent = &pdev->dev; | 200 | input->dev.parent = &pdev->dev; |
diff --git a/drivers/input/misc/drv260x.c b/drivers/input/misc/drv260x.c index 0a2b865b1000..fb089d36c0d6 100644 --- a/drivers/input/misc/drv260x.c +++ b/drivers/input/misc/drv260x.c | |||
@@ -538,7 +538,7 @@ static int drv260x_probe(struct i2c_client *client, | |||
538 | 538 | ||
539 | haptics->input_dev = devm_input_allocate_device(dev); | 539 | haptics->input_dev = devm_input_allocate_device(dev); |
540 | if (!haptics->input_dev) { | 540 | if (!haptics->input_dev) { |
541 | dev_err(&client->dev, "Failed to allocate input device\n"); | 541 | dev_err(dev, "Failed to allocate input device\n"); |
542 | return -ENOMEM; | 542 | return -ENOMEM; |
543 | } | 543 | } |
544 | 544 | ||
diff --git a/drivers/input/misc/e3x0-button.c b/drivers/input/misc/e3x0-button.c index 13bfca8a7b16..e956cf1d273f 100644 --- a/drivers/input/misc/e3x0-button.c +++ b/drivers/input/misc/e3x0-button.c | |||
@@ -120,17 +120,10 @@ static int e3x0_button_probe(struct platform_device *pdev) | |||
120 | return error; | 120 | return error; |
121 | } | 121 | } |
122 | 122 | ||
123 | platform_set_drvdata(pdev, input); | ||
124 | device_init_wakeup(&pdev->dev, 1); | 123 | device_init_wakeup(&pdev->dev, 1); |
125 | return 0; | 124 | return 0; |
126 | } | 125 | } |
127 | 126 | ||
128 | static int e3x0_button_remove(struct platform_device *pdev) | ||
129 | { | ||
130 | device_init_wakeup(&pdev->dev, 0); | ||
131 | return 0; | ||
132 | } | ||
133 | |||
134 | #ifdef CONFIG_OF | 127 | #ifdef CONFIG_OF |
135 | static const struct of_device_id e3x0_button_match[] = { | 128 | static const struct of_device_id e3x0_button_match[] = { |
136 | { .compatible = "ettus,e3x0-button", }, | 129 | { .compatible = "ettus,e3x0-button", }, |
@@ -146,7 +139,6 @@ static struct platform_driver e3x0_button_driver = { | |||
146 | .pm = &e3x0_button_pm_ops, | 139 | .pm = &e3x0_button_pm_ops, |
147 | }, | 140 | }, |
148 | .probe = e3x0_button_probe, | 141 | .probe = e3x0_button_probe, |
149 | .remove = e3x0_button_remove, | ||
150 | }; | 142 | }; |
151 | 143 | ||
152 | module_platform_driver(e3x0_button_driver); | 144 | module_platform_driver(e3x0_button_driver); |
diff --git a/drivers/input/misc/gp2ap002a00f.c b/drivers/input/misc/gp2ap002a00f.c index 3bfdfcc20485..c6a29e57b5e4 100644 --- a/drivers/input/misc/gp2ap002a00f.c +++ b/drivers/input/misc/gp2ap002a00f.c | |||
@@ -210,8 +210,6 @@ static int gp2a_remove(struct i2c_client *client) | |||
210 | struct gp2a_data *dt = i2c_get_clientdata(client); | 210 | struct gp2a_data *dt = i2c_get_clientdata(client); |
211 | const struct gp2a_platform_data *pdata = dt->pdata; | 211 | const struct gp2a_platform_data *pdata = dt->pdata; |
212 | 212 | ||
213 | device_init_wakeup(&client->dev, false); | ||
214 | |||
215 | free_irq(client->irq, dt); | 213 | free_irq(client->irq, dt); |
216 | 214 | ||
217 | input_unregister_device(dt->input); | 215 | input_unregister_device(dt->input); |
diff --git a/drivers/input/misc/gpio_decoder.c b/drivers/input/misc/gpio_decoder.c index ca7e0bacb2d8..1dca526e6f1a 100644 --- a/drivers/input/misc/gpio_decoder.c +++ b/drivers/input/misc/gpio_decoder.c | |||
@@ -110,7 +110,6 @@ static int gpio_decoder_probe(struct platform_device *pdev) | |||
110 | dev_err(dev, "failed to register polled device\n"); | 110 | dev_err(dev, "failed to register polled device\n"); |
111 | return err; | 111 | return err; |
112 | } | 112 | } |
113 | platform_set_drvdata(pdev, decoder); | ||
114 | 113 | ||
115 | return 0; | 114 | return 0; |
116 | } | 115 | } |
diff --git a/drivers/input/misc/gpio_tilt_polled.c b/drivers/input/misc/gpio_tilt_polled.c index f103b99d1852..6e217a45e39a 100644 --- a/drivers/input/misc/gpio_tilt_polled.c +++ b/drivers/input/misc/gpio_tilt_polled.c | |||
@@ -138,7 +138,7 @@ static int gpio_tilt_polled_probe(struct platform_device *pdev) | |||
138 | 138 | ||
139 | input->name = pdev->name; | 139 | input->name = pdev->name; |
140 | input->phys = DRV_NAME"/input0"; | 140 | input->phys = DRV_NAME"/input0"; |
141 | input->dev.parent = &pdev->dev; | 141 | input->dev.parent = dev; |
142 | 142 | ||
143 | input->id.bustype = BUS_HOST; | 143 | input->id.bustype = BUS_HOST; |
144 | input->id.vendor = 0x0001; | 144 | input->id.vendor = 0x0001; |
diff --git a/drivers/input/misc/hisi_powerkey.c b/drivers/input/misc/hisi_powerkey.c index 675539c529ce..dee6245f38d7 100644 --- a/drivers/input/misc/hisi_powerkey.c +++ b/drivers/input/misc/hisi_powerkey.c | |||
@@ -75,9 +75,9 @@ static int hi65xx_powerkey_probe(struct platform_device *pdev) | |||
75 | struct input_dev *input; | 75 | struct input_dev *input; |
76 | int irq, i, error; | 76 | int irq, i, error; |
77 | 77 | ||
78 | input = devm_input_allocate_device(&pdev->dev); | 78 | input = devm_input_allocate_device(dev); |
79 | if (!input) { | 79 | if (!input) { |
80 | dev_err(&pdev->dev, "failed to allocate input device\n"); | 80 | dev_err(dev, "failed to allocate input device\n"); |
81 | return -ENOMEM; | 81 | return -ENOMEM; |
82 | } | 82 | } |
83 | 83 | ||
@@ -111,19 +111,11 @@ static int hi65xx_powerkey_probe(struct platform_device *pdev) | |||
111 | 111 | ||
112 | error = input_register_device(input); | 112 | error = input_register_device(input); |
113 | if (error) { | 113 | if (error) { |
114 | dev_err(&pdev->dev, "failed to register input device: %d\n", | 114 | dev_err(dev, "failed to register input device: %d\n", error); |
115 | error); | ||
116 | return error; | 115 | return error; |
117 | } | 116 | } |
118 | 117 | ||
119 | device_init_wakeup(&pdev->dev, 1); | 118 | device_init_wakeup(dev, 1); |
120 | |||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | static int hi65xx_powerkey_remove(struct platform_device *pdev) | ||
125 | { | ||
126 | device_init_wakeup(&pdev->dev, 0); | ||
127 | 119 | ||
128 | return 0; | 120 | return 0; |
129 | } | 121 | } |
@@ -133,7 +125,6 @@ static struct platform_driver hi65xx_powerkey_driver = { | |||
133 | .name = "hi65xx-powerkey", | 125 | .name = "hi65xx-powerkey", |
134 | }, | 126 | }, |
135 | .probe = hi65xx_powerkey_probe, | 127 | .probe = hi65xx_powerkey_probe, |
136 | .remove = hi65xx_powerkey_remove, | ||
137 | }; | 128 | }; |
138 | module_platform_driver(hi65xx_powerkey_driver); | 129 | module_platform_driver(hi65xx_powerkey_driver); |
139 | 130 | ||
diff --git a/drivers/input/misc/mma8450.c b/drivers/input/misc/mma8450.c index 19c73574458e..b60cdea73826 100644 --- a/drivers/input/misc/mma8450.c +++ b/drivers/input/misc/mma8450.c | |||
@@ -205,8 +205,6 @@ static int mma8450_probe(struct i2c_client *c, | |||
205 | return err; | 205 | return err; |
206 | } | 206 | } |
207 | 207 | ||
208 | i2c_set_clientdata(c, m); | ||
209 | |||
210 | return 0; | 208 | return 0; |
211 | } | 209 | } |
212 | 210 | ||
diff --git a/drivers/input/misc/mpu3050.c b/drivers/input/misc/mpu3050.c deleted file mode 100644 index f088db31cfc7..000000000000 --- a/drivers/input/misc/mpu3050.c +++ /dev/null | |||
@@ -1,481 +0,0 @@ | |||
1 | /* | ||
2 | * MPU3050 Tri-axis gyroscope driver | ||
3 | * | ||
4 | * Copyright (C) 2011 Wistron Co.Ltd | ||
5 | * Joseph Lai <joseph_lai@wistron.com> | ||
6 | * | ||
7 | * Trimmed down by Alan Cox <alan@linux.intel.com> to produce this version | ||
8 | * | ||
9 | * This is a 'lite' version of the driver, while we consider the right way | ||
10 | * to present the other features to user space. In particular it requires the | ||
11 | * device has an IRQ, and it only provides an input interface, so is not much | ||
12 | * use for device orientation. A fuller version is available from the Meego | ||
13 | * tree. | ||
14 | * | ||
15 | * This program is based on bma023.c. | ||
16 | * | ||
17 | * This program is free software; you can redistribute it and/or modify | ||
18 | * it under the terms of the GNU General Public License as published by | ||
19 | * the Free Software Foundation; version 2 of the License. | ||
20 | * | ||
21 | * This program is distributed in the hope that it will be useful, but | ||
22 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
24 | * General Public License for more details. | ||
25 | * | ||
26 | * You should have received a copy of the GNU General Public License along | ||
27 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
28 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
29 | * | ||
30 | */ | ||
31 | |||
32 | #include <linux/module.h> | ||
33 | #include <linux/interrupt.h> | ||
34 | #include <linux/platform_device.h> | ||
35 | #include <linux/mutex.h> | ||
36 | #include <linux/err.h> | ||
37 | #include <linux/i2c.h> | ||
38 | #include <linux/input.h> | ||
39 | #include <linux/delay.h> | ||
40 | #include <linux/slab.h> | ||
41 | #include <linux/pm_runtime.h> | ||
42 | |||
43 | #define MPU3050_CHIP_ID 0x69 | ||
44 | |||
45 | #define MPU3050_AUTO_DELAY 1000 | ||
46 | |||
47 | #define MPU3050_MIN_VALUE -32768 | ||
48 | #define MPU3050_MAX_VALUE 32767 | ||
49 | |||
50 | #define MPU3050_DEFAULT_POLL_INTERVAL 200 | ||
51 | #define MPU3050_DEFAULT_FS_RANGE 3 | ||
52 | |||
53 | /* Register map */ | ||
54 | #define MPU3050_CHIP_ID_REG 0x00 | ||
55 | #define MPU3050_SMPLRT_DIV 0x15 | ||
56 | #define MPU3050_DLPF_FS_SYNC 0x16 | ||
57 | #define MPU3050_INT_CFG 0x17 | ||
58 | #define MPU3050_XOUT_H 0x1D | ||
59 | #define MPU3050_PWR_MGM 0x3E | ||
60 | #define MPU3050_PWR_MGM_POS 6 | ||
61 | |||
62 | /* Register bits */ | ||
63 | |||
64 | /* DLPF_FS_SYNC */ | ||
65 | #define MPU3050_EXT_SYNC_NONE 0x00 | ||
66 | #define MPU3050_EXT_SYNC_TEMP 0x20 | ||
67 | #define MPU3050_EXT_SYNC_GYROX 0x40 | ||
68 | #define MPU3050_EXT_SYNC_GYROY 0x60 | ||
69 | #define MPU3050_EXT_SYNC_GYROZ 0x80 | ||
70 | #define MPU3050_EXT_SYNC_ACCELX 0xA0 | ||
71 | #define MPU3050_EXT_SYNC_ACCELY 0xC0 | ||
72 | #define MPU3050_EXT_SYNC_ACCELZ 0xE0 | ||
73 | #define MPU3050_EXT_SYNC_MASK 0xE0 | ||
74 | #define MPU3050_FS_250DPS 0x00 | ||
75 | #define MPU3050_FS_500DPS 0x08 | ||
76 | #define MPU3050_FS_1000DPS 0x10 | ||
77 | #define MPU3050_FS_2000DPS 0x18 | ||
78 | #define MPU3050_FS_MASK 0x18 | ||
79 | #define MPU3050_DLPF_CFG_256HZ_NOLPF2 0x00 | ||
80 | #define MPU3050_DLPF_CFG_188HZ 0x01 | ||
81 | #define MPU3050_DLPF_CFG_98HZ 0x02 | ||
82 | #define MPU3050_DLPF_CFG_42HZ 0x03 | ||
83 | #define MPU3050_DLPF_CFG_20HZ 0x04 | ||
84 | #define MPU3050_DLPF_CFG_10HZ 0x05 | ||
85 | #define MPU3050_DLPF_CFG_5HZ 0x06 | ||
86 | #define MPU3050_DLPF_CFG_2100HZ_NOLPF 0x07 | ||
87 | #define MPU3050_DLPF_CFG_MASK 0x07 | ||
88 | /* INT_CFG */ | ||
89 | #define MPU3050_RAW_RDY_EN 0x01 | ||
90 | #define MPU3050_MPU_RDY_EN 0x02 | ||
91 | #define MPU3050_LATCH_INT_EN 0x04 | ||
92 | /* PWR_MGM */ | ||
93 | #define MPU3050_PWR_MGM_PLL_X 0x01 | ||
94 | #define MPU3050_PWR_MGM_PLL_Y 0x02 | ||
95 | #define MPU3050_PWR_MGM_PLL_Z 0x03 | ||
96 | #define MPU3050_PWR_MGM_CLKSEL 0x07 | ||
97 | #define MPU3050_PWR_MGM_STBY_ZG 0x08 | ||
98 | #define MPU3050_PWR_MGM_STBY_YG 0x10 | ||
99 | #define MPU3050_PWR_MGM_STBY_XG 0x20 | ||
100 | #define MPU3050_PWR_MGM_SLEEP 0x40 | ||
101 | #define MPU3050_PWR_MGM_RESET 0x80 | ||
102 | #define MPU3050_PWR_MGM_MASK 0x40 | ||
103 | |||
104 | struct axis_data { | ||
105 | s16 x; | ||
106 | s16 y; | ||
107 | s16 z; | ||
108 | }; | ||
109 | |||
110 | struct mpu3050_sensor { | ||
111 | struct i2c_client *client; | ||
112 | struct device *dev; | ||
113 | struct input_dev *idev; | ||
114 | }; | ||
115 | |||
116 | /** | ||
117 | * mpu3050_xyz_read_reg - read the axes values | ||
118 | * @buffer: provide register addr and get register | ||
119 | * @length: length of register | ||
120 | * | ||
121 | * Reads the register values in one transaction or returns a negative | ||
122 | * error code on failure. | ||
123 | */ | ||
124 | static int mpu3050_xyz_read_reg(struct i2c_client *client, | ||
125 | u8 *buffer, int length) | ||
126 | { | ||
127 | /* | ||
128 | * Annoying we can't make this const because the i2c layer doesn't | ||
129 | * declare input buffers const. | ||
130 | */ | ||
131 | char cmd = MPU3050_XOUT_H; | ||
132 | struct i2c_msg msg[] = { | ||
133 | { | ||
134 | .addr = client->addr, | ||
135 | .flags = 0, | ||
136 | .len = 1, | ||
137 | .buf = &cmd, | ||
138 | }, | ||
139 | { | ||
140 | .addr = client->addr, | ||
141 | .flags = I2C_M_RD, | ||
142 | .len = length, | ||
143 | .buf = buffer, | ||
144 | }, | ||
145 | }; | ||
146 | |||
147 | return i2c_transfer(client->adapter, msg, 2); | ||
148 | } | ||
149 | |||
150 | /** | ||
151 | * mpu3050_read_xyz - get co-ordinates from device | ||
152 | * @client: i2c address of sensor | ||
153 | * @coords: co-ordinates to update | ||
154 | * | ||
155 | * Return the converted X Y and Z co-ordinates from the sensor device | ||
156 | */ | ||
157 | static void mpu3050_read_xyz(struct i2c_client *client, | ||
158 | struct axis_data *coords) | ||
159 | { | ||
160 | u16 buffer[3]; | ||
161 | |||
162 | mpu3050_xyz_read_reg(client, (u8 *)buffer, 6); | ||
163 | coords->x = be16_to_cpu(buffer[0]); | ||
164 | coords->y = be16_to_cpu(buffer[1]); | ||
165 | coords->z = be16_to_cpu(buffer[2]); | ||
166 | dev_dbg(&client->dev, "%s: x %d, y %d, z %d\n", __func__, | ||
167 | coords->x, coords->y, coords->z); | ||
168 | } | ||
169 | |||
170 | /** | ||
171 | * mpu3050_set_power_mode - set the power mode | ||
172 | * @client: i2c client for the sensor | ||
173 | * @val: value to switch on/off of power, 1: normal power, 0: low power | ||
174 | * | ||
175 | * Put device to normal-power mode or low-power mode. | ||
176 | */ | ||
177 | static void mpu3050_set_power_mode(struct i2c_client *client, u8 val) | ||
178 | { | ||
179 | u8 value; | ||
180 | |||
181 | value = i2c_smbus_read_byte_data(client, MPU3050_PWR_MGM); | ||
182 | value = (value & ~MPU3050_PWR_MGM_MASK) | | ||
183 | (((val << MPU3050_PWR_MGM_POS) & MPU3050_PWR_MGM_MASK) ^ | ||
184 | MPU3050_PWR_MGM_MASK); | ||
185 | i2c_smbus_write_byte_data(client, MPU3050_PWR_MGM, value); | ||
186 | } | ||
187 | |||
188 | /** | ||
189 | * mpu3050_input_open - called on input event open | ||
190 | * @input: input dev of opened device | ||
191 | * | ||
192 | * The input layer calls this function when input event is opened. The | ||
193 | * function will push the device to resume. Then, the device is ready | ||
194 | * to provide data. | ||
195 | */ | ||
196 | static int mpu3050_input_open(struct input_dev *input) | ||
197 | { | ||
198 | struct mpu3050_sensor *sensor = input_get_drvdata(input); | ||
199 | int error; | ||
200 | |||
201 | pm_runtime_get(sensor->dev); | ||
202 | |||
203 | /* Enable interrupts */ | ||
204 | error = i2c_smbus_write_byte_data(sensor->client, MPU3050_INT_CFG, | ||
205 | MPU3050_LATCH_INT_EN | | ||
206 | MPU3050_RAW_RDY_EN | | ||
207 | MPU3050_MPU_RDY_EN); | ||
208 | if (error < 0) { | ||
209 | pm_runtime_put(sensor->dev); | ||
210 | return error; | ||
211 | } | ||
212 | |||
213 | return 0; | ||
214 | } | ||
215 | |||
216 | /** | ||
217 | * mpu3050_input_close - called on input event close | ||
218 | * @input: input dev of closed device | ||
219 | * | ||
220 | * The input layer calls this function when input event is closed. The | ||
221 | * function will push the device to suspend. | ||
222 | */ | ||
223 | static void mpu3050_input_close(struct input_dev *input) | ||
224 | { | ||
225 | struct mpu3050_sensor *sensor = input_get_drvdata(input); | ||
226 | |||
227 | pm_runtime_put(sensor->dev); | ||
228 | } | ||
229 | |||
230 | /** | ||
231 | * mpu3050_interrupt_thread - handle an IRQ | ||
232 | * @irq: interrupt numner | ||
233 | * @data: the sensor | ||
234 | * | ||
235 | * Called by the kernel single threaded after an interrupt occurs. Read | ||
236 | * the sensor data and generate an input event for it. | ||
237 | */ | ||
238 | static irqreturn_t mpu3050_interrupt_thread(int irq, void *data) | ||
239 | { | ||
240 | struct mpu3050_sensor *sensor = data; | ||
241 | struct axis_data axis; | ||
242 | |||
243 | mpu3050_read_xyz(sensor->client, &axis); | ||
244 | |||
245 | input_report_abs(sensor->idev, ABS_X, axis.x); | ||
246 | input_report_abs(sensor->idev, ABS_Y, axis.y); | ||
247 | input_report_abs(sensor->idev, ABS_Z, axis.z); | ||
248 | input_sync(sensor->idev); | ||
249 | |||
250 | return IRQ_HANDLED; | ||
251 | } | ||
252 | |||
253 | /** | ||
254 | * mpu3050_hw_init - initialize hardware | ||
255 | * @sensor: the sensor | ||
256 | * | ||
257 | * Called during device probe; configures the sampling method. | ||
258 | */ | ||
259 | static int mpu3050_hw_init(struct mpu3050_sensor *sensor) | ||
260 | { | ||
261 | struct i2c_client *client = sensor->client; | ||
262 | int ret; | ||
263 | u8 reg; | ||
264 | |||
265 | /* Reset */ | ||
266 | ret = i2c_smbus_write_byte_data(client, MPU3050_PWR_MGM, | ||
267 | MPU3050_PWR_MGM_RESET); | ||
268 | if (ret < 0) | ||
269 | return ret; | ||
270 | |||
271 | ret = i2c_smbus_read_byte_data(client, MPU3050_PWR_MGM); | ||
272 | if (ret < 0) | ||
273 | return ret; | ||
274 | |||
275 | ret &= ~MPU3050_PWR_MGM_CLKSEL; | ||
276 | ret |= MPU3050_PWR_MGM_PLL_Z; | ||
277 | ret = i2c_smbus_write_byte_data(client, MPU3050_PWR_MGM, ret); | ||
278 | if (ret < 0) | ||
279 | return ret; | ||
280 | |||
281 | /* Output frequency divider. The poll interval */ | ||
282 | ret = i2c_smbus_write_byte_data(client, MPU3050_SMPLRT_DIV, | ||
283 | MPU3050_DEFAULT_POLL_INTERVAL - 1); | ||
284 | if (ret < 0) | ||
285 | return ret; | ||
286 | |||
287 | /* Set low pass filter and full scale */ | ||
288 | reg = MPU3050_DEFAULT_FS_RANGE; | ||
289 | reg |= MPU3050_DLPF_CFG_42HZ << 3; | ||
290 | reg |= MPU3050_EXT_SYNC_NONE << 5; | ||
291 | ret = i2c_smbus_write_byte_data(client, MPU3050_DLPF_FS_SYNC, reg); | ||
292 | if (ret < 0) | ||
293 | return ret; | ||
294 | |||
295 | return 0; | ||
296 | } | ||
297 | |||
298 | /** | ||
299 | * mpu3050_probe - device detection callback | ||
300 | * @client: i2c client of found device | ||
301 | * @id: id match information | ||
302 | * | ||
303 | * The I2C layer calls us when it believes a sensor is present at this | ||
304 | * address. Probe to see if this is correct and to validate the device. | ||
305 | * | ||
306 | * If present install the relevant sysfs interfaces and input device. | ||
307 | */ | ||
308 | static int mpu3050_probe(struct i2c_client *client, | ||
309 | const struct i2c_device_id *id) | ||
310 | { | ||
311 | struct mpu3050_sensor *sensor; | ||
312 | struct input_dev *idev; | ||
313 | int ret; | ||
314 | int error; | ||
315 | |||
316 | sensor = kzalloc(sizeof(struct mpu3050_sensor), GFP_KERNEL); | ||
317 | idev = input_allocate_device(); | ||
318 | if (!sensor || !idev) { | ||
319 | dev_err(&client->dev, "failed to allocate driver data\n"); | ||
320 | error = -ENOMEM; | ||
321 | goto err_free_mem; | ||
322 | } | ||
323 | |||
324 | sensor->client = client; | ||
325 | sensor->dev = &client->dev; | ||
326 | sensor->idev = idev; | ||
327 | |||
328 | mpu3050_set_power_mode(client, 1); | ||
329 | msleep(10); | ||
330 | |||
331 | ret = i2c_smbus_read_byte_data(client, MPU3050_CHIP_ID_REG); | ||
332 | if (ret < 0) { | ||
333 | dev_err(&client->dev, "failed to detect device\n"); | ||
334 | error = -ENXIO; | ||
335 | goto err_free_mem; | ||
336 | } | ||
337 | |||
338 | if (ret != MPU3050_CHIP_ID) { | ||
339 | dev_err(&client->dev, "unsupported chip id\n"); | ||
340 | error = -ENXIO; | ||
341 | goto err_free_mem; | ||
342 | } | ||
343 | |||
344 | idev->name = "MPU3050"; | ||
345 | idev->id.bustype = BUS_I2C; | ||
346 | idev->dev.parent = &client->dev; | ||
347 | |||
348 | idev->open = mpu3050_input_open; | ||
349 | idev->close = mpu3050_input_close; | ||
350 | |||
351 | __set_bit(EV_ABS, idev->evbit); | ||
352 | input_set_abs_params(idev, ABS_X, | ||
353 | MPU3050_MIN_VALUE, MPU3050_MAX_VALUE, 0, 0); | ||
354 | input_set_abs_params(idev, ABS_Y, | ||
355 | MPU3050_MIN_VALUE, MPU3050_MAX_VALUE, 0, 0); | ||
356 | input_set_abs_params(idev, ABS_Z, | ||
357 | MPU3050_MIN_VALUE, MPU3050_MAX_VALUE, 0, 0); | ||
358 | |||
359 | input_set_drvdata(idev, sensor); | ||
360 | |||
361 | pm_runtime_set_active(&client->dev); | ||
362 | |||
363 | error = mpu3050_hw_init(sensor); | ||
364 | if (error) | ||
365 | goto err_pm_set_suspended; | ||
366 | |||
367 | error = request_threaded_irq(client->irq, | ||
368 | NULL, mpu3050_interrupt_thread, | ||
369 | IRQF_TRIGGER_RISING | IRQF_ONESHOT, | ||
370 | "mpu3050", sensor); | ||
371 | if (error) { | ||
372 | dev_err(&client->dev, | ||
373 | "can't get IRQ %d, error %d\n", client->irq, error); | ||
374 | goto err_pm_set_suspended; | ||
375 | } | ||
376 | |||
377 | error = input_register_device(idev); | ||
378 | if (error) { | ||
379 | dev_err(&client->dev, "failed to register input device\n"); | ||
380 | goto err_free_irq; | ||
381 | } | ||
382 | |||
383 | pm_runtime_enable(&client->dev); | ||
384 | pm_runtime_set_autosuspend_delay(&client->dev, MPU3050_AUTO_DELAY); | ||
385 | i2c_set_clientdata(client, sensor); | ||
386 | |||
387 | return 0; | ||
388 | |||
389 | err_free_irq: | ||
390 | free_irq(client->irq, sensor); | ||
391 | err_pm_set_suspended: | ||
392 | pm_runtime_set_suspended(&client->dev); | ||
393 | err_free_mem: | ||
394 | input_free_device(idev); | ||
395 | kfree(sensor); | ||
396 | return error; | ||
397 | } | ||
398 | |||
399 | /** | ||
400 | * mpu3050_remove - remove a sensor | ||
401 | * @client: i2c client of sensor being removed | ||
402 | * | ||
403 | * Our sensor is going away, clean up the resources. | ||
404 | */ | ||
405 | static int mpu3050_remove(struct i2c_client *client) | ||
406 | { | ||
407 | struct mpu3050_sensor *sensor = i2c_get_clientdata(client); | ||
408 | |||
409 | pm_runtime_disable(&client->dev); | ||
410 | pm_runtime_set_suspended(&client->dev); | ||
411 | |||
412 | free_irq(client->irq, sensor); | ||
413 | input_unregister_device(sensor->idev); | ||
414 | kfree(sensor); | ||
415 | |||
416 | return 0; | ||
417 | } | ||
418 | |||
419 | #ifdef CONFIG_PM | ||
420 | /** | ||
421 | * mpu3050_suspend - called on device suspend | ||
422 | * @dev: device being suspended | ||
423 | * | ||
424 | * Put the device into sleep mode before we suspend the machine. | ||
425 | */ | ||
426 | static int mpu3050_suspend(struct device *dev) | ||
427 | { | ||
428 | struct i2c_client *client = to_i2c_client(dev); | ||
429 | |||
430 | mpu3050_set_power_mode(client, 0); | ||
431 | |||
432 | return 0; | ||
433 | } | ||
434 | |||
435 | /** | ||
436 | * mpu3050_resume - called on device resume | ||
437 | * @dev: device being resumed | ||
438 | * | ||
439 | * Put the device into powered mode on resume. | ||
440 | */ | ||
441 | static int mpu3050_resume(struct device *dev) | ||
442 | { | ||
443 | struct i2c_client *client = to_i2c_client(dev); | ||
444 | |||
445 | mpu3050_set_power_mode(client, 1); | ||
446 | msleep(100); /* wait for gyro chip resume */ | ||
447 | |||
448 | return 0; | ||
449 | } | ||
450 | #endif | ||
451 | |||
452 | static UNIVERSAL_DEV_PM_OPS(mpu3050_pm, mpu3050_suspend, mpu3050_resume, NULL); | ||
453 | |||
454 | static const struct i2c_device_id mpu3050_ids[] = { | ||
455 | { "mpu3050", 0 }, | ||
456 | { } | ||
457 | }; | ||
458 | MODULE_DEVICE_TABLE(i2c, mpu3050_ids); | ||
459 | |||
460 | static const struct of_device_id mpu3050_of_match[] = { | ||
461 | { .compatible = "invn,mpu3050", }, | ||
462 | { }, | ||
463 | }; | ||
464 | MODULE_DEVICE_TABLE(of, mpu3050_of_match); | ||
465 | |||
466 | static struct i2c_driver mpu3050_i2c_driver = { | ||
467 | .driver = { | ||
468 | .name = "mpu3050", | ||
469 | .pm = &mpu3050_pm, | ||
470 | .of_match_table = mpu3050_of_match, | ||
471 | }, | ||
472 | .probe = mpu3050_probe, | ||
473 | .remove = mpu3050_remove, | ||
474 | .id_table = mpu3050_ids, | ||
475 | }; | ||
476 | |||
477 | module_i2c_driver(mpu3050_i2c_driver); | ||
478 | |||
479 | MODULE_AUTHOR("Wistron Corp."); | ||
480 | MODULE_DESCRIPTION("MPU3050 Tri-axis gyroscope driver"); | ||
481 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c index e317b75357a0..18ad956454f1 100644 --- a/drivers/input/misc/pm8941-pwrkey.c +++ b/drivers/input/misc/pm8941-pwrkey.c | |||
@@ -266,7 +266,6 @@ static int pm8941_pwrkey_remove(struct platform_device *pdev) | |||
266 | { | 266 | { |
267 | struct pm8941_pwrkey *pwrkey = platform_get_drvdata(pdev); | 267 | struct pm8941_pwrkey *pwrkey = platform_get_drvdata(pdev); |
268 | 268 | ||
269 | device_init_wakeup(&pdev->dev, 0); | ||
270 | unregister_reboot_notifier(&pwrkey->reboot_notifier); | 269 | unregister_reboot_notifier(&pwrkey->reboot_notifier); |
271 | 270 | ||
272 | return 0; | 271 | return 0; |
diff --git a/drivers/input/misc/pmic8xxx-pwrkey.c b/drivers/input/misc/pmic8xxx-pwrkey.c index 67aab86048ad..73323b0c72c1 100644 --- a/drivers/input/misc/pmic8xxx-pwrkey.c +++ b/drivers/input/misc/pmic8xxx-pwrkey.c | |||
@@ -438,13 +438,6 @@ static int pmic8xxx_pwrkey_probe(struct platform_device *pdev) | |||
438 | return 0; | 438 | return 0; |
439 | } | 439 | } |
440 | 440 | ||
441 | static int pmic8xxx_pwrkey_remove(struct platform_device *pdev) | ||
442 | { | ||
443 | device_init_wakeup(&pdev->dev, 0); | ||
444 | |||
445 | return 0; | ||
446 | } | ||
447 | |||
448 | static const struct of_device_id pm8xxx_pwr_key_id_table[] = { | 441 | static const struct of_device_id pm8xxx_pwr_key_id_table[] = { |
449 | { .compatible = "qcom,pm8058-pwrkey", .data = &pm8058_pwrkey_shutdown }, | 442 | { .compatible = "qcom,pm8058-pwrkey", .data = &pm8058_pwrkey_shutdown }, |
450 | { .compatible = "qcom,pm8921-pwrkey", .data = &pm8921_pwrkey_shutdown }, | 443 | { .compatible = "qcom,pm8921-pwrkey", .data = &pm8921_pwrkey_shutdown }, |
@@ -454,7 +447,6 @@ MODULE_DEVICE_TABLE(of, pm8xxx_pwr_key_id_table); | |||
454 | 447 | ||
455 | static struct platform_driver pmic8xxx_pwrkey_driver = { | 448 | static struct platform_driver pmic8xxx_pwrkey_driver = { |
456 | .probe = pmic8xxx_pwrkey_probe, | 449 | .probe = pmic8xxx_pwrkey_probe, |
457 | .remove = pmic8xxx_pwrkey_remove, | ||
458 | .shutdown = pmic8xxx_pwrkey_shutdown, | 450 | .shutdown = pmic8xxx_pwrkey_shutdown, |
459 | .driver = { | 451 | .driver = { |
460 | .name = "pm8xxx-pwrkey", | 452 | .name = "pm8xxx-pwrkey", |
diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c index 5f9655d49a65..e53801dbd560 100644 --- a/drivers/input/misc/pwm-beeper.c +++ b/drivers/input/misc/pwm-beeper.c | |||
@@ -14,6 +14,7 @@ | |||
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <linux/input.h> | 16 | #include <linux/input.h> |
17 | #include <linux/regulator/consumer.h> | ||
17 | #include <linux/module.h> | 18 | #include <linux/module.h> |
18 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
19 | #include <linux/of.h> | 20 | #include <linux/of.h> |
@@ -25,29 +26,62 @@ | |||
25 | struct pwm_beeper { | 26 | struct pwm_beeper { |
26 | struct input_dev *input; | 27 | struct input_dev *input; |
27 | struct pwm_device *pwm; | 28 | struct pwm_device *pwm; |
29 | struct regulator *amplifier; | ||
28 | struct work_struct work; | 30 | struct work_struct work; |
29 | unsigned long period; | 31 | unsigned long period; |
32 | bool suspended; | ||
33 | bool amplifier_on; | ||
30 | }; | 34 | }; |
31 | 35 | ||
32 | #define HZ_TO_NANOSECONDS(x) (1000000000UL/(x)) | 36 | #define HZ_TO_NANOSECONDS(x) (1000000000UL/(x)) |
33 | 37 | ||
34 | static void __pwm_beeper_set(struct pwm_beeper *beeper) | 38 | static int pwm_beeper_on(struct pwm_beeper *beeper, unsigned long period) |
35 | { | 39 | { |
36 | unsigned long period = beeper->period; | 40 | struct pwm_state state; |
41 | int error; | ||
42 | |||
43 | pwm_get_state(beeper->pwm, &state); | ||
44 | |||
45 | state.enabled = true; | ||
46 | state.period = period; | ||
47 | pwm_set_relative_duty_cycle(&state, 50, 100); | ||
48 | |||
49 | error = pwm_apply_state(beeper->pwm, &state); | ||
50 | if (error) | ||
51 | return error; | ||
52 | |||
53 | if (!beeper->amplifier_on) { | ||
54 | error = regulator_enable(beeper->amplifier); | ||
55 | if (error) { | ||
56 | pwm_disable(beeper->pwm); | ||
57 | return error; | ||
58 | } | ||
59 | |||
60 | beeper->amplifier_on = true; | ||
61 | } | ||
62 | |||
63 | return 0; | ||
64 | } | ||
37 | 65 | ||
38 | if (period) { | 66 | static void pwm_beeper_off(struct pwm_beeper *beeper) |
39 | pwm_config(beeper->pwm, period / 2, period); | 67 | { |
40 | pwm_enable(beeper->pwm); | 68 | if (beeper->amplifier_on) { |
41 | } else | 69 | regulator_disable(beeper->amplifier); |
42 | pwm_disable(beeper->pwm); | 70 | beeper->amplifier_on = false; |
71 | } | ||
72 | |||
73 | pwm_disable(beeper->pwm); | ||
43 | } | 74 | } |
44 | 75 | ||
45 | static void pwm_beeper_work(struct work_struct *work) | 76 | static void pwm_beeper_work(struct work_struct *work) |
46 | { | 77 | { |
47 | struct pwm_beeper *beeper = | 78 | struct pwm_beeper *beeper = container_of(work, struct pwm_beeper, work); |
48 | container_of(work, struct pwm_beeper, work); | 79 | unsigned long period = READ_ONCE(beeper->period); |
49 | 80 | ||
50 | __pwm_beeper_set(beeper); | 81 | if (period) |
82 | pwm_beeper_on(beeper, period); | ||
83 | else | ||
84 | pwm_beeper_off(beeper); | ||
51 | } | 85 | } |
52 | 86 | ||
53 | static int pwm_beeper_event(struct input_dev *input, | 87 | static int pwm_beeper_event(struct input_dev *input, |
@@ -73,7 +107,8 @@ static int pwm_beeper_event(struct input_dev *input, | |||
73 | else | 107 | else |
74 | beeper->period = HZ_TO_NANOSECONDS(value); | 108 | beeper->period = HZ_TO_NANOSECONDS(value); |
75 | 109 | ||
76 | schedule_work(&beeper->work); | 110 | if (!beeper->suspended) |
111 | schedule_work(&beeper->work); | ||
77 | 112 | ||
78 | return 0; | 113 | return 0; |
79 | } | 114 | } |
@@ -81,9 +116,7 @@ static int pwm_beeper_event(struct input_dev *input, | |||
81 | static void pwm_beeper_stop(struct pwm_beeper *beeper) | 116 | static void pwm_beeper_stop(struct pwm_beeper *beeper) |
82 | { | 117 | { |
83 | cancel_work_sync(&beeper->work); | 118 | cancel_work_sync(&beeper->work); |
84 | 119 | pwm_beeper_off(beeper); | |
85 | if (beeper->period) | ||
86 | pwm_disable(beeper->pwm); | ||
87 | } | 120 | } |
88 | 121 | ||
89 | static void pwm_beeper_close(struct input_dev *input) | 122 | static void pwm_beeper_close(struct input_dev *input) |
@@ -95,41 +128,50 @@ static void pwm_beeper_close(struct input_dev *input) | |||
95 | 128 | ||
96 | static int pwm_beeper_probe(struct platform_device *pdev) | 129 | static int pwm_beeper_probe(struct platform_device *pdev) |
97 | { | 130 | { |
98 | unsigned long pwm_id = (unsigned long)dev_get_platdata(&pdev->dev); | 131 | struct device *dev = &pdev->dev; |
99 | struct pwm_beeper *beeper; | 132 | struct pwm_beeper *beeper; |
133 | struct pwm_state state; | ||
100 | int error; | 134 | int error; |
101 | 135 | ||
102 | beeper = kzalloc(sizeof(*beeper), GFP_KERNEL); | 136 | beeper = devm_kzalloc(dev, sizeof(*beeper), GFP_KERNEL); |
103 | if (!beeper) | 137 | if (!beeper) |
104 | return -ENOMEM; | 138 | return -ENOMEM; |
105 | 139 | ||
106 | beeper->pwm = pwm_get(&pdev->dev, NULL); | 140 | beeper->pwm = devm_pwm_get(dev, NULL); |
107 | if (IS_ERR(beeper->pwm)) { | 141 | if (IS_ERR(beeper->pwm)) { |
108 | dev_dbg(&pdev->dev, "unable to request PWM, trying legacy API\n"); | 142 | error = PTR_ERR(beeper->pwm); |
109 | beeper->pwm = pwm_request(pwm_id, "pwm beeper"); | 143 | if (error != -EPROBE_DEFER) |
144 | dev_err(dev, "Failed to request PWM device: %d\n", | ||
145 | error); | ||
146 | return error; | ||
110 | } | 147 | } |
111 | 148 | ||
112 | if (IS_ERR(beeper->pwm)) { | 149 | /* Sync up PWM state and ensure it is off. */ |
113 | error = PTR_ERR(beeper->pwm); | 150 | pwm_init_state(beeper->pwm, &state); |
114 | dev_err(&pdev->dev, "Failed to request pwm device: %d\n", error); | 151 | state.enabled = false; |
115 | goto err_free; | 152 | error = pwm_apply_state(beeper->pwm, &state); |
153 | if (error) { | ||
154 | dev_err(dev, "failed to apply initial PWM state: %d\n", | ||
155 | error); | ||
156 | return error; | ||
116 | } | 157 | } |
117 | 158 | ||
118 | /* | 159 | beeper->amplifier = devm_regulator_get(dev, "amp"); |
119 | * FIXME: pwm_apply_args() should be removed when switching to | 160 | if (IS_ERR(beeper->amplifier)) { |
120 | * the atomic PWM API. | 161 | error = PTR_ERR(beeper->amplifier); |
121 | */ | 162 | if (error != -EPROBE_DEFER) |
122 | pwm_apply_args(beeper->pwm); | 163 | dev_err(dev, "Failed to get 'amp' regulator: %d\n", |
164 | error); | ||
165 | return error; | ||
166 | } | ||
123 | 167 | ||
124 | INIT_WORK(&beeper->work, pwm_beeper_work); | 168 | INIT_WORK(&beeper->work, pwm_beeper_work); |
125 | 169 | ||
126 | beeper->input = input_allocate_device(); | 170 | beeper->input = devm_input_allocate_device(dev); |
127 | if (!beeper->input) { | 171 | if (!beeper->input) { |
128 | dev_err(&pdev->dev, "Failed to allocate input device\n"); | 172 | dev_err(dev, "Failed to allocate input device\n"); |
129 | error = -ENOMEM; | 173 | return -ENOMEM; |
130 | goto err_pwm_free; | ||
131 | } | 174 | } |
132 | beeper->input->dev.parent = &pdev->dev; | ||
133 | 175 | ||
134 | beeper->input->name = "pwm-beeper"; | 176 | beeper->input->name = "pwm-beeper"; |
135 | beeper->input->phys = "pwm/input0"; | 177 | beeper->input->phys = "pwm/input0"; |
@@ -138,8 +180,8 @@ static int pwm_beeper_probe(struct platform_device *pdev) | |||
138 | beeper->input->id.product = 0x0001; | 180 | beeper->input->id.product = 0x0001; |
139 | beeper->input->id.version = 0x0100; | 181 | beeper->input->id.version = 0x0100; |
140 | 182 | ||
141 | beeper->input->evbit[0] = BIT(EV_SND); | 183 | input_set_capability(beeper->input, EV_SND, SND_TONE); |
142 | beeper->input->sndbit[0] = BIT(SND_TONE) | BIT(SND_BELL); | 184 | input_set_capability(beeper->input, EV_SND, SND_BELL); |
143 | 185 | ||
144 | beeper->input->event = pwm_beeper_event; | 186 | beeper->input->event = pwm_beeper_event; |
145 | beeper->input->close = pwm_beeper_close; | 187 | beeper->input->close = pwm_beeper_close; |
@@ -148,41 +190,28 @@ static int pwm_beeper_probe(struct platform_device *pdev) | |||
148 | 190 | ||
149 | error = input_register_device(beeper->input); | 191 | error = input_register_device(beeper->input); |
150 | if (error) { | 192 | if (error) { |
151 | dev_err(&pdev->dev, "Failed to register input device: %d\n", error); | 193 | dev_err(dev, "Failed to register input device: %d\n", error); |
152 | goto err_input_free; | 194 | return error; |
153 | } | 195 | } |
154 | 196 | ||
155 | platform_set_drvdata(pdev, beeper); | 197 | platform_set_drvdata(pdev, beeper); |
156 | 198 | ||
157 | return 0; | 199 | return 0; |
158 | |||
159 | err_input_free: | ||
160 | input_free_device(beeper->input); | ||
161 | err_pwm_free: | ||
162 | pwm_free(beeper->pwm); | ||
163 | err_free: | ||
164 | kfree(beeper); | ||
165 | |||
166 | return error; | ||
167 | } | ||
168 | |||
169 | static int pwm_beeper_remove(struct platform_device *pdev) | ||
170 | { | ||
171 | struct pwm_beeper *beeper = platform_get_drvdata(pdev); | ||
172 | |||
173 | input_unregister_device(beeper->input); | ||
174 | |||
175 | pwm_free(beeper->pwm); | ||
176 | |||
177 | kfree(beeper); | ||
178 | |||
179 | return 0; | ||
180 | } | 200 | } |
181 | 201 | ||
182 | static int __maybe_unused pwm_beeper_suspend(struct device *dev) | 202 | static int __maybe_unused pwm_beeper_suspend(struct device *dev) |
183 | { | 203 | { |
184 | struct pwm_beeper *beeper = dev_get_drvdata(dev); | 204 | struct pwm_beeper *beeper = dev_get_drvdata(dev); |
185 | 205 | ||
206 | /* | ||
207 | * Spinlock is taken here is not to protect write to | ||
208 | * beeper->suspended, but to ensure that pwm_beeper_event | ||
209 | * does not re-submit work once flag is set. | ||
210 | */ | ||
211 | spin_lock_irq(&beeper->input->event_lock); | ||
212 | beeper->suspended = true; | ||
213 | spin_unlock_irq(&beeper->input->event_lock); | ||
214 | |||
186 | pwm_beeper_stop(beeper); | 215 | pwm_beeper_stop(beeper); |
187 | 216 | ||
188 | return 0; | 217 | return 0; |
@@ -192,8 +221,12 @@ static int __maybe_unused pwm_beeper_resume(struct device *dev) | |||
192 | { | 221 | { |
193 | struct pwm_beeper *beeper = dev_get_drvdata(dev); | 222 | struct pwm_beeper *beeper = dev_get_drvdata(dev); |
194 | 223 | ||
195 | if (beeper->period) | 224 | spin_lock_irq(&beeper->input->event_lock); |
196 | __pwm_beeper_set(beeper); | 225 | beeper->suspended = false; |
226 | spin_unlock_irq(&beeper->input->event_lock); | ||
227 | |||
228 | /* Let worker figure out if we should resume beeping */ | ||
229 | schedule_work(&beeper->work); | ||
197 | 230 | ||
198 | return 0; | 231 | return 0; |
199 | } | 232 | } |
@@ -211,7 +244,6 @@ MODULE_DEVICE_TABLE(of, pwm_beeper_match); | |||
211 | 244 | ||
212 | static struct platform_driver pwm_beeper_driver = { | 245 | static struct platform_driver pwm_beeper_driver = { |
213 | .probe = pwm_beeper_probe, | 246 | .probe = pwm_beeper_probe, |
214 | .remove = pwm_beeper_remove, | ||
215 | .driver = { | 247 | .driver = { |
216 | .name = "pwm-beeper", | 248 | .name = "pwm-beeper", |
217 | .pm = &pwm_beeper_pm_ops, | 249 | .pm = &pwm_beeper_pm_ops, |
diff --git a/drivers/input/misc/retu-pwrbutton.c b/drivers/input/misc/retu-pwrbutton.c index 30b459b6b344..64023ac08e2b 100644 --- a/drivers/input/misc/retu-pwrbutton.c +++ b/drivers/input/misc/retu-pwrbutton.c | |||
@@ -76,14 +76,8 @@ static int retu_pwrbutton_probe(struct platform_device *pdev) | |||
76 | return 0; | 76 | return 0; |
77 | } | 77 | } |
78 | 78 | ||
79 | static int retu_pwrbutton_remove(struct platform_device *pdev) | ||
80 | { | ||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | static struct platform_driver retu_pwrbutton_driver = { | 79 | static struct platform_driver retu_pwrbutton_driver = { |
85 | .probe = retu_pwrbutton_probe, | 80 | .probe = retu_pwrbutton_probe, |
86 | .remove = retu_pwrbutton_remove, | ||
87 | .driver = { | 81 | .driver = { |
88 | .name = "retu-pwrbutton", | 82 | .name = "retu-pwrbutton", |
89 | }, | 83 | }, |
diff --git a/drivers/input/misc/sirfsoc-onkey.c b/drivers/input/misc/sirfsoc-onkey.c index ed7237f19539..4fd038d476a3 100644 --- a/drivers/input/misc/sirfsoc-onkey.c +++ b/drivers/input/misc/sirfsoc-onkey.c | |||
@@ -172,13 +172,6 @@ static int sirfsoc_pwrc_probe(struct platform_device *pdev) | |||
172 | return 0; | 172 | return 0; |
173 | } | 173 | } |
174 | 174 | ||
175 | static int sirfsoc_pwrc_remove(struct platform_device *pdev) | ||
176 | { | ||
177 | device_init_wakeup(&pdev->dev, 0); | ||
178 | |||
179 | return 0; | ||
180 | } | ||
181 | |||
182 | static int __maybe_unused sirfsoc_pwrc_resume(struct device *dev) | 175 | static int __maybe_unused sirfsoc_pwrc_resume(struct device *dev) |
183 | { | 176 | { |
184 | struct sirfsoc_pwrc_drvdata *pwrcdrv = dev_get_drvdata(dev); | 177 | struct sirfsoc_pwrc_drvdata *pwrcdrv = dev_get_drvdata(dev); |
@@ -200,7 +193,6 @@ static SIMPLE_DEV_PM_OPS(sirfsoc_pwrc_pm_ops, NULL, sirfsoc_pwrc_resume); | |||
200 | 193 | ||
201 | static struct platform_driver sirfsoc_pwrc_driver = { | 194 | static struct platform_driver sirfsoc_pwrc_driver = { |
202 | .probe = sirfsoc_pwrc_probe, | 195 | .probe = sirfsoc_pwrc_probe, |
203 | .remove = sirfsoc_pwrc_remove, | ||
204 | .driver = { | 196 | .driver = { |
205 | .name = "sirfsoc-pwrc", | 197 | .name = "sirfsoc-pwrc", |
206 | .pm = &sirfsoc_pwrc_pm_ops, | 198 | .pm = &sirfsoc_pwrc_pm_ops, |
diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c index 908b51089dee..ddb2f22fca7a 100644 --- a/drivers/input/misc/soc_button_array.c +++ b/drivers/input/misc/soc_button_array.c | |||
@@ -102,6 +102,8 @@ soc_button_device_create(struct platform_device *pdev, | |||
102 | gpio_keys[n_buttons].active_low = 1; | 102 | gpio_keys[n_buttons].active_low = 1; |
103 | gpio_keys[n_buttons].desc = info->name; | 103 | gpio_keys[n_buttons].desc = info->name; |
104 | gpio_keys[n_buttons].wakeup = info->wakeup; | 104 | gpio_keys[n_buttons].wakeup = info->wakeup; |
105 | /* These devices often use cheap buttons, use 50 ms debounce */ | ||
106 | gpio_keys[n_buttons].debounce_interval = 50; | ||
105 | n_buttons++; | 107 | n_buttons++; |
106 | } | 108 | } |
107 | 109 | ||
@@ -167,12 +169,12 @@ static int soc_button_probe(struct platform_device *pdev) | |||
167 | 169 | ||
168 | button_info = (struct soc_button_info *)id->driver_data; | 170 | button_info = (struct soc_button_info *)id->driver_data; |
169 | 171 | ||
170 | if (gpiod_count(&pdev->dev, KBUILD_MODNAME) <= 0) { | 172 | if (gpiod_count(dev, KBUILD_MODNAME) <= 0) { |
171 | dev_dbg(&pdev->dev, "no GPIO attached, ignoring...\n"); | 173 | dev_dbg(dev, "no GPIO attached, ignoring...\n"); |
172 | return -ENODEV; | 174 | return -ENODEV; |
173 | } | 175 | } |
174 | 176 | ||
175 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); | 177 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
176 | if (!priv) | 178 | if (!priv) |
177 | return -ENOMEM; | 179 | return -ENOMEM; |
178 | 180 | ||
diff --git a/drivers/input/misc/tps65218-pwrbutton.c b/drivers/input/misc/tps65218-pwrbutton.c index cc74a41bdb0d..a4455bb12ae0 100644 --- a/drivers/input/misc/tps65218-pwrbutton.c +++ b/drivers/input/misc/tps65218-pwrbutton.c | |||
@@ -95,7 +95,7 @@ static int tps6521x_pb_probe(struct platform_device *pdev) | |||
95 | int error; | 95 | int error; |
96 | int irq; | 96 | int irq; |
97 | 97 | ||
98 | match = of_match_node(of_tps6521x_pb_match, pdev->dev.of_node); | 98 | match = of_match_node(of_tps6521x_pb_match, dev->of_node); |
99 | if (!match) | 99 | if (!match) |
100 | return -ENXIO; | 100 | return -ENXIO; |
101 | 101 | ||
@@ -118,10 +118,9 @@ static int tps6521x_pb_probe(struct platform_device *pdev) | |||
118 | 118 | ||
119 | input_set_capability(idev, EV_KEY, KEY_POWER); | 119 | input_set_capability(idev, EV_KEY, KEY_POWER); |
120 | 120 | ||
121 | pwr->regmap = dev_get_regmap(pdev->dev.parent, NULL); | 121 | pwr->regmap = dev_get_regmap(dev->parent, NULL); |
122 | pwr->dev = dev; | 122 | pwr->dev = dev; |
123 | pwr->idev = idev; | 123 | pwr->idev = idev; |
124 | platform_set_drvdata(pdev, pwr); | ||
125 | device_init_wakeup(dev, true); | 124 | device_init_wakeup(dev, true); |
126 | 125 | ||
127 | irq = platform_get_irq(pdev, 0); | 126 | irq = platform_get_irq(pdev, 0); |
@@ -136,8 +135,7 @@ static int tps6521x_pb_probe(struct platform_device *pdev) | |||
136 | IRQF_ONESHOT, | 135 | IRQF_ONESHOT, |
137 | pwr->data->name, pwr); | 136 | pwr->data->name, pwr); |
138 | if (error) { | 137 | if (error) { |
139 | dev_err(dev, "failed to request IRQ #%d: %d\n", | 138 | dev_err(dev, "failed to request IRQ #%d: %d\n", irq, error); |
140 | irq, error); | ||
141 | return error; | 139 | return error; |
142 | } | 140 | } |
143 | 141 | ||
diff --git a/drivers/input/misc/twl4030-pwrbutton.c b/drivers/input/misc/twl4030-pwrbutton.c index 603fc2fadf05..54162d2cbcfc 100644 --- a/drivers/input/misc/twl4030-pwrbutton.c +++ b/drivers/input/misc/twl4030-pwrbutton.c | |||
@@ -85,7 +85,6 @@ static int twl4030_pwrbutton_probe(struct platform_device *pdev) | |||
85 | return err; | 85 | return err; |
86 | } | 86 | } |
87 | 87 | ||
88 | platform_set_drvdata(pdev, pwr); | ||
89 | device_init_wakeup(&pdev->dev, true); | 88 | device_init_wakeup(&pdev->dev, true); |
90 | 89 | ||
91 | return 0; | 90 | return 0; |
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 328edc8c8786..72b28ebfe360 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c | |||
@@ -1855,7 +1855,7 @@ static int alps_absolute_mode_v1_v2(struct psmouse *psmouse) | |||
1855 | * Switch mouse to poll (remote) mode so motion data will not | 1855 | * Switch mouse to poll (remote) mode so motion data will not |
1856 | * get in our way | 1856 | * get in our way |
1857 | */ | 1857 | */ |
1858 | return ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETPOLL); | 1858 | return ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETPOLL); |
1859 | } | 1859 | } |
1860 | 1860 | ||
1861 | static int alps_monitor_mode_send_word(struct psmouse *psmouse, u16 word) | 1861 | static int alps_monitor_mode_send_word(struct psmouse *psmouse, u16 word) |
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c index 30e3442518f8..d0122134f320 100644 --- a/drivers/input/mouse/bcm5974.c +++ b/drivers/input/mouse/bcm5974.c | |||
@@ -665,7 +665,7 @@ static int bcm5974_wellspring_mode(struct bcm5974 *dev, bool on) | |||
665 | char *data; | 665 | char *data; |
666 | 666 | ||
667 | /* Type 3 does not require a mode switch */ | 667 | /* Type 3 does not require a mode switch */ |
668 | if (dev->cfg.tp_type == TYPE3) | 668 | if (c->tp_type == TYPE3) |
669 | return 0; | 669 | return 0; |
670 | 670 | ||
671 | data = kmalloc(c->um_size, GFP_KERNEL); | 671 | data = kmalloc(c->um_size, GFP_KERNEL); |
diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c index dc2394292088..fd8865c65caf 100644 --- a/drivers/input/mouse/cyapa.c +++ b/drivers/input/mouse/cyapa.c | |||
@@ -832,8 +832,8 @@ static int cyapa_prepare_wakeup_controls(struct cyapa *cyapa) | |||
832 | int error; | 832 | int error; |
833 | 833 | ||
834 | if (device_can_wakeup(dev)) { | 834 | if (device_can_wakeup(dev)) { |
835 | error = sysfs_merge_group(&client->dev.kobj, | 835 | error = sysfs_merge_group(&dev->kobj, |
836 | &cyapa_power_wakeup_group); | 836 | &cyapa_power_wakeup_group); |
837 | if (error) { | 837 | if (error) { |
838 | dev_err(dev, "failed to add power wakeup group: %d\n", | 838 | dev_err(dev, "failed to add power wakeup group: %d\n", |
839 | error); | 839 | error); |
@@ -1312,7 +1312,7 @@ static int cyapa_probe(struct i2c_client *client, | |||
1312 | return error; | 1312 | return error; |
1313 | } | 1313 | } |
1314 | 1314 | ||
1315 | error = sysfs_create_group(&client->dev.kobj, &cyapa_sysfs_group); | 1315 | error = sysfs_create_group(&dev->kobj, &cyapa_sysfs_group); |
1316 | if (error) { | 1316 | if (error) { |
1317 | dev_err(dev, "failed to create sysfs entries: %d\n", error); | 1317 | dev_err(dev, "failed to create sysfs entries: %d\n", error); |
1318 | return error; | 1318 | return error; |
diff --git a/drivers/input/mouse/cyapa_gen3.c b/drivers/input/mouse/cyapa_gen3.c index f9600753eca5..1cbfa4a6e830 100644 --- a/drivers/input/mouse/cyapa_gen3.c +++ b/drivers/input/mouse/cyapa_gen3.c | |||
@@ -562,7 +562,7 @@ static int cyapa_gen3_bl_exit(struct cyapa *cyapa) | |||
562 | * Wait for bootloader to exit, and operation mode to start. | 562 | * Wait for bootloader to exit, and operation mode to start. |
563 | * Normally, this takes at least 50 ms. | 563 | * Normally, this takes at least 50 ms. |
564 | */ | 564 | */ |
565 | usleep_range(50000, 100000); | 565 | msleep(50); |
566 | /* | 566 | /* |
567 | * In addition, when a device boots for the first time after being | 567 | * In addition, when a device boots for the first time after being |
568 | * updated to new firmware, it must first calibrate its sensors, which | 568 | * updated to new firmware, it must first calibrate its sensors, which |
@@ -789,7 +789,7 @@ static ssize_t cyapa_gen3_do_calibrate(struct device *dev, | |||
789 | const char *buf, size_t count) | 789 | const char *buf, size_t count) |
790 | { | 790 | { |
791 | struct cyapa *cyapa = dev_get_drvdata(dev); | 791 | struct cyapa *cyapa = dev_get_drvdata(dev); |
792 | int tries; | 792 | unsigned long timeout; |
793 | int ret; | 793 | int ret; |
794 | 794 | ||
795 | ret = cyapa_read_byte(cyapa, CYAPA_CMD_DEV_STATUS); | 795 | ret = cyapa_read_byte(cyapa, CYAPA_CMD_DEV_STATUS); |
@@ -812,31 +812,28 @@ static ssize_t cyapa_gen3_do_calibrate(struct device *dev, | |||
812 | goto out; | 812 | goto out; |
813 | } | 813 | } |
814 | 814 | ||
815 | tries = 20; /* max recalibration timeout 2s. */ | 815 | /* max recalibration timeout 2s. */ |
816 | timeout = jiffies + 2 * HZ; | ||
816 | do { | 817 | do { |
817 | /* | 818 | /* |
818 | * For this recalibration, the max time will not exceed 2s. | 819 | * For this recalibration, the max time will not exceed 2s. |
819 | * The average time is approximately 500 - 700 ms, and we | 820 | * The average time is approximately 500 - 700 ms, and we |
820 | * will check the status every 100 - 200ms. | 821 | * will check the status every 100 - 200ms. |
821 | */ | 822 | */ |
822 | usleep_range(100000, 200000); | 823 | msleep(100); |
823 | |||
824 | ret = cyapa_read_byte(cyapa, CYAPA_CMD_DEV_STATUS); | 824 | ret = cyapa_read_byte(cyapa, CYAPA_CMD_DEV_STATUS); |
825 | if (ret < 0) { | 825 | if (ret < 0) { |
826 | dev_err(dev, "Error reading dev status: %d\n", | 826 | dev_err(dev, "Error reading dev status: %d\n", ret); |
827 | ret); | ||
828 | goto out; | 827 | goto out; |
829 | } | 828 | } |
830 | if ((ret & CYAPA_DEV_NORMAL) == CYAPA_DEV_NORMAL) | 829 | if ((ret & CYAPA_DEV_NORMAL) == CYAPA_DEV_NORMAL) { |
831 | break; | 830 | dev_dbg(dev, "Calibration successful.\n"); |
832 | } while (--tries); | 831 | goto out; |
832 | } | ||
833 | } while (time_is_after_jiffies(timeout)); | ||
833 | 834 | ||
834 | if (tries == 0) { | 835 | dev_err(dev, "Failed to calibrate. Timeout.\n"); |
835 | dev_err(dev, "Failed to calibrate. Timeout.\n"); | 836 | ret = -ETIMEDOUT; |
836 | ret = -ETIMEDOUT; | ||
837 | goto out; | ||
838 | } | ||
839 | dev_dbg(dev, "Calibration successful.\n"); | ||
840 | 837 | ||
841 | out: | 838 | out: |
842 | return ret < 0 ? ret : count; | 839 | return ret < 0 ? ret : count; |
diff --git a/drivers/input/mouse/cypress_ps2.c b/drivers/input/mouse/cypress_ps2.c index 28dcfc822bf6..21bad3e75fee 100644 --- a/drivers/input/mouse/cypress_ps2.c +++ b/drivers/input/mouse/cypress_ps2.c | |||
@@ -107,7 +107,7 @@ static int cypress_ps2_read_cmd_status(struct psmouse *psmouse, | |||
107 | enum psmouse_state old_state; | 107 | enum psmouse_state old_state; |
108 | int pktsize; | 108 | int pktsize; |
109 | 109 | ||
110 | ps2_begin_command(&psmouse->ps2dev); | 110 | ps2_begin_command(ps2dev); |
111 | 111 | ||
112 | old_state = psmouse->state; | 112 | old_state = psmouse->state; |
113 | psmouse->state = PSMOUSE_CMD_MODE; | 113 | psmouse->state = PSMOUSE_CMD_MODE; |
@@ -133,7 +133,7 @@ out: | |||
133 | psmouse->state = old_state; | 133 | psmouse->state = old_state; |
134 | psmouse->pktcnt = 0; | 134 | psmouse->pktcnt = 0; |
135 | 135 | ||
136 | ps2_end_command(&psmouse->ps2dev); | 136 | ps2_end_command(ps2dev); |
137 | 137 | ||
138 | return rc; | 138 | return rc; |
139 | } | 139 | } |
@@ -414,8 +414,6 @@ static int cypress_set_input_params(struct input_dev *input, | |||
414 | __set_bit(BTN_RIGHT, input->keybit); | 414 | __set_bit(BTN_RIGHT, input->keybit); |
415 | __set_bit(BTN_MIDDLE, input->keybit); | 415 | __set_bit(BTN_MIDDLE, input->keybit); |
416 | 416 | ||
417 | input_set_drvdata(input, cytp); | ||
418 | |||
419 | return 0; | 417 | return 0; |
420 | } | 418 | } |
421 | 419 | ||
diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c index 1e1d0ad406f2..352050e9031d 100644 --- a/drivers/input/mouse/elan_i2c_core.c +++ b/drivers/input/mouse/elan_i2c_core.c | |||
@@ -1041,8 +1041,7 @@ static int elan_probe(struct i2c_client *client, | |||
1041 | return -EIO; | 1041 | return -EIO; |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | data = devm_kzalloc(&client->dev, sizeof(struct elan_tp_data), | 1044 | data = devm_kzalloc(dev, sizeof(struct elan_tp_data), GFP_KERNEL); |
1045 | GFP_KERNEL); | ||
1046 | if (!data) | 1045 | if (!data) |
1047 | return -ENOMEM; | 1046 | return -ENOMEM; |
1048 | 1047 | ||
@@ -1053,29 +1052,25 @@ static int elan_probe(struct i2c_client *client, | |||
1053 | init_completion(&data->fw_completion); | 1052 | init_completion(&data->fw_completion); |
1054 | mutex_init(&data->sysfs_mutex); | 1053 | mutex_init(&data->sysfs_mutex); |
1055 | 1054 | ||
1056 | data->vcc = devm_regulator_get(&client->dev, "vcc"); | 1055 | data->vcc = devm_regulator_get(dev, "vcc"); |
1057 | if (IS_ERR(data->vcc)) { | 1056 | if (IS_ERR(data->vcc)) { |
1058 | error = PTR_ERR(data->vcc); | 1057 | error = PTR_ERR(data->vcc); |
1059 | if (error != -EPROBE_DEFER) | 1058 | if (error != -EPROBE_DEFER) |
1060 | dev_err(&client->dev, | 1059 | dev_err(dev, "Failed to get 'vcc' regulator: %d\n", |
1061 | "Failed to get 'vcc' regulator: %d\n", | ||
1062 | error); | 1060 | error); |
1063 | return error; | 1061 | return error; |
1064 | } | 1062 | } |
1065 | 1063 | ||
1066 | error = regulator_enable(data->vcc); | 1064 | error = regulator_enable(data->vcc); |
1067 | if (error) { | 1065 | if (error) { |
1068 | dev_err(&client->dev, | 1066 | dev_err(dev, "Failed to enable regulator: %d\n", error); |
1069 | "Failed to enable regulator: %d\n", error); | ||
1070 | return error; | 1067 | return error; |
1071 | } | 1068 | } |
1072 | 1069 | ||
1073 | error = devm_add_action(&client->dev, | 1070 | error = devm_add_action(dev, elan_disable_regulator, data); |
1074 | elan_disable_regulator, data); | ||
1075 | if (error) { | 1071 | if (error) { |
1076 | regulator_disable(data->vcc); | 1072 | regulator_disable(data->vcc); |
1077 | dev_err(&client->dev, | 1073 | dev_err(dev, "Failed to add disable regulator action: %d\n", |
1078 | "Failed to add disable regulator action: %d\n", | ||
1079 | error); | 1074 | error); |
1080 | return error; | 1075 | return error; |
1081 | } | 1076 | } |
@@ -1093,14 +1088,14 @@ static int elan_probe(struct i2c_client *client, | |||
1093 | if (error) | 1088 | if (error) |
1094 | return error; | 1089 | return error; |
1095 | 1090 | ||
1096 | dev_info(&client->dev, | 1091 | dev_info(dev, |
1097 | "Elan Touchpad: Module ID: 0x%04x, Firmware: 0x%04x, Sample: 0x%04x, IAP: 0x%04x\n", | 1092 | "Elan Touchpad: Module ID: 0x%04x, Firmware: 0x%04x, Sample: 0x%04x, IAP: 0x%04x\n", |
1098 | data->product_id, | 1093 | data->product_id, |
1099 | data->fw_version, | 1094 | data->fw_version, |
1100 | data->sm_version, | 1095 | data->sm_version, |
1101 | data->iap_version); | 1096 | data->iap_version); |
1102 | 1097 | ||
1103 | dev_dbg(&client->dev, | 1098 | dev_dbg(dev, |
1104 | "Elan Touchpad Extra Information:\n" | 1099 | "Elan Touchpad Extra Information:\n" |
1105 | " Max ABS X,Y: %d,%d\n" | 1100 | " Max ABS X,Y: %d,%d\n" |
1106 | " Width X,Y: %d,%d\n" | 1101 | " Width X,Y: %d,%d\n" |
@@ -1118,38 +1113,33 @@ static int elan_probe(struct i2c_client *client, | |||
1118 | * Systems using device tree should set up interrupt via DTS, | 1113 | * Systems using device tree should set up interrupt via DTS, |
1119 | * the rest will use the default falling edge interrupts. | 1114 | * the rest will use the default falling edge interrupts. |
1120 | */ | 1115 | */ |
1121 | irqflags = client->dev.of_node ? 0 : IRQF_TRIGGER_FALLING; | 1116 | irqflags = dev->of_node ? 0 : IRQF_TRIGGER_FALLING; |
1122 | 1117 | ||
1123 | error = devm_request_threaded_irq(&client->dev, client->irq, | 1118 | error = devm_request_threaded_irq(dev, client->irq, NULL, elan_isr, |
1124 | NULL, elan_isr, | ||
1125 | irqflags | IRQF_ONESHOT, | 1119 | irqflags | IRQF_ONESHOT, |
1126 | client->name, data); | 1120 | client->name, data); |
1127 | if (error) { | 1121 | if (error) { |
1128 | dev_err(&client->dev, "cannot register irq=%d\n", client->irq); | 1122 | dev_err(dev, "cannot register irq=%d\n", client->irq); |
1129 | return error; | 1123 | return error; |
1130 | } | 1124 | } |
1131 | 1125 | ||
1132 | error = sysfs_create_groups(&client->dev.kobj, elan_sysfs_groups); | 1126 | error = sysfs_create_groups(&dev->kobj, elan_sysfs_groups); |
1133 | if (error) { | 1127 | if (error) { |
1134 | dev_err(&client->dev, "failed to create sysfs attributes: %d\n", | 1128 | dev_err(dev, "failed to create sysfs attributes: %d\n", error); |
1135 | error); | ||
1136 | return error; | 1129 | return error; |
1137 | } | 1130 | } |
1138 | 1131 | ||
1139 | error = devm_add_action(&client->dev, | 1132 | error = devm_add_action(dev, elan_remove_sysfs_groups, data); |
1140 | elan_remove_sysfs_groups, data); | ||
1141 | if (error) { | 1133 | if (error) { |
1142 | elan_remove_sysfs_groups(data); | 1134 | elan_remove_sysfs_groups(data); |
1143 | dev_err(&client->dev, | 1135 | dev_err(dev, "Failed to add sysfs cleanup action: %d\n", |
1144 | "Failed to add sysfs cleanup action: %d\n", | ||
1145 | error); | 1136 | error); |
1146 | return error; | 1137 | return error; |
1147 | } | 1138 | } |
1148 | 1139 | ||
1149 | error = input_register_device(data->input); | 1140 | error = input_register_device(data->input); |
1150 | if (error) { | 1141 | if (error) { |
1151 | dev_err(&client->dev, "failed to register input device: %d\n", | 1142 | dev_err(dev, "failed to register input device: %d\n", error); |
1152 | error); | ||
1153 | return error; | 1143 | return error; |
1154 | } | 1144 | } |
1155 | 1145 | ||
@@ -1157,8 +1147,8 @@ static int elan_probe(struct i2c_client *client, | |||
1157 | * Systems using device tree should set up wakeup via DTS, | 1147 | * Systems using device tree should set up wakeup via DTS, |
1158 | * the rest will configure device as wakeup source by default. | 1148 | * the rest will configure device as wakeup source by default. |
1159 | */ | 1149 | */ |
1160 | if (!client->dev.of_node) | 1150 | if (!dev->of_node) |
1161 | device_init_wakeup(&client->dev, true); | 1151 | device_init_wakeup(dev, true); |
1162 | 1152 | ||
1163 | return 0; | 1153 | return 0; |
1164 | } | 1154 | } |
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index db7d1d666ac1..efc8ec342351 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c | |||
@@ -1412,7 +1412,7 @@ int elantech_detect(struct psmouse *psmouse, bool set_properties) | |||
1412 | struct ps2dev *ps2dev = &psmouse->ps2dev; | 1412 | struct ps2dev *ps2dev = &psmouse->ps2dev; |
1413 | unsigned char param[3]; | 1413 | unsigned char param[3]; |
1414 | 1414 | ||
1415 | ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS); | 1415 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_DIS); |
1416 | 1416 | ||
1417 | if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) || | 1417 | if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) || |
1418 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || | 1418 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || |
diff --git a/drivers/input/mouse/hgpk.c b/drivers/input/mouse/hgpk.c index 62be888e83d0..015509e0b140 100644 --- a/drivers/input/mouse/hgpk.c +++ b/drivers/input/mouse/hgpk.c | |||
@@ -713,8 +713,7 @@ static int hgpk_toggle_powersave(struct psmouse *psmouse, int enable) | |||
713 | * the upper bound. (in practice, it takes about 3 loops.) | 713 | * the upper bound. (in practice, it takes about 3 loops.) |
714 | */ | 714 | */ |
715 | for (timeo = 20; timeo > 0; timeo--) { | 715 | for (timeo = 20; timeo > 0; timeo--) { |
716 | if (!ps2_sendbyte(&psmouse->ps2dev, | 716 | if (!ps2_sendbyte(ps2dev, PSMOUSE_CMD_DISABLE, 20)) |
717 | PSMOUSE_CMD_DISABLE, 20)) | ||
718 | break; | 717 | break; |
719 | msleep(25); | 718 | msleep(25); |
720 | } | 719 | } |
@@ -740,7 +739,7 @@ static int hgpk_toggle_powersave(struct psmouse *psmouse, int enable) | |||
740 | psmouse_set_state(psmouse, PSMOUSE_IGNORE); | 739 | psmouse_set_state(psmouse, PSMOUSE_IGNORE); |
741 | 740 | ||
742 | /* probably won't see an ACK, the touchpad will be off */ | 741 | /* probably won't see an ACK, the touchpad will be off */ |
743 | ps2_sendbyte(&psmouse->ps2dev, 0xec, 20); | 742 | ps2_sendbyte(ps2dev, 0xec, 20); |
744 | } | 743 | } |
745 | 744 | ||
746 | return 0; | 745 | return 0; |
diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c index 422da1cd9e76..ef9c97f5e3d7 100644 --- a/drivers/input/mouse/logips2pp.c +++ b/drivers/input/mouse/logips2pp.c | |||
@@ -402,7 +402,7 @@ int ps2pp_detect(struct psmouse *psmouse, bool set_properties) | |||
402 | psmouse->set_resolution = ps2pp_set_resolution; | 402 | psmouse->set_resolution = ps2pp_set_resolution; |
403 | psmouse->disconnect = ps2pp_disconnect; | 403 | psmouse->disconnect = ps2pp_disconnect; |
404 | 404 | ||
405 | error = device_create_file(&psmouse->ps2dev.serio->dev, | 405 | error = device_create_file(&ps2dev->serio->dev, |
406 | &psmouse_attr_smartscroll.dattr); | 406 | &psmouse_attr_smartscroll.dattr); |
407 | if (error) { | 407 | if (error) { |
408 | psmouse_err(psmouse, | 408 | psmouse_err(psmouse, |
diff --git a/drivers/input/mouse/maplemouse.c b/drivers/input/mouse/maplemouse.c index 0a60717b91c6..25f0ecb90126 100644 --- a/drivers/input/mouse/maplemouse.c +++ b/drivers/input/mouse/maplemouse.c | |||
@@ -87,7 +87,6 @@ static int probe_maple_mouse(struct device *dev) | |||
87 | mse->dev = input_dev; | 87 | mse->dev = input_dev; |
88 | mse->mdev = mdev; | 88 | mse->mdev = mdev; |
89 | 89 | ||
90 | input_set_drvdata(input_dev, mse); | ||
91 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); | 90 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
92 | input_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | | 91 | input_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | |
93 | BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE); | 92 | BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE); |
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index bee267424972..a598b7223cef 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c | |||
@@ -127,6 +127,13 @@ struct psmouse_protocol { | |||
127 | int (*init)(struct psmouse *); | 127 | int (*init)(struct psmouse *); |
128 | }; | 128 | }; |
129 | 129 | ||
130 | static void psmouse_report_standard_buttons(struct input_dev *dev, u8 buttons) | ||
131 | { | ||
132 | input_report_key(dev, BTN_LEFT, buttons & BIT(0)); | ||
133 | input_report_key(dev, BTN_MIDDLE, buttons & BIT(2)); | ||
134 | input_report_key(dev, BTN_RIGHT, buttons & BIT(1)); | ||
135 | } | ||
136 | |||
130 | /* | 137 | /* |
131 | * psmouse_process_byte() analyzes the PS/2 data stream and reports | 138 | * psmouse_process_byte() analyzes the PS/2 data stream and reports |
132 | * relevant events to the input module once full packet has arrived. | 139 | * relevant events to the input module once full packet has arrived. |
@@ -199,9 +206,8 @@ psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse) | |||
199 | } | 206 | } |
200 | 207 | ||
201 | /* Generic PS/2 Mouse */ | 208 | /* Generic PS/2 Mouse */ |
202 | input_report_key(dev, BTN_LEFT, packet[0] & 1); | 209 | psmouse_report_standard_buttons(dev, |
203 | input_report_key(dev, BTN_MIDDLE, (packet[0] >> 2) & 1); | 210 | packet[0] | psmouse->extra_buttons); |
204 | input_report_key(dev, BTN_RIGHT, (packet[0] >> 1) & 1); | ||
205 | 211 | ||
206 | input_report_rel(dev, REL_X, packet[1] ? (int) packet[1] - (int) ((packet[0] << 4) & 0x100) : 0); | 212 | input_report_rel(dev, REL_X, packet[1] ? (int) packet[1] - (int) ((packet[0] << 4) & 0x100) : 0); |
207 | input_report_rel(dev, REL_Y, packet[2] ? (int) ((packet[0] << 3) & 0x100) - (int) packet[2] : 0); | 213 | input_report_rel(dev, REL_Y, packet[2] ? (int) ((packet[0] << 3) & 0x100) - (int) packet[2] : 0); |
@@ -282,6 +288,30 @@ static int psmouse_handle_byte(struct psmouse *psmouse) | |||
282 | return 0; | 288 | return 0; |
283 | } | 289 | } |
284 | 290 | ||
291 | static void psmouse_handle_oob_data(struct psmouse *psmouse, u8 data) | ||
292 | { | ||
293 | switch (psmouse->oob_data_type) { | ||
294 | case PSMOUSE_OOB_NONE: | ||
295 | psmouse->oob_data_type = data; | ||
296 | break; | ||
297 | |||
298 | case PSMOUSE_OOB_EXTRA_BTNS: | ||
299 | psmouse_report_standard_buttons(psmouse->dev, data); | ||
300 | input_sync(psmouse->dev); | ||
301 | |||
302 | psmouse->extra_buttons = data; | ||
303 | psmouse->oob_data_type = PSMOUSE_OOB_NONE; | ||
304 | break; | ||
305 | |||
306 | default: | ||
307 | psmouse_warn(psmouse, | ||
308 | "unknown OOB_DATA type: 0x%02x\n", | ||
309 | psmouse->oob_data_type); | ||
310 | psmouse->oob_data_type = PSMOUSE_OOB_NONE; | ||
311 | break; | ||
312 | } | ||
313 | } | ||
314 | |||
285 | /* | 315 | /* |
286 | * psmouse_interrupt() handles incoming characters, either passing them | 316 | * psmouse_interrupt() handles incoming characters, either passing them |
287 | * for normal processing or gathering them as command response. | 317 | * for normal processing or gathering them as command response. |
@@ -306,6 +336,11 @@ static irqreturn_t psmouse_interrupt(struct serio *serio, | |||
306 | goto out; | 336 | goto out; |
307 | } | 337 | } |
308 | 338 | ||
339 | if (flags & SERIO_OOB_DATA) { | ||
340 | psmouse_handle_oob_data(psmouse, data); | ||
341 | goto out; | ||
342 | } | ||
343 | |||
309 | if (unlikely(psmouse->ps2dev.flags & PS2_FLAG_ACK)) | 344 | if (unlikely(psmouse->ps2dev.flags & PS2_FLAG_ACK)) |
310 | if (ps2_handle_ack(&psmouse->ps2dev, data)) | 345 | if (ps2_handle_ack(&psmouse->ps2dev, data)) |
311 | goto out; | 346 | goto out; |
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h index e0ca6cda3d16..8c83b8e2505c 100644 --- a/drivers/input/mouse/psmouse.h +++ b/drivers/input/mouse/psmouse.h | |||
@@ -1,6 +1,9 @@ | |||
1 | #ifndef _PSMOUSE_H | 1 | #ifndef _PSMOUSE_H |
2 | #define _PSMOUSE_H | 2 | #define _PSMOUSE_H |
3 | 3 | ||
4 | #define PSMOUSE_OOB_NONE 0x00 | ||
5 | #define PSMOUSE_OOB_EXTRA_BTNS 0x01 | ||
6 | |||
4 | #define PSMOUSE_CMD_SETSCALE11 0x00e6 | 7 | #define PSMOUSE_CMD_SETSCALE11 0x00e6 |
5 | #define PSMOUSE_CMD_SETSCALE21 0x00e7 | 8 | #define PSMOUSE_CMD_SETSCALE21 0x00e7 |
6 | #define PSMOUSE_CMD_SETRES 0x10e8 | 9 | #define PSMOUSE_CMD_SETRES 0x10e8 |
@@ -53,6 +56,8 @@ struct psmouse { | |||
53 | unsigned char pktcnt; | 56 | unsigned char pktcnt; |
54 | unsigned char pktsize; | 57 | unsigned char pktsize; |
55 | unsigned char type; | 58 | unsigned char type; |
59 | unsigned char oob_data_type; | ||
60 | unsigned char extra_buttons; | ||
56 | bool ignore_parity; | 61 | bool ignore_parity; |
57 | bool acks_disable_command; | 62 | bool acks_disable_command; |
58 | unsigned int model; | 63 | unsigned int model; |
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c index a41d8328c064..597ee4b01d9f 100644 --- a/drivers/input/mouse/synaptics.c +++ b/drivers/input/mouse/synaptics.c | |||
@@ -597,15 +597,13 @@ static int synaptics_is_pt_packet(unsigned char *buf) | |||
597 | return (buf[0] & 0xFC) == 0x84 && (buf[3] & 0xCC) == 0xC4; | 597 | return (buf[0] & 0xFC) == 0x84 && (buf[3] & 0xCC) == 0xC4; |
598 | } | 598 | } |
599 | 599 | ||
600 | static void synaptics_pass_pt_packet(struct psmouse *psmouse, | 600 | static void synaptics_pass_pt_packet(struct serio *ptport, |
601 | struct serio *ptport, | ||
602 | unsigned char *packet) | 601 | unsigned char *packet) |
603 | { | 602 | { |
604 | struct synaptics_data *priv = psmouse->private; | ||
605 | struct psmouse *child = serio_get_drvdata(ptport); | 603 | struct psmouse *child = serio_get_drvdata(ptport); |
606 | 604 | ||
607 | if (child && child->state == PSMOUSE_ACTIVATED) { | 605 | if (child && child->state == PSMOUSE_ACTIVATED) { |
608 | serio_interrupt(ptport, packet[1] | priv->pt_buttons, 0); | 606 | serio_interrupt(ptport, packet[1], 0); |
609 | serio_interrupt(ptport, packet[4], 0); | 607 | serio_interrupt(ptport, packet[4], 0); |
610 | serio_interrupt(ptport, packet[5], 0); | 608 | serio_interrupt(ptport, packet[5], 0); |
611 | if (child->pktsize == 4) | 609 | if (child->pktsize == 4) |
@@ -856,7 +854,6 @@ static void synaptics_report_ext_buttons(struct psmouse *psmouse, | |||
856 | struct input_dev *dev = psmouse->dev; | 854 | struct input_dev *dev = psmouse->dev; |
857 | struct synaptics_data *priv = psmouse->private; | 855 | struct synaptics_data *priv = psmouse->private; |
858 | int ext_bits = (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) + 1) >> 1; | 856 | int ext_bits = (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) + 1) >> 1; |
859 | char buf[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; | ||
860 | int i; | 857 | int i; |
861 | 858 | ||
862 | if (!SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap)) | 859 | if (!SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap)) |
@@ -883,15 +880,18 @@ static void synaptics_report_ext_buttons(struct psmouse *psmouse, | |||
883 | * physically wired to the touchpad. Re-route them through | 880 | * physically wired to the touchpad. Re-route them through |
884 | * the pass-through interface. | 881 | * the pass-through interface. |
885 | */ | 882 | */ |
886 | if (!priv->pt_port) | 883 | if (priv->pt_port) { |
887 | return; | 884 | u8 pt_buttons; |
888 | 885 | ||
889 | /* The trackstick expects at most 3 buttons */ | 886 | /* The trackstick expects at most 3 buttons */ |
890 | priv->pt_buttons = SYN_CAP_EXT_BUTTON_STICK_L(hw->ext_buttons) | | 887 | pt_buttons = SYN_CAP_EXT_BUTTON_STICK_L(hw->ext_buttons) | |
891 | SYN_CAP_EXT_BUTTON_STICK_R(hw->ext_buttons) << 1 | | 888 | SYN_CAP_EXT_BUTTON_STICK_R(hw->ext_buttons) << 1 | |
892 | SYN_CAP_EXT_BUTTON_STICK_M(hw->ext_buttons) << 2; | 889 | SYN_CAP_EXT_BUTTON_STICK_M(hw->ext_buttons) << 2; |
893 | 890 | ||
894 | synaptics_pass_pt_packet(psmouse, priv->pt_port, buf); | 891 | serio_interrupt(priv->pt_port, |
892 | PSMOUSE_OOB_EXTRA_BTNS, SERIO_OOB_DATA); | ||
893 | serio_interrupt(priv->pt_port, pt_buttons, SERIO_OOB_DATA); | ||
894 | } | ||
895 | } | 895 | } |
896 | 896 | ||
897 | static void synaptics_report_buttons(struct psmouse *psmouse, | 897 | static void synaptics_report_buttons(struct psmouse *psmouse, |
@@ -1132,7 +1132,7 @@ static psmouse_ret_t synaptics_process_byte(struct psmouse *psmouse) | |||
1132 | if (SYN_CAP_PASS_THROUGH(priv->capabilities) && | 1132 | if (SYN_CAP_PASS_THROUGH(priv->capabilities) && |
1133 | synaptics_is_pt_packet(psmouse->packet)) { | 1133 | synaptics_is_pt_packet(psmouse->packet)) { |
1134 | if (priv->pt_port) | 1134 | if (priv->pt_port) |
1135 | synaptics_pass_pt_packet(psmouse, priv->pt_port, | 1135 | synaptics_pass_pt_packet(priv->pt_port, |
1136 | psmouse->packet); | 1136 | psmouse->packet); |
1137 | } else | 1137 | } else |
1138 | synaptics_process_packet(psmouse); | 1138 | synaptics_process_packet(psmouse); |
diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h index 56faa7ec4434..116ae2546ace 100644 --- a/drivers/input/mouse/synaptics.h +++ b/drivers/input/mouse/synaptics.h | |||
@@ -183,7 +183,6 @@ struct synaptics_data { | |||
183 | bool disable_gesture; /* disable gestures */ | 183 | bool disable_gesture; /* disable gestures */ |
184 | 184 | ||
185 | struct serio *pt_port; /* Pass-through serio port */ | 185 | struct serio *pt_port; /* Pass-through serio port */ |
186 | unsigned char pt_buttons; /* Pass-through buttons */ | ||
187 | 186 | ||
188 | /* | 187 | /* |
189 | * Last received Advanced Gesture Mode (AGM) packet. An AGM packet | 188 | * Last received Advanced Gesture Mode (AGM) packet. An AGM packet |
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c index 7331084973e1..922ea02edcc3 100644 --- a/drivers/input/mouse/trackpoint.c +++ b/drivers/input/mouse/trackpoint.c | |||
@@ -379,7 +379,7 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties) | |||
379 | if (!set_properties) | 379 | if (!set_properties) |
380 | return 0; | 380 | return 0; |
381 | 381 | ||
382 | if (trackpoint_read(&psmouse->ps2dev, TP_EXT_BTN, &button_info)) { | 382 | if (trackpoint_read(ps2dev, TP_EXT_BTN, &button_info)) { |
383 | psmouse_warn(psmouse, "failed to get extended button data\n"); | 383 | psmouse_warn(psmouse, "failed to get extended button data\n"); |
384 | button_info = 0; | 384 | button_info = 0; |
385 | } | 385 | } |
@@ -402,7 +402,7 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties) | |||
402 | 402 | ||
403 | trackpoint_defaults(psmouse->private); | 403 | trackpoint_defaults(psmouse->private); |
404 | 404 | ||
405 | error = trackpoint_power_on_reset(&psmouse->ps2dev); | 405 | error = trackpoint_power_on_reset(ps2dev); |
406 | 406 | ||
407 | /* Write defaults to TP only if reset fails. */ | 407 | /* Write defaults to TP only if reset fails. */ |
408 | if (error) | 408 | if (error) |
diff --git a/drivers/input/rmi4/Kconfig b/drivers/input/rmi4/Kconfig index bb7762bf2879..7172b88cd064 100644 --- a/drivers/input/rmi4/Kconfig +++ b/drivers/input/rmi4/Kconfig | |||
@@ -9,9 +9,11 @@ config RMI4_CORE | |||
9 | 9 | ||
10 | If unsure, say Y. | 10 | If unsure, say Y. |
11 | 11 | ||
12 | if RMI4_CORE | ||
13 | |||
12 | config RMI4_I2C | 14 | config RMI4_I2C |
13 | tristate "RMI4 I2C Support" | 15 | tristate "RMI4 I2C Support" |
14 | depends on RMI4_CORE && I2C | 16 | depends on I2C |
15 | help | 17 | help |
16 | Say Y here if you want to support RMI4 devices connected to an I2C | 18 | Say Y here if you want to support RMI4 devices connected to an I2C |
17 | bus. | 19 | bus. |
@@ -20,7 +22,7 @@ config RMI4_I2C | |||
20 | 22 | ||
21 | config RMI4_SPI | 23 | config RMI4_SPI |
22 | tristate "RMI4 SPI Support" | 24 | tristate "RMI4 SPI Support" |
23 | depends on RMI4_CORE && SPI | 25 | depends on SPI |
24 | help | 26 | help |
25 | Say Y here if you want to support RMI4 devices connected to a SPI | 27 | Say Y here if you want to support RMI4 devices connected to a SPI |
26 | bus. | 28 | bus. |
@@ -29,7 +31,7 @@ config RMI4_SPI | |||
29 | 31 | ||
30 | config RMI4_SMB | 32 | config RMI4_SMB |
31 | tristate "RMI4 SMB Support" | 33 | tristate "RMI4 SMB Support" |
32 | depends on RMI4_CORE && I2C | 34 | depends on I2C |
33 | help | 35 | help |
34 | Say Y here if you want to support RMI4 devices connected to an SMB | 36 | Say Y here if you want to support RMI4 devices connected to an SMB |
35 | bus. | 37 | bus. |
@@ -40,13 +42,13 @@ config RMI4_SMB | |||
40 | called rmi_smbus. | 42 | called rmi_smbus. |
41 | 43 | ||
42 | config RMI4_F03 | 44 | config RMI4_F03 |
43 | bool "RMI4 Function 03 (PS2 Guest)" | 45 | bool "RMI4 Function 03 (PS2 Guest)" |
44 | depends on RMI4_CORE | 46 | depends on RMI4_CORE |
45 | help | 47 | help |
46 | Say Y here if you want to add support for RMI4 function 03. | 48 | Say Y here if you want to add support for RMI4 function 03. |
47 | 49 | ||
48 | Function 03 provides PS2 guest support for RMI4 devices. This | 50 | Function 03 provides PS2 guest support for RMI4 devices. This |
49 | includes support for TrackPoints on TouchPads. | 51 | includes support for TrackPoints on TouchPads. |
50 | 52 | ||
51 | config RMI4_F03_SERIO | 53 | config RMI4_F03_SERIO |
52 | tristate | 54 | tristate |
@@ -57,12 +59,10 @@ config RMI4_F03_SERIO | |||
57 | 59 | ||
58 | config RMI4_2D_SENSOR | 60 | config RMI4_2D_SENSOR |
59 | bool | 61 | bool |
60 | depends on RMI4_CORE | ||
61 | 62 | ||
62 | config RMI4_F11 | 63 | config RMI4_F11 |
63 | bool "RMI4 Function 11 (2D pointing)" | 64 | bool "RMI4 Function 11 (2D pointing)" |
64 | select RMI4_2D_SENSOR | 65 | select RMI4_2D_SENSOR |
65 | depends on RMI4_CORE | ||
66 | help | 66 | help |
67 | Say Y here if you want to add support for RMI4 function 11. | 67 | Say Y here if you want to add support for RMI4 function 11. |
68 | 68 | ||
@@ -73,7 +73,6 @@ config RMI4_F11 | |||
73 | config RMI4_F12 | 73 | config RMI4_F12 |
74 | bool "RMI4 Function 12 (2D pointing)" | 74 | bool "RMI4 Function 12 (2D pointing)" |
75 | select RMI4_2D_SENSOR | 75 | select RMI4_2D_SENSOR |
76 | depends on RMI4_CORE | ||
77 | help | 76 | help |
78 | Say Y here if you want to add support for RMI4 function 12. | 77 | Say Y here if you want to add support for RMI4 function 12. |
79 | 78 | ||
@@ -83,7 +82,6 @@ config RMI4_F12 | |||
83 | 82 | ||
84 | config RMI4_F30 | 83 | config RMI4_F30 |
85 | bool "RMI4 Function 30 (GPIO LED)" | 84 | bool "RMI4 Function 30 (GPIO LED)" |
86 | depends on RMI4_CORE | ||
87 | help | 85 | help |
88 | Say Y here if you want to add support for RMI4 function 30. | 86 | Say Y here if you want to add support for RMI4 function 30. |
89 | 87 | ||
@@ -92,7 +90,6 @@ config RMI4_F30 | |||
92 | 90 | ||
93 | config RMI4_F34 | 91 | config RMI4_F34 |
94 | bool "RMI4 Function 34 (Device reflash)" | 92 | bool "RMI4 Function 34 (Device reflash)" |
95 | depends on RMI4_CORE | ||
96 | select FW_LOADER | 93 | select FW_LOADER |
97 | help | 94 | help |
98 | Say Y here if you want to add support for RMI4 function 34. | 95 | Say Y here if you want to add support for RMI4 function 34. |
@@ -103,7 +100,6 @@ config RMI4_F34 | |||
103 | 100 | ||
104 | config RMI4_F54 | 101 | config RMI4_F54 |
105 | bool "RMI4 Function 54 (Analog diagnostics)" | 102 | bool "RMI4 Function 54 (Analog diagnostics)" |
106 | depends on RMI4_CORE | ||
107 | depends on VIDEO_V4L2=y || (RMI4_CORE=m && VIDEO_V4L2=m) | 103 | depends on VIDEO_V4L2=y || (RMI4_CORE=m && VIDEO_V4L2=m) |
108 | select VIDEOBUF2_VMALLOC | 104 | select VIDEOBUF2_VMALLOC |
109 | select RMI4_F55 | 105 | select RMI4_F55 |
@@ -115,9 +111,10 @@ config RMI4_F54 | |||
115 | 111 | ||
116 | config RMI4_F55 | 112 | config RMI4_F55 |
117 | bool "RMI4 Function 55 (Sensor tuning)" | 113 | bool "RMI4 Function 55 (Sensor tuning)" |
118 | depends on RMI4_CORE | ||
119 | help | 114 | help |
120 | Say Y here if you want to add support for RMI4 function 55 | 115 | Say Y here if you want to add support for RMI4 function 55 |
121 | 116 | ||
122 | Function 55 provides access to the RMI4 touch sensor tuning | 117 | Function 55 provides access to the RMI4 touch sensor tuning |
123 | mechanism. | 118 | mechanism. |
119 | |||
120 | endif # RMI_CORE | ||
diff --git a/drivers/input/rmi4/rmi_2d_sensor.c b/drivers/input/rmi4/rmi_2d_sensor.c index 07007ff8e29f..8bb866c7b985 100644 --- a/drivers/input/rmi4/rmi_2d_sensor.c +++ b/drivers/input/rmi4/rmi_2d_sensor.c | |||
@@ -144,8 +144,13 @@ static void rmi_2d_sensor_set_input_params(struct rmi_2d_sensor *sensor) | |||
144 | int input_flags = 0; | 144 | int input_flags = 0; |
145 | 145 | ||
146 | if (sensor->report_abs) { | 146 | if (sensor->report_abs) { |
147 | if (sensor->axis_align.swap_axes) | 147 | if (sensor->axis_align.swap_axes) { |
148 | swap(sensor->max_x, sensor->max_y); | 148 | swap(sensor->max_x, sensor->max_y); |
149 | swap(sensor->axis_align.clip_x_low, | ||
150 | sensor->axis_align.clip_y_low); | ||
151 | swap(sensor->axis_align.clip_x_high, | ||
152 | sensor->axis_align.clip_y_high); | ||
153 | } | ||
149 | 154 | ||
150 | sensor->min_x = sensor->axis_align.clip_x_low; | 155 | sensor->min_x = sensor->axis_align.clip_x_low; |
151 | if (sensor->axis_align.clip_x_high) | 156 | if (sensor->axis_align.clip_x_high) |
diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c index 1c40d94ca506..ae1bffe45c75 100644 --- a/drivers/input/rmi4/rmi_bus.c +++ b/drivers/input/rmi4/rmi_bus.c | |||
@@ -55,7 +55,7 @@ static void rmi_release_device(struct device *dev) | |||
55 | kfree(rmi_dev); | 55 | kfree(rmi_dev); |
56 | } | 56 | } |
57 | 57 | ||
58 | static struct device_type rmi_device_type = { | 58 | static const struct device_type rmi_device_type = { |
59 | .name = "rmi4_sensor", | 59 | .name = "rmi4_sensor", |
60 | .release = rmi_release_device, | 60 | .release = rmi_release_device, |
61 | }; | 61 | }; |
@@ -134,7 +134,7 @@ static void rmi_release_function(struct device *dev) | |||
134 | kfree(fn); | 134 | kfree(fn); |
135 | } | 135 | } |
136 | 136 | ||
137 | static struct device_type rmi_function_type = { | 137 | static const struct device_type rmi_function_type = { |
138 | .name = "rmi4_function", | 138 | .name = "rmi4_function", |
139 | .release = rmi_release_function, | 139 | .release = rmi_release_function, |
140 | }; | 140 | }; |
@@ -261,10 +261,10 @@ int __rmi_register_function_handler(struct rmi_function_handler *handler, | |||
261 | driver->probe = rmi_function_probe; | 261 | driver->probe = rmi_function_probe; |
262 | driver->remove = rmi_function_remove; | 262 | driver->remove = rmi_function_remove; |
263 | 263 | ||
264 | error = driver_register(&handler->driver); | 264 | error = driver_register(driver); |
265 | if (error) { | 265 | if (error) { |
266 | pr_err("driver_register() failed for %s, error: %d\n", | 266 | pr_err("driver_register() failed for %s, error: %d\n", |
267 | handler->driver.name, error); | 267 | driver->name, error); |
268 | return error; | 268 | return error; |
269 | } | 269 | } |
270 | 270 | ||
diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c index bf5c36e229ba..d64fc92858f2 100644 --- a/drivers/input/rmi4/rmi_driver.c +++ b/drivers/input/rmi4/rmi_driver.c | |||
@@ -265,6 +265,19 @@ static int rmi_irq_init(struct rmi_device *rmi_dev) | |||
265 | return 0; | 265 | return 0; |
266 | } | 266 | } |
267 | 267 | ||
268 | struct rmi_function *rmi_find_function(struct rmi_device *rmi_dev, u8 number) | ||
269 | { | ||
270 | struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); | ||
271 | struct rmi_function *entry; | ||
272 | |||
273 | list_for_each_entry(entry, &data->function_list, node) { | ||
274 | if (entry->fd.function_number == number) | ||
275 | return entry; | ||
276 | } | ||
277 | |||
278 | return NULL; | ||
279 | } | ||
280 | |||
268 | static int suspend_one_function(struct rmi_function *fn) | 281 | static int suspend_one_function(struct rmi_function *fn) |
269 | { | 282 | { |
270 | struct rmi_function_handler *fh; | 283 | struct rmi_function_handler *fh; |
@@ -364,7 +377,7 @@ static void rmi_driver_set_input_name(struct rmi_device *rmi_dev, | |||
364 | struct input_dev *input) | 377 | struct input_dev *input) |
365 | { | 378 | { |
366 | struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); | 379 | struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); |
367 | char *device_name = rmi_f01_get_product_ID(data->f01_container); | 380 | const char *device_name = rmi_f01_get_product_ID(data->f01_container); |
368 | char *name; | 381 | char *name; |
369 | 382 | ||
370 | name = devm_kasprintf(&rmi_dev->dev, GFP_KERNEL, | 383 | name = devm_kasprintf(&rmi_dev->dev, GFP_KERNEL, |
@@ -836,7 +849,7 @@ static int rmi_create_function(struct rmi_device *rmi_dev, | |||
836 | void *ctx, const struct pdt_entry *pdt) | 849 | void *ctx, const struct pdt_entry *pdt) |
837 | { | 850 | { |
838 | struct device *dev = &rmi_dev->dev; | 851 | struct device *dev = &rmi_dev->dev; |
839 | struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); | 852 | struct rmi_driver_data *data = dev_get_drvdata(dev); |
840 | int *current_irq_count = ctx; | 853 | int *current_irq_count = ctx; |
841 | struct rmi_function *fn; | 854 | struct rmi_function *fn; |
842 | int i; | 855 | int i; |
@@ -1040,7 +1053,7 @@ int rmi_probe_interrupts(struct rmi_driver_data *data) | |||
1040 | } | 1053 | } |
1041 | 1054 | ||
1042 | if (data->bootloader_mode) | 1055 | if (data->bootloader_mode) |
1043 | dev_warn(&rmi_dev->dev, "Device in bootloader mode.\n"); | 1056 | dev_warn(dev, "Device in bootloader mode.\n"); |
1044 | 1057 | ||
1045 | data->irq_count = irq_count; | 1058 | data->irq_count = irq_count; |
1046 | data->num_of_irq_regs = (data->irq_count + 7) / 8; | 1059 | data->num_of_irq_regs = (data->irq_count + 7) / 8; |
@@ -1049,7 +1062,7 @@ int rmi_probe_interrupts(struct rmi_driver_data *data) | |||
1049 | data->irq_memory = devm_kzalloc(dev, size * 4, GFP_KERNEL); | 1062 | data->irq_memory = devm_kzalloc(dev, size * 4, GFP_KERNEL); |
1050 | if (!data->irq_memory) { | 1063 | if (!data->irq_memory) { |
1051 | dev_err(dev, "Failed to allocate memory for irq masks.\n"); | 1064 | dev_err(dev, "Failed to allocate memory for irq masks.\n"); |
1052 | return retval; | 1065 | return -ENOMEM; |
1053 | } | 1066 | } |
1054 | 1067 | ||
1055 | data->irq_status = data->irq_memory + size * 0; | 1068 | data->irq_status = data->irq_memory + size * 0; |
diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h index 24f8f764d171..f1a2a2266022 100644 --- a/drivers/input/rmi4/rmi_driver.h +++ b/drivers/input/rmi4/rmi_driver.h | |||
@@ -93,6 +93,7 @@ bool rmi_is_physical_driver(struct device_driver *); | |||
93 | int rmi_register_physical_driver(void); | 93 | int rmi_register_physical_driver(void); |
94 | void rmi_unregister_physical_driver(void); | 94 | void rmi_unregister_physical_driver(void); |
95 | void rmi_free_function_list(struct rmi_device *rmi_dev); | 95 | void rmi_free_function_list(struct rmi_device *rmi_dev); |
96 | struct rmi_function *rmi_find_function(struct rmi_device *rmi_dev, u8 number); | ||
96 | int rmi_enable_sensor(struct rmi_device *rmi_dev); | 97 | int rmi_enable_sensor(struct rmi_device *rmi_dev); |
97 | int rmi_scan_pdt(struct rmi_device *rmi_dev, void *ctx, | 98 | int rmi_scan_pdt(struct rmi_device *rmi_dev, void *ctx, |
98 | int (*callback)(struct rmi_device *rmi_dev, void *ctx, | 99 | int (*callback)(struct rmi_device *rmi_dev, void *ctx, |
@@ -104,7 +105,20 @@ int rmi_init_functions(struct rmi_driver_data *data); | |||
104 | int rmi_initial_reset(struct rmi_device *rmi_dev, void *ctx, | 105 | int rmi_initial_reset(struct rmi_device *rmi_dev, void *ctx, |
105 | const struct pdt_entry *pdt); | 106 | const struct pdt_entry *pdt); |
106 | 107 | ||
107 | char *rmi_f01_get_product_ID(struct rmi_function *fn); | 108 | const char *rmi_f01_get_product_ID(struct rmi_function *fn); |
109 | |||
110 | #ifdef CONFIG_RMI4_F03 | ||
111 | int rmi_f03_overwrite_button(struct rmi_function *fn, unsigned int button, | ||
112 | int value); | ||
113 | void rmi_f03_commit_buttons(struct rmi_function *fn); | ||
114 | #else | ||
115 | static inline int rmi_f03_overwrite_button(struct rmi_function *fn, | ||
116 | unsigned int button, int value) | ||
117 | { | ||
118 | return 0; | ||
119 | } | ||
120 | static inline void rmi_f03_commit_buttons(struct rmi_function *fn) {} | ||
121 | #endif | ||
108 | 122 | ||
109 | #ifdef CONFIG_RMI4_F34 | 123 | #ifdef CONFIG_RMI4_F34 |
110 | int rmi_f34_create_sysfs(struct rmi_device *rmi_dev); | 124 | int rmi_f34_create_sysfs(struct rmi_device *rmi_dev); |
diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c index 18baf4ceb940..7f7e9176f7ea 100644 --- a/drivers/input/rmi4/rmi_f01.c +++ b/drivers/input/rmi4/rmi_f01.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | #include <linux/uaccess.h> | 13 | #include <linux/uaccess.h> |
14 | #include <linux/of.h> | 14 | #include <linux/of.h> |
15 | #include <asm/unaligned.h> | ||
15 | #include "rmi_driver.h" | 16 | #include "rmi_driver.h" |
16 | 17 | ||
17 | #define RMI_PRODUCT_ID_LENGTH 10 | 18 | #define RMI_PRODUCT_ID_LENGTH 10 |
@@ -54,6 +55,7 @@ struct f01_basic_properties { | |||
54 | u8 product_id[RMI_PRODUCT_ID_LENGTH + 1]; | 55 | u8 product_id[RMI_PRODUCT_ID_LENGTH + 1]; |
55 | u16 productinfo; | 56 | u16 productinfo; |
56 | u32 firmware_id; | 57 | u32 firmware_id; |
58 | u32 package_id; | ||
57 | }; | 59 | }; |
58 | 60 | ||
59 | /* F01 device status bits */ | 61 | /* F01 device status bits */ |
@@ -220,8 +222,19 @@ static int rmi_f01_read_properties(struct rmi_device *rmi_dev, | |||
220 | has_build_id_query = !!(queries[0] & BIT(1)); | 222 | has_build_id_query = !!(queries[0] & BIT(1)); |
221 | } | 223 | } |
222 | 224 | ||
223 | if (has_package_id_query) | 225 | if (has_package_id_query) { |
226 | ret = rmi_read_block(rmi_dev, prod_info_addr, | ||
227 | queries, sizeof(__le64)); | ||
228 | if (ret) { | ||
229 | dev_err(&rmi_dev->dev, | ||
230 | "Failed to read package info: %d\n", | ||
231 | ret); | ||
232 | return ret; | ||
233 | } | ||
234 | |||
235 | props->package_id = get_unaligned_le64(queries); | ||
224 | prod_info_addr++; | 236 | prod_info_addr++; |
237 | } | ||
225 | 238 | ||
226 | if (has_build_id_query) { | 239 | if (has_build_id_query) { |
227 | ret = rmi_read_block(rmi_dev, prod_info_addr, queries, | 240 | ret = rmi_read_block(rmi_dev, prod_info_addr, queries, |
@@ -241,13 +254,90 @@ static int rmi_f01_read_properties(struct rmi_device *rmi_dev, | |||
241 | return 0; | 254 | return 0; |
242 | } | 255 | } |
243 | 256 | ||
244 | char *rmi_f01_get_product_ID(struct rmi_function *fn) | 257 | const char *rmi_f01_get_product_ID(struct rmi_function *fn) |
245 | { | 258 | { |
246 | struct f01_data *f01 = dev_get_drvdata(&fn->dev); | 259 | struct f01_data *f01 = dev_get_drvdata(&fn->dev); |
247 | 260 | ||
248 | return f01->properties.product_id; | 261 | return f01->properties.product_id; |
249 | } | 262 | } |
250 | 263 | ||
264 | static ssize_t rmi_driver_manufacturer_id_show(struct device *dev, | ||
265 | struct device_attribute *dattr, | ||
266 | char *buf) | ||
267 | { | ||
268 | struct rmi_driver_data *data = dev_get_drvdata(dev); | ||
269 | struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev); | ||
270 | |||
271 | return scnprintf(buf, PAGE_SIZE, "%d\n", | ||
272 | f01->properties.manufacturer_id); | ||
273 | } | ||
274 | |||
275 | static DEVICE_ATTR(manufacturer_id, 0444, | ||
276 | rmi_driver_manufacturer_id_show, NULL); | ||
277 | |||
278 | static ssize_t rmi_driver_dom_show(struct device *dev, | ||
279 | struct device_attribute *dattr, char *buf) | ||
280 | { | ||
281 | struct rmi_driver_data *data = dev_get_drvdata(dev); | ||
282 | struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev); | ||
283 | |||
284 | return scnprintf(buf, PAGE_SIZE, "%s\n", f01->properties.dom); | ||
285 | } | ||
286 | |||
287 | static DEVICE_ATTR(date_of_manufacture, 0444, rmi_driver_dom_show, NULL); | ||
288 | |||
289 | static ssize_t rmi_driver_product_id_show(struct device *dev, | ||
290 | struct device_attribute *dattr, | ||
291 | char *buf) | ||
292 | { | ||
293 | struct rmi_driver_data *data = dev_get_drvdata(dev); | ||
294 | struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev); | ||
295 | |||
296 | return scnprintf(buf, PAGE_SIZE, "%s\n", f01->properties.product_id); | ||
297 | } | ||
298 | |||
299 | static DEVICE_ATTR(product_id, 0444, rmi_driver_product_id_show, NULL); | ||
300 | |||
301 | static ssize_t rmi_driver_firmware_id_show(struct device *dev, | ||
302 | struct device_attribute *dattr, | ||
303 | char *buf) | ||
304 | { | ||
305 | struct rmi_driver_data *data = dev_get_drvdata(dev); | ||
306 | struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev); | ||
307 | |||
308 | return scnprintf(buf, PAGE_SIZE, "%d\n", f01->properties.firmware_id); | ||
309 | } | ||
310 | |||
311 | static DEVICE_ATTR(firmware_id, 0444, rmi_driver_firmware_id_show, NULL); | ||
312 | |||
313 | static ssize_t rmi_driver_package_id_show(struct device *dev, | ||
314 | struct device_attribute *dattr, | ||
315 | char *buf) | ||
316 | { | ||
317 | struct rmi_driver_data *data = dev_get_drvdata(dev); | ||
318 | struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev); | ||
319 | |||
320 | u32 package_id = f01->properties.package_id; | ||
321 | |||
322 | return scnprintf(buf, PAGE_SIZE, "%04x.%04x\n", | ||
323 | package_id & 0xffff, (package_id >> 16) & 0xffff); | ||
324 | } | ||
325 | |||
326 | static DEVICE_ATTR(package_id, 0444, rmi_driver_package_id_show, NULL); | ||
327 | |||
328 | static struct attribute *rmi_f01_attrs[] = { | ||
329 | &dev_attr_manufacturer_id.attr, | ||
330 | &dev_attr_date_of_manufacture.attr, | ||
331 | &dev_attr_product_id.attr, | ||
332 | &dev_attr_firmware_id.attr, | ||
333 | &dev_attr_package_id.attr, | ||
334 | NULL | ||
335 | }; | ||
336 | |||
337 | static struct attribute_group rmi_f01_attr_group = { | ||
338 | .attrs = rmi_f01_attrs, | ||
339 | }; | ||
340 | |||
251 | #ifdef CONFIG_OF | 341 | #ifdef CONFIG_OF |
252 | static int rmi_f01_of_probe(struct device *dev, | 342 | static int rmi_f01_of_probe(struct device *dev, |
253 | struct rmi_device_platform_data *pdata) | 343 | struct rmi_device_platform_data *pdata) |
@@ -480,9 +570,18 @@ static int rmi_f01_probe(struct rmi_function *fn) | |||
480 | 570 | ||
481 | dev_set_drvdata(&fn->dev, f01); | 571 | dev_set_drvdata(&fn->dev, f01); |
482 | 572 | ||
573 | error = sysfs_create_group(&fn->rmi_dev->dev.kobj, &rmi_f01_attr_group); | ||
574 | if (error) | ||
575 | dev_warn(&fn->dev, "Failed to create sysfs group: %d\n", error); | ||
576 | |||
483 | return 0; | 577 | return 0; |
484 | } | 578 | } |
485 | 579 | ||
580 | static void rmi_f01_remove(struct rmi_function *fn) | ||
581 | { | ||
582 | sysfs_remove_group(&fn->rmi_dev->dev.kobj, &rmi_f01_attr_group); | ||
583 | } | ||
584 | |||
486 | static int rmi_f01_config(struct rmi_function *fn) | 585 | static int rmi_f01_config(struct rmi_function *fn) |
487 | { | 586 | { |
488 | struct f01_data *f01 = dev_get_drvdata(&fn->dev); | 587 | struct f01_data *f01 = dev_get_drvdata(&fn->dev); |
@@ -622,6 +721,7 @@ struct rmi_function_handler rmi_f01_handler = { | |||
622 | }, | 721 | }, |
623 | .func = 0x01, | 722 | .func = 0x01, |
624 | .probe = rmi_f01_probe, | 723 | .probe = rmi_f01_probe, |
724 | .remove = rmi_f01_remove, | ||
625 | .config = rmi_f01_config, | 725 | .config = rmi_f01_config, |
626 | .attention = rmi_f01_attention, | 726 | .attention = rmi_f01_attention, |
627 | .suspend = rmi_f01_suspend, | 727 | .suspend = rmi_f01_suspend, |
diff --git a/drivers/input/rmi4/rmi_f03.c b/drivers/input/rmi4/rmi_f03.c index 8a7ca3e2f95e..77dad045a468 100644 --- a/drivers/input/rmi4/rmi_f03.c +++ b/drivers/input/rmi4/rmi_f03.c | |||
@@ -26,15 +26,53 @@ | |||
26 | #define RMI_F03_BYTES_PER_DEVICE_SHIFT 4 | 26 | #define RMI_F03_BYTES_PER_DEVICE_SHIFT 4 |
27 | #define RMI_F03_QUEUE_LENGTH 0x0F | 27 | #define RMI_F03_QUEUE_LENGTH 0x0F |
28 | 28 | ||
29 | #define PSMOUSE_OOB_EXTRA_BTNS 0x01 | ||
30 | |||
29 | struct f03_data { | 31 | struct f03_data { |
30 | struct rmi_function *fn; | 32 | struct rmi_function *fn; |
31 | 33 | ||
32 | struct serio *serio; | 34 | struct serio *serio; |
33 | 35 | ||
36 | unsigned int overwrite_buttons; | ||
37 | |||
34 | u8 device_count; | 38 | u8 device_count; |
35 | u8 rx_queue_length; | 39 | u8 rx_queue_length; |
36 | }; | 40 | }; |
37 | 41 | ||
42 | int rmi_f03_overwrite_button(struct rmi_function *fn, unsigned int button, | ||
43 | int value) | ||
44 | { | ||
45 | struct f03_data *f03 = dev_get_drvdata(&fn->dev); | ||
46 | unsigned int bit; | ||
47 | |||
48 | if (button < BTN_LEFT || button > BTN_MIDDLE) | ||
49 | return -EINVAL; | ||
50 | |||
51 | bit = BIT(button - BTN_LEFT); | ||
52 | |||
53 | if (value) | ||
54 | f03->overwrite_buttons |= bit; | ||
55 | else | ||
56 | f03->overwrite_buttons &= ~bit; | ||
57 | |||
58 | return 0; | ||
59 | } | ||
60 | |||
61 | void rmi_f03_commit_buttons(struct rmi_function *fn) | ||
62 | { | ||
63 | struct f03_data *f03 = dev_get_drvdata(&fn->dev); | ||
64 | struct serio *serio = f03->serio; | ||
65 | |||
66 | serio_pause_rx(serio); | ||
67 | if (serio->drv) { | ||
68 | serio->drv->interrupt(serio, PSMOUSE_OOB_EXTRA_BTNS, | ||
69 | SERIO_OOB_DATA); | ||
70 | serio->drv->interrupt(serio, f03->overwrite_buttons, | ||
71 | SERIO_OOB_DATA); | ||
72 | } | ||
73 | serio_continue_rx(serio); | ||
74 | } | ||
75 | |||
38 | static int rmi_f03_pt_write(struct serio *id, unsigned char val) | 76 | static int rmi_f03_pt_write(struct serio *id, unsigned char val) |
39 | { | 77 | { |
40 | struct f03_data *f03 = id->port_data; | 78 | struct f03_data *f03 = id->port_data; |
@@ -175,9 +213,6 @@ static int rmi_f03_attention(struct rmi_function *fn, unsigned long *irq_bits) | |||
175 | int i; | 213 | int i; |
176 | int error; | 214 | int error; |
177 | 215 | ||
178 | if (!rmi_dev) | ||
179 | return -ENODEV; | ||
180 | |||
181 | if (drvdata->attn_data.data) { | 216 | if (drvdata->attn_data.data) { |
182 | /* First grab the data passed by the transport device */ | 217 | /* First grab the data passed by the transport device */ |
183 | if (drvdata->attn_data.size < ob_len) { | 218 | if (drvdata->attn_data.size < ob_len) { |
diff --git a/drivers/input/rmi4/rmi_f30.c b/drivers/input/rmi4/rmi_f30.c index f4b491e3e0fd..3422464af229 100644 --- a/drivers/input/rmi4/rmi_f30.c +++ b/drivers/input/rmi4/rmi_f30.c | |||
@@ -16,30 +16,24 @@ | |||
16 | 16 | ||
17 | /* Defs for Query 0 */ | 17 | /* Defs for Query 0 */ |
18 | #define RMI_F30_EXTENDED_PATTERNS 0x01 | 18 | #define RMI_F30_EXTENDED_PATTERNS 0x01 |
19 | #define RMI_F30_HAS_MAPPABLE_BUTTONS (1 << 1) | 19 | #define RMI_F30_HAS_MAPPABLE_BUTTONS BIT(1) |
20 | #define RMI_F30_HAS_LED (1 << 2) | 20 | #define RMI_F30_HAS_LED BIT(2) |
21 | #define RMI_F30_HAS_GPIO (1 << 3) | 21 | #define RMI_F30_HAS_GPIO BIT(3) |
22 | #define RMI_F30_HAS_HAPTIC (1 << 4) | 22 | #define RMI_F30_HAS_HAPTIC BIT(4) |
23 | #define RMI_F30_HAS_GPIO_DRV_CTL (1 << 5) | 23 | #define RMI_F30_HAS_GPIO_DRV_CTL BIT(5) |
24 | #define RMI_F30_HAS_MECH_MOUSE_BTNS (1 << 6) | 24 | #define RMI_F30_HAS_MECH_MOUSE_BTNS BIT(6) |
25 | 25 | ||
26 | /* Defs for Query 1 */ | 26 | /* Defs for Query 1 */ |
27 | #define RMI_F30_GPIO_LED_COUNT 0x1F | 27 | #define RMI_F30_GPIO_LED_COUNT 0x1F |
28 | 28 | ||
29 | /* Defs for Control Registers */ | 29 | /* Defs for Control Registers */ |
30 | #define RMI_F30_CTRL_1_GPIO_DEBOUNCE 0x01 | 30 | #define RMI_F30_CTRL_1_GPIO_DEBOUNCE 0x01 |
31 | #define RMI_F30_CTRL_1_HALT (1 << 4) | 31 | #define RMI_F30_CTRL_1_HALT BIT(4) |
32 | #define RMI_F30_CTRL_1_HALTED (1 << 5) | 32 | #define RMI_F30_CTRL_1_HALTED BIT(5) |
33 | #define RMI_F30_CTRL_10_NUM_MECH_MOUSE_BTNS 0x03 | 33 | #define RMI_F30_CTRL_10_NUM_MECH_MOUSE_BTNS 0x03 |
34 | 34 | ||
35 | struct rmi_f30_ctrl_data { | ||
36 | int address; | ||
37 | int length; | ||
38 | u8 *regs; | ||
39 | }; | ||
40 | |||
41 | #define RMI_F30_CTRL_MAX_REGS 32 | 35 | #define RMI_F30_CTRL_MAX_REGS 32 |
42 | #define RMI_F30_CTRL_MAX_BYTES ((RMI_F30_CTRL_MAX_REGS + 7) >> 3) | 36 | #define RMI_F30_CTRL_MAX_BYTES DIV_ROUND_UP(RMI_F30_CTRL_MAX_REGS, 8) |
43 | #define RMI_F30_CTRL_MAX_REG_BLOCKS 11 | 37 | #define RMI_F30_CTRL_MAX_REG_BLOCKS 11 |
44 | 38 | ||
45 | #define RMI_F30_CTRL_REGS_MAX_SIZE (RMI_F30_CTRL_MAX_BYTES \ | 39 | #define RMI_F30_CTRL_REGS_MAX_SIZE (RMI_F30_CTRL_MAX_BYTES \ |
@@ -54,6 +48,15 @@ struct rmi_f30_ctrl_data { | |||
54 | + 1 \ | 48 | + 1 \ |
55 | + 1) | 49 | + 1) |
56 | 50 | ||
51 | #define TRACKSTICK_RANGE_START 3 | ||
52 | #define TRACKSTICK_RANGE_END 6 | ||
53 | |||
54 | struct rmi_f30_ctrl_data { | ||
55 | int address; | ||
56 | int length; | ||
57 | u8 *regs; | ||
58 | }; | ||
59 | |||
57 | struct f30_data { | 60 | struct f30_data { |
58 | /* Query Data */ | 61 | /* Query Data */ |
59 | bool has_extended_pattern; | 62 | bool has_extended_pattern; |
@@ -76,18 +79,21 @@ struct f30_data { | |||
76 | u16 *gpioled_key_map; | 79 | u16 *gpioled_key_map; |
77 | 80 | ||
78 | struct input_dev *input; | 81 | struct input_dev *input; |
82 | |||
83 | struct rmi_function *f03; | ||
84 | bool trackstick_buttons; | ||
79 | }; | 85 | }; |
80 | 86 | ||
81 | static int rmi_f30_read_control_parameters(struct rmi_function *fn, | 87 | static int rmi_f30_read_control_parameters(struct rmi_function *fn, |
82 | struct f30_data *f30) | 88 | struct f30_data *f30) |
83 | { | 89 | { |
84 | struct rmi_device *rmi_dev = fn->rmi_dev; | 90 | int error; |
85 | int error = 0; | ||
86 | 91 | ||
87 | error = rmi_read_block(rmi_dev, fn->fd.control_base_addr, | 92 | error = rmi_read_block(fn->rmi_dev, fn->fd.control_base_addr, |
88 | f30->ctrl_regs, f30->ctrl_regs_size); | 93 | f30->ctrl_regs, f30->ctrl_regs_size); |
89 | if (error) { | 94 | if (error) { |
90 | dev_err(&rmi_dev->dev, "%s : Could not read control registers at 0x%x error (%d)\n", | 95 | dev_err(&fn->dev, |
96 | "%s: Could not read control registers at 0x%x: %d\n", | ||
91 | __func__, fn->fd.control_base_addr, error); | 97 | __func__, fn->fd.control_base_addr, error); |
92 | return error; | 98 | return error; |
93 | } | 99 | } |
@@ -95,24 +101,39 @@ static int rmi_f30_read_control_parameters(struct rmi_function *fn, | |||
95 | return 0; | 101 | return 0; |
96 | } | 102 | } |
97 | 103 | ||
104 | static void rmi_f30_report_button(struct rmi_function *fn, | ||
105 | struct f30_data *f30, unsigned int button) | ||
106 | { | ||
107 | unsigned int reg_num = button >> 3; | ||
108 | unsigned int bit_num = button & 0x07; | ||
109 | u16 key_code = f30->gpioled_key_map[button]; | ||
110 | bool key_down = !(f30->data_regs[reg_num] & BIT(bit_num)); | ||
111 | |||
112 | if (f30->trackstick_buttons && | ||
113 | button >= TRACKSTICK_RANGE_START && | ||
114 | button <= TRACKSTICK_RANGE_END) { | ||
115 | rmi_f03_overwrite_button(f30->f03, key_code, key_down); | ||
116 | } else { | ||
117 | rmi_dbg(RMI_DEBUG_FN, &fn->dev, | ||
118 | "%s: call input report key (0x%04x) value (0x%02x)", | ||
119 | __func__, key_code, key_down); | ||
120 | |||
121 | input_report_key(f30->input, key_code, key_down); | ||
122 | } | ||
123 | } | ||
124 | |||
98 | static int rmi_f30_attention(struct rmi_function *fn, unsigned long *irq_bits) | 125 | static int rmi_f30_attention(struct rmi_function *fn, unsigned long *irq_bits) |
99 | { | 126 | { |
100 | struct f30_data *f30 = dev_get_drvdata(&fn->dev); | 127 | struct f30_data *f30 = dev_get_drvdata(&fn->dev); |
101 | struct rmi_device *rmi_dev = fn->rmi_dev; | 128 | struct rmi_driver_data *drvdata = dev_get_drvdata(&fn->rmi_dev->dev); |
102 | struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev); | 129 | int error; |
103 | int retval; | ||
104 | int gpiled = 0; | ||
105 | int value = 0; | ||
106 | int i; | 130 | int i; |
107 | int reg_num; | ||
108 | |||
109 | if (!f30->input) | ||
110 | return 0; | ||
111 | 131 | ||
112 | /* Read the gpi led data. */ | 132 | /* Read the gpi led data. */ |
113 | if (drvdata->attn_data.data) { | 133 | if (drvdata->attn_data.data) { |
114 | if (drvdata->attn_data.size < f30->register_count) { | 134 | if (drvdata->attn_data.size < f30->register_count) { |
115 | dev_warn(&fn->dev, "F30 interrupted, but data is missing\n"); | 135 | dev_warn(&fn->dev, |
136 | "F30 interrupted, but data is missing\n"); | ||
116 | return 0; | 137 | return 0; |
117 | } | 138 | } |
118 | memcpy(f30->data_regs, drvdata->attn_data.data, | 139 | memcpy(f30->data_regs, drvdata->attn_data.data, |
@@ -120,72 +141,24 @@ static int rmi_f30_attention(struct rmi_function *fn, unsigned long *irq_bits) | |||
120 | drvdata->attn_data.data += f30->register_count; | 141 | drvdata->attn_data.data += f30->register_count; |
121 | drvdata->attn_data.size -= f30->register_count; | 142 | drvdata->attn_data.size -= f30->register_count; |
122 | } else { | 143 | } else { |
123 | retval = rmi_read_block(rmi_dev, fn->fd.data_base_addr, | 144 | error = rmi_read_block(fn->rmi_dev, fn->fd.data_base_addr, |
124 | f30->data_regs, f30->register_count); | 145 | f30->data_regs, f30->register_count); |
125 | 146 | if (error) { | |
126 | if (retval) { | 147 | dev_err(&fn->dev, |
127 | dev_err(&fn->dev, "%s: Failed to read F30 data registers.\n", | 148 | "%s: Failed to read F30 data registers: %d\n", |
128 | __func__); | 149 | __func__, error); |
129 | return retval; | 150 | return error; |
130 | } | ||
131 | } | ||
132 | |||
133 | for (reg_num = 0; reg_num < f30->register_count; ++reg_num) { | ||
134 | for (i = 0; gpiled < f30->gpioled_count && i < 8; ++i, | ||
135 | ++gpiled) { | ||
136 | if (f30->gpioled_key_map[gpiled] != 0) { | ||
137 | /* buttons have pull up resistors */ | ||
138 | value = (((f30->data_regs[reg_num] >> i) & 0x01) | ||
139 | == 0); | ||
140 | |||
141 | rmi_dbg(RMI_DEBUG_FN, &fn->dev, | ||
142 | "%s: call input report key (0x%04x) value (0x%02x)", | ||
143 | __func__, | ||
144 | f30->gpioled_key_map[gpiled], value); | ||
145 | input_report_key(f30->input, | ||
146 | f30->gpioled_key_map[gpiled], | ||
147 | value); | ||
148 | } | ||
149 | |||
150 | } | 151 | } |
151 | } | 152 | } |
152 | 153 | ||
153 | return 0; | 154 | if (f30->has_gpio) { |
154 | } | 155 | for (i = 0; i < f30->gpioled_count; i++) |
155 | 156 | if (f30->gpioled_key_map[i] != KEY_RESERVED) | |
156 | static int rmi_f30_register_device(struct rmi_function *fn) | 157 | rmi_f30_report_button(fn, f30, i); |
157 | { | 158 | if (f30->trackstick_buttons) |
158 | int i; | 159 | rmi_f03_commit_buttons(f30->f03); |
159 | struct rmi_device *rmi_dev = fn->rmi_dev; | ||
160 | struct rmi_driver_data *drv_data = dev_get_drvdata(&rmi_dev->dev); | ||
161 | struct f30_data *f30 = dev_get_drvdata(&fn->dev); | ||
162 | struct input_dev *input_dev; | ||
163 | int button_count = 0; | ||
164 | |||
165 | input_dev = drv_data->input; | ||
166 | if (!input_dev) { | ||
167 | dev_info(&fn->dev, "F30: no input device found, ignoring.\n"); | ||
168 | return -EINVAL; | ||
169 | } | ||
170 | |||
171 | f30->input = input_dev; | ||
172 | |||
173 | set_bit(EV_KEY, input_dev->evbit); | ||
174 | |||
175 | input_dev->keycode = f30->gpioled_key_map; | ||
176 | input_dev->keycodesize = sizeof(u16); | ||
177 | input_dev->keycodemax = f30->gpioled_count; | ||
178 | |||
179 | for (i = 0; i < f30->gpioled_count; i++) { | ||
180 | if (f30->gpioled_key_map[i] != 0) { | ||
181 | input_set_capability(input_dev, EV_KEY, | ||
182 | f30->gpioled_key_map[i]); | ||
183 | button_count++; | ||
184 | } | ||
185 | } | 160 | } |
186 | 161 | ||
187 | if (button_count == 1) | ||
188 | __set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit); | ||
189 | return 0; | 162 | return 0; |
190 | } | 163 | } |
191 | 164 | ||
@@ -197,6 +170,12 @@ static int rmi_f30_config(struct rmi_function *fn) | |||
197 | rmi_get_platform_data(fn->rmi_dev); | 170 | rmi_get_platform_data(fn->rmi_dev); |
198 | int error; | 171 | int error; |
199 | 172 | ||
173 | if (pdata->f30_data.trackstick_buttons) { | ||
174 | /* Try [re-]establish link to F03. */ | ||
175 | f30->f03 = rmi_find_function(fn->rmi_dev, 0x03); | ||
176 | f30->trackstick_buttons = f30->f03 != NULL; | ||
177 | } | ||
178 | |||
200 | if (pdata->f30_data.disable) { | 179 | if (pdata->f30_data.disable) { |
201 | drv->clear_irq_bits(fn->rmi_dev, fn->irq_mask); | 180 | drv->clear_irq_bits(fn->rmi_dev, fn->irq_mask); |
202 | } else { | 181 | } else { |
@@ -204,19 +183,20 @@ static int rmi_f30_config(struct rmi_function *fn) | |||
204 | error = rmi_write_block(fn->rmi_dev, fn->fd.control_base_addr, | 183 | error = rmi_write_block(fn->rmi_dev, fn->fd.control_base_addr, |
205 | f30->ctrl_regs, f30->ctrl_regs_size); | 184 | f30->ctrl_regs, f30->ctrl_regs_size); |
206 | if (error) { | 185 | if (error) { |
207 | dev_err(&fn->rmi_dev->dev, | 186 | dev_err(&fn->dev, |
208 | "%s : Could not write control registers at 0x%x error (%d)\n", | 187 | "%s: Could not write control registers at 0x%x: %d\n", |
209 | __func__, fn->fd.control_base_addr, error); | 188 | __func__, fn->fd.control_base_addr, error); |
210 | return error; | 189 | return error; |
211 | } | 190 | } |
212 | 191 | ||
213 | drv->set_irq_bits(fn->rmi_dev, fn->irq_mask); | 192 | drv->set_irq_bits(fn->rmi_dev, fn->irq_mask); |
214 | } | 193 | } |
194 | |||
215 | return 0; | 195 | return 0; |
216 | } | 196 | } |
217 | 197 | ||
218 | static inline void rmi_f30_set_ctrl_data(struct rmi_f30_ctrl_data *ctrl, | 198 | static void rmi_f30_set_ctrl_data(struct rmi_f30_ctrl_data *ctrl, |
219 | int *ctrl_addr, int len, u8 **reg) | 199 | int *ctrl_addr, int len, u8 **reg) |
220 | { | 200 | { |
221 | ctrl->address = *ctrl_addr; | 201 | ctrl->address = *ctrl_addr; |
222 | ctrl->length = len; | 202 | ctrl->length = len; |
@@ -225,8 +205,7 @@ static inline void rmi_f30_set_ctrl_data(struct rmi_f30_ctrl_data *ctrl, | |||
225 | *reg += len; | 205 | *reg += len; |
226 | } | 206 | } |
227 | 207 | ||
228 | static inline bool rmi_f30_is_valid_button(int button, | 208 | static bool rmi_f30_is_valid_button(int button, struct rmi_f30_ctrl_data *ctrl) |
229 | struct rmi_f30_ctrl_data *ctrl) | ||
230 | { | 209 | { |
231 | int byte_position = button >> 3; | 210 | int byte_position = button >> 3; |
232 | int bit_position = button & 0x07; | 211 | int bit_position = button & 0x07; |
@@ -239,32 +218,66 @@ static inline bool rmi_f30_is_valid_button(int button, | |||
239 | (ctrl[3].regs[byte_position] & BIT(bit_position)); | 218 | (ctrl[3].regs[byte_position] & BIT(bit_position)); |
240 | } | 219 | } |
241 | 220 | ||
242 | static inline int rmi_f30_initialize(struct rmi_function *fn) | 221 | static int rmi_f30_map_gpios(struct rmi_function *fn, |
222 | struct f30_data *f30) | ||
243 | { | 223 | { |
244 | struct f30_data *f30; | 224 | const struct rmi_device_platform_data *pdata = |
245 | struct rmi_device *rmi_dev = fn->rmi_dev; | 225 | rmi_get_platform_data(fn->rmi_dev); |
246 | const struct rmi_device_platform_data *pdata; | 226 | struct input_dev *input = f30->input; |
247 | int retval = 0; | 227 | unsigned int button = BTN_LEFT; |
248 | int control_address; | 228 | unsigned int trackstick_button = BTN_LEFT; |
229 | bool button_mapped = false; | ||
249 | int i; | 230 | int i; |
250 | int button; | ||
251 | u8 buf[RMI_F30_QUERY_SIZE]; | ||
252 | u8 *ctrl_reg; | ||
253 | u8 *map_memory; | ||
254 | 231 | ||
255 | f30 = devm_kzalloc(&fn->dev, sizeof(struct f30_data), | 232 | f30->gpioled_key_map = devm_kcalloc(&fn->dev, |
256 | GFP_KERNEL); | 233 | f30->gpioled_count, |
257 | if (!f30) | 234 | sizeof(f30->gpioled_key_map[0]), |
235 | GFP_KERNEL); | ||
236 | if (!f30->gpioled_key_map) { | ||
237 | dev_err(&fn->dev, "Failed to allocate gpioled map memory.\n"); | ||
258 | return -ENOMEM; | 238 | return -ENOMEM; |
239 | } | ||
259 | 240 | ||
260 | dev_set_drvdata(&fn->dev, f30); | 241 | for (i = 0; i < f30->gpioled_count; i++) { |
242 | if (!rmi_f30_is_valid_button(i, f30->ctrl)) | ||
243 | continue; | ||
244 | |||
245 | if (pdata->f30_data.trackstick_buttons && | ||
246 | i >= TRACKSTICK_RANGE_START && i < TRACKSTICK_RANGE_END) { | ||
247 | f30->gpioled_key_map[i] = trackstick_button++; | ||
248 | } else if (!pdata->f30_data.buttonpad || !button_mapped) { | ||
249 | f30->gpioled_key_map[i] = button; | ||
250 | input_set_capability(input, EV_KEY, button++); | ||
251 | button_mapped = true; | ||
252 | } | ||
253 | } | ||
254 | |||
255 | input->keycode = f30->gpioled_key_map; | ||
256 | input->keycodesize = sizeof(f30->gpioled_key_map[0]); | ||
257 | input->keycodemax = f30->gpioled_count; | ||
258 | |||
259 | /* | ||
260 | * Buttonpad could be also inferred from f30->has_mech_mouse_btns, | ||
261 | * but I am not sure, so use only the pdata info. | ||
262 | */ | ||
263 | if (pdata->f30_data.buttonpad) | ||
264 | __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); | ||
265 | |||
266 | return 0; | ||
267 | } | ||
261 | 268 | ||
262 | retval = rmi_read_block(fn->rmi_dev, fn->fd.query_base_addr, buf, | 269 | static int rmi_f30_initialize(struct rmi_function *fn, struct f30_data *f30) |
263 | RMI_F30_QUERY_SIZE); | 270 | { |
271 | u8 *ctrl_reg = f30->ctrl_regs; | ||
272 | int control_address = fn->fd.control_base_addr; | ||
273 | u8 buf[RMI_F30_QUERY_SIZE]; | ||
274 | int error; | ||
264 | 275 | ||
265 | if (retval) { | 276 | error = rmi_read_block(fn->rmi_dev, fn->fd.query_base_addr, |
266 | dev_err(&fn->dev, "Failed to read query register.\n"); | 277 | buf, RMI_F30_QUERY_SIZE); |
267 | return retval; | 278 | if (error) { |
279 | dev_err(&fn->dev, "Failed to read query register\n"); | ||
280 | return error; | ||
268 | } | 281 | } |
269 | 282 | ||
270 | f30->has_extended_pattern = buf[0] & RMI_F30_EXTENDED_PATTERNS; | 283 | f30->has_extended_pattern = buf[0] & RMI_F30_EXTENDED_PATTERNS; |
@@ -276,101 +289,71 @@ static inline int rmi_f30_initialize(struct rmi_function *fn) | |||
276 | f30->has_mech_mouse_btns = buf[0] & RMI_F30_HAS_MECH_MOUSE_BTNS; | 289 | f30->has_mech_mouse_btns = buf[0] & RMI_F30_HAS_MECH_MOUSE_BTNS; |
277 | f30->gpioled_count = buf[1] & RMI_F30_GPIO_LED_COUNT; | 290 | f30->gpioled_count = buf[1] & RMI_F30_GPIO_LED_COUNT; |
278 | 291 | ||
279 | f30->register_count = (f30->gpioled_count + 7) >> 3; | 292 | f30->register_count = DIV_ROUND_UP(f30->gpioled_count, 8); |
280 | |||
281 | control_address = fn->fd.control_base_addr; | ||
282 | ctrl_reg = f30->ctrl_regs; | ||
283 | 293 | ||
284 | if (f30->has_gpio && f30->has_led) | 294 | if (f30->has_gpio && f30->has_led) |
285 | rmi_f30_set_ctrl_data(&f30->ctrl[0], &control_address, | 295 | rmi_f30_set_ctrl_data(&f30->ctrl[0], &control_address, |
286 | f30->register_count, &ctrl_reg); | 296 | f30->register_count, &ctrl_reg); |
287 | 297 | ||
288 | rmi_f30_set_ctrl_data(&f30->ctrl[1], &control_address, sizeof(u8), | 298 | rmi_f30_set_ctrl_data(&f30->ctrl[1], &control_address, |
289 | &ctrl_reg); | 299 | sizeof(u8), &ctrl_reg); |
290 | 300 | ||
291 | if (f30->has_gpio) { | 301 | if (f30->has_gpio) { |
292 | rmi_f30_set_ctrl_data(&f30->ctrl[2], &control_address, | 302 | rmi_f30_set_ctrl_data(&f30->ctrl[2], &control_address, |
293 | f30->register_count, &ctrl_reg); | 303 | f30->register_count, &ctrl_reg); |
294 | 304 | ||
295 | rmi_f30_set_ctrl_data(&f30->ctrl[3], &control_address, | 305 | rmi_f30_set_ctrl_data(&f30->ctrl[3], &control_address, |
296 | f30->register_count, &ctrl_reg); | 306 | f30->register_count, &ctrl_reg); |
297 | } | 307 | } |
298 | 308 | ||
299 | if (f30->has_led) { | 309 | if (f30->has_led) { |
300 | int ctrl5_len; | ||
301 | |||
302 | rmi_f30_set_ctrl_data(&f30->ctrl[4], &control_address, | 310 | rmi_f30_set_ctrl_data(&f30->ctrl[4], &control_address, |
303 | f30->register_count, &ctrl_reg); | 311 | f30->register_count, &ctrl_reg); |
304 | |||
305 | if (f30->has_extended_pattern) | ||
306 | ctrl5_len = 6; | ||
307 | else | ||
308 | ctrl5_len = 2; | ||
309 | 312 | ||
310 | rmi_f30_set_ctrl_data(&f30->ctrl[5], &control_address, | 313 | rmi_f30_set_ctrl_data(&f30->ctrl[5], &control_address, |
311 | ctrl5_len, &ctrl_reg); | 314 | f30->has_extended_pattern ? 6 : 2, |
315 | &ctrl_reg); | ||
312 | } | 316 | } |
313 | 317 | ||
314 | if (f30->has_led || f30->has_gpio_driver_control) { | 318 | if (f30->has_led || f30->has_gpio_driver_control) { |
315 | /* control 6 uses a byte per gpio/led */ | 319 | /* control 6 uses a byte per gpio/led */ |
316 | rmi_f30_set_ctrl_data(&f30->ctrl[6], &control_address, | 320 | rmi_f30_set_ctrl_data(&f30->ctrl[6], &control_address, |
317 | f30->gpioled_count, &ctrl_reg); | 321 | f30->gpioled_count, &ctrl_reg); |
318 | } | 322 | } |
319 | 323 | ||
320 | if (f30->has_mappable_buttons) { | 324 | if (f30->has_mappable_buttons) { |
321 | /* control 7 uses a byte per gpio/led */ | 325 | /* control 7 uses a byte per gpio/led */ |
322 | rmi_f30_set_ctrl_data(&f30->ctrl[7], &control_address, | 326 | rmi_f30_set_ctrl_data(&f30->ctrl[7], &control_address, |
323 | f30->gpioled_count, &ctrl_reg); | 327 | f30->gpioled_count, &ctrl_reg); |
324 | } | 328 | } |
325 | 329 | ||
326 | if (f30->has_haptic) { | 330 | if (f30->has_haptic) { |
327 | rmi_f30_set_ctrl_data(&f30->ctrl[8], &control_address, | 331 | rmi_f30_set_ctrl_data(&f30->ctrl[8], &control_address, |
328 | f30->register_count, &ctrl_reg); | 332 | f30->register_count, &ctrl_reg); |
329 | 333 | ||
330 | rmi_f30_set_ctrl_data(&f30->ctrl[9], &control_address, | 334 | rmi_f30_set_ctrl_data(&f30->ctrl[9], &control_address, |
331 | sizeof(u8), &ctrl_reg); | 335 | sizeof(u8), &ctrl_reg); |
332 | } | 336 | } |
333 | 337 | ||
334 | if (f30->has_mech_mouse_btns) | 338 | if (f30->has_mech_mouse_btns) |
335 | rmi_f30_set_ctrl_data(&f30->ctrl[10], &control_address, | 339 | rmi_f30_set_ctrl_data(&f30->ctrl[10], &control_address, |
336 | sizeof(u8), &ctrl_reg); | 340 | sizeof(u8), &ctrl_reg); |
337 | 341 | ||
338 | f30->ctrl_regs_size = ctrl_reg - f30->ctrl_regs | 342 | f30->ctrl_regs_size = ctrl_reg - |
339 | ?: RMI_F30_CTRL_REGS_MAX_SIZE; | 343 | f30->ctrl_regs ?: RMI_F30_CTRL_REGS_MAX_SIZE; |
340 | 344 | ||
341 | retval = rmi_f30_read_control_parameters(fn, f30); | 345 | error = rmi_f30_read_control_parameters(fn, f30); |
342 | if (retval < 0) { | 346 | if (error) { |
343 | dev_err(&fn->dev, | 347 | dev_err(&fn->dev, |
344 | "Failed to initialize F19 control params.\n"); | 348 | "Failed to initialize F30 control params: %d\n", |
345 | return retval; | 349 | error); |
346 | } | 350 | return error; |
347 | |||
348 | map_memory = devm_kzalloc(&fn->dev, | ||
349 | (f30->gpioled_count * (sizeof(u16))), | ||
350 | GFP_KERNEL); | ||
351 | if (!map_memory) { | ||
352 | dev_err(&fn->dev, "Failed to allocate gpioled map memory.\n"); | ||
353 | return -ENOMEM; | ||
354 | } | 351 | } |
355 | 352 | ||
356 | f30->gpioled_key_map = (u16 *)map_memory; | ||
357 | |||
358 | pdata = rmi_get_platform_data(rmi_dev); | ||
359 | if (f30->has_gpio) { | 353 | if (f30->has_gpio) { |
360 | button = BTN_LEFT; | 354 | error = rmi_f30_map_gpios(fn, f30); |
361 | for (i = 0; i < f30->gpioled_count; i++) { | 355 | if (error) |
362 | if (rmi_f30_is_valid_button(i, f30->ctrl)) { | 356 | return error; |
363 | f30->gpioled_key_map[i] = button++; | ||
364 | |||
365 | /* | ||
366 | * buttonpad might be given by | ||
367 | * f30->has_mech_mouse_btns, but I am | ||
368 | * not sure, so use only the pdata info | ||
369 | */ | ||
370 | if (pdata->f30_data.buttonpad) | ||
371 | break; | ||
372 | } | ||
373 | } | ||
374 | } | 357 | } |
375 | 358 | ||
376 | return 0; | 359 | return 0; |
@@ -378,26 +361,33 @@ static inline int rmi_f30_initialize(struct rmi_function *fn) | |||
378 | 361 | ||
379 | static int rmi_f30_probe(struct rmi_function *fn) | 362 | static int rmi_f30_probe(struct rmi_function *fn) |
380 | { | 363 | { |
381 | int rc; | 364 | struct rmi_device *rmi_dev = fn->rmi_dev; |
382 | const struct rmi_device_platform_data *pdata = | 365 | const struct rmi_device_platform_data *pdata = |
383 | rmi_get_platform_data(fn->rmi_dev); | 366 | rmi_get_platform_data(rmi_dev); |
367 | struct rmi_driver_data *drv_data = dev_get_drvdata(&rmi_dev->dev); | ||
368 | struct f30_data *f30; | ||
369 | int error; | ||
384 | 370 | ||
385 | if (pdata->f30_data.disable) | 371 | if (pdata->f30_data.disable) |
386 | return 0; | 372 | return 0; |
387 | 373 | ||
388 | rc = rmi_f30_initialize(fn); | 374 | if (!drv_data->input) { |
389 | if (rc < 0) | 375 | dev_info(&fn->dev, "F30: no input device found, ignoring\n"); |
390 | goto error_exit; | 376 | return -ENXIO; |
377 | } | ||
391 | 378 | ||
392 | rc = rmi_f30_register_device(fn); | 379 | f30 = devm_kzalloc(&fn->dev, sizeof(*f30), GFP_KERNEL); |
393 | if (rc < 0) | 380 | if (!f30) |
394 | goto error_exit; | 381 | return -ENOMEM; |
395 | 382 | ||
396 | return 0; | 383 | f30->input = drv_data->input; |
397 | 384 | ||
398 | error_exit: | 385 | error = rmi_f30_initialize(fn, f30); |
399 | return rc; | 386 | if (error) |
387 | return error; | ||
400 | 388 | ||
389 | dev_set_drvdata(&fn->dev, f30); | ||
390 | return 0; | ||
401 | } | 391 | } |
402 | 392 | ||
403 | struct rmi_function_handler rmi_f30_handler = { | 393 | struct rmi_function_handler rmi_f30_handler = { |
diff --git a/drivers/input/rmi4/rmi_f34.c b/drivers/input/rmi4/rmi_f34.c index 9774dfbab9bb..425fe140e9df 100644 --- a/drivers/input/rmi4/rmi_f34.c +++ b/drivers/input/rmi4/rmi_f34.c | |||
@@ -157,6 +157,9 @@ static int rmi_f34_write_blocks(struct f34_data *f34, const void *data, | |||
157 | i + 1, block_count); | 157 | i + 1, block_count); |
158 | 158 | ||
159 | data += f34->v5.block_size; | 159 | data += f34->v5.block_size; |
160 | f34->update_progress += f34->v5.block_size; | ||
161 | f34->update_status = (f34->update_progress * 100) / | ||
162 | f34->update_size; | ||
160 | } | 163 | } |
161 | 164 | ||
162 | return 0; | 165 | return 0; |
@@ -174,7 +177,7 @@ static int rmi_f34_write_config(struct f34_data *f34, const void *data) | |||
174 | F34_WRITE_CONFIG_BLOCK); | 177 | F34_WRITE_CONFIG_BLOCK); |
175 | } | 178 | } |
176 | 179 | ||
177 | int rmi_f34_enable_flash(struct f34_data *f34) | 180 | static int rmi_f34_enable_flash(struct f34_data *f34) |
178 | { | 181 | { |
179 | return rmi_f34_command(f34, F34_ENABLE_FLASH_PROG, | 182 | return rmi_f34_command(f34, F34_ENABLE_FLASH_PROG, |
180 | F34_ENABLE_WAIT_MS, true); | 183 | F34_ENABLE_WAIT_MS, true); |
@@ -184,9 +187,14 @@ static int rmi_f34_flash_firmware(struct f34_data *f34, | |||
184 | const struct rmi_f34_firmware *syn_fw) | 187 | const struct rmi_f34_firmware *syn_fw) |
185 | { | 188 | { |
186 | struct rmi_function *fn = f34->fn; | 189 | struct rmi_function *fn = f34->fn; |
190 | u32 image_size = le32_to_cpu(syn_fw->image_size); | ||
191 | u32 config_size = le32_to_cpu(syn_fw->config_size); | ||
187 | int ret; | 192 | int ret; |
188 | 193 | ||
189 | if (syn_fw->image_size) { | 194 | f34->update_progress = 0; |
195 | f34->update_size = image_size + config_size; | ||
196 | |||
197 | if (image_size) { | ||
190 | dev_info(&fn->dev, "Erasing firmware...\n"); | 198 | dev_info(&fn->dev, "Erasing firmware...\n"); |
191 | ret = rmi_f34_command(f34, F34_ERASE_ALL, | 199 | ret = rmi_f34_command(f34, F34_ERASE_ALL, |
192 | F34_ERASE_WAIT_MS, true); | 200 | F34_ERASE_WAIT_MS, true); |
@@ -194,18 +202,18 @@ static int rmi_f34_flash_firmware(struct f34_data *f34, | |||
194 | return ret; | 202 | return ret; |
195 | 203 | ||
196 | dev_info(&fn->dev, "Writing firmware (%d bytes)...\n", | 204 | dev_info(&fn->dev, "Writing firmware (%d bytes)...\n", |
197 | syn_fw->image_size); | 205 | image_size); |
198 | ret = rmi_f34_write_firmware(f34, syn_fw->data); | 206 | ret = rmi_f34_write_firmware(f34, syn_fw->data); |
199 | if (ret) | 207 | if (ret) |
200 | return ret; | 208 | return ret; |
201 | } | 209 | } |
202 | 210 | ||
203 | if (syn_fw->config_size) { | 211 | if (config_size) { |
204 | /* | 212 | /* |
205 | * We only need to erase config if we haven't updated | 213 | * We only need to erase config if we haven't updated |
206 | * firmware. | 214 | * firmware. |
207 | */ | 215 | */ |
208 | if (!syn_fw->image_size) { | 216 | if (!image_size) { |
209 | dev_info(&fn->dev, "Erasing config...\n"); | 217 | dev_info(&fn->dev, "Erasing config...\n"); |
210 | ret = rmi_f34_command(f34, F34_ERASE_CONFIG, | 218 | ret = rmi_f34_command(f34, F34_ERASE_CONFIG, |
211 | F34_ERASE_WAIT_MS, true); | 219 | F34_ERASE_WAIT_MS, true); |
@@ -214,9 +222,8 @@ static int rmi_f34_flash_firmware(struct f34_data *f34, | |||
214 | } | 222 | } |
215 | 223 | ||
216 | dev_info(&fn->dev, "Writing config (%d bytes)...\n", | 224 | dev_info(&fn->dev, "Writing config (%d bytes)...\n", |
217 | syn_fw->config_size); | 225 | config_size); |
218 | ret = rmi_f34_write_config(f34, | 226 | ret = rmi_f34_write_config(f34, &syn_fw->data[image_size]); |
219 | &syn_fw->data[syn_fw->image_size]); | ||
220 | if (ret) | 227 | if (ret) |
221 | return ret; | 228 | return ret; |
222 | } | 229 | } |
@@ -224,21 +231,23 @@ static int rmi_f34_flash_firmware(struct f34_data *f34, | |||
224 | return 0; | 231 | return 0; |
225 | } | 232 | } |
226 | 233 | ||
227 | int rmi_f34_update_firmware(struct f34_data *f34, const struct firmware *fw) | 234 | static int rmi_f34_update_firmware(struct f34_data *f34, |
235 | const struct firmware *fw) | ||
228 | { | 236 | { |
229 | const struct rmi_f34_firmware *syn_fw; | 237 | const struct rmi_f34_firmware *syn_fw = |
238 | (const struct rmi_f34_firmware *)fw->data; | ||
239 | u32 image_size = le32_to_cpu(syn_fw->image_size); | ||
240 | u32 config_size = le32_to_cpu(syn_fw->config_size); | ||
230 | int ret; | 241 | int ret; |
231 | 242 | ||
232 | syn_fw = (const struct rmi_f34_firmware *)fw->data; | ||
233 | BUILD_BUG_ON(offsetof(struct rmi_f34_firmware, data) != | 243 | BUILD_BUG_ON(offsetof(struct rmi_f34_firmware, data) != |
234 | F34_FW_IMAGE_OFFSET); | 244 | F34_FW_IMAGE_OFFSET); |
235 | 245 | ||
236 | rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, | 246 | rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, |
237 | "FW size:%d, checksum:%08x, image_size:%d, config_size:%d\n", | 247 | "FW size:%zd, checksum:%08x, image_size:%d, config_size:%d\n", |
238 | (int)fw->size, | 248 | fw->size, |
239 | le32_to_cpu(syn_fw->checksum), | 249 | le32_to_cpu(syn_fw->checksum), |
240 | le32_to_cpu(syn_fw->image_size), | 250 | image_size, config_size); |
241 | le32_to_cpu(syn_fw->config_size)); | ||
242 | 251 | ||
243 | rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, | 252 | rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, |
244 | "FW bootloader_id:%02x, product_id:%.*s, info: %02x%02x\n", | 253 | "FW bootloader_id:%02x, product_id:%.*s, info: %02x%02x\n", |
@@ -246,27 +255,25 @@ int rmi_f34_update_firmware(struct f34_data *f34, const struct firmware *fw) | |||
246 | (int)sizeof(syn_fw->product_id), syn_fw->product_id, | 255 | (int)sizeof(syn_fw->product_id), syn_fw->product_id, |
247 | syn_fw->product_info[0], syn_fw->product_info[1]); | 256 | syn_fw->product_info[0], syn_fw->product_info[1]); |
248 | 257 | ||
249 | if (syn_fw->image_size && | 258 | if (image_size && image_size != f34->v5.fw_blocks * f34->v5.block_size) { |
250 | syn_fw->image_size != f34->v5.fw_blocks * f34->v5.block_size) { | ||
251 | dev_err(&f34->fn->dev, | 259 | dev_err(&f34->fn->dev, |
252 | "Bad firmware image: fw size %d, expected %d\n", | 260 | "Bad firmware image: fw size %d, expected %d\n", |
253 | syn_fw->image_size, | 261 | image_size, f34->v5.fw_blocks * f34->v5.block_size); |
254 | f34->v5.fw_blocks * f34->v5.block_size); | ||
255 | ret = -EILSEQ; | 262 | ret = -EILSEQ; |
256 | goto out; | 263 | goto out; |
257 | } | 264 | } |
258 | 265 | ||
259 | if (syn_fw->config_size && | 266 | if (config_size && |
260 | syn_fw->config_size != f34->v5.config_blocks * f34->v5.block_size) { | 267 | config_size != f34->v5.config_blocks * f34->v5.block_size) { |
261 | dev_err(&f34->fn->dev, | 268 | dev_err(&f34->fn->dev, |
262 | "Bad firmware image: config size %d, expected %d\n", | 269 | "Bad firmware image: config size %d, expected %d\n", |
263 | syn_fw->config_size, | 270 | config_size, |
264 | f34->v5.config_blocks * f34->v5.block_size); | 271 | f34->v5.config_blocks * f34->v5.block_size); |
265 | ret = -EILSEQ; | 272 | ret = -EILSEQ; |
266 | goto out; | 273 | goto out; |
267 | } | 274 | } |
268 | 275 | ||
269 | if (syn_fw->image_size && !syn_fw->config_size) { | 276 | if (image_size && !config_size) { |
270 | dev_err(&f34->fn->dev, "Bad firmware image: no config data\n"); | 277 | dev_err(&f34->fn->dev, "Bad firmware image: no config data\n"); |
271 | ret = -EILSEQ; | 278 | ret = -EILSEQ; |
272 | goto out; | 279 | goto out; |
@@ -283,6 +290,63 @@ out: | |||
283 | return ret; | 290 | return ret; |
284 | } | 291 | } |
285 | 292 | ||
293 | static int rmi_f34_status(struct rmi_function *fn) | ||
294 | { | ||
295 | struct f34_data *f34 = dev_get_drvdata(&fn->dev); | ||
296 | |||
297 | /* | ||
298 | * The status is the percentage complete, or once complete, | ||
299 | * zero for success or a negative return code. | ||
300 | */ | ||
301 | return f34->update_status; | ||
302 | } | ||
303 | |||
304 | static ssize_t rmi_driver_bootloader_id_show(struct device *dev, | ||
305 | struct device_attribute *dattr, | ||
306 | char *buf) | ||
307 | { | ||
308 | struct rmi_driver_data *data = dev_get_drvdata(dev); | ||
309 | struct rmi_function *fn = data->f34_container; | ||
310 | struct f34_data *f34; | ||
311 | |||
312 | if (fn) { | ||
313 | f34 = dev_get_drvdata(&fn->dev); | ||
314 | |||
315 | if (f34->bl_version == 5) | ||
316 | return scnprintf(buf, PAGE_SIZE, "%c%c\n", | ||
317 | f34->bootloader_id[0], | ||
318 | f34->bootloader_id[1]); | ||
319 | else | ||
320 | return scnprintf(buf, PAGE_SIZE, "V%d.%d\n", | ||
321 | f34->bootloader_id[1], | ||
322 | f34->bootloader_id[0]); | ||
323 | } | ||
324 | |||
325 | return 0; | ||
326 | } | ||
327 | |||
328 | static DEVICE_ATTR(bootloader_id, 0444, rmi_driver_bootloader_id_show, NULL); | ||
329 | |||
330 | static ssize_t rmi_driver_configuration_id_show(struct device *dev, | ||
331 | struct device_attribute *dattr, | ||
332 | char *buf) | ||
333 | { | ||
334 | struct rmi_driver_data *data = dev_get_drvdata(dev); | ||
335 | struct rmi_function *fn = data->f34_container; | ||
336 | struct f34_data *f34; | ||
337 | |||
338 | if (fn) { | ||
339 | f34 = dev_get_drvdata(&fn->dev); | ||
340 | |||
341 | return scnprintf(buf, PAGE_SIZE, "%s\n", f34->configuration_id); | ||
342 | } | ||
343 | |||
344 | return 0; | ||
345 | } | ||
346 | |||
347 | static DEVICE_ATTR(configuration_id, 0444, | ||
348 | rmi_driver_configuration_id_show, NULL); | ||
349 | |||
286 | static int rmi_firmware_update(struct rmi_driver_data *data, | 350 | static int rmi_firmware_update(struct rmi_driver_data *data, |
287 | const struct firmware *fw) | 351 | const struct firmware *fw) |
288 | { | 352 | { |
@@ -346,7 +410,13 @@ static int rmi_firmware_update(struct rmi_driver_data *data, | |||
346 | else | 410 | else |
347 | ret = rmi_f34_update_firmware(f34, fw); | 411 | ret = rmi_f34_update_firmware(f34, fw); |
348 | 412 | ||
349 | dev_info(&f34->fn->dev, "Firmware update complete, status:%d\n", ret); | 413 | if (ret) { |
414 | f34->update_status = ret; | ||
415 | dev_err(&f34->fn->dev, | ||
416 | "Firmware update failed, status: %d\n", ret); | ||
417 | } else { | ||
418 | dev_info(&f34->fn->dev, "Firmware update complete\n"); | ||
419 | } | ||
350 | 420 | ||
351 | rmi_disable_irq(rmi_dev, false); | 421 | rmi_disable_irq(rmi_dev, false); |
352 | 422 | ||
@@ -377,9 +447,6 @@ static int rmi_firmware_update(struct rmi_driver_data *data, | |||
377 | return ret; | 447 | return ret; |
378 | } | 448 | } |
379 | 449 | ||
380 | static int rmi_firmware_update(struct rmi_driver_data *data, | ||
381 | const struct firmware *fw); | ||
382 | |||
383 | static ssize_t rmi_driver_update_fw_store(struct device *dev, | 450 | static ssize_t rmi_driver_update_fw_store(struct device *dev, |
384 | struct device_attribute *dattr, | 451 | struct device_attribute *dattr, |
385 | const char *buf, size_t count) | 452 | const char *buf, size_t count) |
@@ -414,8 +481,27 @@ static ssize_t rmi_driver_update_fw_store(struct device *dev, | |||
414 | 481 | ||
415 | static DEVICE_ATTR(update_fw, 0200, NULL, rmi_driver_update_fw_store); | 482 | static DEVICE_ATTR(update_fw, 0200, NULL, rmi_driver_update_fw_store); |
416 | 483 | ||
484 | static ssize_t rmi_driver_update_fw_status_show(struct device *dev, | ||
485 | struct device_attribute *dattr, | ||
486 | char *buf) | ||
487 | { | ||
488 | struct rmi_driver_data *data = dev_get_drvdata(dev); | ||
489 | int update_status = 0; | ||
490 | |||
491 | if (data->f34_container) | ||
492 | update_status = rmi_f34_status(data->f34_container); | ||
493 | |||
494 | return scnprintf(buf, PAGE_SIZE, "%d\n", update_status); | ||
495 | } | ||
496 | |||
497 | static DEVICE_ATTR(update_fw_status, 0444, | ||
498 | rmi_driver_update_fw_status_show, NULL); | ||
499 | |||
417 | static struct attribute *rmi_firmware_attrs[] = { | 500 | static struct attribute *rmi_firmware_attrs[] = { |
501 | &dev_attr_bootloader_id.attr, | ||
502 | &dev_attr_configuration_id.attr, | ||
418 | &dev_attr_update_fw.attr, | 503 | &dev_attr_update_fw.attr, |
504 | &dev_attr_update_fw_status.attr, | ||
419 | NULL | 505 | NULL |
420 | }; | 506 | }; |
421 | 507 | ||
@@ -441,8 +527,6 @@ static int rmi_f34_probe(struct rmi_function *fn) | |||
441 | /* v5 code only supported version 0, try V7 probe */ | 527 | /* v5 code only supported version 0, try V7 probe */ |
442 | if (version > 0) | 528 | if (version > 0) |
443 | return rmi_f34v7_probe(f34); | 529 | return rmi_f34v7_probe(f34); |
444 | else if (version != 0) | ||
445 | return -ENODEV; | ||
446 | 530 | ||
447 | f34->bl_version = 5; | 531 | f34->bl_version = 5; |
448 | 532 | ||
diff --git a/drivers/input/rmi4/rmi_f34.h b/drivers/input/rmi4/rmi_f34.h index 2c21056dc375..43a91349b28d 100644 --- a/drivers/input/rmi4/rmi_f34.h +++ b/drivers/input/rmi4/rmi_f34.h | |||
@@ -301,6 +301,10 @@ struct f34_data { | |||
301 | unsigned char bootloader_id[5]; | 301 | unsigned char bootloader_id[5]; |
302 | unsigned char configuration_id[CONFIG_ID_SIZE*2 + 1]; | 302 | unsigned char configuration_id[CONFIG_ID_SIZE*2 + 1]; |
303 | 303 | ||
304 | int update_status; | ||
305 | int update_progress; | ||
306 | int update_size; | ||
307 | |||
304 | union { | 308 | union { |
305 | struct f34v5_data v5; | 309 | struct f34v5_data v5; |
306 | struct f34v7_data v7; | 310 | struct f34v7_data v7; |
diff --git a/drivers/input/rmi4/rmi_f34v7.c b/drivers/input/rmi4/rmi_f34v7.c index ca31f9539d9b..56c6c39ad31e 100644 --- a/drivers/input/rmi4/rmi_f34v7.c +++ b/drivers/input/rmi4/rmi_f34v7.c | |||
@@ -588,6 +588,7 @@ static int rmi_f34v7_check_ui_firmware_size(struct f34_data *f34) | |||
588 | u16 block_count; | 588 | u16 block_count; |
589 | 589 | ||
590 | block_count = f34->v7.img.ui_firmware.size / f34->v7.block_size; | 590 | block_count = f34->v7.img.ui_firmware.size / f34->v7.block_size; |
591 | f34->update_size += block_count; | ||
591 | 592 | ||
592 | if (block_count != f34->v7.blkcount.ui_firmware) { | 593 | if (block_count != f34->v7.blkcount.ui_firmware) { |
593 | dev_err(&f34->fn->dev, | 594 | dev_err(&f34->fn->dev, |
@@ -604,6 +605,7 @@ static int rmi_f34v7_check_ui_config_size(struct f34_data *f34) | |||
604 | u16 block_count; | 605 | u16 block_count; |
605 | 606 | ||
606 | block_count = f34->v7.img.ui_config.size / f34->v7.block_size; | 607 | block_count = f34->v7.img.ui_config.size / f34->v7.block_size; |
608 | f34->update_size += block_count; | ||
607 | 609 | ||
608 | if (block_count != f34->v7.blkcount.ui_config) { | 610 | if (block_count != f34->v7.blkcount.ui_config) { |
609 | dev_err(&f34->fn->dev, "UI config size mismatch\n"); | 611 | dev_err(&f34->fn->dev, "UI config size mismatch\n"); |
@@ -618,6 +620,7 @@ static int rmi_f34v7_check_dp_config_size(struct f34_data *f34) | |||
618 | u16 block_count; | 620 | u16 block_count; |
619 | 621 | ||
620 | block_count = f34->v7.img.dp_config.size / f34->v7.block_size; | 622 | block_count = f34->v7.img.dp_config.size / f34->v7.block_size; |
623 | f34->update_size += block_count; | ||
621 | 624 | ||
622 | if (block_count != f34->v7.blkcount.dp_config) { | 625 | if (block_count != f34->v7.blkcount.dp_config) { |
623 | dev_err(&f34->fn->dev, "Display config size mismatch\n"); | 626 | dev_err(&f34->fn->dev, "Display config size mismatch\n"); |
@@ -632,6 +635,8 @@ static int rmi_f34v7_check_guest_code_size(struct f34_data *f34) | |||
632 | u16 block_count; | 635 | u16 block_count; |
633 | 636 | ||
634 | block_count = f34->v7.img.guest_code.size / f34->v7.block_size; | 637 | block_count = f34->v7.img.guest_code.size / f34->v7.block_size; |
638 | f34->update_size += block_count; | ||
639 | |||
635 | if (block_count != f34->v7.blkcount.guest_code) { | 640 | if (block_count != f34->v7.blkcount.guest_code) { |
636 | dev_err(&f34->fn->dev, "Guest code size mismatch\n"); | 641 | dev_err(&f34->fn->dev, "Guest code size mismatch\n"); |
637 | return -EINVAL; | 642 | return -EINVAL; |
@@ -645,6 +650,7 @@ static int rmi_f34v7_check_bl_config_size(struct f34_data *f34) | |||
645 | u16 block_count; | 650 | u16 block_count; |
646 | 651 | ||
647 | block_count = f34->v7.img.bl_config.size / f34->v7.block_size; | 652 | block_count = f34->v7.img.bl_config.size / f34->v7.block_size; |
653 | f34->update_size += block_count; | ||
648 | 654 | ||
649 | if (block_count != f34->v7.blkcount.bl_config) { | 655 | if (block_count != f34->v7.blkcount.bl_config) { |
650 | dev_err(&f34->fn->dev, "Bootloader config size mismatch\n"); | 656 | dev_err(&f34->fn->dev, "Bootloader config size mismatch\n"); |
@@ -881,6 +887,9 @@ static int rmi_f34v7_write_f34v7_blocks(struct f34_data *f34, | |||
881 | 887 | ||
882 | block_ptr += (transfer * f34->v7.block_size); | 888 | block_ptr += (transfer * f34->v7.block_size); |
883 | remaining -= transfer; | 889 | remaining -= transfer; |
890 | f34->update_progress += transfer; | ||
891 | f34->update_status = (f34->update_progress * 100) / | ||
892 | f34->update_size; | ||
884 | } while (remaining); | 893 | } while (remaining); |
885 | 894 | ||
886 | return 0; | 895 | return 0; |
@@ -1191,6 +1200,8 @@ int rmi_f34v7_do_reflash(struct f34_data *f34, const struct firmware *fw) | |||
1191 | rmi_f34v7_read_queries_bl_version(f34); | 1200 | rmi_f34v7_read_queries_bl_version(f34); |
1192 | 1201 | ||
1193 | f34->v7.image = fw->data; | 1202 | f34->v7.image = fw->data; |
1203 | f34->update_progress = 0; | ||
1204 | f34->update_size = 0; | ||
1194 | 1205 | ||
1195 | ret = rmi_f34v7_parse_image_info(f34); | 1206 | ret = rmi_f34v7_parse_image_info(f34); |
1196 | if (ret < 0) | 1207 | if (ret < 0) |
diff --git a/drivers/input/serio/at32psif.c b/drivers/input/serio/at32psif.c index 2e4ff5bac754..e420fd781d44 100644 --- a/drivers/input/serio/at32psif.c +++ b/drivers/input/serio/at32psif.c | |||
@@ -159,13 +159,12 @@ static int psif_open(struct serio *io) | |||
159 | 159 | ||
160 | retval = clk_enable(psif->pclk); | 160 | retval = clk_enable(psif->pclk); |
161 | if (retval) | 161 | if (retval) |
162 | goto out; | 162 | return retval; |
163 | 163 | ||
164 | psif_writel(psif, CR, PSIF_BIT(CR_TXEN) | PSIF_BIT(CR_RXEN)); | 164 | psif_writel(psif, CR, PSIF_BIT(CR_TXEN) | PSIF_BIT(CR_RXEN)); |
165 | psif_writel(psif, IER, PSIF_BIT(RXRDY)); | 165 | psif_writel(psif, IER, PSIF_BIT(RXRDY)); |
166 | 166 | ||
167 | psif->open = true; | 167 | psif->open = true; |
168 | out: | ||
169 | return retval; | 168 | return retval; |
170 | } | 169 | } |
171 | 170 | ||
@@ -210,16 +209,12 @@ static int __init psif_probe(struct platform_device *pdev) | |||
210 | int ret; | 209 | int ret; |
211 | 210 | ||
212 | psif = kzalloc(sizeof(struct psif), GFP_KERNEL); | 211 | psif = kzalloc(sizeof(struct psif), GFP_KERNEL); |
213 | if (!psif) { | 212 | if (!psif) |
214 | dev_dbg(&pdev->dev, "out of memory\n"); | 213 | return -ENOMEM; |
215 | ret = -ENOMEM; | ||
216 | goto out; | ||
217 | } | ||
218 | psif->pdev = pdev; | 214 | psif->pdev = pdev; |
219 | 215 | ||
220 | io = kzalloc(sizeof(struct serio), GFP_KERNEL); | 216 | io = kzalloc(sizeof(struct serio), GFP_KERNEL); |
221 | if (!io) { | 217 | if (!io) { |
222 | dev_dbg(&pdev->dev, "out of memory\n"); | ||
223 | ret = -ENOMEM; | 218 | ret = -ENOMEM; |
224 | goto out_free_psif; | 219 | goto out_free_psif; |
225 | } | 220 | } |
@@ -297,7 +292,6 @@ out_free_io: | |||
297 | kfree(io); | 292 | kfree(io); |
298 | out_free_psif: | 293 | out_free_psif: |
299 | kfree(psif); | 294 | kfree(psif); |
300 | out: | ||
301 | return ret; | 295 | return ret; |
302 | } | 296 | } |
303 | 297 | ||
diff --git a/drivers/input/serio/hyperv-keyboard.c b/drivers/input/serio/hyperv-keyboard.c index c948866edf87..25151d9214e0 100644 --- a/drivers/input/serio/hyperv-keyboard.c +++ b/drivers/input/serio/hyperv-keyboard.c | |||
@@ -402,7 +402,6 @@ static int hv_kbd_remove(struct hv_device *hv_dev) | |||
402 | { | 402 | { |
403 | struct hv_kbd_dev *kbd_dev = hv_get_drvdata(hv_dev); | 403 | struct hv_kbd_dev *kbd_dev = hv_get_drvdata(hv_dev); |
404 | 404 | ||
405 | device_init_wakeup(&hv_dev->device, false); | ||
406 | serio_unregister_port(kbd_dev->hv_serio); | 405 | serio_unregister_port(kbd_dev->hv_serio); |
407 | vmbus_close(hv_dev->channel); | 406 | vmbus_close(hv_dev->channel); |
408 | kfree(kbd_dev); | 407 | kfree(kbd_dev); |
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index a7618776705a..05afd16ea9c9 100644 --- a/drivers/input/serio/i8042-x86ia64io.h +++ b/drivers/input/serio/i8042-x86ia64io.h | |||
@@ -923,6 +923,10 @@ static struct pnp_driver i8042_pnp_kbd_driver = { | |||
923 | .name = "i8042 kbd", | 923 | .name = "i8042 kbd", |
924 | .id_table = pnp_kbd_devids, | 924 | .id_table = pnp_kbd_devids, |
925 | .probe = i8042_pnp_kbd_probe, | 925 | .probe = i8042_pnp_kbd_probe, |
926 | .driver = { | ||
927 | .probe_type = PROBE_FORCE_SYNCHRONOUS, | ||
928 | .suppress_bind_attrs = true, | ||
929 | }, | ||
926 | }; | 930 | }; |
927 | 931 | ||
928 | static struct pnp_device_id pnp_aux_devids[] = { | 932 | static struct pnp_device_id pnp_aux_devids[] = { |
@@ -945,6 +949,10 @@ static struct pnp_driver i8042_pnp_aux_driver = { | |||
945 | .name = "i8042 aux", | 949 | .name = "i8042 aux", |
946 | .id_table = pnp_aux_devids, | 950 | .id_table = pnp_aux_devids, |
947 | .probe = i8042_pnp_aux_probe, | 951 | .probe = i8042_pnp_aux_probe, |
952 | .driver = { | ||
953 | .probe_type = PROBE_FORCE_SYNCHRONOUS, | ||
954 | .suppress_bind_attrs = true, | ||
955 | }, | ||
948 | }; | 956 | }; |
949 | 957 | ||
950 | static void i8042_pnp_exit(void) | 958 | static void i8042_pnp_exit(void) |
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index 62685a768913..c52da651269b 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c | |||
@@ -312,8 +312,10 @@ static int __i8042_command(unsigned char *param, int command) | |||
312 | 312 | ||
313 | for (i = 0; i < ((command >> 12) & 0xf); i++) { | 313 | for (i = 0; i < ((command >> 12) & 0xf); i++) { |
314 | error = i8042_wait_write(); | 314 | error = i8042_wait_write(); |
315 | if (error) | 315 | if (error) { |
316 | dbg(" -- i8042 (wait write timeout)\n"); | ||
316 | return error; | 317 | return error; |
318 | } | ||
317 | dbg("%02x -> i8042 (parameter)\n", param[i]); | 319 | dbg("%02x -> i8042 (parameter)\n", param[i]); |
318 | i8042_write_data(param[i]); | 320 | i8042_write_data(param[i]); |
319 | } | 321 | } |
@@ -321,7 +323,7 @@ static int __i8042_command(unsigned char *param, int command) | |||
321 | for (i = 0; i < ((command >> 8) & 0xf); i++) { | 323 | for (i = 0; i < ((command >> 8) & 0xf); i++) { |
322 | error = i8042_wait_read(); | 324 | error = i8042_wait_read(); |
323 | if (error) { | 325 | if (error) { |
324 | dbg(" -- i8042 (timeout)\n"); | 326 | dbg(" -- i8042 (wait read timeout)\n"); |
325 | return error; | 327 | return error; |
326 | } | 328 | } |
327 | 329 | ||
diff --git a/drivers/input/serio/xilinx_ps2.c b/drivers/input/serio/xilinx_ps2.c index 5223cbf94262..14c40892ed82 100644 --- a/drivers/input/serio/xilinx_ps2.c +++ b/drivers/input/serio/xilinx_ps2.c | |||
@@ -243,18 +243,17 @@ static int xps2_of_probe(struct platform_device *ofdev) | |||
243 | unsigned int irq; | 243 | unsigned int irq; |
244 | int error; | 244 | int error; |
245 | 245 | ||
246 | dev_info(dev, "Device Tree Probing \'%s\'\n", | 246 | dev_info(dev, "Device Tree Probing \'%s\'\n", dev->of_node->name); |
247 | ofdev->dev.of_node->name); | ||
248 | 247 | ||
249 | /* Get iospace for the device */ | 248 | /* Get iospace for the device */ |
250 | error = of_address_to_resource(ofdev->dev.of_node, 0, &r_mem); | 249 | error = of_address_to_resource(dev->of_node, 0, &r_mem); |
251 | if (error) { | 250 | if (error) { |
252 | dev_err(dev, "invalid address\n"); | 251 | dev_err(dev, "invalid address\n"); |
253 | return error; | 252 | return error; |
254 | } | 253 | } |
255 | 254 | ||
256 | /* Get IRQ for the device */ | 255 | /* Get IRQ for the device */ |
257 | irq = irq_of_parse_and_map(ofdev->dev.of_node, 0); | 256 | irq = irq_of_parse_and_map(dev->of_node, 0); |
258 | if (!irq) { | 257 | if (!irq) { |
259 | dev_err(dev, "no IRQ found\n"); | 258 | dev_err(dev, "no IRQ found\n"); |
260 | return -ENODEV; | 259 | return -ENODEV; |
diff --git a/drivers/input/touchscreen/88pm860x-ts.c b/drivers/input/touchscreen/88pm860x-ts.c index 251ff2aa0633..7ed828a51f4c 100644 --- a/drivers/input/touchscreen/88pm860x-ts.c +++ b/drivers/input/touchscreen/88pm860x-ts.c | |||
@@ -240,8 +240,6 @@ static int pm860x_touch_probe(struct platform_device *pdev) | |||
240 | if (!touch) | 240 | if (!touch) |
241 | return -ENOMEM; | 241 | return -ENOMEM; |
242 | 242 | ||
243 | platform_set_drvdata(pdev, touch); | ||
244 | |||
245 | touch->idev = devm_input_allocate_device(&pdev->dev); | 243 | touch->idev = devm_input_allocate_device(&pdev->dev); |
246 | if (!touch->idev) { | 244 | if (!touch->idev) { |
247 | dev_err(&pdev->dev, "Failed to allocate input device!\n"); | 245 | dev_err(&pdev->dev, "Failed to allocate input device!\n"); |
@@ -285,7 +283,6 @@ static int pm860x_touch_probe(struct platform_device *pdev) | |||
285 | return ret; | 283 | return ret; |
286 | } | 284 | } |
287 | 285 | ||
288 | platform_set_drvdata(pdev, touch); | ||
289 | return 0; | 286 | return 0; |
290 | } | 287 | } |
291 | 288 | ||
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index efca0133e266..033599777651 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig | |||
@@ -546,18 +546,6 @@ config TOUCHSCREEN_INEXIO | |||
546 | To compile this driver as a module, choose M here: the | 546 | To compile this driver as a module, choose M here: the |
547 | module will be called inexio. | 547 | module will be called inexio. |
548 | 548 | ||
549 | config TOUCHSCREEN_INTEL_MID | ||
550 | tristate "Intel MID platform resistive touchscreen" | ||
551 | depends on INTEL_SCU_IPC | ||
552 | help | ||
553 | Say Y here if you have a Intel MID based touchscreen in | ||
554 | your system. | ||
555 | |||
556 | If unsure, say N. | ||
557 | |||
558 | To compile this driver as a module, choose M here: the | ||
559 | module will be called intel_mid_touch. | ||
560 | |||
561 | config TOUCHSCREEN_MK712 | 549 | config TOUCHSCREEN_MK712 |
562 | tristate "ICS MicroClock MK712 touchscreen" | 550 | tristate "ICS MicroClock MK712 touchscreen" |
563 | help | 551 | help |
@@ -1177,6 +1165,17 @@ config TOUCHSCREEN_TPS6507X | |||
1177 | To compile this driver as a module, choose M here: the | 1165 | To compile this driver as a module, choose M here: the |
1178 | module will be called tps6507x_ts. | 1166 | module will be called tps6507x_ts. |
1179 | 1167 | ||
1168 | config TOUCHSCREEN_ZET6223 | ||
1169 | tristate "Zeitec ZET6223 touchscreen driver" | ||
1170 | depends on I2C | ||
1171 | help | ||
1172 | Say Y here if you have a touchscreen using Zeitec ZET6223 | ||
1173 | |||
1174 | If unsure, say N. | ||
1175 | |||
1176 | To compile this driver as a module, choose M here: the | ||
1177 | module will be called zet6223. | ||
1178 | |||
1180 | config TOUCHSCREEN_ZFORCE | 1179 | config TOUCHSCREEN_ZFORCE |
1181 | tristate "Neonode zForce infrared touchscreens" | 1180 | tristate "Neonode zForce infrared touchscreens" |
1182 | depends on I2C | 1181 | depends on I2C |
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 81b86451782d..b622e5344137 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile | |||
@@ -42,7 +42,6 @@ obj-$(CONFIG_TOUCHSCREEN_GOODIX) += goodix.o | |||
42 | obj-$(CONFIG_TOUCHSCREEN_ILI210X) += ili210x.o | 42 | obj-$(CONFIG_TOUCHSCREEN_ILI210X) += ili210x.o |
43 | obj-$(CONFIG_TOUCHSCREEN_IMX6UL_TSC) += imx6ul_tsc.o | 43 | obj-$(CONFIG_TOUCHSCREEN_IMX6UL_TSC) += imx6ul_tsc.o |
44 | obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o | 44 | obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o |
45 | obj-$(CONFIG_TOUCHSCREEN_INTEL_MID) += intel-mid-touch.o | ||
46 | obj-$(CONFIG_TOUCHSCREEN_IPROC) += bcm_iproc_tsc.o | 45 | obj-$(CONFIG_TOUCHSCREEN_IPROC) += bcm_iproc_tsc.o |
47 | obj-$(CONFIG_TOUCHSCREEN_LPC32XX) += lpc32xx_ts.o | 46 | obj-$(CONFIG_TOUCHSCREEN_LPC32XX) += lpc32xx_ts.o |
48 | obj-$(CONFIG_TOUCHSCREEN_MAX11801) += max11801_ts.o | 47 | obj-$(CONFIG_TOUCHSCREEN_MAX11801) += max11801_ts.o |
@@ -96,6 +95,7 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE) += zylonite-wm97xx.o | |||
96 | obj-$(CONFIG_TOUCHSCREEN_W90X900) += w90p910_ts.o | 95 | obj-$(CONFIG_TOUCHSCREEN_W90X900) += w90p910_ts.o |
97 | obj-$(CONFIG_TOUCHSCREEN_SX8654) += sx8654.o | 96 | obj-$(CONFIG_TOUCHSCREEN_SX8654) += sx8654.o |
98 | obj-$(CONFIG_TOUCHSCREEN_TPS6507X) += tps6507x-ts.o | 97 | obj-$(CONFIG_TOUCHSCREEN_TPS6507X) += tps6507x-ts.o |
98 | obj-$(CONFIG_TOUCHSCREEN_ZET6223) += zet6223.o | ||
99 | obj-$(CONFIG_TOUCHSCREEN_ZFORCE) += zforce_ts.o | 99 | obj-$(CONFIG_TOUCHSCREEN_ZFORCE) += zforce_ts.o |
100 | obj-$(CONFIG_TOUCHSCREEN_COLIBRI_VF50) += colibri-vf50-ts.o | 100 | obj-$(CONFIG_TOUCHSCREEN_COLIBRI_VF50) += colibri-vf50-ts.o |
101 | obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023) += rohm_bu21023.o | 101 | obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023) += rohm_bu21023.o |
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 1ce3ecbe37f8..f5793e3d945f 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
@@ -1462,8 +1462,6 @@ static int ads7846_remove(struct spi_device *spi) | |||
1462 | { | 1462 | { |
1463 | struct ads7846 *ts = spi_get_drvdata(spi); | 1463 | struct ads7846 *ts = spi_get_drvdata(spi); |
1464 | 1464 | ||
1465 | device_init_wakeup(&spi->dev, false); | ||
1466 | |||
1467 | sysfs_remove_group(&spi->dev.kobj, &ads784x_attr_group); | 1465 | sysfs_remove_group(&spi->dev.kobj, &ads784x_attr_group); |
1468 | 1466 | ||
1469 | ads7846_disable(ts); | 1467 | ads7846_disable(ts); |
diff --git a/drivers/input/touchscreen/ar1021_i2c.c b/drivers/input/touchscreen/ar1021_i2c.c index 71b5a634cf6d..6562b17117f7 100644 --- a/drivers/input/touchscreen/ar1021_i2c.c +++ b/drivers/input/touchscreen/ar1021_i2c.c | |||
@@ -127,7 +127,6 @@ static int ar1021_i2c_probe(struct i2c_client *client, | |||
127 | return error; | 127 | return error; |
128 | } | 128 | } |
129 | 129 | ||
130 | i2c_set_clientdata(client, ar1021); | ||
131 | return 0; | 130 | return 0; |
132 | } | 131 | } |
133 | 132 | ||
diff --git a/drivers/input/touchscreen/atmel-wm97xx.c b/drivers/input/touchscreen/atmel-wm97xx.c index 7ec0421c0dd8..8cf0b2be2df4 100644 --- a/drivers/input/touchscreen/atmel-wm97xx.c +++ b/drivers/input/touchscreen/atmel-wm97xx.c | |||
@@ -339,10 +339,8 @@ static int __init atmel_wm97xx_probe(struct platform_device *pdev) | |||
339 | int ret; | 339 | int ret; |
340 | 340 | ||
341 | atmel_wm97xx = kzalloc(sizeof(struct atmel_wm97xx), GFP_KERNEL); | 341 | atmel_wm97xx = kzalloc(sizeof(struct atmel_wm97xx), GFP_KERNEL); |
342 | if (!atmel_wm97xx) { | 342 | if (!atmel_wm97xx) |
343 | dev_dbg(&pdev->dev, "out of memory\n"); | ||
344 | return -ENOMEM; | 343 | return -ENOMEM; |
345 | } | ||
346 | 344 | ||
347 | atmel_wm97xx->wm = wm; | 345 | atmel_wm97xx->wm = wm; |
348 | atmel_wm97xx->regs = (void *)ATMEL_WM97XX_AC97C_IOMEM; | 346 | atmel_wm97xx->regs = (void *)ATMEL_WM97XX_AC97C_IOMEM; |
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index e5d185fe69b9..2302aef2b2d4 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c | |||
@@ -2509,7 +2509,7 @@ static void mxt_debug_init(struct mxt_data *data) | |||
2509 | dbg->t37_pages = MXT1386_COLUMNS * MXT1386_PAGES_PER_COLUMN; | 2509 | dbg->t37_pages = MXT1386_COLUMNS * MXT1386_PAGES_PER_COLUMN; |
2510 | else | 2510 | else |
2511 | dbg->t37_pages = DIV_ROUND_UP(data->xsize * | 2511 | dbg->t37_pages = DIV_ROUND_UP(data->xsize * |
2512 | data->info.matrix_ysize * | 2512 | info->matrix_ysize * |
2513 | sizeof(u16), | 2513 | sizeof(u16), |
2514 | sizeof(dbg->t37_buf->data)); | 2514 | sizeof(dbg->t37_buf->data)); |
2515 | 2515 | ||
diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c index 931417eb4f5a..4fa5da8d5fa8 100644 --- a/drivers/input/touchscreen/bu21013_ts.c +++ b/drivers/input/touchscreen/bu21013_ts.c | |||
@@ -637,8 +637,6 @@ static int bu21013_remove(struct i2c_client *client) | |||
637 | 637 | ||
638 | kfree(bu21013_data); | 638 | kfree(bu21013_data); |
639 | 639 | ||
640 | device_init_wakeup(&client->dev, false); | ||
641 | |||
642 | return 0; | 640 | return 0; |
643 | } | 641 | } |
644 | 642 | ||
diff --git a/drivers/input/touchscreen/colibri-vf50-ts.c b/drivers/input/touchscreen/colibri-vf50-ts.c index 69828d015d45..69c08acae264 100644 --- a/drivers/input/touchscreen/colibri-vf50-ts.c +++ b/drivers/input/touchscreen/colibri-vf50-ts.c | |||
@@ -311,8 +311,6 @@ static int vf50_ts_probe(struct platform_device *pdev) | |||
311 | return -ENOMEM; | 311 | return -ENOMEM; |
312 | } | 312 | } |
313 | 313 | ||
314 | platform_set_drvdata(pdev, touchdev); | ||
315 | |||
316 | input->name = DRIVER_NAME; | 314 | input->name = DRIVER_NAME; |
317 | input->id.bustype = BUS_HOST; | 315 | input->id.bustype = BUS_HOST; |
318 | input->dev.parent = dev; | 316 | input->dev.parent = dev; |
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index 28466e358fee..8cf8d8d5d4ef 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c | |||
@@ -67,7 +67,7 @@ | |||
67 | #define EDT_SWITCH_MODE_RETRIES 10 | 67 | #define EDT_SWITCH_MODE_RETRIES 10 |
68 | #define EDT_SWITCH_MODE_DELAY 5 /* msec */ | 68 | #define EDT_SWITCH_MODE_DELAY 5 /* msec */ |
69 | #define EDT_RAW_DATA_RETRIES 100 | 69 | #define EDT_RAW_DATA_RETRIES 100 |
70 | #define EDT_RAW_DATA_DELAY 1 /* msec */ | 70 | #define EDT_RAW_DATA_DELAY 1000 /* usec */ |
71 | 71 | ||
72 | enum edt_ver { | 72 | enum edt_ver { |
73 | M06, | 73 | M06, |
@@ -664,7 +664,7 @@ static ssize_t edt_ft5x06_debugfs_raw_data_read(struct file *file, | |||
664 | } | 664 | } |
665 | 665 | ||
666 | do { | 666 | do { |
667 | msleep(EDT_RAW_DATA_DELAY); | 667 | usleep_range(EDT_RAW_DATA_DELAY, EDT_RAW_DATA_DELAY + 100); |
668 | val = edt_ft5x06_register_read(tsdata, 0x08); | 668 | val = edt_ft5x06_register_read(tsdata, 0x08); |
669 | if (val < 1) | 669 | if (val < 1) |
670 | break; | 670 | break; |
@@ -982,7 +982,6 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, | |||
982 | return error; | 982 | return error; |
983 | } | 983 | } |
984 | 984 | ||
985 | input_set_drvdata(input, tsdata); | ||
986 | i2c_set_clientdata(client, tsdata); | 985 | i2c_set_clientdata(client, tsdata); |
987 | 986 | ||
988 | irq_flags = irq_get_trigger_type(client->irq); | 987 | irq_flags = irq_get_trigger_type(client->irq); |
diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c index 09be6ced7151..16023867b9da 100644 --- a/drivers/input/touchscreen/eeti_ts.c +++ b/drivers/input/touchscreen/eeti_ts.c | |||
@@ -173,12 +173,11 @@ static int eeti_ts_probe(struct i2c_client *client, | |||
173 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | 173 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
174 | if (!priv) { | 174 | if (!priv) { |
175 | dev_err(&client->dev, "failed to allocate driver data\n"); | 175 | dev_err(&client->dev, "failed to allocate driver data\n"); |
176 | goto err0; | 176 | return -ENOMEM; |
177 | } | 177 | } |
178 | 178 | ||
179 | mutex_init(&priv->mutex); | 179 | mutex_init(&priv->mutex); |
180 | input = input_allocate_device(); | 180 | input = input_allocate_device(); |
181 | |||
182 | if (!input) { | 181 | if (!input) { |
183 | dev_err(&client->dev, "Failed to allocate input device.\n"); | 182 | dev_err(&client->dev, "Failed to allocate input device.\n"); |
184 | goto err1; | 183 | goto err1; |
@@ -232,7 +231,6 @@ static int eeti_ts_probe(struct i2c_client *client, | |||
232 | */ | 231 | */ |
233 | eeti_ts_stop(priv); | 232 | eeti_ts_stop(priv); |
234 | 233 | ||
235 | device_init_wakeup(&client->dev, 0); | ||
236 | return 0; | 234 | return 0; |
237 | 235 | ||
238 | err3: | 236 | err3: |
@@ -243,7 +241,6 @@ err2: | |||
243 | err1: | 241 | err1: |
244 | input_free_device(input); | 242 | input_free_device(input); |
245 | kfree(priv); | 243 | kfree(priv); |
246 | err0: | ||
247 | return err; | 244 | return err; |
248 | } | 245 | } |
249 | 246 | ||
diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c index 1afc08b08155..752ae9cf4514 100644 --- a/drivers/input/touchscreen/egalax_ts.c +++ b/drivers/input/touchscreen/egalax_ts.c | |||
@@ -214,8 +214,6 @@ static int egalax_ts_probe(struct i2c_client *client, | |||
214 | ABS_MT_POSITION_Y, 0, EGALAX_MAX_Y, 0, 0); | 214 | ABS_MT_POSITION_Y, 0, EGALAX_MAX_Y, 0, 0); |
215 | input_mt_init_slots(input_dev, MAX_SUPPORT_POINTS, 0); | 215 | input_mt_init_slots(input_dev, MAX_SUPPORT_POINTS, 0); |
216 | 216 | ||
217 | input_set_drvdata(input_dev, ts); | ||
218 | |||
219 | error = devm_request_threaded_irq(&client->dev, client->irq, NULL, | 217 | error = devm_request_threaded_irq(&client->dev, client->irq, NULL, |
220 | egalax_ts_interrupt, | 218 | egalax_ts_interrupt, |
221 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, | 219 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, |
@@ -229,7 +227,6 @@ static int egalax_ts_probe(struct i2c_client *client, | |||
229 | if (error) | 227 | if (error) |
230 | return error; | 228 | return error; |
231 | 229 | ||
232 | i2c_set_clientdata(client, ts); | ||
233 | return 0; | 230 | return 0; |
234 | } | 231 | } |
235 | 232 | ||
diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c index 3e6003d32e56..872750eeca93 100644 --- a/drivers/input/touchscreen/elants_i2c.c +++ b/drivers/input/touchscreen/elants_i2c.c | |||
@@ -1260,8 +1260,6 @@ static int elants_i2c_probe(struct i2c_client *client, | |||
1260 | input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->x_res); | 1260 | input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->x_res); |
1261 | input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->y_res); | 1261 | input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->y_res); |
1262 | 1262 | ||
1263 | input_set_drvdata(ts->input, ts); | ||
1264 | |||
1265 | error = input_register_device(ts->input); | 1263 | error = input_register_device(ts->input); |
1266 | if (error) { | 1264 | if (error) { |
1267 | dev_err(&client->dev, | 1265 | dev_err(&client->dev, |
diff --git a/drivers/input/touchscreen/fsl-imx25-tcq.c b/drivers/input/touchscreen/fsl-imx25-tcq.c index d50ee490c9cc..47fe1f184bbc 100644 --- a/drivers/input/touchscreen/fsl-imx25-tcq.c +++ b/drivers/input/touchscreen/fsl-imx25-tcq.c | |||
@@ -507,7 +507,7 @@ static int mx25_tcq_probe(struct platform_device *pdev) | |||
507 | struct device *dev = &pdev->dev; | 507 | struct device *dev = &pdev->dev; |
508 | struct input_dev *idev; | 508 | struct input_dev *idev; |
509 | struct mx25_tcq_priv *priv; | 509 | struct mx25_tcq_priv *priv; |
510 | struct mx25_tsadc *tsadc = dev_get_drvdata(pdev->dev.parent); | 510 | struct mx25_tsadc *tsadc = dev_get_drvdata(dev->parent); |
511 | struct resource *res; | 511 | struct resource *res; |
512 | void __iomem *mem; | 512 | void __iomem *mem; |
513 | int error; | 513 | int error; |
diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c index fe4848bd1f4c..6f76eeedf465 100644 --- a/drivers/input/touchscreen/ili210x.c +++ b/drivers/input/touchscreen/ili210x.c | |||
@@ -256,7 +256,6 @@ static int ili210x_i2c_probe(struct i2c_client *client, | |||
256 | input_set_abs_params(input, ABS_MT_POSITION_X, 0, xmax, 0, 0); | 256 | input_set_abs_params(input, ABS_MT_POSITION_X, 0, xmax, 0, 0); |
257 | input_set_abs_params(input, ABS_MT_POSITION_Y, 0, ymax, 0, 0); | 257 | input_set_abs_params(input, ABS_MT_POSITION_Y, 0, ymax, 0, 0); |
258 | 258 | ||
259 | input_set_drvdata(input, priv); | ||
260 | i2c_set_clientdata(client, priv); | 259 | i2c_set_clientdata(client, priv); |
261 | 260 | ||
262 | error = request_irq(client->irq, ili210x_irq, pdata->irq_flags, | 261 | error = request_irq(client->irq, ili210x_irq, pdata->irq_flags, |
@@ -280,7 +279,7 @@ static int ili210x_i2c_probe(struct i2c_client *client, | |||
280 | goto err_remove_sysfs; | 279 | goto err_remove_sysfs; |
281 | } | 280 | } |
282 | 281 | ||
283 | device_init_wakeup(&client->dev, 1); | 282 | device_init_wakeup(dev, 1); |
284 | 283 | ||
285 | dev_dbg(dev, | 284 | dev_dbg(dev, |
286 | "ILI210x initialized (IRQ: %d), firmware version %d.%d.%d", | 285 | "ILI210x initialized (IRQ: %d), firmware version %d.%d.%d", |
diff --git a/drivers/input/touchscreen/intel-mid-touch.c b/drivers/input/touchscreen/intel-mid-touch.c deleted file mode 100644 index b4f0725a1c3d..000000000000 --- a/drivers/input/touchscreen/intel-mid-touch.c +++ /dev/null | |||
@@ -1,654 +0,0 @@ | |||
1 | /* | ||
2 | * Intel MID Resistive Touch Screen Driver | ||
3 | * | ||
4 | * Copyright (C) 2008 Intel Corp | ||
5 | * | ||
6 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; version 2 of the License. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, but | ||
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License along | ||
18 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
20 | * | ||
21 | * Questions/Comments/Bug fixes to Sreedhara (sreedhara.ds@intel.com) | ||
22 | * Ramesh Agarwal (ramesh.agarwal@intel.com) | ||
23 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
24 | * | ||
25 | * TODO: | ||
26 | * review conversion of r/m/w sequences | ||
27 | */ | ||
28 | |||
29 | #include <linux/module.h> | ||
30 | #include <linux/input.h> | ||
31 | #include <linux/interrupt.h> | ||
32 | #include <linux/err.h> | ||
33 | #include <linux/param.h> | ||
34 | #include <linux/slab.h> | ||
35 | #include <linux/platform_device.h> | ||
36 | #include <linux/irq.h> | ||
37 | #include <linux/delay.h> | ||
38 | #include <asm/intel_scu_ipc.h> | ||
39 | #include <linux/device.h> | ||
40 | |||
41 | /* PMIC Interrupt registers */ | ||
42 | #define PMIC_REG_ID1 0x00 /* PMIC ID1 register */ | ||
43 | |||
44 | /* PMIC Interrupt registers */ | ||
45 | #define PMIC_REG_INT 0x04 /* PMIC interrupt register */ | ||
46 | #define PMIC_REG_MINT 0x05 /* PMIC interrupt mask register */ | ||
47 | |||
48 | /* ADC Interrupt registers */ | ||
49 | #define PMIC_REG_ADCINT 0x5F /* ADC interrupt register */ | ||
50 | #define PMIC_REG_MADCINT 0x60 /* ADC interrupt mask register */ | ||
51 | |||
52 | /* ADC Control registers */ | ||
53 | #define PMIC_REG_ADCCNTL1 0x61 /* ADC control register */ | ||
54 | |||
55 | /* ADC Channel Selection registers */ | ||
56 | #define PMICADDR0 0xA4 | ||
57 | #define END_OF_CHANNEL 0x1F | ||
58 | |||
59 | /* ADC Result register */ | ||
60 | #define PMIC_REG_ADCSNS0H 0x64 | ||
61 | |||
62 | /* ADC channels for touch screen */ | ||
63 | #define MRST_TS_CHAN10 0xA /* Touch screen X+ connection */ | ||
64 | #define MRST_TS_CHAN11 0xB /* Touch screen X- connection */ | ||
65 | #define MRST_TS_CHAN12 0xC /* Touch screen Y+ connection */ | ||
66 | #define MRST_TS_CHAN13 0xD /* Touch screen Y- connection */ | ||
67 | |||
68 | /* Touch screen channel BIAS constants */ | ||
69 | #define MRST_XBIAS 0x20 | ||
70 | #define MRST_YBIAS 0x40 | ||
71 | #define MRST_ZBIAS 0x80 | ||
72 | |||
73 | /* Touch screen coordinates */ | ||
74 | #define MRST_X_MIN 10 | ||
75 | #define MRST_X_MAX 1024 | ||
76 | #define MRST_X_FUZZ 5 | ||
77 | #define MRST_Y_MIN 10 | ||
78 | #define MRST_Y_MAX 1024 | ||
79 | #define MRST_Y_FUZZ 5 | ||
80 | #define MRST_PRESSURE_MIN 0 | ||
81 | #define MRST_PRESSURE_NOMINAL 50 | ||
82 | #define MRST_PRESSURE_MAX 100 | ||
83 | |||
84 | #define WAIT_ADC_COMPLETION 10 /* msec */ | ||
85 | |||
86 | /* PMIC ADC round robin delays */ | ||
87 | #define ADC_LOOP_DELAY0 0x0 /* Continuous loop */ | ||
88 | #define ADC_LOOP_DELAY1 0x1 /* 4.5 ms approximate */ | ||
89 | |||
90 | /* PMIC Vendor Identifiers */ | ||
91 | #define PMIC_VENDOR_FS 0 /* PMIC vendor FreeScale */ | ||
92 | #define PMIC_VENDOR_MAXIM 1 /* PMIC vendor MAXIM */ | ||
93 | #define PMIC_VENDOR_NEC 2 /* PMIC vendor NEC */ | ||
94 | #define MRSTOUCH_MAX_CHANNELS 32 /* Maximum ADC channels */ | ||
95 | |||
96 | /* Touch screen device structure */ | ||
97 | struct mrstouch_dev { | ||
98 | struct device *dev; /* device associated with touch screen */ | ||
99 | struct input_dev *input; | ||
100 | char phys[32]; | ||
101 | u16 asr; /* Address selection register */ | ||
102 | int irq; | ||
103 | unsigned int vendor; /* PMIC vendor */ | ||
104 | unsigned int rev; /* PMIC revision */ | ||
105 | |||
106 | int (*read_prepare)(struct mrstouch_dev *tsdev); | ||
107 | int (*read)(struct mrstouch_dev *tsdev, u16 *x, u16 *y, u16 *z); | ||
108 | int (*read_finish)(struct mrstouch_dev *tsdev); | ||
109 | }; | ||
110 | |||
111 | |||
112 | /*************************** NEC and Maxim Interface ************************/ | ||
113 | |||
114 | static int mrstouch_nec_adc_read_prepare(struct mrstouch_dev *tsdev) | ||
115 | { | ||
116 | return intel_scu_ipc_update_register(PMIC_REG_MADCINT, 0, 0x20); | ||
117 | } | ||
118 | |||
119 | /* | ||
120 | * Enables PENDET interrupt. | ||
121 | */ | ||
122 | static int mrstouch_nec_adc_read_finish(struct mrstouch_dev *tsdev) | ||
123 | { | ||
124 | int err; | ||
125 | |||
126 | err = intel_scu_ipc_update_register(PMIC_REG_MADCINT, 0x20, 0x20); | ||
127 | if (!err) | ||
128 | err = intel_scu_ipc_update_register(PMIC_REG_ADCCNTL1, 0, 0x05); | ||
129 | |||
130 | return err; | ||
131 | } | ||
132 | |||
133 | /* | ||
134 | * Reads PMIC ADC touch screen result | ||
135 | * Reads ADC storage registers for higher 7 and lower 3 bits and | ||
136 | * converts the two readings into a single value and turns off gain bit | ||
137 | */ | ||
138 | static int mrstouch_ts_chan_read(u16 offset, u16 chan, u16 *vp, u16 *vm) | ||
139 | { | ||
140 | int err; | ||
141 | u16 result; | ||
142 | u32 res; | ||
143 | |||
144 | result = PMIC_REG_ADCSNS0H + offset; | ||
145 | |||
146 | if (chan == MRST_TS_CHAN12) | ||
147 | result += 4; | ||
148 | |||
149 | err = intel_scu_ipc_ioread32(result, &res); | ||
150 | if (err) | ||
151 | return err; | ||
152 | |||
153 | /* Mash the bits up */ | ||
154 | |||
155 | *vp = (res & 0xFF) << 3; /* Highest 7 bits */ | ||
156 | *vp |= (res >> 8) & 0x07; /* Lower 3 bits */ | ||
157 | *vp &= 0x3FF; | ||
158 | |||
159 | res >>= 16; | ||
160 | |||
161 | *vm = (res & 0xFF) << 3; /* Highest 7 bits */ | ||
162 | *vm |= (res >> 8) & 0x07; /* Lower 3 bits */ | ||
163 | *vm &= 0x3FF; | ||
164 | |||
165 | return 0; | ||
166 | } | ||
167 | |||
168 | /* | ||
169 | * Enables X, Y and Z bias values | ||
170 | * Enables YPYM for X channels and XPXM for Y channels | ||
171 | */ | ||
172 | static int mrstouch_ts_bias_set(uint offset, uint bias) | ||
173 | { | ||
174 | int count; | ||
175 | u16 chan, start; | ||
176 | u16 reg[4]; | ||
177 | u8 data[4]; | ||
178 | |||
179 | chan = PMICADDR0 + offset; | ||
180 | start = MRST_TS_CHAN10; | ||
181 | |||
182 | for (count = 0; count <= 3; count++) { | ||
183 | reg[count] = chan++; | ||
184 | data[count] = bias | (start + count); | ||
185 | } | ||
186 | |||
187 | return intel_scu_ipc_writev(reg, data, 4); | ||
188 | } | ||
189 | |||
190 | /* To read touch screen channel values */ | ||
191 | static int mrstouch_nec_adc_read(struct mrstouch_dev *tsdev, | ||
192 | u16 *x, u16 *y, u16 *z) | ||
193 | { | ||
194 | int err; | ||
195 | u16 xm, ym, zm; | ||
196 | |||
197 | /* configure Y bias for X channels */ | ||
198 | err = mrstouch_ts_bias_set(tsdev->asr, MRST_YBIAS); | ||
199 | if (err) | ||
200 | goto ipc_error; | ||
201 | |||
202 | msleep(WAIT_ADC_COMPLETION); | ||
203 | |||
204 | /* read x+ and x- channels */ | ||
205 | err = mrstouch_ts_chan_read(tsdev->asr, MRST_TS_CHAN10, x, &xm); | ||
206 | if (err) | ||
207 | goto ipc_error; | ||
208 | |||
209 | /* configure x bias for y channels */ | ||
210 | err = mrstouch_ts_bias_set(tsdev->asr, MRST_XBIAS); | ||
211 | if (err) | ||
212 | goto ipc_error; | ||
213 | |||
214 | msleep(WAIT_ADC_COMPLETION); | ||
215 | |||
216 | /* read y+ and y- channels */ | ||
217 | err = mrstouch_ts_chan_read(tsdev->asr, MRST_TS_CHAN12, y, &ym); | ||
218 | if (err) | ||
219 | goto ipc_error; | ||
220 | |||
221 | /* configure z bias for x and y channels */ | ||
222 | err = mrstouch_ts_bias_set(tsdev->asr, MRST_ZBIAS); | ||
223 | if (err) | ||
224 | goto ipc_error; | ||
225 | |||
226 | msleep(WAIT_ADC_COMPLETION); | ||
227 | |||
228 | /* read z+ and z- channels */ | ||
229 | err = mrstouch_ts_chan_read(tsdev->asr, MRST_TS_CHAN10, z, &zm); | ||
230 | if (err) | ||
231 | goto ipc_error; | ||
232 | |||
233 | return 0; | ||
234 | |||
235 | ipc_error: | ||
236 | dev_err(tsdev->dev, "ipc error during adc read\n"); | ||
237 | return err; | ||
238 | } | ||
239 | |||
240 | |||
241 | /*************************** Freescale Interface ************************/ | ||
242 | |||
243 | static int mrstouch_fs_adc_read_prepare(struct mrstouch_dev *tsdev) | ||
244 | { | ||
245 | int err, count; | ||
246 | u16 chan; | ||
247 | u16 reg[5]; | ||
248 | u8 data[5]; | ||
249 | |||
250 | /* Stop the ADC */ | ||
251 | err = intel_scu_ipc_update_register(PMIC_REG_MADCINT, 0x00, 0x02); | ||
252 | if (err) | ||
253 | goto ipc_error; | ||
254 | |||
255 | chan = PMICADDR0 + tsdev->asr; | ||
256 | |||
257 | /* Set X BIAS */ | ||
258 | for (count = 0; count <= 3; count++) { | ||
259 | reg[count] = chan++; | ||
260 | data[count] = 0x2A; | ||
261 | } | ||
262 | reg[count] = chan++; /* Dummy */ | ||
263 | data[count] = 0; | ||
264 | |||
265 | err = intel_scu_ipc_writev(reg, data, 5); | ||
266 | if (err) | ||
267 | goto ipc_error; | ||
268 | |||
269 | msleep(WAIT_ADC_COMPLETION); | ||
270 | |||
271 | /* Set Y BIAS */ | ||
272 | for (count = 0; count <= 3; count++) { | ||
273 | reg[count] = chan++; | ||
274 | data[count] = 0x4A; | ||
275 | } | ||
276 | reg[count] = chan++; /* Dummy */ | ||
277 | data[count] = 0; | ||
278 | |||
279 | err = intel_scu_ipc_writev(reg, data, 5); | ||
280 | if (err) | ||
281 | goto ipc_error; | ||
282 | |||
283 | msleep(WAIT_ADC_COMPLETION); | ||
284 | |||
285 | /* Set Z BIAS */ | ||
286 | err = intel_scu_ipc_iowrite32(chan + 2, 0x8A8A8A8A); | ||
287 | if (err) | ||
288 | goto ipc_error; | ||
289 | |||
290 | msleep(WAIT_ADC_COMPLETION); | ||
291 | |||
292 | return 0; | ||
293 | |||
294 | ipc_error: | ||
295 | dev_err(tsdev->dev, "ipc error during %s\n", __func__); | ||
296 | return err; | ||
297 | } | ||
298 | |||
299 | static int mrstouch_fs_adc_read(struct mrstouch_dev *tsdev, | ||
300 | u16 *x, u16 *y, u16 *z) | ||
301 | { | ||
302 | int err; | ||
303 | u16 result; | ||
304 | u16 reg[4]; | ||
305 | u8 data[4]; | ||
306 | |||
307 | result = PMIC_REG_ADCSNS0H + tsdev->asr; | ||
308 | |||
309 | reg[0] = result + 4; | ||
310 | reg[1] = result + 5; | ||
311 | reg[2] = result + 16; | ||
312 | reg[3] = result + 17; | ||
313 | |||
314 | err = intel_scu_ipc_readv(reg, data, 4); | ||
315 | if (err) | ||
316 | goto ipc_error; | ||
317 | |||
318 | *x = data[0] << 3; /* Higher 7 bits */ | ||
319 | *x |= data[1] & 0x7; /* Lower 3 bits */ | ||
320 | *x &= 0x3FF; | ||
321 | |||
322 | *y = data[2] << 3; /* Higher 7 bits */ | ||
323 | *y |= data[3] & 0x7; /* Lower 3 bits */ | ||
324 | *y &= 0x3FF; | ||
325 | |||
326 | /* Read Z value */ | ||
327 | reg[0] = result + 28; | ||
328 | reg[1] = result + 29; | ||
329 | |||
330 | err = intel_scu_ipc_readv(reg, data, 4); | ||
331 | if (err) | ||
332 | goto ipc_error; | ||
333 | |||
334 | *z = data[0] << 3; /* Higher 7 bits */ | ||
335 | *z |= data[1] & 0x7; /* Lower 3 bits */ | ||
336 | *z &= 0x3FF; | ||
337 | |||
338 | return 0; | ||
339 | |||
340 | ipc_error: | ||
341 | dev_err(tsdev->dev, "ipc error during %s\n", __func__); | ||
342 | return err; | ||
343 | } | ||
344 | |||
345 | static int mrstouch_fs_adc_read_finish(struct mrstouch_dev *tsdev) | ||
346 | { | ||
347 | int err, count; | ||
348 | u16 chan; | ||
349 | u16 reg[5]; | ||
350 | u8 data[5]; | ||
351 | |||
352 | /* Clear all TS channels */ | ||
353 | chan = PMICADDR0 + tsdev->asr; | ||
354 | for (count = 0; count <= 4; count++) { | ||
355 | reg[count] = chan++; | ||
356 | data[count] = 0; | ||
357 | } | ||
358 | err = intel_scu_ipc_writev(reg, data, 5); | ||
359 | if (err) | ||
360 | goto ipc_error; | ||
361 | |||
362 | for (count = 0; count <= 4; count++) { | ||
363 | reg[count] = chan++; | ||
364 | data[count] = 0; | ||
365 | } | ||
366 | err = intel_scu_ipc_writev(reg, data, 5); | ||
367 | if (err) | ||
368 | goto ipc_error; | ||
369 | |||
370 | err = intel_scu_ipc_iowrite32(chan + 2, 0x00000000); | ||
371 | if (err) | ||
372 | goto ipc_error; | ||
373 | |||
374 | /* Start ADC */ | ||
375 | err = intel_scu_ipc_update_register(PMIC_REG_MADCINT, 0x02, 0x02); | ||
376 | if (err) | ||
377 | goto ipc_error; | ||
378 | |||
379 | return 0; | ||
380 | |||
381 | ipc_error: | ||
382 | dev_err(tsdev->dev, "ipc error during %s\n", __func__); | ||
383 | return err; | ||
384 | } | ||
385 | |||
386 | static void mrstouch_report_event(struct input_dev *input, | ||
387 | unsigned int x, unsigned int y, unsigned int z) | ||
388 | { | ||
389 | if (z > MRST_PRESSURE_NOMINAL) { | ||
390 | /* Pen touched, report button touch and coordinates */ | ||
391 | input_report_key(input, BTN_TOUCH, 1); | ||
392 | input_report_abs(input, ABS_X, x); | ||
393 | input_report_abs(input, ABS_Y, y); | ||
394 | } else { | ||
395 | input_report_key(input, BTN_TOUCH, 0); | ||
396 | } | ||
397 | |||
398 | input_report_abs(input, ABS_PRESSURE, z); | ||
399 | input_sync(input); | ||
400 | } | ||
401 | |||
402 | /* PENDET interrupt handler */ | ||
403 | static irqreturn_t mrstouch_pendet_irq(int irq, void *dev_id) | ||
404 | { | ||
405 | struct mrstouch_dev *tsdev = dev_id; | ||
406 | u16 x, y, z; | ||
407 | |||
408 | /* | ||
409 | * Should we lower thread priority? Probably not, since we are | ||
410 | * not spinning but sleeping... | ||
411 | */ | ||
412 | |||
413 | if (tsdev->read_prepare(tsdev)) | ||
414 | goto out; | ||
415 | |||
416 | do { | ||
417 | if (tsdev->read(tsdev, &x, &y, &z)) | ||
418 | break; | ||
419 | |||
420 | mrstouch_report_event(tsdev->input, x, y, z); | ||
421 | } while (z > MRST_PRESSURE_NOMINAL); | ||
422 | |||
423 | tsdev->read_finish(tsdev); | ||
424 | |||
425 | out: | ||
426 | return IRQ_HANDLED; | ||
427 | } | ||
428 | |||
429 | /* Utility to read PMIC ID */ | ||
430 | static int mrstouch_read_pmic_id(uint *vendor, uint *rev) | ||
431 | { | ||
432 | int err; | ||
433 | u8 r; | ||
434 | |||
435 | err = intel_scu_ipc_ioread8(PMIC_REG_ID1, &r); | ||
436 | if (err) | ||
437 | return err; | ||
438 | |||
439 | *vendor = r & 0x7; | ||
440 | *rev = (r >> 3) & 0x7; | ||
441 | |||
442 | return 0; | ||
443 | } | ||
444 | |||
445 | /* | ||
446 | * Parse ADC channels to find end of the channel configured by other ADC user | ||
447 | * NEC and MAXIM requires 4 channels and FreeScale needs 18 channels | ||
448 | */ | ||
449 | static int mrstouch_chan_parse(struct mrstouch_dev *tsdev) | ||
450 | { | ||
451 | int found = 0; | ||
452 | int err, i; | ||
453 | u8 r8; | ||
454 | |||
455 | for (i = 0; i < MRSTOUCH_MAX_CHANNELS; i++) { | ||
456 | err = intel_scu_ipc_ioread8(PMICADDR0 + i, &r8); | ||
457 | if (err) | ||
458 | return err; | ||
459 | |||
460 | if (r8 == END_OF_CHANNEL) { | ||
461 | found = i; | ||
462 | break; | ||
463 | } | ||
464 | } | ||
465 | |||
466 | if (tsdev->vendor == PMIC_VENDOR_FS) { | ||
467 | if (found > MRSTOUCH_MAX_CHANNELS - 18) | ||
468 | return -ENOSPC; | ||
469 | } else { | ||
470 | if (found > MRSTOUCH_MAX_CHANNELS - 4) | ||
471 | return -ENOSPC; | ||
472 | } | ||
473 | |||
474 | return found; | ||
475 | } | ||
476 | |||
477 | |||
478 | /* | ||
479 | * Writes touch screen channels to ADC address selection registers | ||
480 | */ | ||
481 | static int mrstouch_ts_chan_set(uint offset) | ||
482 | { | ||
483 | u16 chan; | ||
484 | |||
485 | int ret, count; | ||
486 | |||
487 | chan = PMICADDR0 + offset; | ||
488 | for (count = 0; count <= 3; count++) { | ||
489 | ret = intel_scu_ipc_iowrite8(chan++, MRST_TS_CHAN10 + count); | ||
490 | if (ret) | ||
491 | return ret; | ||
492 | } | ||
493 | return intel_scu_ipc_iowrite8(chan++, END_OF_CHANNEL); | ||
494 | } | ||
495 | |||
496 | /* Initialize ADC */ | ||
497 | static int mrstouch_adc_init(struct mrstouch_dev *tsdev) | ||
498 | { | ||
499 | int err, start; | ||
500 | u8 ra, rm; | ||
501 | |||
502 | err = mrstouch_read_pmic_id(&tsdev->vendor, &tsdev->rev); | ||
503 | if (err) { | ||
504 | dev_err(tsdev->dev, "Unable to read PMIC id\n"); | ||
505 | return err; | ||
506 | } | ||
507 | |||
508 | switch (tsdev->vendor) { | ||
509 | case PMIC_VENDOR_NEC: | ||
510 | case PMIC_VENDOR_MAXIM: | ||
511 | tsdev->read_prepare = mrstouch_nec_adc_read_prepare; | ||
512 | tsdev->read = mrstouch_nec_adc_read; | ||
513 | tsdev->read_finish = mrstouch_nec_adc_read_finish; | ||
514 | break; | ||
515 | |||
516 | case PMIC_VENDOR_FS: | ||
517 | tsdev->read_prepare = mrstouch_fs_adc_read_prepare; | ||
518 | tsdev->read = mrstouch_fs_adc_read; | ||
519 | tsdev->read_finish = mrstouch_fs_adc_read_finish; | ||
520 | break; | ||
521 | |||
522 | default: | ||
523 | dev_err(tsdev->dev, | ||
524 | "Unsupported touchscreen: %d\n", tsdev->vendor); | ||
525 | return -ENXIO; | ||
526 | } | ||
527 | |||
528 | start = mrstouch_chan_parse(tsdev); | ||
529 | if (start < 0) { | ||
530 | dev_err(tsdev->dev, "Unable to parse channels\n"); | ||
531 | return start; | ||
532 | } | ||
533 | |||
534 | tsdev->asr = start; | ||
535 | |||
536 | /* | ||
537 | * ADC power on, start, enable PENDET and set loop delay | ||
538 | * ADC loop delay is set to 4.5 ms approximately | ||
539 | * Loop delay more than this results in jitter in adc readings | ||
540 | * Setting loop delay to 0 (continuous loop) in MAXIM stops PENDET | ||
541 | * interrupt generation sometimes. | ||
542 | */ | ||
543 | |||
544 | if (tsdev->vendor == PMIC_VENDOR_FS) { | ||
545 | ra = 0xE0 | ADC_LOOP_DELAY0; | ||
546 | rm = 0x5; | ||
547 | } else { | ||
548 | /* NEC and MAXIm not consistent with loop delay 0 */ | ||
549 | ra = 0xE0 | ADC_LOOP_DELAY1; | ||
550 | rm = 0x0; | ||
551 | |||
552 | /* configure touch screen channels */ | ||
553 | err = mrstouch_ts_chan_set(tsdev->asr); | ||
554 | if (err) | ||
555 | return err; | ||
556 | } | ||
557 | |||
558 | err = intel_scu_ipc_update_register(PMIC_REG_ADCCNTL1, ra, 0xE7); | ||
559 | if (err) | ||
560 | return err; | ||
561 | |||
562 | err = intel_scu_ipc_update_register(PMIC_REG_MADCINT, rm, 0x03); | ||
563 | if (err) | ||
564 | return err; | ||
565 | |||
566 | return 0; | ||
567 | } | ||
568 | |||
569 | |||
570 | /* Probe function for touch screen driver */ | ||
571 | static int mrstouch_probe(struct platform_device *pdev) | ||
572 | { | ||
573 | struct mrstouch_dev *tsdev; | ||
574 | struct input_dev *input; | ||
575 | int err; | ||
576 | int irq; | ||
577 | |||
578 | irq = platform_get_irq(pdev, 0); | ||
579 | if (irq < 0) { | ||
580 | dev_err(&pdev->dev, "no interrupt assigned\n"); | ||
581 | return -EINVAL; | ||
582 | } | ||
583 | |||
584 | tsdev = devm_kzalloc(&pdev->dev, sizeof(struct mrstouch_dev), | ||
585 | GFP_KERNEL); | ||
586 | if (!tsdev) { | ||
587 | dev_err(&pdev->dev, "unable to allocate memory\n"); | ||
588 | return -ENOMEM; | ||
589 | } | ||
590 | |||
591 | input = devm_input_allocate_device(&pdev->dev); | ||
592 | if (!input) { | ||
593 | dev_err(&pdev->dev, "unable to allocate input device\n"); | ||
594 | return -ENOMEM; | ||
595 | } | ||
596 | |||
597 | tsdev->dev = &pdev->dev; | ||
598 | tsdev->input = input; | ||
599 | tsdev->irq = irq; | ||
600 | |||
601 | snprintf(tsdev->phys, sizeof(tsdev->phys), | ||
602 | "%s/input0", dev_name(tsdev->dev)); | ||
603 | |||
604 | err = mrstouch_adc_init(tsdev); | ||
605 | if (err) { | ||
606 | dev_err(&pdev->dev, "ADC initialization failed\n"); | ||
607 | return err; | ||
608 | } | ||
609 | |||
610 | input->name = "mrst_touchscreen"; | ||
611 | input->phys = tsdev->phys; | ||
612 | input->dev.parent = tsdev->dev; | ||
613 | |||
614 | input->id.vendor = tsdev->vendor; | ||
615 | input->id.version = tsdev->rev; | ||
616 | |||
617 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | ||
618 | input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); | ||
619 | |||
620 | input_set_abs_params(tsdev->input, ABS_X, | ||
621 | MRST_X_MIN, MRST_X_MAX, MRST_X_FUZZ, 0); | ||
622 | input_set_abs_params(tsdev->input, ABS_Y, | ||
623 | MRST_Y_MIN, MRST_Y_MAX, MRST_Y_FUZZ, 0); | ||
624 | input_set_abs_params(tsdev->input, ABS_PRESSURE, | ||
625 | MRST_PRESSURE_MIN, MRST_PRESSURE_MAX, 0, 0); | ||
626 | |||
627 | err = devm_request_threaded_irq(&pdev->dev, tsdev->irq, NULL, | ||
628 | mrstouch_pendet_irq, IRQF_ONESHOT, | ||
629 | "mrstouch", tsdev); | ||
630 | if (err) { | ||
631 | dev_err(tsdev->dev, "unable to allocate irq\n"); | ||
632 | return err; | ||
633 | } | ||
634 | |||
635 | err = input_register_device(tsdev->input); | ||
636 | if (err) { | ||
637 | dev_err(tsdev->dev, "unable to register input device\n"); | ||
638 | return err; | ||
639 | } | ||
640 | |||
641 | return 0; | ||
642 | } | ||
643 | |||
644 | static struct platform_driver mrstouch_driver = { | ||
645 | .driver = { | ||
646 | .name = "pmic_touch", | ||
647 | }, | ||
648 | .probe = mrstouch_probe, | ||
649 | }; | ||
650 | module_platform_driver(mrstouch_driver); | ||
651 | |||
652 | MODULE_AUTHOR("Sreedhara Murthy. D.S, sreedhara.ds@intel.com"); | ||
653 | MODULE_DESCRIPTION("Intel Moorestown Resistive Touch Screen Driver"); | ||
654 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/input/touchscreen/lpc32xx_ts.c b/drivers/input/touchscreen/lpc32xx_ts.c index 7fbb3b0c8571..e0baa7de4102 100644 --- a/drivers/input/touchscreen/lpc32xx_ts.c +++ b/drivers/input/touchscreen/lpc32xx_ts.c | |||
@@ -313,7 +313,6 @@ static int lpc32xx_ts_remove(struct platform_device *pdev) | |||
313 | struct lpc32xx_tsc *tsc = platform_get_drvdata(pdev); | 313 | struct lpc32xx_tsc *tsc = platform_get_drvdata(pdev); |
314 | struct resource *res; | 314 | struct resource *res; |
315 | 315 | ||
316 | device_init_wakeup(&pdev->dev, 0); | ||
317 | free_irq(tsc->irq, tsc); | 316 | free_irq(tsc->irq, tsc); |
318 | 317 | ||
319 | input_unregister_device(tsc->dev); | 318 | input_unregister_device(tsc->dev); |
diff --git a/drivers/input/touchscreen/max11801_ts.c b/drivers/input/touchscreen/max11801_ts.c index 82079cde849c..a595ae5284e3 100644 --- a/drivers/input/touchscreen/max11801_ts.c +++ b/drivers/input/touchscreen/max11801_ts.c | |||
@@ -199,7 +199,6 @@ static int max11801_ts_probe(struct i2c_client *client, | |||
199 | __set_bit(BTN_TOUCH, input_dev->keybit); | 199 | __set_bit(BTN_TOUCH, input_dev->keybit); |
200 | input_set_abs_params(input_dev, ABS_X, 0, MAX11801_MAX_X, 0, 0); | 200 | input_set_abs_params(input_dev, ABS_X, 0, MAX11801_MAX_X, 0, 0); |
201 | input_set_abs_params(input_dev, ABS_Y, 0, MAX11801_MAX_Y, 0, 0); | 201 | input_set_abs_params(input_dev, ABS_Y, 0, MAX11801_MAX_Y, 0, 0); |
202 | input_set_drvdata(input_dev, data); | ||
203 | 202 | ||
204 | max11801_ts_phy_init(data); | 203 | max11801_ts_phy_init(data); |
205 | 204 | ||
@@ -216,7 +215,6 @@ static int max11801_ts_probe(struct i2c_client *client, | |||
216 | if (error) | 215 | if (error) |
217 | return error; | 216 | return error; |
218 | 217 | ||
219 | i2c_set_clientdata(client, data); | ||
220 | return 0; | 218 | return 0; |
221 | } | 219 | } |
222 | 220 | ||
diff --git a/drivers/input/touchscreen/mcs5000_ts.c b/drivers/input/touchscreen/mcs5000_ts.c index 8b47e1fecb25..90fc07dc98a6 100644 --- a/drivers/input/touchscreen/mcs5000_ts.c +++ b/drivers/input/touchscreen/mcs5000_ts.c | |||
@@ -221,7 +221,6 @@ static int mcs5000_ts_probe(struct i2c_client *client, | |||
221 | input_set_abs_params(input_dev, ABS_X, 0, MCS5000_MAX_XC, 0, 0); | 221 | input_set_abs_params(input_dev, ABS_X, 0, MCS5000_MAX_XC, 0, 0); |
222 | input_set_abs_params(input_dev, ABS_Y, 0, MCS5000_MAX_YC, 0, 0); | 222 | input_set_abs_params(input_dev, ABS_Y, 0, MCS5000_MAX_YC, 0, 0); |
223 | 223 | ||
224 | input_set_drvdata(input_dev, data); | ||
225 | data->input_dev = input_dev; | 224 | data->input_dev = input_dev; |
226 | 225 | ||
227 | if (pdata->cfg_pin) | 226 | if (pdata->cfg_pin) |
diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c index 3bb0637d832e..37ff672c7802 100644 --- a/drivers/input/touchscreen/pixcir_i2c_ts.c +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c | |||
@@ -461,7 +461,7 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client, | |||
461 | if (error) | 461 | if (error) |
462 | return error; | 462 | return error; |
463 | } else { | 463 | } else { |
464 | dev_err(&client->dev, "platform data not defined\n"); | 464 | dev_err(dev, "platform data not defined\n"); |
465 | return -EINVAL; | 465 | return -EINVAL; |
466 | } | 466 | } |
467 | 467 | ||
@@ -483,7 +483,7 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client, | |||
483 | input->id.bustype = BUS_I2C; | 483 | input->id.bustype = BUS_I2C; |
484 | input->open = pixcir_input_open; | 484 | input->open = pixcir_input_open; |
485 | input->close = pixcir_input_close; | 485 | input->close = pixcir_input_close; |
486 | input->dev.parent = &client->dev; | 486 | input->dev.parent = dev; |
487 | 487 | ||
488 | if (pdata) { | 488 | if (pdata) { |
489 | input_set_abs_params(input, ABS_MT_POSITION_X, 0, pdata->x_max, 0, 0); | 489 | input_set_abs_params(input, ABS_MT_POSITION_X, 0, pdata->x_max, 0, 0); |
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c index 2658afa016c9..1252e49ccfa1 100644 --- a/drivers/input/touchscreen/raydium_i2c_ts.c +++ b/drivers/input/touchscreen/raydium_i2c_ts.c | |||
@@ -1087,8 +1087,6 @@ static int raydium_i2c_probe(struct i2c_client *client, | |||
1087 | ts->input->name = "Raydium Touchscreen"; | 1087 | ts->input->name = "Raydium Touchscreen"; |
1088 | ts->input->id.bustype = BUS_I2C; | 1088 | ts->input->id.bustype = BUS_I2C; |
1089 | 1089 | ||
1090 | input_set_drvdata(ts->input, ts); | ||
1091 | |||
1092 | input_set_abs_params(ts->input, ABS_MT_POSITION_X, | 1090 | input_set_abs_params(ts->input, ABS_MT_POSITION_X, |
1093 | 0, le16_to_cpu(ts->info.x_max), 0, 0); | 1091 | 0, le16_to_cpu(ts->info.x_max), 0, 0); |
1094 | input_set_abs_params(ts->input, ABS_MT_POSITION_Y, | 1092 | input_set_abs_params(ts->input, ABS_MT_POSITION_Y, |
diff --git a/drivers/input/touchscreen/rohm_bu21023.c b/drivers/input/touchscreen/rohm_bu21023.c index 611156a2ef80..eeaf6ff03597 100644 --- a/drivers/input/touchscreen/rohm_bu21023.c +++ b/drivers/input/touchscreen/rohm_bu21023.c | |||
@@ -1189,8 +1189,7 @@ static int rohm_bu21023_i2c_probe(struct i2c_client *client, | |||
1189 | error = devm_add_action(dev, rohm_ts_remove_sysfs_group, dev); | 1189 | error = devm_add_action(dev, rohm_ts_remove_sysfs_group, dev); |
1190 | if (error) { | 1190 | if (error) { |
1191 | rohm_ts_remove_sysfs_group(dev); | 1191 | rohm_ts_remove_sysfs_group(dev); |
1192 | dev_err(&client->dev, | 1192 | dev_err(dev, "Failed to add sysfs cleanup action: %d\n", |
1193 | "Failed to add sysfs cleanup action: %d\n", | ||
1194 | error); | 1193 | error); |
1195 | return error; | 1194 | return error; |
1196 | } | 1195 | } |
diff --git a/drivers/input/touchscreen/s3c2410_ts.c b/drivers/input/touchscreen/s3c2410_ts.c index a4a103e1d11b..41d58e88cc8a 100644 --- a/drivers/input/touchscreen/s3c2410_ts.c +++ b/drivers/input/touchscreen/s3c2410_ts.c | |||
@@ -250,7 +250,7 @@ static int s3c2410ts_probe(struct platform_device *pdev) | |||
250 | 250 | ||
251 | ts.dev = dev; | 251 | ts.dev = dev; |
252 | 252 | ||
253 | info = dev_get_platdata(&pdev->dev); | 253 | info = dev_get_platdata(dev); |
254 | if (!info) { | 254 | if (!info) { |
255 | dev_err(dev, "no platform data, cannot attach\n"); | 255 | dev_err(dev, "no platform data, cannot attach\n"); |
256 | return -EINVAL; | 256 | return -EINVAL; |
diff --git a/drivers/input/touchscreen/sis_i2c.c b/drivers/input/touchscreen/sis_i2c.c index 8d93f8c9a403..67c2563031d6 100644 --- a/drivers/input/touchscreen/sis_i2c.c +++ b/drivers/input/touchscreen/sis_i2c.c | |||
@@ -316,7 +316,6 @@ static int sis_ts_probe(struct i2c_client *client, | |||
316 | return -ENOMEM; | 316 | return -ENOMEM; |
317 | 317 | ||
318 | ts->client = client; | 318 | ts->client = client; |
319 | i2c_set_clientdata(client, ts); | ||
320 | 319 | ||
321 | ts->attn_gpio = devm_gpiod_get_optional(&client->dev, | 320 | ts->attn_gpio = devm_gpiod_get_optional(&client->dev, |
322 | "attn", GPIOD_IN); | 321 | "attn", GPIOD_IN); |
diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c index e943678ce54c..be5615c6bf8f 100644 --- a/drivers/input/touchscreen/st1232.c +++ b/drivers/input/touchscreen/st1232.c | |||
@@ -237,7 +237,6 @@ static int st1232_ts_remove(struct i2c_client *client) | |||
237 | { | 237 | { |
238 | struct st1232_ts_data *ts = i2c_get_clientdata(client); | 238 | struct st1232_ts_data *ts = i2c_get_clientdata(client); |
239 | 239 | ||
240 | device_init_wakeup(&client->dev, 0); | ||
241 | st1232_ts_power(ts, false); | 240 | st1232_ts_power(ts, false); |
242 | 241 | ||
243 | return 0; | 242 | return 0; |
diff --git a/drivers/input/touchscreen/sx8654.c b/drivers/input/touchscreen/sx8654.c index 642f4a53de50..ed29db3ec731 100644 --- a/drivers/input/touchscreen/sx8654.c +++ b/drivers/input/touchscreen/sx8654.c | |||
@@ -253,7 +253,6 @@ static int sx8654_probe(struct i2c_client *client, | |||
253 | if (error) | 253 | if (error) |
254 | return error; | 254 | return error; |
255 | 255 | ||
256 | i2c_set_clientdata(client, sx8654); | ||
257 | return 0; | 256 | return 0; |
258 | } | 257 | } |
259 | 258 | ||
diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c index f2c5f0e47f77..e02b69f40ad8 100644 --- a/drivers/input/touchscreen/tsc2005.c +++ b/drivers/input/touchscreen/tsc2005.c | |||
@@ -18,8 +18,9 @@ | |||
18 | * GNU General Public License for more details. | 18 | * GNU General Public License for more details. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/module.h> | ||
22 | #include <linux/input.h> | 21 | #include <linux/input.h> |
22 | #include <linux/module.h> | ||
23 | #include <linux/of.h> | ||
23 | #include <linux/spi/spi.h> | 24 | #include <linux/spi/spi.h> |
24 | #include <linux/regmap.h> | 25 | #include <linux/regmap.h> |
25 | #include "tsc200x-core.h" | 26 | #include "tsc200x-core.h" |
@@ -77,9 +78,18 @@ static int tsc2005_remove(struct spi_device *spi) | |||
77 | return tsc200x_remove(&spi->dev); | 78 | return tsc200x_remove(&spi->dev); |
78 | } | 79 | } |
79 | 80 | ||
81 | #ifdef CONFIG_OF | ||
82 | static const struct of_device_id tsc2005_of_match[] = { | ||
83 | { .compatible = "ti,tsc2005" }, | ||
84 | { /* sentinel */ } | ||
85 | }; | ||
86 | MODULE_DEVICE_TABLE(of, tsc2005_of_match); | ||
87 | #endif | ||
88 | |||
80 | static struct spi_driver tsc2005_driver = { | 89 | static struct spi_driver tsc2005_driver = { |
81 | .driver = { | 90 | .driver = { |
82 | .name = "tsc2005", | 91 | .name = "tsc2005", |
92 | .of_match_table = of_match_ptr(tsc2005_of_match), | ||
83 | .pm = &tsc200x_pm_ops, | 93 | .pm = &tsc200x_pm_ops, |
84 | }, | 94 | }, |
85 | .probe = tsc2005_probe, | 95 | .probe = tsc2005_probe, |
diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c index b7059ed8872e..88ea5e1b72ae 100644 --- a/drivers/input/touchscreen/tsc200x-core.c +++ b/drivers/input/touchscreen/tsc200x-core.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
28 | #include <linux/pm.h> | 28 | #include <linux/pm.h> |
29 | #include <linux/of.h> | 29 | #include <linux/of.h> |
30 | #include <linux/spi/tsc2005.h> | ||
31 | #include <linux/regulator/consumer.h> | 30 | #include <linux/regulator/consumer.h> |
32 | #include <linux/regmap.h> | 31 | #include <linux/regmap.h> |
33 | #include <linux/gpio/consumer.h> | 32 | #include <linux/gpio/consumer.h> |
@@ -114,7 +113,6 @@ struct tsc200x { | |||
114 | struct regulator *vio; | 113 | struct regulator *vio; |
115 | 114 | ||
116 | struct gpio_desc *reset_gpio; | 115 | struct gpio_desc *reset_gpio; |
117 | void (*set_reset)(bool enable); | ||
118 | int (*tsc200x_cmd)(struct device *dev, u8 cmd); | 116 | int (*tsc200x_cmd)(struct device *dev, u8 cmd); |
119 | int irq; | 117 | int irq; |
120 | }; | 118 | }; |
@@ -227,12 +225,13 @@ static void tsc200x_stop_scan(struct tsc200x *ts) | |||
227 | ts->tsc200x_cmd(ts->dev, TSC200X_CMD_STOP); | 225 | ts->tsc200x_cmd(ts->dev, TSC200X_CMD_STOP); |
228 | } | 226 | } |
229 | 227 | ||
230 | static void tsc200x_set_reset(struct tsc200x *ts, bool enable) | 228 | static void tsc200x_reset(struct tsc200x *ts) |
231 | { | 229 | { |
232 | if (ts->reset_gpio) | 230 | if (ts->reset_gpio) { |
233 | gpiod_set_value_cansleep(ts->reset_gpio, enable); | 231 | gpiod_set_value_cansleep(ts->reset_gpio, 1); |
234 | else if (ts->set_reset) | 232 | usleep_range(100, 500); /* only 10us required */ |
235 | ts->set_reset(enable); | 233 | gpiod_set_value_cansleep(ts->reset_gpio, 0); |
234 | } | ||
236 | } | 235 | } |
237 | 236 | ||
238 | /* must be called with ts->mutex held */ | 237 | /* must be called with ts->mutex held */ |
@@ -253,7 +252,7 @@ static void __tsc200x_enable(struct tsc200x *ts) | |||
253 | { | 252 | { |
254 | tsc200x_start_scan(ts); | 253 | tsc200x_start_scan(ts); |
255 | 254 | ||
256 | if (ts->esd_timeout && (ts->set_reset || ts->reset_gpio)) { | 255 | if (ts->esd_timeout && ts->reset_gpio) { |
257 | ts->last_valid_interrupt = jiffies; | 256 | ts->last_valid_interrupt = jiffies; |
258 | schedule_delayed_work(&ts->esd_work, | 257 | schedule_delayed_work(&ts->esd_work, |
259 | round_jiffies_relative( | 258 | round_jiffies_relative( |
@@ -310,9 +309,7 @@ static ssize_t tsc200x_selftest_show(struct device *dev, | |||
310 | } | 309 | } |
311 | 310 | ||
312 | /* hardware reset */ | 311 | /* hardware reset */ |
313 | tsc200x_set_reset(ts, false); | 312 | tsc200x_reset(ts); |
314 | usleep_range(100, 500); /* only 10us required */ | ||
315 | tsc200x_set_reset(ts, true); | ||
316 | 313 | ||
317 | if (!success) | 314 | if (!success) |
318 | goto out; | 315 | goto out; |
@@ -354,7 +351,7 @@ static umode_t tsc200x_attr_is_visible(struct kobject *kobj, | |||
354 | umode_t mode = attr->mode; | 351 | umode_t mode = attr->mode; |
355 | 352 | ||
356 | if (attr == &dev_attr_selftest.attr) { | 353 | if (attr == &dev_attr_selftest.attr) { |
357 | if (!ts->set_reset && !ts->reset_gpio) | 354 | if (!ts->reset_gpio) |
358 | mode = 0; | 355 | mode = 0; |
359 | } | 356 | } |
360 | 357 | ||
@@ -404,9 +401,7 @@ static void tsc200x_esd_work(struct work_struct *work) | |||
404 | 401 | ||
405 | tsc200x_update_pen_state(ts, 0, 0, 0); | 402 | tsc200x_update_pen_state(ts, 0, 0, 0); |
406 | 403 | ||
407 | tsc200x_set_reset(ts, false); | 404 | tsc200x_reset(ts); |
408 | usleep_range(100, 500); /* only 10us required */ | ||
409 | tsc200x_set_reset(ts, true); | ||
410 | 405 | ||
411 | enable_irq(ts->irq); | 406 | enable_irq(ts->irq); |
412 | tsc200x_start_scan(ts); | 407 | tsc200x_start_scan(ts); |
@@ -454,26 +449,12 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, | |||
454 | struct regmap *regmap, | 449 | struct regmap *regmap, |
455 | int (*tsc200x_cmd)(struct device *dev, u8 cmd)) | 450 | int (*tsc200x_cmd)(struct device *dev, u8 cmd)) |
456 | { | 451 | { |
457 | const struct tsc2005_platform_data *pdata = dev_get_platdata(dev); | ||
458 | struct device_node *np = dev->of_node; | ||
459 | |||
460 | struct tsc200x *ts; | 452 | struct tsc200x *ts; |
461 | struct input_dev *input_dev; | 453 | struct input_dev *input_dev; |
462 | unsigned int max_x = MAX_12BIT; | 454 | u32 x_plate_ohm; |
463 | unsigned int max_y = MAX_12BIT; | 455 | u32 esd_timeout; |
464 | unsigned int max_p = MAX_12BIT; | ||
465 | unsigned int fudge_x = TSC200X_DEF_X_FUZZ; | ||
466 | unsigned int fudge_y = TSC200X_DEF_Y_FUZZ; | ||
467 | unsigned int fudge_p = TSC200X_DEF_P_FUZZ; | ||
468 | unsigned int x_plate_ohm = TSC200X_DEF_RESISTOR; | ||
469 | unsigned int esd_timeout; | ||
470 | int error; | 456 | int error; |
471 | 457 | ||
472 | if (!np && !pdata) { | ||
473 | dev_err(dev, "no platform data\n"); | ||
474 | return -ENODEV; | ||
475 | } | ||
476 | |||
477 | if (irq <= 0) { | 458 | if (irq <= 0) { |
478 | dev_err(dev, "no irq\n"); | 459 | dev_err(dev, "no irq\n"); |
479 | return -ENODEV; | 460 | return -ENODEV; |
@@ -487,23 +468,6 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, | |||
487 | return -ENODEV; | 468 | return -ENODEV; |
488 | } | 469 | } |
489 | 470 | ||
490 | if (pdata) { | ||
491 | fudge_x = pdata->ts_x_fudge; | ||
492 | fudge_y = pdata->ts_y_fudge; | ||
493 | fudge_p = pdata->ts_pressure_fudge; | ||
494 | max_x = pdata->ts_x_max; | ||
495 | max_y = pdata->ts_y_max; | ||
496 | max_p = pdata->ts_pressure_max; | ||
497 | x_plate_ohm = pdata->ts_x_plate_ohm; | ||
498 | esd_timeout = pdata->esd_timeout_ms; | ||
499 | } else { | ||
500 | x_plate_ohm = TSC200X_DEF_RESISTOR; | ||
501 | of_property_read_u32(np, "ti,x-plate-ohms", &x_plate_ohm); | ||
502 | esd_timeout = 0; | ||
503 | of_property_read_u32(np, "ti,esd-recovery-timeout-ms", | ||
504 | &esd_timeout); | ||
505 | } | ||
506 | |||
507 | ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL); | 471 | ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL); |
508 | if (!ts) | 472 | if (!ts) |
509 | return -ENOMEM; | 473 | return -ENOMEM; |
@@ -517,8 +481,13 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, | |||
517 | ts->idev = input_dev; | 481 | ts->idev = input_dev; |
518 | ts->regmap = regmap; | 482 | ts->regmap = regmap; |
519 | ts->tsc200x_cmd = tsc200x_cmd; | 483 | ts->tsc200x_cmd = tsc200x_cmd; |
520 | ts->x_plate_ohm = x_plate_ohm; | 484 | |
521 | ts->esd_timeout = esd_timeout; | 485 | error = device_property_read_u32(dev, "ti,x-plate-ohms", &x_plate_ohm); |
486 | ts->x_plate_ohm = error ? TSC200X_DEF_RESISTOR : x_plate_ohm; | ||
487 | |||
488 | error = device_property_read_u32(dev, "ti,esd-recovery-timeout-ms", | ||
489 | &esd_timeout); | ||
490 | ts->esd_timeout = error ? 0 : esd_timeout; | ||
522 | 491 | ||
523 | ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); | 492 | ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); |
524 | if (IS_ERR(ts->reset_gpio)) { | 493 | if (IS_ERR(ts->reset_gpio)) { |
@@ -527,16 +496,13 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, | |||
527 | return error; | 496 | return error; |
528 | } | 497 | } |
529 | 498 | ||
530 | ts->vio = devm_regulator_get_optional(dev, "vio"); | 499 | ts->vio = devm_regulator_get(dev, "vio"); |
531 | if (IS_ERR(ts->vio)) { | 500 | if (IS_ERR(ts->vio)) { |
532 | error = PTR_ERR(ts->vio); | 501 | error = PTR_ERR(ts->vio); |
533 | dev_err(dev, "vio regulator missing (%d)", error); | 502 | dev_err(dev, "error acquiring vio regulator: %d", error); |
534 | return error; | 503 | return error; |
535 | } | 504 | } |
536 | 505 | ||
537 | if (!ts->reset_gpio && pdata) | ||
538 | ts->set_reset = pdata->set_reset; | ||
539 | |||
540 | mutex_init(&ts->mutex); | 506 | mutex_init(&ts->mutex); |
541 | 507 | ||
542 | spin_lock_init(&ts->lock); | 508 | spin_lock_init(&ts->lock); |
@@ -559,22 +525,23 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, | |||
559 | 525 | ||
560 | input_dev->phys = ts->phys; | 526 | input_dev->phys = ts->phys; |
561 | input_dev->id = *tsc_id; | 527 | input_dev->id = *tsc_id; |
562 | input_dev->dev.parent = dev; | ||
563 | input_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY); | ||
564 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); | ||
565 | |||
566 | input_set_abs_params(input_dev, ABS_X, 0, max_x, fudge_x, 0); | ||
567 | input_set_abs_params(input_dev, ABS_Y, 0, max_y, fudge_y, 0); | ||
568 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, max_p, fudge_p, 0); | ||
569 | |||
570 | if (np) | ||
571 | touchscreen_parse_properties(input_dev, false, NULL); | ||
572 | 528 | ||
573 | input_dev->open = tsc200x_open; | 529 | input_dev->open = tsc200x_open; |
574 | input_dev->close = tsc200x_close; | 530 | input_dev->close = tsc200x_close; |
575 | 531 | ||
576 | input_set_drvdata(input_dev, ts); | 532 | input_set_drvdata(input_dev, ts); |
577 | 533 | ||
534 | input_set_capability(input_dev, EV_KEY, BTN_TOUCH); | ||
535 | |||
536 | input_set_abs_params(input_dev, ABS_X, | ||
537 | 0, MAX_12BIT, TSC200X_DEF_X_FUZZ, 0); | ||
538 | input_set_abs_params(input_dev, ABS_Y, | ||
539 | 0, MAX_12BIT, TSC200X_DEF_Y_FUZZ, 0); | ||
540 | input_set_abs_params(input_dev, ABS_PRESSURE, | ||
541 | 0, MAX_12BIT, TSC200X_DEF_P_FUZZ, 0); | ||
542 | |||
543 | touchscreen_parse_properties(input_dev, false, NULL); | ||
544 | |||
578 | /* Ensure the touchscreen is off */ | 545 | /* Ensure the touchscreen is off */ |
579 | tsc200x_stop_scan(ts); | 546 | tsc200x_stop_scan(ts); |
580 | 547 | ||
@@ -587,12 +554,9 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, | |||
587 | return error; | 554 | return error; |
588 | } | 555 | } |
589 | 556 | ||
590 | /* enable regulator for DT */ | 557 | error = regulator_enable(ts->vio); |
591 | if (ts->vio) { | 558 | if (error) |
592 | error = regulator_enable(ts->vio); | 559 | return error; |
593 | if (error) | ||
594 | return error; | ||
595 | } | ||
596 | 560 | ||
597 | dev_set_drvdata(dev, ts); | 561 | dev_set_drvdata(dev, ts); |
598 | error = sysfs_create_group(&dev->kobj, &tsc200x_attr_group); | 562 | error = sysfs_create_group(&dev->kobj, &tsc200x_attr_group); |
@@ -615,8 +579,7 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, | |||
615 | err_remove_sysfs: | 579 | err_remove_sysfs: |
616 | sysfs_remove_group(&dev->kobj, &tsc200x_attr_group); | 580 | sysfs_remove_group(&dev->kobj, &tsc200x_attr_group); |
617 | disable_regulator: | 581 | disable_regulator: |
618 | if (ts->vio) | 582 | regulator_disable(ts->vio); |
619 | regulator_disable(ts->vio); | ||
620 | return error; | 583 | return error; |
621 | } | 584 | } |
622 | EXPORT_SYMBOL_GPL(tsc200x_probe); | 585 | EXPORT_SYMBOL_GPL(tsc200x_probe); |
@@ -627,8 +590,7 @@ int tsc200x_remove(struct device *dev) | |||
627 | 590 | ||
628 | sysfs_remove_group(&dev->kobj, &tsc200x_attr_group); | 591 | sysfs_remove_group(&dev->kobj, &tsc200x_attr_group); |
629 | 592 | ||
630 | if (ts->vio) | 593 | regulator_disable(ts->vio); |
631 | regulator_disable(ts->vio); | ||
632 | 594 | ||
633 | return 0; | 595 | return 0; |
634 | } | 596 | } |
diff --git a/drivers/input/touchscreen/zet6223.c b/drivers/input/touchscreen/zet6223.c new file mode 100644 index 000000000000..19ffcc7b886c --- /dev/null +++ b/drivers/input/touchscreen/zet6223.c | |||
@@ -0,0 +1,268 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016, Jelle van der Waa <jelle@vdwaa.nl> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms of the GNU General Public License as published by the Free | ||
6 | * Software Foundation; either version 2 of the License, or (at your option) | ||
7 | * any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
12 | * more details. | ||
13 | */ | ||
14 | |||
15 | #include <linux/delay.h> | ||
16 | #include <linux/i2c.h> | ||
17 | #include <linux/input.h> | ||
18 | #include <linux/input/mt.h> | ||
19 | #include <linux/input/touchscreen.h> | ||
20 | #include <linux/interrupt.h> | ||
21 | #include <linux/module.h> | ||
22 | #include <linux/regulator/consumer.h> | ||
23 | #include <asm/unaligned.h> | ||
24 | |||
25 | #define ZET6223_MAX_FINGERS 16 | ||
26 | #define ZET6223_MAX_PKT_SIZE (3 + 4 * ZET6223_MAX_FINGERS) | ||
27 | |||
28 | #define ZET6223_CMD_INFO 0xB2 | ||
29 | #define ZET6223_CMD_INFO_LENGTH 17 | ||
30 | #define ZET6223_VALID_PACKET 0x3c | ||
31 | |||
32 | #define ZET6223_POWER_ON_DELAY_MSEC 30 | ||
33 | |||
34 | struct zet6223_ts { | ||
35 | struct i2c_client *client; | ||
36 | struct input_dev *input; | ||
37 | struct regulator *vcc; | ||
38 | struct regulator *vio; | ||
39 | struct touchscreen_properties prop; | ||
40 | struct regulator_bulk_data supplies[2]; | ||
41 | u16 max_x; | ||
42 | u16 max_y; | ||
43 | u8 fingernum; | ||
44 | }; | ||
45 | |||
46 | static int zet6223_start(struct input_dev *dev) | ||
47 | { | ||
48 | struct zet6223_ts *ts = input_get_drvdata(dev); | ||
49 | |||
50 | enable_irq(ts->client->irq); | ||
51 | |||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | static void zet6223_stop(struct input_dev *dev) | ||
56 | { | ||
57 | struct zet6223_ts *ts = input_get_drvdata(dev); | ||
58 | |||
59 | disable_irq(ts->client->irq); | ||
60 | } | ||
61 | |||
62 | static irqreturn_t zet6223_irq(int irq, void *dev_id) | ||
63 | { | ||
64 | struct zet6223_ts *ts = dev_id; | ||
65 | u16 finger_bits; | ||
66 | |||
67 | /* | ||
68 | * First 3 bytes are an identifier, two bytes of finger data. | ||
69 | * X, Y data per finger is 4 bytes. | ||
70 | */ | ||
71 | u8 bufsize = 3 + 4 * ts->fingernum; | ||
72 | u8 buf[ZET6223_MAX_PKT_SIZE]; | ||
73 | int i; | ||
74 | int ret; | ||
75 | int error; | ||
76 | |||
77 | ret = i2c_master_recv(ts->client, buf, bufsize); | ||
78 | if (ret != bufsize) { | ||
79 | error = ret < 0 ? ret : -EIO; | ||
80 | dev_err_ratelimited(&ts->client->dev, | ||
81 | "Error reading input data: %d\n", error); | ||
82 | return IRQ_HANDLED; | ||
83 | } | ||
84 | |||
85 | if (buf[0] != ZET6223_VALID_PACKET) | ||
86 | return IRQ_HANDLED; | ||
87 | |||
88 | finger_bits = get_unaligned_be16(buf + 1); | ||
89 | for (i = 0; i < ts->fingernum; i++) { | ||
90 | if (!(finger_bits & BIT(15 - i))) | ||
91 | continue; | ||
92 | |||
93 | input_mt_slot(ts->input, i); | ||
94 | input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, true); | ||
95 | input_event(ts->input, EV_ABS, ABS_MT_POSITION_X, | ||
96 | ((buf[i + 3] >> 4) << 8) + buf[i + 4]); | ||
97 | input_event(ts->input, EV_ABS, ABS_MT_POSITION_Y, | ||
98 | ((buf[i + 3] & 0xF) << 8) + buf[i + 5]); | ||
99 | } | ||
100 | |||
101 | input_mt_sync_frame(ts->input); | ||
102 | input_sync(ts->input); | ||
103 | |||
104 | return IRQ_HANDLED; | ||
105 | } | ||
106 | |||
107 | static void zet6223_power_off(void *_ts) | ||
108 | { | ||
109 | struct zet6223_ts *ts = _ts; | ||
110 | |||
111 | regulator_bulk_disable(ARRAY_SIZE(ts->supplies), ts->supplies); | ||
112 | } | ||
113 | |||
114 | static int zet6223_power_on(struct zet6223_ts *ts) | ||
115 | { | ||
116 | struct device *dev = &ts->client->dev; | ||
117 | int error; | ||
118 | |||
119 | ts->supplies[0].supply = "vio"; | ||
120 | ts->supplies[1].supply = "vcc"; | ||
121 | |||
122 | error = devm_regulator_bulk_get(dev, ARRAY_SIZE(ts->supplies), | ||
123 | ts->supplies); | ||
124 | if (error) | ||
125 | return error; | ||
126 | |||
127 | error = regulator_bulk_enable(ARRAY_SIZE(ts->supplies), ts->supplies); | ||
128 | if (error) | ||
129 | return error; | ||
130 | |||
131 | msleep(ZET6223_POWER_ON_DELAY_MSEC); | ||
132 | |||
133 | error = devm_add_action_or_reset(dev, zet6223_power_off, ts); | ||
134 | if (error) { | ||
135 | dev_err(dev, "failed to install poweroff action: %d\n", error); | ||
136 | return error; | ||
137 | } | ||
138 | |||
139 | return 0; | ||
140 | } | ||
141 | |||
142 | static int zet6223_query_device(struct zet6223_ts *ts) | ||
143 | { | ||
144 | u8 buf[ZET6223_CMD_INFO_LENGTH]; | ||
145 | u8 cmd = ZET6223_CMD_INFO; | ||
146 | int ret; | ||
147 | int error; | ||
148 | |||
149 | ret = i2c_master_send(ts->client, &cmd, sizeof(cmd)); | ||
150 | if (ret != sizeof(cmd)) { | ||
151 | error = ret < 0 ? ret : -EIO; | ||
152 | dev_err(&ts->client->dev, | ||
153 | "touchpanel info cmd failed: %d\n", error); | ||
154 | return error; | ||
155 | } | ||
156 | |||
157 | ret = i2c_master_recv(ts->client, buf, sizeof(buf)); | ||
158 | if (ret != sizeof(buf)) { | ||
159 | error = ret < 0 ? ret : -EIO; | ||
160 | dev_err(&ts->client->dev, | ||
161 | "failed to retrieve touchpanel info: %d\n", error); | ||
162 | return error; | ||
163 | } | ||
164 | |||
165 | ts->fingernum = buf[15] & 0x7F; | ||
166 | if (ts->fingernum > ZET6223_MAX_FINGERS) { | ||
167 | dev_warn(&ts->client->dev, | ||
168 | "touchpanel reports %d fingers, limiting to %d\n", | ||
169 | ts->fingernum, ZET6223_MAX_FINGERS); | ||
170 | ts->fingernum = ZET6223_MAX_FINGERS; | ||
171 | } | ||
172 | |||
173 | ts->max_x = get_unaligned_le16(&buf[8]); | ||
174 | ts->max_y = get_unaligned_le16(&buf[10]); | ||
175 | |||
176 | return 0; | ||
177 | } | ||
178 | |||
179 | static int zet6223_probe(struct i2c_client *client, | ||
180 | const struct i2c_device_id *id) | ||
181 | { | ||
182 | struct device *dev = &client->dev; | ||
183 | struct zet6223_ts *ts; | ||
184 | struct input_dev *input; | ||
185 | int error; | ||
186 | |||
187 | if (!client->irq) { | ||
188 | dev_err(dev, "no irq specified\n"); | ||
189 | return -EINVAL; | ||
190 | } | ||
191 | |||
192 | ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL); | ||
193 | if (!ts) | ||
194 | return -ENOMEM; | ||
195 | |||
196 | ts->client = client; | ||
197 | |||
198 | error = zet6223_power_on(ts); | ||
199 | if (error) | ||
200 | return error; | ||
201 | |||
202 | error = zet6223_query_device(ts); | ||
203 | if (error) | ||
204 | return error; | ||
205 | |||
206 | ts->input = input = devm_input_allocate_device(dev); | ||
207 | if (!input) | ||
208 | return -ENOMEM; | ||
209 | |||
210 | input_set_drvdata(input, ts); | ||
211 | |||
212 | input->name = client->name; | ||
213 | input->id.bustype = BUS_I2C; | ||
214 | input->open = zet6223_start; | ||
215 | input->close = zet6223_stop; | ||
216 | |||
217 | input_set_abs_params(input, ABS_MT_POSITION_X, 0, ts->max_x, 0, 0); | ||
218 | input_set_abs_params(input, ABS_MT_POSITION_Y, 0, ts->max_y, 0, 0); | ||
219 | |||
220 | touchscreen_parse_properties(input, true, &ts->prop); | ||
221 | |||
222 | error = input_mt_init_slots(input, ts->fingernum, | ||
223 | INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED); | ||
224 | if (error) | ||
225 | return error; | ||
226 | |||
227 | error = devm_request_threaded_irq(dev, client->irq, NULL, zet6223_irq, | ||
228 | IRQF_ONESHOT, client->name, ts); | ||
229 | if (error) { | ||
230 | dev_err(dev, "failed to request irq %d: %d\n", | ||
231 | client->irq, error); | ||
232 | return error; | ||
233 | } | ||
234 | |||
235 | zet6223_stop(input); | ||
236 | |||
237 | error = input_register_device(input); | ||
238 | if (error) | ||
239 | return error; | ||
240 | |||
241 | return 0; | ||
242 | } | ||
243 | |||
244 | static const struct of_device_id zet6223_of_match[] = { | ||
245 | { .compatible = "zeitec,zet6223" }, | ||
246 | { } | ||
247 | }; | ||
248 | MODULE_DEVICE_TABLE(of, zet6223_of_match); | ||
249 | |||
250 | static const struct i2c_device_id zet6223_id[] = { | ||
251 | { "zet6223", 0}, | ||
252 | { } | ||
253 | }; | ||
254 | MODULE_DEVICE_TABLE(i2c, zet6223_id); | ||
255 | |||
256 | static struct i2c_driver zet6223_driver = { | ||
257 | .driver = { | ||
258 | .name = "zet6223", | ||
259 | .of_match_table = zet6223_of_match, | ||
260 | }, | ||
261 | .probe = zet6223_probe, | ||
262 | .id_table = zet6223_id | ||
263 | }; | ||
264 | module_i2c_driver(zet6223_driver); | ||
265 | |||
266 | MODULE_AUTHOR("Jelle van der Waa <jelle@vdwaa.nl>"); | ||
267 | MODULE_DESCRIPTION("ZEITEC zet622x I2C touchscreen driver"); | ||
268 | MODULE_LICENSE("GPL"); | ||
diff --git a/include/linux/i2c/mpr121_touchkey.h b/include/linux/i2c/mpr121_touchkey.h deleted file mode 100644 index f0bcc38bbb97..000000000000 --- a/include/linux/i2c/mpr121_touchkey.h +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | /* Header file for Freescale MPR121 Capacitive Touch Sensor */ | ||
2 | |||
3 | #ifndef _MPR121_TOUCHKEY_H | ||
4 | #define _MPR121_TOUCHKEY_H | ||
5 | |||
6 | /** | ||
7 | * struct mpr121_platform_data - platform data for mpr121 sensor | ||
8 | * @keymap: pointer to array of KEY_* values representing keymap | ||
9 | * @keymap_size: size of the keymap | ||
10 | * @wakeup: configure the button as a wake-up source | ||
11 | * @vdd_uv: VDD voltage in uV | ||
12 | */ | ||
13 | struct mpr121_platform_data { | ||
14 | const unsigned short *keymap; | ||
15 | unsigned int keymap_size; | ||
16 | bool wakeup; | ||
17 | int vdd_uv; | ||
18 | }; | ||
19 | |||
20 | #endif /* _MPR121_TOUCHKEY_H */ | ||
diff --git a/include/linux/input/matrix_keypad.h b/include/linux/input/matrix_keypad.h index 27e06acc509a..37b04a0fdea4 100644 --- a/include/linux/input/matrix_keypad.h +++ b/include/linux/input/matrix_keypad.h | |||
@@ -80,24 +80,9 @@ int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data, | |||
80 | unsigned int rows, unsigned int cols, | 80 | unsigned int rows, unsigned int cols, |
81 | unsigned short *keymap, | 81 | unsigned short *keymap, |
82 | struct input_dev *input_dev); | 82 | struct input_dev *input_dev); |
83 | int matrix_keypad_parse_properties(struct device *dev, | ||
84 | unsigned int *rows, unsigned int *cols); | ||
83 | 85 | ||
84 | #ifdef CONFIG_OF | 86 | #define matrix_keypad_parse_of_params matrix_keypad_parse_properties |
85 | /** | ||
86 | * matrix_keypad_parse_of_params() - Read parameters from matrix-keypad node | ||
87 | * | ||
88 | * @dev: Device containing of_node | ||
89 | * @rows: Returns number of matrix rows | ||
90 | * @cols: Returns number of matrix columns | ||
91 | * @return 0 if OK, <0 on error | ||
92 | */ | ||
93 | int matrix_keypad_parse_of_params(struct device *dev, | ||
94 | unsigned int *rows, unsigned int *cols); | ||
95 | #else | ||
96 | static inline int matrix_keypad_parse_of_params(struct device *dev, | ||
97 | unsigned int *rows, unsigned int *cols) | ||
98 | { | ||
99 | return -ENOSYS; | ||
100 | } | ||
101 | #endif /* CONFIG_OF */ | ||
102 | 87 | ||
103 | #endif /* _MATRIX_KEYPAD_H */ | 88 | #endif /* _MATRIX_KEYPAD_H */ |
diff --git a/include/linux/input/tca8418_keypad.h b/include/linux/input/tca8418_keypad.h deleted file mode 100644 index e71a85dc2cbd..000000000000 --- a/include/linux/input/tca8418_keypad.h +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
1 | /* | ||
2 | * TCA8418 keypad platform support | ||
3 | * | ||
4 | * Copyright (C) 2011 Fuel7, Inc. All rights reserved. | ||
5 | * | ||
6 | * Author: Kyle Manna <kyle.manna@fuel7.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public | ||
10 | * License v2 as published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public | ||
18 | * License along with this program; if not, write to the | ||
19 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
20 | * Boston, MA 021110-1307, USA. | ||
21 | * | ||
22 | * If you can't comply with GPLv2, alternative licensing terms may be | ||
23 | * arranged. Please contact Fuel7, Inc. (http://fuel7.com/) for proprietary | ||
24 | * alternative licensing inquiries. | ||
25 | */ | ||
26 | |||
27 | #ifndef _TCA8418_KEYPAD_H | ||
28 | #define _TCA8418_KEYPAD_H | ||
29 | |||
30 | #include <linux/types.h> | ||
31 | #include <linux/input/matrix_keypad.h> | ||
32 | |||
33 | #define TCA8418_I2C_ADDR 0x34 | ||
34 | #define TCA8418_NAME "tca8418_keypad" | ||
35 | |||
36 | struct tca8418_keypad_platform_data { | ||
37 | const struct matrix_keymap_data *keymap_data; | ||
38 | unsigned rows; | ||
39 | unsigned cols; | ||
40 | bool rep; | ||
41 | bool irq_is_gpio; | ||
42 | }; | ||
43 | |||
44 | #endif | ||
diff --git a/include/linux/spi/tsc2005.h b/include/linux/spi/tsc2005.h deleted file mode 100644 index 563b3b1799a8..000000000000 --- a/include/linux/spi/tsc2005.h +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | /* | ||
2 | * This file is part of TSC2005 touchscreen driver | ||
3 | * | ||
4 | * Copyright (C) 2009-2010 Nokia Corporation | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | */ | ||
16 | |||
17 | #ifndef _LINUX_SPI_TSC2005_H | ||
18 | #define _LINUX_SPI_TSC2005_H | ||
19 | |||
20 | #include <linux/types.h> | ||
21 | |||
22 | struct tsc2005_platform_data { | ||
23 | int ts_pressure_max; | ||
24 | int ts_pressure_fudge; | ||
25 | int ts_x_max; | ||
26 | int ts_x_fudge; | ||
27 | int ts_y_max; | ||
28 | int ts_y_fudge; | ||
29 | int ts_x_plate_ohm; | ||
30 | unsigned int esd_timeout_ms; | ||
31 | void (*set_reset)(bool enable); | ||
32 | }; | ||
33 | |||
34 | #endif | ||
diff --git a/include/uapi/linux/serio.h b/include/uapi/linux/serio.h index f2447a83ac8d..ccd0ccd00f47 100644 --- a/include/uapi/linux/serio.h +++ b/include/uapi/linux/serio.h | |||
@@ -17,9 +17,10 @@ | |||
17 | /* | 17 | /* |
18 | * bit masks for use in "interrupt" flags (3rd argument) | 18 | * bit masks for use in "interrupt" flags (3rd argument) |
19 | */ | 19 | */ |
20 | #define SERIO_TIMEOUT 1 | 20 | #define SERIO_TIMEOUT BIT(0) |
21 | #define SERIO_PARITY 2 | 21 | #define SERIO_PARITY BIT(1) |
22 | #define SERIO_FRAME 4 | 22 | #define SERIO_FRAME BIT(2) |
23 | #define SERIO_OOB_DATA BIT(3) | ||
23 | 24 | ||
24 | /* | 25 | /* |
25 | * Serio types | 26 | * Serio types |