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

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input

Pull input updates from Dmitry Torokhov:

- input core allows hardware drivers to specify a [more precise]
timestamp (normally taken in top half) to better track velocity of
contacts

- input_dev instances now support "polling" mode so that drivers could
use the same object for polled and interrupt-driven operation. The
plan is to convert existing drivers and retire input_polled_dev API

- a new driver for the FlySky FS-iA6B RC receiver

- a refresh of BU21013 touchpad driver

- w90x900 keyboard and touchpad drivers are removed as the platform is
gone

- assorted fixes

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (45 commits)
Input: sidewinder - make array seq static const, makes object smaller
Input: reset device timestamp on sync
Input: bu21013_ts - switch to using standard touchscreen properties
Input: bu21013_ts - switch to using MT-B (slotted) protocol
Input: bu21013_ts - fix suspend when wake source
Input: bu21013_ts - use interrupt from I2C client
Input: bu21013_ts - remove support for platform data
Input: bu21013_ts - convert to using managed resources
Input: bu21013_ts - remove useless comments
Input: bu21013_ts - annotate supend/resume methods as __maybe_unused
Input: bu21013_ts - rename some variables
Input: bu21013_ts - convert to use GPIO descriptors
ARM: ux500: improve BU21013 touchpad bindings
Input: i8042 - enable wakeup on a stable struct device
Input: soc_button_array - use platform_device_register_resndata()
Input: psmouse - drop all unneeded functions from mouse headers
Input: add support for polling to input devices
Input: wacom_w8001 - allocate additional space for 'phys'
Input: cros_ec_keyb - add back missing mask for event_type
Input: remove dev_err() usage after platform_get_irq()
...

