Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'next' into for-linus

Prepare input updates for 4.11 merge window.

+2328 -2249
+27
Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
··· 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 + };
+30
Documentation/devicetree/bindings/input/mpr121-touchkey.txt
··· 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 + };
+16
Documentation/devicetree/bindings/input/pwm-beeper.txt
··· 5 5 Required properties: 6 6 - compatible: should be "pwm-beeper" 7 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 + };
+32
Documentation/devicetree/bindings/input/touchscreen/zet6223.txt
··· 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 + };
+1
Documentation/devicetree/bindings/vendor-prefixes.txt
··· 329 329 xillybus Xillybus Ltd. 330 330 xlnx Xilinx 331 331 zarlink Zarlink Semiconductor 332 + zeitec ZEITEC Semiconductor Co., LTD. 332 333 zii Zodiac Inflight Innovations 333 334 zte ZTE Corp. 334 335 zyxel ZyXEL Communications Corp.
-3
drivers/input/Kconfig
··· 94 94 95 95 config INPUT_MOUSEDEV 96 96 tristate "Mouse interface" 97 - default y 98 97 help 99 98 Say Y here if you want your mouse to be accessible as char devices 100 99 13:32+ - /dev/input/mouseX and 13:63 - /dev/input/mice as an ··· 108 109 109 110 config INPUT_MOUSEDEV_PSAUX 110 111 bool "Provide legacy /dev/psaux device" 111 - default y 112 112 depends on INPUT_MOUSEDEV 113 113 help 114 114 Say Y here if you want your mouse also be accessible as char device ··· 115 117 the same as the data from /dev/input/mice. 116 118 117 119 If unsure, say Y. 118 - 119 120 120 121 config INPUT_MOUSEDEV_SCREEN_X 121 122 int "Horizontal screen resolution"
+7 -1
drivers/input/input.c
··· 1749 1749 }; 1750 1750 #endif /* CONFIG_PM */ 1751 1751 1752 - static struct device_type input_dev_type = { 1752 + static const struct device_type input_dev_type = { 1753 1753 .groups = input_dev_attr_groups, 1754 1754 .release = input_dev_release, 1755 1755 .uevent = input_dev_uevent, ··· 2090 2090 unsigned int packet_size; 2091 2091 const char *path; 2092 2092 int error; 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 + } 2093 2099 2094 2100 if (dev->devres_managed) { 2095 2101 devres = devres_alloc(devm_input_device_unregister,
+14 -6
drivers/input/joydev.c
··· 87 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 93 static void joydev_pass_event(struct joydev_client *client, ··· 187 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 201 static int joydev_open_device(struct joydev *joydev) 191 202 { 192 203 int retval; ··· 212 201 retval = input_open_device(&joydev->handle); 213 202 if (retval) 214 203 joydev->open--; 204 + else 205 + joydev_refresh_state(joydev); 215 206 } 216 207 217 208 mutex_unlock(&joydev->mutex); ··· 885 872 j = joydev->abspam[i]; 886 873 if (input_abs_get_max(dev, j) == input_abs_get_min(dev, j)) { 887 874 joydev->corr[i].type = JS_CORR_NONE; 888 - joydev->abs[i] = input_abs_get_val(dev, j); 889 875 continue; 890 876 } 891 877 joydev->corr[i].type = JS_CORR_BROKEN; ··· 899 887 if (t) { 900 888 joydev->corr[i].coef[2] = (1 << 29) / t; 901 889 joydev->corr[i].coef[3] = (1 << 29) / t; 902 - 903 - joydev->abs[i] = 904 - joydev_correct(input_abs_get_val(dev, j), 905 - joydev->corr + i); 906 890 } 907 891 } 908 892
-1
drivers/input/joystick/maplecontrol.c
··· 139 139 idev->dev.parent = &mdev->dev; 140 140 idev->name = mdev->product_name; 141 141 idev->id.bustype = BUS_HOST; 142 - input_set_drvdata(idev, pad); 143 142 144 143 error = input_register_device(idev); 145 144 if (error)
+95 -61
drivers/input/joystick/xpad.c
··· 320 320 XPAD_XBOXONE_VENDOR(0x0738), /* Mad Catz FightStick TE 2 */ 321 321 XPAD_XBOX360_VENDOR(0x0e6f), /* 0x0e6f X-Box 360 controllers */ 322 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 325 XPAD_XBOX360_VENDOR(0x12ab), /* X-Box 360 dance pads */ 324 326 XPAD_XBOX360_VENDOR(0x1430), /* RedOctane X-Box 360 controllers */ 325 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 328 XPAD_XBOX360_VENDOR(0x1532), /* Razer Sabertooth */ 333 329 XPAD_XBOX360_VENDOR(0x15e4), /* Numark X-Box 360 controllers */ 334 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 389 390 390 static int xpad_init_input(struct usb_xpad *xpad); 391 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 395 * xpad_process_packet ··· 609 608 } 610 609 611 610 /* 612 - * xpadone_process_buttons 611 + * xpadone_process_packet 613 612 * 614 - * Process a button update packet from an Xbox one controller. 613 + * Completes a request by converting the data into events for the 614 + * input subsystem. This version is for the Xbox One controller. 615 + * 616 + * The report format was gleaned from 617 + * https://github.com/kylelemons/xbox/blob/master/xbox.go 615 618 */ 616 - static void xpadone_process_buttons(struct usb_xpad *xpad, 617 - struct input_dev *dev, 618 - unsigned char *data) 619 + static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) 619 620 { 621 + struct input_dev *dev = xpad->dev; 622 + 623 + /* the xbox button has its own special report */ 624 + if (data[0] == 0X07) { 625 + /* 626 + * The Xbox One S controller requires these reports to be 627 + * acked otherwise it continues sending them forever and 628 + * won't report further mode button events. 629 + */ 630 + if (data[1] == 0x30) 631 + xpadone_ack_mode_report(xpad, data[2]); 632 + 633 + input_report_key(dev, BTN_MODE, data[4] & 0x01); 634 + input_sync(dev); 635 + return; 636 + } 637 + /* check invalid packet */ 638 + else if (data[0] != 0X20) 639 + return; 640 + 620 641 /* menu/view buttons */ 621 642 input_report_key(dev, BTN_START, data[4] & 0x04); 622 643 input_report_key(dev, BTN_SELECT, data[4] & 0x08); ··· 699 676 } 700 677 701 678 input_sync(dev); 702 - } 703 - 704 - /* 705 - * xpadone_process_packet 706 - * 707 - * Completes a request by converting the data into events for the 708 - * input subsystem. This version is for the Xbox One controller. 709 - * 710 - * The report format was gleaned from 711 - * https://github.com/kylelemons/xbox/blob/master/xbox.go 712 - */ 713 - 714 - static void xpadone_process_packet(struct usb_xpad *xpad, 715 - u16 cmd, unsigned char *data) 716 - { 717 - struct input_dev *dev = xpad->dev; 718 - 719 - switch (data[0]) { 720 - case 0x20: 721 - xpadone_process_buttons(xpad, dev, data); 722 - break; 723 - 724 - case 0x07: 725 - /* the xbox button has its own special report */ 726 - input_report_key(dev, BTN_MODE, data[4] & 0x01); 727 - input_sync(dev); 728 - break; 729 - } 730 679 } 731 680 732 681 static void xpad_irq_in(struct urb *urb) ··· 845 850 spin_unlock_irqrestore(&xpad->odata_lock, flags); 846 851 } 847 852 848 - static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad) 853 + static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad, 854 + struct usb_endpoint_descriptor *ep_irq_out) 849 855 { 850 - struct usb_endpoint_descriptor *ep_irq_out; 851 - int ep_irq_out_idx; 852 856 int error; 853 857 854 858 if (xpad->xtype == XTYPE_UNKNOWN) ··· 857 863 858 864 xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN, 859 865 GFP_KERNEL, &xpad->odata_dma); 860 - if (!xpad->odata) { 861 - error = -ENOMEM; 862 - goto fail1; 863 - } 866 + if (!xpad->odata) 867 + return -ENOMEM; 864 868 865 869 spin_lock_init(&xpad->odata_lock); 866 870 867 871 xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL); 868 872 if (!xpad->irq_out) { 869 873 error = -ENOMEM; 870 - goto fail2; 874 + goto err_free_coherent; 871 875 } 872 - 873 - /* Xbox One controller has in/out endpoints swapped. */ 874 - ep_irq_out_idx = xpad->xtype == XTYPE_XBOXONE ? 0 : 1; 875 - ep_irq_out = &intf->cur_altsetting->endpoint[ep_irq_out_idx].desc; 876 876 877 877 usb_fill_int_urb(xpad->irq_out, xpad->udev, 878 878 usb_sndintpipe(xpad->udev, ep_irq_out->bEndpointAddress), ··· 877 889 878 890 return 0; 879 891 880 - fail2: usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma); 881 - fail1: return error; 892 + err_free_coherent: 893 + usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma); 894 + return error; 882 895 } 883 896 884 897 static void xpad_stop_output(struct usb_xpad *xpad) ··· 961 972 spin_unlock_irqrestore(&xpad->odata_lock, flags); 962 973 963 974 return retval; 975 + } 976 + 977 + static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num) 978 + { 979 + unsigned long flags; 980 + struct xpad_output_packet *packet = 981 + &xpad->out_packets[XPAD_OUT_CMD_IDX]; 982 + static const u8 mode_report_ack[] = { 983 + 0x01, 0x20, 0x00, 0x09, 0x00, 0x07, 0x20, 0x02, 984 + 0x00, 0x00, 0x00, 0x00, 0x00 985 + }; 986 + 987 + spin_lock_irqsave(&xpad->odata_lock, flags); 988 + 989 + packet->len = sizeof(mode_report_ack); 990 + memcpy(packet->data, mode_report_ack, packet->len); 991 + packet->data[2] = seq_num; 992 + packet->pending = true; 993 + 994 + /* Reset the sequence so we send out the ack now */ 995 + xpad->last_out_packet = -1; 996 + xpad_try_sending_next_out_packet(xpad); 997 + 998 + spin_unlock_irqrestore(&xpad->odata_lock, flags); 964 999 } 965 1000 966 1001 #ifdef CONFIG_JOYSTICK_XPAD_FF ··· 1211 1198 led_cdev = &led->led_cdev; 1212 1199 led_cdev->name = led->name; 1213 1200 led_cdev->brightness_set = xpad_led_set; 1201 + led_cdev->flags = LED_CORE_SUSPENDRESUME; 1214 1202 1215 1203 error = led_classdev_register(&xpad->udev->dev, led_cdev); 1216 1204 if (error) ··· 1482 1468 { 1483 1469 struct usb_device *udev = interface_to_usbdev(intf); 1484 1470 struct usb_xpad *xpad; 1485 - struct usb_endpoint_descriptor *ep_irq_in; 1486 - int ep_irq_in_idx; 1471 + struct usb_endpoint_descriptor *ep_irq_in, *ep_irq_out; 1487 1472 int i, error; 1488 1473 1489 1474 if (intf->cur_altsetting->desc.bNumEndpoints != 2) ··· 1552 1539 goto err_free_in_urb; 1553 1540 } 1554 1541 1555 - error = xpad_init_output(intf, xpad); 1542 + ep_irq_in = ep_irq_out = NULL; 1543 + 1544 + for (i = 0; i < 2; i++) { 1545 + struct usb_endpoint_descriptor *ep = 1546 + &intf->cur_altsetting->endpoint[i].desc; 1547 + 1548 + if (usb_endpoint_dir_in(ep)) 1549 + ep_irq_in = ep; 1550 + else 1551 + ep_irq_out = ep; 1552 + } 1553 + 1554 + if (!ep_irq_in || !ep_irq_out) { 1555 + error = -ENODEV; 1556 + goto err_free_in_urb; 1557 + } 1558 + 1559 + error = xpad_init_output(intf, xpad, ep_irq_out); 1556 1560 if (error) 1557 1561 goto err_free_in_urb; 1558 - 1559 - /* Xbox One controller has in/out endpoints swapped. */ 1560 - ep_irq_in_idx = xpad->xtype == XTYPE_XBOXONE ? 1 : 0; 1561 - ep_irq_in = &intf->cur_altsetting->endpoint[ep_irq_in_idx].desc; 1562 1562 1563 1563 usb_fill_int_urb(xpad->irq_in, udev, 1564 1564 usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), ··· 1688 1662 retval = xpad360w_start_input(xpad); 1689 1663 } else { 1690 1664 mutex_lock(&input->mutex); 1691 - if (input->users) 1665 + if (input->users) { 1692 1666 retval = xpad_start_input(xpad); 1667 + } else if (xpad->xtype == XTYPE_XBOXONE) { 1668 + /* 1669 + * Even if there are no users, we'll send Xbox One pads 1670 + * the startup sequence so they don't sit there and 1671 + * blink until somebody opens the input device again. 1672 + */ 1673 + retval = xpad_start_xbox_one(xpad); 1674 + } 1693 1675 mutex_unlock(&input->mutex); 1694 1676 } 1695 1677
+11
drivers/input/keyboard/Kconfig
··· 666 666 To compile this driver as a module, choose M here: the 667 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 680 config KEYBOARD_TWL4030 670 681 tristate "TI TWL4030/TWL5030/TPS659x0 keypad support" 671 682 depends on TWL4030_CORE
+1
drivers/input/keyboard/Makefile
··· 61 61 obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o 62 62 obj-$(CONFIG_KEYBOARD_TC3589X) += tc3589x-keypad.o 63 63 obj-$(CONFIG_KEYBOARD_TEGRA) += tegra-kbc.o 64 + obj-$(CONFIG_KEYBOARD_TM2_TOUCHKEY) += tm2-touchkey.o 64 65 obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o 65 66 obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o 66 67 obj-$(CONFIG_KEYBOARD_W90P910) += w90p910_keypad.o
-2
drivers/input/keyboard/adc-keys.c
··· 148 148 if (error) 149 149 return error; 150 150 151 - platform_set_drvdata(pdev, st); 152 - 153 151 poll_dev = devm_input_allocate_polled_device(dev); 154 152 if (!poll_dev) { 155 153 dev_err(dev, "failed to allocate input device\n");
-2
drivers/input/keyboard/adp5520-keys.c
··· 107 107 input->phys = "adp5520-keys/input0"; 108 108 input->dev.parent = &pdev->dev; 109 109 110 - input_set_drvdata(input, dev); 111 - 112 110 input->id.bustype = BUS_I2C; 113 111 input->id.vendor = 0x0001; 114 112 input->id.product = 0x5520;
+1 -3
drivers/input/keyboard/bcm-keypad.c
··· 213 213 /* Initialize the KPCR Keypad Configuration Register */ 214 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 217 if (error) { 218 218 dev_err(dev, "failed to parse kp params\n"); 219 219 return error; ··· 351 351 input_set_drvdata(input_dev, kp); 352 352 353 353 kp->input_dev = input_dev; 354 - 355 - platform_set_drvdata(pdev, kp); 356 354 357 355 error = bcm_kp_matrix_key_parse_dt(kp); 358 356 if (error)
-2
drivers/input/keyboard/bf54x-keys.c
··· 268 268 input->phys = "bf54x-keys/input0"; 269 269 input->dev.parent = &pdev->dev; 270 270 271 - input_set_drvdata(input, bf54x_kpad); 272 - 273 271 input->id.bustype = BUS_HOST; 274 272 input->id.vendor = 0x0001; 275 273 input->id.product = 0x0001;
-1
drivers/input/keyboard/cap11xx.c
··· 392 392 return error; 393 393 394 394 dev_info(dev, "CAP11XX detected, revision 0x%02x\n", rev); 395 - i2c_set_clientdata(i2c_client, priv); 396 395 node = dev->of_node; 397 396 398 397 if (!of_property_read_u32(node, "microchip,sensor-gain", &gain32)) {
+409 -47
drivers/input/keyboard/cros_ec_keyb.c
··· 34 34 #include <linux/mfd/cros_ec.h> 35 35 #include <linux/mfd/cros_ec_commands.h> 36 36 37 + #include <asm/unaligned.h> 38 + 37 39 /* 38 40 * @rows: Number of rows in the keypad 39 41 * @cols: Number of columns in the keypad ··· 45 43 * @valid_keys: bitmap of existing keys for each matrix column 46 44 * @old_kb_state: bitmap of keys pressed last scan 47 45 * @dev: Device pointer 48 - * @idev: Input device 49 46 * @ec: Top level ChromeOS device to use to talk to EC 47 + * @idev: The input device for the matrix keys. 48 + * @bs_idev: The input device for non-matrix buttons and switches (or NULL). 50 49 * @notifier: interrupt event notifier for transport devices 51 50 */ 52 51 struct cros_ec_keyb { ··· 60 57 uint8_t *old_kb_state; 61 58 62 59 struct device *dev; 63 - struct input_dev *idev; 64 60 struct cros_ec_device *ec; 61 + 62 + struct input_dev *idev; 63 + struct input_dev *bs_idev; 65 64 struct notifier_block notifier; 66 65 }; 67 66 67 + 68 + /** 69 + * cros_ec_bs_map - Struct mapping Linux keycodes to EC button/switch bitmap 70 + * #defines 71 + * 72 + * @ev_type: The type of the input event to generate (e.g., EV_KEY). 73 + * @code: A linux keycode 74 + * @bit: A #define like EC_MKBP_POWER_BUTTON or EC_MKBP_LID_OPEN 75 + * @inverted: If the #define and EV_SW have opposite meanings, this is true. 76 + * Only applicable to switches. 77 + */ 78 + struct cros_ec_bs_map { 79 + unsigned int ev_type; 80 + unsigned int code; 81 + u8 bit; 82 + bool inverted; 83 + }; 84 + 85 + /* cros_ec_keyb_bs - Map EC button/switch #defines into kernel ones */ 86 + static const struct cros_ec_bs_map cros_ec_keyb_bs[] = { 87 + /* Buttons */ 88 + { 89 + .ev_type = EV_KEY, 90 + .code = KEY_POWER, 91 + .bit = EC_MKBP_POWER_BUTTON, 92 + }, 93 + { 94 + .ev_type = EV_KEY, 95 + .code = KEY_VOLUMEUP, 96 + .bit = EC_MKBP_VOL_UP, 97 + }, 98 + { 99 + .ev_type = EV_KEY, 100 + .code = KEY_VOLUMEDOWN, 101 + .bit = EC_MKBP_VOL_DOWN, 102 + }, 103 + 104 + /* Switches */ 105 + { 106 + .ev_type = EV_SW, 107 + .code = SW_LID, 108 + .bit = EC_MKBP_LID_OPEN, 109 + .inverted = true, 110 + }, 111 + { 112 + .ev_type = EV_SW, 113 + .code = SW_TABLET_MODE, 114 + .bit = EC_MKBP_TABLET_MODE, 115 + }, 116 + }; 68 117 69 118 /* 70 119 * Returns true when there is at least one combination of pressed keys that ··· 204 149 input_sync(ckdev->idev); 205 150 } 206 151 207 - static int cros_ec_keyb_open(struct input_dev *dev) 152 + /** 153 + * cros_ec_keyb_report_bs - Report non-matrixed buttons or switches 154 + * 155 + * This takes a bitmap of buttons or switches from the EC and reports events, 156 + * syncing at the end. 157 + * 158 + * @ckdev: The keyboard device. 159 + * @ev_type: The input event type (e.g., EV_KEY). 160 + * @mask: A bitmap of buttons from the EC. 161 + */ 162 + static void cros_ec_keyb_report_bs(struct cros_ec_keyb *ckdev, 163 + unsigned int ev_type, u32 mask) 164 + 208 165 { 209 - struct cros_ec_keyb *ckdev = input_get_drvdata(dev); 166 + struct input_dev *idev = ckdev->bs_idev; 167 + int i; 210 168 211 - return blocking_notifier_chain_register(&ckdev->ec->event_notifier, 212 - &ckdev->notifier); 213 - } 169 + for (i = 0; i < ARRAY_SIZE(cros_ec_keyb_bs); i++) { 170 + const struct cros_ec_bs_map *map = &cros_ec_keyb_bs[i]; 214 171 215 - static void cros_ec_keyb_close(struct input_dev *dev) 216 - { 217 - struct cros_ec_keyb *ckdev = input_get_drvdata(dev); 172 + if (map->ev_type != ev_type) 173 + continue; 218 174 219 - blocking_notifier_chain_unregister(&ckdev->ec->event_notifier, 220 - &ckdev->notifier); 175 + input_event(idev, ev_type, map->code, 176 + !!(mask & BIT(map->bit)) ^ map->inverted); 177 + } 178 + input_sync(idev); 221 179 } 222 180 223 181 static int cros_ec_keyb_work(struct notifier_block *nb, ··· 238 170 { 239 171 struct cros_ec_keyb *ckdev = container_of(nb, struct cros_ec_keyb, 240 172 notifier); 173 + u32 val; 174 + unsigned int ev_type; 241 175 242 - if (ckdev->ec->event_data.event_type != EC_MKBP_EVENT_KEY_MATRIX) 176 + switch (ckdev->ec->event_data.event_type) { 177 + case EC_MKBP_EVENT_KEY_MATRIX: 178 + /* 179 + * If EC is not the wake source, discard key state changes 180 + * during suspend. 181 + */ 182 + if (queued_during_suspend) 183 + return NOTIFY_OK; 184 + 185 + if (ckdev->ec->event_size != ckdev->cols) { 186 + dev_err(ckdev->dev, 187 + "Discarded incomplete key matrix event.\n"); 188 + return NOTIFY_OK; 189 + } 190 + cros_ec_keyb_process(ckdev, 191 + ckdev->ec->event_data.data.key_matrix, 192 + ckdev->ec->event_size); 193 + break; 194 + 195 + case EC_MKBP_EVENT_BUTTON: 196 + case EC_MKBP_EVENT_SWITCH: 197 + /* 198 + * If EC is not the wake source, discard key state 199 + * changes during suspend. Switches will be re-checked in 200 + * cros_ec_keyb_resume() to be sure nothing is lost. 201 + */ 202 + if (queued_during_suspend) 203 + return NOTIFY_OK; 204 + 205 + if (ckdev->ec->event_data.event_type == EC_MKBP_EVENT_BUTTON) { 206 + val = get_unaligned_le32( 207 + &ckdev->ec->event_data.data.buttons); 208 + ev_type = EV_KEY; 209 + } else { 210 + val = get_unaligned_le32( 211 + &ckdev->ec->event_data.data.switches); 212 + ev_type = EV_SW; 213 + } 214 + cros_ec_keyb_report_bs(ckdev, ev_type, val); 215 + break; 216 + 217 + default: 243 218 return NOTIFY_DONE; 244 - /* 245 - * If EC is not the wake source, discard key state changes during 246 - * suspend. 247 - */ 248 - if (queued_during_suspend) 249 - return NOTIFY_OK; 250 - if (ckdev->ec->event_size != ckdev->cols) { 251 - dev_err(ckdev->dev, 252 - "Discarded incomplete key matrix event.\n"); 253 - return NOTIFY_OK; 254 219 } 255 - cros_ec_keyb_process(ckdev, ckdev->ec->event_data.data.key_matrix, 256 - ckdev->ec->event_size); 220 + 257 221 return NOTIFY_OK; 258 222 } 259 223 ··· 313 213 } 314 214 } 315 215 316 - static int cros_ec_keyb_probe(struct platform_device *pdev) 216 + /** 217 + * cros_ec_keyb_info - Wrap the EC command EC_CMD_MKBP_INFO 218 + * 219 + * This wraps the EC_CMD_MKBP_INFO, abstracting out all of the marshalling and 220 + * unmarshalling and different version nonsense into something simple. 221 + * 222 + * @ec_dev: The EC device 223 + * @info_type: Either EC_MKBP_INFO_SUPPORTED or EC_MKBP_INFO_CURRENT. 224 + * @event_type: Either EC_MKBP_EVENT_BUTTON or EC_MKBP_EVENT_SWITCH. Actually 225 + * in some cases this could be EC_MKBP_EVENT_KEY_MATRIX or 226 + * EC_MKBP_EVENT_HOST_EVENT too but we don't use in this driver. 227 + * @result: Where we'll store the result; a union 228 + * @result_size: The size of the result. Expected to be the size of one of 229 + * the elements in the union. 230 + * 231 + * Returns 0 if no error or -error upon error. 232 + */ 233 + static int cros_ec_keyb_info(struct cros_ec_device *ec_dev, 234 + enum ec_mkbp_info_type info_type, 235 + enum ec_mkbp_event event_type, 236 + union ec_response_get_next_data *result, 237 + size_t result_size) 317 238 { 318 - struct cros_ec_device *ec = dev_get_drvdata(pdev->dev.parent); 319 - struct device *dev = &pdev->dev; 320 - struct cros_ec_keyb *ckdev; 239 + struct ec_params_mkbp_info *params; 240 + struct cros_ec_command *msg; 241 + int ret; 242 + 243 + msg = kzalloc(sizeof(*msg) + max_t(size_t, result_size, 244 + sizeof(*params)), GFP_KERNEL); 245 + if (!msg) 246 + return -ENOMEM; 247 + 248 + msg->command = EC_CMD_MKBP_INFO; 249 + msg->version = 1; 250 + msg->outsize = sizeof(*params); 251 + msg->insize = result_size; 252 + params = (struct ec_params_mkbp_info *)msg->data; 253 + params->info_type = info_type; 254 + params->event_type = event_type; 255 + 256 + ret = cros_ec_cmd_xfer(ec_dev, msg); 257 + if (ret < 0) { 258 + dev_warn(ec_dev->dev, "Transfer error %d/%d: %d\n", 259 + (int)info_type, (int)event_type, ret); 260 + } else if (msg->result == EC_RES_INVALID_VERSION) { 261 + /* With older ECs we just return 0 for everything */ 262 + memset(result, 0, result_size); 263 + ret = 0; 264 + } else if (msg->result != EC_RES_SUCCESS) { 265 + dev_warn(ec_dev->dev, "Error getting info %d/%d: %d\n", 266 + (int)info_type, (int)event_type, msg->result); 267 + ret = -EPROTO; 268 + } else if (ret != result_size) { 269 + dev_warn(ec_dev->dev, "Wrong size %d/%d: %d != %zu\n", 270 + (int)info_type, (int)event_type, 271 + ret, result_size); 272 + ret = -EPROTO; 273 + } else { 274 + memcpy(result, msg->data, result_size); 275 + ret = 0; 276 + } 277 + 278 + kfree(msg); 279 + 280 + return ret; 281 + } 282 + 283 + /** 284 + * cros_ec_keyb_query_switches - Query the state of switches and report 285 + * 286 + * This will ask the EC about the current state of switches and report to the 287 + * kernel. Note that we don't query for buttons because they are more 288 + * transitory and we'll get an update on the next release / press. 289 + * 290 + * @ckdev: The keyboard device 291 + * 292 + * Returns 0 if no error or -error upon error. 293 + */ 294 + static int cros_ec_keyb_query_switches(struct cros_ec_keyb *ckdev) 295 + { 296 + struct cros_ec_device *ec_dev = ckdev->ec; 297 + union ec_response_get_next_data event_data = {}; 298 + int ret; 299 + 300 + ret = cros_ec_keyb_info(ec_dev, EC_MKBP_INFO_CURRENT, 301 + EC_MKBP_EVENT_SWITCH, &event_data, 302 + sizeof(event_data.switches)); 303 + if (ret) 304 + return ret; 305 + 306 + cros_ec_keyb_report_bs(ckdev, EV_SW, 307 + get_unaligned_le32(&event_data.switches)); 308 + 309 + return 0; 310 + } 311 + 312 + /** 313 + * cros_ec_keyb_resume - Resume the keyboard 314 + * 315 + * We use the resume notification as a chance to query the EC for switches. 316 + * 317 + * @dev: The keyboard device 318 + * 319 + * Returns 0 if no error or -error upon error. 320 + */ 321 + static __maybe_unused int cros_ec_keyb_resume(struct device *dev) 322 + { 323 + struct cros_ec_keyb *ckdev = dev_get_drvdata(dev); 324 + 325 + if (ckdev->bs_idev) 326 + return cros_ec_keyb_query_switches(ckdev); 327 + 328 + return 0; 329 + } 330 + 331 + /** 332 + * cros_ec_keyb_register_bs - Register non-matrix buttons/switches 333 + * 334 + * Handles all the bits of the keyboard driver related to non-matrix buttons 335 + * and switches, including asking the EC about which are present and telling 336 + * the kernel to expect them. 337 + * 338 + * If this device has no support for buttons and switches we'll return no error 339 + * but the ckdev->bs_idev will remain NULL when this function exits. 340 + * 341 + * @ckdev: The keyboard device 342 + * 343 + * Returns 0 if no error or -error upon error. 344 + */ 345 + static int cros_ec_keyb_register_bs(struct cros_ec_keyb *ckdev) 346 + { 347 + struct cros_ec_device *ec_dev = ckdev->ec; 348 + struct device *dev = ckdev->dev; 321 349 struct input_dev *idev; 322 - struct device_node *np; 350 + union ec_response_get_next_data event_data = {}; 351 + const char *phys; 352 + u32 buttons; 353 + u32 switches; 354 + int ret; 355 + int i; 356 + 357 + ret = cros_ec_keyb_info(ec_dev, EC_MKBP_INFO_SUPPORTED, 358 + EC_MKBP_EVENT_BUTTON, &event_data, 359 + sizeof(event_data.buttons)); 360 + if (ret) 361 + return ret; 362 + buttons = get_unaligned_le32(&event_data.buttons); 363 + 364 + ret = cros_ec_keyb_info(ec_dev, EC_MKBP_INFO_SUPPORTED, 365 + EC_MKBP_EVENT_SWITCH, &event_data, 366 + sizeof(event_data.switches)); 367 + if (ret) 368 + return ret; 369 + switches = get_unaligned_le32(&event_data.switches); 370 + 371 + if (!buttons && !switches) 372 + return 0; 373 + 374 + /* 375 + * We call the non-matrix buttons/switches 'input1', if present. 376 + * Allocate phys before input dev, to ensure correct tear-down 377 + * ordering. 378 + */ 379 + phys = devm_kasprintf(dev, GFP_KERNEL, "%s/input1", ec_dev->phys_name); 380 + if (!phys) 381 + return -ENOMEM; 382 + 383 + idev = devm_input_allocate_device(dev); 384 + if (!idev) 385 + return -ENOMEM; 386 + 387 + idev->name = "cros_ec_buttons"; 388 + idev->phys = phys; 389 + __set_bit(EV_REP, idev->evbit); 390 + 391 + idev->id.bustype = BUS_VIRTUAL; 392 + idev->id.version = 1; 393 + idev->id.product = 0; 394 + idev->dev.parent = dev; 395 + 396 + input_set_drvdata(idev, ckdev); 397 + ckdev->bs_idev = idev; 398 + 399 + for (i = 0; i < ARRAY_SIZE(cros_ec_keyb_bs); i++) { 400 + const struct cros_ec_bs_map *map = &cros_ec_keyb_bs[i]; 401 + 402 + if (buttons & BIT(map->bit)) 403 + input_set_capability(idev, map->ev_type, map->code); 404 + } 405 + 406 + ret = cros_ec_keyb_query_switches(ckdev); 407 + if (ret) { 408 + dev_err(dev, "cannot query switches\n"); 409 + return ret; 410 + } 411 + 412 + ret = input_register_device(ckdev->bs_idev); 413 + if (ret) { 414 + dev_err(dev, "cannot register input device\n"); 415 + return ret; 416 + } 417 + 418 + return 0; 419 + } 420 + 421 + /** 422 + * cros_ec_keyb_register_bs - Register matrix keys 423 + * 424 + * Handles all the bits of the keyboard driver related to matrix keys. 425 + * 426 + * @ckdev: The keyboard device 427 + * 428 + * Returns 0 if no error or -error upon error. 429 + */ 430 + static int cros_ec_keyb_register_matrix(struct cros_ec_keyb *ckdev) 431 + { 432 + struct cros_ec_device *ec_dev = ckdev->ec; 433 + struct device *dev = ckdev->dev; 434 + struct input_dev *idev; 435 + const char *phys; 323 436 int err; 324 437 325 - np = pdev->dev.of_node; 326 - if (!np) 327 - return -ENODEV; 328 - 329 - ckdev = devm_kzalloc(dev, sizeof(*ckdev), GFP_KERNEL); 330 - if (!ckdev) 331 - return -ENOMEM; 332 - err = matrix_keypad_parse_of_params(dev, &ckdev->rows, &ckdev->cols); 438 + err = matrix_keypad_parse_properties(dev, &ckdev->rows, &ckdev->cols); 333 439 if (err) 334 440 return err; 335 441 ··· 547 241 if (!ckdev->old_kb_state) 548 242 return -ENOMEM; 549 243 244 + /* 245 + * We call the keyboard matrix 'input0'. Allocate phys before input 246 + * dev, to ensure correct tear-down ordering. 247 + */ 248 + phys = devm_kasprintf(dev, GFP_KERNEL, "%s/input0", ec_dev->phys_name); 249 + if (!phys) 250 + return -ENOMEM; 251 + 550 252 idev = devm_input_allocate_device(dev); 551 253 if (!idev) 552 254 return -ENOMEM; 553 255 554 - ckdev->ec = ec; 555 - ckdev->notifier.notifier_call = cros_ec_keyb_work; 556 - ckdev->dev = dev; 557 - dev_set_drvdata(dev, ckdev); 558 - 559 256 idev->name = CROS_EC_DEV_NAME; 560 - idev->phys = ec->phys_name; 257 + idev->phys = phys; 561 258 __set_bit(EV_REP, idev->evbit); 562 259 563 260 idev->id.bustype = BUS_VIRTUAL; 564 261 idev->id.version = 1; 565 262 idev->id.product = 0; 566 263 idev->dev.parent = dev; 567 - idev->open = cros_ec_keyb_open; 568 - idev->close = cros_ec_keyb_close; 569 264 570 - ckdev->ghost_filter = of_property_read_bool(np, 265 + ckdev->ghost_filter = of_property_read_bool(dev->of_node, 571 266 "google,needs-ghost-filter"); 572 267 573 268 err = matrix_keypad_build_keymap(NULL, NULL, ckdev->rows, ckdev->cols, ··· 594 287 return 0; 595 288 } 596 289 290 + static int cros_ec_keyb_probe(struct platform_device *pdev) 291 + { 292 + struct cros_ec_device *ec = dev_get_drvdata(pdev->dev.parent); 293 + struct device *dev = &pdev->dev; 294 + struct cros_ec_keyb *ckdev; 295 + int err; 296 + 297 + if (!dev->of_node) 298 + return -ENODEV; 299 + 300 + ckdev = devm_kzalloc(dev, sizeof(*ckdev), GFP_KERNEL); 301 + if (!ckdev) 302 + return -ENOMEM; 303 + 304 + ckdev->ec = ec; 305 + ckdev->dev = dev; 306 + dev_set_drvdata(dev, ckdev); 307 + 308 + err = cros_ec_keyb_register_matrix(ckdev); 309 + if (err) { 310 + dev_err(dev, "cannot register matrix inputs: %d\n", err); 311 + return err; 312 + } 313 + 314 + err = cros_ec_keyb_register_bs(ckdev); 315 + if (err) { 316 + dev_err(dev, "cannot register non-matrix inputs: %d\n", err); 317 + return err; 318 + } 319 + 320 + ckdev->notifier.notifier_call = cros_ec_keyb_work; 321 + err = blocking_notifier_chain_register(&ckdev->ec->event_notifier, 322 + &ckdev->notifier); 323 + if (err) { 324 + dev_err(dev, "cannot register notifier: %d\n", err); 325 + return err; 326 + } 327 + 328 + return 0; 329 + } 330 + 331 + static int cros_ec_keyb_remove(struct platform_device *pdev) 332 + { 333 + struct cros_ec_keyb *ckdev = dev_get_drvdata(&pdev->dev); 334 + 335 + blocking_notifier_chain_unregister(&ckdev->ec->event_notifier, 336 + &ckdev->notifier); 337 + 338 + return 0; 339 + } 340 + 597 341 #ifdef CONFIG_OF 598 342 static const struct of_device_id cros_ec_keyb_of_match[] = { 599 343 { .compatible = "google,cros-ec-keyb" }, ··· 653 295 MODULE_DEVICE_TABLE(of, cros_ec_keyb_of_match); 654 296 #endif 655 297 298 + static const SIMPLE_DEV_PM_OPS(cros_ec_keyb_pm_ops, NULL, cros_ec_keyb_resume); 299 + 656 300 static struct platform_driver cros_ec_keyb_driver = { 657 301 .probe = cros_ec_keyb_probe, 302 + .remove = cros_ec_keyb_remove, 658 303 .driver = { 659 304 .name = "cros-ec-keyb", 660 305 .of_match_table = of_match_ptr(cros_ec_keyb_of_match), 306 + .pm = &cros_ec_keyb_pm_ops, 661 307 }, 662 308 }; 663 309
+2 -2
drivers/input/keyboard/davinci_keyscan.c
··· 172 172 struct input_dev *key_dev; 173 173 struct resource *res, *mem; 174 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 176 int error, i; 177 177 178 178 if (pdata->device_enable) { ··· 255 255 256 256 key_dev->name = "davinci_keyscan"; 257 257 key_dev->phys = "davinci_keyscan/input0"; 258 - key_dev->dev.parent = &pdev->dev; 258 + key_dev->dev.parent = dev; 259 259 key_dev->id.bustype = BUS_HOST; 260 260 key_dev->id.vendor = 0x0001; 261 261 key_dev->id.product = 0x0001;
+39 -27
drivers/input/keyboard/gpio_keys.c
··· 36 36 struct input_dev *input; 37 37 struct gpio_desc *gpiod; 38 38 39 + unsigned short *code; 40 + 39 41 struct timer_list release_timer; 40 42 unsigned int release_delay; /* in msecs, for IRQ-only buttons */ 41 43 ··· 54 52 const struct gpio_keys_platform_data *pdata; 55 53 struct input_dev *input; 56 54 struct mutex disable_lock; 55 + unsigned short *keymap; 57 56 struct gpio_button_data data[0]; 58 57 }; 59 58 ··· 206 203 if (only_disabled && !bdata->disabled) 207 204 continue; 208 205 209 - __set_bit(bdata->button->code, bits); 206 + __set_bit(*bdata->code, bits); 210 207 } 211 208 212 209 ret = scnprintf(buf, PAGE_SIZE - 1, "%*pbl", n_events, bits); ··· 257 254 if (bdata->button->type != type) 258 255 continue; 259 256 260 - if (test_bit(bdata->button->code, bits) && 257 + if (test_bit(*bdata->code, bits) && 261 258 !bdata->button->can_disable) { 262 259 error = -EINVAL; 263 260 goto out; ··· 272 269 if (bdata->button->type != type) 273 270 continue; 274 271 275 - if (test_bit(bdata->button->code, bits)) 272 + if (test_bit(*bdata->code, bits)) 276 273 gpio_keys_disable_button(bdata); 277 274 else 278 275 gpio_keys_enable_button(bdata); ··· 374 371 if (state) 375 372 input_event(input, type, button->code, button->value); 376 373 } else { 377 - input_event(input, type, button->code, state); 374 + input_event(input, type, *bdata->code, state); 378 375 } 379 376 input_sync(input); 380 377 } ··· 414 411 415 412 spin_lock_irqsave(&bdata->lock, flags); 416 413 if (bdata->key_pressed) { 417 - input_event(input, EV_KEY, bdata->button->code, 0); 414 + input_event(input, EV_KEY, *bdata->code, 0); 418 415 input_sync(input); 419 416 bdata->key_pressed = false; 420 417 } ··· 424 421 static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id) 425 422 { 426 423 struct gpio_button_data *bdata = dev_id; 427 - const struct gpio_keys_button *button = bdata->button; 428 424 struct input_dev *input = bdata->input; 429 425 unsigned long flags; 430 426 ··· 435 433 if (bdata->button->wakeup) 436 434 pm_wakeup_event(bdata->input->dev.parent, 0); 437 435 438 - input_event(input, EV_KEY, button->code, 1); 436 + input_event(input, EV_KEY, *bdata->code, 1); 439 437 input_sync(input); 440 438 441 439 if (!bdata->release_delay) { 442 - input_event(input, EV_KEY, button->code, 0); 440 + input_event(input, EV_KEY, *bdata->code, 0); 443 441 input_sync(input); 444 442 goto out; 445 443 } ··· 467 465 468 466 static int gpio_keys_setup_key(struct platform_device *pdev, 469 467 struct input_dev *input, 470 - struct gpio_button_data *bdata, 468 + struct gpio_keys_drvdata *ddata, 471 469 const struct gpio_keys_button *button, 470 + int idx, 472 471 struct fwnode_handle *child) 473 472 { 474 473 const char *desc = button->desc ? button->desc : "gpio_keys"; 475 474 struct device *dev = &pdev->dev; 475 + struct gpio_button_data *bdata = &ddata->data[idx]; 476 476 irq_handler_t isr; 477 477 unsigned long irqflags; 478 478 int irq; ··· 518 514 if (button->active_low) 519 515 flags |= GPIOF_ACTIVE_LOW; 520 516 521 - error = devm_gpio_request_one(&pdev->dev, button->gpio, flags, 522 - desc); 517 + error = devm_gpio_request_one(dev, button->gpio, flags, desc); 523 518 if (error < 0) { 524 519 dev_err(dev, "Failed to request GPIO %d, error %d\n", 525 520 button->gpio, error); ··· 580 577 irqflags = 0; 581 578 } 582 579 583 - input_set_capability(input, button->type ?: EV_KEY, button->code); 580 + bdata->code = &ddata->keymap[idx]; 581 + *bdata->code = button->code; 582 + input_set_capability(input, button->type ?: EV_KEY, *bdata->code); 584 583 585 584 /* 586 585 * Install custom action to cancel release timer and 587 586 * workqueue item. 588 587 */ 589 - error = devm_add_action(&pdev->dev, gpio_keys_quiesce_key, bdata); 588 + error = devm_add_action(dev, gpio_keys_quiesce_key, bdata); 590 589 if (error) { 591 - dev_err(&pdev->dev, 592 - "failed to register quiesce action, error: %d\n", 590 + dev_err(dev, "failed to register quiesce action, error: %d\n", 593 591 error); 594 592 return error; 595 593 } ··· 602 598 if (!button->can_disable) 603 599 irqflags |= IRQF_SHARED; 604 600 605 - error = devm_request_any_context_irq(&pdev->dev, bdata->irq, 606 - isr, irqflags, desc, bdata); 601 + error = devm_request_any_context_irq(dev, bdata->irq, isr, irqflags, 602 + desc, bdata); 607 603 if (error < 0) { 608 604 dev_err(dev, "Unable to claim irq %d; error %d\n", 609 605 bdata->irq, error); ··· 754 750 return -ENOMEM; 755 751 } 756 752 753 + ddata->keymap = devm_kcalloc(dev, 754 + pdata->nbuttons, sizeof(ddata->keymap[0]), 755 + GFP_KERNEL); 756 + if (!ddata->keymap) 757 + return -ENOMEM; 758 + 757 759 input = devm_input_allocate_device(dev); 758 760 if (!input) { 759 761 dev_err(dev, "failed to allocate input device\n"); ··· 775 765 776 766 input->name = pdata->name ? : pdev->name; 777 767 input->phys = "gpio-keys/input0"; 778 - input->dev.parent = &pdev->dev; 768 + input->dev.parent = dev; 779 769 input->open = gpio_keys_open; 780 770 input->close = gpio_keys_close; 781 771 ··· 784 774 input->id.product = 0x0001; 785 775 input->id.version = 0x0100; 786 776 777 + input->keycode = ddata->keymap; 778 + input->keycodesize = sizeof(ddata->keymap[0]); 779 + input->keycodemax = pdata->nbuttons; 780 + 787 781 /* Enable auto repeat feature of Linux input subsystem */ 788 782 if (pdata->rep) 789 783 __set_bit(EV_REP, input->evbit); 790 784 791 785 for (i = 0; i < pdata->nbuttons; i++) { 792 786 const struct gpio_keys_button *button = &pdata->buttons[i]; 793 - struct gpio_button_data *bdata = &ddata->data[i]; 794 787 795 788 if (!dev_get_platdata(dev)) { 796 - child = device_get_next_child_node(&pdev->dev, child); 789 + child = device_get_next_child_node(dev, child); 797 790 if (!child) { 798 - dev_err(&pdev->dev, 791 + dev_err(dev, 799 792 "missing child device node for entry %d\n", 800 793 i); 801 794 return -EINVAL; 802 795 } 803 796 } 804 797 805 - error = gpio_keys_setup_key(pdev, input, bdata, button, child); 798 + error = gpio_keys_setup_key(pdev, input, ddata, 799 + button, i, child); 806 800 if (error) { 807 801 fwnode_handle_put(child); 808 802 return error; ··· 818 804 819 805 fwnode_handle_put(child); 820 806 821 - error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group); 807 + error = sysfs_create_group(&dev->kobj, &gpio_keys_attr_group); 822 808 if (error) { 823 809 dev_err(dev, "Unable to export keys/switches, error: %d\n", 824 810 error); ··· 832 818 goto err_remove_group; 833 819 } 834 820 835 - device_init_wakeup(&pdev->dev, wakeup); 821 + device_init_wakeup(dev, wakeup); 836 822 837 823 return 0; 838 824 839 825 err_remove_group: 840 - sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); 826 + sysfs_remove_group(&dev->kobj, &gpio_keys_attr_group); 841 827 return error; 842 828 } 843 829 844 830 static int gpio_keys_remove(struct platform_device *pdev) 845 831 { 846 832 sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); 847 - 848 - device_init_wakeup(&pdev->dev, 0); 849 833 850 834 return 0; 851 835 }
+3 -4
drivers/input/keyboard/gpio_keys_polled.c
··· 252 252 253 253 size = sizeof(struct gpio_keys_polled_dev) + 254 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 256 if (!bdev) { 257 257 dev_err(dev, "no memory for private data\n"); 258 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 262 if (!poll_dev) { 263 263 dev_err(dev, "no memory for polled device\n"); 264 264 return -ENOMEM; ··· 332 332 if (button->active_low) 333 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 336 flags, button->desc ? : DRV_NAME); 337 337 if (error) { 338 338 dev_err(dev, ··· 365 365 bdev->poll_dev = poll_dev; 366 366 bdev->dev = dev; 367 367 bdev->pdata = pdata; 368 - platform_set_drvdata(pdev, bdev); 369 368 370 369 error = input_register_polled_device(poll_dev); 371 370 if (error) {
-2
drivers/input/keyboard/jornada680_kbd.c
··· 197 197 return -ENOMEM; 198 198 } 199 199 200 - platform_set_drvdata(pdev, jornadakbd); 201 - 202 200 jornadakbd->poll_dev = poll_dev; 203 201 204 202 memcpy(jornadakbd->keymap, jornada_scancodes,
+1 -1
drivers/input/keyboard/lpc32xx-keys.c
··· 145 145 u32 rows = 0, columns = 0; 146 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 149 if (err) 150 150 return err; 151 151 if (rows != columns) {
-1
drivers/input/keyboard/maple_keyb.c
··· 196 196 __clear_bit(KEY_RESERVED, idev->keybit); 197 197 198 198 input_set_capability(idev, EV_MSC, MSC_SCAN); 199 - input_set_drvdata(idev, kbd); 200 199 201 200 error = input_register_device(idev); 202 201 if (error)
-2
drivers/input/keyboard/matrix_keypad.c
··· 545 545 { 546 546 struct matrix_keypad *keypad = platform_get_drvdata(pdev); 547 547 548 - device_init_wakeup(&pdev->dev, 0); 549 - 550 548 matrix_keypad_free_gpio(keypad); 551 549 input_unregister_device(keypad->input_dev); 552 550 kfree(keypad);
-1
drivers/input/keyboard/max7359_keypad.c
··· 241 241 /* Initialize MAX7359 */ 242 242 max7359_initialize(client); 243 243 244 - i2c_set_clientdata(client, keypad); 245 244 device_init_wakeup(&client->dev, 1); 246 245 247 246 return 0;
+116 -62
drivers/input/keyboard/mpr121_touchkey.c
··· 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 15 #include <linux/bitops.h> 16 + #include <linux/delay.h> 17 + #include <linux/i2c.h> 18 + #include <linux/input.h> 21 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 26 /* Register definitions */ 25 27 #define ELE_TOUCH_STATUS_0_ADDR 0x0 ··· 61 59 struct mpr121_touchkey { 62 60 struct i2c_client *client; 63 61 struct input_dev *input_dev; 64 - unsigned int key_val; 65 62 unsigned int statusbits; 66 63 unsigned int keycount; 67 - u16 keycodes[MPR121_MAX_KEY_COUNT]; 64 + u32 keycodes[MPR121_MAX_KEY_COUNT]; 68 65 }; 69 66 70 67 struct mpr121_init_register { ··· 83 82 { AUTO_CONFIG_CTRL_ADDR, 0x0b }, 84 83 }; 85 84 85 + static void mpr121_vdd_supply_disable(void *data) 86 + { 87 + struct regulator *vdd_supply = data; 88 + 89 + regulator_disable(vdd_supply); 90 + } 91 + 92 + static struct regulator *mpr121_vdd_supply_init(struct device *dev) 93 + { 94 + struct regulator *vdd_supply; 95 + int err; 96 + 97 + vdd_supply = devm_regulator_get(dev, "vdd"); 98 + if (IS_ERR(vdd_supply)) { 99 + dev_err(dev, "failed to get vdd regulator: %ld\n", 100 + PTR_ERR(vdd_supply)); 101 + return vdd_supply; 102 + } 103 + 104 + err = regulator_enable(vdd_supply); 105 + if (err) { 106 + dev_err(dev, "failed to enable vdd regulator: %d\n", err); 107 + return ERR_PTR(err); 108 + } 109 + 110 + err = devm_add_action(dev, mpr121_vdd_supply_disable, vdd_supply); 111 + if (err) { 112 + regulator_disable(vdd_supply); 113 + dev_err(dev, "failed to add disable regulator action: %d\n", 114 + err); 115 + return ERR_PTR(err); 116 + } 117 + 118 + return vdd_supply; 119 + } 120 + 86 121 static irqreturn_t mpr_touchkey_interrupt(int irq, void *dev_id) 87 122 { 88 123 struct mpr121_touchkey *mpr121 = dev_id; 89 124 struct i2c_client *client = mpr121->client; 90 125 struct input_dev *input = mpr121->input_dev; 91 - unsigned int key_num, key_val, pressed; 126 + unsigned long bit_changed; 127 + unsigned int key_num; 92 128 int reg; 93 129 94 130 reg = i2c_smbus_read_byte_data(client, ELE_TOUCH_STATUS_1_ADDR); ··· 143 105 144 106 reg &= TOUCH_STATUS_MASK; 145 107 /* use old press bit to figure out which bit changed */ 146 - key_num = ffs(reg ^ mpr121->statusbits) - 1; 147 - pressed = reg & (1 << key_num); 108 + bit_changed = reg ^ mpr121->statusbits; 148 109 mpr121->statusbits = reg; 110 + for_each_set_bit(key_num, &bit_changed, mpr121->keycount) { 111 + unsigned int key_val, pressed; 149 112 150 - key_val = mpr121->keycodes[key_num]; 113 + pressed = reg & BIT(key_num); 114 + key_val = mpr121->keycodes[key_num]; 151 115 152 - input_event(input, EV_MSC, MSC_SCAN, key_num); 153 - input_report_key(input, key_val, pressed); 116 + input_event(input, EV_MSC, MSC_SCAN, key_num); 117 + input_report_key(input, key_val, pressed); 118 + 119 + dev_dbg(&client->dev, "key %d %d %s\n", key_num, key_val, 120 + pressed ? "pressed" : "released"); 121 + 122 + } 154 123 input_sync(input); 155 - 156 - dev_dbg(&client->dev, "key %d %d %s\n", key_num, key_val, 157 - pressed ? "pressed" : "released"); 158 124 159 125 out: 160 126 return IRQ_HANDLED; 161 127 } 162 128 163 - static int mpr121_phys_init(const struct mpr121_platform_data *pdata, 164 - struct mpr121_touchkey *mpr121, 165 - struct i2c_client *client) 129 + static int mpr121_phys_init(struct mpr121_touchkey *mpr121, 130 + struct i2c_client *client, int vdd_uv) 166 131 { 167 132 const struct mpr121_init_register *reg; 168 133 unsigned char usl, lsl, tl, eleconf; ··· 195 154 /* 196 155 * Capacitance on sensing input varies and needs to be compensated. 197 156 * The internal MPR121-auto-configuration can do this if it's 198 - * registers are set properly (based on pdata->vdd_uv). 157 + * registers are set properly (based on vdd_uv). 199 158 */ 200 - vdd = pdata->vdd_uv / 1000; 159 + vdd = vdd_uv / 1000; 201 160 usl = ((vdd - 700) * 256) / vdd; 202 161 lsl = (usl * 65) / 100; 203 162 tl = (usl * 90) / 100; ··· 228 187 static int mpr_touchkey_probe(struct i2c_client *client, 229 188 const struct i2c_device_id *id) 230 189 { 231 - const struct mpr121_platform_data *pdata = 232 - dev_get_platdata(&client->dev); 190 + struct device *dev = &client->dev; 191 + struct regulator *vdd_supply; 192 + int vdd_uv; 233 193 struct mpr121_touchkey *mpr121; 234 194 struct input_dev *input_dev; 235 195 int error; 236 196 int i; 237 197 238 - if (!pdata) { 239 - dev_err(&client->dev, "no platform data defined\n"); 240 - return -EINVAL; 241 - } 242 - 243 - if (!pdata->keymap || !pdata->keymap_size) { 244 - dev_err(&client->dev, "missing keymap data\n"); 245 - return -EINVAL; 246 - } 247 - 248 - if (pdata->keymap_size > MPR121_MAX_KEY_COUNT) { 249 - dev_err(&client->dev, "too many keys defined\n"); 250 - return -EINVAL; 251 - } 252 - 253 198 if (!client->irq) { 254 - dev_err(&client->dev, "irq number should not be zero\n"); 199 + dev_err(dev, "irq number should not be zero\n"); 255 200 return -EINVAL; 256 201 } 257 202 258 - mpr121 = devm_kzalloc(&client->dev, sizeof(*mpr121), 259 - GFP_KERNEL); 203 + vdd_supply = mpr121_vdd_supply_init(dev); 204 + if (IS_ERR(vdd_supply)) 205 + return PTR_ERR(vdd_supply); 206 + 207 + vdd_uv = regulator_get_voltage(vdd_supply); 208 + 209 + mpr121 = devm_kzalloc(dev, sizeof(*mpr121), GFP_KERNEL); 260 210 if (!mpr121) 261 211 return -ENOMEM; 262 212 263 - input_dev = devm_input_allocate_device(&client->dev); 213 + input_dev = devm_input_allocate_device(dev); 264 214 if (!input_dev) 265 215 return -ENOMEM; 266 216 267 217 mpr121->client = client; 268 218 mpr121->input_dev = input_dev; 269 - mpr121->keycount = pdata->keymap_size; 219 + mpr121->keycount = device_property_read_u32_array(dev, "linux,keycodes", 220 + NULL, 0); 221 + if (mpr121->keycount > MPR121_MAX_KEY_COUNT) { 222 + dev_err(dev, "too many keys defined (%d)\n", mpr121->keycount); 223 + return -EINVAL; 224 + } 225 + 226 + error = device_property_read_u32_array(dev, "linux,keycodes", 227 + mpr121->keycodes, 228 + mpr121->keycount); 229 + if (error) { 230 + dev_err(dev, 231 + "failed to read linux,keycode property: %d\n", error); 232 + return error; 233 + } 270 234 271 235 input_dev->name = "Freescale MPR121 Touchkey"; 272 236 input_dev->id.bustype = BUS_I2C; 273 - input_dev->dev.parent = &client->dev; 274 - input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); 237 + input_dev->dev.parent = dev; 238 + if (device_property_read_bool(dev, "autorepeat")) 239 + __set_bit(EV_REP, input_dev->evbit); 240 + input_set_capability(input_dev, EV_MSC, MSC_SCAN); 275 241 276 242 input_dev->keycode = mpr121->keycodes; 277 243 input_dev->keycodesize = sizeof(mpr121->keycodes[0]); 278 244 input_dev->keycodemax = mpr121->keycount; 279 245 280 - for (i = 0; i < pdata->keymap_size; i++) { 281 - input_set_capability(input_dev, EV_KEY, pdata->keymap[i]); 282 - mpr121->keycodes[i] = pdata->keymap[i]; 283 - } 246 + for (i = 0; i < mpr121->keycount; i++) 247 + input_set_capability(input_dev, EV_KEY, mpr121->keycodes[i]); 284 248 285 - error = mpr121_phys_init(pdata, mpr121, client); 249 + error = mpr121_phys_init(mpr121, client, vdd_uv); 286 250 if (error) { 287 - dev_err(&client->dev, "Failed to init register\n"); 251 + dev_err(dev, "Failed to init register\n"); 288 252 return error; 289 253 } 290 254 291 - error = devm_request_threaded_irq(&client->dev, client->irq, NULL, 292 - mpr_touchkey_interrupt, 293 - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 294 - client->dev.driver->name, mpr121); 255 + error = devm_request_threaded_irq(dev, client->irq, NULL, 256 + mpr_touchkey_interrupt, 257 + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 258 + dev->driver->name, mpr121); 295 259 if (error) { 296 - dev_err(&client->dev, "Failed to register interrupt\n"); 260 + dev_err(dev, "Failed to register interrupt\n"); 297 261 return error; 298 262 } 299 263 ··· 307 261 return error; 308 262 309 263 i2c_set_clientdata(client, mpr121); 310 - device_init_wakeup(&client->dev, pdata->wakeup); 264 + device_init_wakeup(dev, 265 + device_property_read_bool(dev, "wakeup-source")); 311 266 312 267 return 0; 313 268 } 314 269 315 - #ifdef CONFIG_PM_SLEEP 316 - static int mpr_suspend(struct device *dev) 270 + static int __maybe_unused mpr_suspend(struct device *dev) 317 271 { 318 272 struct i2c_client *client = to_i2c_client(dev); 319 273 ··· 325 279 return 0; 326 280 } 327 281 328 - static int mpr_resume(struct device *dev) 282 + static int __maybe_unused mpr_resume(struct device *dev) 329 283 { 330 284 struct i2c_client *client = to_i2c_client(dev); 331 285 struct mpr121_touchkey *mpr121 = i2c_get_clientdata(client); ··· 338 292 339 293 return 0; 340 294 } 341 - #endif 342 295 343 296 static SIMPLE_DEV_PM_OPS(mpr121_touchkey_pm_ops, mpr_suspend, mpr_resume); 344 297 ··· 347 302 }; 348 303 MODULE_DEVICE_TABLE(i2c, mpr121_id); 349 304 305 + #ifdef CONFIG_OF 306 + static const struct of_device_id mpr121_touchkey_dt_match_table[] = { 307 + { .compatible = "fsl,mpr121-touchkey" }, 308 + { }, 309 + }; 310 + MODULE_DEVICE_TABLE(of, mpr121_touchkey_dt_match_table); 311 + #endif 312 + 350 313 static struct i2c_driver mpr_touchkey_driver = { 351 314 .driver = { 352 315 .name = "mpr121", 353 316 .pm = &mpr121_touchkey_pm_ops, 317 + .of_match_table = of_match_ptr(mpr121_touchkey_dt_match_table), 354 318 }, 355 319 .id_table = mpr121_id, 356 320 .probe = mpr_touchkey_probe,
-2
drivers/input/keyboard/nspire-keypad.c
··· 249 249 return error; 250 250 } 251 251 252 - platform_set_drvdata(pdev, keypad); 253 - 254 252 dev_dbg(&pdev->dev, 255 253 "TI-NSPIRE keypad at %pR (scan_interval=%uus, row_delay=%uus%s)\n", 256 254 res, keypad->row_delay, keypad->scan_interval,
+2 -5
drivers/input/keyboard/omap4-keypad.c
··· 223 223 struct device_node *np = dev->of_node; 224 224 int err; 225 225 226 - err = matrix_keypad_parse_of_params(dev, &keypad_data->rows, 227 - &keypad_data->cols); 226 + err = matrix_keypad_parse_properties(dev, &keypad_data->rows, 227 + &keypad_data->cols); 228 228 if (err) 229 229 return err; 230 230 ··· 375 375 376 376 err_pm_disable: 377 377 pm_runtime_disable(&pdev->dev); 378 - device_init_wakeup(&pdev->dev, false); 379 378 free_irq(keypad_data->irq, keypad_data); 380 379 err_free_keymap: 381 380 kfree(keypad_data->keymap); ··· 399 400 free_irq(keypad_data->irq, keypad_data); 400 401 401 402 pm_runtime_disable(&pdev->dev); 402 - 403 - device_init_wakeup(&pdev->dev, false); 404 403 405 404 input_unregister_device(keypad_data->input); 406 405
-4
drivers/input/keyboard/opencores-kbd.c
··· 75 75 input->name = pdev->name; 76 76 input->phys = "opencores-kbd/input0"; 77 77 78 - input_set_drvdata(input, opencores_kbd); 79 - 80 78 input->id.bustype = BUS_HOST; 81 79 input->id.vendor = 0x0001; 82 80 input->id.product = 0x0001; ··· 109 111 dev_err(&pdev->dev, "unable to register input device\n"); 110 112 return error; 111 113 } 112 - 113 - platform_set_drvdata(pdev, opencores_kbd); 114 114 115 115 return 0; 116 116 }
+1 -1
drivers/input/keyboard/pmic8xxx-keypad.c
··· 515 515 int rc; 516 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 519 if (rc) 520 520 return rc; 521 521
+1 -1
drivers/input/keyboard/pxa27x_keypad.c
··· 126 126 u32 rows, cols; 127 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 130 if (error) 131 131 return error; 132 132
-2
drivers/input/keyboard/samsung-keypad.c
··· 445 445 446 446 err_disable_runtime_pm: 447 447 pm_runtime_disable(&pdev->dev); 448 - device_init_wakeup(&pdev->dev, 0); 449 448 err_unprepare_clk: 450 449 clk_unprepare(keypad->clk); 451 450 return error; ··· 455 456 struct samsung_keypad *keypad = platform_get_drvdata(pdev); 456 457 457 458 pm_runtime_disable(&pdev->dev); 458 - device_init_wakeup(&pdev->dev, 0); 459 459 460 460 input_unregister_device(keypad->input_dev); 461 461
-2
drivers/input/keyboard/spear-keyboard.c
··· 283 283 input_unregister_device(kbd->input); 284 284 clk_unprepare(kbd->clk); 285 285 286 - device_init_wakeup(&pdev->dev, 0); 287 - 288 286 return 0; 289 287 } 290 288
+2 -2
drivers/input/keyboard/st-keyscan.c
··· 106 106 struct device_node *np = dev->of_node; 107 107 int error; 108 108 109 - error = matrix_keypad_parse_of_params(dev, &keypad_data->n_rows, 110 - &keypad_data->n_cols); 109 + error = matrix_keypad_parse_properties(dev, &keypad_data->n_rows, 110 + &keypad_data->n_cols); 111 111 if (error) { 112 112 dev_err(dev, "failed to parse keypad params\n"); 113 113 return error;
+1 -1
drivers/input/keyboard/stmpe-keypad.c
··· 354 354 input->id.bustype = BUS_I2C; 355 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 358 if (error) 359 359 return error; 360 360
-1
drivers/input/keyboard/sun4i-lradc-keys.c
··· 261 261 if (error) 262 262 return error; 263 263 264 - platform_set_drvdata(pdev, lradc); 265 264 return 0; 266 265 } 267 266
+26 -66
drivers/input/keyboard/tca8418_keypad.c
··· 24 24 * alternative licensing inquiries. 25 25 */ 26 26 27 - #include <linux/types.h> 28 - #include <linux/module.h> 29 - #include <linux/init.h> 30 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 28 #include <linux/i2c.h> 29 + #include <linux/init.h> 36 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 34 #include <linux/of.h> 35 + #include <linux/property.h> 36 + #include <linux/slab.h> 37 + #include <linux/types.h> 39 38 40 39 /* TCA8418 hardware limits */ 41 40 #define TCA8418_MAX_ROWS 8 ··· 263 264 } 264 265 265 266 static int tca8418_keypad_probe(struct i2c_client *client, 266 - const struct i2c_device_id *id) 267 + const struct i2c_device_id *id) 267 268 { 268 269 struct device *dev = &client->dev; 269 - const struct tca8418_keypad_platform_data *pdata = 270 - dev_get_platdata(dev); 271 270 struct tca8418_keypad *keypad_data; 272 271 struct input_dev *input; 273 - const struct matrix_keymap_data *keymap_data = NULL; 274 272 u32 rows = 0, cols = 0; 275 - bool rep = false; 276 - bool irq_is_gpio = false; 277 - int irq; 278 273 int error, row_shift, max_keys; 279 274 280 - /* Copy the platform data */ 281 - if (pdata) { 282 - if (!pdata->keymap_data) { 283 - dev_err(dev, "no keymap data defined\n"); 284 - return -EINVAL; 285 - } 286 - keymap_data = pdata->keymap_data; 287 - rows = pdata->rows; 288 - cols = pdata->cols; 289 - rep = pdata->rep; 290 - irq_is_gpio = pdata->irq_is_gpio; 291 - } else { 292 - struct device_node *np = dev->of_node; 293 - int err; 294 - 295 - err = matrix_keypad_parse_of_params(dev, &rows, &cols); 296 - if (err) 297 - return err; 298 - rep = of_property_read_bool(np, "keypad,autorepeat"); 275 + /* Check i2c driver capabilities */ 276 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) { 277 + dev_err(dev, "%s adapter not supported\n", 278 + dev_driver_string(&client->adapter->dev)); 279 + return -ENODEV; 299 280 } 281 + 282 + error = matrix_keypad_parse_properties(dev, &rows, &cols); 283 + if (error) 284 + return error; 300 285 301 286 if (!rows || rows > TCA8418_MAX_ROWS) { 302 287 dev_err(dev, "invalid rows\n"); ··· 290 307 if (!cols || cols > TCA8418_MAX_COLS) { 291 308 dev_err(dev, "invalid columns\n"); 292 309 return -EINVAL; 293 - } 294 - 295 - /* Check i2c driver capabilities */ 296 - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) { 297 - dev_err(dev, "%s adapter not supported\n", 298 - dev_driver_string(&client->adapter->dev)); 299 - return -ENODEV; 300 310 } 301 311 302 312 row_shift = get_count_order(cols); ··· 321 345 input->id.product = 0x001; 322 346 input->id.version = 0x0001; 323 347 324 - error = matrix_keypad_build_keymap(keymap_data, NULL, rows, cols, 325 - NULL, input); 348 + error = matrix_keypad_build_keymap(NULL, NULL, rows, cols, NULL, input); 326 349 if (error) { 327 350 dev_err(dev, "Failed to build keymap\n"); 328 351 return error; 329 352 } 330 353 331 - if (rep) 354 + if (device_property_read_bool(dev, "keypad,autorepeat")) 332 355 __set_bit(EV_REP, input->evbit); 356 + 333 357 input_set_capability(input, EV_MSC, MSC_SCAN); 334 358 335 - input_set_drvdata(input, keypad_data); 336 - 337 - irq = client->irq; 338 - if (irq_is_gpio) 339 - irq = gpio_to_irq(irq); 340 - 341 - error = devm_request_threaded_irq(dev, irq, NULL, tca8418_irq_handler, 342 - IRQF_TRIGGER_FALLING | 343 - IRQF_SHARED | 344 - IRQF_ONESHOT, 359 + error = devm_request_threaded_irq(dev, client->irq, 360 + NULL, tca8418_irq_handler, 361 + IRQF_SHARED | IRQF_ONESHOT, 345 362 client->name, keypad_data); 346 363 if (error) { 347 364 dev_err(dev, "Unable to claim irq %d; error %d\n", ··· 353 384 } 354 385 355 386 static const struct i2c_device_id tca8418_id[] = { 356 - { TCA8418_NAME, 8418, }, 387 + { "tca8418", 8418, }, 357 388 { } 358 389 }; 359 390 MODULE_DEVICE_TABLE(i2c, tca8418_id); 360 391 361 - #ifdef CONFIG_OF 362 392 static const struct of_device_id tca8418_dt_ids[] = { 363 393 { .compatible = "ti,tca8418", }, 364 394 { } 365 395 }; 366 396 MODULE_DEVICE_TABLE(of, tca8418_dt_ids); 367 397 368 - /* 369 - * The device tree based i2c loader looks for 370 - * "i2c:" + second_component_of(property("compatible")) 371 - * and therefore we need an alias to be found. 372 - */ 373 - MODULE_ALIAS("i2c:tca8418"); 374 - #endif 375 - 376 398 static struct i2c_driver tca8418_keypad_driver = { 377 399 .driver = { 378 - .name = TCA8418_NAME, 379 - .of_match_table = of_match_ptr(tca8418_dt_ids), 400 + .name = "tca8418_keypad", 401 + .of_match_table = tca8418_dt_ids, 380 402 }, 381 403 .probe = tca8418_keypad_probe, 382 404 .id_table = tca8418_id,
+284
drivers/input/keyboard/tm2-touchkey.c
··· 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");
+2 -3
drivers/input/keyboard/twl4030_keypad.c
··· 374 374 kp->autorepeat = pdata->rep; 375 375 keymap_data = pdata->keymap_data; 376 376 } else { 377 - error = matrix_keypad_parse_of_params(&pdev->dev, &kp->n_rows, 378 - &kp->n_cols); 377 + error = matrix_keypad_parse_properties(&pdev->dev, &kp->n_rows, 378 + &kp->n_cols); 379 379 if (error) 380 380 return error; 381 381 ··· 441 441 return -EIO; 442 442 } 443 443 444 - platform_set_drvdata(pdev, kp); 445 444 return 0; 446 445 } 447 446
+58 -55
drivers/input/matrix-keymap.c
··· 14 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 16 * GNU General Public License for more details. 17 - * 18 17 */ 19 18 20 19 #include <linux/device.h> 21 - #include <linux/gfp.h> 22 - #include <linux/kernel.h> 23 - #include <linux/types.h> 24 - #include <linux/input.h> 25 - #include <linux/of.h> 26 20 #include <linux/export.h> 27 - #include <linux/module.h> 21 + #include <linux/gfp.h> 22 + #include <linux/input.h> 28 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 30 static bool matrix_keypad_map_key(struct input_dev *input_dev, 31 31 unsigned int rows, unsigned int cols, ··· 49 49 return true; 50 50 } 51 51 52 - #ifdef CONFIG_OF 53 - int matrix_keypad_parse_of_params(struct device *dev, 54 - unsigned int *rows, unsigned int *cols) 52 + /** 53 + * matrix_keypad_parse_properties() - Read properties of matrix keypad 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; 57 64 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); 65 + device_property_read_u32(dev, "keypad,num-rows", rows); 66 + device_property_read_u32(dev, "keypad,num-columns", cols); 67 + 64 68 if (!*rows || !*cols) { 65 69 dev_err(dev, "number of keypad rows/columns not specified\n"); 66 70 return -EINVAL; ··· 72 68 73 69 return 0; 74 70 } 75 - EXPORT_SYMBOL_GPL(matrix_keypad_parse_of_params); 71 + EXPORT_SYMBOL_GPL(matrix_keypad_parse_properties); 76 72 77 - static int matrix_keypad_parse_of_keymap(const char *propname, 78 - unsigned int rows, unsigned int cols, 79 - struct input_dev *input_dev) 73 + static int matrix_keypad_parse_keymap(const char *propname, 74 + unsigned int rows, unsigned int cols, 75 + struct input_dev *input_dev) 80 76 { 81 77 struct device *dev = input_dev->dev.parent; 82 - struct device_node *np = dev->of_node; 83 78 unsigned int row_shift = get_count_order(cols); 84 79 unsigned int max_keys = rows << row_shift; 85 - unsigned int proplen, i, size; 86 - const __be32 *prop; 87 - 88 - if (!np) 89 - return -ENOENT; 80 + u32 *keys; 81 + int i; 82 + int size; 83 + int retval; 90 84 91 85 if (!propname) 92 86 propname = "linux,keymap"; 93 87 94 - prop = of_get_property(np, propname, &proplen); 95 - if (!prop) { 96 - dev_err(dev, "OF: %s property not defined in %s\n", 97 - propname, np->full_name); 98 - return -ENOENT; 88 + size = device_property_read_u32_array(dev, propname, NULL, 0); 89 + if (size <= 0) { 90 + dev_err(dev, "missing or malformed property %s: %d\n", 91 + propname, size); 92 + return size < 0 ? size : -EINVAL; 99 93 } 100 94 101 - if (proplen % sizeof(u32)) { 102 - dev_err(dev, "OF: Malformed keycode property %s in %s\n", 103 - propname, np->full_name); 104 - return -EINVAL; 105 - } 106 - 107 - size = proplen / sizeof(u32); 108 95 if (size > max_keys) { 109 - dev_err(dev, "OF: %s size overflow\n", propname); 96 + dev_err(dev, "%s size overflow (%d vs max %u)\n", 97 + propname, size, max_keys); 110 98 return -EINVAL; 99 + } 100 + 101 + keys = kmalloc_array(size, sizeof(u32), GFP_KERNEL); 102 + if (!keys) 103 + return -ENOMEM; 104 + 105 + retval = device_property_read_u32_array(dev, propname, keys, size); 106 + if (retval) { 107 + dev_err(dev, "failed to read %s property: %d\n", 108 + propname, retval); 109 + goto out; 111 110 } 112 111 113 112 for (i = 0; i < size; i++) { 114 - unsigned int key = be32_to_cpup(prop + i); 115 - 116 113 if (!matrix_keypad_map_key(input_dev, rows, cols, 117 - row_shift, key)) 118 - return -EINVAL; 114 + row_shift, keys[i])) { 115 + retval = -EINVAL; 116 + goto out; 117 + } 119 118 } 120 119 121 - return 0; 120 + retval = 0; 121 + 122 + out: 123 + kfree(keys); 124 + return retval; 122 125 } 123 - #else 124 - static int matrix_keypad_parse_of_keymap(const char *propname, 125 - unsigned int rows, unsigned int cols, 126 - struct input_dev *input_dev) 127 - { 128 - return -ENOSYS; 129 - } 130 - #endif 131 126 132 127 /** 133 128 * matrix_keypad_build_keymap - convert platform keymap into matrix keymap ··· 195 192 return -EINVAL; 196 193 } 197 194 } else { 198 - error = matrix_keypad_parse_of_keymap(keymap_name, rows, cols, 199 - input_dev); 195 + error = matrix_keypad_parse_keymap(keymap_name, rows, cols, 196 + input_dev); 200 197 if (error) 201 198 return error; 202 199 }
-1
drivers/input/misc/88pm80x_onkey.c
··· 143 143 { 144 144 struct pm80x_onkey_info *info = platform_get_drvdata(pdev); 145 145 146 - device_init_wakeup(&pdev->dev, 0); 147 146 pm80x_free_irq(info->pm80x, info->irq, info); 148 147 input_unregister_device(info->idev); 149 148 kfree(info);
-10
drivers/input/misc/Kconfig
··· 234 234 To compile this driver as a module, choose M here: the 235 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 237 config INPUT_APANEL 248 238 tristate "Fujitsu Lifebook Application Panel buttons" 249 239 depends on X86 && I2C && LEDS_CLASS
-1
drivers/input/misc/Makefile
··· 48 48 obj-$(CONFIG_INPUT_MAX8997_HAPTIC) += max8997_haptic.o 49 49 obj-$(CONFIG_INPUT_MC13783_PWRBUTTON) += mc13783-pwrbutton.o 50 50 obj-$(CONFIG_INPUT_MMA8450) += mma8450.o 51 - obj-$(CONFIG_INPUT_MPU3050) += mpu3050.o 52 51 obj-$(CONFIG_INPUT_PALMAS_PWRBUTTON) += palmas-pwrbutton.o 53 52 obj-$(CONFIG_INPUT_PCAP) += pcap_keys.o 54 53 obj-$(CONFIG_INPUT_PCF50633_PMU) += pcf50633-input.o
-1
drivers/input/misc/ab8500-ponkey.c
··· 109 109 return error; 110 110 } 111 111 112 - platform_set_drvdata(pdev, ponkey); 113 112 return 0; 114 113 } 115 114
-2
drivers/input/misc/arizona-haptics.c
··· 201 201 return ret; 202 202 } 203 203 204 - platform_set_drvdata(pdev, haptics); 205 - 206 204 return 0; 207 205 } 208 206
-1
drivers/input/misc/atmel_captouch.c
··· 191 191 return -ENOMEM; 192 192 193 193 capdev->client = client; 194 - i2c_set_clientdata(client, capdev); 195 194 196 195 err = atmel_read(capdev, REG_KEY_STATE, 197 196 &capdev->prev_btn, sizeof(capdev->prev_btn));
+5 -6
drivers/input/misc/bfin_rotary.c
··· 147 147 148 148 if (pdata->pin_list) { 149 149 error = peripheral_request_list(pdata->pin_list, 150 - dev_name(&pdev->dev)); 150 + dev_name(dev)); 151 151 if (error) { 152 152 dev_err(dev, "requesting peripherals failed: %d\n", 153 153 error); 154 154 return error; 155 155 } 156 156 157 - error = devm_add_action(dev, bfin_rotary_free_action, 158 - pdata->pin_list); 157 + error = devm_add_action_or_reset(dev, bfin_rotary_free_action, 158 + pdata->pin_list); 159 159 if (error) { 160 160 dev_err(dev, "setting cleanup action failed: %d\n", 161 161 error); 162 - peripheral_free_list(pdata->pin_list); 163 162 return error; 164 163 } 165 164 } ··· 188 189 189 190 input->name = pdev->name; 190 191 input->phys = "bfin-rotary/input0"; 191 - input->dev.parent = &pdev->dev; 192 + input->dev.parent = dev; 192 193 193 194 input_set_drvdata(input, rotary); 194 195 ··· 238 239 } 239 240 240 241 platform_set_drvdata(pdev, rotary); 241 - device_init_wakeup(&pdev->dev, 1); 242 + device_init_wakeup(dev, 1); 242 243 243 244 return 0; 244 245 }
+2 -2
drivers/input/misc/bma150.c
··· 207 207 return error; 208 208 209 209 if (mode == BMA150_MODE_NORMAL) 210 - msleep(2); 210 + usleep_range(2000, 2100); 211 211 212 212 bma150->mode = mode; 213 213 return 0; ··· 222 222 if (error) 223 223 return error; 224 224 225 - msleep(2); 225 + usleep_range(2000, 2100); 226 226 return 0; 227 227 } 228 228
-1
drivers/input/misc/da9063_onkey.c
··· 287 287 return error; 288 288 } 289 289 290 - platform_set_drvdata(pdev, onkey); 291 290 return 0; 292 291 } 293 292
-2
drivers/input/misc/dm355evm_keys.c
··· 195 195 goto fail1; 196 196 keys->irq = status; 197 197 198 - input_set_drvdata(input, keys); 199 - 200 198 input->name = "DM355 EVM Controls"; 201 199 input->phys = "dm355evm/input0"; 202 200 input->dev.parent = &pdev->dev;
+1 -1
drivers/input/misc/drv260x.c
··· 538 538 539 539 haptics->input_dev = devm_input_allocate_device(dev); 540 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 542 return -ENOMEM; 543 543 } 544 544
-8
drivers/input/misc/e3x0-button.c
··· 120 120 return error; 121 121 } 122 122 123 - platform_set_drvdata(pdev, input); 124 123 device_init_wakeup(&pdev->dev, 1); 125 - return 0; 126 - } 127 - 128 - static int e3x0_button_remove(struct platform_device *pdev) 129 - { 130 - device_init_wakeup(&pdev->dev, 0); 131 124 return 0; 132 125 } 133 126 ··· 139 146 .pm = &e3x0_button_pm_ops, 140 147 }, 141 148 .probe = e3x0_button_probe, 142 - .remove = e3x0_button_remove, 143 149 }; 144 150 145 151 module_platform_driver(e3x0_button_driver);
-2
drivers/input/misc/gp2ap002a00f.c
··· 210 210 struct gp2a_data *dt = i2c_get_clientdata(client); 211 211 const struct gp2a_platform_data *pdata = dt->pdata; 212 212 213 - device_init_wakeup(&client->dev, false); 214 - 215 213 free_irq(client->irq, dt); 216 214 217 215 input_unregister_device(dt->input);
-1
drivers/input/misc/gpio_decoder.c
··· 110 110 dev_err(dev, "failed to register polled device\n"); 111 111 return err; 112 112 } 113 - platform_set_drvdata(pdev, decoder); 114 113 115 114 return 0; 116 115 }
+1 -1
drivers/input/misc/gpio_tilt_polled.c
··· 138 138 139 139 input->name = pdev->name; 140 140 input->phys = DRV_NAME"/input0"; 141 - input->dev.parent = &pdev->dev; 141 + input->dev.parent = dev; 142 142 143 143 input->id.bustype = BUS_HOST; 144 144 input->id.vendor = 0x0001;
+4 -13
drivers/input/misc/hisi_powerkey.c
··· 75 75 struct input_dev *input; 76 76 int irq, i, error; 77 77 78 - input = devm_input_allocate_device(&pdev->dev); 78 + input = devm_input_allocate_device(dev); 79 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 81 return -ENOMEM; 82 82 } 83 83 ··· 111 111 112 112 error = input_register_device(input); 113 113 if (error) { 114 - dev_err(&pdev->dev, "failed to register input device: %d\n", 115 - error); 114 + dev_err(dev, "failed to register input device: %d\n", error); 116 115 return error; 117 116 } 118 117 119 - device_init_wakeup(&pdev->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); 118 + device_init_wakeup(dev, 1); 127 119 128 120 return 0; 129 121 } ··· 125 133 .name = "hi65xx-powerkey", 126 134 }, 127 135 .probe = hi65xx_powerkey_probe, 128 - .remove = hi65xx_powerkey_remove, 129 136 }; 130 137 module_platform_driver(hi65xx_powerkey_driver); 131 138
-2
drivers/input/misc/mma8450.c
··· 205 205 return err; 206 206 } 207 207 208 - i2c_set_clientdata(c, m); 209 - 210 208 return 0; 211 209 } 212 210
-481
drivers/input/misc/mpu3050.c
··· 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");
-1
drivers/input/misc/pm8941-pwrkey.c
··· 266 266 { 267 267 struct pm8941_pwrkey *pwrkey = platform_get_drvdata(pdev); 268 268 269 - device_init_wakeup(&pdev->dev, 0); 270 269 unregister_reboot_notifier(&pwrkey->reboot_notifier); 271 270 272 271 return 0;
-8
drivers/input/misc/pmic8xxx-pwrkey.c
··· 438 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 441 static const struct of_device_id pm8xxx_pwr_key_id_table[] = { 449 442 { .compatible = "qcom,pm8058-pwrkey", .data = &pm8058_pwrkey_shutdown }, 450 443 { .compatible = "qcom,pm8921-pwrkey", .data = &pm8921_pwrkey_shutdown }, ··· 447 454 448 455 static struct platform_driver pmic8xxx_pwrkey_driver = { 449 456 .probe = pmic8xxx_pwrkey_probe, 450 - .remove = pmic8xxx_pwrkey_remove, 451 457 .shutdown = pmic8xxx_pwrkey_shutdown, 452 458 .driver = { 453 459 .name = "pm8xxx-pwrkey",
+95 -63
drivers/input/misc/pwm-beeper.c
··· 14 14 */ 15 15 16 16 #include <linux/input.h> 17 + #include <linux/regulator/consumer.h> 17 18 #include <linux/module.h> 18 19 #include <linux/kernel.h> 19 20 #include <linux/of.h> ··· 26 25 struct pwm_beeper { 27 26 struct input_dev *input; 28 27 struct pwm_device *pwm; 28 + struct regulator *amplifier; 29 29 struct work_struct work; 30 30 unsigned long period; 31 + bool suspended; 32 + bool amplifier_on; 31 33 }; 32 34 33 35 #define HZ_TO_NANOSECONDS(x) (1000000000UL/(x)) 34 36 35 - static void __pwm_beeper_set(struct pwm_beeper *beeper) 37 + static int pwm_beeper_on(struct pwm_beeper *beeper, unsigned long period) 36 38 { 37 - unsigned long period = beeper->period; 39 + struct pwm_state state; 40 + int error; 38 41 39 - if (period) { 40 - pwm_config(beeper->pwm, period / 2, period); 41 - pwm_enable(beeper->pwm); 42 - } else 43 - pwm_disable(beeper->pwm); 42 + pwm_get_state(beeper->pwm, &state); 43 + 44 + state.enabled = true; 45 + state.period = period; 46 + pwm_set_relative_duty_cycle(&state, 50, 100); 47 + 48 + error = pwm_apply_state(beeper->pwm, &state); 49 + if (error) 50 + return error; 51 + 52 + if (!beeper->amplifier_on) { 53 + error = regulator_enable(beeper->amplifier); 54 + if (error) { 55 + pwm_disable(beeper->pwm); 56 + return error; 57 + } 58 + 59 + beeper->amplifier_on = true; 60 + } 61 + 62 + return 0; 63 + } 64 + 65 + static void pwm_beeper_off(struct pwm_beeper *beeper) 66 + { 67 + if (beeper->amplifier_on) { 68 + regulator_disable(beeper->amplifier); 69 + beeper->amplifier_on = false; 70 + } 71 + 72 + pwm_disable(beeper->pwm); 44 73 } 45 74 46 75 static void pwm_beeper_work(struct work_struct *work) 47 76 { 48 - struct pwm_beeper *beeper = 49 - container_of(work, struct pwm_beeper, work); 77 + struct pwm_beeper *beeper = container_of(work, struct pwm_beeper, work); 78 + unsigned long period = READ_ONCE(beeper->period); 50 79 51 - __pwm_beeper_set(beeper); 80 + if (period) 81 + pwm_beeper_on(beeper, period); 82 + else 83 + pwm_beeper_off(beeper); 52 84 } 53 85 54 86 static int pwm_beeper_event(struct input_dev *input, ··· 107 73 else 108 74 beeper->period = HZ_TO_NANOSECONDS(value); 109 75 110 - schedule_work(&beeper->work); 76 + if (!beeper->suspended) 77 + schedule_work(&beeper->work); 111 78 112 79 return 0; 113 80 } ··· 116 81 static void pwm_beeper_stop(struct pwm_beeper *beeper) 117 82 { 118 83 cancel_work_sync(&beeper->work); 119 - 120 - if (beeper->period) 121 - pwm_disable(beeper->pwm); 84 + pwm_beeper_off(beeper); 122 85 } 123 86 124 87 static void pwm_beeper_close(struct input_dev *input) ··· 128 95 129 96 static int pwm_beeper_probe(struct platform_device *pdev) 130 97 { 131 - unsigned long pwm_id = (unsigned long)dev_get_platdata(&pdev->dev); 98 + struct device *dev = &pdev->dev; 132 99 struct pwm_beeper *beeper; 100 + struct pwm_state state; 133 101 int error; 134 102 135 - beeper = kzalloc(sizeof(*beeper), GFP_KERNEL); 103 + beeper = devm_kzalloc(dev, sizeof(*beeper), GFP_KERNEL); 136 104 if (!beeper) 137 105 return -ENOMEM; 138 106 139 - beeper->pwm = pwm_get(&pdev->dev, NULL); 140 - if (IS_ERR(beeper->pwm)) { 141 - dev_dbg(&pdev->dev, "unable to request PWM, trying legacy API\n"); 142 - beeper->pwm = pwm_request(pwm_id, "pwm beeper"); 143 - } 144 - 107 + beeper->pwm = devm_pwm_get(dev, NULL); 145 108 if (IS_ERR(beeper->pwm)) { 146 109 error = PTR_ERR(beeper->pwm); 147 - dev_err(&pdev->dev, "Failed to request pwm device: %d\n", error); 148 - goto err_free; 110 + if (error != -EPROBE_DEFER) 111 + dev_err(dev, "Failed to request PWM device: %d\n", 112 + error); 113 + return error; 149 114 } 150 115 151 - /* 152 - * FIXME: pwm_apply_args() should be removed when switching to 153 - * the atomic PWM API. 154 - */ 155 - pwm_apply_args(beeper->pwm); 116 + /* Sync up PWM state and ensure it is off. */ 117 + pwm_init_state(beeper->pwm, &state); 118 + state.enabled = false; 119 + error = pwm_apply_state(beeper->pwm, &state); 120 + if (error) { 121 + dev_err(dev, "failed to apply initial PWM state: %d\n", 122 + error); 123 + return error; 124 + } 125 + 126 + beeper->amplifier = devm_regulator_get(dev, "amp"); 127 + if (IS_ERR(beeper->amplifier)) { 128 + error = PTR_ERR(beeper->amplifier); 129 + if (error != -EPROBE_DEFER) 130 + dev_err(dev, "Failed to get 'amp' regulator: %d\n", 131 + error); 132 + return error; 133 + } 156 134 157 135 INIT_WORK(&beeper->work, pwm_beeper_work); 158 136 159 - beeper->input = input_allocate_device(); 137 + beeper->input = devm_input_allocate_device(dev); 160 138 if (!beeper->input) { 161 - dev_err(&pdev->dev, "Failed to allocate input device\n"); 162 - error = -ENOMEM; 163 - goto err_pwm_free; 139 + dev_err(dev, "Failed to allocate input device\n"); 140 + return -ENOMEM; 164 141 } 165 - beeper->input->dev.parent = &pdev->dev; 166 142 167 143 beeper->input->name = "pwm-beeper"; 168 144 beeper->input->phys = "pwm/input0"; ··· 180 138 beeper->input->id.product = 0x0001; 181 139 beeper->input->id.version = 0x0100; 182 140 183 - beeper->input->evbit[0] = BIT(EV_SND); 184 - beeper->input->sndbit[0] = BIT(SND_TONE) | BIT(SND_BELL); 141 + input_set_capability(beeper->input, EV_SND, SND_TONE); 142 + input_set_capability(beeper->input, EV_SND, SND_BELL); 185 143 186 144 beeper->input->event = pwm_beeper_event; 187 145 beeper->input->close = pwm_beeper_close; ··· 190 148 191 149 error = input_register_device(beeper->input); 192 150 if (error) { 193 - dev_err(&pdev->dev, "Failed to register input device: %d\n", error); 194 - goto err_input_free; 151 + dev_err(dev, "Failed to register input device: %d\n", error); 152 + return error; 195 153 } 196 154 197 155 platform_set_drvdata(pdev, beeper); 198 - 199 - return 0; 200 - 201 - err_input_free: 202 - input_free_device(beeper->input); 203 - err_pwm_free: 204 - pwm_free(beeper->pwm); 205 - err_free: 206 - kfree(beeper); 207 - 208 - return error; 209 - } 210 - 211 - static int pwm_beeper_remove(struct platform_device *pdev) 212 - { 213 - struct pwm_beeper *beeper = platform_get_drvdata(pdev); 214 - 215 - input_unregister_device(beeper->input); 216 - 217 - pwm_free(beeper->pwm); 218 - 219 - kfree(beeper); 220 156 221 157 return 0; 222 158 } ··· 202 182 static int __maybe_unused pwm_beeper_suspend(struct device *dev) 203 183 { 204 184 struct pwm_beeper *beeper = dev_get_drvdata(dev); 185 + 186 + /* 187 + * Spinlock is taken here is not to protect write to 188 + * beeper->suspended, but to ensure that pwm_beeper_event 189 + * does not re-submit work once flag is set. 190 + */ 191 + spin_lock_irq(&beeper->input->event_lock); 192 + beeper->suspended = true; 193 + spin_unlock_irq(&beeper->input->event_lock); 205 194 206 195 pwm_beeper_stop(beeper); 207 196 ··· 221 192 { 222 193 struct pwm_beeper *beeper = dev_get_drvdata(dev); 223 194 224 - if (beeper->period) 225 - __pwm_beeper_set(beeper); 195 + spin_lock_irq(&beeper->input->event_lock); 196 + beeper->suspended = false; 197 + spin_unlock_irq(&beeper->input->event_lock); 198 + 199 + /* Let worker figure out if we should resume beeping */ 200 + schedule_work(&beeper->work); 226 201 227 202 return 0; 228 203 } ··· 244 211 245 212 static struct platform_driver pwm_beeper_driver = { 246 213 .probe = pwm_beeper_probe, 247 - .remove = pwm_beeper_remove, 248 214 .driver = { 249 215 .name = "pwm-beeper", 250 216 .pm = &pwm_beeper_pm_ops,
-6
drivers/input/misc/retu-pwrbutton.c
··· 76 76 return 0; 77 77 } 78 78 79 - static int retu_pwrbutton_remove(struct platform_device *pdev) 80 - { 81 - return 0; 82 - } 83 - 84 79 static struct platform_driver retu_pwrbutton_driver = { 85 80 .probe = retu_pwrbutton_probe, 86 - .remove = retu_pwrbutton_remove, 87 81 .driver = { 88 82 .name = "retu-pwrbutton", 89 83 },
-8
drivers/input/misc/sirfsoc-onkey.c
··· 172 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 175 static int __maybe_unused sirfsoc_pwrc_resume(struct device *dev) 183 176 { 184 177 struct sirfsoc_pwrc_drvdata *pwrcdrv = dev_get_drvdata(dev); ··· 193 200 194 201 static struct platform_driver sirfsoc_pwrc_driver = { 195 202 .probe = sirfsoc_pwrc_probe, 196 - .remove = sirfsoc_pwrc_remove, 197 203 .driver = { 198 204 .name = "sirfsoc-pwrc", 199 205 .pm = &sirfsoc_pwrc_pm_ops,
+5 -3
drivers/input/misc/soc_button_array.c
··· 102 102 gpio_keys[n_buttons].active_low = 1; 103 103 gpio_keys[n_buttons].desc = info->name; 104 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 107 n_buttons++; 106 108 } 107 109 ··· 169 167 170 168 button_info = (struct soc_button_info *)id->driver_data; 171 169 172 - if (gpiod_count(&pdev->dev, KBUILD_MODNAME) <= 0) { 173 - dev_dbg(&pdev->dev, "no GPIO attached, ignoring...\n"); 170 + if (gpiod_count(dev, KBUILD_MODNAME) <= 0) { 171 + dev_dbg(dev, "no GPIO attached, ignoring...\n"); 174 172 return -ENODEV; 175 173 } 176 174 177 - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 175 + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 178 176 if (!priv) 179 177 return -ENOMEM; 180 178
+3 -5
drivers/input/misc/tps65218-pwrbutton.c
··· 95 95 int error; 96 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 99 if (!match) 100 100 return -ENXIO; 101 101 ··· 118 118 119 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 122 pwr->dev = dev; 123 123 pwr->idev = idev; 124 - platform_set_drvdata(pdev, pwr); 125 124 device_init_wakeup(dev, true); 126 125 127 126 irq = platform_get_irq(pdev, 0); ··· 135 136 IRQF_ONESHOT, 136 137 pwr->data->name, pwr); 137 138 if (error) { 138 - dev_err(dev, "failed to request IRQ #%d: %d\n", 139 - irq, error); 139 + dev_err(dev, "failed to request IRQ #%d: %d\n", irq, error); 140 140 return error; 141 141 } 142 142
-1
drivers/input/misc/twl4030-pwrbutton.c
··· 85 85 return err; 86 86 } 87 87 88 - platform_set_drvdata(pdev, pwr); 89 88 device_init_wakeup(&pdev->dev, true); 90 89 91 90 return 0;
+1 -1
drivers/input/mouse/alps.c
··· 1855 1855 * Switch mouse to poll (remote) mode so motion data will not 1856 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 1861 static int alps_monitor_mode_send_word(struct psmouse *psmouse, u16 word)
+1 -1
drivers/input/mouse/bcm5974.c
··· 665 665 char *data; 666 666 667 667 /* Type 3 does not require a mode switch */ 668 - if (dev->cfg.tp_type == TYPE3) 668 + if (c->tp_type == TYPE3) 669 669 return 0; 670 670 671 671 data = kmalloc(c->um_size, GFP_KERNEL);
+3 -3
drivers/input/mouse/cyapa.c
··· 832 832 int error; 833 833 834 834 if (device_can_wakeup(dev)) { 835 - error = sysfs_merge_group(&client->dev.kobj, 836 - &cyapa_power_wakeup_group); 835 + error = sysfs_merge_group(&dev->kobj, 836 + &cyapa_power_wakeup_group); 837 837 if (error) { 838 838 dev_err(dev, "failed to add power wakeup group: %d\n", 839 839 error); ··· 1312 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 1316 if (error) { 1317 1317 dev_err(dev, "failed to create sysfs entries: %d\n", error); 1318 1318 return error;
+13 -16
drivers/input/mouse/cyapa_gen3.c
··· 562 562 * Wait for bootloader to exit, and operation mode to start. 563 563 * Normally, this takes at least 50 ms. 564 564 */ 565 - usleep_range(50000, 100000); 565 + msleep(50); 566 566 /* 567 567 * In addition, when a device boots for the first time after being 568 568 * updated to new firmware, it must first calibrate its sensors, which ··· 789 789 const char *buf, size_t count) 790 790 { 791 791 struct cyapa *cyapa = dev_get_drvdata(dev); 792 - int tries; 792 + unsigned long timeout; 793 793 int ret; 794 794 795 795 ret = cyapa_read_byte(cyapa, CYAPA_CMD_DEV_STATUS); ··· 812 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 817 do { 817 818 /* 818 819 * For this recalibration, the max time will not exceed 2s. 819 820 * The average time is approximately 500 - 700 ms, and we 820 821 * will check the status every 100 - 200ms. 821 822 */ 822 - usleep_range(100000, 200000); 823 - 823 + msleep(100); 824 824 ret = cyapa_read_byte(cyapa, CYAPA_CMD_DEV_STATUS); 825 825 if (ret < 0) { 826 - dev_err(dev, "Error reading dev status: %d\n", 827 - ret); 826 + dev_err(dev, "Error reading dev status: %d\n", ret); 828 827 goto out; 829 828 } 830 - if ((ret & CYAPA_DEV_NORMAL) == CYAPA_DEV_NORMAL) 831 - break; 832 - } while (--tries); 829 + if ((ret & CYAPA_DEV_NORMAL) == CYAPA_DEV_NORMAL) { 830 + dev_dbg(dev, "Calibration successful.\n"); 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"); 836 - ret = -ETIMEDOUT; 837 - goto out; 838 - } 839 - dev_dbg(dev, "Calibration successful.\n"); 835 + dev_err(dev, "Failed to calibrate. Timeout.\n"); 836 + ret = -ETIMEDOUT; 840 837 841 838 out: 842 839 return ret < 0 ? ret : count;
+2 -4
drivers/input/mouse/cypress_ps2.c
··· 107 107 enum psmouse_state old_state; 108 108 int pktsize; 109 109 110 - ps2_begin_command(&psmouse->ps2dev); 110 + ps2_begin_command(ps2dev); 111 111 112 112 old_state = psmouse->state; 113 113 psmouse->state = PSMOUSE_CMD_MODE; ··· 133 133 psmouse->state = old_state; 134 134 psmouse->pktcnt = 0; 135 135 136 - ps2_end_command(&psmouse->ps2dev); 136 + ps2_end_command(ps2dev); 137 137 138 138 return rc; 139 139 } ··· 413 413 __set_bit(BTN_LEFT, input->keybit); 414 414 __set_bit(BTN_RIGHT, input->keybit); 415 415 __set_bit(BTN_MIDDLE, input->keybit); 416 - 417 - input_set_drvdata(input, cytp); 418 416 419 417 return 0; 420 418 }
+18 -28
drivers/input/mouse/elan_i2c_core.c
··· 1041 1041 return -EIO; 1042 1042 } 1043 1043 1044 - data = devm_kzalloc(&client->dev, sizeof(struct elan_tp_data), 1045 - GFP_KERNEL); 1044 + data = devm_kzalloc(dev, sizeof(struct elan_tp_data), GFP_KERNEL); 1046 1045 if (!data) 1047 1046 return -ENOMEM; 1048 1047 ··· 1052 1053 init_completion(&data->fw_completion); 1053 1054 mutex_init(&data->sysfs_mutex); 1054 1055 1055 - data->vcc = devm_regulator_get(&client->dev, "vcc"); 1056 + data->vcc = devm_regulator_get(dev, "vcc"); 1056 1057 if (IS_ERR(data->vcc)) { 1057 1058 error = PTR_ERR(data->vcc); 1058 1059 if (error != -EPROBE_DEFER) 1059 - dev_err(&client->dev, 1060 - "Failed to get 'vcc' regulator: %d\n", 1060 + dev_err(dev, "Failed to get 'vcc' regulator: %d\n", 1061 1061 error); 1062 1062 return error; 1063 1063 } 1064 1064 1065 1065 error = regulator_enable(data->vcc); 1066 1066 if (error) { 1067 - dev_err(&client->dev, 1068 - "Failed to enable regulator: %d\n", error); 1067 + dev_err(dev, "Failed to enable regulator: %d\n", error); 1069 1068 return error; 1070 1069 } 1071 1070 1072 - error = devm_add_action(&client->dev, 1073 - elan_disable_regulator, data); 1071 + error = devm_add_action(dev, elan_disable_regulator, data); 1074 1072 if (error) { 1075 1073 regulator_disable(data->vcc); 1076 - dev_err(&client->dev, 1077 - "Failed to add disable regulator action: %d\n", 1074 + dev_err(dev, "Failed to add disable regulator action: %d\n", 1078 1075 error); 1079 1076 return error; 1080 1077 } ··· 1088 1093 if (error) 1089 1094 return error; 1090 1095 1091 - dev_info(&client->dev, 1096 + dev_info(dev, 1092 1097 "Elan Touchpad: Module ID: 0x%04x, Firmware: 0x%04x, Sample: 0x%04x, IAP: 0x%04x\n", 1093 1098 data->product_id, 1094 1099 data->fw_version, 1095 1100 data->sm_version, 1096 1101 data->iap_version); 1097 1102 1098 - dev_dbg(&client->dev, 1103 + dev_dbg(dev, 1099 1104 "Elan Touchpad Extra Information:\n" 1100 1105 " Max ABS X,Y: %d,%d\n" 1101 1106 " Width X,Y: %d,%d\n" ··· 1113 1118 * Systems using device tree should set up interrupt via DTS, 1114 1119 * the rest will use the default falling edge interrupts. 1115 1120 */ 1116 - irqflags = client->dev.of_node ? 0 : IRQF_TRIGGER_FALLING; 1121 + irqflags = dev->of_node ? 0 : IRQF_TRIGGER_FALLING; 1117 1122 1118 - error = devm_request_threaded_irq(&client->dev, client->irq, 1119 - NULL, elan_isr, 1123 + error = devm_request_threaded_irq(dev, client->irq, NULL, elan_isr, 1120 1124 irqflags | IRQF_ONESHOT, 1121 1125 client->name, data); 1122 1126 if (error) { 1123 - dev_err(&client->dev, "cannot register irq=%d\n", client->irq); 1127 + dev_err(dev, "cannot register irq=%d\n", client->irq); 1124 1128 return error; 1125 1129 } 1126 1130 1127 - error = sysfs_create_groups(&client->dev.kobj, elan_sysfs_groups); 1131 + error = sysfs_create_groups(&dev->kobj, elan_sysfs_groups); 1128 1132 if (error) { 1129 - dev_err(&client->dev, "failed to create sysfs attributes: %d\n", 1130 - error); 1133 + dev_err(dev, "failed to create sysfs attributes: %d\n", error); 1131 1134 return error; 1132 1135 } 1133 1136 1134 - error = devm_add_action(&client->dev, 1135 - elan_remove_sysfs_groups, data); 1137 + error = devm_add_action(dev, elan_remove_sysfs_groups, data); 1136 1138 if (error) { 1137 1139 elan_remove_sysfs_groups(data); 1138 - dev_err(&client->dev, 1139 - "Failed to add sysfs cleanup action: %d\n", 1140 + dev_err(dev, "Failed to add sysfs cleanup action: %d\n", 1140 1141 error); 1141 1142 return error; 1142 1143 } 1143 1144 1144 1145 error = input_register_device(data->input); 1145 1146 if (error) { 1146 - dev_err(&client->dev, "failed to register input device: %d\n", 1147 - error); 1147 + dev_err(dev, "failed to register input device: %d\n", error); 1148 1148 return error; 1149 1149 } 1150 1150 ··· 1147 1157 * Systems using device tree should set up wakeup via DTS, 1148 1158 * the rest will configure device as wakeup source by default. 1149 1159 */ 1150 - if (!client->dev.of_node) 1151 - device_init_wakeup(&client->dev, true); 1160 + if (!dev->of_node) 1161 + device_init_wakeup(dev, true); 1152 1162 1153 1163 return 0; 1154 1164 }
+1 -1
drivers/input/mouse/elantech.c
··· 1412 1412 struct ps2dev *ps2dev = &psmouse->ps2dev; 1413 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 1417 if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) || 1418 1418 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
+2 -3
drivers/input/mouse/hgpk.c
··· 713 713 * the upper bound. (in practice, it takes about 3 loops.) 714 714 */ 715 715 for (timeo = 20; timeo > 0; timeo--) { 716 - if (!ps2_sendbyte(&psmouse->ps2dev, 717 - PSMOUSE_CMD_DISABLE, 20)) 716 + if (!ps2_sendbyte(ps2dev, PSMOUSE_CMD_DISABLE, 20)) 718 717 break; 719 718 msleep(25); 720 719 } ··· 739 740 psmouse_set_state(psmouse, PSMOUSE_IGNORE); 740 741 741 742 /* probably won't see an ACK, the touchpad will be off */ 742 - ps2_sendbyte(&psmouse->ps2dev, 0xec, 20); 743 + ps2_sendbyte(ps2dev, 0xec, 20); 743 744 } 744 745 745 746 return 0;
+1 -1
drivers/input/mouse/logips2pp.c
··· 402 402 psmouse->set_resolution = ps2pp_set_resolution; 403 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 406 &psmouse_attr_smartscroll.dattr); 407 407 if (error) { 408 408 psmouse_err(psmouse,
-1
drivers/input/mouse/maplemouse.c
··· 87 87 mse->dev = input_dev; 88 88 mse->mdev = mdev; 89 89 90 - input_set_drvdata(input_dev, mse); 91 90 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); 92 91 input_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | 93 92 BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE);
+38 -3
drivers/input/mouse/psmouse-base.c
··· 127 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 138 * psmouse_process_byte() analyzes the PS/2 data stream and reports 132 139 * relevant events to the input module once full packet has arrived. ··· 206 199 } 207 200 208 201 /* Generic PS/2 Mouse */ 209 - input_report_key(dev, BTN_LEFT, packet[0] & 1); 210 - input_report_key(dev, BTN_MIDDLE, (packet[0] >> 2) & 1); 211 - input_report_key(dev, BTN_RIGHT, (packet[0] >> 1) & 1); 202 + psmouse_report_standard_buttons(dev, 203 + packet[0] | psmouse->extra_buttons); 212 204 213 205 input_report_rel(dev, REL_X, packet[1] ? (int) packet[1] - (int) ((packet[0] << 4) & 0x100) : 0); 214 206 input_report_rel(dev, REL_Y, packet[2] ? (int) ((packet[0] << 3) & 0x100) - (int) packet[2] : 0); ··· 288 282 return 0; 289 283 } 290 284 285 + static void psmouse_handle_oob_data(struct psmouse *psmouse, u8 data) 286 + { 287 + switch (psmouse->oob_data_type) { 288 + case PSMOUSE_OOB_NONE: 289 + psmouse->oob_data_type = data; 290 + break; 291 + 292 + case PSMOUSE_OOB_EXTRA_BTNS: 293 + psmouse_report_standard_buttons(psmouse->dev, data); 294 + input_sync(psmouse->dev); 295 + 296 + psmouse->extra_buttons = data; 297 + psmouse->oob_data_type = PSMOUSE_OOB_NONE; 298 + break; 299 + 300 + default: 301 + psmouse_warn(psmouse, 302 + "unknown OOB_DATA type: 0x%02x\n", 303 + psmouse->oob_data_type); 304 + psmouse->oob_data_type = PSMOUSE_OOB_NONE; 305 + break; 306 + } 307 + } 308 + 291 309 /* 292 310 * psmouse_interrupt() handles incoming characters, either passing them 293 311 * for normal processing or gathering them as command response. ··· 333 303 flags & SERIO_TIMEOUT ? " timeout" : "", 334 304 flags & SERIO_PARITY ? " bad parity" : ""); 335 305 ps2_cmd_aborted(&psmouse->ps2dev); 306 + goto out; 307 + } 308 + 309 + if (flags & SERIO_OOB_DATA) { 310 + psmouse_handle_oob_data(psmouse, data); 336 311 goto out; 337 312 } 338 313
+5
drivers/input/mouse/psmouse.h
··· 1 1 #ifndef _PSMOUSE_H 2 2 #define _PSMOUSE_H 3 3 4 + #define PSMOUSE_OOB_NONE 0x00 5 + #define PSMOUSE_OOB_EXTRA_BTNS 0x01 6 + 4 7 #define PSMOUSE_CMD_SETSCALE11 0x00e6 5 8 #define PSMOUSE_CMD_SETSCALE21 0x00e7 6 9 #define PSMOUSE_CMD_SETRES 0x10e8 ··· 56 53 unsigned char pktcnt; 57 54 unsigned char pktsize; 58 55 unsigned char type; 56 + unsigned char oob_data_type; 57 + unsigned char extra_buttons; 59 58 bool ignore_parity; 60 59 bool acks_disable_command; 61 60 unsigned int model;
+13 -13
drivers/input/mouse/synaptics.c
··· 597 597 return (buf[0] & 0xFC) == 0x84 && (buf[3] & 0xCC) == 0xC4; 598 598 } 599 599 600 - static void synaptics_pass_pt_packet(struct psmouse *psmouse, 601 - struct serio *ptport, 600 + static void synaptics_pass_pt_packet(struct serio *ptport, 602 601 unsigned char *packet) 603 602 { 604 - struct synaptics_data *priv = psmouse->private; 605 603 struct psmouse *child = serio_get_drvdata(ptport); 606 604 607 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 607 serio_interrupt(ptport, packet[4], 0); 610 608 serio_interrupt(ptport, packet[5], 0); 611 609 if (child->pktsize == 4) ··· 854 856 struct input_dev *dev = psmouse->dev; 855 857 struct synaptics_data *priv = psmouse->private; 856 858 int ext_bits = (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) + 1) >> 1; 857 - char buf[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 858 859 int i; 859 860 860 861 if (!SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap)) ··· 880 883 * physically wired to the touchpad. Re-route them through 881 884 * the pass-through interface. 882 885 */ 883 - if (!priv->pt_port) 884 - return; 886 + if (priv->pt_port) { 887 + u8 pt_buttons; 885 888 886 - /* The trackstick expects at most 3 buttons */ 887 - priv->pt_buttons = SYN_CAP_EXT_BUTTON_STICK_L(hw->ext_buttons) | 888 - SYN_CAP_EXT_BUTTON_STICK_R(hw->ext_buttons) << 1 | 889 - SYN_CAP_EXT_BUTTON_STICK_M(hw->ext_buttons) << 2; 889 + /* The trackstick expects at most 3 buttons */ 890 + pt_buttons = SYN_CAP_EXT_BUTTON_STICK_L(hw->ext_buttons) | 891 + SYN_CAP_EXT_BUTTON_STICK_R(hw->ext_buttons) << 1 | 892 + SYN_CAP_EXT_BUTTON_STICK_M(hw->ext_buttons) << 2; 890 893 891 - synaptics_pass_pt_packet(psmouse, priv->pt_port, buf); 894 + serio_interrupt(priv->pt_port, 895 + PSMOUSE_OOB_EXTRA_BTNS, SERIO_OOB_DATA); 896 + serio_interrupt(priv->pt_port, pt_buttons, SERIO_OOB_DATA); 897 + } 892 898 } 893 899 894 900 static void synaptics_report_buttons(struct psmouse *psmouse, ··· 1132 1132 if (SYN_CAP_PASS_THROUGH(priv->capabilities) && 1133 1133 synaptics_is_pt_packet(psmouse->packet)) { 1134 1134 if (priv->pt_port) 1135 - synaptics_pass_pt_packet(psmouse, priv->pt_port, 1135 + synaptics_pass_pt_packet(priv->pt_port, 1136 1136 psmouse->packet); 1137 1137 } else 1138 1138 synaptics_process_packet(psmouse);
-1
drivers/input/mouse/synaptics.h
··· 183 183 bool disable_gesture; /* disable gestures */ 184 184 185 185 struct serio *pt_port; /* Pass-through serio port */ 186 - unsigned char pt_buttons; /* Pass-through buttons */ 187 186 188 187 /* 189 188 * Last received Advanced Gesture Mode (AGM) packet. An AGM packet
+2 -2
drivers/input/mouse/trackpoint.c
··· 379 379 if (!set_properties) 380 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 383 psmouse_warn(psmouse, "failed to get extended button data\n"); 384 384 button_info = 0; 385 385 } ··· 402 402 403 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 407 /* Write defaults to TP only if reset fails. */ 408 408 if (error)
+12 -15
drivers/input/rmi4/Kconfig
··· 9 9 10 10 If unsure, say Y. 11 11 12 + if RMI4_CORE 13 + 12 14 config RMI4_I2C 13 15 tristate "RMI4 I2C Support" 14 - depends on RMI4_CORE && I2C 16 + depends on I2C 15 17 help 16 18 Say Y here if you want to support RMI4 devices connected to an I2C 17 19 bus. ··· 22 20 23 21 config RMI4_SPI 24 22 tristate "RMI4 SPI Support" 25 - depends on RMI4_CORE && SPI 23 + depends on SPI 26 24 help 27 25 Say Y here if you want to support RMI4 devices connected to a SPI 28 26 bus. ··· 31 29 32 30 config RMI4_SMB 33 31 tristate "RMI4 SMB Support" 34 - depends on RMI4_CORE && I2C 32 + depends on I2C 35 33 help 36 34 Say Y here if you want to support RMI4 devices connected to an SMB 37 35 bus. ··· 42 40 called rmi_smbus. 43 41 44 42 config RMI4_F03 45 - bool "RMI4 Function 03 (PS2 Guest)" 43 + bool "RMI4 Function 03 (PS2 Guest)" 46 44 depends on RMI4_CORE 47 - help 48 - Say Y here if you want to add support for RMI4 function 03. 45 + help 46 + Say Y here if you want to add support for RMI4 function 03. 49 47 50 - Function 03 provides PS2 guest support for RMI4 devices. This 51 - includes support for TrackPoints on TouchPads. 48 + Function 03 provides PS2 guest support for RMI4 devices. This 49 + includes support for TrackPoints on TouchPads. 52 50 53 51 config RMI4_F03_SERIO 54 52 tristate ··· 59 57 60 58 config RMI4_2D_SENSOR 61 59 bool 62 - depends on RMI4_CORE 63 60 64 61 config RMI4_F11 65 62 bool "RMI4 Function 11 (2D pointing)" 66 63 select RMI4_2D_SENSOR 67 - depends on RMI4_CORE 68 64 help 69 65 Say Y here if you want to add support for RMI4 function 11. 70 66 ··· 73 73 config RMI4_F12 74 74 bool "RMI4 Function 12 (2D pointing)" 75 75 select RMI4_2D_SENSOR 76 - depends on RMI4_CORE 77 76 help 78 77 Say Y here if you want to add support for RMI4 function 12. 79 78 ··· 82 83 83 84 config RMI4_F30 84 85 bool "RMI4 Function 30 (GPIO LED)" 85 - depends on RMI4_CORE 86 86 help 87 87 Say Y here if you want to add support for RMI4 function 30. 88 88 ··· 90 92 91 93 config RMI4_F34 92 94 bool "RMI4 Function 34 (Device reflash)" 93 - depends on RMI4_CORE 94 95 select FW_LOADER 95 96 help 96 97 Say Y here if you want to add support for RMI4 function 34. ··· 100 103 101 104 config RMI4_F54 102 105 bool "RMI4 Function 54 (Analog diagnostics)" 103 - depends on RMI4_CORE 104 106 depends on VIDEO_V4L2=y || (RMI4_CORE=m && VIDEO_V4L2=m) 105 107 select VIDEOBUF2_VMALLOC 106 108 select RMI4_F55 ··· 111 115 112 116 config RMI4_F55 113 117 bool "RMI4 Function 55 (Sensor tuning)" 114 - depends on RMI4_CORE 115 118 help 116 119 Say Y here if you want to add support for RMI4 function 55 117 120 118 121 Function 55 provides access to the RMI4 touch sensor tuning 119 122 mechanism. 123 + 124 + endif # RMI_CORE
+6 -1
drivers/input/rmi4/rmi_2d_sensor.c
··· 144 144 int input_flags = 0; 145 145 146 146 if (sensor->report_abs) { 147 - if (sensor->axis_align.swap_axes) 147 + if (sensor->axis_align.swap_axes) { 148 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 155 sensor->min_x = sensor->axis_align.clip_x_low; 151 156 if (sensor->axis_align.clip_x_high)
+4 -4
drivers/input/rmi4/rmi_bus.c
··· 55 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 59 .name = "rmi4_sensor", 60 60 .release = rmi_release_device, 61 61 }; ··· 134 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 138 .name = "rmi4_function", 139 139 .release = rmi_release_function, 140 140 }; ··· 261 261 driver->probe = rmi_function_probe; 262 262 driver->remove = rmi_function_remove; 263 263 264 - error = driver_register(&handler->driver); 264 + error = driver_register(driver); 265 265 if (error) { 266 266 pr_err("driver_register() failed for %s, error: %d\n", 267 - handler->driver.name, error); 267 + driver->name, error); 268 268 return error; 269 269 } 270 270
+17 -4
drivers/input/rmi4/rmi_driver.c
··· 265 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 281 static int suspend_one_function(struct rmi_function *fn) 269 282 { 270 283 struct rmi_function_handler *fh; ··· 377 364 struct input_dev *input) 378 365 { 379 366 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); 380 - char *device_name = rmi_f01_get_product_ID(data->f01_container); 367 + const char *device_name = rmi_f01_get_product_ID(data->f01_container); 381 368 char *name; 382 369 383 370 name = devm_kasprintf(&rmi_dev->dev, GFP_KERNEL, ··· 849 836 void *ctx, const struct pdt_entry *pdt) 850 837 { 851 838 struct device *dev = &rmi_dev->dev; 852 - struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); 839 + struct rmi_driver_data *data = dev_get_drvdata(dev); 853 840 int *current_irq_count = ctx; 854 841 struct rmi_function *fn; 855 842 int i; ··· 1053 1040 } 1054 1041 1055 1042 if (data->bootloader_mode) 1056 - dev_warn(&rmi_dev->dev, "Device in bootloader mode.\n"); 1043 + dev_warn(dev, "Device in bootloader mode.\n"); 1057 1044 1058 1045 data->irq_count = irq_count; 1059 1046 data->num_of_irq_regs = (data->irq_count + 7) / 8; ··· 1062 1049 data->irq_memory = devm_kzalloc(dev, size * 4, GFP_KERNEL); 1063 1050 if (!data->irq_memory) { 1064 1051 dev_err(dev, "Failed to allocate memory for irq masks.\n"); 1065 - return retval; 1052 + return -ENOMEM; 1066 1053 } 1067 1054 1068 1055 data->irq_status = data->irq_memory + size * 0;
+15 -1
drivers/input/rmi4/rmi_driver.h
··· 93 93 int rmi_register_physical_driver(void); 94 94 void rmi_unregister_physical_driver(void); 95 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 97 int rmi_enable_sensor(struct rmi_device *rmi_dev); 97 98 int rmi_scan_pdt(struct rmi_device *rmi_dev, void *ctx, 98 99 int (*callback)(struct rmi_device *rmi_dev, void *ctx, ··· 105 104 int rmi_initial_reset(struct rmi_device *rmi_dev, void *ctx, 106 105 const struct pdt_entry *pdt); 107 106 108 - char *rmi_f01_get_product_ID(struct rmi_function *fn); 107 + const char *rmi_f01_get_product_ID(struct rmi_function *fn); 108 + 109 + #ifdef CONFIG_RMI4_F03 110 + int rmi_f03_overwrite_button(struct rmi_function *fn, unsigned int button, 111 + int value); 112 + void rmi_f03_commit_buttons(struct rmi_function *fn); 113 + #else 114 + static inline int rmi_f03_overwrite_button(struct rmi_function *fn, 115 + unsigned int button, int value) 116 + { 117 + return 0; 118 + } 119 + static inline void rmi_f03_commit_buttons(struct rmi_function *fn) {} 120 + #endif 109 121 110 122 #ifdef CONFIG_RMI4_F34 111 123 int rmi_f34_create_sysfs(struct rmi_device *rmi_dev);
+102 -2
drivers/input/rmi4/rmi_f01.c
··· 12 12 #include <linux/slab.h> 13 13 #include <linux/uaccess.h> 14 14 #include <linux/of.h> 15 + #include <asm/unaligned.h> 15 16 #include "rmi_driver.h" 16 17 17 18 #define RMI_PRODUCT_ID_LENGTH 10 ··· 55 54 u8 product_id[RMI_PRODUCT_ID_LENGTH + 1]; 56 55 u16 productinfo; 57 56 u32 firmware_id; 57 + u32 package_id; 58 58 }; 59 59 60 60 /* F01 device status bits */ ··· 222 220 has_build_id_query = !!(queries[0] & BIT(1)); 223 221 } 224 222 225 - if (has_package_id_query) 223 + if (has_package_id_query) { 224 + ret = rmi_read_block(rmi_dev, prod_info_addr, 225 + queries, sizeof(__le64)); 226 + if (ret) { 227 + dev_err(&rmi_dev->dev, 228 + "Failed to read package info: %d\n", 229 + ret); 230 + return ret; 231 + } 232 + 233 + props->package_id = get_unaligned_le64(queries); 226 234 prod_info_addr++; 235 + } 227 236 228 237 if (has_build_id_query) { 229 238 ret = rmi_read_block(rmi_dev, prod_info_addr, queries, ··· 254 241 return 0; 255 242 } 256 243 257 - char *rmi_f01_get_product_ID(struct rmi_function *fn) 244 + const char *rmi_f01_get_product_ID(struct rmi_function *fn) 258 245 { 259 246 struct f01_data *f01 = dev_get_drvdata(&fn->dev); 260 247 261 248 return f01->properties.product_id; 262 249 } 250 + 251 + static ssize_t rmi_driver_manufacturer_id_show(struct device *dev, 252 + struct device_attribute *dattr, 253 + char *buf) 254 + { 255 + struct rmi_driver_data *data = dev_get_drvdata(dev); 256 + struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev); 257 + 258 + return scnprintf(buf, PAGE_SIZE, "%d\n", 259 + f01->properties.manufacturer_id); 260 + } 261 + 262 + static DEVICE_ATTR(manufacturer_id, 0444, 263 + rmi_driver_manufacturer_id_show, NULL); 264 + 265 + static ssize_t rmi_driver_dom_show(struct device *dev, 266 + struct device_attribute *dattr, 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, "%s\n", f01->properties.dom); 272 + } 273 + 274 + static DEVICE_ATTR(date_of_manufacture, 0444, rmi_driver_dom_show, NULL); 275 + 276 + static ssize_t rmi_driver_product_id_show(struct device *dev, 277 + struct device_attribute *dattr, 278 + char *buf) 279 + { 280 + struct rmi_driver_data *data = dev_get_drvdata(dev); 281 + struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev); 282 + 283 + return scnprintf(buf, PAGE_SIZE, "%s\n", f01->properties.product_id); 284 + } 285 + 286 + static DEVICE_ATTR(product_id, 0444, rmi_driver_product_id_show, NULL); 287 + 288 + static ssize_t rmi_driver_firmware_id_show(struct device *dev, 289 + struct device_attribute *dattr, 290 + char *buf) 291 + { 292 + struct rmi_driver_data *data = dev_get_drvdata(dev); 293 + struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev); 294 + 295 + return scnprintf(buf, PAGE_SIZE, "%d\n", f01->properties.firmware_id); 296 + } 297 + 298 + static DEVICE_ATTR(firmware_id, 0444, rmi_driver_firmware_id_show, NULL); 299 + 300 + static ssize_t rmi_driver_package_id_show(struct device *dev, 301 + struct device_attribute *dattr, 302 + char *buf) 303 + { 304 + struct rmi_driver_data *data = dev_get_drvdata(dev); 305 + struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev); 306 + 307 + u32 package_id = f01->properties.package_id; 308 + 309 + return scnprintf(buf, PAGE_SIZE, "%04x.%04x\n", 310 + package_id & 0xffff, (package_id >> 16) & 0xffff); 311 + } 312 + 313 + static DEVICE_ATTR(package_id, 0444, rmi_driver_package_id_show, NULL); 314 + 315 + static struct attribute *rmi_f01_attrs[] = { 316 + &dev_attr_manufacturer_id.attr, 317 + &dev_attr_date_of_manufacture.attr, 318 + &dev_attr_product_id.attr, 319 + &dev_attr_firmware_id.attr, 320 + &dev_attr_package_id.attr, 321 + NULL 322 + }; 323 + 324 + static struct attribute_group rmi_f01_attr_group = { 325 + .attrs = rmi_f01_attrs, 326 + }; 263 327 264 328 #ifdef CONFIG_OF 265 329 static int rmi_f01_of_probe(struct device *dev, ··· 570 480 571 481 dev_set_drvdata(&fn->dev, f01); 572 482 483 + error = sysfs_create_group(&fn->rmi_dev->dev.kobj, &rmi_f01_attr_group); 484 + if (error) 485 + dev_warn(&fn->dev, "Failed to create sysfs group: %d\n", error); 486 + 573 487 return 0; 488 + } 489 + 490 + static void rmi_f01_remove(struct rmi_function *fn) 491 + { 492 + sysfs_remove_group(&fn->rmi_dev->dev.kobj, &rmi_f01_attr_group); 574 493 } 575 494 576 495 static int rmi_f01_config(struct rmi_function *fn) ··· 721 622 }, 722 623 .func = 0x01, 723 624 .probe = rmi_f01_probe, 625 + .remove = rmi_f01_remove, 724 626 .config = rmi_f01_config, 725 627 .attention = rmi_f01_attention, 726 628 .suspend = rmi_f01_suspend,
+38 -3
drivers/input/rmi4/rmi_f03.c
··· 26 26 #define RMI_F03_BYTES_PER_DEVICE_SHIFT 4 27 27 #define RMI_F03_QUEUE_LENGTH 0x0F 28 28 29 + #define PSMOUSE_OOB_EXTRA_BTNS 0x01 30 + 29 31 struct f03_data { 30 32 struct rmi_function *fn; 31 33 32 34 struct serio *serio; 33 35 36 + unsigned int overwrite_buttons; 37 + 34 38 u8 device_count; 35 39 u8 rx_queue_length; 36 40 }; 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 + } 37 75 38 76 static int rmi_f03_pt_write(struct serio *id, unsigned char val) 39 77 { ··· 212 174 unsigned int serio_flags; 213 175 int i; 214 176 int error; 215 - 216 - if (!rmi_dev) 217 - return -ENODEV; 218 177 219 178 if (drvdata->attn_data.data) { 220 179 /* First grab the data passed by the transport device */
+172 -182
drivers/input/rmi4/rmi_f30.c
··· 16 16 17 17 /* Defs for Query 0 */ 18 18 #define RMI_F30_EXTENDED_PATTERNS 0x01 19 - #define RMI_F30_HAS_MAPPABLE_BUTTONS (1 << 1) 20 - #define RMI_F30_HAS_LED (1 << 2) 21 - #define RMI_F30_HAS_GPIO (1 << 3) 22 - #define RMI_F30_HAS_HAPTIC (1 << 4) 23 - #define RMI_F30_HAS_GPIO_DRV_CTL (1 << 5) 24 - #define RMI_F30_HAS_MECH_MOUSE_BTNS (1 << 6) 19 + #define RMI_F30_HAS_MAPPABLE_BUTTONS BIT(1) 20 + #define RMI_F30_HAS_LED BIT(2) 21 + #define RMI_F30_HAS_GPIO BIT(3) 22 + #define RMI_F30_HAS_HAPTIC BIT(4) 23 + #define RMI_F30_HAS_GPIO_DRV_CTL BIT(5) 24 + #define RMI_F30_HAS_MECH_MOUSE_BTNS BIT(6) 25 25 26 26 /* Defs for Query 1 */ 27 27 #define RMI_F30_GPIO_LED_COUNT 0x1F 28 28 29 29 /* Defs for Control Registers */ 30 30 #define RMI_F30_CTRL_1_GPIO_DEBOUNCE 0x01 31 - #define RMI_F30_CTRL_1_HALT (1 << 4) 32 - #define RMI_F30_CTRL_1_HALTED (1 << 5) 31 + #define RMI_F30_CTRL_1_HALT BIT(4) 32 + #define RMI_F30_CTRL_1_HALTED BIT(5) 33 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 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 37 #define RMI_F30_CTRL_MAX_REG_BLOCKS 11 44 38 45 39 #define RMI_F30_CTRL_REGS_MAX_SIZE (RMI_F30_CTRL_MAX_BYTES \ ··· 47 53 + RMI_F30_CTRL_MAX_BYTES \ 48 54 + 1 \ 49 55 + 1) 56 + 57 + #define TRACKSTICK_RANGE_START 3 58 + #define TRACKSTICK_RANGE_END 6 59 + 60 + struct rmi_f30_ctrl_data { 61 + int address; 62 + int length; 63 + u8 *regs; 64 + }; 50 65 51 66 struct f30_data { 52 67 /* Query Data */ ··· 79 76 u16 *gpioled_key_map; 80 77 81 78 struct input_dev *input; 79 + 80 + struct rmi_function *f03; 81 + bool trackstick_buttons; 82 82 }; 83 83 84 84 static int rmi_f30_read_control_parameters(struct rmi_function *fn, 85 85 struct f30_data *f30) 86 86 { 87 - struct rmi_device *rmi_dev = fn->rmi_dev; 88 - int error = 0; 87 + int error; 89 88 90 - error = rmi_read_block(rmi_dev, fn->fd.control_base_addr, 91 - f30->ctrl_regs, f30->ctrl_regs_size); 89 + error = rmi_read_block(fn->rmi_dev, fn->fd.control_base_addr, 90 + f30->ctrl_regs, f30->ctrl_regs_size); 92 91 if (error) { 93 - dev_err(&rmi_dev->dev, "%s : Could not read control registers at 0x%x error (%d)\n", 92 + dev_err(&fn->dev, 93 + "%s: Could not read control registers at 0x%x: %d\n", 94 94 __func__, fn->fd.control_base_addr, error); 95 95 return error; 96 96 } ··· 101 95 return 0; 102 96 } 103 97 98 + static void rmi_f30_report_button(struct rmi_function *fn, 99 + struct f30_data *f30, unsigned int button) 100 + { 101 + unsigned int reg_num = button >> 3; 102 + unsigned int bit_num = button & 0x07; 103 + u16 key_code = f30->gpioled_key_map[button]; 104 + bool key_down = !(f30->data_regs[reg_num] & BIT(bit_num)); 105 + 106 + if (f30->trackstick_buttons && 107 + button >= TRACKSTICK_RANGE_START && 108 + button <= TRACKSTICK_RANGE_END) { 109 + rmi_f03_overwrite_button(f30->f03, key_code, key_down); 110 + } else { 111 + rmi_dbg(RMI_DEBUG_FN, &fn->dev, 112 + "%s: call input report key (0x%04x) value (0x%02x)", 113 + __func__, key_code, key_down); 114 + 115 + input_report_key(f30->input, key_code, key_down); 116 + } 117 + } 118 + 104 119 static int rmi_f30_attention(struct rmi_function *fn, unsigned long *irq_bits) 105 120 { 106 121 struct f30_data *f30 = dev_get_drvdata(&fn->dev); 107 - struct rmi_device *rmi_dev = fn->rmi_dev; 108 - struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev); 109 - int retval; 110 - int gpiled = 0; 111 - int value = 0; 122 + struct rmi_driver_data *drvdata = dev_get_drvdata(&fn->rmi_dev->dev); 123 + int error; 112 124 int i; 113 - int reg_num; 114 - 115 - if (!f30->input) 116 - return 0; 117 125 118 126 /* Read the gpi led data. */ 119 127 if (drvdata->attn_data.data) { 120 128 if (drvdata->attn_data.size < f30->register_count) { 121 - dev_warn(&fn->dev, "F30 interrupted, but data is missing\n"); 129 + dev_warn(&fn->dev, 130 + "F30 interrupted, but data is missing\n"); 122 131 return 0; 123 132 } 124 133 memcpy(f30->data_regs, drvdata->attn_data.data, ··· 141 120 drvdata->attn_data.data += f30->register_count; 142 121 drvdata->attn_data.size -= f30->register_count; 143 122 } else { 144 - retval = rmi_read_block(rmi_dev, fn->fd.data_base_addr, 145 - f30->data_regs, f30->register_count); 146 - 147 - if (retval) { 148 - dev_err(&fn->dev, "%s: Failed to read F30 data registers.\n", 149 - __func__); 150 - return retval; 123 + error = rmi_read_block(fn->rmi_dev, fn->fd.data_base_addr, 124 + f30->data_regs, f30->register_count); 125 + if (error) { 126 + dev_err(&fn->dev, 127 + "%s: Failed to read F30 data registers: %d\n", 128 + __func__, error); 129 + return error; 151 130 } 152 131 } 153 132 154 - for (reg_num = 0; reg_num < f30->register_count; ++reg_num) { 155 - for (i = 0; gpiled < f30->gpioled_count && i < 8; ++i, 156 - ++gpiled) { 157 - if (f30->gpioled_key_map[gpiled] != 0) { 158 - /* buttons have pull up resistors */ 159 - value = (((f30->data_regs[reg_num] >> i) & 0x01) 160 - == 0); 161 - 162 - rmi_dbg(RMI_DEBUG_FN, &fn->dev, 163 - "%s: call input report key (0x%04x) value (0x%02x)", 164 - __func__, 165 - f30->gpioled_key_map[gpiled], value); 166 - input_report_key(f30->input, 167 - f30->gpioled_key_map[gpiled], 168 - value); 169 - } 170 - 171 - } 133 + if (f30->has_gpio) { 134 + for (i = 0; i < f30->gpioled_count; i++) 135 + if (f30->gpioled_key_map[i] != KEY_RESERVED) 136 + rmi_f30_report_button(fn, f30, i); 137 + if (f30->trackstick_buttons) 138 + rmi_f03_commit_buttons(f30->f03); 172 139 } 173 140 174 - return 0; 175 - } 176 - 177 - static int rmi_f30_register_device(struct rmi_function *fn) 178 - { 179 - int i; 180 - struct rmi_device *rmi_dev = fn->rmi_dev; 181 - struct rmi_driver_data *drv_data = dev_get_drvdata(&rmi_dev->dev); 182 - struct f30_data *f30 = dev_get_drvdata(&fn->dev); 183 - struct input_dev *input_dev; 184 - int button_count = 0; 185 - 186 - input_dev = drv_data->input; 187 - if (!input_dev) { 188 - dev_info(&fn->dev, "F30: no input device found, ignoring.\n"); 189 - return -EINVAL; 190 - } 191 - 192 - f30->input = input_dev; 193 - 194 - set_bit(EV_KEY, input_dev->evbit); 195 - 196 - input_dev->keycode = f30->gpioled_key_map; 197 - input_dev->keycodesize = sizeof(u16); 198 - input_dev->keycodemax = f30->gpioled_count; 199 - 200 - for (i = 0; i < f30->gpioled_count; i++) { 201 - if (f30->gpioled_key_map[i] != 0) { 202 - input_set_capability(input_dev, EV_KEY, 203 - f30->gpioled_key_map[i]); 204 - button_count++; 205 - } 206 - } 207 - 208 - if (button_count == 1) 209 - __set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit); 210 141 return 0; 211 142 } 212 143 ··· 170 197 rmi_get_platform_data(fn->rmi_dev); 171 198 int error; 172 199 200 + if (pdata->f30_data.trackstick_buttons) { 201 + /* Try [re-]establish link to F03. */ 202 + f30->f03 = rmi_find_function(fn->rmi_dev, 0x03); 203 + f30->trackstick_buttons = f30->f03 != NULL; 204 + } 205 + 173 206 if (pdata->f30_data.disable) { 174 207 drv->clear_irq_bits(fn->rmi_dev, fn->irq_mask); 175 208 } else { ··· 183 204 error = rmi_write_block(fn->rmi_dev, fn->fd.control_base_addr, 184 205 f30->ctrl_regs, f30->ctrl_regs_size); 185 206 if (error) { 186 - dev_err(&fn->rmi_dev->dev, 187 - "%s : Could not write control registers at 0x%x error (%d)\n", 207 + dev_err(&fn->dev, 208 + "%s: Could not write control registers at 0x%x: %d\n", 188 209 __func__, fn->fd.control_base_addr, error); 189 210 return error; 190 211 } 191 212 192 213 drv->set_irq_bits(fn->rmi_dev, fn->irq_mask); 193 214 } 215 + 194 216 return 0; 195 217 } 196 218 197 - static inline void rmi_f30_set_ctrl_data(struct rmi_f30_ctrl_data *ctrl, 198 - int *ctrl_addr, int len, u8 **reg) 219 + static void rmi_f30_set_ctrl_data(struct rmi_f30_ctrl_data *ctrl, 220 + int *ctrl_addr, int len, u8 **reg) 199 221 { 200 222 ctrl->address = *ctrl_addr; 201 223 ctrl->length = len; ··· 205 225 *reg += len; 206 226 } 207 227 208 - static inline bool rmi_f30_is_valid_button(int button, 209 - struct rmi_f30_ctrl_data *ctrl) 228 + static bool rmi_f30_is_valid_button(int button, struct rmi_f30_ctrl_data *ctrl) 210 229 { 211 230 int byte_position = button >> 3; 212 231 int bit_position = button & 0x07; ··· 218 239 (ctrl[3].regs[byte_position] & BIT(bit_position)); 219 240 } 220 241 221 - static inline int rmi_f30_initialize(struct rmi_function *fn) 242 + static int rmi_f30_map_gpios(struct rmi_function *fn, 243 + struct f30_data *f30) 222 244 { 223 - struct f30_data *f30; 224 - struct rmi_device *rmi_dev = fn->rmi_dev; 225 - const struct rmi_device_platform_data *pdata; 226 - int retval = 0; 227 - int control_address; 245 + const struct rmi_device_platform_data *pdata = 246 + rmi_get_platform_data(fn->rmi_dev); 247 + struct input_dev *input = f30->input; 248 + unsigned int button = BTN_LEFT; 249 + unsigned int trackstick_button = BTN_LEFT; 250 + bool button_mapped = false; 228 251 int i; 229 - int button; 230 - u8 buf[RMI_F30_QUERY_SIZE]; 231 - u8 *ctrl_reg; 232 - u8 *map_memory; 233 252 234 - f30 = devm_kzalloc(&fn->dev, sizeof(struct f30_data), 235 - GFP_KERNEL); 236 - if (!f30) 253 + f30->gpioled_key_map = devm_kcalloc(&fn->dev, 254 + f30->gpioled_count, 255 + sizeof(f30->gpioled_key_map[0]), 256 + GFP_KERNEL); 257 + if (!f30->gpioled_key_map) { 258 + dev_err(&fn->dev, "Failed to allocate gpioled map memory.\n"); 237 259 return -ENOMEM; 260 + } 238 261 239 - dev_set_drvdata(&fn->dev, f30); 262 + for (i = 0; i < f30->gpioled_count; i++) { 263 + if (!rmi_f30_is_valid_button(i, f30->ctrl)) 264 + continue; 240 265 241 - retval = rmi_read_block(fn->rmi_dev, fn->fd.query_base_addr, buf, 242 - RMI_F30_QUERY_SIZE); 266 + if (pdata->f30_data.trackstick_buttons && 267 + i >= TRACKSTICK_RANGE_START && i < TRACKSTICK_RANGE_END) { 268 + f30->gpioled_key_map[i] = trackstick_button++; 269 + } else if (!pdata->f30_data.buttonpad || !button_mapped) { 270 + f30->gpioled_key_map[i] = button; 271 + input_set_capability(input, EV_KEY, button++); 272 + button_mapped = true; 273 + } 274 + } 243 275 244 - if (retval) { 245 - dev_err(&fn->dev, "Failed to read query register.\n"); 246 - return retval; 276 + input->keycode = f30->gpioled_key_map; 277 + input->keycodesize = sizeof(f30->gpioled_key_map[0]); 278 + input->keycodemax = f30->gpioled_count; 279 + 280 + /* 281 + * Buttonpad could be also inferred from f30->has_mech_mouse_btns, 282 + * but I am not sure, so use only the pdata info. 283 + */ 284 + if (pdata->f30_data.buttonpad) 285 + __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); 286 + 287 + return 0; 288 + } 289 + 290 + static int rmi_f30_initialize(struct rmi_function *fn, struct f30_data *f30) 291 + { 292 + u8 *ctrl_reg = f30->ctrl_regs; 293 + int control_address = fn->fd.control_base_addr; 294 + u8 buf[RMI_F30_QUERY_SIZE]; 295 + int error; 296 + 297 + error = rmi_read_block(fn->rmi_dev, fn->fd.query_base_addr, 298 + buf, RMI_F30_QUERY_SIZE); 299 + if (error) { 300 + dev_err(&fn->dev, "Failed to read query register\n"); 301 + return error; 247 302 } 248 303 249 304 f30->has_extended_pattern = buf[0] & RMI_F30_EXTENDED_PATTERNS; ··· 289 276 f30->has_mech_mouse_btns = buf[0] & RMI_F30_HAS_MECH_MOUSE_BTNS; 290 277 f30->gpioled_count = buf[1] & RMI_F30_GPIO_LED_COUNT; 291 278 292 - f30->register_count = (f30->gpioled_count + 7) >> 3; 293 - 294 - control_address = fn->fd.control_base_addr; 295 - ctrl_reg = f30->ctrl_regs; 279 + f30->register_count = DIV_ROUND_UP(f30->gpioled_count, 8); 296 280 297 281 if (f30->has_gpio && f30->has_led) 298 282 rmi_f30_set_ctrl_data(&f30->ctrl[0], &control_address, 299 - f30->register_count, &ctrl_reg); 283 + f30->register_count, &ctrl_reg); 300 284 301 - rmi_f30_set_ctrl_data(&f30->ctrl[1], &control_address, sizeof(u8), 302 - &ctrl_reg); 285 + rmi_f30_set_ctrl_data(&f30->ctrl[1], &control_address, 286 + sizeof(u8), &ctrl_reg); 303 287 304 288 if (f30->has_gpio) { 305 289 rmi_f30_set_ctrl_data(&f30->ctrl[2], &control_address, 306 - f30->register_count, &ctrl_reg); 290 + f30->register_count, &ctrl_reg); 307 291 308 292 rmi_f30_set_ctrl_data(&f30->ctrl[3], &control_address, 309 - f30->register_count, &ctrl_reg); 293 + f30->register_count, &ctrl_reg); 310 294 } 311 295 312 296 if (f30->has_led) { 313 - int ctrl5_len; 314 - 315 297 rmi_f30_set_ctrl_data(&f30->ctrl[4], &control_address, 316 - f30->register_count, &ctrl_reg); 317 - 318 - if (f30->has_extended_pattern) 319 - ctrl5_len = 6; 320 - else 321 - ctrl5_len = 2; 298 + f30->register_count, &ctrl_reg); 322 299 323 300 rmi_f30_set_ctrl_data(&f30->ctrl[5], &control_address, 324 - ctrl5_len, &ctrl_reg); 301 + f30->has_extended_pattern ? 6 : 2, 302 + &ctrl_reg); 325 303 } 326 304 327 305 if (f30->has_led || f30->has_gpio_driver_control) { 328 306 /* control 6 uses a byte per gpio/led */ 329 307 rmi_f30_set_ctrl_data(&f30->ctrl[6], &control_address, 330 - f30->gpioled_count, &ctrl_reg); 308 + f30->gpioled_count, &ctrl_reg); 331 309 } 332 310 333 311 if (f30->has_mappable_buttons) { 334 312 /* control 7 uses a byte per gpio/led */ 335 313 rmi_f30_set_ctrl_data(&f30->ctrl[7], &control_address, 336 - f30->gpioled_count, &ctrl_reg); 314 + f30->gpioled_count, &ctrl_reg); 337 315 } 338 316 339 317 if (f30->has_haptic) { 340 318 rmi_f30_set_ctrl_data(&f30->ctrl[8], &control_address, 341 - f30->register_count, &ctrl_reg); 319 + f30->register_count, &ctrl_reg); 342 320 343 321 rmi_f30_set_ctrl_data(&f30->ctrl[9], &control_address, 344 - sizeof(u8), &ctrl_reg); 322 + sizeof(u8), &ctrl_reg); 345 323 } 346 324 347 325 if (f30->has_mech_mouse_btns) 348 326 rmi_f30_set_ctrl_data(&f30->ctrl[10], &control_address, 349 - sizeof(u8), &ctrl_reg); 327 + sizeof(u8), &ctrl_reg); 350 328 351 - f30->ctrl_regs_size = ctrl_reg - f30->ctrl_regs 352 - ?: RMI_F30_CTRL_REGS_MAX_SIZE; 329 + f30->ctrl_regs_size = ctrl_reg - 330 + f30->ctrl_regs ?: RMI_F30_CTRL_REGS_MAX_SIZE; 353 331 354 - retval = rmi_f30_read_control_parameters(fn, f30); 355 - if (retval < 0) { 332 + error = rmi_f30_read_control_parameters(fn, f30); 333 + if (error) { 356 334 dev_err(&fn->dev, 357 - "Failed to initialize F19 control params.\n"); 358 - return retval; 335 + "Failed to initialize F30 control params: %d\n", 336 + error); 337 + return error; 359 338 } 360 339 361 - map_memory = devm_kzalloc(&fn->dev, 362 - (f30->gpioled_count * (sizeof(u16))), 363 - GFP_KERNEL); 364 - if (!map_memory) { 365 - dev_err(&fn->dev, "Failed to allocate gpioled map memory.\n"); 366 - return -ENOMEM; 367 - } 368 - 369 - f30->gpioled_key_map = (u16 *)map_memory; 370 - 371 - pdata = rmi_get_platform_data(rmi_dev); 372 340 if (f30->has_gpio) { 373 - button = BTN_LEFT; 374 - for (i = 0; i < f30->gpioled_count; i++) { 375 - if (rmi_f30_is_valid_button(i, f30->ctrl)) { 376 - f30->gpioled_key_map[i] = button++; 377 - 378 - /* 379 - * buttonpad might be given by 380 - * f30->has_mech_mouse_btns, but I am 381 - * not sure, so use only the pdata info 382 - */ 383 - if (pdata->f30_data.buttonpad) 384 - break; 385 - } 386 - } 341 + error = rmi_f30_map_gpios(fn, f30); 342 + if (error) 343 + return error; 387 344 } 388 345 389 346 return 0; ··· 361 378 362 379 static int rmi_f30_probe(struct rmi_function *fn) 363 380 { 364 - int rc; 381 + struct rmi_device *rmi_dev = fn->rmi_dev; 365 382 const struct rmi_device_platform_data *pdata = 366 - rmi_get_platform_data(fn->rmi_dev); 383 + rmi_get_platform_data(rmi_dev); 384 + struct rmi_driver_data *drv_data = dev_get_drvdata(&rmi_dev->dev); 385 + struct f30_data *f30; 386 + int error; 367 387 368 388 if (pdata->f30_data.disable) 369 389 return 0; 370 390 371 - rc = rmi_f30_initialize(fn); 372 - if (rc < 0) 373 - goto error_exit; 391 + if (!drv_data->input) { 392 + dev_info(&fn->dev, "F30: no input device found, ignoring\n"); 393 + return -ENXIO; 394 + } 374 395 375 - rc = rmi_f30_register_device(fn); 376 - if (rc < 0) 377 - goto error_exit; 396 + f30 = devm_kzalloc(&fn->dev, sizeof(*f30), GFP_KERNEL); 397 + if (!f30) 398 + return -ENOMEM; 378 399 400 + f30->input = drv_data->input; 401 + 402 + error = rmi_f30_initialize(fn, f30); 403 + if (error) 404 + return error; 405 + 406 + dev_set_drvdata(&fn->dev, f30); 379 407 return 0; 380 - 381 - error_exit: 382 - return rc; 383 - 384 408 } 385 409 386 410 struct rmi_function_handler rmi_f30_handler = {
+113 -29
drivers/input/rmi4/rmi_f34.c
··· 157 157 i + 1, block_count); 158 158 159 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 165 return 0; ··· 177 174 F34_WRITE_CONFIG_BLOCK); 178 175 } 179 176 180 - int rmi_f34_enable_flash(struct f34_data *f34) 177 + static int rmi_f34_enable_flash(struct f34_data *f34) 181 178 { 182 179 return rmi_f34_command(f34, F34_ENABLE_FLASH_PROG, 183 180 F34_ENABLE_WAIT_MS, true); ··· 187 184 const struct rmi_f34_firmware *syn_fw) 188 185 { 189 186 struct rmi_function *fn = f34->fn; 187 + u32 image_size = le32_to_cpu(syn_fw->image_size); 188 + u32 config_size = le32_to_cpu(syn_fw->config_size); 190 189 int ret; 191 190 192 - if (syn_fw->image_size) { 191 + f34->update_progress = 0; 192 + f34->update_size = image_size + config_size; 193 + 194 + if (image_size) { 193 195 dev_info(&fn->dev, "Erasing firmware...\n"); 194 196 ret = rmi_f34_command(f34, F34_ERASE_ALL, 195 197 F34_ERASE_WAIT_MS, true); ··· 202 194 return ret; 203 195 204 196 dev_info(&fn->dev, "Writing firmware (%d bytes)...\n", 205 - syn_fw->image_size); 197 + image_size); 206 198 ret = rmi_f34_write_firmware(f34, syn_fw->data); 207 199 if (ret) 208 200 return ret; 209 201 } 210 202 211 - if (syn_fw->config_size) { 203 + if (config_size) { 212 204 /* 213 205 * We only need to erase config if we haven't updated 214 206 * firmware. 215 207 */ 216 - if (!syn_fw->image_size) { 208 + if (!image_size) { 217 209 dev_info(&fn->dev, "Erasing config...\n"); 218 210 ret = rmi_f34_command(f34, F34_ERASE_CONFIG, 219 211 F34_ERASE_WAIT_MS, true); ··· 222 214 } 223 215 224 216 dev_info(&fn->dev, "Writing config (%d bytes)...\n", 225 - syn_fw->config_size); 226 - ret = rmi_f34_write_config(f34, 227 - &syn_fw->data[syn_fw->image_size]); 217 + config_size); 218 + ret = rmi_f34_write_config(f34, &syn_fw->data[image_size]); 228 219 if (ret) 229 220 return ret; 230 221 } ··· 231 224 return 0; 232 225 } 233 226 234 - int rmi_f34_update_firmware(struct f34_data *f34, const struct firmware *fw) 227 + static int rmi_f34_update_firmware(struct f34_data *f34, 228 + const struct firmware *fw) 235 229 { 236 - const struct rmi_f34_firmware *syn_fw; 230 + const struct rmi_f34_firmware *syn_fw = 231 + (const struct rmi_f34_firmware *)fw->data; 232 + u32 image_size = le32_to_cpu(syn_fw->image_size); 233 + u32 config_size = le32_to_cpu(syn_fw->config_size); 237 234 int ret; 238 235 239 - syn_fw = (const struct rmi_f34_firmware *)fw->data; 240 236 BUILD_BUG_ON(offsetof(struct rmi_f34_firmware, data) != 241 237 F34_FW_IMAGE_OFFSET); 242 238 243 239 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, 244 - "FW size:%d, checksum:%08x, image_size:%d, config_size:%d\n", 245 - (int)fw->size, 240 + "FW size:%zd, checksum:%08x, image_size:%d, config_size:%d\n", 241 + fw->size, 246 242 le32_to_cpu(syn_fw->checksum), 247 - le32_to_cpu(syn_fw->image_size), 248 - le32_to_cpu(syn_fw->config_size)); 243 + image_size, config_size); 249 244 250 245 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, 251 246 "FW bootloader_id:%02x, product_id:%.*s, info: %02x%02x\n", ··· 255 246 (int)sizeof(syn_fw->product_id), syn_fw->product_id, 256 247 syn_fw->product_info[0], syn_fw->product_info[1]); 257 248 258 - if (syn_fw->image_size && 259 - syn_fw->image_size != f34->v5.fw_blocks * f34->v5.block_size) { 249 + if (image_size && image_size != f34->v5.fw_blocks * f34->v5.block_size) { 260 250 dev_err(&f34->fn->dev, 261 251 "Bad firmware image: fw size %d, expected %d\n", 262 - syn_fw->image_size, 263 - f34->v5.fw_blocks * f34->v5.block_size); 252 + image_size, f34->v5.fw_blocks * f34->v5.block_size); 264 253 ret = -EILSEQ; 265 254 goto out; 266 255 } 267 256 268 - if (syn_fw->config_size && 269 - syn_fw->config_size != f34->v5.config_blocks * f34->v5.block_size) { 257 + if (config_size && 258 + config_size != f34->v5.config_blocks * f34->v5.block_size) { 270 259 dev_err(&f34->fn->dev, 271 260 "Bad firmware image: config size %d, expected %d\n", 272 - syn_fw->config_size, 261 + config_size, 273 262 f34->v5.config_blocks * f34->v5.block_size); 274 263 ret = -EILSEQ; 275 264 goto out; 276 265 } 277 266 278 - if (syn_fw->image_size && !syn_fw->config_size) { 267 + if (image_size && !config_size) { 279 268 dev_err(&f34->fn->dev, "Bad firmware image: no config data\n"); 280 269 ret = -EILSEQ; 281 270 goto out; ··· 289 282 out: 290 283 return ret; 291 284 } 285 + 286 + static int rmi_f34_status(struct rmi_function *fn) 287 + { 288 + struct f34_data *f34 = dev_get_drvdata(&fn->dev); 289 + 290 + /* 291 + * The status is the percentage complete, or once complete, 292 + * zero for success or a negative return code. 293 + */ 294 + return f34->update_status; 295 + } 296 + 297 + static ssize_t rmi_driver_bootloader_id_show(struct device *dev, 298 + struct device_attribute *dattr, 299 + char *buf) 300 + { 301 + struct rmi_driver_data *data = dev_get_drvdata(dev); 302 + struct rmi_function *fn = data->f34_container; 303 + struct f34_data *f34; 304 + 305 + if (fn) { 306 + f34 = dev_get_drvdata(&fn->dev); 307 + 308 + if (f34->bl_version == 5) 309 + return scnprintf(buf, PAGE_SIZE, "%c%c\n", 310 + f34->bootloader_id[0], 311 + f34->bootloader_id[1]); 312 + else 313 + return scnprintf(buf, PAGE_SIZE, "V%d.%d\n", 314 + f34->bootloader_id[1], 315 + f34->bootloader_id[0]); 316 + } 317 + 318 + return 0; 319 + } 320 + 321 + static DEVICE_ATTR(bootloader_id, 0444, rmi_driver_bootloader_id_show, NULL); 322 + 323 + static ssize_t rmi_driver_configuration_id_show(struct device *dev, 324 + struct device_attribute *dattr, 325 + char *buf) 326 + { 327 + struct rmi_driver_data *data = dev_get_drvdata(dev); 328 + struct rmi_function *fn = data->f34_container; 329 + struct f34_data *f34; 330 + 331 + if (fn) { 332 + f34 = dev_get_drvdata(&fn->dev); 333 + 334 + return scnprintf(buf, PAGE_SIZE, "%s\n", f34->configuration_id); 335 + } 336 + 337 + return 0; 338 + } 339 + 340 + static DEVICE_ATTR(configuration_id, 0444, 341 + rmi_driver_configuration_id_show, NULL); 292 342 293 343 static int rmi_firmware_update(struct rmi_driver_data *data, 294 344 const struct firmware *fw) ··· 410 346 else 411 347 ret = rmi_f34_update_firmware(f34, fw); 412 348 413 - dev_info(&f34->fn->dev, "Firmware update complete, status:%d\n", ret); 349 + if (ret) { 350 + f34->update_status = ret; 351 + dev_err(&f34->fn->dev, 352 + "Firmware update failed, status: %d\n", ret); 353 + } else { 354 + dev_info(&f34->fn->dev, "Firmware update complete\n"); 355 + } 414 356 415 357 rmi_disable_irq(rmi_dev, false); 416 358 ··· 446 376 447 377 return ret; 448 378 } 449 - 450 - static int rmi_firmware_update(struct rmi_driver_data *data, 451 - const struct firmware *fw); 452 379 453 380 static ssize_t rmi_driver_update_fw_store(struct device *dev, 454 381 struct device_attribute *dattr, ··· 481 414 482 415 static DEVICE_ATTR(update_fw, 0200, NULL, rmi_driver_update_fw_store); 483 416 417 + static ssize_t rmi_driver_update_fw_status_show(struct device *dev, 418 + struct device_attribute *dattr, 419 + char *buf) 420 + { 421 + struct rmi_driver_data *data = dev_get_drvdata(dev); 422 + int update_status = 0; 423 + 424 + if (data->f34_container) 425 + update_status = rmi_f34_status(data->f34_container); 426 + 427 + return scnprintf(buf, PAGE_SIZE, "%d\n", update_status); 428 + } 429 + 430 + static DEVICE_ATTR(update_fw_status, 0444, 431 + rmi_driver_update_fw_status_show, NULL); 432 + 484 433 static struct attribute *rmi_firmware_attrs[] = { 434 + &dev_attr_bootloader_id.attr, 435 + &dev_attr_configuration_id.attr, 485 436 &dev_attr_update_fw.attr, 437 + &dev_attr_update_fw_status.attr, 486 438 NULL 487 439 }; 488 440 ··· 527 441 /* v5 code only supported version 0, try V7 probe */ 528 442 if (version > 0) 529 443 return rmi_f34v7_probe(f34); 530 - else if (version != 0) 531 - return -ENODEV; 532 444 533 445 f34->bl_version = 5; 534 446
+4
drivers/input/rmi4/rmi_f34.h
··· 301 301 unsigned char bootloader_id[5]; 302 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 308 union { 305 309 struct f34v5_data v5; 306 310 struct f34v7_data v7;
+11
drivers/input/rmi4/rmi_f34v7.c
··· 588 588 u16 block_count; 589 589 590 590 block_count = f34->v7.img.ui_firmware.size / f34->v7.block_size; 591 + f34->update_size += block_count; 591 592 592 593 if (block_count != f34->v7.blkcount.ui_firmware) { 593 594 dev_err(&f34->fn->dev, ··· 605 604 u16 block_count; 606 605 607 606 block_count = f34->v7.img.ui_config.size / f34->v7.block_size; 607 + f34->update_size += block_count; 608 608 609 609 if (block_count != f34->v7.blkcount.ui_config) { 610 610 dev_err(&f34->fn->dev, "UI config size mismatch\n"); ··· 620 618 u16 block_count; 621 619 622 620 block_count = f34->v7.img.dp_config.size / f34->v7.block_size; 621 + f34->update_size += block_count; 623 622 624 623 if (block_count != f34->v7.blkcount.dp_config) { 625 624 dev_err(&f34->fn->dev, "Display config size mismatch\n"); ··· 635 632 u16 block_count; 636 633 637 634 block_count = f34->v7.img.guest_code.size / f34->v7.block_size; 635 + f34->update_size += block_count; 636 + 638 637 if (block_count != f34->v7.blkcount.guest_code) { 639 638 dev_err(&f34->fn->dev, "Guest code size mismatch\n"); 640 639 return -EINVAL; ··· 650 645 u16 block_count; 651 646 652 647 block_count = f34->v7.img.bl_config.size / f34->v7.block_size; 648 + f34->update_size += block_count; 653 649 654 650 if (block_count != f34->v7.blkcount.bl_config) { 655 651 dev_err(&f34->fn->dev, "Bootloader config size mismatch\n"); ··· 887 881 888 882 block_ptr += (transfer * f34->v7.block_size); 889 883 remaining -= transfer; 884 + f34->update_progress += transfer; 885 + f34->update_status = (f34->update_progress * 100) / 886 + f34->update_size; 890 887 } while (remaining); 891 888 892 889 return 0; ··· 1200 1191 rmi_f34v7_read_queries_bl_version(f34); 1201 1192 1202 1193 f34->v7.image = fw->data; 1194 + f34->update_progress = 0; 1195 + f34->update_size = 0; 1203 1196 1204 1197 ret = rmi_f34v7_parse_image_info(f34); 1205 1198 if (ret < 0)
+3 -9
drivers/input/serio/at32psif.c
··· 159 159 160 160 retval = clk_enable(psif->pclk); 161 161 if (retval) 162 - goto out; 162 + return retval; 163 163 164 164 psif_writel(psif, CR, PSIF_BIT(CR_TXEN) | PSIF_BIT(CR_RXEN)); 165 165 psif_writel(psif, IER, PSIF_BIT(RXRDY)); 166 166 167 167 psif->open = true; 168 - out: 169 168 return retval; 170 169 } 171 170 ··· 209 210 int ret; 210 211 211 212 psif = kzalloc(sizeof(struct psif), GFP_KERNEL); 212 - if (!psif) { 213 - dev_dbg(&pdev->dev, "out of memory\n"); 214 - ret = -ENOMEM; 215 - goto out; 216 - } 213 + if (!psif) 214 + return -ENOMEM; 217 215 psif->pdev = pdev; 218 216 219 217 io = kzalloc(sizeof(struct serio), GFP_KERNEL); 220 218 if (!io) { 221 - dev_dbg(&pdev->dev, "out of memory\n"); 222 219 ret = -ENOMEM; 223 220 goto out_free_psif; 224 221 } ··· 292 297 kfree(io); 293 298 out_free_psif: 294 299 kfree(psif); 295 - out: 296 300 return ret; 297 301 } 298 302
-1
drivers/input/serio/hyperv-keyboard.c
··· 402 402 { 403 403 struct hv_kbd_dev *kbd_dev = hv_get_drvdata(hv_dev); 404 404 405 - device_init_wakeup(&hv_dev->device, false); 406 405 serio_unregister_port(kbd_dev->hv_serio); 407 406 vmbus_close(hv_dev->channel); 408 407 kfree(kbd_dev);
+8
drivers/input/serio/i8042-x86ia64io.h
··· 923 923 .name = "i8042 kbd", 924 924 .id_table = pnp_kbd_devids, 925 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 932 static struct pnp_device_id pnp_aux_devids[] = { ··· 949 945 .name = "i8042 aux", 950 946 .id_table = pnp_aux_devids, 951 947 .probe = i8042_pnp_aux_probe, 948 + .driver = { 949 + .probe_type = PROBE_FORCE_SYNCHRONOUS, 950 + .suppress_bind_attrs = true, 951 + }, 952 952 }; 953 953 954 954 static void i8042_pnp_exit(void)
+4 -2
drivers/input/serio/i8042.c
··· 312 312 313 313 for (i = 0; i < ((command >> 12) & 0xf); i++) { 314 314 error = i8042_wait_write(); 315 - if (error) 315 + if (error) { 316 + dbg(" -- i8042 (wait write timeout)\n"); 316 317 return error; 318 + } 317 319 dbg("%02x -> i8042 (parameter)\n", param[i]); 318 320 i8042_write_data(param[i]); 319 321 } ··· 323 321 for (i = 0; i < ((command >> 8) & 0xf); i++) { 324 322 error = i8042_wait_read(); 325 323 if (error) { 326 - dbg(" -- i8042 (timeout)\n"); 324 + dbg(" -- i8042 (wait read timeout)\n"); 327 325 return error; 328 326 } 329 327
+3 -4
drivers/input/serio/xilinx_ps2.c
··· 243 243 unsigned int irq; 244 244 int error; 245 245 246 - dev_info(dev, "Device Tree Probing \'%s\'\n", 247 - ofdev->dev.of_node->name); 246 + dev_info(dev, "Device Tree Probing \'%s\'\n", dev->of_node->name); 248 247 249 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 250 if (error) { 252 251 dev_err(dev, "invalid address\n"); 253 252 return error; 254 253 } 255 254 256 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 257 if (!irq) { 259 258 dev_err(dev, "no IRQ found\n"); 260 259 return -ENODEV;
-3
drivers/input/touchscreen/88pm860x-ts.c
··· 240 240 if (!touch) 241 241 return -ENOMEM; 242 242 243 - platform_set_drvdata(pdev, touch); 244 - 245 243 touch->idev = devm_input_allocate_device(&pdev->dev); 246 244 if (!touch->idev) { 247 245 dev_err(&pdev->dev, "Failed to allocate input device!\n"); ··· 283 285 return ret; 284 286 } 285 287 286 - platform_set_drvdata(pdev, touch); 287 288 return 0; 288 289 } 289 290
+11 -12
drivers/input/touchscreen/Kconfig
··· 546 546 To compile this driver as a module, choose M here: the 547 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 549 config TOUCHSCREEN_MK712 562 550 tristate "ICS MicroClock MK712 touchscreen" 563 551 help ··· 1164 1176 1165 1177 To compile this driver as a module, choose M here: the 1166 1178 module will be called tps6507x_ts. 1179 + 1180 + config TOUCHSCREEN_ZET6223 1181 + tristate "Zeitec ZET6223 touchscreen driver" 1182 + depends on I2C 1183 + help 1184 + Say Y here if you have a touchscreen using Zeitec ZET6223 1185 + 1186 + If unsure, say N. 1187 + 1188 + To compile this driver as a module, choose M here: the 1189 + module will be called zet6223. 1167 1190 1168 1191 config TOUCHSCREEN_ZFORCE 1169 1192 tristate "Neonode zForce infrared touchscreens"
+1 -1
drivers/input/touchscreen/Makefile
··· 42 42 obj-$(CONFIG_TOUCHSCREEN_ILI210X) += ili210x.o 43 43 obj-$(CONFIG_TOUCHSCREEN_IMX6UL_TSC) += imx6ul_tsc.o 44 44 obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o 45 - obj-$(CONFIG_TOUCHSCREEN_INTEL_MID) += intel-mid-touch.o 46 45 obj-$(CONFIG_TOUCHSCREEN_IPROC) += bcm_iproc_tsc.o 47 46 obj-$(CONFIG_TOUCHSCREEN_LPC32XX) += lpc32xx_ts.o 48 47 obj-$(CONFIG_TOUCHSCREEN_MAX11801) += max11801_ts.o ··· 95 96 obj-$(CONFIG_TOUCHSCREEN_W90X900) += w90p910_ts.o 96 97 obj-$(CONFIG_TOUCHSCREEN_SX8654) += sx8654.o 97 98 obj-$(CONFIG_TOUCHSCREEN_TPS6507X) += tps6507x-ts.o 99 + obj-$(CONFIG_TOUCHSCREEN_ZET6223) += zet6223.o 98 100 obj-$(CONFIG_TOUCHSCREEN_ZFORCE) += zforce_ts.o 99 101 obj-$(CONFIG_TOUCHSCREEN_COLIBRI_VF50) += colibri-vf50-ts.o 100 102 obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023) += rohm_bu21023.o
-2
drivers/input/touchscreen/ads7846.c
··· 1462 1462 { 1463 1463 struct ads7846 *ts = spi_get_drvdata(spi); 1464 1464 1465 - device_init_wakeup(&spi->dev, false); 1466 - 1467 1465 sysfs_remove_group(&spi->dev.kobj, &ads784x_attr_group); 1468 1466 1469 1467 ads7846_disable(ts);
-1
drivers/input/touchscreen/ar1021_i2c.c
··· 127 127 return error; 128 128 } 129 129 130 - i2c_set_clientdata(client, ar1021); 131 130 return 0; 132 131 } 133 132
+1 -3
drivers/input/touchscreen/atmel-wm97xx.c
··· 339 339 int ret; 340 340 341 341 atmel_wm97xx = kzalloc(sizeof(struct atmel_wm97xx), GFP_KERNEL); 342 - if (!atmel_wm97xx) { 343 - dev_dbg(&pdev->dev, "out of memory\n"); 342 + if (!atmel_wm97xx) 344 343 return -ENOMEM; 345 - } 346 344 347 345 atmel_wm97xx->wm = wm; 348 346 atmel_wm97xx->regs = (void *)ATMEL_WM97XX_AC97C_IOMEM;
+1 -1
drivers/input/touchscreen/atmel_mxt_ts.c
··· 2509 2509 dbg->t37_pages = MXT1386_COLUMNS * MXT1386_PAGES_PER_COLUMN; 2510 2510 else 2511 2511 dbg->t37_pages = DIV_ROUND_UP(data->xsize * 2512 - data->info.matrix_ysize * 2512 + info->matrix_ysize * 2513 2513 sizeof(u16), 2514 2514 sizeof(dbg->t37_buf->data)); 2515 2515
-2
drivers/input/touchscreen/bu21013_ts.c
··· 637 637 638 638 kfree(bu21013_data); 639 639 640 - device_init_wakeup(&client->dev, false); 641 - 642 640 return 0; 643 641 } 644 642
-2
drivers/input/touchscreen/colibri-vf50-ts.c
··· 311 311 return -ENOMEM; 312 312 } 313 313 314 - platform_set_drvdata(pdev, touchdev); 315 - 316 314 input->name = DRIVER_NAME; 317 315 input->id.bustype = BUS_HOST; 318 316 input->dev.parent = dev;
+2 -3
drivers/input/touchscreen/edt-ft5x06.c
··· 67 67 #define EDT_SWITCH_MODE_RETRIES 10 68 68 #define EDT_SWITCH_MODE_DELAY 5 /* msec */ 69 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 72 enum edt_ver { 73 73 M06, ··· 664 664 } 665 665 666 666 do { 667 - msleep(EDT_RAW_DATA_DELAY); 667 + usleep_range(EDT_RAW_DATA_DELAY, EDT_RAW_DATA_DELAY + 100); 668 668 val = edt_ft5x06_register_read(tsdata, 0x08); 669 669 if (val < 1) 670 670 break; ··· 982 982 return error; 983 983 } 984 984 985 - input_set_drvdata(input, tsdata); 986 985 i2c_set_clientdata(client, tsdata); 987 986 988 987 irq_flags = irq_get_trigger_type(client->irq);
+1 -4
drivers/input/touchscreen/eeti_ts.c
··· 173 173 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 174 174 if (!priv) { 175 175 dev_err(&client->dev, "failed to allocate driver data\n"); 176 - goto err0; 176 + return -ENOMEM; 177 177 } 178 178 179 179 mutex_init(&priv->mutex); 180 180 input = input_allocate_device(); 181 - 182 181 if (!input) { 183 182 dev_err(&client->dev, "Failed to allocate input device.\n"); 184 183 goto err1; ··· 231 232 */ 232 233 eeti_ts_stop(priv); 233 234 234 - device_init_wakeup(&client->dev, 0); 235 235 return 0; 236 236 237 237 err3: ··· 241 243 err1: 242 244 input_free_device(input); 243 245 kfree(priv); 244 - err0: 245 246 return err; 246 247 } 247 248
-3
drivers/input/touchscreen/egalax_ts.c
··· 214 214 ABS_MT_POSITION_Y, 0, EGALAX_MAX_Y, 0, 0); 215 215 input_mt_init_slots(input_dev, MAX_SUPPORT_POINTS, 0); 216 216 217 - input_set_drvdata(input_dev, ts); 218 - 219 217 error = devm_request_threaded_irq(&client->dev, client->irq, NULL, 220 218 egalax_ts_interrupt, 221 219 IRQF_TRIGGER_LOW | IRQF_ONESHOT, ··· 227 229 if (error) 228 230 return error; 229 231 230 - i2c_set_clientdata(client, ts); 231 232 return 0; 232 233 } 233 234
-2
drivers/input/touchscreen/elants_i2c.c
··· 1260 1260 input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->x_res); 1261 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 1263 error = input_register_device(ts->input); 1266 1264 if (error) { 1267 1265 dev_err(&client->dev,
+1 -1
drivers/input/touchscreen/fsl-imx25-tcq.c
··· 507 507 struct device *dev = &pdev->dev; 508 508 struct input_dev *idev; 509 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 511 struct resource *res; 512 512 void __iomem *mem; 513 513 int error;
+1 -2
drivers/input/touchscreen/ili210x.c
··· 256 256 input_set_abs_params(input, ABS_MT_POSITION_X, 0, xmax, 0, 0); 257 257 input_set_abs_params(input, ABS_MT_POSITION_Y, 0, ymax, 0, 0); 258 258 259 - input_set_drvdata(input, priv); 260 259 i2c_set_clientdata(client, priv); 261 260 262 261 error = request_irq(client->irq, ili210x_irq, pdata->irq_flags, ··· 279 280 goto err_remove_sysfs; 280 281 } 281 282 282 - device_init_wakeup(&client->dev, 1); 283 + device_init_wakeup(dev, 1); 283 284 284 285 dev_dbg(dev, 285 286 "ILI210x initialized (IRQ: %d), firmware version %d.%d.%d",
-654
drivers/input/touchscreen/intel-mid-touch.c
··· 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");
-1
drivers/input/touchscreen/lpc32xx_ts.c
··· 313 313 struct lpc32xx_tsc *tsc = platform_get_drvdata(pdev); 314 314 struct resource *res; 315 315 316 - device_init_wakeup(&pdev->dev, 0); 317 316 free_irq(tsc->irq, tsc); 318 317 319 318 input_unregister_device(tsc->dev);
-2
drivers/input/touchscreen/max11801_ts.c
··· 199 199 __set_bit(BTN_TOUCH, input_dev->keybit); 200 200 input_set_abs_params(input_dev, ABS_X, 0, MAX11801_MAX_X, 0, 0); 201 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 203 max11801_ts_phy_init(data); 205 204 ··· 215 216 if (error) 216 217 return error; 217 218 218 - i2c_set_clientdata(client, data); 219 219 return 0; 220 220 } 221 221
-1
drivers/input/touchscreen/mcs5000_ts.c
··· 221 221 input_set_abs_params(input_dev, ABS_X, 0, MCS5000_MAX_XC, 0, 0); 222 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 224 data->input_dev = input_dev; 226 225 227 226 if (pdata->cfg_pin)
+2 -2
drivers/input/touchscreen/pixcir_i2c_ts.c
··· 461 461 if (error) 462 462 return error; 463 463 } else { 464 - dev_err(&client->dev, "platform data not defined\n"); 464 + dev_err(dev, "platform data not defined\n"); 465 465 return -EINVAL; 466 466 } 467 467 ··· 483 483 input->id.bustype = BUS_I2C; 484 484 input->open = pixcir_input_open; 485 485 input->close = pixcir_input_close; 486 - input->dev.parent = &client->dev; 486 + input->dev.parent = dev; 487 487 488 488 if (pdata) { 489 489 input_set_abs_params(input, ABS_MT_POSITION_X, 0, pdata->x_max, 0, 0);
-2
drivers/input/touchscreen/raydium_i2c_ts.c
··· 1087 1087 ts->input->name = "Raydium Touchscreen"; 1088 1088 ts->input->id.bustype = BUS_I2C; 1089 1089 1090 - input_set_drvdata(ts->input, ts); 1091 - 1092 1090 input_set_abs_params(ts->input, ABS_MT_POSITION_X, 1093 1091 0, le16_to_cpu(ts->info.x_max), 0, 0); 1094 1092 input_set_abs_params(ts->input, ABS_MT_POSITION_Y,
+1 -2
drivers/input/touchscreen/rohm_bu21023.c
··· 1189 1189 error = devm_add_action(dev, rohm_ts_remove_sysfs_group, dev); 1190 1190 if (error) { 1191 1191 rohm_ts_remove_sysfs_group(dev); 1192 - dev_err(&client->dev, 1193 - "Failed to add sysfs cleanup action: %d\n", 1192 + dev_err(dev, "Failed to add sysfs cleanup action: %d\n", 1194 1193 error); 1195 1194 return error; 1196 1195 }
+1 -1
drivers/input/touchscreen/s3c2410_ts.c
··· 250 250 251 251 ts.dev = dev; 252 252 253 - info = dev_get_platdata(&pdev->dev); 253 + info = dev_get_platdata(dev); 254 254 if (!info) { 255 255 dev_err(dev, "no platform data, cannot attach\n"); 256 256 return -EINVAL;
-1
drivers/input/touchscreen/sis_i2c.c
··· 316 316 return -ENOMEM; 317 317 318 318 ts->client = client; 319 - i2c_set_clientdata(client, ts); 320 319 321 320 ts->attn_gpio = devm_gpiod_get_optional(&client->dev, 322 321 "attn", GPIOD_IN);
-1
drivers/input/touchscreen/st1232.c
··· 237 237 { 238 238 struct st1232_ts_data *ts = i2c_get_clientdata(client); 239 239 240 - device_init_wakeup(&client->dev, 0); 241 240 st1232_ts_power(ts, false); 242 241 243 242 return 0;
-1
drivers/input/touchscreen/sx8654.c
··· 253 253 if (error) 254 254 return error; 255 255 256 - i2c_set_clientdata(client, sx8654); 257 256 return 0; 258 257 } 259 258
+11 -1
drivers/input/touchscreen/tsc2005.c
··· 18 18 * GNU General Public License for more details. 19 19 */ 20 20 21 - #include <linux/module.h> 22 21 #include <linux/input.h> 22 + #include <linux/module.h> 23 + #include <linux/of.h> 23 24 #include <linux/spi/spi.h> 24 25 #include <linux/regmap.h> 25 26 #include "tsc200x-core.h" ··· 78 77 return tsc200x_remove(&spi->dev); 79 78 } 80 79 80 + #ifdef CONFIG_OF 81 + static const struct of_device_id tsc2005_of_match[] = { 82 + { .compatible = "ti,tsc2005" }, 83 + { /* sentinel */ } 84 + }; 85 + MODULE_DEVICE_TABLE(of, tsc2005_of_match); 86 + #endif 87 + 81 88 static struct spi_driver tsc2005_driver = { 82 89 .driver = { 83 90 .name = "tsc2005", 91 + .of_match_table = of_match_ptr(tsc2005_of_match), 84 92 .pm = &tsc200x_pm_ops, 85 93 }, 86 94 .probe = tsc2005_probe,
+37 -75
drivers/input/touchscreen/tsc200x-core.c
··· 27 27 #include <linux/delay.h> 28 28 #include <linux/pm.h> 29 29 #include <linux/of.h> 30 - #include <linux/spi/tsc2005.h> 31 30 #include <linux/regulator/consumer.h> 32 31 #include <linux/regmap.h> 33 32 #include <linux/gpio/consumer.h> ··· 113 114 struct regulator *vio; 114 115 115 116 struct gpio_desc *reset_gpio; 116 - void (*set_reset)(bool enable); 117 117 int (*tsc200x_cmd)(struct device *dev, u8 cmd); 118 118 int irq; 119 119 }; ··· 225 227 ts->tsc200x_cmd(ts->dev, TSC200X_CMD_STOP); 226 228 } 227 229 228 - static void tsc200x_set_reset(struct tsc200x *ts, bool enable) 230 + static void tsc200x_reset(struct tsc200x *ts) 229 231 { 230 - if (ts->reset_gpio) 231 - gpiod_set_value_cansleep(ts->reset_gpio, enable); 232 - else if (ts->set_reset) 233 - ts->set_reset(enable); 232 + if (ts->reset_gpio) { 233 + gpiod_set_value_cansleep(ts->reset_gpio, 1); 234 + usleep_range(100, 500); /* only 10us required */ 235 + gpiod_set_value_cansleep(ts->reset_gpio, 0); 236 + } 234 237 } 235 238 236 239 /* must be called with ts->mutex held */ ··· 252 253 { 253 254 tsc200x_start_scan(ts); 254 255 255 - if (ts->esd_timeout && (ts->set_reset || ts->reset_gpio)) { 256 + if (ts->esd_timeout && ts->reset_gpio) { 256 257 ts->last_valid_interrupt = jiffies; 257 258 schedule_delayed_work(&ts->esd_work, 258 259 round_jiffies_relative( ··· 309 310 } 310 311 311 312 /* hardware reset */ 312 - tsc200x_set_reset(ts, false); 313 - usleep_range(100, 500); /* only 10us required */ 314 - tsc200x_set_reset(ts, true); 313 + tsc200x_reset(ts); 315 314 316 315 if (!success) 317 316 goto out; ··· 351 354 umode_t mode = attr->mode; 352 355 353 356 if (attr == &dev_attr_selftest.attr) { 354 - if (!ts->set_reset && !ts->reset_gpio) 357 + if (!ts->reset_gpio) 355 358 mode = 0; 356 359 } 357 360 ··· 401 404 402 405 tsc200x_update_pen_state(ts, 0, 0, 0); 403 406 404 - tsc200x_set_reset(ts, false); 405 - usleep_range(100, 500); /* only 10us required */ 406 - tsc200x_set_reset(ts, true); 407 + tsc200x_reset(ts); 407 408 408 409 enable_irq(ts->irq); 409 410 tsc200x_start_scan(ts); ··· 449 454 struct regmap *regmap, 450 455 int (*tsc200x_cmd)(struct device *dev, u8 cmd)) 451 456 { 452 - const struct tsc2005_platform_data *pdata = dev_get_platdata(dev); 453 - struct device_node *np = dev->of_node; 454 - 455 457 struct tsc200x *ts; 456 458 struct input_dev *input_dev; 457 - unsigned int max_x = MAX_12BIT; 458 - unsigned int max_y = MAX_12BIT; 459 - unsigned int max_p = MAX_12BIT; 460 - unsigned int fudge_x = TSC200X_DEF_X_FUZZ; 461 - unsigned int fudge_y = TSC200X_DEF_Y_FUZZ; 462 - unsigned int fudge_p = TSC200X_DEF_P_FUZZ; 463 - unsigned int x_plate_ohm = TSC200X_DEF_RESISTOR; 464 - unsigned int esd_timeout; 459 + u32 x_plate_ohm; 460 + u32 esd_timeout; 465 461 int error; 466 - 467 - if (!np && !pdata) { 468 - dev_err(dev, "no platform data\n"); 469 - return -ENODEV; 470 - } 471 462 472 463 if (irq <= 0) { 473 464 dev_err(dev, "no irq\n"); ··· 466 485 if (!tsc200x_cmd) { 467 486 dev_err(dev, "no cmd function\n"); 468 487 return -ENODEV; 469 - } 470 - 471 - if (pdata) { 472 - fudge_x = pdata->ts_x_fudge; 473 - fudge_y = pdata->ts_y_fudge; 474 - fudge_p = pdata->ts_pressure_fudge; 475 - max_x = pdata->ts_x_max; 476 - max_y = pdata->ts_y_max; 477 - max_p = pdata->ts_pressure_max; 478 - x_plate_ohm = pdata->ts_x_plate_ohm; 479 - esd_timeout = pdata->esd_timeout_ms; 480 - } else { 481 - x_plate_ohm = TSC200X_DEF_RESISTOR; 482 - of_property_read_u32(np, "ti,x-plate-ohms", &x_plate_ohm); 483 - esd_timeout = 0; 484 - of_property_read_u32(np, "ti,esd-recovery-timeout-ms", 485 - &esd_timeout); 486 488 } 487 489 488 490 ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL); ··· 481 517 ts->idev = input_dev; 482 518 ts->regmap = regmap; 483 519 ts->tsc200x_cmd = tsc200x_cmd; 484 - ts->x_plate_ohm = x_plate_ohm; 485 - ts->esd_timeout = esd_timeout; 520 + 521 + error = device_property_read_u32(dev, "ti,x-plate-ohms", &x_plate_ohm); 522 + ts->x_plate_ohm = error ? TSC200X_DEF_RESISTOR : x_plate_ohm; 523 + 524 + error = device_property_read_u32(dev, "ti,esd-recovery-timeout-ms", 525 + &esd_timeout); 526 + ts->esd_timeout = error ? 0 : esd_timeout; 486 527 487 528 ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); 488 529 if (IS_ERR(ts->reset_gpio)) { ··· 496 527 return error; 497 528 } 498 529 499 - ts->vio = devm_regulator_get_optional(dev, "vio"); 530 + ts->vio = devm_regulator_get(dev, "vio"); 500 531 if (IS_ERR(ts->vio)) { 501 532 error = PTR_ERR(ts->vio); 502 - dev_err(dev, "vio regulator missing (%d)", error); 533 + dev_err(dev, "error acquiring vio regulator: %d", error); 503 534 return error; 504 535 } 505 - 506 - if (!ts->reset_gpio && pdata) 507 - ts->set_reset = pdata->set_reset; 508 536 509 537 mutex_init(&ts->mutex); 510 538 ··· 525 559 526 560 input_dev->phys = ts->phys; 527 561 input_dev->id = *tsc_id; 528 - input_dev->dev.parent = dev; 529 - input_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY); 530 - input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); 531 - 532 - input_set_abs_params(input_dev, ABS_X, 0, max_x, fudge_x, 0); 533 - input_set_abs_params(input_dev, ABS_Y, 0, max_y, fudge_y, 0); 534 - input_set_abs_params(input_dev, ABS_PRESSURE, 0, max_p, fudge_p, 0); 535 - 536 - if (np) 537 - touchscreen_parse_properties(input_dev, false, NULL); 538 562 539 563 input_dev->open = tsc200x_open; 540 564 input_dev->close = tsc200x_close; 541 565 542 566 input_set_drvdata(input_dev, ts); 567 + 568 + input_set_capability(input_dev, EV_KEY, BTN_TOUCH); 569 + 570 + input_set_abs_params(input_dev, ABS_X, 571 + 0, MAX_12BIT, TSC200X_DEF_X_FUZZ, 0); 572 + input_set_abs_params(input_dev, ABS_Y, 573 + 0, MAX_12BIT, TSC200X_DEF_Y_FUZZ, 0); 574 + input_set_abs_params(input_dev, ABS_PRESSURE, 575 + 0, MAX_12BIT, TSC200X_DEF_P_FUZZ, 0); 576 + 577 + touchscreen_parse_properties(input_dev, false, NULL); 543 578 544 579 /* Ensure the touchscreen is off */ 545 580 tsc200x_stop_scan(ts); ··· 554 587 return error; 555 588 } 556 589 557 - /* enable regulator for DT */ 558 - if (ts->vio) { 559 - error = regulator_enable(ts->vio); 560 - if (error) 561 - return error; 562 - } 590 + error = regulator_enable(ts->vio); 591 + if (error) 592 + return error; 563 593 564 594 dev_set_drvdata(dev, ts); 565 595 error = sysfs_create_group(&dev->kobj, &tsc200x_attr_group); ··· 579 615 err_remove_sysfs: 580 616 sysfs_remove_group(&dev->kobj, &tsc200x_attr_group); 581 617 disable_regulator: 582 - if (ts->vio) 583 - regulator_disable(ts->vio); 618 + regulator_disable(ts->vio); 584 619 return error; 585 620 } 586 621 EXPORT_SYMBOL_GPL(tsc200x_probe); ··· 590 627 591 628 sysfs_remove_group(&dev->kobj, &tsc200x_attr_group); 592 629 593 - if (ts->vio) 594 - regulator_disable(ts->vio); 630 + regulator_disable(ts->vio); 595 631 596 632 return 0; 597 633 }
+268
drivers/input/touchscreen/zet6223.c
··· 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");
-20
include/linux/i2c/mpr121_touchkey.h
··· 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 */
+3 -18
include/linux/input/matrix_keypad.h
··· 80 80 unsigned int rows, unsigned int cols, 81 81 unsigned short *keymap, 82 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 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 */ 86 + #define matrix_keypad_parse_of_params matrix_keypad_parse_properties 102 87 103 88 #endif /* _MATRIX_KEYPAD_H */
-44
include/linux/input/tca8418_keypad.h
··· 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
+72 -2
include/linux/mfd/cros_ec_commands.h
··· 1839 1839 * 1840 1840 * Returns raw data for keyboard cols; see ec_response_mkbp_info.cols for 1841 1841 * expected response size. 1842 + * 1843 + * NOTE: This has been superseded by EC_CMD_MKBP_GET_NEXT_EVENT. If you wish 1844 + * to obtain the instantaneous state, use EC_CMD_MKBP_INFO with the type 1845 + * EC_MKBP_INFO_CURRENT and event EC_MKBP_EVENT_KEY_MATRIX. 1842 1846 */ 1843 1847 #define EC_CMD_MKBP_STATE 0x60 1844 1848 1845 - /* Provide information about the matrix : number of rows and columns */ 1849 + /* 1850 + * Provide information about various MKBP things. See enum ec_mkbp_info_type. 1851 + */ 1846 1852 #define EC_CMD_MKBP_INFO 0x61 1847 1853 1848 1854 struct ec_response_mkbp_info { 1849 1855 uint32_t rows; 1850 1856 uint32_t cols; 1851 - uint8_t switches; 1857 + /* Formerly "switches", which was 0. */ 1858 + uint8_t reserved; 1852 1859 } __packed; 1860 + 1861 + struct ec_params_mkbp_info { 1862 + uint8_t info_type; 1863 + uint8_t event_type; 1864 + } __packed; 1865 + 1866 + enum ec_mkbp_info_type { 1867 + /* 1868 + * Info about the keyboard matrix: number of rows and columns. 1869 + * 1870 + * Returns struct ec_response_mkbp_info. 1871 + */ 1872 + EC_MKBP_INFO_KBD = 0, 1873 + 1874 + /* 1875 + * For buttons and switches, info about which specifically are 1876 + * supported. event_type must be set to one of the values in enum 1877 + * ec_mkbp_event. 1878 + * 1879 + * For EC_MKBP_EVENT_BUTTON and EC_MKBP_EVENT_SWITCH, returns a 4 byte 1880 + * bitmask indicating which buttons or switches are present. See the 1881 + * bit inidices below. 1882 + */ 1883 + EC_MKBP_INFO_SUPPORTED = 1, 1884 + 1885 + /* 1886 + * Instantaneous state of buttons and switches. 1887 + * 1888 + * event_type must be set to one of the values in enum ec_mkbp_event. 1889 + * 1890 + * For EC_MKBP_EVENT_KEY_MATRIX, returns uint8_t key_matrix[13] 1891 + * indicating the current state of the keyboard matrix. 1892 + * 1893 + * For EC_MKBP_EVENT_HOST_EVENT, return uint32_t host_event, the raw 1894 + * event state. 1895 + * 1896 + * For EC_MKBP_EVENT_BUTTON, returns uint32_t buttons, indicating the 1897 + * state of supported buttons. 1898 + * 1899 + * For EC_MKBP_EVENT_SWITCH, returns uint32_t switches, indicating the 1900 + * state of supported switches. 1901 + */ 1902 + EC_MKBP_INFO_CURRENT = 2, 1903 + }; 1853 1904 1854 1905 /* Simulate key press */ 1855 1906 #define EC_CMD_MKBP_SIMULATE_KEY 0x62 ··· 2034 1983 /* New Sensor FIFO data. The event data is fifo_info structure. */ 2035 1984 EC_MKBP_EVENT_SENSOR_FIFO = 2, 2036 1985 1986 + /* The state of the non-matrixed buttons have changed. */ 1987 + EC_MKBP_EVENT_BUTTON = 3, 1988 + 1989 + /* The state of the switches have changed. */ 1990 + EC_MKBP_EVENT_SWITCH = 4, 1991 + 2037 1992 /* Number of MKBP events */ 2038 1993 EC_MKBP_EVENT_COUNT, 2039 1994 }; ··· 2049 1992 2050 1993 /* Unaligned */ 2051 1994 uint32_t host_event; 1995 + 1996 + uint32_t buttons; 1997 + uint32_t switches; 2052 1998 } __packed; 2053 1999 2054 2000 struct ec_response_get_next_event { ··· 2059 1999 /* Followed by event data if any */ 2060 2000 union ec_response_get_next_data data; 2061 2001 } __packed; 2002 + 2003 + /* Bit indices for buttons and switches.*/ 2004 + /* Buttons */ 2005 + #define EC_MKBP_POWER_BUTTON 0 2006 + #define EC_MKBP_VOL_UP 1 2007 + #define EC_MKBP_VOL_DOWN 2 2008 + 2009 + /* Switches */ 2010 + #define EC_MKBP_LID_OPEN 0 2011 + #define EC_MKBP_TABLET_MODE 1 2062 2012 2063 2013 /*****************************************************************************/ 2064 2014 /* Temperature sensor commands */
-34
include/linux/spi/tsc2005.h
··· 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
+4 -3
include/uapi/linux/serio.h
··· 17 17 /* 18 18 * bit masks for use in "interrupt" flags (3rd argument) 19 19 */ 20 - #define SERIO_TIMEOUT 1 21 - #define SERIO_PARITY 2 22 - #define SERIO_FRAME 4 20 + #define SERIO_TIMEOUT BIT(0) 21 + #define SERIO_PARITY BIT(1) 22 + #define SERIO_FRAME BIT(2) 23 + #define SERIO_OOB_DATA BIT(3) 23 24 24 25 /* 25 26 * Serio types