+1242 -1557
+21 -8
Documentation/devicetree/bindings/input/touchscreen/ads7846.txt
··· 32 32 (ADS7846). 33 33 ti,keep-vref-on set to keep vref on for differential 34 34 measurements as well 35 - ti,swap-xy swap x and y axis 36 35 ti,settle-delay-usec Settling time of the analog signals; 37 36 a function of Vcc and the capacitance 38 37 on the X/Y drivers. If set to non-zero, ··· 50 51 in Ohms (u16). 51 52 ti,x-min Minimum value on the X axis (u16). 52 53 ti,y-min Minimum value on the Y axis (u16). 53 - ti,x-max Maximum value on the X axis (u16). 54 - ti,y-max Minimum value on the Y axis (u16). 55 - ti,pressure-min Minimum reported pressure value 56 - (threshold) - u16. 57 - ti,pressure-max Maximum reported pressure value (u16). 58 - ti,debounce-max Max number of additional readings per 59 - sample (u16). 60 54 ti,debounce-tol Tolerance used for filtering (u16). 61 55 ti,debounce-rep Additional consecutive good readings 62 56 required after the first two (u16). ··· 59 67 line is connected to. 60 68 wakeup-source use any event on touchscreen as wakeup event. 61 69 (Legacy property support: "linux,wakeup") 70 + touchscreen-size-x General touchscreen binding, see [1]. 71 + touchscreen-size-y General touchscreen binding, see [1]. 72 + touchscreen-max-pressure General touchscreen binding, see [1]. 73 + touchscreen-min-pressure General touchscreen binding, see [1]. 74 + touchscreen-average-samples General touchscreen binding, see [1]. 75 + touchscreen-inverted-x General touchscreen binding, see [1]. 76 + touchscreen-inverted-y General touchscreen binding, see [1]. 77 + touchscreen-swapped-x-y General touchscreen binding, see [1]. 62 78 79 + [1] All general touchscreen properties are described in 80 + Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt. 81 + 82 + Deprecated properties: 83 + 84 + ti,swap-xy swap x and y axis 85 + ti,x-max Maximum value on the X axis (u16). 86 + ti,y-max Maximum value on the Y axis (u16). 87 + ti,pressure-min Minimum reported pressure value 88 + (threshold) - u16. 89 + ti,pressure-max Maximum reported pressure value (u16). 90 + ti,debounce-max Max number of additional readings per 91 + sample (u16). 63 92 64 93 Example for a TSC2046 chip connected to an McSPI controller of an OMAP SoC:: 65 94
+21 -6
Documentation/devicetree/bindings/input/touchscreen/bu21013.txt
··· 2 2 3 3 Required properties: 4 4 - compatible : "rohm,bu21013_tp" 5 - - reg : I2C device address 5 + - reg : I2C device address 6 + - reset-gpios : GPIO pin enabling (selecting) chip (CS) 7 + - interrupt-parent : the phandle for the gpio controller 8 + - interrupts : (gpio) interrupt to which the chip is connected 6 9 7 10 Optional properties: 8 - - touch-gpio : GPIO pin registering a touch event 11 + - touch-gpios : GPIO pin registering a touch event 9 12 - <supply_name>-supply : Phandle to a regulator supply 13 + - touchscreen-size-x : General touchscreen binding, see [1]. 14 + - touchscreen-size-y : General touchscreen binding, see [1]. 15 + - touchscreen-inverted-x : General touchscreen binding, see [1]. 16 + - touchscreen-inverted-y : General touchscreen binding, see [1]. 17 + - touchscreen-swapped-x-y : General touchscreen binding, see [1]. 18 + 19 + [1] All general touchscreen properties are described in 20 + Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt. 21 + 22 + Deprecated properties: 10 23 - rohm,touch-max-x : Maximum outward permitted limit in the X axis 11 24 - rohm,touch-max-y : Maximum outward permitted limit in the Y axis 12 25 - rohm,flip-x : Flip touch coordinates on the X axis ··· 31 18 bu21013_tp@5c { 32 19 compatible = "rohm,bu21013_tp"; 33 20 reg = <0x5c>; 34 - touch-gpio = <&gpio2 20 0x4>; 21 + interrupt-parent = <&gpio2>; 22 + interrupts <&20 IRQ_TYPE_LEVEL_LOW>; 23 + touch-gpio = <&gpio2 20 GPIO_ACTIVE_LOW>; 35 24 avdd-supply = <&ab8500_ldo_aux1_reg>; 36 25 37 - rohm,touch-max-x = <384>; 38 - rohm,touch-max-y = <704>; 39 - rohm,flip-y; 26 + touchscreen-size-x = <384>; 27 + touchscreen-size-y = <704>; 28 + touchscreen-inverted-y; 40 29 }; 41 30 };
+6
MAINTAINERS
··· 12742 12742 F: Documentation/input/devices/pxrc.rst 12743 12743 F: drivers/input/joystick/pxrc.c 12744 12744 12745 + FLYSKY FSIA6B RC RECEIVER 12746 + M: Markus Koch <markus@notsyncing.net> 12747 + L: linux-input@vger.kernel.org 12748 + S: Maintained 12749 + F: drivers/input/joystick/fsia6b.c 12750 + 12745 12751 PHONET PROTOCOL 12746 12752 M: Remi Denis-Courmont <courmisch@gmail.com> 12747 12753 S: Supported
+1 -1
drivers/input/Makefile
··· 6 6 # Each configuration option enables a list of files. 7 7 8 8 obj-$(CONFIG_INPUT) += input-core.o 9 - input-core-y := input.o input-compat.o input-mt.o ff-core.o 9 + input-core-y := input.o input-compat.o input-mt.o input-poller.o ff-core.o 10 10 11 11 obj-$(CONFIG_INPUT_FF_MEMLESS) += ff-memless.o 12 12 obj-$(CONFIG_INPUT_POLLDEV) += input-polldev.o
+8 -27
drivers/input/evdev.c
··· 25 25 #include <linux/cdev.h> 26 26 #include "input-compat.h" 27 27 28 - enum evdev_clock_type { 29 - EV_CLK_REAL = 0, 30 - EV_CLK_MONO, 31 - EV_CLK_BOOT, 32 - EV_CLK_MAX 33 - }; 34 - 35 28 struct evdev { 36 29 int open; 37 30 struct input_handle handle; ··· 46 53 struct fasync_struct *fasync; 47 54 struct evdev *evdev; 48 55 struct list_head node; 49 - unsigned int clk_type; 56 + enum input_clock_type clk_type; 50 57 bool revoked; 51 58 unsigned long *evmasks[EV_CNT]; 52 59 unsigned int bufsize; ··· 142 149 143 150 static void __evdev_queue_syn_dropped(struct evdev_client *client) 144 151 { 152 + ktime_t *ev_time = input_get_timestamp(client->evdev->handle.dev); 153 + struct timespec64 ts = ktime_to_timespec64(ev_time[client->clk_type]); 145 154 struct input_event ev; 146 - ktime_t time; 147 - struct timespec64 ts; 148 155 149 - time = client->clk_type == EV_CLK_REAL ? 150 - ktime_get_real() : 151 - client->clk_type == EV_CLK_MONO ? 152 - ktime_get() : 153 - ktime_get_boottime(); 154 - 155 - ts = ktime_to_timespec64(time); 156 156 ev.input_event_sec = ts.tv_sec; 157 157 ev.input_event_usec = ts.tv_nsec / NSEC_PER_USEC; 158 158 ev.type = EV_SYN; ··· 174 188 static int evdev_set_clk_type(struct evdev_client *client, unsigned int clkid) 175 189 { 176 190 unsigned long flags; 177 - unsigned int clk_type; 191 + enum input_clock_type clk_type; 178 192 179 193 switch (clkid) { 180 194 181 195 case CLOCK_REALTIME: 182 - clk_type = EV_CLK_REAL; 196 + clk_type = INPUT_CLK_REAL; 183 197 break; 184 198 case CLOCK_MONOTONIC: 185 - clk_type = EV_CLK_MONO; 199 + clk_type = INPUT_CLK_MONO; 186 200 break; 187 201 case CLOCK_BOOTTIME: 188 - clk_type = EV_CLK_BOOT; 202 + clk_type = INPUT_CLK_BOOT; 189 203 break; 190 204 default: 191 205 return -EINVAL; ··· 293 307 { 294 308 struct evdev *evdev = handle->private; 295 309 struct evdev_client *client; 296 - ktime_t ev_time[EV_CLK_MAX]; 297 - 298 - ev_time[EV_CLK_MONO] = ktime_get(); 299 - ev_time[EV_CLK_REAL] = ktime_mono_to_real(ev_time[EV_CLK_MONO]); 300 - ev_time[EV_CLK_BOOT] = ktime_mono_to_any(ev_time[EV_CLK_MONO], 301 - TK_OFFS_BOOT); 310 + ktime_t *ev_time = input_get_timestamp(handle->dev); 302 311 303 312 rcu_read_lock(); 304 313
+213
drivers/input/input-poller.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Support for polling mode for input devices. 4 + */ 5 + 6 + #include <linux/device.h> 7 + #include <linux/input.h> 8 + #include <linux/jiffies.h> 9 + #include <linux/mutex.h> 10 + #include <linux/slab.h> 11 + #include <linux/types.h> 12 + #include <linux/workqueue.h> 13 + #include "input-poller.h" 14 + 15 + struct input_dev_poller { 16 + void (*poll)(struct input_dev *dev); 17 + 18 + unsigned int poll_interval; /* msec */ 19 + unsigned int poll_interval_max; /* msec */ 20 + unsigned int poll_interval_min; /* msec */ 21 + 22 + struct input_dev *input; 23 + struct delayed_work work; 24 + }; 25 + 26 + static void input_dev_poller_queue_work(struct input_dev_poller *poller) 27 + { 28 + unsigned long delay; 29 + 30 + delay = msecs_to_jiffies(poller->poll_interval); 31 + if (delay >= HZ) 32 + delay = round_jiffies_relative(delay); 33 + 34 + queue_delayed_work(system_freezable_wq, &poller->work, delay); 35 + } 36 + 37 + static void input_dev_poller_work(struct work_struct *work) 38 + { 39 + struct input_dev_poller *poller = 40 + container_of(work, struct input_dev_poller, work.work); 41 + 42 + poller->poll(poller->input); 43 + input_dev_poller_queue_work(poller); 44 + } 45 + 46 + void input_dev_poller_finalize(struct input_dev_poller *poller) 47 + { 48 + if (!poller->poll_interval) 49 + poller->poll_interval = 500; 50 + if (!poller->poll_interval_max) 51 + poller->poll_interval_max = poller->poll_interval; 52 + } 53 + 54 + void input_dev_poller_start(struct input_dev_poller *poller) 55 + { 56 + /* Only start polling if polling is enabled */ 57 + if (poller->poll_interval > 0) { 58 + poller->poll(poller->input); 59 + input_dev_poller_queue_work(poller); 60 + } 61 + } 62 + 63 + void input_dev_poller_stop(struct input_dev_poller *poller) 64 + { 65 + cancel_delayed_work_sync(&poller->work); 66 + } 67 + 68 + int input_setup_polling(struct input_dev *dev, 69 + void (*poll_fn)(struct input_dev *dev)) 70 + { 71 + struct input_dev_poller *poller; 72 + 73 + poller = kzalloc(sizeof(*poller), GFP_KERNEL); 74 + if (!poller) { 75 + /* 76 + * We want to show message even though kzalloc() may have 77 + * printed backtrace as knowing what instance of input 78 + * device we were dealing with is helpful. 79 + */ 80 + dev_err(dev->dev.parent ?: &dev->dev, 81 + "%s: unable to allocate poller structure\n", __func__); 82 + return -ENOMEM; 83 + } 84 + 85 + INIT_DELAYED_WORK(&poller->work, input_dev_poller_work); 86 + poller->input = dev; 87 + poller->poll = poll_fn; 88 + 89 + dev->poller = poller; 90 + return 0; 91 + } 92 + EXPORT_SYMBOL(input_setup_polling); 93 + 94 + static bool input_dev_ensure_poller(struct input_dev *dev) 95 + { 96 + if (!dev->poller) { 97 + dev_err(dev->dev.parent ?: &dev->dev, 98 + "poller structure has not been set up\n"); 99 + return false; 100 + } 101 + 102 + return true; 103 + } 104 + 105 + void input_set_poll_interval(struct input_dev *dev, unsigned int interval) 106 + { 107 + if (input_dev_ensure_poller(dev)) 108 + dev->poller->poll_interval = interval; 109 + } 110 + EXPORT_SYMBOL(input_set_poll_interval); 111 + 112 + void input_set_min_poll_interval(struct input_dev *dev, unsigned int interval) 113 + { 114 + if (input_dev_ensure_poller(dev)) 115 + dev->poller->poll_interval_min = interval; 116 + } 117 + EXPORT_SYMBOL(input_set_min_poll_interval); 118 + 119 + void input_set_max_poll_interval(struct input_dev *dev, unsigned int interval) 120 + { 121 + if (input_dev_ensure_poller(dev)) 122 + dev->poller->poll_interval_max = interval; 123 + } 124 + EXPORT_SYMBOL(input_set_max_poll_interval); 125 + 126 + /* SYSFS interface */ 127 + 128 + static ssize_t input_dev_get_poll_interval(struct device *dev, 129 + struct device_attribute *attr, 130 + char *buf) 131 + { 132 + struct input_dev *input = to_input_dev(dev); 133 + 134 + return sprintf(buf, "%d\n", input->poller->poll_interval); 135 + } 136 + 137 + static ssize_t input_dev_set_poll_interval(struct device *dev, 138 + struct device_attribute *attr, 139 + const char *buf, size_t count) 140 + { 141 + struct input_dev *input = to_input_dev(dev); 142 + struct input_dev_poller *poller = input->poller; 143 + unsigned int interval; 144 + int err; 145 + 146 + err = kstrtouint(buf, 0, &interval); 147 + if (err) 148 + return err; 149 + 150 + if (interval < poller->poll_interval_min) 151 + return -EINVAL; 152 + 153 + if (interval > poller->poll_interval_max) 154 + return -EINVAL; 155 + 156 + mutex_lock(&input->mutex); 157 + 158 + poller->poll_interval = interval; 159 + 160 + if (input->users) { 161 + cancel_delayed_work_sync(&poller->work); 162 + if (poller->poll_interval > 0) 163 + input_dev_poller_queue_work(poller); 164 + } 165 + 166 + mutex_unlock(&input->mutex); 167 + 168 + return count; 169 + } 170 + 171 + static DEVICE_ATTR(poll, 0644, 172 + input_dev_get_poll_interval, input_dev_set_poll_interval); 173 + 174 + static ssize_t input_dev_get_poll_max(struct device *dev, 175 + struct device_attribute *attr, char *buf) 176 + { 177 + struct input_dev *input = to_input_dev(dev); 178 + 179 + return sprintf(buf, "%d\n", input->poller->poll_interval_max); 180 + } 181 + 182 + static DEVICE_ATTR(max, 0444, input_dev_get_poll_max, NULL); 183 + 184 + static ssize_t input_dev_get_poll_min(struct device *dev, 185 + struct device_attribute *attr, char *buf) 186 + { 187 + struct input_dev *input = to_input_dev(dev); 188 + 189 + return sprintf(buf, "%d\n", input->poller->poll_interval_min); 190 + } 191 + 192 + static DEVICE_ATTR(min, 0444, input_dev_get_poll_min, NULL); 193 + 194 + static umode_t input_poller_attrs_visible(struct kobject *kobj, 195 + struct attribute *attr, int n) 196 + { 197 + struct device *dev = kobj_to_dev(kobj); 198 + struct input_dev *input = to_input_dev(dev); 199 + 200 + return input->poller ? attr->mode : 0; 201 + } 202 + 203 + static struct attribute *input_poller_attrs[] = { 204 + &dev_attr_poll.attr, 205 + &dev_attr_max.attr, 206 + &dev_attr_min.attr, 207 + NULL 208 + }; 209 + 210 + struct attribute_group input_poller_attribute_group = { 211 + .is_visible = input_poller_attrs_visible, 212 + .attrs = input_poller_attrs, 213 + };
+18
drivers/input/input-poller.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + #ifndef _INPUT_POLLER_H 3 + #define _INPUT_POLLER_H 4 + 5 + /* 6 + * Support for polling mode for input devices. 7 + */ 8 + #include <linux/sysfs.h> 9 + 10 + struct input_dev_poller; 11 + 12 + void input_dev_poller_finalize(struct input_dev_poller *poller); 13 + void input_dev_poller_start(struct input_dev_poller *poller); 14 + void input_dev_poller_stop(struct input_dev_poller *poller); 15 + 16 + extern struct attribute_group input_poller_attribute_group; 17 + 18 + #endif /* _INPUT_POLLER_H */
+76 -7
drivers/input/input.c
··· 24 24 #include <linux/mutex.h> 25 25 #include <linux/rcupdate.h> 26 26 #include "input-compat.h" 27 + #include "input-poller.h" 27 28 28 29 MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); 29 30 MODULE_DESCRIPTION("Input core"); ··· 397 396 if (dev->num_vals >= 2) 398 397 input_pass_values(dev, dev->vals, dev->num_vals); 399 398 dev->num_vals = 0; 399 + /* 400 + * Reset the timestamp on flush so we won't end up 401 + * with a stale one. Note we only need to reset the 402 + * monolithic one as we use its presence when deciding 403 + * whether to generate a synthetic timestamp. 404 + */ 405 + dev->timestamp[INPUT_CLK_MONO] = ktime_set(0, 0); 400 406 } else if (dev->num_vals >= dev->max_vals - 2) { 401 407 dev->vals[dev->num_vals++] = input_value_sync; 402 408 input_pass_values(dev, dev->vals, dev->num_vals); ··· 611 603 612 604 handle->open++; 613 605 614 - if (!dev->users++ && dev->open) 615 - retval = dev->open(dev); 606 + if (dev->users++) { 607 + /* 608 + * Device is already opened, so we can exit immediately and 609 + * report success. 610 + */ 611 + goto out; 612 + } 616 613 617 - if (retval) { 618 - dev->users--; 619 - if (!--handle->open) { 614 + if (dev->open) { 615 + retval = dev->open(dev); 616 + if (retval) { 617 + dev->users--; 618 + handle->open--; 620 619 /* 621 620 * Make sure we are not delivering any more events 622 621 * through this handle 623 622 */ 624 623 synchronize_rcu(); 624 + goto out; 625 625 } 626 626 } 627 + 628 + if (dev->poller) 629 + input_dev_poller_start(dev->poller); 627 630 628 631 out: 629 632 mutex_unlock(&dev->mutex); ··· 674 655 675 656 __input_release_device(handle); 676 657 677 - if (!--dev->users && dev->close) 678 - dev->close(dev); 658 + if (!--dev->users) { 659 + if (dev->poller) 660 + input_dev_poller_stop(dev->poller); 661 + 662 + if (dev->close) 663 + dev->close(dev); 664 + } 679 665 680 666 if (!--handle->open) { 681 667 /* ··· 1526 1502 &input_dev_attr_group, 1527 1503 &input_dev_id_attr_group, 1528 1504 &input_dev_caps_attr_group, 1505 + &input_poller_attribute_group, 1529 1506 NULL 1530 1507 }; 1531 1508 ··· 1536 1511 1537 1512 input_ff_destroy(dev); 1538 1513 input_mt_destroy_slots(dev); 1514 + kfree(dev->poller); 1539 1515 kfree(dev->absinfo); 1540 1516 kfree(dev->vals); 1541 1517 kfree(dev); ··· 1921 1895 EXPORT_SYMBOL(input_free_device); 1922 1896 1923 1897 /** 1898 + * input_set_timestamp - set timestamp for input events 1899 + * @dev: input device to set timestamp for 1900 + * @timestamp: the time at which the event has occurred 1901 + * in CLOCK_MONOTONIC 1902 + * 1903 + * This function is intended to provide to the input system a more 1904 + * accurate time of when an event actually occurred. The driver should 1905 + * call this function as soon as a timestamp is acquired ensuring 1906 + * clock conversions in input_set_timestamp are done correctly. 1907 + * 1908 + * The system entering suspend state between timestamp acquisition and 1909 + * calling input_set_timestamp can result in inaccurate conversions. 1910 + */ 1911 + void input_set_timestamp(struct input_dev *dev, ktime_t timestamp) 1912 + { 1913 + dev->timestamp[INPUT_CLK_MONO] = timestamp; 1914 + dev->timestamp[INPUT_CLK_REAL] = ktime_mono_to_real(timestamp); 1915 + dev->timestamp[INPUT_CLK_BOOT] = ktime_mono_to_any(timestamp, 1916 + TK_OFFS_BOOT); 1917 + } 1918 + EXPORT_SYMBOL(input_set_timestamp); 1919 + 1920 + /** 1921 + * input_get_timestamp - get timestamp for input events 1922 + * @dev: input device to get timestamp from 1923 + * 1924 + * A valid timestamp is a timestamp of non-zero value. 1925 + */ 1926 + ktime_t *input_get_timestamp(struct input_dev *dev) 1927 + { 1928 + const ktime_t invalid_timestamp = ktime_set(0, 0); 1929 + 1930 + if (!ktime_compare(dev->timestamp[INPUT_CLK_MONO], invalid_timestamp)) 1931 + input_set_timestamp(dev, ktime_get()); 1932 + 1933 + return dev->timestamp; 1934 + } 1935 + EXPORT_SYMBOL(input_get_timestamp); 1936 + 1937 + /** 1924 1938 * input_set_capability - mark device as capable of a certain event 1925 1939 * @dev: device that is capable of emitting or accepting event 1926 1940 * @type: type of the event (EV_KEY, EV_REL, etc...) ··· 2200 2134 2201 2135 if (!dev->setkeycode) 2202 2136 dev->setkeycode = input_default_setkeycode; 2137 + 2138 + if (dev->poller) 2139 + input_dev_poller_finalize(dev->poller); 2203 2140 2204 2141 error = device_add(&dev->dev); 2205 2142 if (error)
+10
drivers/input/joystick/Kconfig
··· 362 362 To compile this driver as a module, choose M here: the 363 363 module will be called pxrc. 364 364 365 + config JOYSTICK_FSIA6B 366 + tristate "FlySky FS-iA6B RC Receiver" 367 + select SERIO 368 + help 369 + Say Y here if you use a FlySky FS-i6 RC remote control along with the 370 + FS-iA6B RC receiver as a joystick input device. 371 + 372 + To compile this driver as a module, choose M here: the 373 + module will be called fsia6b. 374 + 365 375 endif
+3 -2
drivers/input/joystick/Makefile
··· 12 12 obj-$(CONFIG_JOYSTICK_ANALOG) += analog.o 13 13 obj-$(CONFIG_JOYSTICK_COBRA) += cobra.o 14 14 obj-$(CONFIG_JOYSTICK_DB9) += db9.o 15 + obj-$(CONFIG_JOYSTICK_FSIA6B) += fsia6b.o 15 16 obj-$(CONFIG_JOYSTICK_GAMECON) += gamecon.o 16 17 obj-$(CONFIG_JOYSTICK_GF2K) += gf2k.o 17 18 obj-$(CONFIG_JOYSTICK_GRIP) += grip.o ··· 24 23 obj-$(CONFIG_JOYSTICK_MAGELLAN) += magellan.o 25 24 obj-$(CONFIG_JOYSTICK_MAPLE) += maplecontrol.o 26 25 obj-$(CONFIG_JOYSTICK_PSXPAD_SPI) += psxpad-spi.o 27 - obj-$(CONFIG_JOYSTICK_PXRC) += pxrc.o 26 + obj-$(CONFIG_JOYSTICK_PXRC) += pxrc.o 28 27 obj-$(CONFIG_JOYSTICK_SIDEWINDER) += sidewinder.o 29 28 obj-$(CONFIG_JOYSTICK_SPACEBALL) += spaceball.o 30 29 obj-$(CONFIG_JOYSTICK_SPACEORB) += spaceorb.o ··· 33 32 obj-$(CONFIG_JOYSTICK_TURBOGRAFX) += turbografx.o 34 33 obj-$(CONFIG_JOYSTICK_TWIDJOY) += twidjoy.o 35 34 obj-$(CONFIG_JOYSTICK_WARRIOR) += warrior.o 35 + obj-$(CONFIG_JOYSTICK_WALKERA0701) += walkera0701.o 36 36 obj-$(CONFIG_JOYSTICK_XPAD) += xpad.o 37 37 obj-$(CONFIG_JOYSTICK_ZHENHUA) += zhenhua.o 38 - obj-$(CONFIG_JOYSTICK_WALKERA0701) += walkera0701.o 39 38
+231
drivers/input/joystick/fsia6b.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * FS-iA6B iBus RC receiver driver 4 + * 5 + * This driver provides all 14 channels of the FlySky FS-ia6B RC receiver 6 + * as analog values. 7 + * 8 + * Additionally, the channels can be converted to discrete switch values. 9 + * By default, it is configured for the offical FS-i6 remote control. 10 + * If you use a different hardware configuration, you can configure it 11 + * using the `switch_config` parameter. 12 + */ 13 + 14 + #include <linux/device.h> 15 + #include <linux/input.h> 16 + #include <linux/kernel.h> 17 + #include <linux/module.h> 18 + #include <linux/serio.h> 19 + #include <linux/slab.h> 20 + #include <linux/types.h> 21 + 22 + #define DRIVER_DESC "FS-iA6B iBus RC receiver" 23 + 24 + MODULE_AUTHOR("Markus Koch <markus@notsyncing.net>"); 25 + MODULE_DESCRIPTION(DRIVER_DESC); 26 + MODULE_LICENSE("GPL"); 27 + 28 + #define IBUS_SERVO_COUNT 14 29 + 30 + static char *switch_config = "00000022320000"; 31 + module_param(switch_config, charp, 0444); 32 + MODULE_PARM_DESC(switch_config, 33 + "Amount of switch positions per channel (14 characters, 0-3)"); 34 + 35 + static int fsia6b_axes[IBUS_SERVO_COUNT] = { 36 + ABS_X, ABS_Y, 37 + ABS_Z, ABS_RX, 38 + ABS_RY, ABS_RZ, 39 + ABS_HAT0X, ABS_HAT0Y, 40 + ABS_HAT1X, ABS_HAT1Y, 41 + ABS_HAT2X, ABS_HAT2Y, 42 + ABS_HAT3X, ABS_HAT3Y 43 + }; 44 + 45 + enum ibus_state { SYNC, COLLECT, PROCESS }; 46 + 47 + struct ibus_packet { 48 + enum ibus_state state; 49 + 50 + int offset; 51 + u16 ibuf; 52 + u16 channel[IBUS_SERVO_COUNT]; 53 + }; 54 + 55 + struct fsia6b { 56 + struct input_dev *dev; 57 + struct ibus_packet packet; 58 + 59 + char phys[32]; 60 + }; 61 + 62 + static irqreturn_t fsia6b_serio_irq(struct serio *serio, 63 + unsigned char data, unsigned int flags) 64 + { 65 + struct fsia6b *fsia6b = serio_get_drvdata(serio); 66 + int i; 67 + int sw_state; 68 + int sw_id = BTN_0; 69 + 70 + fsia6b->packet.ibuf = (data << 8) | ((fsia6b->packet.ibuf >> 8) & 0xFF); 71 + 72 + switch (fsia6b->packet.state) { 73 + case SYNC: 74 + if (fsia6b->packet.ibuf == 0x4020) 75 + fsia6b->packet.state = COLLECT; 76 + break; 77 + 78 + case COLLECT: 79 + fsia6b->packet.state = PROCESS; 80 + break; 81 + 82 + case PROCESS: 83 + fsia6b->packet.channel[fsia6b->packet.offset] = 84 + fsia6b->packet.ibuf; 85 + fsia6b->packet.offset++; 86 + 87 + if (fsia6b->packet.offset == IBUS_SERVO_COUNT) { 88 + fsia6b->packet.offset = 0; 89 + fsia6b->packet.state = SYNC; 90 + for (i = 0; i < IBUS_SERVO_COUNT; ++i) { 91 + input_report_abs(fsia6b->dev, fsia6b_axes[i], 92 + fsia6b->packet.channel[i]); 93 + 94 + sw_state = 0; 95 + if (fsia6b->packet.channel[i] > 1900) 96 + sw_state = 1; 97 + else if (fsia6b->packet.channel[i] < 1100) 98 + sw_state = 2; 99 + 100 + switch (switch_config[i]) { 101 + case '3': 102 + input_report_key(fsia6b->dev, 103 + sw_id++, 104 + sw_state == 0); 105 + /* fall-through */ 106 + case '2': 107 + input_report_key(fsia6b->dev, 108 + sw_id++, 109 + sw_state == 1); 110 + /* fall-through */ 111 + case '1': 112 + input_report_key(fsia6b->dev, 113 + sw_id++, 114 + sw_state == 2); 115 + } 116 + } 117 + input_sync(fsia6b->dev); 118 + } else { 119 + fsia6b->packet.state = COLLECT; 120 + } 121 + break; 122 + } 123 + 124 + return IRQ_HANDLED; 125 + } 126 + 127 + static int fsia6b_serio_connect(struct serio *serio, struct serio_driver *drv) 128 + { 129 + struct fsia6b *fsia6b; 130 + struct input_dev *input_dev; 131 + int err; 132 + int i, j; 133 + int sw_id = 0; 134 + 135 + fsia6b = kzalloc(sizeof(*fsia6b), GFP_KERNEL); 136 + if (!fsia6b) 137 + return -ENOMEM; 138 + 139 + fsia6b->packet.ibuf = 0; 140 + fsia6b->packet.offset = 0; 141 + fsia6b->packet.state = SYNC; 142 + 143 + serio_set_drvdata(serio, fsia6b); 144 + 145 + input_dev = input_allocate_device(); 146 + if (!input_dev) { 147 + err = -ENOMEM; 148 + goto fail1; 149 + } 150 + fsia6b->dev = input_dev; 151 + 152 + snprintf(fsia6b->phys, sizeof(fsia6b->phys), "%s/input0", serio->phys); 153 + 154 + input_dev->name = DRIVER_DESC; 155 + input_dev->phys = fsia6b->phys; 156 + input_dev->id.bustype = BUS_RS232; 157 + input_dev->id.vendor = SERIO_FSIA6B; 158 + input_dev->id.product = serio->id.id; 159 + input_dev->id.version = 0x0100; 160 + input_dev->dev.parent = &serio->dev; 161 + 162 + for (i = 0; i < IBUS_SERVO_COUNT; i++) 163 + input_set_abs_params(input_dev, fsia6b_axes[i], 164 + 1000, 2000, 2, 2); 165 + 166 + /* Register switch configuration */ 167 + for (i = 0; i < IBUS_SERVO_COUNT; i++) { 168 + if (switch_config[i] < '0' || switch_config[i] > '3') { 169 + dev_err(&fsia6b->dev->dev, 170 + "Invalid switch configuration supplied for fsia6b.\n"); 171 + err = -EINVAL; 172 + goto fail2; 173 + } 174 + 175 + for (j = '1'; j <= switch_config[i]; j++) { 176 + input_set_capability(input_dev, EV_KEY, BTN_0 + sw_id); 177 + sw_id++; 178 + } 179 + } 180 + 181 + err = serio_open(serio, drv); 182 + if (err) 183 + goto fail2; 184 + 185 + err = input_register_device(fsia6b->dev); 186 + if (err) 187 + goto fail3; 188 + 189 + return 0; 190 + 191 + fail3: serio_close(serio); 192 + fail2: input_free_device(input_dev); 193 + fail1: serio_set_drvdata(serio, NULL); 194 + kfree(fsia6b); 195 + return err; 196 + } 197 + 198 + static void fsia6b_serio_disconnect(struct serio *serio) 199 + { 200 + struct fsia6b *fsia6b = serio_get_drvdata(serio); 201 + 202 + serio_close(serio); 203 + serio_set_drvdata(serio, NULL); 204 + input_unregister_device(fsia6b->dev); 205 + kfree(fsia6b); 206 + } 207 + 208 + static const struct serio_device_id fsia6b_serio_ids[] = { 209 + { 210 + .type = SERIO_RS232, 211 + .proto = SERIO_FSIA6B, 212 + .id = SERIO_ANY, 213 + .extra = SERIO_ANY, 214 + }, 215 + { 0 } 216 + }; 217 + 218 + MODULE_DEVICE_TABLE(serio, fsia6b_serio_ids); 219 + 220 + static struct serio_driver fsia6b_serio_drv = { 221 + .driver = { 222 + .name = "fsia6b" 223 + }, 224 + .description = DRIVER_DESC, 225 + .id_table = fsia6b_serio_ids, 226 + .interrupt = fsia6b_serio_irq, 227 + .connect = fsia6b_serio_connect, 228 + .disconnect = fsia6b_serio_disconnect 229 + }; 230 + 231 + module_serio_driver(fsia6b_serio_drv)
+1 -1
drivers/input/joystick/sidewinder.c
··· 223 223 224 224 static void sw_init_digital(struct gameport *gameport) 225 225 { 226 - int seq[] = { 140, 140+725, 140+300, 0 }; 226 + static const int seq[] = { 140, 140+725, 140+300, 0 }; 227 227 unsigned long flags; 228 228 int i, t; 229 229
-11
drivers/input/keyboard/Kconfig
··· 733 733 To compile this driver as a module, choose M here: the 734 734 module will be called xtkbd. 735 735 736 - config KEYBOARD_W90P910 737 - tristate "W90P910 Matrix Keypad support" 738 - depends on ARCH_W90X900 739 - select INPUT_MATRIXKMAP 740 - help 741 - Say Y here to enable the matrix keypad on evaluation board 742 - based on W90P910. 743 - 744 - To compile this driver as a module, choose M here: the 745 - module will be called w90p910_keypad. 746 - 747 736 config KEYBOARD_CROS_EC 748 737 tristate "ChromeOS EC keyboard" 749 738 select INPUT_MATRIXKMAP
-1
drivers/input/keyboard/Makefile
··· 68 68 obj-$(CONFIG_KEYBOARD_TM2_TOUCHKEY) += tm2-touchkey.o 69 69 obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o 70 70 obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o 71 - obj-$(CONFIG_KEYBOARD_W90P910) += w90p910_keypad.o
+4 -22
drivers/input/keyboard/applespi.c
··· 1797 1797 1798 1798 /* set up debugfs entries for touchpad dimensions logging */ 1799 1799 applespi->debugfs_root = debugfs_create_dir("applespi", NULL); 1800 - if (IS_ERR(applespi->debugfs_root)) { 1801 - if (PTR_ERR(applespi->debugfs_root) != -ENODEV) 1802 - dev_warn(&applespi->spi->dev, 1803 - "Error creating debugfs root entry (%ld)\n", 1804 - PTR_ERR(applespi->debugfs_root)); 1805 - } else { 1806 - struct dentry *ret; 1807 1800 1808 - ret = debugfs_create_bool("enable_tp_dim", 0600, 1809 - applespi->debugfs_root, 1810 - &applespi->debug_tp_dim); 1811 - if (IS_ERR(ret)) 1812 - dev_dbg(&applespi->spi->dev, 1813 - "Error creating debugfs entry enable_tp_dim (%ld)\n", 1814 - PTR_ERR(ret)); 1801 + debugfs_create_bool("enable_tp_dim", 0600, applespi->debugfs_root, 1802 + &applespi->debug_tp_dim); 1815 1803 1816 - ret = debugfs_create_file("tp_dim", 0400, 1817 - applespi->debugfs_root, applespi, 1818 - &applespi_tp_dim_fops); 1819 - if (IS_ERR(ret)) 1820 - dev_dbg(&applespi->spi->dev, 1821 - "Error creating debugfs entry tp_dim (%ld)\n", 1822 - PTR_ERR(ret)); 1823 - } 1804 + debugfs_create_file("tp_dim", 0400, applespi->debugfs_root, applespi, 1805 + &applespi_tp_dim_fops); 1824 1806 1825 1807 return 0; 1826 1808 }
+1 -3
drivers/input/keyboard/bcm-keypad.c
··· 413 413 bcm_kp_stop(kp); 414 414 415 415 kp->irq = platform_get_irq(pdev, 0); 416 - if (kp->irq < 0) { 417 - dev_err(&pdev->dev, "no IRQ specified\n"); 416 + if (kp->irq < 0) 418 417 return -EINVAL; 419 - } 420 418 421 419 error = devm_request_threaded_irq(&pdev->dev, kp->irq, 422 420 NULL, bcm_kp_isr_thread,
+4 -2
drivers/input/keyboard/cros_ec_keyb.c
··· 226 226 { 227 227 struct cros_ec_keyb *ckdev = container_of(nb, struct cros_ec_keyb, 228 228 notifier); 229 + uint8_t mkbp_event_type = ckdev->ec->event_data.event_type & 230 + EC_MKBP_EVENT_TYPE_MASK; 229 231 u32 val; 230 232 unsigned int ev_type; 231 233 ··· 239 237 if (queued_during_suspend && !device_may_wakeup(ckdev->dev)) 240 238 return NOTIFY_OK; 241 239 242 - switch (ckdev->ec->event_data.event_type & EC_MKBP_EVENT_TYPE_MASK) { 240 + switch (mkbp_event_type) { 243 241 case EC_MKBP_EVENT_KEY_MATRIX: 244 242 pm_wakeup_event(ckdev->dev, 0); 245 243 ··· 266 264 case EC_MKBP_EVENT_SWITCH: 267 265 pm_wakeup_event(ckdev->dev, 0); 268 266 269 - if (ckdev->ec->event_data.event_type == EC_MKBP_EVENT_BUTTON) { 267 + if (mkbp_event_type == EC_MKBP_EVENT_BUTTON) { 270 268 val = get_unaligned_le32( 271 269 &ckdev->ec->event_data.data.buttons); 272 270 ev_type = EV_KEY;
-1
drivers/input/keyboard/davinci_keyscan.c
··· 192 192 193 193 davinci_ks->irq = platform_get_irq(pdev, 0); 194 194 if (davinci_ks->irq < 0) { 195 - dev_err(dev, "no key scan irq\n"); 196 195 error = davinci_ks->irq; 197 196 goto fail2; 198 197 }
+2 -11
drivers/input/keyboard/gpio_keys.c
··· 351 351 &dev_attr_disabled_switches.attr, 352 352 NULL, 353 353 }; 354 - 355 - static const struct attribute_group gpio_keys_attr_group = { 356 - .attrs = gpio_keys_attrs, 357 - }; 354 + ATTRIBUTE_GROUPS(gpio_keys); 358 355 359 356 static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata) 360 357 { ··· 848 851 849 852 fwnode_handle_put(child); 850 853 851 - error = devm_device_add_group(dev, &gpio_keys_attr_group); 852 - if (error) { 853 - dev_err(dev, "Unable to export keys/switches, error: %d\n", 854 - error); 855 - return error; 856 - } 857 - 858 854 error = input_register_device(input); 859 855 if (error) { 860 856 dev_err(dev, "Unable to register input device, error: %d\n", ··· 1016 1026 .name = "gpio-keys", 1017 1027 .pm = &gpio_keys_pm_ops, 1018 1028 .of_match_table = gpio_keys_of_match, 1029 + .dev_groups = gpio_keys_groups, 1019 1030 } 1020 1031 }; 1021 1032
+1 -3
drivers/input/keyboard/imx_keypad.c
··· 430 430 } 431 431 432 432 irq = platform_get_irq(pdev, 0); 433 - if (irq < 0) { 434 - dev_err(&pdev->dev, "no irq defined in platform data\n"); 433 + if (irq < 0) 435 434 return irq; 436 - } 437 435 438 436 input_dev = devm_input_allocate_device(&pdev->dev); 439 437 if (!input_dev) {
+1 -3
drivers/input/keyboard/lpc32xx-keys.c
··· 172 172 } 173 173 174 174 irq = platform_get_irq(pdev, 0); 175 - if (irq < 0) { 176 - dev_err(&pdev->dev, "failed to get platform irq\n"); 175 + if (irq < 0) 177 176 return -EINVAL; 178 - } 179 177 180 178 kscandat = devm_kzalloc(&pdev->dev, sizeof(*kscandat), 181 179 GFP_KERNEL);
+1 -2
drivers/input/keyboard/mpr121_touchkey.c
··· 253 253 254 254 mpr121->client = client; 255 255 mpr121->input_dev = input_dev; 256 - mpr121->keycount = device_property_read_u32_array(dev, "linux,keycodes", 257 - NULL, 0); 256 + mpr121->keycount = device_property_count_u32(dev, "linux,keycodes"); 258 257 if (mpr121->keycount > MPR121_MAX_KEY_COUNT) { 259 258 dev_err(dev, "too many keys defined (%d)\n", mpr121->keycount); 260 259 return -EINVAL;
+1 -3
drivers/input/keyboard/nomadik-ske-keypad.c
··· 235 235 } 236 236 237 237 irq = platform_get_irq(pdev, 0); 238 - if (irq < 0) { 239 - dev_err(&pdev->dev, "failed to get keypad irq\n"); 238 + if (irq < 0) 240 239 return -EINVAL; 241 - } 242 240 243 241 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 244 242 if (!res) {
+1 -3
drivers/input/keyboard/nspire-keypad.c
··· 165 165 int error; 166 166 167 167 irq = platform_get_irq(pdev, 0); 168 - if (irq < 0) { 169 - dev_err(&pdev->dev, "failed to get keypad irq\n"); 168 + if (irq < 0) 170 169 return -EINVAL; 171 - } 172 170 173 171 keypad = devm_kzalloc(&pdev->dev, sizeof(struct nspire_keypad), 174 172 GFP_KERNEL);
+1 -3
drivers/input/keyboard/opencores-kbd.c
··· 49 49 } 50 50 51 51 irq = platform_get_irq(pdev, 0); 52 - if (irq < 0) { 53 - dev_err(&pdev->dev, "missing board IRQ resource\n"); 52 + if (irq < 0) 54 53 return -EINVAL; 55 - } 56 54 57 55 opencores_kbd = devm_kzalloc(&pdev->dev, sizeof(*opencores_kbd), 58 56 GFP_KERNEL);
+2 -6
drivers/input/keyboard/pmic8xxx-keypad.c
··· 544 544 } 545 545 546 546 kp->key_sense_irq = platform_get_irq(pdev, 0); 547 - if (kp->key_sense_irq < 0) { 548 - dev_err(&pdev->dev, "unable to get keypad sense irq\n"); 547 + if (kp->key_sense_irq < 0) 549 548 return kp->key_sense_irq; 550 - } 551 549 552 550 kp->key_stuck_irq = platform_get_irq(pdev, 1); 553 - if (kp->key_stuck_irq < 0) { 554 - dev_err(&pdev->dev, "unable to get keypad stuck irq\n"); 551 + if (kp->key_stuck_irq < 0) 555 552 return kp->key_stuck_irq; 556 - } 557 553 558 554 kp->input->name = "PMIC8XXX keypad"; 559 555 kp->input->phys = "pmic8xxx_keypad/input0";
+1 -3
drivers/input/keyboard/pxa27x_keypad.c
··· 727 727 return -EINVAL; 728 728 729 729 irq = platform_get_irq(pdev, 0); 730 - if (irq < 0) { 731 - dev_err(&pdev->dev, "failed to get keypad irq\n"); 730 + if (irq < 0) 732 731 return -ENXIO; 733 - } 734 732 735 733 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 736 734 if (res == NULL) {
+1 -3
drivers/input/keyboard/pxa930_rotary.c
··· 89 89 int err; 90 90 91 91 irq = platform_get_irq(pdev, 0); 92 - if (irq < 0) { 93 - dev_err(&pdev->dev, "no irq for rotary controller\n"); 92 + if (irq < 0) 94 93 return -ENXIO; 95 - } 96 94 97 95 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 98 96 if (!res) {
+1 -3
drivers/input/keyboard/sh_keysc.c
··· 181 181 } 182 182 183 183 irq = platform_get_irq(pdev, 0); 184 - if (irq < 0) { 185 - dev_err(&pdev->dev, "failed to get irq\n"); 184 + if (irq < 0) 186 185 goto err0; 187 - } 188 186 189 187 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 190 188 if (priv == NULL) {
+1 -3
drivers/input/keyboard/snvs_pwrkey.c
··· 118 118 pdata->wakeup = of_property_read_bool(np, "wakeup-source"); 119 119 120 120 pdata->irq = platform_get_irq(pdev, 0); 121 - if (pdata->irq < 0) { 122 - dev_err(&pdev->dev, "no irq defined in platform data\n"); 121 + if (pdata->irq < 0) 123 122 return -EINVAL; 124 - } 125 123 126 124 regmap_update_bits(pdata->snvs, SNVS_LPCR_REG, SNVS_LPCR_DEP_EN, SNVS_LPCR_DEP_EN); 127 125
+1 -3
drivers/input/keyboard/spear-keyboard.c
··· 191 191 int error; 192 192 193 193 irq = platform_get_irq(pdev, 0); 194 - if (irq < 0) { 195 - dev_err(&pdev->dev, "not able to get irq for the device\n"); 194 + if (irq < 0) 196 195 return irq; 197 - } 198 196 199 197 kbd = devm_kzalloc(&pdev->dev, sizeof(*kbd), GFP_KERNEL); 200 198 if (!kbd) {
+1 -3
drivers/input/keyboard/st-keyscan.c
··· 187 187 keyscan_stop(keypad_data); 188 188 189 189 keypad_data->irq = platform_get_irq(pdev, 0); 190 - if (keypad_data->irq < 0) { 191 - dev_err(&pdev->dev, "no IRQ specified\n"); 190 + if (keypad_data->irq < 0) 192 191 return -EINVAL; 193 - } 194 192 195 193 error = devm_request_irq(&pdev->dev, keypad_data->irq, keyscan_isr, 0, 196 194 pdev->name, keypad_data);
+1 -3
drivers/input/keyboard/tegra-kbc.c
··· 631 631 return -EINVAL; 632 632 633 633 kbc->irq = platform_get_irq(pdev, 0); 634 - if (kbc->irq < 0) { 635 - dev_err(&pdev->dev, "failed to get keyboard IRQ\n"); 634 + if (kbc->irq < 0) 636 635 return -ENXIO; 637 - } 638 636 639 637 kbc->idev = devm_input_allocate_device(&pdev->dev); 640 638 if (!kbc->idev) {
-264
drivers/input/keyboard/w90p910_keypad.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only 2 - /* 3 - * Copyright (c) 2008-2009 Nuvoton technology corporation. 4 - * 5 - * Wan ZongShun <mcuos.com@gmail.com> 6 - */ 7 - 8 - #include <linux/kernel.h> 9 - #include <linux/module.h> 10 - #include <linux/interrupt.h> 11 - #include <linux/input.h> 12 - #include <linux/device.h> 13 - #include <linux/platform_device.h> 14 - #include <linux/clk.h> 15 - #include <linux/err.h> 16 - #include <linux/io.h> 17 - #include <linux/slab.h> 18 - 19 - #include <linux/platform_data/keypad-w90p910.h> 20 - 21 - /* Keypad Interface Control Registers */ 22 - #define KPI_CONF 0x00 23 - #define KPI_3KCONF 0x04 24 - #define KPI_LPCONF 0x08 25 - #define KPI_STATUS 0x0C 26 - 27 - #define IS1KEY (0x01 << 16) 28 - #define INTTR (0x01 << 21) 29 - #define KEY0R (0x0f << 3) 30 - #define KEY0C 0x07 31 - #define DEBOUNCE_BIT 0x08 32 - #define KSIZE0 (0x01 << 16) 33 - #define KSIZE1 (0x01 << 17) 34 - #define KPSEL (0x01 << 19) 35 - #define ENKP (0x01 << 18) 36 - 37 - #define KGET_RAW(n) (((n) & KEY0R) >> 3) 38 - #define KGET_COLUMN(n) ((n) & KEY0C) 39 - 40 - #define W90P910_NUM_ROWS 8 41 - #define W90P910_NUM_COLS 8 42 - #define W90P910_ROW_SHIFT 3 43 - 44 - struct w90p910_keypad { 45 - const struct w90p910_keypad_platform_data *pdata; 46 - struct clk *clk; 47 - struct input_dev *input_dev; 48 - void __iomem *mmio_base; 49 - int irq; 50 - unsigned short keymap[W90P910_NUM_ROWS * W90P910_NUM_COLS]; 51 - }; 52 - 53 - static void w90p910_keypad_scan_matrix(struct w90p910_keypad *keypad, 54 - unsigned int status) 55 - { 56 - struct input_dev *input_dev = keypad->input_dev; 57 - unsigned int row = KGET_RAW(status); 58 - unsigned int col = KGET_COLUMN(status); 59 - unsigned int code = MATRIX_SCAN_CODE(row, col, W90P910_ROW_SHIFT); 60 - unsigned int key = keypad->keymap[code]; 61 - 62 - input_event(input_dev, EV_MSC, MSC_SCAN, code); 63 - input_report_key(input_dev, key, 1); 64 - input_sync(input_dev); 65 - 66 - input_event(input_dev, EV_MSC, MSC_SCAN, code); 67 - input_report_key(input_dev, key, 0); 68 - input_sync(input_dev); 69 - } 70 - 71 - static irqreturn_t w90p910_keypad_irq_handler(int irq, void *dev_id) 72 - { 73 - struct w90p910_keypad *keypad = dev_id; 74 - unsigned int kstatus, val; 75 - 76 - kstatus = __raw_readl(keypad->mmio_base + KPI_STATUS); 77 - 78 - val = INTTR | IS1KEY; 79 - 80 - if (kstatus & val) 81 - w90p910_keypad_scan_matrix(keypad, kstatus); 82 - 83 - return IRQ_HANDLED; 84 - } 85 - 86 - static int w90p910_keypad_open(struct input_dev *dev) 87 - { 88 - struct w90p910_keypad *keypad = input_get_drvdata(dev); 89 - const struct w90p910_keypad_platform_data *pdata = keypad->pdata; 90 - unsigned int val, config; 91 - 92 - /* Enable unit clock */ 93 - clk_enable(keypad->clk); 94 - 95 - val = __raw_readl(keypad->mmio_base + KPI_CONF); 96 - val |= (KPSEL | ENKP); 97 - val &= ~(KSIZE0 | KSIZE1); 98 - 99 - config = pdata->prescale | (pdata->debounce << DEBOUNCE_BIT); 100 - 101 - val |= config; 102 - 103 - __raw_writel(val, keypad->mmio_base + KPI_CONF); 104 - 105 - return 0; 106 - } 107 - 108 - static void w90p910_keypad_close(struct input_dev *dev) 109 - { 110 - struct w90p910_keypad *keypad = input_get_drvdata(dev); 111 - 112 - /* Disable clock unit */ 113 - clk_disable(keypad->clk); 114 - } 115 - 116 - static int w90p910_keypad_probe(struct platform_device *pdev) 117 - { 118 - const struct w90p910_keypad_platform_data *pdata = 119 - dev_get_platdata(&pdev->dev); 120 - const struct matrix_keymap_data *keymap_data; 121 - struct w90p910_keypad *keypad; 122 - struct input_dev *input_dev; 123 - struct resource *res; 124 - int irq; 125 - int error; 126 - 127 - if (!pdata) { 128 - dev_err(&pdev->dev, "no platform data defined\n"); 129 - return -EINVAL; 130 - } 131 - 132 - keymap_data = pdata->keymap_data; 133 - 134 - irq = platform_get_irq(pdev, 0); 135 - if (irq < 0) { 136 - dev_err(&pdev->dev, "failed to get keypad irq\n"); 137 - return -ENXIO; 138 - } 139 - 140 - keypad = kzalloc(sizeof(struct w90p910_keypad), GFP_KERNEL); 141 - input_dev = input_allocate_device(); 142 - if (!keypad || !input_dev) { 143 - dev_err(&pdev->dev, "failed to allocate driver data\n"); 144 - error = -ENOMEM; 145 - goto failed_free; 146 - } 147 - 148 - keypad->pdata = pdata; 149 - keypad->input_dev = input_dev; 150 - keypad->irq = irq; 151 - 152 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 153 - if (res == NULL) { 154 - dev_err(&pdev->dev, "failed to get I/O memory\n"); 155 - error = -ENXIO; 156 - goto failed_free; 157 - } 158 - 159 - res = request_mem_region(res->start, resource_size(res), pdev->name); 160 - if (res == NULL) { 161 - dev_err(&pdev->dev, "failed to request I/O memory\n"); 162 - error = -EBUSY; 163 - goto failed_free; 164 - } 165 - 166 - keypad->mmio_base = ioremap(res->start, resource_size(res)); 167 - if (keypad->mmio_base == NULL) { 168 - dev_err(&pdev->dev, "failed to remap I/O memory\n"); 169 - error = -ENXIO; 170 - goto failed_free_res; 171 - } 172 - 173 - keypad->clk = clk_get(&pdev->dev, NULL); 174 - if (IS_ERR(keypad->clk)) { 175 - dev_err(&pdev->dev, "failed to get keypad clock\n"); 176 - error = PTR_ERR(keypad->clk); 177 - goto failed_free_io; 178 - } 179 - 180 - /* set multi-function pin for w90p910 kpi. */ 181 - mfp_set_groupi(&pdev->dev); 182 - 183 - input_dev->name = pdev->name; 184 - input_dev->id.bustype = BUS_HOST; 185 - input_dev->open = w90p910_keypad_open; 186 - input_dev->close = w90p910_keypad_close; 187 - input_dev->dev.parent = &pdev->dev; 188 - 189 - error = matrix_keypad_build_keymap(keymap_data, NULL, 190 - W90P910_NUM_ROWS, W90P910_NUM_COLS, 191 - keypad->keymap, input_dev); 192 - if (error) { 193 - dev_err(&pdev->dev, "failed to build keymap\n"); 194 - goto failed_put_clk; 195 - } 196 - 197 - error = request_irq(keypad->irq, w90p910_keypad_irq_handler, 198 - 0, pdev->name, keypad); 199 - if (error) { 200 - dev_err(&pdev->dev, "failed to request IRQ\n"); 201 - goto failed_put_clk; 202 - } 203 - 204 - __set_bit(EV_REP, input_dev->evbit); 205 - input_set_capability(input_dev, EV_MSC, MSC_SCAN); 206 - input_set_drvdata(input_dev, keypad); 207 - 208 - /* Register the input device */ 209 - error = input_register_device(input_dev); 210 - if (error) { 211 - dev_err(&pdev->dev, "failed to register input device\n"); 212 - goto failed_free_irq; 213 - } 214 - 215 - platform_set_drvdata(pdev, keypad); 216 - return 0; 217 - 218 - failed_free_irq: 219 - free_irq(irq, keypad); 220 - failed_put_clk: 221 - clk_put(keypad->clk); 222 - failed_free_io: 223 - iounmap(keypad->mmio_base); 224 - failed_free_res: 225 - release_mem_region(res->start, resource_size(res)); 226 - failed_free: 227 - input_free_device(input_dev); 228 - kfree(keypad); 229 - return error; 230 - } 231 - 232 - static int w90p910_keypad_remove(struct platform_device *pdev) 233 - { 234 - struct w90p910_keypad *keypad = platform_get_drvdata(pdev); 235 - struct resource *res; 236 - 237 - free_irq(keypad->irq, keypad); 238 - 239 - clk_put(keypad->clk); 240 - 241 - input_unregister_device(keypad->input_dev); 242 - 243 - iounmap(keypad->mmio_base); 244 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 245 - release_mem_region(res->start, resource_size(res)); 246 - 247 - kfree(keypad); 248 - 249 - return 0; 250 - } 251 - 252 - static struct platform_driver w90p910_keypad_driver = { 253 - .probe = w90p910_keypad_probe, 254 - .remove = w90p910_keypad_remove, 255 - .driver = { 256 - .name = "nuc900-kpi", 257 - }, 258 - }; 259 - module_platform_driver(w90p910_keypad_driver); 260 - 261 - MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>"); 262 - MODULE_DESCRIPTION("w90p910 keypad driver"); 263 - MODULE_LICENSE("GPL"); 264 - MODULE_ALIAS("platform:nuc900-keypad");
+1 -1
drivers/input/matrix-keymap.c
··· 81 81 if (!propname) 82 82 propname = "linux,keymap"; 83 83 84 - size = device_property_read_u32_array(dev, propname, NULL, 0); 84 + size = device_property_count_u32(dev, propname); 85 85 if (size <= 0) { 86 86 dev_err(dev, "missing or malformed property %s: %d\n", 87 87 propname, size);
-1
drivers/input/misc/88pm80x_onkey.c
··· 77 77 78 78 info->irq = platform_get_irq(pdev, 0); 79 79 if (info->irq < 0) { 80 - dev_err(&pdev->dev, "No IRQ resource!\n"); 81 80 err = -EINVAL; 82 81 goto out; 83 82 }
+1 -3
drivers/input/misc/88pm860x_onkey.c
··· 64 64 int irq, ret; 65 65 66 66 irq = platform_get_irq(pdev, 0); 67 - if (irq < 0) { 68 - dev_err(&pdev->dev, "No IRQ resource!\n"); 67 + if (irq < 0) 69 68 return -EINVAL; 70 - } 71 69 72 70 info = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_onkey_info), 73 71 GFP_KERNEL);
+3 -3
drivers/input/misc/Kconfig
··· 813 813 814 814 config INPUT_SOC_BUTTON_ARRAY 815 815 tristate "Windows-compatible SoC Button Array" 816 - depends on KEYBOARD_GPIO 816 + depends on KEYBOARD_GPIO && ACPI 817 817 help 818 - Say Y here if you have a SoC-based tablet that originally 819 - runs Windows 8. 818 + Say Y here if you have a SoC-based tablet that originally runs 819 + Windows 8 or a Microsoft Surface Book 2, Pro 5, Laptop 1 or later. 820 820 821 821 To compile this driver as a module, choose M here: the 822 822 module will be called soc_button_array.
+2 -6
drivers/input/misc/ab8500-ponkey.c
··· 55 55 int error; 56 56 57 57 irq_dbf = platform_get_irq_byname(pdev, "ONKEY_DBF"); 58 - if (irq_dbf < 0) { 59 - dev_err(&pdev->dev, "No IRQ for ONKEY_DBF, error=%d\n", irq_dbf); 58 + if (irq_dbf < 0) 60 59 return irq_dbf; 61 - } 62 60 63 61 irq_dbr = platform_get_irq_byname(pdev, "ONKEY_DBR"); 64 - if (irq_dbr < 0) { 65 - dev_err(&pdev->dev, "No IRQ for ONKEY_DBR, error=%d\n", irq_dbr); 62 + if (irq_dbr < 0) 66 63 return irq_dbr; 67 - } 68 64 69 65 ponkey = devm_kzalloc(&pdev->dev, sizeof(struct ab8500_ponkey), 70 66 GFP_KERNEL);
+5 -20
drivers/input/misc/axp20x-pek.c
··· 195 195 DEVICE_ATTR(shutdown, 0644, axp20x_show_attr_shutdown, 196 196 axp20x_store_attr_shutdown); 197 197 198 - static struct attribute *axp20x_attributes[] = { 198 + static struct attribute *axp20x_attrs[] = { 199 199 &dev_attr_startup.attr, 200 200 &dev_attr_shutdown.attr, 201 201 NULL, 202 202 }; 203 - 204 - static const struct attribute_group axp20x_attribute_group = { 205 - .attrs = axp20x_attributes, 206 - }; 203 + ATTRIBUTE_GROUPS(axp20x); 207 204 208 205 static irqreturn_t axp20x_pek_irq(int irq, void *pwr) 209 206 { ··· 229 232 int error; 230 233 231 234 axp20x_pek->irq_dbr = platform_get_irq_byname(pdev, "PEK_DBR"); 232 - if (axp20x_pek->irq_dbr < 0) { 233 - dev_err(&pdev->dev, "No IRQ for PEK_DBR, error=%d\n", 234 - axp20x_pek->irq_dbr); 235 + if (axp20x_pek->irq_dbr < 0) 235 236 return axp20x_pek->irq_dbr; 236 - } 237 237 axp20x_pek->irq_dbr = regmap_irq_get_virq(axp20x->regmap_irqc, 238 238 axp20x_pek->irq_dbr); 239 239 240 240 axp20x_pek->irq_dbf = platform_get_irq_byname(pdev, "PEK_DBF"); 241 - if (axp20x_pek->irq_dbf < 0) { 242 - dev_err(&pdev->dev, "No IRQ for PEK_DBF, error=%d\n", 243 - axp20x_pek->irq_dbf); 241 + if (axp20x_pek->irq_dbf < 0) 244 242 return axp20x_pek->irq_dbf; 245 - } 246 243 axp20x_pek->irq_dbf = regmap_irq_get_virq(axp20x->regmap_irqc, 247 244 axp20x_pek->irq_dbf); 248 245 ··· 347 356 348 357 axp20x_pek->info = (struct axp20x_info *)match->driver_data; 349 358 350 - error = devm_device_add_group(&pdev->dev, &axp20x_attribute_group); 351 - if (error) { 352 - dev_err(&pdev->dev, "Failed to create sysfs attributes: %d\n", 353 - error); 354 - return error; 355 - } 356 - 357 359 platform_set_drvdata(pdev, axp20x_pek); 358 360 359 361 return 0; ··· 395 411 .driver = { 396 412 .name = "axp20x-pek", 397 413 .pm = &axp20x_pek_pm_ops, 414 + .dev_groups = axp20x_groups, 398 415 }, 399 416 }; 400 417 module_platform_driver(axp20x_pek_driver);
+1 -4
drivers/input/misc/da9055_onkey.c
··· 76 76 int irq, err; 77 77 78 78 irq = platform_get_irq_byname(pdev, "ONKEY"); 79 - if (irq < 0) { 80 - dev_err(&pdev->dev, 81 - "Failed to get an IRQ for input device, %d\n", irq); 79 + if (irq < 0) 82 80 return -EINVAL; 83 - } 84 81 85 82 onkey = devm_kzalloc(&pdev->dev, sizeof(*onkey), GFP_KERNEL); 86 83 if (!onkey) {
+2 -5
drivers/input/misc/da9063_onkey.c
··· 248 248 } 249 249 250 250 irq = platform_get_irq_byname(pdev, "ONKEY"); 251 - if (irq < 0) { 252 - error = irq; 253 - dev_err(&pdev->dev, "Failed to get platform IRQ: %d\n", error); 254 - return error; 255 - } 251 + if (irq < 0) 252 + return irq; 256 253 257 254 error = devm_request_threaded_irq(&pdev->dev, irq, 258 255 NULL, da9063_onkey_irq_handler,
+2 -8
drivers/input/misc/e3x0-button.c
··· 65 65 int error; 66 66 67 67 irq_press = platform_get_irq_byname(pdev, "press"); 68 - if (irq_press < 0) { 69 - dev_err(&pdev->dev, "No IRQ for 'press', error=%d\n", 70 - irq_press); 68 + if (irq_press < 0) 71 69 return irq_press; 72 - } 73 70 74 71 irq_release = platform_get_irq_byname(pdev, "release"); 75 - if (irq_release < 0) { 76 - dev_err(&pdev->dev, "No IRQ for 'release', error=%d\n", 77 - irq_release); 72 + if (irq_release < 0) 78 73 return irq_release; 79 - } 80 74 81 75 input = devm_input_allocate_device(&pdev->dev); 82 76 if (!input)
+2 -6
drivers/input/misc/hisi_powerkey.c
··· 90 90 for (i = 0; i < ARRAY_SIZE(hi65xx_irq_info); i++) { 91 91 92 92 irq = platform_get_irq_byname(pdev, hi65xx_irq_info[i].name); 93 - if (irq < 0) { 94 - error = irq; 95 - dev_err(dev, "couldn't get irq %s: %d\n", 96 - hi65xx_irq_info[i].name, error); 97 - return error; 98 - } 93 + if (irq < 0) 94 + return irq; 99 95 100 96 error = devm_request_any_context_irq(dev, irq, 101 97 hi65xx_irq_info[i].handler,
+2 -6
drivers/input/misc/max8925_onkey.c
··· 71 71 int irq[2], error; 72 72 73 73 irq[0] = platform_get_irq(pdev, 0); 74 - if (irq[0] < 0) { 75 - dev_err(&pdev->dev, "No IRQ resource!\n"); 74 + if (irq[0] < 0) 76 75 return -EINVAL; 77 - } 78 76 79 77 irq[1] = platform_get_irq(pdev, 1); 80 - if (irq[1] < 0) { 81 - dev_err(&pdev->dev, "No IRQ resource!\n"); 78 + if (irq[1] < 0) 82 79 return -EINVAL; 83 - } 84 80 85 81 info = devm_kzalloc(&pdev->dev, sizeof(struct max8925_onkey_info), 86 82 GFP_KERNEL);
+1 -3
drivers/input/misc/pm8941-pwrkey.c
··· 205 205 return error; 206 206 207 207 pwrkey->irq = platform_get_irq(pdev, 0); 208 - if (pwrkey->irq < 0) { 209 - dev_err(&pdev->dev, "failed to get irq\n"); 208 + if (pwrkey->irq < 0) 210 209 return pwrkey->irq; 211 - } 212 210 213 211 error = regmap_read(pwrkey->regmap, pwrkey->baseaddr + PON_REV2, 214 212 &pwrkey->revision);
+2 -6
drivers/input/misc/rk805-pwrkey.c
··· 53 53 input_set_capability(pwr, EV_KEY, KEY_POWER); 54 54 55 55 fall_irq = platform_get_irq(pdev, 0); 56 - if (fall_irq < 0) { 57 - dev_err(&pdev->dev, "Can't get fall irq: %d\n", fall_irq); 56 + if (fall_irq < 0) 58 57 return fall_irq; 59 - } 60 58 61 59 rise_irq = platform_get_irq(pdev, 1); 62 - if (rise_irq < 0) { 63 - dev_err(&pdev->dev, "Can't get rise irq: %d\n", rise_irq); 60 + if (rise_irq < 0) 64 61 return rise_irq; 65 - } 66 62 67 63 err = devm_request_any_context_irq(&pwr->dev, fall_irq, 68 64 pwrkey_fall_irq,
+101 -26
drivers/input/misc/soc_button_array.c
··· 25 25 bool wakeup; 26 26 }; 27 27 28 + struct soc_device_data { 29 + const struct soc_button_info *button_info; 30 + int (*check)(struct device *dev); 31 + }; 32 + 28 33 /* 29 34 * Some of the buttons like volume up/down are auto repeat, while others 30 35 * are not. To support both, we register two platform devices, and put ··· 92 87 continue; 93 88 94 89 gpio = soc_button_lookup_gpio(&pdev->dev, info->acpi_index); 95 - if (!gpio_is_valid(gpio)) 90 + if (gpio < 0 && gpio != -ENOENT) { 91 + error = gpio; 92 + goto err_free_mem; 93 + } else if (!gpio_is_valid(gpio)) { 94 + /* Skip GPIO if not present */ 96 95 continue; 96 + } 97 97 98 98 gpio_keys[n_buttons].type = info->event_type; 99 99 gpio_keys[n_buttons].code = info->event_code; ··· 120 110 gpio_keys_pdata->nbuttons = n_buttons; 121 111 gpio_keys_pdata->rep = autorepeat; 122 112 123 - pd = platform_device_alloc("gpio-keys", PLATFORM_DEVID_AUTO); 124 - if (!pd) { 125 - error = -ENOMEM; 113 + pd = platform_device_register_resndata(&pdev->dev, "gpio-keys", 114 + PLATFORM_DEVID_AUTO, NULL, 0, 115 + gpio_keys_pdata, 116 + sizeof(*gpio_keys_pdata)); 117 + error = PTR_ERR_OR_ZERO(pd); 118 + if (error) { 119 + dev_err(&pdev->dev, 120 + "failed registering gpio-keys: %d\n", error); 126 121 goto err_free_mem; 127 122 } 128 123 129 - error = platform_device_add_data(pd, gpio_keys_pdata, 130 - sizeof(*gpio_keys_pdata)); 131 - if (error) 132 - goto err_free_pdev; 133 - 134 - error = platform_device_add(pd); 135 - if (error) 136 - goto err_free_pdev; 137 - 138 124 return pd; 139 125 140 - err_free_pdev: 141 - platform_device_put(pd); 142 126 err_free_mem: 143 127 devm_kfree(&pdev->dev, gpio_keys_pdata); 144 128 return ERR_PTR(error); ··· 313 309 static int soc_button_probe(struct platform_device *pdev) 314 310 { 315 311 struct device *dev = &pdev->dev; 316 - const struct acpi_device_id *id; 317 - struct soc_button_info *button_info; 312 + const struct soc_device_data *device_data; 313 + const struct soc_button_info *button_info; 318 314 struct soc_button_data *priv; 319 315 struct platform_device *pd; 320 316 int i; 321 317 int error; 322 318 323 - id = acpi_match_device(dev->driver->acpi_match_table, dev); 324 - if (!id) 325 - return -ENODEV; 319 + device_data = acpi_device_get_match_data(dev); 320 + if (device_data && device_data->check) { 321 + error = device_data->check(dev); 322 + if (error) 323 + return error; 324 + } 326 325 327 - if (!id->driver_data) { 326 + if (device_data && device_data->button_info) { 327 + button_info = device_data->button_info; 328 + } else { 328 329 button_info = soc_button_get_button_info(dev); 329 330 if (IS_ERR(button_info)) 330 331 return PTR_ERR(button_info); 331 - } else { 332 - button_info = (struct soc_button_info *)id->driver_data; 333 332 } 334 333 335 334 error = gpiod_count(dev, NULL); ··· 364 357 if (!priv->children[0] && !priv->children[1]) 365 358 return -ENODEV; 366 359 367 - if (!id->driver_data) 360 + if (!device_data || !device_data->button_info) 368 361 devm_kfree(dev, button_info); 369 362 370 363 return 0; ··· 375 368 * is defined in section 2.8.7.2 of "Windows ACPI Design Guide for SoC 376 369 * Platforms" 377 370 */ 378 - static struct soc_button_info soc_button_PNP0C40[] = { 371 + static const struct soc_button_info soc_button_PNP0C40[] = { 379 372 { "power", 0, EV_KEY, KEY_POWER, false, true }, 380 373 { "home", 1, EV_KEY, KEY_LEFTMETA, false, true }, 381 374 { "volume_up", 2, EV_KEY, KEY_VOLUMEUP, true, false }, ··· 384 377 { } 385 378 }; 386 379 380 + static const struct soc_device_data soc_device_PNP0C40 = { 381 + .button_info = soc_button_PNP0C40, 382 + }; 383 + 384 + /* 385 + * Special device check for Surface Book 2 and Surface Pro (2017). 386 + * Both, the Surface Pro 4 (surfacepro3_button.c) and the above mentioned 387 + * devices use MSHW0040 for power and volume buttons, however the way they 388 + * have to be addressed differs. Make sure that we only load this drivers 389 + * for the correct devices by checking the OEM Platform Revision provided by 390 + * the _DSM method. 391 + */ 392 + #define MSHW0040_DSM_REVISION 0x01 393 + #define MSHW0040_DSM_GET_OMPR 0x02 // get OEM Platform Revision 394 + static const guid_t MSHW0040_DSM_UUID = 395 + GUID_INIT(0x6fd05c69, 0xcde3, 0x49f4, 0x95, 0xed, 0xab, 0x16, 0x65, 396 + 0x49, 0x80, 0x35); 397 + 398 + static int soc_device_check_MSHW0040(struct device *dev) 399 + { 400 + acpi_handle handle = ACPI_HANDLE(dev); 401 + union acpi_object *result; 402 + u64 oem_platform_rev = 0; // valid revisions are nonzero 403 + 404 + // get OEM platform revision 405 + result = acpi_evaluate_dsm_typed(handle, &MSHW0040_DSM_UUID, 406 + MSHW0040_DSM_REVISION, 407 + MSHW0040_DSM_GET_OMPR, NULL, 408 + ACPI_TYPE_INTEGER); 409 + 410 + if (result) { 411 + oem_platform_rev = result->integer.value; 412 + ACPI_FREE(result); 413 + } 414 + 415 + /* 416 + * If the revision is zero here, the _DSM evaluation has failed. This 417 + * indicates that we have a Pro 4 or Book 1 and this driver should not 418 + * be used. 419 + */ 420 + if (oem_platform_rev == 0) 421 + return -ENODEV; 422 + 423 + dev_dbg(dev, "OEM Platform Revision %llu\n", oem_platform_rev); 424 + 425 + return 0; 426 + } 427 + 428 + /* 429 + * Button infos for Microsoft Surface Book 2 and Surface Pro (2017). 430 + * Obtained from DSDT/testing. 431 + */ 432 + static const struct soc_button_info soc_button_MSHW0040[] = { 433 + { "power", 0, EV_KEY, KEY_POWER, false, true }, 434 + { "volume_up", 2, EV_KEY, KEY_VOLUMEUP, true, false }, 435 + { "volume_down", 4, EV_KEY, KEY_VOLUMEDOWN, true, false }, 436 + { } 437 + }; 438 + 439 + static const struct soc_device_data soc_device_MSHW0040 = { 440 + .button_info = soc_button_MSHW0040, 441 + .check = soc_device_check_MSHW0040, 442 + }; 443 + 387 444 static const struct acpi_device_id soc_button_acpi_match[] = { 388 - { "PNP0C40", (unsigned long)soc_button_PNP0C40 }, 445 + { "PNP0C40", (unsigned long)&soc_device_PNP0C40 }, 389 446 { "ACPI0011", 0 }, 447 + 448 + /* Microsoft Surface Devices (5th and 6th generation) */ 449 + { "MSHW0040", (unsigned long)&soc_device_MSHW0040 }, 450 + 390 451 { } 391 452 }; 392 453
+2 -8
drivers/input/misc/stpmic1_onkey.c
··· 61 61 return -ENOMEM; 62 62 63 63 onkey->irq_falling = platform_get_irq_byname(pdev, "onkey-falling"); 64 - if (onkey->irq_falling < 0) { 65 - dev_err(dev, "failed: request IRQ onkey-falling %d\n", 66 - onkey->irq_falling); 64 + if (onkey->irq_falling < 0) 67 65 return onkey->irq_falling; 68 - } 69 66 70 67 onkey->irq_rising = platform_get_irq_byname(pdev, "onkey-rising"); 71 - if (onkey->irq_rising < 0) { 72 - dev_err(dev, "failed: request IRQ onkey-rising %d\n", 73 - onkey->irq_rising); 68 + if (onkey->irq_rising < 0) 74 69 return onkey->irq_rising; 75 - } 76 70 77 71 if (!device_property_read_u32(dev, "power-off-time-sec", &val)) { 78 72 if (val > 0 && val <= 16) {
+1 -3
drivers/input/misc/tps65218-pwrbutton.c
··· 124 124 device_init_wakeup(dev, true); 125 125 126 126 irq = platform_get_irq(pdev, 0); 127 - if (irq < 0) { 128 - dev_err(dev, "No IRQ resource!\n"); 127 + if (irq < 0) 129 128 return -EINVAL; 130 - } 131 129 132 130 error = devm_request_threaded_irq(dev, irq, NULL, tps6521x_pb_irq, 133 131 IRQF_TRIGGER_RISING |
+1 -3
drivers/input/misc/twl6040-vibra.c
··· 272 272 } 273 273 274 274 info->irq = platform_get_irq(pdev, 0); 275 - if (info->irq < 0) { 276 - dev_err(info->dev, "invalid irq\n"); 275 + if (info->irq < 0) 277 276 return -EINVAL; 278 - } 279 277 280 278 error = devm_request_threaded_irq(&pdev->dev, info->irq, NULL, 281 279 twl6040_vib_irq_handler,
-11
drivers/input/mouse/alps.h
··· 323 323 324 324 #define ALPS_QUIRK_TRACKSTICK_BUTTONS 1 /* trakcstick buttons in trackstick packet */ 325 325 326 - #ifdef CONFIG_MOUSE_PS2_ALPS 327 326 int alps_detect(struct psmouse *psmouse, bool set_properties); 328 327 int alps_init(struct psmouse *psmouse); 329 - #else 330 - inline int alps_detect(struct psmouse *psmouse, bool set_properties) 331 - { 332 - return -ENOSYS; 333 - } 334 - inline int alps_init(struct psmouse *psmouse) 335 - { 336 - return -ENOSYS; 337 - } 338 - #endif /* CONFIG_MOUSE_PS2_ALPS */ 339 328 340 329 #endif
-11
drivers/input/mouse/byd.h
··· 2 2 #ifndef _BYD_H 3 3 #define _BYD_H 4 4 5 - #ifdef CONFIG_MOUSE_PS2_BYD 6 5 int byd_detect(struct psmouse *psmouse, bool set_properties); 7 6 int byd_init(struct psmouse *psmouse); 8 - #else 9 - static inline int byd_detect(struct psmouse *psmouse, bool set_properties) 10 - { 11 - return -ENOSYS; 12 - } 13 - static inline int byd_init(struct psmouse *psmouse) 14 - { 15 - return -ENOSYS; 16 - } 17 - #endif /* CONFIG_MOUSE_PS2_BYD */ 18 7 19 8 #endif /* _BYD_H */
+1 -15
drivers/input/mouse/cyapa.c
··· 1238 1238 .attrs = cyapa_sysfs_entries, 1239 1239 }; 1240 1240 1241 - static void cyapa_remove_sysfs_group(void *data) 1242 - { 1243 - struct cyapa *cyapa = data; 1244 - 1245 - sysfs_remove_group(&cyapa->client->dev.kobj, &cyapa_sysfs_group); 1246 - } 1247 - 1248 1241 static void cyapa_disable_regulator(void *data) 1249 1242 { 1250 1243 struct cyapa *cyapa = data; ··· 1305 1312 return error; 1306 1313 } 1307 1314 1308 - error = sysfs_create_group(&dev->kobj, &cyapa_sysfs_group); 1315 + error = devm_device_add_group(dev, &cyapa_sysfs_group); 1309 1316 if (error) { 1310 1317 dev_err(dev, "failed to create sysfs entries: %d\n", error); 1311 - return error; 1312 - } 1313 - 1314 - error = devm_add_action(dev, cyapa_remove_sysfs_group, cyapa); 1315 - if (error) { 1316 - cyapa_remove_sysfs_group(cyapa); 1317 - dev_err(dev, "failed to add sysfs cleanup action: %d\n", error); 1318 1318 return error; 1319 1319 } 1320 1320
-11
drivers/input/mouse/cypress_ps2.h
··· 170 170 }; 171 171 172 172 173 - #ifdef CONFIG_MOUSE_PS2_CYPRESS 174 173 int cypress_detect(struct psmouse *psmouse, bool set_properties); 175 174 int cypress_init(struct psmouse *psmouse); 176 - #else 177 - inline int cypress_detect(struct psmouse *psmouse, bool set_properties) 178 - { 179 - return -ENOSYS; 180 - } 181 - inline int cypress_init(struct psmouse *psmouse) 182 - { 183 - return -ENOSYS; 184 - } 185 - #endif /* CONFIG_MOUSE_PS2_CYPRESS */ 186 175 187 176 #endif /* _CYPRESS_PS2_H */
+2 -18
drivers/input/mouse/elan_i2c_core.c
··· 1138 1138 regulator_disable(data->vcc); 1139 1139 } 1140 1140 1141 - static void elan_remove_sysfs_groups(void *_data) 1142 - { 1143 - struct elan_tp_data *data = _data; 1144 - 1145 - sysfs_remove_groups(&data->client->dev.kobj, elan_sysfs_groups); 1146 - } 1147 - 1148 1141 static int elan_probe(struct i2c_client *client, 1149 1142 const struct i2c_device_id *dev_id) 1150 1143 { ··· 1187 1194 return error; 1188 1195 } 1189 1196 1190 - error = devm_add_action(dev, elan_disable_regulator, data); 1197 + error = devm_add_action_or_reset(dev, elan_disable_regulator, data); 1191 1198 if (error) { 1192 - regulator_disable(data->vcc); 1193 1199 dev_err(dev, "Failed to add disable regulator action: %d\n", 1194 1200 error); 1195 1201 return error; ··· 1261 1269 return error; 1262 1270 } 1263 1271 1264 - error = sysfs_create_groups(&dev->kobj, elan_sysfs_groups); 1272 + error = devm_device_add_groups(dev, elan_sysfs_groups); 1265 1273 if (error) { 1266 1274 dev_err(dev, "failed to create sysfs attributes: %d\n", error); 1267 - return error; 1268 - } 1269 - 1270 - error = devm_add_action(dev, elan_remove_sysfs_groups, data); 1271 - if (error) { 1272 - elan_remove_sysfs_groups(data); 1273 - dev_err(dev, "Failed to add sysfs cleanup action: %d\n", 1274 - error); 1275 1275 return error; 1276 1276 } 1277 1277
+2 -16
drivers/input/mouse/elantech.h
··· 184 184 void (*original_set_rate)(struct psmouse *psmouse, unsigned int rate); 185 185 }; 186 186 187 - #ifdef CONFIG_MOUSE_PS2_ELANTECH 188 187 int elantech_detect(struct psmouse *psmouse, bool set_properties); 189 188 int elantech_init_ps2(struct psmouse *psmouse); 189 + 190 + #ifdef CONFIG_MOUSE_PS2_ELANTECH 190 191 int elantech_init(struct psmouse *psmouse); 191 192 #else 192 - static inline int elantech_detect(struct psmouse *psmouse, bool set_properties) 193 - { 194 - return -ENOSYS; 195 - } 196 193 static inline int elantech_init(struct psmouse *psmouse) 197 - { 198 - return -ENOSYS; 199 - } 200 - static inline int elantech_init_ps2(struct psmouse *psmouse) 201 194 { 202 195 return -ENOSYS; 203 196 } 204 197 #endif /* CONFIG_MOUSE_PS2_ELANTECH */ 205 198 206 - #if defined(CONFIG_MOUSE_PS2_ELANTECH_SMBUS) 207 199 int elantech_init_smbus(struct psmouse *psmouse); 208 - #else 209 - static inline int elantech_init_smbus(struct psmouse *psmouse) 210 - { 211 - return -ENOSYS; 212 - } 213 - #endif /* CONFIG_MOUSE_PS2_ELANTECH_SMBUS */ 214 200 215 201 #endif
+3 -10
drivers/input/mouse/hgpk.h
··· 47 47 int xsaw_secondary, ysaw_secondary; /* jumpiness detection */ 48 48 }; 49 49 50 - #ifdef CONFIG_MOUSE_PS2_OLPC 51 - void hgpk_module_init(void); 52 50 int hgpk_detect(struct psmouse *psmouse, bool set_properties); 53 51 int hgpk_init(struct psmouse *psmouse); 52 + 53 + #ifdef CONFIG_MOUSE_PS2_OLPC 54 + void hgpk_module_init(void); 54 55 #else 55 56 static inline void hgpk_module_init(void) 56 57 { 57 - } 58 - static inline int hgpk_detect(struct psmouse *psmouse, bool set_properties) 59 - { 60 - return -ENODEV; 61 - } 62 - static inline int hgpk_init(struct psmouse *psmouse) 63 - { 64 - return -ENODEV; 65 58 } 66 59 #endif 67 60
+3 -10
drivers/input/mouse/lifebook.h
··· 8 8 #ifndef _LIFEBOOK_H 9 9 #define _LIFEBOOK_H 10 10 11 - #ifdef CONFIG_MOUSE_PS2_LIFEBOOK 12 - void lifebook_module_init(void); 13 11 int lifebook_detect(struct psmouse *psmouse, bool set_properties); 14 12 int lifebook_init(struct psmouse *psmouse); 13 + 14 + #ifdef CONFIG_MOUSE_PS2_LIFEBOOK 15 + void lifebook_module_init(void); 15 16 #else 16 17 static inline void lifebook_module_init(void) 17 18 { 18 - } 19 - static inline int lifebook_detect(struct psmouse *psmouse, bool set_properties) 20 - { 21 - return -ENOSYS; 22 - } 23 - static inline int lifebook_init(struct psmouse *psmouse) 24 - { 25 - return -ENOSYS; 26 19 } 27 20 #endif 28 21
-7
drivers/input/mouse/logips2pp.h
··· 8 8 #ifndef _LOGIPS2PP_H 9 9 #define _LOGIPS2PP_H 10 10 11 - #ifdef CONFIG_MOUSE_PS2_LOGIPS2PP 12 11 int ps2pp_detect(struct psmouse *psmouse, bool set_properties); 13 - #else 14 - static inline int ps2pp_detect(struct psmouse *psmouse, bool set_properties) 15 - { 16 - return -ENOSYS; 17 - } 18 - #endif /* CONFIG_MOUSE_PS2_LOGIPS2PP */ 19 12 20 13 #endif
+1 -3
drivers/input/mouse/pxa930_trkball.c
··· 147 147 int irq, error; 148 148 149 149 irq = platform_get_irq(pdev, 0); 150 - if (irq < 0) { 151 - dev_err(&pdev->dev, "failed to get trkball irq\n"); 150 + if (irq < 0) 152 151 return -ENXIO; 153 - } 154 152 155 153 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 156 154 if (!res) {
-11
drivers/input/mouse/sentelic.h
··· 106 106 unsigned int last_mt_fgr; /* Last seen finger(multitouch) */ 107 107 }; 108 108 109 - #ifdef CONFIG_MOUSE_PS2_SENTELIC 110 109 extern int fsp_detect(struct psmouse *psmouse, bool set_properties); 111 110 extern int fsp_init(struct psmouse *psmouse); 112 - #else 113 - static inline int fsp_detect(struct psmouse *psmouse, bool set_properties) 114 - { 115 - return -ENOSYS; 116 - } 117 - static inline int fsp_init(struct psmouse *psmouse) 118 - { 119 - return -ENOSYS; 120 - } 121 - #endif 122 111 123 112 #endif /* __KERNEL__ */ 124 113
+1 -1
drivers/input/mouse/synaptics.c
··· 193 193 }; 194 194 195 195 /* 196 - * Send a command to the synpatics touchpad by special commands 196 + * Send a command to the synaptics touchpad by special commands 197 197 */ 198 198 static int synaptics_send_cmd(struct psmouse *psmouse, u8 cmd, u8 *param) 199 199 {
-8
drivers/input/mouse/touchkit_ps2.h
··· 9 9 #ifndef _TOUCHKIT_PS2_H 10 10 #define _TOUCHKIT_PS2_H 11 11 12 - #ifdef CONFIG_MOUSE_PS2_TOUCHKIT 13 12 int touchkit_ps2_detect(struct psmouse *psmouse, bool set_properties); 14 - #else 15 - static inline int touchkit_ps2_detect(struct psmouse *psmouse, 16 - bool set_properties) 17 - { 18 - return -ENOSYS; 19 - } 20 - #endif /* CONFIG_MOUSE_PS2_TOUCHKIT */ 21 13 22 14 #endif
-8
drivers/input/mouse/trackpoint.h
··· 155 155 bool ext_dev; 156 156 }; 157 157 158 - #ifdef CONFIG_MOUSE_PS2_TRACKPOINT 159 158 int trackpoint_detect(struct psmouse *psmouse, bool set_properties); 160 - #else 161 - static inline int trackpoint_detect(struct psmouse *psmouse, 162 - bool set_properties) 163 - { 164 - return -ENOSYS; 165 - } 166 - #endif /* CONFIG_MOUSE_PS2_TRACKPOINT */ 167 159 168 160 #endif /* _TRACKPOINT_H */
-11
drivers/input/mouse/vmmouse.h
··· 8 8 #ifndef _VMMOUSE_H 9 9 #define _VMMOUSE_H 10 10 11 - #ifdef CONFIG_MOUSE_PS2_VMMOUSE 12 11 #define VMMOUSE_PSNAME "VirtualPS/2" 13 12 14 13 int vmmouse_detect(struct psmouse *psmouse, bool set_properties); 15 14 int vmmouse_init(struct psmouse *psmouse); 16 - #else 17 - static inline int vmmouse_detect(struct psmouse *psmouse, bool set_properties) 18 - { 19 - return -ENOSYS; 20 - } 21 - static inline int vmmouse_init(struct psmouse *psmouse) 22 - { 23 - return -ENOSYS; 24 - } 25 - #endif 26 15 27 16 #endif
-1
drivers/input/rmi4/rmi_2d_sensor.c
··· 204 204 if (sensor->topbuttonpad) 205 205 set_bit(INPUT_PROP_TOPBUTTONPAD, input->propbit); 206 206 } 207 - EXPORT_SYMBOL_GPL(rmi_2d_sensor_set_input_params); 208 207 209 208 int rmi_2d_sensor_configure_input(struct rmi_function *fn, 210 209 struct rmi_2d_sensor *sensor)
+1 -3
drivers/input/serio/arc_ps2.c
··· 187 187 int error, id, i; 188 188 189 189 irq = platform_get_irq_byname(pdev, "arc_ps2_irq"); 190 - if (irq < 0) { 191 - dev_err(&pdev->dev, "no IRQ defined\n"); 190 + if (irq < 0) 192 191 return -EINVAL; 193 - } 194 192 195 193 arc_ps2 = devm_kzalloc(&pdev->dev, sizeof(struct arc_ps2_data), 196 194 GFP_KERNEL);
+14 -11
drivers/input/serio/i8042.c
··· 432 432 { 433 433 struct i8042_port *port = serio->port_data; 434 434 435 + device_set_wakeup_capable(&serio->dev, true); 436 + 437 + /* 438 + * On platforms using suspend-to-idle, allow the keyboard to 439 + * wake up the system from sleep by enabling keyboard wakeups 440 + * by default. This is consistent with keyboard wakeup 441 + * behavior on many platforms using suspend-to-RAM (ACPI S3) 442 + * by default. 443 + */ 444 + if (pm_suspend_default_s2idle() && 445 + serio == i8042_ports[I8042_KBD_PORT_NO].serio) { 446 + device_set_wakeup_enable(&serio->dev, true); 447 + } 448 + 435 449 spin_lock_irq(&i8042_lock); 436 450 port->exists = true; 437 451 spin_unlock_irq(&i8042_lock); ··· 1411 1397 (unsigned long) I8042_COMMAND_REG, 1412 1398 i8042_ports[i].irq); 1413 1399 serio_register_port(serio); 1414 - device_set_wakeup_capable(&serio->dev, true); 1415 - 1416 - /* 1417 - * On platforms using suspend-to-idle, allow the keyboard to 1418 - * wake up the system from sleep by enabling keyboard wakeups 1419 - * by default. This is consistent with keyboard wakeup 1420 - * behavior on many platforms using suspend-to-RAM (ACPI S3) 1421 - * by default. 1422 - */ 1423 - if (pm_suspend_default_s2idle() && i == I8042_KBD_PORT_NO) 1424 - device_set_wakeup_enable(&serio->dev, true); 1425 1400 } 1426 1401 } 1427 1402
-2
drivers/input/serio/ps2-gpio.c
··· 369 369 370 370 drvdata->irq = platform_get_irq(pdev, 0); 371 371 if (drvdata->irq < 0) { 372 - dev_err(dev, "failed to get irq from platform resource: %d\n", 373 - drvdata->irq); 374 372 error = drvdata->irq; 375 373 goto err_free_serio; 376 374 }
+1 -3
drivers/input/touchscreen/88pm860x-ts.c
··· 185 185 int irq, ret, res_x = 0, data = 0; 186 186 187 187 irq = platform_get_irq(pdev, 0); 188 - if (irq < 0) { 189 - dev_err(&pdev->dev, "No IRQ resource!\n"); 188 + if (irq < 0) 190 189 return -EINVAL; 191 - } 192 190 193 191 if (pm860x_touch_dt_init(pdev, chip, &res_x)) { 194 192 if (pdata) {
-9
drivers/input/touchscreen/Kconfig
··· 1112 1112 or ambient light monitoring), temperature and raw input 1113 1113 values. 1114 1114 1115 - config TOUCHSCREEN_W90X900 1116 - tristate "W90P910 touchscreen driver" 1117 - depends on ARCH_W90X900 1118 - help 1119 - Say Y here if you have a W90P910 based touchscreen. 1120 - 1121 - To compile this driver as a module, choose M here: the 1122 - module will be called w90p910_ts. 1123 - 1124 1115 config TOUCHSCREEN_PCAP 1125 1116 tristate "Motorola PCAP touchscreen" 1126 1117 depends on EZX_PCAP
-1
drivers/input/touchscreen/Makefile
··· 102 102 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9713) += wm9713.o 103 103 obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE) += mainstone-wm97xx.o 104 104 obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE) += zylonite-wm97xx.o 105 - obj-$(CONFIG_TOUCHSCREEN_W90X900) += w90p910_ts.o 106 105 obj-$(CONFIG_TOUCHSCREEN_SX8654) += sx8654.o 107 106 obj-$(CONFIG_TOUCHSCREEN_TPS6507X) += tps6507x-ts.o 108 107 obj-$(CONFIG_TOUCHSCREEN_ZET6223) += zet6223.o
+30 -8
drivers/input/touchscreen/ads7846.c
··· 20 20 #include <linux/sched.h> 21 21 #include <linux/delay.h> 22 22 #include <linux/input.h> 23 + #include <linux/input/touchscreen.h> 23 24 #include <linux/interrupt.h> 24 25 #include <linux/slab.h> 25 26 #include <linux/pm.h> ··· 129 128 u16 debounce_rep; 130 129 131 130 u16 penirq_recheck_delay_usecs; 131 + 132 + struct touchscreen_properties core_prop; 132 133 133 134 struct mutex lock; 134 135 bool stopped; /* P: lock */ ··· 826 823 if (Rt) { 827 824 struct input_dev *input = ts->input; 828 825 829 - if (ts->swap_xy) 830 - swap(x, y); 831 - 832 826 if (!ts->pendown) { 833 827 input_report_key(input, BTN_TOUCH, 1); 834 828 ts->pendown = true; 835 829 dev_vdbg(&ts->spi->dev, "DOWN\n"); 836 830 } 837 831 838 - input_report_abs(input, ABS_X, x); 839 - input_report_abs(input, ABS_Y, y); 832 + touchscreen_report_pos(input, &ts->core_prop, x, y, false); 840 833 input_report_abs(input, ABS_PRESSURE, ts->pressure_max - Rt); 841 834 842 835 input_sync(input); ··· 1184 1185 struct ads7846_platform_data *pdata; 1185 1186 struct device_node *node = dev->of_node; 1186 1187 const struct of_device_id *match; 1188 + u32 value; 1187 1189 1188 1190 if (!node) { 1189 1191 dev_err(dev, "Device does not have associated DT data\n"); ··· 1223 1223 of_property_read_u16(node, "ti,x-max", &pdata->x_max); 1224 1224 of_property_read_u16(node, "ti,y-max", &pdata->y_max); 1225 1225 1226 + /* 1227 + * touchscreen-max-pressure gets parsed during 1228 + * touchscreen_parse_properties() 1229 + */ 1226 1230 of_property_read_u16(node, "ti,pressure-min", &pdata->pressure_min); 1231 + if (!of_property_read_u32(node, "touchscreen-min-pressure", &value)) 1232 + pdata->pressure_min = (u16) value; 1227 1233 of_property_read_u16(node, "ti,pressure-max", &pdata->pressure_max); 1228 1234 1229 1235 of_property_read_u16(node, "ti,debounce-max", &pdata->debounce_max); 1236 + if (!of_property_read_u32(node, "touchscreen-average-samples", &value)) 1237 + pdata->debounce_max = (u16) value; 1230 1238 of_property_read_u16(node, "ti,debounce-tol", &pdata->debounce_tol); 1231 1239 of_property_read_u16(node, "ti,debounce-rep", &pdata->debounce_rep); 1232 1240 ··· 1317 1309 ts->model = pdata->model ? : 7846; 1318 1310 ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100; 1319 1311 ts->x_plate_ohms = pdata->x_plate_ohms ? : 400; 1320 - ts->pressure_max = pdata->pressure_max ? : ~0; 1321 - 1322 1312 ts->vref_mv = pdata->vref_mv; 1323 - ts->swap_xy = pdata->swap_xy; 1324 1313 1325 1314 if (pdata->filter != NULL) { 1326 1315 if (pdata->filter_init != NULL) { ··· 1368 1363 0, 0); 1369 1364 input_set_abs_params(input_dev, ABS_PRESSURE, 1370 1365 pdata->pressure_min, pdata->pressure_max, 0, 0); 1366 + 1367 + /* 1368 + * Parse common framework properties. Must be done here to ensure the 1369 + * correct behaviour in case of using the legacy vendor bindings. The 1370 + * general binding value overrides the vendor specific one. 1371 + */ 1372 + touchscreen_parse_properties(ts->input, false, &ts->core_prop); 1373 + ts->pressure_max = input_abs_get_max(input_dev, ABS_PRESSURE) ? : ~0; 1374 + 1375 + /* 1376 + * Check if legacy ti,swap-xy binding is used instead of 1377 + * touchscreen-swapped-x-y 1378 + */ 1379 + if (!ts->core_prop.swap_x_y && pdata->swap_xy) { 1380 + swap(input_dev->absinfo[ABS_X], input_dev->absinfo[ABS_Y]); 1381 + ts->core_prop.swap_x_y = true; 1382 + } 1371 1383 1372 1384 ads7846_setup_spi_msg(ts, pdata); 1373 1385
+1 -2
drivers/input/touchscreen/atmel_mxt_ts.c
··· 2990 2990 int error; 2991 2991 2992 2992 if (device_property_present(dev, keymap_property)) { 2993 - n_keys = device_property_read_u32_array(dev, keymap_property, 2994 - NULL, 0); 2993 + n_keys = device_property_count_u32(dev, keymap_property); 2995 2994 if (n_keys <= 0) { 2996 2995 error = n_keys < 0 ? n_keys : -EINVAL; 2997 2996 dev_err(dev, "invalid/malformed '%s' property: %d\n",
+1 -3
drivers/input/touchscreen/bcm_iproc_tsc.c
··· 489 489 490 490 /* get interrupt */ 491 491 irq = platform_get_irq(pdev, 0); 492 - if (irq < 0) { 493 - dev_err(&pdev->dev, "platform_get_irq failed: %d\n", irq); 492 + if (irq < 0) 494 493 return irq; 495 - } 496 494 497 495 error = devm_request_irq(&pdev->dev, irq, 498 496 iproc_touchscreen_interrupt,
+329 -427
drivers/input/touchscreen/bu21013_ts.c
··· 4 4 * Author: Naveen Kumar G <naveen.gaddipati@stericsson.com> for ST-Ericsson 5 5 */ 6 6 7 - #include <linux/kernel.h> 7 + #include <linux/bitops.h> 8 8 #include <linux/delay.h> 9 - #include <linux/interrupt.h> 9 + #include <linux/gpio/consumer.h> 10 10 #include <linux/i2c.h> 11 - #include <linux/workqueue.h> 12 11 #include <linux/input.h> 13 - #include <linux/input/bu21013.h> 14 - #include <linux/slab.h> 15 - #include <linux/regulator/consumer.h> 12 + #include <linux/input/mt.h> 13 + #include <linux/input/touchscreen.h> 14 + #include <linux/interrupt.h> 15 + #include <linux/kernel.h> 16 16 #include <linux/module.h> 17 - #include <linux/gpio.h> 18 - #include <linux/of.h> 19 - #include <linux/of_gpio.h> 17 + #include <linux/property.h> 18 + #include <linux/regulator/consumer.h> 19 + #include <linux/slab.h> 20 + #include <linux/types.h> 20 21 21 - #define PEN_DOWN_INTR 0 22 22 #define MAX_FINGERS 2 23 23 #define RESET_DELAY 30 24 24 #define PENUP_TIMEOUT (10) ··· 137 137 #define DRIVER_TP "bu21013_tp" 138 138 139 139 /** 140 - * struct bu21013_ts_data - touch panel data structure 140 + * struct bu21013_ts - touch panel data structure 141 141 * @client: pointer to the i2c client 142 - * @wait: variable to wait_queue_head_t structure 143 - * @touch_stopped: touch stop flag 144 - * @chip: pointer to the touch panel controller 145 142 * @in_dev: pointer to the input device structure 146 - * @intr_pin: interrupt pin value 143 + * @props: the device coordinate transformation properties 147 144 * @regulator: pointer to the Regulator used for touch screen 145 + * @cs_gpiod: chip select GPIO line 146 + * @int_gpiod: touch interrupt GPIO line 147 + * @touch_x_max: maximum X coordinate reported by the device 148 + * @touch_y_max: maximum Y coordinate reported by the device 149 + * @x_flip: indicates that the driver should invert X coordinate before 150 + * reporting 151 + * @y_flip: indicates that the driver should invert Y coordinate before 152 + * reporting 153 + * @touch_stopped: touch stop flag 148 154 * 149 155 * Touch panel device data structure 150 156 */ 151 - struct bu21013_ts_data { 157 + struct bu21013_ts { 152 158 struct i2c_client *client; 153 - wait_queue_head_t wait; 154 - const struct bu21013_platform_device *chip; 155 159 struct input_dev *in_dev; 160 + struct touchscreen_properties props; 156 161 struct regulator *regulator; 157 - unsigned int irq; 158 - unsigned int intr_pin; 162 + struct gpio_desc *cs_gpiod; 163 + struct gpio_desc *int_gpiod; 164 + u32 touch_x_max; 165 + u32 touch_y_max; 166 + bool x_flip; 167 + bool y_flip; 159 168 bool touch_stopped; 160 169 }; 161 170 162 - /** 163 - * bu21013_read_block_data(): read the touch co-ordinates 164 - * @data: bu21013_ts_data structure pointer 165 - * @buf: byte pointer 166 - * 167 - * Read the touch co-ordinates using i2c read block into buffer 168 - * and returns integer. 169 - */ 170 - static int bu21013_read_block_data(struct bu21013_ts_data *data, u8 *buf) 171 + static int bu21013_read_block_data(struct bu21013_ts *ts, u8 *buf) 171 172 { 172 173 int ret, i; 173 174 174 175 for (i = 0; i < I2C_RETRY_COUNT; i++) { 175 - ret = i2c_smbus_read_i2c_block_data 176 - (data->client, BU21013_SENSORS_BTN_0_7_REG, 177 - LENGTH_OF_BUFFER, buf); 176 + ret = i2c_smbus_read_i2c_block_data(ts->client, 177 + BU21013_SENSORS_BTN_0_7_REG, 178 + LENGTH_OF_BUFFER, buf); 178 179 if (ret == LENGTH_OF_BUFFER) 179 180 return 0; 180 181 } 182 + 181 183 return -EINVAL; 182 184 } 183 185 184 - /** 185 - * bu21013_do_touch_report(): Get the touch co-ordinates 186 - * @data: bu21013_ts_data structure pointer 187 - * 188 - * Get the touch co-ordinates from touch sensor registers and writes 189 - * into device structure and returns integer. 190 - */ 191 - static int bu21013_do_touch_report(struct bu21013_ts_data *data) 186 + static int bu21013_do_touch_report(struct bu21013_ts *ts) 192 187 { 193 - u8 buf[LENGTH_OF_BUFFER]; 194 - unsigned int pos_x[2], pos_y[2]; 195 - bool has_x_sensors, has_y_sensors; 196 - int finger_down_count = 0; 197 - int i; 188 + struct input_dev *input = ts->in_dev; 189 + struct input_mt_pos pos[MAX_FINGERS]; 190 + int slots[MAX_FINGERS]; 191 + u8 buf[LENGTH_OF_BUFFER]; 192 + bool has_x_sensors, has_y_sensors; 193 + int finger_down_count = 0; 194 + int i; 198 195 199 - if (data == NULL) 200 - return -EINVAL; 201 - 202 - if (bu21013_read_block_data(data, buf) < 0) 196 + if (bu21013_read_block_data(ts, buf) < 0) 203 197 return -EINVAL; 204 198 205 199 has_x_sensors = hweight32(buf[0] & BU21013_SENSORS_EN_0_7); ··· 203 209 return 0; 204 210 205 211 for (i = 0; i < MAX_FINGERS; i++) { 206 - const u8 *p = &buf[4 * i + 3]; 207 - unsigned int x = p[0] << SHIFT_2 | (p[1] & MASK_BITS); 208 - unsigned int y = p[2] << SHIFT_2 | (p[3] & MASK_BITS); 209 - if (x == 0 || y == 0) 210 - continue; 211 - pos_x[finger_down_count] = x; 212 - pos_y[finger_down_count] = y; 213 - finger_down_count++; 212 + const u8 *data = &buf[4 * i + 3]; 213 + unsigned int x, y; 214 + 215 + x = data[0] << SHIFT_2 | (data[1] & MASK_BITS); 216 + y = data[2] << SHIFT_2 | (data[3] & MASK_BITS); 217 + if (x != 0 && y != 0) 218 + touchscreen_set_mt_pos(&pos[finger_down_count++], 219 + &ts->props, x, y); 214 220 } 215 221 216 - if (finger_down_count) { 217 - if (finger_down_count == 2 && 218 - (abs(pos_x[0] - pos_x[1]) < DELTA_MIN || 219 - abs(pos_y[0] - pos_y[1]) < DELTA_MIN)) { 220 - return 0; 221 - } 222 + if (finger_down_count == 2 && 223 + (abs(pos[0].x - pos[1].x) < DELTA_MIN || 224 + abs(pos[0].y - pos[1].y) < DELTA_MIN)) { 225 + return 0; 226 + } 222 227 223 - for (i = 0; i < finger_down_count; i++) { 224 - if (data->chip->x_flip) 225 - pos_x[i] = data->chip->touch_x_max - pos_x[i]; 226 - if (data->chip->y_flip) 227 - pos_y[i] = data->chip->touch_y_max - pos_y[i]; 228 + input_mt_assign_slots(input, slots, pos, finger_down_count, DELTA_MIN); 229 + for (i = 0; i < finger_down_count; i++) { 230 + input_mt_slot(input, slots[i]); 231 + input_mt_report_slot_state(input, MT_TOOL_FINGER, true); 232 + input_report_abs(input, ABS_MT_POSITION_X, pos[i].x); 233 + input_report_abs(input, ABS_MT_POSITION_Y, pos[i].y); 234 + } 228 235 229 - input_report_abs(data->in_dev, 230 - ABS_MT_POSITION_X, pos_x[i]); 231 - input_report_abs(data->in_dev, 232 - ABS_MT_POSITION_Y, pos_y[i]); 233 - input_mt_sync(data->in_dev); 234 - } 235 - } else 236 - input_mt_sync(data->in_dev); 237 - 238 - input_sync(data->in_dev); 236 + input_mt_sync_frame(input); 237 + input_sync(input); 239 238 240 239 return 0; 241 240 } 242 - /** 243 - * bu21013_gpio_irq() - gpio thread function for touch interrupt 244 - * @irq: irq value 245 - * @device_data: void pointer 246 - * 247 - * This gpio thread function for touch interrupt 248 - * and returns irqreturn_t. 249 - */ 241 + 250 242 static irqreturn_t bu21013_gpio_irq(int irq, void *device_data) 251 243 { 252 - struct bu21013_ts_data *data = device_data; 253 - struct i2c_client *i2c = data->client; 254 - int retval; 244 + struct bu21013_ts *ts = device_data; 245 + int keep_polling; 246 + int error; 255 247 256 248 do { 257 - retval = bu21013_do_touch_report(data); 258 - if (retval < 0) { 259 - dev_err(&i2c->dev, "bu21013_do_touch_report failed\n"); 260 - return IRQ_NONE; 249 + error = bu21013_do_touch_report(ts); 250 + if (error) { 251 + dev_err(&ts->client->dev, "%s failed\n", __func__); 252 + break; 261 253 } 262 254 263 - data->intr_pin = gpio_get_value(data->chip->touch_pin); 264 - if (data->intr_pin == PEN_DOWN_INTR) 265 - wait_event_timeout(data->wait, data->touch_stopped, 266 - msecs_to_jiffies(2)); 267 - } while (!data->intr_pin && !data->touch_stopped); 255 + if (unlikely(ts->touch_stopped)) 256 + break; 257 + 258 + keep_polling = ts->int_gpiod ? 259 + gpiod_get_value(ts->int_gpiod) : false; 260 + if (keep_polling) 261 + usleep_range(2000, 2500); 262 + } while (keep_polling); 268 263 269 264 return IRQ_HANDLED; 270 265 } 271 266 272 - /** 273 - * bu21013_init_chip() - power on sequence for the bu21013 controller 274 - * @data: device structure pointer 275 - * 276 - * This function is used to power on 277 - * the bu21013 controller and returns integer. 278 - */ 279 - static int bu21013_init_chip(struct bu21013_ts_data *data) 267 + static int bu21013_init_chip(struct bu21013_ts *ts) 280 268 { 281 - int retval; 282 - struct i2c_client *i2c = data->client; 269 + struct i2c_client *client = ts->client; 270 + int error; 283 271 284 - retval = i2c_smbus_write_byte_data(i2c, BU21013_RESET_REG, 285 - BU21013_RESET_ENABLE); 286 - if (retval < 0) { 287 - dev_err(&i2c->dev, "BU21013_RESET reg write failed\n"); 288 - return retval; 272 + error = i2c_smbus_write_byte_data(client, BU21013_RESET_REG, 273 + BU21013_RESET_ENABLE); 274 + if (error) { 275 + dev_err(&client->dev, "BU21013_RESET reg write failed\n"); 276 + return error; 289 277 } 290 278 msleep(RESET_DELAY); 291 279 292 - retval = i2c_smbus_write_byte_data(i2c, BU21013_SENSOR_0_7_REG, 293 - BU21013_SENSORS_EN_0_7); 294 - if (retval < 0) { 295 - dev_err(&i2c->dev, "BU21013_SENSOR_0_7 reg write failed\n"); 296 - return retval; 280 + error = i2c_smbus_write_byte_data(client, BU21013_SENSOR_0_7_REG, 281 + BU21013_SENSORS_EN_0_7); 282 + if (error) { 283 + dev_err(&client->dev, "BU21013_SENSOR_0_7 reg write failed\n"); 284 + return error; 297 285 } 298 286 299 - retval = i2c_smbus_write_byte_data(i2c, BU21013_SENSOR_8_15_REG, 300 - BU21013_SENSORS_EN_8_15); 301 - if (retval < 0) { 302 - dev_err(&i2c->dev, "BU21013_SENSOR_8_15 reg write failed\n"); 303 - return retval; 287 + error = i2c_smbus_write_byte_data(client, BU21013_SENSOR_8_15_REG, 288 + BU21013_SENSORS_EN_8_15); 289 + if (error) { 290 + dev_err(&client->dev, "BU21013_SENSOR_8_15 reg write failed\n"); 291 + return error; 304 292 } 305 293 306 - retval = i2c_smbus_write_byte_data(i2c, BU21013_SENSOR_16_23_REG, 307 - BU21013_SENSORS_EN_16_23); 308 - if (retval < 0) { 309 - dev_err(&i2c->dev, "BU21013_SENSOR_16_23 reg write failed\n"); 310 - return retval; 294 + error = i2c_smbus_write_byte_data(client, BU21013_SENSOR_16_23_REG, 295 + BU21013_SENSORS_EN_16_23); 296 + if (error) { 297 + dev_err(&client->dev, "BU21013_SENSOR_16_23 reg write failed\n"); 298 + return error; 311 299 } 312 300 313 - retval = i2c_smbus_write_byte_data(i2c, BU21013_POS_MODE1_REG, 314 - (BU21013_POS_MODE1_0 | BU21013_POS_MODE1_1)); 315 - if (retval < 0) { 316 - dev_err(&i2c->dev, "BU21013_POS_MODE1 reg write failed\n"); 317 - return retval; 301 + error = i2c_smbus_write_byte_data(client, BU21013_POS_MODE1_REG, 302 + BU21013_POS_MODE1_0 | 303 + BU21013_POS_MODE1_1); 304 + if (error) { 305 + dev_err(&client->dev, "BU21013_POS_MODE1 reg write failed\n"); 306 + return error; 318 307 } 319 308 320 - retval = i2c_smbus_write_byte_data(i2c, BU21013_POS_MODE2_REG, 321 - (BU21013_POS_MODE2_ZERO | BU21013_POS_MODE2_AVG1 | 322 - BU21013_POS_MODE2_AVG2 | BU21013_POS_MODE2_EN_RAW | 323 - BU21013_POS_MODE2_MULTI)); 324 - if (retval < 0) { 325 - dev_err(&i2c->dev, "BU21013_POS_MODE2 reg write failed\n"); 326 - return retval; 309 + error = i2c_smbus_write_byte_data(client, BU21013_POS_MODE2_REG, 310 + BU21013_POS_MODE2_ZERO | 311 + BU21013_POS_MODE2_AVG1 | 312 + BU21013_POS_MODE2_AVG2 | 313 + BU21013_POS_MODE2_EN_RAW | 314 + BU21013_POS_MODE2_MULTI); 315 + if (error) { 316 + dev_err(&client->dev, "BU21013_POS_MODE2 reg write failed\n"); 317 + return error; 327 318 } 328 319 329 - if (data->chip->ext_clk) 330 - retval = i2c_smbus_write_byte_data(i2c, BU21013_CLK_MODE_REG, 331 - (BU21013_CLK_MODE_EXT | BU21013_CLK_MODE_CALIB)); 332 - else 333 - retval = i2c_smbus_write_byte_data(i2c, BU21013_CLK_MODE_REG, 334 - (BU21013_CLK_MODE_DIV | BU21013_CLK_MODE_CALIB)); 335 - if (retval < 0) { 336 - dev_err(&i2c->dev, "BU21013_CLK_MODE reg write failed\n"); 337 - return retval; 320 + error = i2c_smbus_write_byte_data(client, BU21013_CLK_MODE_REG, 321 + BU21013_CLK_MODE_DIV | 322 + BU21013_CLK_MODE_CALIB); 323 + if (error) { 324 + dev_err(&client->dev, "BU21013_CLK_MODE reg write failed\n"); 325 + return error; 338 326 } 339 327 340 - retval = i2c_smbus_write_byte_data(i2c, BU21013_IDLE_REG, 341 - (BU21013_IDLET_0 | BU21013_IDLE_INTERMIT_EN)); 342 - if (retval < 0) { 343 - dev_err(&i2c->dev, "BU21013_IDLE reg write failed\n"); 344 - return retval; 328 + error = i2c_smbus_write_byte_data(client, BU21013_IDLE_REG, 329 + BU21013_IDLET_0 | 330 + BU21013_IDLE_INTERMIT_EN); 331 + if (error) { 332 + dev_err(&client->dev, "BU21013_IDLE reg write failed\n"); 333 + return error; 345 334 } 346 335 347 - retval = i2c_smbus_write_byte_data(i2c, BU21013_INT_MODE_REG, 348 - BU21013_INT_MODE_LEVEL); 349 - if (retval < 0) { 350 - dev_err(&i2c->dev, "BU21013_INT_MODE reg write failed\n"); 351 - return retval; 336 + error = i2c_smbus_write_byte_data(client, BU21013_INT_MODE_REG, 337 + BU21013_INT_MODE_LEVEL); 338 + if (error) { 339 + dev_err(&client->dev, "BU21013_INT_MODE reg write failed\n"); 340 + return error; 352 341 } 353 342 354 - retval = i2c_smbus_write_byte_data(i2c, BU21013_FILTER_REG, 355 - (BU21013_DELTA_0_6 | 356 - BU21013_FILTER_EN)); 357 - if (retval < 0) { 358 - dev_err(&i2c->dev, "BU21013_FILTER reg write failed\n"); 359 - return retval; 343 + error = i2c_smbus_write_byte_data(client, BU21013_FILTER_REG, 344 + BU21013_DELTA_0_6 | 345 + BU21013_FILTER_EN); 346 + if (error) { 347 + dev_err(&client->dev, "BU21013_FILTER reg write failed\n"); 348 + return error; 360 349 } 361 350 362 - retval = i2c_smbus_write_byte_data(i2c, BU21013_TH_ON_REG, 363 - BU21013_TH_ON_5); 364 - if (retval < 0) { 365 - dev_err(&i2c->dev, "BU21013_TH_ON reg write failed\n"); 366 - return retval; 351 + error = i2c_smbus_write_byte_data(client, BU21013_TH_ON_REG, 352 + BU21013_TH_ON_5); 353 + if (error) { 354 + dev_err(&client->dev, "BU21013_TH_ON reg write failed\n"); 355 + return error; 367 356 } 368 357 369 - retval = i2c_smbus_write_byte_data(i2c, BU21013_TH_OFF_REG, 370 - BU21013_TH_OFF_4 | BU21013_TH_OFF_3); 371 - if (retval < 0) { 372 - dev_err(&i2c->dev, "BU21013_TH_OFF reg write failed\n"); 373 - return retval; 358 + error = i2c_smbus_write_byte_data(client, BU21013_TH_OFF_REG, 359 + BU21013_TH_OFF_4 | BU21013_TH_OFF_3); 360 + if (error) { 361 + dev_err(&client->dev, "BU21013_TH_OFF reg write failed\n"); 362 + return error; 374 363 } 375 364 376 - retval = i2c_smbus_write_byte_data(i2c, BU21013_GAIN_REG, 377 - (BU21013_GAIN_0 | BU21013_GAIN_1)); 378 - if (retval < 0) { 379 - dev_err(&i2c->dev, "BU21013_GAIN reg write failed\n"); 380 - return retval; 365 + error = i2c_smbus_write_byte_data(client, BU21013_GAIN_REG, 366 + BU21013_GAIN_0 | BU21013_GAIN_1); 367 + if (error) { 368 + dev_err(&client->dev, "BU21013_GAIN reg write failed\n"); 369 + return error; 381 370 } 382 371 383 - retval = i2c_smbus_write_byte_data(i2c, BU21013_OFFSET_MODE_REG, 384 - BU21013_OFFSET_MODE_DEFAULT); 385 - if (retval < 0) { 386 - dev_err(&i2c->dev, "BU21013_OFFSET_MODE reg write failed\n"); 387 - return retval; 372 + error = i2c_smbus_write_byte_data(client, BU21013_OFFSET_MODE_REG, 373 + BU21013_OFFSET_MODE_DEFAULT); 374 + if (error) { 375 + dev_err(&client->dev, "BU21013_OFFSET_MODE reg write failed\n"); 376 + return error; 388 377 } 389 378 390 - retval = i2c_smbus_write_byte_data(i2c, BU21013_XY_EDGE_REG, 391 - (BU21013_X_EDGE_0 | BU21013_X_EDGE_2 | 392 - BU21013_Y_EDGE_1 | BU21013_Y_EDGE_3)); 393 - if (retval < 0) { 394 - dev_err(&i2c->dev, "BU21013_XY_EDGE reg write failed\n"); 395 - return retval; 379 + error = i2c_smbus_write_byte_data(client, BU21013_XY_EDGE_REG, 380 + BU21013_X_EDGE_0 | 381 + BU21013_X_EDGE_2 | 382 + BU21013_Y_EDGE_1 | 383 + BU21013_Y_EDGE_3); 384 + if (error) { 385 + dev_err(&client->dev, "BU21013_XY_EDGE reg write failed\n"); 386 + return error; 396 387 } 397 388 398 - retval = i2c_smbus_write_byte_data(i2c, BU21013_DONE_REG, 399 - BU21013_DONE); 400 - if (retval < 0) { 401 - dev_err(&i2c->dev, "BU21013_REG_DONE reg write failed\n"); 402 - return retval; 389 + error = i2c_smbus_write_byte_data(client, BU21013_DONE_REG, 390 + BU21013_DONE); 391 + if (error) { 392 + dev_err(&client->dev, "BU21013_REG_DONE reg write failed\n"); 393 + return error; 403 394 } 404 395 405 396 return 0; 406 397 } 407 398 408 - /** 409 - * bu21013_free_irq() - frees IRQ registered for touchscreen 410 - * @bu21013_data: device structure pointer 411 - * 412 - * This function signals interrupt thread to stop processing and 413 - * frees interrupt. 414 - */ 415 - static void bu21013_free_irq(struct bu21013_ts_data *bu21013_data) 399 + static void bu21013_power_off(void *_ts) 416 400 { 417 - bu21013_data->touch_stopped = true; 418 - wake_up(&bu21013_data->wait); 419 - free_irq(bu21013_data->irq, bu21013_data); 401 + struct bu21013_ts *ts = _ts; 402 + 403 + regulator_disable(ts->regulator); 420 404 } 421 405 422 - /** 423 - * bu21013_cs_disable() - deconfigures the touch panel controller 424 - * @bu21013_data: device structure pointer 425 - * 426 - * This function is used to deconfigure the chip selection 427 - * for touch panel controller. 428 - */ 429 - static void bu21013_cs_disable(struct bu21013_ts_data *bu21013_data) 406 + static void bu21013_disable_chip(void *_ts) 430 407 { 431 - int error; 408 + struct bu21013_ts *ts = _ts; 432 409 433 - error = gpio_direction_output(bu21013_data->chip->cs_pin, 0); 434 - if (error < 0) 435 - dev_warn(&bu21013_data->client->dev, 436 - "%s: gpio direction failed, error: %d\n", 437 - __func__, error); 438 - else 439 - gpio_set_value(bu21013_data->chip->cs_pin, 0); 440 - 441 - gpio_free(bu21013_data->chip->cs_pin); 410 + gpiod_set_value(ts->cs_gpiod, 0); 442 411 } 443 412 444 - #ifdef CONFIG_OF 445 - static const struct bu21013_platform_device * 446 - bu21013_parse_dt(struct device *dev) 447 - { 448 - struct device_node *np = dev->of_node; 449 - struct bu21013_platform_device *pdata; 450 - 451 - if (!np) { 452 - dev_err(dev, "no device tree or platform data\n"); 453 - return ERR_PTR(-EINVAL); 454 - } 455 - 456 - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); 457 - if (!pdata) 458 - return ERR_PTR(-ENOMEM); 459 - 460 - pdata->y_flip = pdata->x_flip = false; 461 - 462 - pdata->x_flip = of_property_read_bool(np, "rohm,flip-x"); 463 - pdata->y_flip = of_property_read_bool(np, "rohm,flip-y"); 464 - 465 - of_property_read_u32(np, "rohm,touch-max-x", &pdata->touch_x_max); 466 - of_property_read_u32(np, "rohm,touch-max-y", &pdata->touch_y_max); 467 - 468 - pdata->touch_pin = of_get_named_gpio(np, "touch-gpio", 0); 469 - pdata->cs_pin = of_get_named_gpio(np, "reset-gpio", 0); 470 - 471 - pdata->ext_clk = false; 472 - 473 - return pdata; 474 - } 475 - #else 476 - static inline const struct bu21013_platform_device * 477 - bu21013_parse_dt(struct device *dev) 478 - { 479 - dev_err(dev, "no platform data available\n"); 480 - return ERR_PTR(-EINVAL); 481 - } 482 - #endif 483 - 484 - /** 485 - * bu21013_probe() - initializes the i2c-client touchscreen driver 486 - * @client: i2c client structure pointer 487 - * @id: i2c device id pointer 488 - * 489 - * This function used to initializes the i2c-client touchscreen 490 - * driver and returns integer. 491 - */ 492 413 static int bu21013_probe(struct i2c_client *client, 493 414 const struct i2c_device_id *id) 494 415 { 495 - const struct bu21013_platform_device *pdata = 496 - dev_get_platdata(&client->dev); 497 - struct bu21013_ts_data *bu21013_data; 416 + struct bu21013_ts *ts; 498 417 struct input_dev *in_dev; 418 + struct input_absinfo *info; 419 + u32 max_x = 0, max_y = 0; 499 420 int error; 500 421 501 422 if (!i2c_check_functionality(client->adapter, 502 - I2C_FUNC_SMBUS_BYTE_DATA)) { 423 + I2C_FUNC_SMBUS_BYTE_DATA)) { 503 424 dev_err(&client->dev, "i2c smbus byte data not supported\n"); 504 425 return -EIO; 505 426 } 506 427 507 - if (!pdata) { 508 - pdata = bu21013_parse_dt(&client->dev); 509 - if (IS_ERR(pdata)) 510 - return PTR_ERR(pdata); 511 - } 512 - 513 - if (!gpio_is_valid(pdata->touch_pin)) { 514 - dev_err(&client->dev, "invalid touch_pin supplied\n"); 428 + if (!client->irq) { 429 + dev_err(&client->dev, "No IRQ set up\n"); 515 430 return -EINVAL; 516 431 } 517 432 518 - bu21013_data = kzalloc(sizeof(struct bu21013_ts_data), GFP_KERNEL); 519 - in_dev = input_allocate_device(); 520 - if (!bu21013_data || !in_dev) { 433 + ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); 434 + if (!ts) 435 + return -ENOMEM; 436 + 437 + ts->client = client; 438 + 439 + ts->x_flip = device_property_read_bool(&client->dev, "rohm,flip-x"); 440 + ts->y_flip = device_property_read_bool(&client->dev, "rohm,flip-y"); 441 + 442 + in_dev = devm_input_allocate_device(&client->dev); 443 + if (!in_dev) { 521 444 dev_err(&client->dev, "device memory alloc failed\n"); 522 - error = -ENOMEM; 523 - goto err_free_mem; 445 + return -ENOMEM; 524 446 } 525 - 526 - bu21013_data->in_dev = in_dev; 527 - bu21013_data->chip = pdata; 528 - bu21013_data->client = client; 529 - bu21013_data->irq = gpio_to_irq(pdata->touch_pin); 530 - 531 - bu21013_data->regulator = regulator_get(&client->dev, "avdd"); 532 - if (IS_ERR(bu21013_data->regulator)) { 533 - dev_err(&client->dev, "regulator_get failed\n"); 534 - error = PTR_ERR(bu21013_data->regulator); 535 - goto err_free_mem; 536 - } 537 - 538 - error = regulator_enable(bu21013_data->regulator); 539 - if (error < 0) { 540 - dev_err(&client->dev, "regulator enable failed\n"); 541 - goto err_put_regulator; 542 - } 543 - 544 - bu21013_data->touch_stopped = false; 545 - init_waitqueue_head(&bu21013_data->wait); 546 - 547 - /* configure the gpio pins */ 548 - error = gpio_request_one(pdata->cs_pin, GPIOF_OUT_INIT_HIGH, 549 - "touchp_reset"); 550 - if (error < 0) { 551 - dev_err(&client->dev, "Unable to request gpio reset_pin\n"); 552 - goto err_disable_regulator; 553 - } 554 - 555 - /* configure the touch panel controller */ 556 - error = bu21013_init_chip(bu21013_data); 557 - if (error) { 558 - dev_err(&client->dev, "error in bu21013 config\n"); 559 - goto err_cs_disable; 560 - } 447 + ts->in_dev = in_dev; 448 + input_set_drvdata(in_dev, ts); 561 449 562 450 /* register the device to input subsystem */ 563 451 in_dev->name = DRIVER_TP; 564 452 in_dev->id.bustype = BUS_I2C; 565 - in_dev->dev.parent = &client->dev; 566 453 567 - __set_bit(EV_SYN, in_dev->evbit); 568 - __set_bit(EV_KEY, in_dev->evbit); 569 - __set_bit(EV_ABS, in_dev->evbit); 454 + device_property_read_u32(&client->dev, "rohm,touch-max-x", &max_x); 455 + device_property_read_u32(&client->dev, "rohm,touch-max-y", &max_y); 570 456 571 - input_set_abs_params(in_dev, ABS_MT_POSITION_X, 0, 572 - pdata->touch_x_max, 0, 0); 573 - input_set_abs_params(in_dev, ABS_MT_POSITION_Y, 0, 574 - pdata->touch_y_max, 0, 0); 575 - input_set_drvdata(in_dev, bu21013_data); 457 + input_set_abs_params(in_dev, ABS_MT_POSITION_X, 0, max_x, 0, 0); 458 + input_set_abs_params(in_dev, ABS_MT_POSITION_Y, 0, max_y, 0, 0); 576 459 577 - error = request_threaded_irq(bu21013_data->irq, NULL, bu21013_gpio_irq, 578 - IRQF_TRIGGER_FALLING | IRQF_SHARED | 579 - IRQF_ONESHOT, 580 - DRIVER_TP, bu21013_data); 460 + touchscreen_parse_properties(in_dev, true, &ts->props); 461 + 462 + /* Adjust for the legacy "flip" properties, if present */ 463 + if (!ts->props.invert_x && 464 + device_property_read_bool(&client->dev, "rohm,flip-x")) { 465 + info = &in_dev->absinfo[ABS_MT_POSITION_X]; 466 + info->maximum -= info->minimum; 467 + info->minimum = 0; 468 + } 469 + 470 + if (!ts->props.invert_y && 471 + device_property_read_bool(&client->dev, "rohm,flip-y")) { 472 + info = &in_dev->absinfo[ABS_MT_POSITION_Y]; 473 + info->maximum -= info->minimum; 474 + info->minimum = 0; 475 + } 476 + 477 + error = input_mt_init_slots(in_dev, MAX_FINGERS, 478 + INPUT_MT_DIRECT | INPUT_MT_TRACK | 479 + INPUT_MT_DROP_UNUSED); 480 + if (error) { 481 + dev_err(&client->dev, "failed to initialize MT slots"); 482 + return error; 483 + } 484 + 485 + ts->regulator = devm_regulator_get(&client->dev, "avdd"); 486 + if (IS_ERR(ts->regulator)) { 487 + dev_err(&client->dev, "regulator_get failed\n"); 488 + return PTR_ERR(ts->regulator); 489 + } 490 + 491 + error = regulator_enable(ts->regulator); 492 + if (error) { 493 + dev_err(&client->dev, "regulator enable failed\n"); 494 + return error; 495 + } 496 + 497 + error = devm_add_action_or_reset(&client->dev, bu21013_power_off, ts); 498 + if (error) { 499 + dev_err(&client->dev, "failed to install power off handler\n"); 500 + return error; 501 + } 502 + 503 + /* Named "CS" on the chip, DT binding is "reset" */ 504 + ts->cs_gpiod = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH); 505 + error = PTR_ERR_OR_ZERO(ts->cs_gpiod); 506 + if (error) { 507 + if (error != -EPROBE_DEFER) 508 + dev_err(&client->dev, "failed to get CS GPIO\n"); 509 + return error; 510 + } 511 + gpiod_set_consumer_name(ts->cs_gpiod, "BU21013 CS"); 512 + 513 + error = devm_add_action_or_reset(&client->dev, 514 + bu21013_disable_chip, ts); 515 + if (error) { 516 + dev_err(&client->dev, 517 + "failed to install chip disable handler\n"); 518 + return error; 519 + } 520 + 521 + /* Named "INT" on the chip, DT binding is "touch" */ 522 + ts->int_gpiod = devm_gpiod_get_optional(&client->dev, 523 + "touch", GPIOD_IN); 524 + error = PTR_ERR_OR_ZERO(ts->int_gpiod); 525 + if (error) { 526 + if (error != -EPROBE_DEFER) 527 + dev_err(&client->dev, "failed to get INT GPIO\n"); 528 + return error; 529 + } 530 + 531 + if (ts->int_gpiod) 532 + gpiod_set_consumer_name(ts->int_gpiod, "BU21013 INT"); 533 + 534 + /* configure the touch panel controller */ 535 + error = bu21013_init_chip(ts); 536 + if (error) { 537 + dev_err(&client->dev, "error in bu21013 config\n"); 538 + return error; 539 + } 540 + 541 + error = devm_request_threaded_irq(&client->dev, client->irq, 542 + NULL, bu21013_gpio_irq, 543 + IRQF_ONESHOT, DRIVER_TP, ts); 581 544 if (error) { 582 545 dev_err(&client->dev, "request irq %d failed\n", 583 - bu21013_data->irq); 584 - goto err_cs_disable; 546 + client->irq); 547 + return error; 585 548 } 586 549 587 550 error = input_register_device(in_dev); 588 551 if (error) { 589 552 dev_err(&client->dev, "failed to register input device\n"); 590 - goto err_free_irq; 553 + return error; 591 554 } 592 555 593 - device_init_wakeup(&client->dev, pdata->wakeup); 594 - i2c_set_clientdata(client, bu21013_data); 556 + i2c_set_clientdata(client, ts); 595 557 596 558 return 0; 597 - 598 - err_free_irq: 599 - bu21013_free_irq(bu21013_data); 600 - err_cs_disable: 601 - bu21013_cs_disable(bu21013_data); 602 - err_disable_regulator: 603 - regulator_disable(bu21013_data->regulator); 604 - err_put_regulator: 605 - regulator_put(bu21013_data->regulator); 606 - err_free_mem: 607 - input_free_device(in_dev); 608 - kfree(bu21013_data); 609 - 610 - return error; 611 559 } 612 - /** 613 - * bu21013_remove() - removes the i2c-client touchscreen driver 614 - * @client: i2c client structure pointer 615 - * 616 - * This function uses to remove the i2c-client 617 - * touchscreen driver and returns integer. 618 - */ 560 + 619 561 static int bu21013_remove(struct i2c_client *client) 620 562 { 621 - struct bu21013_ts_data *bu21013_data = i2c_get_clientdata(client); 563 + struct bu21013_ts *ts = i2c_get_clientdata(client); 622 564 623 - bu21013_free_irq(bu21013_data); 624 - 625 - bu21013_cs_disable(bu21013_data); 626 - 627 - input_unregister_device(bu21013_data->in_dev); 628 - 629 - regulator_disable(bu21013_data->regulator); 630 - regulator_put(bu21013_data->regulator); 631 - 632 - kfree(bu21013_data); 565 + /* Make sure IRQ will exit quickly even if there is contact */ 566 + ts->touch_stopped = true; 567 + /* The resources will be freed by devm */ 633 568 634 569 return 0; 635 570 } 636 571 637 - #ifdef CONFIG_PM 638 - /** 639 - * bu21013_suspend() - suspend the touch screen controller 640 - * @dev: pointer to device structure 641 - * 642 - * This function is used to suspend the 643 - * touch panel controller and returns integer 644 - */ 645 - static int bu21013_suspend(struct device *dev) 572 + static int __maybe_unused bu21013_suspend(struct device *dev) 646 573 { 647 - struct bu21013_ts_data *bu21013_data = dev_get_drvdata(dev); 648 - struct i2c_client *client = bu21013_data->client; 574 + struct i2c_client *client = to_i2c_client(dev); 575 + struct bu21013_ts *ts = i2c_get_clientdata(client); 649 576 650 - bu21013_data->touch_stopped = true; 651 - if (device_may_wakeup(&client->dev)) 652 - enable_irq_wake(bu21013_data->irq); 653 - else 654 - disable_irq(bu21013_data->irq); 577 + ts->touch_stopped = true; 578 + mb(); 579 + disable_irq(client->irq); 655 580 656 - regulator_disable(bu21013_data->regulator); 581 + if (!device_may_wakeup(&client->dev)) 582 + regulator_disable(ts->regulator); 657 583 658 584 return 0; 659 585 } 660 586 661 - /** 662 - * bu21013_resume() - resume the touch screen controller 663 - * @dev: pointer to device structure 664 - * 665 - * This function is used to resume the touch panel 666 - * controller and returns integer. 667 - */ 668 - static int bu21013_resume(struct device *dev) 587 + static int __maybe_unused bu21013_resume(struct device *dev) 669 588 { 670 - struct bu21013_ts_data *bu21013_data = dev_get_drvdata(dev); 671 - struct i2c_client *client = bu21013_data->client; 672 - int retval; 589 + struct i2c_client *client = to_i2c_client(dev); 590 + struct bu21013_ts *ts = i2c_get_clientdata(client); 591 + int error; 673 592 674 - retval = regulator_enable(bu21013_data->regulator); 675 - if (retval < 0) { 676 - dev_err(&client->dev, "bu21013 regulator enable failed\n"); 677 - return retval; 593 + if (!device_may_wakeup(&client->dev)) { 594 + error = regulator_enable(ts->regulator); 595 + if (error) { 596 + dev_err(&client->dev, 597 + "failed to re-enable regulator when resuming\n"); 598 + return error; 599 + } 600 + 601 + error = bu21013_init_chip(ts); 602 + if (error) { 603 + dev_err(&client->dev, 604 + "failed to reinitialize chip when resuming\n"); 605 + return error; 606 + } 678 607 } 679 608 680 - retval = bu21013_init_chip(bu21013_data); 681 - if (retval < 0) { 682 - dev_err(&client->dev, "bu21013 controller config failed\n"); 683 - return retval; 684 - } 685 - 686 - bu21013_data->touch_stopped = false; 687 - 688 - if (device_may_wakeup(&client->dev)) 689 - disable_irq_wake(bu21013_data->irq); 690 - else 691 - enable_irq(bu21013_data->irq); 609 + ts->touch_stopped = false; 610 + mb(); 611 + enable_irq(client->irq); 692 612 693 613 return 0; 694 614 } 695 615 696 - static const struct dev_pm_ops bu21013_dev_pm_ops = { 697 - .suspend = bu21013_suspend, 698 - .resume = bu21013_resume, 699 - }; 700 - #endif 616 + static SIMPLE_DEV_PM_OPS(bu21013_dev_pm_ops, bu21013_suspend, bu21013_resume); 701 617 702 618 static const struct i2c_device_id bu21013_id[] = { 703 619 { DRIVER_TP, 0 }, ··· 618 714 static struct i2c_driver bu21013_driver = { 619 715 .driver = { 620 716 .name = DRIVER_TP, 621 - #ifdef CONFIG_PM 622 717 .pm = &bu21013_dev_pm_ops, 623 - #endif 624 718 }, 625 719 .probe = bu21013_probe, 626 720 .remove = bu21013_remove,
-2
drivers/input/touchscreen/edt-ft5x06.c
··· 764 764 const char *debugfs_name) 765 765 { 766 766 tsdata->debug_dir = debugfs_create_dir(debugfs_name, NULL); 767 - if (!tsdata->debug_dir) 768 - return; 769 767 770 768 debugfs_create_u16("num_x", S_IRUSR, tsdata->debug_dir, &tsdata->num_x); 771 769 debugfs_create_u16("num_y", S_IRUSR, tsdata->debug_dir, &tsdata->num_y);
+2 -6
drivers/input/touchscreen/fsl-imx25-tcq.c
··· 503 503 struct input_dev *idev; 504 504 struct mx25_tcq_priv *priv; 505 505 struct mx25_tsadc *tsadc = dev_get_drvdata(dev->parent); 506 - struct resource *res; 507 506 void __iomem *mem; 508 507 int error; 509 508 ··· 511 512 return -ENOMEM; 512 513 priv->dev = dev; 513 514 514 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 515 - mem = devm_ioremap_resource(dev, res); 515 + mem = devm_platform_ioremap_resource(pdev, 0); 516 516 if (IS_ERR(mem)) 517 517 return PTR_ERR(mem); 518 518 ··· 526 528 } 527 529 528 530 priv->irq = platform_get_irq(pdev, 0); 529 - if (priv->irq <= 0) { 530 - dev_err(dev, "Failed to get IRQ\n"); 531 + if (priv->irq <= 0) 531 532 return priv->irq; 532 - } 533 533 534 534 idev = devm_input_allocate_device(dev); 535 535 if (!idev) {
+1 -2
drivers/input/touchscreen/hideep.c
··· 811 811 if (error) 812 812 return error; 813 813 814 - ts->key_num = device_property_read_u32_array(dev, "linux,keycodes", 815 - NULL, 0); 814 + ts->key_num = device_property_count_u32(dev, "linux,keycodes"); 816 815 if (ts->key_num > HIDEEP_KEY_MAX) { 817 816 dev_err(dev, "too many keys defined: %d\n", 818 817 ts->key_num);
+2 -6
drivers/input/touchscreen/imx6ul_tsc.c
··· 430 430 } 431 431 432 432 tsc_irq = platform_get_irq(pdev, 0); 433 - if (tsc_irq < 0) { 434 - dev_err(&pdev->dev, "no tsc irq resource?\n"); 433 + if (tsc_irq < 0) 435 434 return tsc_irq; 436 - } 437 435 438 436 adc_irq = platform_get_irq(pdev, 1); 439 - if (adc_irq < 0) { 440 - dev_err(&pdev->dev, "no adc irq resource?\n"); 437 + if (adc_irq < 0) 441 438 return adc_irq; 442 - } 443 439 444 440 err = devm_request_threaded_irq(tsc->dev, tsc_irq, 445 441 NULL, tsc_irq_fn, IRQF_ONESHOT,
+1 -3
drivers/input/touchscreen/lpc32xx_ts.c
··· 212 212 } 213 213 214 214 irq = platform_get_irq(pdev, 0); 215 - if (irq < 0) { 216 - dev_err(&pdev->dev, "Can't get interrupt resource\n"); 215 + if (irq < 0) 217 216 return irq; 218 - } 219 217 220 218 tsc = kzalloc(sizeof(*tsc), GFP_KERNEL); 221 219 input = input_allocate_device();
+3 -7
drivers/input/touchscreen/mxs-lradc-ts.c
··· 606 606 struct device_node *node = dev->parent->of_node; 607 607 struct mxs_lradc *lradc = dev_get_drvdata(dev->parent); 608 608 struct mxs_lradc_ts *ts; 609 - struct resource *iores; 610 609 int ret, irq, virq, i; 611 610 u32 ts_wires = 0, adapt; 612 611 ··· 619 620 ts->dev = dev; 620 621 spin_lock_init(&ts->lock); 621 622 622 - iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); 623 - if (!iores) 624 - return -EINVAL; 625 - ts->base = devm_ioremap(dev, iores->start, resource_size(iores)); 626 - if (!ts->base) 627 - return -ENOMEM; 623 + ts->base = devm_platform_ioremap_resource(pdev, 0); 624 + if (IS_ERR(ts->base)) 625 + return PTR_ERR(ts->base); 628 626 629 627 ret = of_property_read_u32(node, "fsl,lradc-touchscreen-wires", 630 628 &ts_wires);
+1 -2
drivers/input/touchscreen/sun4i-ts.c
··· 300 300 input_set_drvdata(ts->input, ts); 301 301 } 302 302 303 - ts->base = devm_ioremap_resource(dev, 304 - platform_get_resource(pdev, IORESOURCE_MEM, 0)); 303 + ts->base = devm_platform_ioremap_resource(pdev, 0); 305 304 if (IS_ERR(ts->base)) 306 305 return PTR_ERR(ts->base); 307 306
+1 -3
drivers/input/touchscreen/ts4800-ts.c
··· 148 148 { 149 149 struct input_polled_dev *poll_dev; 150 150 struct ts4800_ts *ts; 151 - struct resource *res; 152 151 int error; 153 152 154 153 ts = devm_kzalloc(&pdev->dev, sizeof(*ts), GFP_KERNEL); ··· 158 159 if (error) 159 160 return error; 160 161 161 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 162 - ts->base = devm_ioremap_resource(&pdev->dev, res); 162 + ts->base = devm_platform_ioremap_resource(pdev, 0); 163 163 if (IS_ERR(ts->base)) 164 164 return PTR_ERR(ts->base); 165 165
-331
drivers/input/touchscreen/w90p910_ts.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only 2 - /* 3 - * Copyright (c) 2008 Nuvoton technology corporation. 4 - * 5 - * Wan ZongShun <mcuos.com@gmail.com> 6 - */ 7 - 8 - #include <linux/delay.h> 9 - #include <linux/module.h> 10 - #include <linux/platform_device.h> 11 - #include <linux/io.h> 12 - #include <linux/clk.h> 13 - #include <linux/input.h> 14 - #include <linux/interrupt.h> 15 - #include <linux/slab.h> 16 - 17 - /* ADC controller bit defines */ 18 - #define ADC_DELAY 0xf00 19 - #define ADC_DOWN 0x01 20 - #define ADC_TSC_Y (0x01 << 8) 21 - #define ADC_TSC_X (0x00 << 8) 22 - #define TSC_FOURWIRE (~(0x03 << 1)) 23 - #define ADC_CLK_EN (0x01 << 28) /* ADC clock enable */ 24 - #define ADC_READ_CON (0x01 << 12) 25 - #define ADC_CONV (0x01 << 13) 26 - #define ADC_SEMIAUTO (0x01 << 14) 27 - #define ADC_WAITTRIG (0x03 << 14) 28 - #define ADC_RST1 (0x01 << 16) 29 - #define ADC_RST0 (0x00 << 16) 30 - #define ADC_EN (0x01 << 17) 31 - #define ADC_INT (0x01 << 18) 32 - #define WT_INT (0x01 << 20) 33 - #define ADC_INT_EN (0x01 << 21) 34 - #define LVD_INT_EN (0x01 << 22) 35 - #define WT_INT_EN (0x01 << 23) 36 - #define ADC_DIV (0x04 << 1) /* div = 6 */ 37 - 38 - enum ts_state { 39 - TS_WAIT_NEW_PACKET, /* We are waiting next touch report */ 40 - TS_WAIT_X_COORD, /* We are waiting for ADC to report X coord */ 41 - TS_WAIT_Y_COORD, /* We are waiting for ADC to report Y coord */ 42 - TS_IDLE, /* Input device is closed, don't do anything */ 43 - }; 44 - 45 - struct w90p910_ts { 46 - struct input_dev *input; 47 - struct timer_list timer; 48 - struct clk *clk; 49 - int irq_num; 50 - void __iomem *ts_reg; 51 - spinlock_t lock; 52 - enum ts_state state; 53 - }; 54 - 55 - static void w90p910_report_event(struct w90p910_ts *w90p910_ts, bool down) 56 - { 57 - struct input_dev *dev = w90p910_ts->input; 58 - 59 - if (down) { 60 - input_report_abs(dev, ABS_X, 61 - __raw_readl(w90p910_ts->ts_reg + 0x0c)); 62 - input_report_abs(dev, ABS_Y, 63 - __raw_readl(w90p910_ts->ts_reg + 0x10)); 64 - } 65 - 66 - input_report_key(dev, BTN_TOUCH, down); 67 - input_sync(dev); 68 - } 69 - 70 - static void w90p910_prepare_x_reading(struct w90p910_ts *w90p910_ts) 71 - { 72 - unsigned long ctlreg; 73 - 74 - __raw_writel(ADC_TSC_X, w90p910_ts->ts_reg + 0x04); 75 - ctlreg = __raw_readl(w90p910_ts->ts_reg); 76 - ctlreg &= ~(ADC_WAITTRIG | WT_INT | WT_INT_EN); 77 - ctlreg |= ADC_SEMIAUTO | ADC_INT_EN | ADC_CONV; 78 - __raw_writel(ctlreg, w90p910_ts->ts_reg); 79 - 80 - w90p910_ts->state = TS_WAIT_X_COORD; 81 - } 82 - 83 - static void w90p910_prepare_y_reading(struct w90p910_ts *w90p910_ts) 84 - { 85 - unsigned long ctlreg; 86 - 87 - __raw_writel(ADC_TSC_Y, w90p910_ts->ts_reg + 0x04); 88 - ctlreg = __raw_readl(w90p910_ts->ts_reg); 89 - ctlreg &= ~(ADC_WAITTRIG | ADC_INT | WT_INT_EN); 90 - ctlreg |= ADC_SEMIAUTO | ADC_INT_EN | ADC_CONV; 91 - __raw_writel(ctlreg, w90p910_ts->ts_reg); 92 - 93 - w90p910_ts->state = TS_WAIT_Y_COORD; 94 - } 95 - 96 - static void w90p910_prepare_next_packet(struct w90p910_ts *w90p910_ts) 97 - { 98 - unsigned long ctlreg; 99 - 100 - ctlreg = __raw_readl(w90p910_ts->ts_reg); 101 - ctlreg &= ~(ADC_INT | ADC_INT_EN | ADC_SEMIAUTO | ADC_CONV); 102 - ctlreg |= ADC_WAITTRIG | WT_INT_EN; 103 - __raw_writel(ctlreg, w90p910_ts->ts_reg); 104 - 105 - w90p910_ts->state = TS_WAIT_NEW_PACKET; 106 - } 107 - 108 - static irqreturn_t w90p910_ts_interrupt(int irq, void *dev_id) 109 - { 110 - struct w90p910_ts *w90p910_ts = dev_id; 111 - unsigned long flags; 112 - 113 - spin_lock_irqsave(&w90p910_ts->lock, flags); 114 - 115 - switch (w90p910_ts->state) { 116 - case TS_WAIT_NEW_PACKET: 117 - /* 118 - * The controller only generates interrupts when pen 119 - * is down. 120 - */ 121 - del_timer(&w90p910_ts->timer); 122 - w90p910_prepare_x_reading(w90p910_ts); 123 - break; 124 - 125 - 126 - case TS_WAIT_X_COORD: 127 - w90p910_prepare_y_reading(w90p910_ts); 128 - break; 129 - 130 - case TS_WAIT_Y_COORD: 131 - w90p910_report_event(w90p910_ts, true); 132 - w90p910_prepare_next_packet(w90p910_ts); 133 - mod_timer(&w90p910_ts->timer, jiffies + msecs_to_jiffies(100)); 134 - break; 135 - 136 - case TS_IDLE: 137 - break; 138 - } 139 - 140 - spin_unlock_irqrestore(&w90p910_ts->lock, flags); 141 - 142 - return IRQ_HANDLED; 143 - } 144 - 145 - static void w90p910_check_pen_up(struct timer_list *t) 146 - { 147 - struct w90p910_ts *w90p910_ts = from_timer(w90p910_ts, t, timer); 148 - unsigned long flags; 149 - 150 - spin_lock_irqsave(&w90p910_ts->lock, flags); 151 - 152 - if (w90p910_ts->state == TS_WAIT_NEW_PACKET && 153 - !(__raw_readl(w90p910_ts->ts_reg + 0x04) & ADC_DOWN)) { 154 - 155 - w90p910_report_event(w90p910_ts, false); 156 - } 157 - 158 - spin_unlock_irqrestore(&w90p910_ts->lock, flags); 159 - } 160 - 161 - static int w90p910_open(struct input_dev *dev) 162 - { 163 - struct w90p910_ts *w90p910_ts = input_get_drvdata(dev); 164 - unsigned long val; 165 - 166 - /* enable the ADC clock */ 167 - clk_enable(w90p910_ts->clk); 168 - 169 - __raw_writel(ADC_RST1, w90p910_ts->ts_reg); 170 - msleep(1); 171 - __raw_writel(ADC_RST0, w90p910_ts->ts_reg); 172 - msleep(1); 173 - 174 - /* set delay and screen type */ 175 - val = __raw_readl(w90p910_ts->ts_reg + 0x04); 176 - __raw_writel(val & TSC_FOURWIRE, w90p910_ts->ts_reg + 0x04); 177 - __raw_writel(ADC_DELAY, w90p910_ts->ts_reg + 0x08); 178 - 179 - w90p910_ts->state = TS_WAIT_NEW_PACKET; 180 - wmb(); 181 - 182 - /* set trigger mode */ 183 - val = __raw_readl(w90p910_ts->ts_reg); 184 - val |= ADC_WAITTRIG | ADC_DIV | ADC_EN | WT_INT_EN; 185 - __raw_writel(val, w90p910_ts->ts_reg); 186 - 187 - return 0; 188 - } 189 - 190 - static void w90p910_close(struct input_dev *dev) 191 - { 192 - struct w90p910_ts *w90p910_ts = input_get_drvdata(dev); 193 - unsigned long val; 194 - 195 - /* disable trigger mode */ 196 - 197 - spin_lock_irq(&w90p910_ts->lock); 198 - 199 - w90p910_ts->state = TS_IDLE; 200 - 201 - val = __raw_readl(w90p910_ts->ts_reg); 202 - val &= ~(ADC_WAITTRIG | ADC_DIV | ADC_EN | WT_INT_EN | ADC_INT_EN); 203 - __raw_writel(val, w90p910_ts->ts_reg); 204 - 205 - spin_unlock_irq(&w90p910_ts->lock); 206 - 207 - /* Now that interrupts are shut off we can safely delete timer */ 208 - del_timer_sync(&w90p910_ts->timer); 209 - 210 - /* stop the ADC clock */ 211 - clk_disable(w90p910_ts->clk); 212 - } 213 - 214 - static int w90x900ts_probe(struct platform_device *pdev) 215 - { 216 - struct w90p910_ts *w90p910_ts; 217 - struct input_dev *input_dev; 218 - struct resource *res; 219 - int err; 220 - 221 - w90p910_ts = kzalloc(sizeof(struct w90p910_ts), GFP_KERNEL); 222 - input_dev = input_allocate_device(); 223 - if (!w90p910_ts || !input_dev) { 224 - err = -ENOMEM; 225 - goto fail1; 226 - } 227 - 228 - w90p910_ts->input = input_dev; 229 - w90p910_ts->state = TS_IDLE; 230 - spin_lock_init(&w90p910_ts->lock); 231 - timer_setup(&w90p910_ts->timer, w90p910_check_pen_up, 0); 232 - 233 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 234 - if (!res) { 235 - err = -ENXIO; 236 - goto fail1; 237 - } 238 - 239 - if (!request_mem_region(res->start, resource_size(res), 240 - pdev->name)) { 241 - err = -EBUSY; 242 - goto fail1; 243 - } 244 - 245 - w90p910_ts->ts_reg = ioremap(res->start, resource_size(res)); 246 - if (!w90p910_ts->ts_reg) { 247 - err = -ENOMEM; 248 - goto fail2; 249 - } 250 - 251 - w90p910_ts->clk = clk_get(&pdev->dev, NULL); 252 - if (IS_ERR(w90p910_ts->clk)) { 253 - err = PTR_ERR(w90p910_ts->clk); 254 - goto fail3; 255 - } 256 - 257 - input_dev->name = "W90P910 TouchScreen"; 258 - input_dev->phys = "w90p910ts/event0"; 259 - input_dev->id.bustype = BUS_HOST; 260 - input_dev->id.vendor = 0x0005; 261 - input_dev->id.product = 0x0001; 262 - input_dev->id.version = 0x0100; 263 - input_dev->dev.parent = &pdev->dev; 264 - input_dev->open = w90p910_open; 265 - input_dev->close = w90p910_close; 266 - 267 - input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 268 - input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); 269 - 270 - input_set_abs_params(input_dev, ABS_X, 0, 0x400, 0, 0); 271 - input_set_abs_params(input_dev, ABS_Y, 0, 0x400, 0, 0); 272 - 273 - input_set_drvdata(input_dev, w90p910_ts); 274 - 275 - w90p910_ts->irq_num = platform_get_irq(pdev, 0); 276 - if (request_irq(w90p910_ts->irq_num, w90p910_ts_interrupt, 277 - 0, "w90p910ts", w90p910_ts)) { 278 - err = -EBUSY; 279 - goto fail4; 280 - } 281 - 282 - err = input_register_device(w90p910_ts->input); 283 - if (err) 284 - goto fail5; 285 - 286 - platform_set_drvdata(pdev, w90p910_ts); 287 - 288 - return 0; 289 - 290 - fail5: free_irq(w90p910_ts->irq_num, w90p910_ts); 291 - fail4: clk_put(w90p910_ts->clk); 292 - fail3: iounmap(w90p910_ts->ts_reg); 293 - fail2: release_mem_region(res->start, resource_size(res)); 294 - fail1: input_free_device(input_dev); 295 - kfree(w90p910_ts); 296 - return err; 297 - } 298 - 299 - static int w90x900ts_remove(struct platform_device *pdev) 300 - { 301 - struct w90p910_ts *w90p910_ts = platform_get_drvdata(pdev); 302 - struct resource *res; 303 - 304 - free_irq(w90p910_ts->irq_num, w90p910_ts); 305 - del_timer_sync(&w90p910_ts->timer); 306 - iounmap(w90p910_ts->ts_reg); 307 - 308 - clk_put(w90p910_ts->clk); 309 - 310 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 311 - release_mem_region(res->start, resource_size(res)); 312 - 313 - input_unregister_device(w90p910_ts->input); 314 - kfree(w90p910_ts); 315 - 316 - return 0; 317 - } 318 - 319 - static struct platform_driver w90x900ts_driver = { 320 - .probe = w90x900ts_probe, 321 - .remove = w90x900ts_remove, 322 - .driver = { 323 - .name = "nuc900-ts", 324 - }, 325 - }; 326 - module_platform_driver(w90x900ts_driver); 327 - 328 - MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>"); 329 - MODULE_DESCRIPTION("w90p910 touch screen driver!"); 330 - MODULE_LICENSE("GPL"); 331 - MODULE_ALIAS("platform:nuc900-ts");
+3 -1
drivers/input/touchscreen/wacom_w8001.c
··· 27 27 MODULE_DESCRIPTION(DRIVER_DESC); 28 28 MODULE_LICENSE("GPL"); 29 29 30 + #define W8001_MAX_PHYS 42 31 + 30 32 #define W8001_MAX_LENGTH 13 31 33 #define W8001_LEAD_MASK 0x80 32 34 #define W8001_LEAD_BYTE 0x80 ··· 91 89 unsigned char response_type; 92 90 unsigned char response[W8001_MAX_LENGTH]; 93 91 unsigned char data[W8001_MAX_LENGTH]; 94 - char phys[32]; 92 + char phys[W8001_MAX_PHYS]; 95 93 int type; 96 94 unsigned int pktlen; 97 95 u16 max_touch_x;
+47
drivers/platform/x86/surfacepro3_button.c
··· 20 20 #define SURFACE_BUTTON_OBJ_NAME "VGBI" 21 21 #define SURFACE_BUTTON_DEVICE_NAME "Surface Pro 3/4 Buttons" 22 22 23 + #define MSHW0040_DSM_REVISION 0x01 24 + #define MSHW0040_DSM_GET_OMPR 0x02 // get OEM Platform Revision 25 + static const guid_t MSHW0040_DSM_UUID = 26 + GUID_INIT(0x6fd05c69, 0xcde3, 0x49f4, 0x95, 0xed, 0xab, 0x16, 0x65, 27 + 0x49, 0x80, 0x35); 28 + 23 29 #define SURFACE_BUTTON_NOTIFY_TABLET_MODE 0xc8 24 30 25 31 #define SURFACE_BUTTON_NOTIFY_PRESS_POWER 0xc6 ··· 148 142 } 149 143 #endif 150 144 145 + /* 146 + * Surface Pro 4 and Surface Book 2 / Surface Pro 2017 use the same device 147 + * ID (MSHW0040) for the power/volume buttons. Make sure this is the right 148 + * device by checking for the _DSM method and OEM Platform Revision. 149 + * 150 + * Returns true if the driver should bind to this device, i.e. the device is 151 + * either MSWH0028 (Pro 3) or MSHW0040 on a Pro 4 or Book 1. 152 + */ 153 + static bool surface_button_check_MSHW0040(struct acpi_device *dev) 154 + { 155 + acpi_handle handle = dev->handle; 156 + union acpi_object *result; 157 + u64 oem_platform_rev = 0; // valid revisions are nonzero 158 + 159 + // get OEM platform revision 160 + result = acpi_evaluate_dsm_typed(handle, &MSHW0040_DSM_UUID, 161 + MSHW0040_DSM_REVISION, 162 + MSHW0040_DSM_GET_OMPR, 163 + NULL, ACPI_TYPE_INTEGER); 164 + 165 + /* 166 + * If evaluating the _DSM fails, the method is not present. This means 167 + * that we have either MSHW0028 or MSHW0040 on Pro 4 or Book 1, so we 168 + * should use this driver. We use revision 0 indicating it is 169 + * unavailable. 170 + */ 171 + 172 + if (result) { 173 + oem_platform_rev = result->integer.value; 174 + ACPI_FREE(result); 175 + } 176 + 177 + dev_dbg(&dev->dev, "OEM Platform Revision %llu\n", oem_platform_rev); 178 + 179 + return oem_platform_rev == 0; 180 + } 181 + 182 + 151 183 static int surface_button_add(struct acpi_device *device) 152 184 { 153 185 struct surface_button *button; ··· 196 152 197 153 if (strncmp(acpi_device_bid(device), SURFACE_BUTTON_OBJ_NAME, 198 154 strlen(SURFACE_BUTTON_OBJ_NAME))) 155 + return -ENODEV; 156 + 157 + if (!surface_button_check_MSHW0040(device)) 199 158 return -ENODEV; 200 159 201 160 button = kzalloc(sizeof(struct surface_button), GFP_KERNEL);
+26
include/linux/input.h
··· 21 21 #include <linux/timer.h> 22 22 #include <linux/mod_devicetable.h> 23 23 24 + struct input_dev_poller; 25 + 24 26 /** 25 27 * struct input_value - input value representation 26 28 * @type: type of value (EV_KEY, EV_ABS, etc) ··· 33 31 __u16 type; 34 32 __u16 code; 35 33 __s32 value; 34 + }; 35 + 36 + enum input_clock_type { 37 + INPUT_CLK_REAL = 0, 38 + INPUT_CLK_MONO, 39 + INPUT_CLK_BOOT, 40 + INPUT_CLK_MAX 36 41 }; 37 42 38 43 /** ··· 73 64 * not sleep 74 65 * @ff: force feedback structure associated with the device if device 75 66 * supports force feedback effects 67 + * @poller: poller structure associated with the device if device is 68 + * set up to use polling mode 76 69 * @repeat_key: stores key code of the last key pressed; used to implement 77 70 * software autorepeat 78 71 * @timer: timer for software autorepeat ··· 125 114 * @vals: array of values queued in the current frame 126 115 * @devres_managed: indicates that devices is managed with devres framework 127 116 * and needs not be explicitly unregistered or freed. 117 + * @timestamp: storage for a timestamp set by input_set_timestamp called 118 + * by a driver 128 119 */ 129 120 struct input_dev { 130 121 const char *name; ··· 159 146 struct input_keymap_entry *ke); 160 147 161 148 struct ff_device *ff; 149 + 150 + struct input_dev_poller *poller; 162 151 163 152 unsigned int repeat_key; 164 153 struct timer_list timer; ··· 199 184 struct input_value *vals; 200 185 201 186 bool devres_managed; 187 + 188 + ktime_t timestamp[INPUT_CLK_MAX]; 202 189 }; 203 190 #define to_input_dev(d) container_of(d, struct input_dev, dev) 204 191 ··· 378 361 379 362 void input_reset_device(struct input_dev *); 380 363 364 + int input_setup_polling(struct input_dev *dev, 365 + void (*poll_fn)(struct input_dev *dev)); 366 + void input_set_poll_interval(struct input_dev *dev, unsigned int interval); 367 + void input_set_min_poll_interval(struct input_dev *dev, unsigned int interval); 368 + void input_set_max_poll_interval(struct input_dev *dev, unsigned int interval); 369 + 381 370 int __must_check input_register_handler(struct input_handler *); 382 371 void input_unregister_handler(struct input_handler *); 383 372 ··· 404 381 void input_close_device(struct input_handle *); 405 382 406 383 int input_flush_device(struct input_handle *handle, struct file *file); 384 + 385 + void input_set_timestamp(struct input_dev *dev, ktime_t timestamp); 386 + ktime_t *input_get_timestamp(struct input_dev *dev); 407 387 408 388 void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value); 409 389 void input_inject_event(struct input_handle *handle, unsigned int type, unsigned int code, int value);
-34
include/linux/input/bu21013.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-only */ 2 - /* 3 - * Copyright (C) ST-Ericsson SA 2010 4 - * Author: Naveen Kumar G <naveen.gaddipati@stericsson.com> for ST-Ericsson 5 - */ 6 - 7 - #ifndef _BU21013_H 8 - #define _BU21013_H 9 - 10 - /** 11 - * struct bu21013_platform_device - Handle the platform data 12 - * @touch_x_max: touch x max 13 - * @touch_y_max: touch y max 14 - * @cs_pin: chip select pin 15 - * @touch_pin: touch gpio pin 16 - * @ext_clk: external clock flag 17 - * @x_flip: x flip flag 18 - * @y_flip: y flip flag 19 - * @wakeup: wakeup flag 20 - * 21 - * This is used to handle the platform data 22 - */ 23 - struct bu21013_platform_device { 24 - int touch_x_max; 25 - int touch_y_max; 26 - unsigned int cs_pin; 27 - unsigned int touch_pin; 28 - bool ext_clk; 29 - bool x_flip; 30 - bool y_flip; 31 - bool wakeup; 32 - }; 33 - 34 - #endif
-16
include/linux/platform_data/keypad-w90p910.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef __ASM_ARCH_W90P910_KEYPAD_H 3 - #define __ASM_ARCH_W90P910_KEYPAD_H 4 - 5 - #include <linux/input/matrix_keypad.h> 6 - 7 - extern void mfp_set_groupi(struct device *dev); 8 - 9 - struct w90p910_keypad_platform_data { 10 - const struct matrix_keymap_data *keymap_data; 11 - 12 - unsigned int prescale; 13 - unsigned int debounce; 14 - }; 15 - 16 - #endif /* __ASM_ARCH_W90P910_KEYPAD_H */
+1
include/uapi/linux/serio.h
··· 82 82 #define SERIO_EGALAX 0x3f 83 83 #define SERIO_PULSE8_CEC 0x40 84 84 #define SERIO_RAINSHADOW_CEC 0x41 85 + #define SERIO_FSIA6B 0x42 85 86 86 87 #endif /* _UAPI_SERIO_H */