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:
"Mostly existing driver fixes plus a new driver for game controllers
directly connected to Nintendo 64, and an enhancement for keyboards
driven by Chrome OS EC to communicate layout of the top row to
userspace"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (47 commits)
Input: st1232 - fix NORMAL vs. IDLE state handling
Input: aiptek - convert sysfs sprintf/snprintf family to sysfs_emit
Input: alps - fix spelling of "positive"
ARM: dts: cros-ec-keyboard: Use keymap macros
dt-bindings: input: Fix the keymap for LOCK key
dt-bindings: input: Create macros for cros-ec keymap
Input: cros-ec-keyb - expose function row physical map to userspace
dt-bindings: input: cros-ec-keyb: Add a new property describing top row
Input: applespi - fix occasional crc errors under load.
Input: applespi - don't wait for responses to commands indefinitely.
Input: st1232 - add IDLE state as ready condition
Input: zinitix - fix return type of zinitix_init_touch()
Input: i8042 - add ASUS Zenbook Flip to noselftest list
Input: add missing dependencies on CONFIG_HAS_IOMEM
Input: joydev - prevent potential read overflow in ioctl
Input: elo - fix an error code in elo_connect()
Input: xpad - add support for PowerA Enhanced Wired Controller for Xbox Series X|S
Input: sur40 - fix an error code in sur40_probe()
Input: elants_i2c - detect enum overflow
Input: zinitix - remove unneeded semicolon
...

+1265 -608
+6
Documentation/ABI/testing/sysfs-driver-input-cros-ec-keyb
··· 1 + What: /sys/class/input/input(x)/device/function_row_physmap 2 + Date: January 2021 3 + Contact: Philip Chen <philipchen@chromium.org> 4 + Description: A space separated list of scancodes for the top row keys, 5 + ordered by the physical positions of the keys, from left 6 + to right.
+24
Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
··· 31 31 if the EC does not have its own logic or hardware for this. 32 32 type: boolean 33 33 34 + function-row-physmap: 35 + minItems: 1 36 + maxItems: 15 37 + description: | 38 + An ordered u32 array describing the rows/columns (in the scan matrix) 39 + of top row keys from physical left (KEY_F1) to right. Each entry 40 + encodes the row/column as: 41 + (((row) & 0xFF) << 24) | (((column) & 0xFF) << 16) 42 + where the lower 16 bits are reserved. This property is specified only 43 + when the keyboard has a custom design for the top row keys. 44 + 34 45 required: 35 46 - compatible 36 47 ··· 49 38 50 39 examples: 51 40 - | 41 + #include <dt-bindings/input/input.h> 52 42 cros-ec-keyb { 53 43 compatible = "google,cros-ec-keyb"; 54 44 keypad,num-rows = <8>; 55 45 keypad,num-columns = <13>; 56 46 google,needs-ghost-filter; 47 + function-row-physmap = < 48 + MATRIX_KEY(0x00, 0x02, 0) /* T1 */ 49 + MATRIX_KEY(0x03, 0x02, 0) /* T2 */ 50 + MATRIX_KEY(0x02, 0x02, 0) /* T3 */ 51 + MATRIX_KEY(0x01, 0x02, 0) /* T4 */ 52 + MATRIX_KEY(0x03, 0x04, 0) /* T5 */ 53 + MATRIX_KEY(0x02, 0x04, 0) /* T6 */ 54 + MATRIX_KEY(0x01, 0x04, 0) /* T7 */ 55 + MATRIX_KEY(0x02, 0x09, 0) /* T8 */ 56 + MATRIX_KEY(0x01, 0x09, 0) /* T9 */ 57 + MATRIX_KEY(0x00, 0x04, 0) /* T10 */ 58 + >; 57 59 /* 58 60 * Keymap entries take the form of 0xRRCCKKKK where 59 61 * RR=Row CC=Column KKKK=Key Code
+4 -89
arch/arm/boot/dts/cros-ec-keyboard.dtsi
··· 6 6 */ 7 7 8 8 #include <dt-bindings/input/input.h> 9 + #include <dt-bindings/input/cros-ec-keyboard.h> 9 10 10 11 &cros_ec { 11 - keyboard-controller { 12 + keyboard_controller: keyboard-controller { 12 13 compatible = "google,cros-ec-keyb"; 13 14 keypad,num-rows = <8>; 14 15 keypad,num-columns = <13>; 15 16 google,needs-ghost-filter; 16 17 17 18 linux,keymap = < 18 - MATRIX_KEY(0x00, 0x01, KEY_LEFTMETA) 19 - MATRIX_KEY(0x00, 0x02, KEY_F1) 20 - MATRIX_KEY(0x00, 0x03, KEY_B) 21 - MATRIX_KEY(0x00, 0x04, KEY_F10) 22 - MATRIX_KEY(0x00, 0x05, KEY_RO) 23 - MATRIX_KEY(0x00, 0x06, KEY_N) 24 - MATRIX_KEY(0x00, 0x08, KEY_EQUAL) 25 - MATRIX_KEY(0x00, 0x0a, KEY_RIGHTALT) 26 - 27 - MATRIX_KEY(0x01, 0x01, KEY_ESC) 28 - MATRIX_KEY(0x01, 0x02, KEY_F4) 29 - MATRIX_KEY(0x01, 0x03, KEY_G) 30 - MATRIX_KEY(0x01, 0x04, KEY_F7) 31 - MATRIX_KEY(0x01, 0x06, KEY_H) 32 - MATRIX_KEY(0x01, 0x08, KEY_APOSTROPHE) 33 - MATRIX_KEY(0x01, 0x09, KEY_F9) 34 - MATRIX_KEY(0x01, 0x0b, KEY_BACKSPACE) 35 - MATRIX_KEY(0x01, 0x0c, KEY_HENKAN) 36 - 37 - MATRIX_KEY(0x02, 0x00, KEY_LEFTCTRL) 38 - MATRIX_KEY(0x02, 0x01, KEY_TAB) 39 - MATRIX_KEY(0x02, 0x02, KEY_F3) 40 - MATRIX_KEY(0x02, 0x03, KEY_T) 41 - MATRIX_KEY(0x02, 0x04, KEY_F6) 42 - MATRIX_KEY(0x02, 0x05, KEY_RIGHTBRACE) 43 - MATRIX_KEY(0x02, 0x06, KEY_Y) 44 - MATRIX_KEY(0x02, 0x07, KEY_102ND) 45 - MATRIX_KEY(0x02, 0x08, KEY_LEFTBRACE) 46 - MATRIX_KEY(0x02, 0x09, KEY_F8) 47 - MATRIX_KEY(0x02, 0x0a, KEY_YEN) 48 - 49 - MATRIX_KEY(0x03, 0x00, KEY_LEFTMETA) 50 - MATRIX_KEY(0x03, 0x01, KEY_GRAVE) 51 - MATRIX_KEY(0x03, 0x02, KEY_F2) 52 - MATRIX_KEY(0x03, 0x03, KEY_5) 53 - MATRIX_KEY(0x03, 0x04, KEY_F5) 54 - MATRIX_KEY(0x03, 0x06, KEY_6) 55 - MATRIX_KEY(0x03, 0x08, KEY_MINUS) 56 - MATRIX_KEY(0x03, 0x09, KEY_F13) 57 - MATRIX_KEY(0x03, 0x0b, KEY_BACKSLASH) 58 - MATRIX_KEY(0x03, 0x0c, KEY_MUHENKAN) 59 - 60 - MATRIX_KEY(0x04, 0x00, KEY_RIGHTCTRL) 61 - MATRIX_KEY(0x04, 0x01, KEY_A) 62 - MATRIX_KEY(0x04, 0x02, KEY_D) 63 - MATRIX_KEY(0x04, 0x03, KEY_F) 64 - MATRIX_KEY(0x04, 0x04, KEY_S) 65 - MATRIX_KEY(0x04, 0x05, KEY_K) 66 - MATRIX_KEY(0x04, 0x06, KEY_J) 67 - MATRIX_KEY(0x04, 0x08, KEY_SEMICOLON) 68 - MATRIX_KEY(0x04, 0x09, KEY_L) 69 - MATRIX_KEY(0x04, 0x0a, KEY_BACKSLASH) 70 - MATRIX_KEY(0x04, 0x0b, KEY_ENTER) 71 - 72 - MATRIX_KEY(0x05, 0x01, KEY_Z) 73 - MATRIX_KEY(0x05, 0x02, KEY_C) 74 - MATRIX_KEY(0x05, 0x03, KEY_V) 75 - MATRIX_KEY(0x05, 0x04, KEY_X) 76 - MATRIX_KEY(0x05, 0x05, KEY_COMMA) 77 - MATRIX_KEY(0x05, 0x06, KEY_M) 78 - MATRIX_KEY(0x05, 0x07, KEY_LEFTSHIFT) 79 - MATRIX_KEY(0x05, 0x08, KEY_SLASH) 80 - MATRIX_KEY(0x05, 0x09, KEY_DOT) 81 - MATRIX_KEY(0x05, 0x0b, KEY_SPACE) 82 - 83 - MATRIX_KEY(0x06, 0x01, KEY_1) 84 - MATRIX_KEY(0x06, 0x02, KEY_3) 85 - MATRIX_KEY(0x06, 0x03, KEY_4) 86 - MATRIX_KEY(0x06, 0x04, KEY_2) 87 - MATRIX_KEY(0x06, 0x05, KEY_8) 88 - MATRIX_KEY(0x06, 0x06, KEY_7) 89 - MATRIX_KEY(0x06, 0x08, KEY_0) 90 - MATRIX_KEY(0x06, 0x09, KEY_9) 91 - MATRIX_KEY(0x06, 0x0a, KEY_LEFTALT) 92 - MATRIX_KEY(0x06, 0x0b, KEY_DOWN) 93 - MATRIX_KEY(0x06, 0x0c, KEY_RIGHT) 94 - 95 - MATRIX_KEY(0x07, 0x01, KEY_Q) 96 - MATRIX_KEY(0x07, 0x02, KEY_E) 97 - MATRIX_KEY(0x07, 0x03, KEY_R) 98 - MATRIX_KEY(0x07, 0x04, KEY_W) 99 - MATRIX_KEY(0x07, 0x05, KEY_I) 100 - MATRIX_KEY(0x07, 0x06, KEY_U) 101 - MATRIX_KEY(0x07, 0x07, KEY_RIGHTSHIFT) 102 - MATRIX_KEY(0x07, 0x08, KEY_P) 103 - MATRIX_KEY(0x07, 0x09, KEY_O) 104 - MATRIX_KEY(0x07, 0x0b, KEY_UP) 105 - MATRIX_KEY(0x07, 0x0c, KEY_LEFT) 19 + CROS_STD_TOP_ROW_KEYMAP 20 + CROS_STD_MAIN_KEYMAP 106 21 >; 107 22 }; 108 23 };
+5 -2
drivers/input/joydev.c
··· 456 456 if (IS_ERR(abspam)) 457 457 return PTR_ERR(abspam); 458 458 459 - for (i = 0; i < joydev->nabs; i++) { 459 + for (i = 0; i < len && i < joydev->nabs; i++) { 460 460 if (abspam[i] > ABS_MAX) { 461 461 retval = -EINVAL; 462 462 goto out; ··· 480 480 int i; 481 481 int retval = 0; 482 482 483 + if (len % sizeof(*keypam)) 484 + return -EINVAL; 485 + 483 486 len = min(len, sizeof(joydev->keypam)); 484 487 485 488 /* Validate the map. */ ··· 490 487 if (IS_ERR(keypam)) 491 488 return PTR_ERR(keypam); 492 489 493 - for (i = 0; i < joydev->nkey; i++) { 490 + for (i = 0; i < (len / 2) && i < joydev->nkey; i++) { 494 491 if (keypam[i] > KEY_MAX || keypam[i] < BTN_MISC) { 495 492 retval = -EINVAL; 496 493 goto out;
+7
drivers/input/joystick/Kconfig
··· 382 382 To compile this driver as a module, choose M here: the 383 383 module will be called fsia6b. 384 384 385 + config JOYSTICK_N64 386 + bool "N64 controller" 387 + depends on MACH_NINTENDO64 388 + help 389 + Say Y here if you want enable support for the four 390 + built-in controller ports on the Nintendo 64 console. 391 + 385 392 endif
+1 -1
drivers/input/joystick/Makefile
··· 24 24 obj-$(CONFIG_JOYSTICK_JOYDUMP) += joydump.o 25 25 obj-$(CONFIG_JOYSTICK_MAGELLAN) += magellan.o 26 26 obj-$(CONFIG_JOYSTICK_MAPLE) += maplecontrol.o 27 + obj-$(CONFIG_JOYSTICK_N64) += n64joy.o 27 28 obj-$(CONFIG_JOYSTICK_PSXPAD_SPI) += psxpad-spi.o 28 29 obj-$(CONFIG_JOYSTICK_PXRC) += pxrc.o 29 30 obj-$(CONFIG_JOYSTICK_SIDEWINDER) += sidewinder.o ··· 38 37 obj-$(CONFIG_JOYSTICK_WALKERA0701) += walkera0701.o 39 38 obj-$(CONFIG_JOYSTICK_XPAD) += xpad.o 40 39 obj-$(CONFIG_JOYSTICK_ZHENHUA) += zhenhua.o 41 -
+345
drivers/input/joystick/n64joy.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Support for the four N64 controllers. 4 + * 5 + * Copyright (c) 2021 Lauri Kasanen 6 + */ 7 + 8 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 9 + 10 + #include <linux/errno.h> 11 + #include <linux/init.h> 12 + #include <linux/input.h> 13 + #include <linux/limits.h> 14 + #include <linux/kernel.h> 15 + #include <linux/module.h> 16 + #include <linux/mutex.h> 17 + #include <linux/platform_device.h> 18 + #include <linux/slab.h> 19 + #include <linux/timer.h> 20 + 21 + MODULE_AUTHOR("Lauri Kasanen <cand@gmx.com>"); 22 + MODULE_DESCRIPTION("Driver for N64 controllers"); 23 + MODULE_LICENSE("GPL"); 24 + 25 + #define PIF_RAM 0x1fc007c0 26 + 27 + #define SI_DRAM_REG 0 28 + #define SI_READ_REG 1 29 + #define SI_WRITE_REG 4 30 + #define SI_STATUS_REG 6 31 + 32 + #define SI_STATUS_DMA_BUSY BIT(0) 33 + #define SI_STATUS_IO_BUSY BIT(1) 34 + 35 + #define N64_CONTROLLER_ID 0x0500 36 + 37 + #define MAX_CONTROLLERS 4 38 + 39 + static const char *n64joy_phys[MAX_CONTROLLERS] = { 40 + "n64joy/port0", 41 + "n64joy/port1", 42 + "n64joy/port2", 43 + "n64joy/port3", 44 + }; 45 + 46 + struct n64joy_priv { 47 + u64 si_buf[8] ____cacheline_aligned; 48 + struct timer_list timer; 49 + struct mutex n64joy_mutex; 50 + struct input_dev *n64joy_dev[MAX_CONTROLLERS]; 51 + u32 __iomem *reg_base; 52 + u8 n64joy_opened; 53 + }; 54 + 55 + struct joydata { 56 + unsigned int: 16; /* unused */ 57 + unsigned int err: 2; 58 + unsigned int: 14; /* unused */ 59 + 60 + union { 61 + u32 data; 62 + 63 + struct { 64 + unsigned int a: 1; 65 + unsigned int b: 1; 66 + unsigned int z: 1; 67 + unsigned int start: 1; 68 + unsigned int up: 1; 69 + unsigned int down: 1; 70 + unsigned int left: 1; 71 + unsigned int right: 1; 72 + unsigned int: 2; /* unused */ 73 + unsigned int l: 1; 74 + unsigned int r: 1; 75 + unsigned int c_up: 1; 76 + unsigned int c_down: 1; 77 + unsigned int c_left: 1; 78 + unsigned int c_right: 1; 79 + signed int x: 8; 80 + signed int y: 8; 81 + }; 82 + }; 83 + }; 84 + 85 + static void n64joy_write_reg(u32 __iomem *reg_base, const u8 reg, const u32 value) 86 + { 87 + writel(value, reg_base + reg); 88 + } 89 + 90 + static u32 n64joy_read_reg(u32 __iomem *reg_base, const u8 reg) 91 + { 92 + return readl(reg_base + reg); 93 + } 94 + 95 + static void n64joy_wait_si_dma(u32 __iomem *reg_base) 96 + { 97 + while (n64joy_read_reg(reg_base, SI_STATUS_REG) & 98 + (SI_STATUS_DMA_BUSY | SI_STATUS_IO_BUSY)) 99 + cpu_relax(); 100 + } 101 + 102 + static void n64joy_exec_pif(struct n64joy_priv *priv, const u64 in[8]) 103 + { 104 + unsigned long flags; 105 + 106 + dma_cache_wback_inv((unsigned long) in, 8 * 8); 107 + dma_cache_inv((unsigned long) priv->si_buf, 8 * 8); 108 + 109 + local_irq_save(flags); 110 + 111 + n64joy_wait_si_dma(priv->reg_base); 112 + 113 + barrier(); 114 + n64joy_write_reg(priv->reg_base, SI_DRAM_REG, virt_to_phys(in)); 115 + barrier(); 116 + n64joy_write_reg(priv->reg_base, SI_WRITE_REG, PIF_RAM); 117 + barrier(); 118 + 119 + n64joy_wait_si_dma(priv->reg_base); 120 + 121 + barrier(); 122 + n64joy_write_reg(priv->reg_base, SI_DRAM_REG, virt_to_phys(priv->si_buf)); 123 + barrier(); 124 + n64joy_write_reg(priv->reg_base, SI_READ_REG, PIF_RAM); 125 + barrier(); 126 + 127 + n64joy_wait_si_dma(priv->reg_base); 128 + 129 + local_irq_restore(flags); 130 + } 131 + 132 + static const u64 polldata[] ____cacheline_aligned = { 133 + 0xff010401ffffffff, 134 + 0xff010401ffffffff, 135 + 0xff010401ffffffff, 136 + 0xff010401ffffffff, 137 + 0xfe00000000000000, 138 + 0, 139 + 0, 140 + 1 141 + }; 142 + 143 + static void n64joy_poll(struct timer_list *t) 144 + { 145 + const struct joydata *data; 146 + struct n64joy_priv *priv = container_of(t, struct n64joy_priv, timer); 147 + struct input_dev *dev; 148 + u32 i; 149 + 150 + n64joy_exec_pif(priv, polldata); 151 + 152 + data = (struct joydata *) priv->si_buf; 153 + 154 + for (i = 0; i < MAX_CONTROLLERS; i++) { 155 + if (!priv->n64joy_dev[i]) 156 + continue; 157 + 158 + dev = priv->n64joy_dev[i]; 159 + 160 + /* d-pad */ 161 + input_report_key(dev, BTN_DPAD_UP, data[i].up); 162 + input_report_key(dev, BTN_DPAD_DOWN, data[i].down); 163 + input_report_key(dev, BTN_DPAD_LEFT, data[i].left); 164 + input_report_key(dev, BTN_DPAD_RIGHT, data[i].right); 165 + 166 + /* c buttons */ 167 + input_report_key(dev, BTN_FORWARD, data[i].c_up); 168 + input_report_key(dev, BTN_BACK, data[i].c_down); 169 + input_report_key(dev, BTN_LEFT, data[i].c_left); 170 + input_report_key(dev, BTN_RIGHT, data[i].c_right); 171 + 172 + /* matching buttons */ 173 + input_report_key(dev, BTN_START, data[i].start); 174 + input_report_key(dev, BTN_Z, data[i].z); 175 + 176 + /* remaining ones: a, b, l, r */ 177 + input_report_key(dev, BTN_0, data[i].a); 178 + input_report_key(dev, BTN_1, data[i].b); 179 + input_report_key(dev, BTN_2, data[i].l); 180 + input_report_key(dev, BTN_3, data[i].r); 181 + 182 + input_report_abs(dev, ABS_X, data[i].x); 183 + input_report_abs(dev, ABS_Y, data[i].y); 184 + 185 + input_sync(dev); 186 + } 187 + 188 + mod_timer(&priv->timer, jiffies + msecs_to_jiffies(16)); 189 + } 190 + 191 + static int n64joy_open(struct input_dev *dev) 192 + { 193 + struct n64joy_priv *priv = input_get_drvdata(dev); 194 + int err; 195 + 196 + err = mutex_lock_interruptible(&priv->n64joy_mutex); 197 + if (err) 198 + return err; 199 + 200 + if (!priv->n64joy_opened) { 201 + /* 202 + * We could use the vblank irq, but it's not important if 203 + * the poll point slightly changes. 204 + */ 205 + timer_setup(&priv->timer, n64joy_poll, 0); 206 + mod_timer(&priv->timer, jiffies + msecs_to_jiffies(16)); 207 + } 208 + 209 + priv->n64joy_opened++; 210 + 211 + mutex_unlock(&priv->n64joy_mutex); 212 + return err; 213 + } 214 + 215 + static void n64joy_close(struct input_dev *dev) 216 + { 217 + struct n64joy_priv *priv = input_get_drvdata(dev); 218 + 219 + mutex_lock(&priv->n64joy_mutex); 220 + if (!--priv->n64joy_opened) 221 + del_timer_sync(&priv->timer); 222 + mutex_unlock(&priv->n64joy_mutex); 223 + } 224 + 225 + static const u64 __initconst scandata[] ____cacheline_aligned = { 226 + 0xff010300ffffffff, 227 + 0xff010300ffffffff, 228 + 0xff010300ffffffff, 229 + 0xff010300ffffffff, 230 + 0xfe00000000000000, 231 + 0, 232 + 0, 233 + 1 234 + }; 235 + 236 + /* 237 + * The target device is embedded and RAM-constrained. We save RAM 238 + * by initializing in __init code that gets dropped late in boot. 239 + * For the same reason there is no module or unloading support. 240 + */ 241 + static int __init n64joy_probe(struct platform_device *pdev) 242 + { 243 + const struct joydata *data; 244 + struct n64joy_priv *priv; 245 + struct input_dev *dev; 246 + int err = 0; 247 + u32 i, j, found = 0; 248 + 249 + priv = kzalloc(sizeof(struct n64joy_priv), GFP_KERNEL); 250 + if (!priv) 251 + return -ENOMEM; 252 + mutex_init(&priv->n64joy_mutex); 253 + 254 + priv->reg_base = devm_platform_ioremap_resource(pdev, 0); 255 + if (!priv->reg_base) { 256 + err = -EINVAL; 257 + goto fail; 258 + } 259 + 260 + /* The controllers are not hotpluggable, so we can scan in init */ 261 + n64joy_exec_pif(priv, scandata); 262 + 263 + data = (struct joydata *) priv->si_buf; 264 + 265 + for (i = 0; i < MAX_CONTROLLERS; i++) { 266 + if (!data[i].err && data[i].data >> 16 == N64_CONTROLLER_ID) { 267 + found++; 268 + 269 + dev = priv->n64joy_dev[i] = input_allocate_device(); 270 + if (!priv->n64joy_dev[i]) { 271 + err = -ENOMEM; 272 + goto fail; 273 + } 274 + 275 + input_set_drvdata(dev, priv); 276 + 277 + dev->name = "N64 controller"; 278 + dev->phys = n64joy_phys[i]; 279 + dev->id.bustype = BUS_HOST; 280 + dev->id.vendor = 0; 281 + dev->id.product = data[i].data >> 16; 282 + dev->id.version = 0; 283 + dev->dev.parent = &pdev->dev; 284 + 285 + dev->open = n64joy_open; 286 + dev->close = n64joy_close; 287 + 288 + /* d-pad */ 289 + input_set_capability(dev, EV_KEY, BTN_DPAD_UP); 290 + input_set_capability(dev, EV_KEY, BTN_DPAD_DOWN); 291 + input_set_capability(dev, EV_KEY, BTN_DPAD_LEFT); 292 + input_set_capability(dev, EV_KEY, BTN_DPAD_RIGHT); 293 + /* c buttons */ 294 + input_set_capability(dev, EV_KEY, BTN_LEFT); 295 + input_set_capability(dev, EV_KEY, BTN_RIGHT); 296 + input_set_capability(dev, EV_KEY, BTN_FORWARD); 297 + input_set_capability(dev, EV_KEY, BTN_BACK); 298 + /* matching buttons */ 299 + input_set_capability(dev, EV_KEY, BTN_START); 300 + input_set_capability(dev, EV_KEY, BTN_Z); 301 + /* remaining ones: a, b, l, r */ 302 + input_set_capability(dev, EV_KEY, BTN_0); 303 + input_set_capability(dev, EV_KEY, BTN_1); 304 + input_set_capability(dev, EV_KEY, BTN_2); 305 + input_set_capability(dev, EV_KEY, BTN_3); 306 + 307 + for (j = 0; j < 2; j++) 308 + input_set_abs_params(dev, ABS_X + j, 309 + S8_MIN, S8_MAX, 0, 0); 310 + 311 + err = input_register_device(dev); 312 + if (err) { 313 + input_free_device(dev); 314 + goto fail; 315 + } 316 + } 317 + } 318 + 319 + pr_info("%u controller(s) connected\n", found); 320 + 321 + if (!found) 322 + return -ENODEV; 323 + 324 + return 0; 325 + fail: 326 + for (i = 0; i < MAX_CONTROLLERS; i++) { 327 + if (!priv->n64joy_dev[i]) 328 + continue; 329 + input_unregister_device(priv->n64joy_dev[i]); 330 + } 331 + return err; 332 + } 333 + 334 + static struct platform_driver n64joy_driver = { 335 + .driver = { 336 + .name = "n64joy", 337 + }, 338 + }; 339 + 340 + static int __init n64joy_init(void) 341 + { 342 + return platform_driver_probe(&n64joy_driver, n64joy_probe); 343 + } 344 + 345 + module_init(n64joy_init);
+1
drivers/input/joystick/xpad.c
··· 305 305 { 0x1bad, 0xfd00, "Razer Onza TE", 0, XTYPE_XBOX360 }, 306 306 { 0x1bad, 0xfd01, "Razer Onza", 0, XTYPE_XBOX360 }, 307 307 { 0x20d6, 0x2001, "BDA Xbox Series X Wired Controller", 0, XTYPE_XBOXONE }, 308 + { 0x20d6, 0x2009, "PowerA Enhanced Wired Controller for Xbox Series X|S", 0, XTYPE_XBOXONE }, 308 309 { 0x20d6, 0x281f, "PowerA Wired Controller For Xbox 360", 0, XTYPE_XBOX360 }, 309 310 { 0x2e24, 0x0652, "Hyperkin Duke X-Box One pad", 0, XTYPE_XBOXONE }, 310 311 { 0x24c6, 0x5000, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
+3 -3
drivers/input/keyboard/Kconfig
··· 446 446 447 447 config KEYBOARD_SNVS_PWRKEY 448 448 tristate "IMX SNVS Power Key Driver" 449 - depends on ARCH_MXC || COMPILE_TEST 449 + depends on ARCH_MXC || (COMPILE_TEST && HAS_IOMEM) 450 450 depends on OF 451 451 help 452 452 This is the snvs powerkey driver for the Freescale i.MX application ··· 685 685 686 686 config KEYBOARD_OMAP4 687 687 tristate "TI OMAP4+ keypad support" 688 - depends on OF || ARCH_OMAP2PLUS 688 + depends on (OF && HAS_IOMEM) || ARCH_OMAP2PLUS 689 689 select INPUT_MATRIXKMAP 690 690 help 691 691 Say Y here if you want to use the OMAP4+ keypad. ··· 773 773 774 774 config KEYBOARD_BCM 775 775 tristate "Broadcom keypad driver" 776 - depends on OF && HAVE_CLK 776 + depends on OF && HAVE_CLK && HAS_IOMEM 777 777 select INPUT_MATRIXKMAP 778 778 default ARCH_BCM_CYGNUS 779 779 help
+17 -6
drivers/input/keyboard/applespi.c
··· 48 48 #include <linux/efi.h> 49 49 #include <linux/input.h> 50 50 #include <linux/input/mt.h> 51 + #include <linux/ktime.h> 51 52 #include <linux/leds.h> 52 53 #include <linux/module.h> 53 54 #include <linux/spinlock.h> ··· 410 409 unsigned int cmd_msg_cntr; 411 410 /* lock to protect the above parameters and flags below */ 412 411 spinlock_t cmd_msg_lock; 413 - bool cmd_msg_queued; 412 + ktime_t cmd_msg_queued; 414 413 enum applespi_evt_type cmd_evt_type; 415 414 416 415 struct led_classdev backlight_info; ··· 730 729 wake_up_all(&applespi->drain_complete); 731 730 732 731 if (is_write_msg) { 733 - applespi->cmd_msg_queued = false; 732 + applespi->cmd_msg_queued = 0; 734 733 applespi_send_cmd_msg(applespi); 735 734 } 736 735 ··· 748 747 applespi_get_trace_fun(evt_type)(evt_type, PT_STATUS, 749 748 applespi->tx_status, 750 749 APPLESPI_STATUS_SIZE); 750 + 751 + udelay(SPI_RW_CHG_DELAY_US); 751 752 752 753 if (!applespi_check_write_status(applespi, applespi->wr_m.status)) { 753 754 /* ··· 774 771 return 0; 775 772 776 773 /* check whether send is in progress */ 777 - if (applespi->cmd_msg_queued) 778 - return 0; 774 + if (applespi->cmd_msg_queued) { 775 + if (ktime_ms_delta(ktime_get(), applespi->cmd_msg_queued) < 1000) 776 + return 0; 777 + 778 + dev_warn(&applespi->spi->dev, "Command %d timed out\n", 779 + applespi->cmd_evt_type); 780 + 781 + applespi->cmd_msg_queued = 0; 782 + applespi->write_active = false; 783 + } 779 784 780 785 /* set up packet */ 781 786 memset(packet, 0, APPLESPI_PACKET_SIZE); ··· 880 869 return sts; 881 870 } 882 871 883 - applespi->cmd_msg_queued = true; 872 + applespi->cmd_msg_queued = ktime_get_coarse(); 884 873 applespi->write_active = true; 885 874 886 875 return 0; ··· 1932 1921 applespi->drain = false; 1933 1922 applespi->have_cl_led_on = false; 1934 1923 applespi->have_bl_level = 0; 1935 - applespi->cmd_msg_queued = false; 1924 + applespi->cmd_msg_queued = 0; 1936 1925 applespi->read_active = false; 1937 1926 applespi->write_active = false; 1938 1927
+79
drivers/input/keyboard/cros_ec_keyb.c
··· 27 27 28 28 #include <asm/unaligned.h> 29 29 30 + #define MAX_NUM_TOP_ROW_KEYS 15 31 + 30 32 /** 31 33 * struct cros_ec_keyb - Structure representing EC keyboard device 32 34 * ··· 44 42 * @idev: The input device for the matrix keys. 45 43 * @bs_idev: The input device for non-matrix buttons and switches (or NULL). 46 44 * @notifier: interrupt event notifier for transport devices 45 + * @function_row_physmap: An array of the encoded rows/columns for the top 46 + * row function keys, in an order from left to right 47 + * @num_function_row_keys: The number of top row keys in a custom keyboard 47 48 */ 48 49 struct cros_ec_keyb { 49 50 unsigned int rows; ··· 63 58 struct input_dev *idev; 64 59 struct input_dev *bs_idev; 65 60 struct notifier_block notifier; 61 + 62 + u16 function_row_physmap[MAX_NUM_TOP_ROW_KEYS]; 63 + size_t num_function_row_keys; 66 64 }; 67 65 68 66 /** ··· 535 527 struct input_dev *idev; 536 528 const char *phys; 537 529 int err; 530 + struct property *prop; 531 + const __be32 *p; 532 + u16 *physmap; 533 + u32 key_pos; 534 + int row, col; 538 535 539 536 err = matrix_keypad_parse_properties(dev, &ckdev->rows, &ckdev->cols); 540 537 if (err) ··· 591 578 ckdev->idev = idev; 592 579 cros_ec_keyb_compute_valid_keys(ckdev); 593 580 581 + physmap = ckdev->function_row_physmap; 582 + of_property_for_each_u32(dev->of_node, "function-row-physmap", 583 + prop, p, key_pos) { 584 + if (ckdev->num_function_row_keys == MAX_NUM_TOP_ROW_KEYS) { 585 + dev_warn(dev, "Only support up to %d top row keys\n", 586 + MAX_NUM_TOP_ROW_KEYS); 587 + break; 588 + } 589 + row = KEY_ROW(key_pos); 590 + col = KEY_COL(key_pos); 591 + *physmap = MATRIX_SCAN_CODE(row, col, ckdev->row_shift); 592 + physmap++; 593 + ckdev->num_function_row_keys++; 594 + } 595 + 594 596 err = input_register_device(ckdev->idev); 595 597 if (err) { 596 598 dev_err(dev, "cannot register input device\n"); ··· 614 586 615 587 return 0; 616 588 } 589 + 590 + static ssize_t function_row_physmap_show(struct device *dev, 591 + struct device_attribute *attr, 592 + char *buf) 593 + { 594 + ssize_t size = 0; 595 + int i; 596 + struct cros_ec_keyb *ckdev = dev_get_drvdata(dev); 597 + u16 *physmap = ckdev->function_row_physmap; 598 + 599 + for (i = 0; i < ckdev->num_function_row_keys; i++) 600 + size += scnprintf(buf + size, PAGE_SIZE - size, 601 + "%s%02X", size ? " " : "", physmap[i]); 602 + if (size) 603 + size += scnprintf(buf + size, PAGE_SIZE - size, "\n"); 604 + 605 + return size; 606 + } 607 + 608 + static DEVICE_ATTR_RO(function_row_physmap); 609 + 610 + static struct attribute *cros_ec_keyb_attrs[] = { 611 + &dev_attr_function_row_physmap.attr, 612 + NULL, 613 + }; 614 + 615 + static umode_t cros_ec_keyb_attr_is_visible(struct kobject *kobj, 616 + struct attribute *attr, 617 + int n) 618 + { 619 + struct device *dev = container_of(kobj, struct device, kobj); 620 + struct cros_ec_keyb *ckdev = dev_get_drvdata(dev); 621 + 622 + if (attr == &dev_attr_function_row_physmap.attr && 623 + !ckdev->num_function_row_keys) 624 + return 0; 625 + 626 + return attr->mode; 627 + } 628 + 629 + static const struct attribute_group cros_ec_keyb_attr_group = { 630 + .is_visible = cros_ec_keyb_attr_is_visible, 631 + .attrs = cros_ec_keyb_attrs, 632 + }; 633 + 617 634 618 635 static int cros_ec_keyb_probe(struct platform_device *pdev) 619 636 { ··· 687 614 err = cros_ec_keyb_register_bs(ckdev); 688 615 if (err) { 689 616 dev_err(dev, "cannot register non-matrix inputs: %d\n", err); 617 + return err; 618 + } 619 + 620 + err = devm_device_add_group(dev, &cros_ec_keyb_attr_group); 621 + if (err) { 622 + dev_err(dev, "failed to create attributes. err=%d\n", err); 690 623 return err; 691 624 } 692 625
+179 -123
drivers/input/keyboard/omap4-keypad.c
··· 60 60 ((((dbms) * 1000) / ((1 << ((ptv) + 1)) * (1000000 / 32768))) - 1) 61 61 #define OMAP4_VAL_DEBOUNCINGTIME_16MS \ 62 62 OMAP4_KEYPAD_DEBOUNCINGTIME_MS(16, OMAP4_KEYPAD_PTV_DIV_128) 63 + #define OMAP4_KEYPAD_AUTOIDLE_MS 50 /* Approximate measured time */ 64 + #define OMAP4_KEYPAD_IDLE_CHECK_MS (OMAP4_KEYPAD_AUTOIDLE_MS / 2) 63 65 64 66 enum { 65 67 KBD_REVISION_OMAP4 = 0, ··· 73 71 74 72 void __iomem *base; 75 73 unsigned int irq; 74 + struct mutex lock; /* for key scan */ 76 75 77 76 unsigned int rows; 78 77 unsigned int cols; ··· 81 78 u32 irqreg_offset; 82 79 unsigned int row_shift; 83 80 bool no_autorepeat; 84 - unsigned char key_state[8]; 81 + u64 keys; 85 82 unsigned short *keymap; 86 83 }; 87 84 ··· 110 107 keypad_data->base + keypad_data->irqreg_offset + offset); 111 108 } 112 109 110 + static int omap4_keypad_report_keys(struct omap4_keypad *keypad_data, 111 + u64 keys, bool down) 112 + { 113 + struct input_dev *input_dev = keypad_data->input; 114 + unsigned int col, row, code; 115 + DECLARE_BITMAP(mask, 64); 116 + unsigned long bit; 117 + int events = 0; 118 + 119 + bitmap_from_u64(mask, keys); 120 + 121 + for_each_set_bit(bit, mask, keypad_data->rows * BITS_PER_BYTE) { 122 + row = bit / BITS_PER_BYTE; 123 + col = bit % BITS_PER_BYTE; 124 + code = MATRIX_SCAN_CODE(row, col, keypad_data->row_shift); 125 + 126 + input_event(input_dev, EV_MSC, MSC_SCAN, code); 127 + input_report_key(input_dev, keypad_data->keymap[code], down); 128 + 129 + events++; 130 + } 131 + 132 + if (events) 133 + input_sync(input_dev); 134 + 135 + return events; 136 + } 137 + 138 + static void omap4_keypad_scan_keys(struct omap4_keypad *keypad_data, u64 keys) 139 + { 140 + u64 changed; 141 + 142 + mutex_lock(&keypad_data->lock); 143 + 144 + changed = keys ^ keypad_data->keys; 145 + 146 + /* 147 + * Report key up events separately and first. This matters in case we 148 + * lost key-up interrupt and just now catching up. 149 + */ 150 + omap4_keypad_report_keys(keypad_data, changed & ~keys, false); 151 + 152 + /* Report key down events */ 153 + omap4_keypad_report_keys(keypad_data, changed & keys, true); 154 + 155 + keypad_data->keys = keys; 156 + 157 + mutex_unlock(&keypad_data->lock); 158 + } 113 159 114 160 /* Interrupt handlers */ 115 161 static irqreturn_t omap4_keypad_irq_handler(int irq, void *dev_id) ··· 174 122 static irqreturn_t omap4_keypad_irq_thread_fn(int irq, void *dev_id) 175 123 { 176 124 struct omap4_keypad *keypad_data = dev_id; 177 - struct input_dev *input_dev = keypad_data->input; 178 - unsigned char key_state[ARRAY_SIZE(keypad_data->key_state)]; 179 - unsigned int col, row, code, changed; 180 - u32 *new_state = (u32 *) key_state; 125 + struct device *dev = keypad_data->input->dev.parent; 126 + u32 low, high; 127 + int error; 128 + u64 keys; 181 129 182 - *new_state = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE31_0); 183 - *(new_state + 1) = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE63_32); 184 - 185 - for (row = 0; row < keypad_data->rows; row++) { 186 - changed = key_state[row] ^ keypad_data->key_state[row]; 187 - if (!changed) 188 - continue; 189 - 190 - for (col = 0; col < keypad_data->cols; col++) { 191 - if (changed & (1 << col)) { 192 - code = MATRIX_SCAN_CODE(row, col, 193 - keypad_data->row_shift); 194 - input_event(input_dev, EV_MSC, MSC_SCAN, code); 195 - input_report_key(input_dev, 196 - keypad_data->keymap[code], 197 - key_state[row] & (1 << col)); 198 - } 199 - } 130 + error = pm_runtime_get_sync(dev); 131 + if (error < 0) { 132 + pm_runtime_put_noidle(dev); 133 + return IRQ_NONE; 200 134 } 201 135 202 - input_sync(input_dev); 136 + low = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE31_0); 137 + high = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE63_32); 138 + keys = low | (u64)high << 32; 203 139 204 - memcpy(keypad_data->key_state, key_state, 205 - sizeof(keypad_data->key_state)); 140 + omap4_keypad_scan_keys(keypad_data, keys); 206 141 207 142 /* clear pending interrupts */ 208 143 kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS, 209 144 kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS)); 145 + 146 + pm_runtime_mark_last_busy(dev); 147 + pm_runtime_put_autosuspend(dev); 210 148 211 149 return IRQ_HANDLED; 212 150 } ··· 204 162 static int omap4_keypad_open(struct input_dev *input) 205 163 { 206 164 struct omap4_keypad *keypad_data = input_get_drvdata(input); 165 + struct device *dev = input->dev.parent; 166 + int error; 207 167 208 - pm_runtime_get_sync(input->dev.parent); 168 + error = pm_runtime_get_sync(dev); 169 + if (error < 0) { 170 + pm_runtime_put_noidle(dev); 171 + return error; 172 + } 209 173 210 174 disable_irq(keypad_data->irq); 211 175 ··· 224 176 kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS, 225 177 kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS)); 226 178 kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE, 227 - OMAP4_DEF_IRQENABLE_EVENTEN | 228 - OMAP4_DEF_IRQENABLE_LONGKEY); 179 + OMAP4_DEF_IRQENABLE_EVENTEN); 229 180 kbd_writel(keypad_data, OMAP4_KBD_WAKEUPENABLE, 230 - OMAP4_DEF_WUP_EVENT_ENA | OMAP4_DEF_WUP_LONG_KEY_ENA); 181 + OMAP4_DEF_WUP_EVENT_ENA); 231 182 232 183 enable_irq(keypad_data->irq); 184 + 185 + pm_runtime_mark_last_busy(dev); 186 + pm_runtime_put_autosuspend(dev); 233 187 234 188 return 0; 235 189 } ··· 250 200 251 201 static void omap4_keypad_close(struct input_dev *input) 252 202 { 253 - struct omap4_keypad *keypad_data; 203 + struct omap4_keypad *keypad_data = input_get_drvdata(input); 204 + struct device *dev = input->dev.parent; 205 + int error; 254 206 255 - keypad_data = input_get_drvdata(input); 207 + error = pm_runtime_get_sync(dev); 208 + if (error < 0) 209 + pm_runtime_put_noidle(dev); 210 + 256 211 disable_irq(keypad_data->irq); 257 212 omap4_keypad_stop(keypad_data); 258 213 enable_irq(keypad_data->irq); 259 214 260 - pm_runtime_put_sync(input->dev.parent); 215 + pm_runtime_mark_last_busy(dev); 216 + pm_runtime_put_autosuspend(dev); 261 217 } 262 218 263 219 static int omap4_keypad_parse_dt(struct device *dev, ··· 308 252 return 0; 309 253 } 310 254 255 + /* 256 + * Errata ID i689 "1.32 Keyboard Key Up Event Can Be Missed". 257 + * Interrupt may not happen for key-up events. We must clear stuck 258 + * key-up events after the keyboard hardware has auto-idled. 259 + */ 260 + static int __maybe_unused omap4_keypad_runtime_suspend(struct device *dev) 261 + { 262 + struct platform_device *pdev = to_platform_device(dev); 263 + struct omap4_keypad *keypad_data = platform_get_drvdata(pdev); 264 + u32 active; 265 + 266 + active = kbd_readl(keypad_data, OMAP4_KBD_STATEMACHINE); 267 + if (active) { 268 + pm_runtime_mark_last_busy(dev); 269 + return -EBUSY; 270 + } 271 + 272 + omap4_keypad_scan_keys(keypad_data, 0); 273 + 274 + return 0; 275 + } 276 + 277 + static const struct dev_pm_ops omap4_keypad_pm_ops = { 278 + SET_RUNTIME_PM_OPS(omap4_keypad_runtime_suspend, NULL, NULL) 279 + }; 280 + 281 + static void omap4_disable_pm(void *d) 282 + { 283 + pm_runtime_dont_use_autosuspend(d); 284 + pm_runtime_disable(d); 285 + } 286 + 311 287 static int omap4_keypad_probe(struct platform_device *pdev) 312 288 { 289 + struct device *dev = &pdev->dev; 313 290 struct omap4_keypad *keypad_data; 314 291 struct input_dev *input_dev; 315 292 struct resource *res; ··· 360 271 if (irq < 0) 361 272 return irq; 362 273 363 - keypad_data = kzalloc(sizeof(struct omap4_keypad), GFP_KERNEL); 274 + keypad_data = devm_kzalloc(dev, sizeof(*keypad_data), GFP_KERNEL); 364 275 if (!keypad_data) { 365 - dev_err(&pdev->dev, "keypad_data memory allocation failed\n"); 276 + dev_err(dev, "keypad_data memory allocation failed\n"); 366 277 return -ENOMEM; 367 278 } 368 279 369 280 keypad_data->irq = irq; 281 + mutex_init(&keypad_data->lock); 282 + platform_set_drvdata(pdev, keypad_data); 370 283 371 - error = omap4_keypad_parse_dt(&pdev->dev, keypad_data); 284 + error = omap4_keypad_parse_dt(dev, keypad_data); 372 285 if (error) 373 - goto err_free_keypad; 286 + return error; 374 287 375 - res = request_mem_region(res->start, resource_size(res), pdev->name); 376 - if (!res) { 377 - dev_err(&pdev->dev, "can't request mem region\n"); 378 - error = -EBUSY; 379 - goto err_free_keypad; 288 + keypad_data->base = devm_ioremap_resource(dev, res); 289 + if (IS_ERR(keypad_data->base)) 290 + return PTR_ERR(keypad_data->base); 291 + 292 + pm_runtime_use_autosuspend(dev); 293 + pm_runtime_set_autosuspend_delay(dev, OMAP4_KEYPAD_IDLE_CHECK_MS); 294 + pm_runtime_enable(dev); 295 + 296 + error = devm_add_action_or_reset(dev, omap4_disable_pm, dev); 297 + if (error) { 298 + dev_err(dev, "unable to register cleanup action\n"); 299 + return error; 380 300 } 381 - 382 - keypad_data->base = ioremap(res->start, resource_size(res)); 383 - if (!keypad_data->base) { 384 - dev_err(&pdev->dev, "can't ioremap mem resource\n"); 385 - error = -ENOMEM; 386 - goto err_release_mem; 387 - } 388 - 389 - pm_runtime_enable(&pdev->dev); 390 301 391 302 /* 392 303 * Enable clocks for the keypad module so that we can read 393 304 * revision register. 394 305 */ 395 - error = pm_runtime_get_sync(&pdev->dev); 306 + error = pm_runtime_get_sync(dev); 396 307 if (error) { 397 - dev_err(&pdev->dev, "pm_runtime_get_sync() failed\n"); 398 - pm_runtime_put_noidle(&pdev->dev); 399 - } else { 400 - error = omap4_keypad_check_revision(&pdev->dev, 401 - keypad_data); 402 - if (!error) { 403 - /* Ensure device does not raise interrupts */ 404 - omap4_keypad_stop(keypad_data); 405 - } 406 - pm_runtime_put_sync(&pdev->dev); 308 + dev_err(dev, "pm_runtime_get_sync() failed\n"); 309 + pm_runtime_put_noidle(dev); 310 + return error; 407 311 } 312 + 313 + error = omap4_keypad_check_revision(dev, keypad_data); 314 + if (!error) { 315 + /* Ensure device does not raise interrupts */ 316 + omap4_keypad_stop(keypad_data); 317 + } 318 + 319 + pm_runtime_mark_last_busy(dev); 320 + pm_runtime_put_autosuspend(dev); 408 321 if (error) 409 - goto err_pm_disable; 322 + return error; 410 323 411 324 /* input device allocation */ 412 - keypad_data->input = input_dev = input_allocate_device(); 413 - if (!input_dev) { 414 - error = -ENOMEM; 415 - goto err_pm_disable; 416 - } 325 + keypad_data->input = input_dev = devm_input_allocate_device(dev); 326 + if (!input_dev) 327 + return -ENOMEM; 417 328 418 329 input_dev->name = pdev->name; 419 - input_dev->dev.parent = &pdev->dev; 420 330 input_dev->id.bustype = BUS_HOST; 421 331 input_dev->id.vendor = 0x0001; 422 332 input_dev->id.product = 0x0001; ··· 432 344 433 345 keypad_data->row_shift = get_count_order(keypad_data->cols); 434 346 max_keys = keypad_data->rows << keypad_data->row_shift; 435 - keypad_data->keymap = kcalloc(max_keys, 436 - sizeof(keypad_data->keymap[0]), 437 - GFP_KERNEL); 347 + keypad_data->keymap = devm_kcalloc(dev, 348 + max_keys, 349 + sizeof(keypad_data->keymap[0]), 350 + GFP_KERNEL); 438 351 if (!keypad_data->keymap) { 439 - dev_err(&pdev->dev, "Not enough memory for keymap\n"); 440 - error = -ENOMEM; 441 - goto err_free_input; 352 + dev_err(dev, "Not enough memory for keymap\n"); 353 + return -ENOMEM; 442 354 } 443 355 444 356 error = matrix_keypad_build_keymap(NULL, NULL, 445 357 keypad_data->rows, keypad_data->cols, 446 358 keypad_data->keymap, input_dev); 447 359 if (error) { 448 - dev_err(&pdev->dev, "failed to build keymap\n"); 449 - goto err_free_keymap; 360 + dev_err(dev, "failed to build keymap\n"); 361 + return error; 450 362 } 451 363 452 - error = request_threaded_irq(keypad_data->irq, omap4_keypad_irq_handler, 453 - omap4_keypad_irq_thread_fn, IRQF_ONESHOT, 454 - "omap4-keypad", keypad_data); 364 + error = devm_request_threaded_irq(dev, keypad_data->irq, 365 + omap4_keypad_irq_handler, 366 + omap4_keypad_irq_thread_fn, 367 + IRQF_ONESHOT, 368 + "omap4-keypad", keypad_data); 455 369 if (error) { 456 - dev_err(&pdev->dev, "failed to register interrupt\n"); 457 - goto err_free_keymap; 370 + dev_err(dev, "failed to register interrupt\n"); 371 + return error; 458 372 } 459 373 460 374 error = input_register_device(keypad_data->input); 461 - if (error < 0) { 462 - dev_err(&pdev->dev, "failed to register input device\n"); 463 - goto err_free_irq; 375 + if (error) { 376 + dev_err(dev, "failed to register input device\n"); 377 + return error; 464 378 } 465 379 466 - device_init_wakeup(&pdev->dev, true); 467 - error = dev_pm_set_wake_irq(&pdev->dev, keypad_data->irq); 380 + device_init_wakeup(dev, true); 381 + error = dev_pm_set_wake_irq(dev, keypad_data->irq); 468 382 if (error) 469 - dev_warn(&pdev->dev, 470 - "failed to set up wakeup irq: %d\n", error); 471 - 472 - platform_set_drvdata(pdev, keypad_data); 383 + dev_warn(dev, "failed to set up wakeup irq: %d\n", error); 473 384 474 385 return 0; 475 - 476 - err_free_irq: 477 - free_irq(keypad_data->irq, keypad_data); 478 - err_free_keymap: 479 - kfree(keypad_data->keymap); 480 - err_free_input: 481 - input_free_device(input_dev); 482 - err_pm_disable: 483 - pm_runtime_disable(&pdev->dev); 484 - iounmap(keypad_data->base); 485 - err_release_mem: 486 - release_mem_region(res->start, resource_size(res)); 487 - err_free_keypad: 488 - kfree(keypad_data); 489 - return error; 490 386 } 491 387 492 388 static int omap4_keypad_remove(struct platform_device *pdev) 493 389 { 494 - struct omap4_keypad *keypad_data = platform_get_drvdata(pdev); 495 - struct resource *res; 496 - 497 390 dev_pm_clear_wake_irq(&pdev->dev); 498 - 499 - free_irq(keypad_data->irq, keypad_data); 500 - 501 - pm_runtime_disable(&pdev->dev); 502 - 503 - input_unregister_device(keypad_data->input); 504 - 505 - iounmap(keypad_data->base); 506 - 507 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 508 - release_mem_region(res->start, resource_size(res)); 509 - 510 - kfree(keypad_data->keymap); 511 - kfree(keypad_data); 512 391 513 392 return 0; 514 393 } ··· 492 437 .driver = { 493 438 .name = "omap4-keypad", 494 439 .of_match_table = omap_keypad_dt_match, 440 + .pm = &omap4_keypad_pm_ops, 495 441 }, 496 442 }; 497 443 module_platform_driver(omap4_keypad_driver);
+3
drivers/input/misc/da7280.c
··· 863 863 gpi_str3[7] = '0' + i; 864 864 haptics->gpi_ctl[i].polarity = 0; 865 865 error = device_property_read_string(dev, gpi_str3, &str); 866 + if (!error) 866 867 haptics->gpi_ctl[i].polarity = 867 868 da7280_haptic_of_gpi_pol_str(dev, str); 868 869 } ··· 1300 1299 return retval; 1301 1300 } 1302 1301 1302 + #ifdef CONFIG_OF 1303 1303 static const struct of_device_id da7280_of_match[] = { 1304 1304 { .compatible = "dlg,da7280", }, 1305 1305 { } 1306 1306 }; 1307 1307 MODULE_DEVICE_TABLE(of, da7280_of_match); 1308 + #endif 1308 1309 1309 1310 static const struct i2c_device_id da7280_i2c_id[] = { 1310 1311 { "da7280", },
+1 -1
drivers/input/mouse/alps.c
··· 986 986 case V7_PACKET_ID_TWO: 987 987 mt[1].x &= ~0x000F; 988 988 mt[1].y |= 0x000F; 989 - /* Detect false-postive touches where x & y report max value */ 989 + /* Detect false-positive touches where x & y report max value */ 990 990 if (mt[1].y == 0x7ff && mt[1].x == 0xff0) { 991 991 mt[1].x = 0; 992 992 /* y gets set to 0 at the end of this function */
+5 -2
drivers/input/mouse/synaptics.c
··· 1106 1106 num_fingers = hw.w + 2; 1107 1107 break; 1108 1108 case 2: 1109 - if (SYN_MODEL_PEN(info->model_id)) 1110 - ; /* Nothing, treat a pen as a single finger */ 1109 + /* 1110 + * SYN_MODEL_PEN(info->model_id): even if 1111 + * the device supports pen, we treat it as 1112 + * a single finger. 1113 + */ 1111 1114 break; 1112 1115 case 4 ... 15: 1113 1116 if (SYN_CAP_PALMDETECT(info->capabilities))
+1 -1
drivers/input/serio/Kconfig
··· 255 255 256 256 config SERIO_APBPS2 257 257 tristate "GRLIB APBPS2 PS/2 keyboard/mouse controller" 258 - depends on OF 258 + depends on OF && HAS_IOMEM 259 259 help 260 260 Say Y here if you want support for GRLIB APBPS2 peripherals used 261 261 to connect to PS/2 keyboard and/or mouse.
+4
drivers/input/serio/i8042-x86ia64io.h
··· 588 588 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 589 589 DMI_MATCH(DMI_CHASSIS_TYPE, "10"), /* Notebook */ 590 590 }, 591 + .matches = { 592 + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 593 + DMI_MATCH(DMI_CHASSIS_TYPE, "31"), /* Convertible Notebook */ 594 + }, 591 595 }, 592 596 { } 593 597 };
+33 -47
drivers/input/tablet/aiptek.c
··· 1036 1036 { 1037 1037 struct aiptek *aiptek = dev_get_drvdata(dev); 1038 1038 1039 - return snprintf(buf, PAGE_SIZE, "%dx%d\n", 1040 - input_abs_get_max(aiptek->inputdev, ABS_X) + 1, 1041 - input_abs_get_max(aiptek->inputdev, ABS_Y) + 1); 1039 + return sysfs_emit(buf, "%dx%d\n", 1040 + input_abs_get_max(aiptek->inputdev, ABS_X) + 1, 1041 + input_abs_get_max(aiptek->inputdev, ABS_Y) + 1); 1042 1042 } 1043 1043 1044 1044 /* These structs define the sysfs files, param #1 is the name of the ··· 1064 1064 { 1065 1065 struct aiptek *aiptek = dev_get_drvdata(dev); 1066 1066 1067 - return snprintf(buf, PAGE_SIZE, "%s\n", 1068 - map_val_to_str(pointer_mode_map, 1069 - aiptek->curSetting.pointerMode)); 1067 + return sysfs_emit(buf, "%s\n", map_val_to_str(pointer_mode_map, 1068 + aiptek->curSetting.pointerMode)); 1070 1069 } 1071 1070 1072 1071 static ssize_t ··· 1100 1101 { 1101 1102 struct aiptek *aiptek = dev_get_drvdata(dev); 1102 1103 1103 - return snprintf(buf, PAGE_SIZE, "%s\n", 1104 - map_val_to_str(coordinate_mode_map, 1105 - aiptek->curSetting.coordinateMode)); 1104 + return sysfs_emit(buf, "%s\n", map_val_to_str(coordinate_mode_map, 1105 + aiptek->curSetting.coordinateMode)); 1106 1106 } 1107 1107 1108 1108 static ssize_t ··· 1141 1143 { 1142 1144 struct aiptek *aiptek = dev_get_drvdata(dev); 1143 1145 1144 - return snprintf(buf, PAGE_SIZE, "%s\n", 1145 - map_val_to_str(tool_mode_map, 1146 - aiptek->curSetting.toolMode)); 1146 + return sysfs_emit(buf, "%s\n", map_val_to_str(tool_mode_map, 1147 + aiptek->curSetting.toolMode)); 1147 1148 } 1148 1149 1149 1150 static ssize_t ··· 1171 1174 struct aiptek *aiptek = dev_get_drvdata(dev); 1172 1175 1173 1176 if (aiptek->curSetting.xTilt == AIPTEK_TILT_DISABLE) { 1174 - return snprintf(buf, PAGE_SIZE, "disable\n"); 1177 + return sysfs_emit(buf, "disable\n"); 1175 1178 } else { 1176 - return snprintf(buf, PAGE_SIZE, "%d\n", 1177 - aiptek->curSetting.xTilt); 1179 + return sysfs_emit(buf, "%d\n", aiptek->curSetting.xTilt); 1178 1180 } 1179 1181 } 1180 1182 ··· 1212 1216 struct aiptek *aiptek = dev_get_drvdata(dev); 1213 1217 1214 1218 if (aiptek->curSetting.yTilt == AIPTEK_TILT_DISABLE) { 1215 - return snprintf(buf, PAGE_SIZE, "disable\n"); 1219 + return sysfs_emit(buf, "disable\n"); 1216 1220 } else { 1217 - return snprintf(buf, PAGE_SIZE, "%d\n", 1218 - aiptek->curSetting.yTilt); 1221 + return sysfs_emit(buf, "%d\n", aiptek->curSetting.yTilt); 1219 1222 } 1220 1223 } 1221 1224 ··· 1252 1257 { 1253 1258 struct aiptek *aiptek = dev_get_drvdata(dev); 1254 1259 1255 - return snprintf(buf, PAGE_SIZE, "%d\n", aiptek->curSetting.jitterDelay); 1260 + return sysfs_emit(buf, "%d\n", aiptek->curSetting.jitterDelay); 1256 1261 } 1257 1262 1258 1263 static ssize_t ··· 1281 1286 { 1282 1287 struct aiptek *aiptek = dev_get_drvdata(dev); 1283 1288 1284 - return snprintf(buf, PAGE_SIZE, "%d\n", 1285 - aiptek->curSetting.programmableDelay); 1289 + return sysfs_emit(buf, "%d\n", aiptek->curSetting.programmableDelay); 1286 1290 } 1287 1291 1288 1292 static ssize_t ··· 1310 1316 { 1311 1317 struct aiptek *aiptek = dev_get_drvdata(dev); 1312 1318 1313 - return snprintf(buf, PAGE_SIZE, "%ld\n", aiptek->eventCount); 1319 + return sysfs_emit(buf, "%ld\n", aiptek->eventCount); 1314 1320 } 1315 1321 1316 1322 static DEVICE_ATTR(event_count, S_IRUGO, show_tabletEventsReceived, NULL); ··· 1349 1355 default: 1350 1356 return 0; 1351 1357 } 1352 - return snprintf(buf, PAGE_SIZE, retMsg); 1358 + return sysfs_emit(buf, retMsg); 1353 1359 } 1354 1360 1355 1361 static DEVICE_ATTR(diagnostic, S_IRUGO, show_tabletDiagnosticMessage, NULL); ··· 1369 1375 { 1370 1376 struct aiptek *aiptek = dev_get_drvdata(dev); 1371 1377 1372 - return snprintf(buf, PAGE_SIZE, "%s\n", 1373 - map_val_to_str(stylus_button_map, 1374 - aiptek->curSetting.stylusButtonUpper)); 1378 + return sysfs_emit(buf, "%s\n", map_val_to_str(stylus_button_map, 1379 + aiptek->curSetting.stylusButtonUpper)); 1375 1380 } 1376 1381 1377 1382 static ssize_t ··· 1399 1406 { 1400 1407 struct aiptek *aiptek = dev_get_drvdata(dev); 1401 1408 1402 - return snprintf(buf, PAGE_SIZE, "%s\n", 1403 - map_val_to_str(stylus_button_map, 1404 - aiptek->curSetting.stylusButtonLower)); 1409 + return sysfs_emit(buf, "%s\n", map_val_to_str(stylus_button_map, 1410 + aiptek->curSetting.stylusButtonLower)); 1405 1411 } 1406 1412 1407 1413 static ssize_t ··· 1436 1444 { 1437 1445 struct aiptek *aiptek = dev_get_drvdata(dev); 1438 1446 1439 - return snprintf(buf, PAGE_SIZE, "%s\n", 1440 - map_val_to_str(mouse_button_map, 1441 - aiptek->curSetting.mouseButtonLeft)); 1447 + return sysfs_emit(buf, "%s\n", map_val_to_str(mouse_button_map, 1448 + aiptek->curSetting.mouseButtonLeft)); 1442 1449 } 1443 1450 1444 1451 static ssize_t ··· 1465 1474 { 1466 1475 struct aiptek *aiptek = dev_get_drvdata(dev); 1467 1476 1468 - return snprintf(buf, PAGE_SIZE, "%s\n", 1469 - map_val_to_str(mouse_button_map, 1470 - aiptek->curSetting.mouseButtonMiddle)); 1477 + return sysfs_emit(buf, "%s\n", map_val_to_str(mouse_button_map, 1478 + aiptek->curSetting.mouseButtonMiddle)); 1471 1479 } 1472 1480 1473 1481 static ssize_t ··· 1494 1504 { 1495 1505 struct aiptek *aiptek = dev_get_drvdata(dev); 1496 1506 1497 - return snprintf(buf, PAGE_SIZE, "%s\n", 1498 - map_val_to_str(mouse_button_map, 1499 - aiptek->curSetting.mouseButtonRight)); 1507 + return sysfs_emit(buf, "%s\n", map_val_to_str(mouse_button_map, 1508 + aiptek->curSetting.mouseButtonRight)); 1500 1509 } 1501 1510 1502 1511 static ssize_t ··· 1524 1535 struct aiptek *aiptek = dev_get_drvdata(dev); 1525 1536 1526 1537 if (aiptek->curSetting.wheel == AIPTEK_WHEEL_DISABLE) { 1527 - return snprintf(buf, PAGE_SIZE, "disable\n"); 1538 + return sysfs_emit(buf, "disable\n"); 1528 1539 } else { 1529 - return snprintf(buf, PAGE_SIZE, "%d\n", 1530 - aiptek->curSetting.wheel); 1540 + return sysfs_emit(buf, "%d\n", aiptek->curSetting.wheel); 1531 1541 } 1532 1542 } 1533 1543 ··· 1556 1568 /* There is nothing useful to display, so a one-line manual 1557 1569 * is in order... 1558 1570 */ 1559 - return snprintf(buf, PAGE_SIZE, 1560 - "Write anything to this file to program your tablet.\n"); 1571 + return sysfs_emit(buf, "Write anything to this file to program your tablet.\n"); 1561 1572 } 1562 1573 1563 1574 static ssize_t ··· 1587 1600 { 1588 1601 struct aiptek *aiptek = dev_get_drvdata(dev); 1589 1602 1590 - return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->features.odmCode); 1603 + return sysfs_emit(buf, "0x%04x\n", aiptek->features.odmCode); 1591 1604 } 1592 1605 1593 1606 static DEVICE_ATTR(odm_code, S_IRUGO, show_tabletODMCode, NULL); ··· 1600 1613 { 1601 1614 struct aiptek *aiptek = dev_get_drvdata(dev); 1602 1615 1603 - return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->features.modelCode); 1616 + return sysfs_emit(buf, "0x%04x\n", aiptek->features.modelCode); 1604 1617 } 1605 1618 1606 1619 static DEVICE_ATTR(model_code, S_IRUGO, show_tabletModelCode, NULL); ··· 1613 1626 { 1614 1627 struct aiptek *aiptek = dev_get_drvdata(dev); 1615 1628 1616 - return snprintf(buf, PAGE_SIZE, "%04x\n", 1617 - aiptek->features.firmwareCode); 1629 + return sysfs_emit(buf, "%04x\n", aiptek->features.firmwareCode); 1618 1630 } 1619 1631 1620 1632 static DEVICE_ATTR(firmware_code, S_IRUGO, show_firmwareCode, NULL);
+1 -1
drivers/input/touchscreen/Kconfig
··· 608 608 609 609 config TOUCHSCREEN_IMX6UL_TSC 610 610 tristate "Freescale i.MX6UL touchscreen controller" 611 - depends on (OF && GPIOLIB) || COMPILE_TEST 611 + depends on ((OF && GPIOLIB) || COMPILE_TEST) && HAS_IOMEM 612 612 help 613 613 Say Y here if you have a Freescale i.MX6UL, and want to 614 614 use the internal touchscreen controller.
+193 -183
drivers/input/touchscreen/ads7846.c
··· 64 64 65 65 struct ads7846_buf { 66 66 u8 cmd; 67 - /* 68 - * This union is a temporary hack. The driver does an in-place 69 - * endianness conversion. This will be cleaned up in the next 70 - * patch. 71 - */ 72 - union { 73 - __be16 data_be16; 74 - u16 data; 75 - }; 67 + __be16 data; 76 68 } __packed; 77 69 78 - 79 - struct ts_event { 80 - bool ignore; 81 - struct ads7846_buf x; 82 - struct ads7846_buf y; 83 - struct ads7846_buf z1; 84 - struct ads7846_buf z2; 70 + struct ads7846_buf_layout { 71 + unsigned int offset; 72 + unsigned int count; 73 + unsigned int skip; 85 74 }; 86 75 87 76 /* ··· 79 90 * systems where main memory is not DMA-coherent (most non-x86 boards). 80 91 */ 81 92 struct ads7846_packet { 82 - struct ts_event tc; 83 - struct ads7846_buf read_x_cmd; 84 - struct ads7846_buf read_y_cmd; 85 - struct ads7846_buf read_z1_cmd; 86 - struct ads7846_buf read_z2_cmd; 93 + unsigned int count; 94 + unsigned int count_skip; 95 + unsigned int cmds; 96 + unsigned int last_cmd_idx; 97 + struct ads7846_buf_layout l[5]; 98 + struct ads7846_buf *rx; 99 + struct ads7846_buf *tx; 100 + 87 101 struct ads7846_buf pwrdown_cmd; 102 + 103 + bool ignore; 104 + u16 x, y, z1, z2; 88 105 }; 89 106 90 107 struct ads7846 { ··· 189 194 #define READ_Y(vref) (READ_12BIT_DFR(y, 1, vref)) 190 195 #define READ_Z1(vref) (READ_12BIT_DFR(z1, 1, vref)) 191 196 #define READ_Z2(vref) (READ_12BIT_DFR(z2, 1, vref)) 192 - 193 197 #define READ_X(vref) (READ_12BIT_DFR(x, 1, vref)) 194 198 #define PWRDOWN (READ_12BIT_DFR(y, 0, 0)) /* LAST */ 195 199 ··· 200 206 201 207 #define REF_ON (READ_12BIT_DFR(x, 1, 1)) 202 208 #define REF_OFF (READ_12BIT_DFR(y, 0, 0)) 209 + 210 + /* Order commands in the most optimal way to reduce Vref switching and 211 + * settling time: 212 + * Measure: X; Vref: X+, X-; IN: Y+ 213 + * Measure: Y; Vref: Y+, Y-; IN: X+ 214 + * Measure: Z1; Vref: Y+, X-; IN: X+ 215 + * Measure: Z2; Vref: Y+, X-; IN: Y- 216 + */ 217 + enum ads7846_cmds { 218 + ADS7846_X, 219 + ADS7846_Y, 220 + ADS7846_Z1, 221 + ADS7846_Z2, 222 + ADS7846_PWDOWN, 223 + }; 203 224 204 225 static int get_pendown_state(struct ads7846 *ts) 205 226 { ··· 698 689 return ADS7846_FILTER_OK; 699 690 } 700 691 701 - static int ads7846_get_value(struct ads7846 *ts, struct spi_message *m) 692 + static int ads7846_get_value(struct ads7846_buf *buf) 702 693 { 703 694 int value; 704 - struct spi_transfer *t = 705 - list_entry(m->transfers.prev, struct spi_transfer, transfer_list); 706 - struct ads7846_buf *buf = t->rx_buf; 707 695 708 - value = be16_to_cpup(&buf->data_be16); 696 + value = be16_to_cpup(&buf->data); 709 697 710 698 /* enforce ADC output is 12 bits width */ 711 699 return (value >> 3) & 0xfff; 712 700 } 713 701 714 - static void ads7846_update_value(struct spi_message *m, int val) 702 + static void ads7846_set_cmd_val(struct ads7846 *ts, enum ads7846_cmds cmd_idx, 703 + u16 val) 715 704 { 716 - struct spi_transfer *t = 717 - list_entry(m->transfers.prev, struct spi_transfer, transfer_list); 718 - struct ads7846_buf *buf = t->rx_buf; 705 + struct ads7846_packet *packet = ts->packet; 719 706 720 - buf->data = val; 707 + switch (cmd_idx) { 708 + case ADS7846_Y: 709 + packet->y = val; 710 + break; 711 + case ADS7846_X: 712 + packet->x = val; 713 + break; 714 + case ADS7846_Z1: 715 + packet->z1 = val; 716 + break; 717 + case ADS7846_Z2: 718 + packet->z2 = val; 719 + break; 720 + default: 721 + WARN_ON_ONCE(1); 722 + } 723 + } 724 + 725 + static u8 ads7846_get_cmd(enum ads7846_cmds cmd_idx, int vref) 726 + { 727 + switch (cmd_idx) { 728 + case ADS7846_Y: 729 + return READ_Y(vref); 730 + case ADS7846_X: 731 + return READ_X(vref); 732 + 733 + /* 7846 specific commands */ 734 + case ADS7846_Z1: 735 + return READ_Z1(vref); 736 + case ADS7846_Z2: 737 + return READ_Z2(vref); 738 + case ADS7846_PWDOWN: 739 + return PWRDOWN; 740 + default: 741 + WARN_ON_ONCE(1); 742 + } 743 + 744 + return 0; 745 + } 746 + 747 + static bool ads7846_cmd_need_settle(enum ads7846_cmds cmd_idx) 748 + { 749 + switch (cmd_idx) { 750 + case ADS7846_X: 751 + case ADS7846_Y: 752 + case ADS7846_Z1: 753 + case ADS7846_Z2: 754 + return true; 755 + case ADS7846_PWDOWN: 756 + return false; 757 + default: 758 + WARN_ON_ONCE(1); 759 + } 760 + 761 + return false; 762 + } 763 + 764 + static int ads7846_filter(struct ads7846 *ts) 765 + { 766 + struct ads7846_packet *packet = ts->packet; 767 + int action; 768 + int val; 769 + unsigned int cmd_idx, b; 770 + 771 + packet->ignore = false; 772 + for (cmd_idx = packet->last_cmd_idx; cmd_idx < packet->cmds - 1; cmd_idx++) { 773 + struct ads7846_buf_layout *l = &packet->l[cmd_idx]; 774 + 775 + packet->last_cmd_idx = cmd_idx; 776 + 777 + for (b = l->skip; b < l->count; b++) { 778 + val = ads7846_get_value(&packet->rx[l->offset + b]); 779 + 780 + action = ts->filter(ts->filter_data, cmd_idx, &val); 781 + if (action == ADS7846_FILTER_REPEAT) { 782 + if (b == l->count - 1) 783 + return -EAGAIN; 784 + } else if (action == ADS7846_FILTER_OK) { 785 + ads7846_set_cmd_val(ts, cmd_idx, val); 786 + break; 787 + } else { 788 + packet->ignore = true; 789 + return 0; 790 + } 791 + } 792 + } 793 + 794 + return 0; 721 795 } 722 796 723 797 static void ads7846_read_state(struct ads7846 *ts) ··· 808 716 struct ads7846_packet *packet = ts->packet; 809 717 struct spi_message *m; 810 718 int msg_idx = 0; 811 - int val; 812 - int action; 813 719 int error; 814 720 815 - while (msg_idx < ts->msg_count) { 721 + packet->last_cmd_idx = 0; 816 722 723 + while (true) { 817 724 ts->wait_for_sync(); 818 725 819 726 m = &ts->msg[msg_idx]; 820 727 error = spi_sync(ts->spi, m); 821 728 if (error) { 822 729 dev_err(&ts->spi->dev, "spi_sync --> %d\n", error); 823 - packet->tc.ignore = true; 730 + packet->ignore = true; 824 731 return; 825 732 } 826 733 827 - /* 828 - * Last message is power down request, no need to convert 829 - * or filter the value. 830 - */ 831 - if (msg_idx < ts->msg_count - 1) { 734 + error = ads7846_filter(ts); 735 + if (error) 736 + continue; 832 737 833 - val = ads7846_get_value(ts, m); 834 - 835 - action = ts->filter(ts->filter_data, msg_idx, &val); 836 - switch (action) { 837 - case ADS7846_FILTER_REPEAT: 838 - continue; 839 - 840 - case ADS7846_FILTER_IGNORE: 841 - packet->tc.ignore = true; 842 - msg_idx = ts->msg_count - 1; 843 - continue; 844 - 845 - case ADS7846_FILTER_OK: 846 - ads7846_update_value(m, val); 847 - packet->tc.ignore = false; 848 - msg_idx++; 849 - break; 850 - 851 - default: 852 - BUG(); 853 - } 854 - } else { 855 - msg_idx++; 856 - } 738 + return; 857 739 } 858 740 } 859 741 ··· 837 771 unsigned int Rt; 838 772 u16 x, y, z1, z2; 839 773 840 - /* 841 - * ads7846_get_value() does in-place conversion (including byte swap) 842 - * from on-the-wire format as part of debouncing to get stable 843 - * readings. 844 - */ 845 - x = packet->tc.x.data; 846 - y = packet->tc.y.data; 774 + x = packet->x; 775 + y = packet->y; 847 776 if (ts->model == 7845) { 848 777 z1 = 0; 849 778 z2 = 0; 850 779 } else { 851 - z1 = packet->tc.z1.data; 852 - z2 = packet->tc.z2.data; 780 + z1 = packet->z1; 781 + z2 = packet->z2; 853 782 } 854 783 855 784 /* range filtering */ ··· 877 816 * the maximum. Don't report it to user space, repeat at least 878 817 * once more the measurement 879 818 */ 880 - if (packet->tc.ignore || Rt > ts->pressure_max) { 819 + if (packet->ignore || Rt > ts->pressure_max) { 881 820 dev_vdbg(&ts->spi->dev, "ignored %d pressure %d\n", 882 - packet->tc.ignore, Rt); 821 + packet->ignore, Rt); 883 822 return; 884 823 } 885 824 ··· 1040 979 * Set up the transfers to read touchscreen state; this assumes we 1041 980 * use formula #2 for pressure, not #3. 1042 981 */ 1043 - static void ads7846_setup_spi_msg(struct ads7846 *ts, 982 + static int ads7846_setup_spi_msg(struct ads7846 *ts, 1044 983 const struct ads7846_platform_data *pdata) 1045 984 { 1046 985 struct spi_message *m = &ts->msg[0]; 1047 986 struct spi_transfer *x = ts->xfer; 1048 987 struct ads7846_packet *packet = ts->packet; 1049 988 int vref = pdata->keep_vref_on; 989 + unsigned int count, offset = 0; 990 + unsigned int cmd_idx, b; 991 + unsigned long time; 992 + size_t size = 0; 993 + 994 + /* time per bit */ 995 + time = NSEC_PER_SEC / ts->spi->max_speed_hz; 996 + 997 + count = pdata->settle_delay_usecs * NSEC_PER_USEC / time; 998 + packet->count_skip = DIV_ROUND_UP(count, 24); 999 + 1000 + if (ts->debounce_max && ts->debounce_rep) 1001 + /* ads7846_debounce_filter() is making ts->debounce_rep + 2 1002 + * reads. So we need to get all samples for normal case. */ 1003 + packet->count = ts->debounce_rep + 2; 1004 + else 1005 + packet->count = 1; 1006 + 1007 + if (ts->model == 7846) 1008 + packet->cmds = 5; /* x, y, z1, z2, pwdown */ 1009 + else 1010 + packet->cmds = 3; /* x, y, pwdown */ 1011 + 1012 + for (cmd_idx = 0; cmd_idx < packet->cmds; cmd_idx++) { 1013 + struct ads7846_buf_layout *l = &packet->l[cmd_idx]; 1014 + unsigned int max_count; 1015 + 1016 + if (ads7846_cmd_need_settle(cmd_idx)) 1017 + max_count = packet->count + packet->count_skip; 1018 + else 1019 + max_count = packet->count; 1020 + 1021 + l->offset = offset; 1022 + offset += max_count; 1023 + l->count = max_count; 1024 + l->skip = packet->count_skip; 1025 + size += sizeof(*packet->tx) * max_count; 1026 + } 1027 + 1028 + packet->tx = devm_kzalloc(&ts->spi->dev, size, GFP_KERNEL); 1029 + if (!packet->tx) 1030 + return -ENOMEM; 1031 + 1032 + packet->rx = devm_kzalloc(&ts->spi->dev, size, GFP_KERNEL); 1033 + if (!packet->rx) 1034 + return -ENOMEM; 1050 1035 1051 1036 if (ts->model == 7873) { 1052 1037 /* ··· 1108 1001 spi_message_init(m); 1109 1002 m->context = ts; 1110 1003 1111 - packet->read_y_cmd.cmd = READ_Y(vref); 1112 - x->tx_buf = &packet->read_y_cmd; 1113 - x->rx_buf = &packet->tc.y; 1114 - x->len = 3; 1115 - spi_message_add_tail(x, m); 1004 + for (cmd_idx = 0; cmd_idx < packet->cmds; cmd_idx++) { 1005 + struct ads7846_buf_layout *l = &packet->l[cmd_idx]; 1006 + u8 cmd = ads7846_get_cmd(cmd_idx, vref); 1116 1007 1117 - /* 1118 - * The first sample after switching drivers can be low quality; 1119 - * optionally discard it, using a second one after the signals 1120 - * have had enough time to stabilize. 1121 - */ 1122 - if (pdata->settle_delay_usecs) { 1123 - x->delay.value = pdata->settle_delay_usecs; 1124 - x->delay.unit = SPI_DELAY_UNIT_USECS; 1125 - x++; 1126 - 1127 - x->tx_buf = &packet->read_y_cmd; 1128 - x->rx_buf = &packet->tc.y; 1129 - x->len = 3; 1130 - spi_message_add_tail(x, m); 1008 + for (b = 0; b < l->count; b++) 1009 + packet->tx[l->offset + b].cmd = cmd; 1131 1010 } 1132 1011 1133 - ts->msg_count++; 1134 - m++; 1135 - spi_message_init(m); 1136 - m->context = ts; 1137 - 1138 - /* turn y- off, x+ on, then leave in lowpower */ 1139 - x++; 1140 - packet->read_x_cmd.cmd = READ_X(vref); 1141 - x->tx_buf = &packet->read_x_cmd; 1142 - x->rx_buf = &packet->tc.x; 1143 - x->len = 3; 1012 + x->tx_buf = packet->tx; 1013 + x->rx_buf = packet->rx; 1014 + x->len = size; 1144 1015 spi_message_add_tail(x, m); 1145 1016 1146 - /* ... maybe discard first sample ... */ 1147 - if (pdata->settle_delay_usecs) { 1148 - x->delay.value = pdata->settle_delay_usecs; 1149 - x->delay.unit = SPI_DELAY_UNIT_USECS; 1150 - 1151 - x++; 1152 - x->tx_buf = &packet->read_x_cmd; 1153 - x->rx_buf = &packet->tc.x; 1154 - x->len = 3; 1155 - spi_message_add_tail(x, m); 1156 - } 1157 - 1158 - /* turn y+ off, x- on; we'll use formula #2 */ 1159 - if (ts->model == 7846) { 1160 - ts->msg_count++; 1161 - m++; 1162 - spi_message_init(m); 1163 - m->context = ts; 1164 - 1165 - x++; 1166 - packet->read_z1_cmd.cmd = READ_Z1(vref); 1167 - x->tx_buf = &packet->read_z1_cmd; 1168 - x->rx_buf = &packet->tc.z1; 1169 - x->len = 3; 1170 - spi_message_add_tail(x, m); 1171 - 1172 - /* ... maybe discard first sample ... */ 1173 - if (pdata->settle_delay_usecs) { 1174 - x->delay.value = pdata->settle_delay_usecs; 1175 - x->delay.unit = SPI_DELAY_UNIT_USECS; 1176 - 1177 - x++; 1178 - x->tx_buf = &packet->read_z1_cmd; 1179 - x->rx_buf = &packet->tc.z1; 1180 - x->len = 3; 1181 - spi_message_add_tail(x, m); 1182 - } 1183 - 1184 - ts->msg_count++; 1185 - m++; 1186 - spi_message_init(m); 1187 - m->context = ts; 1188 - 1189 - x++; 1190 - packet->read_z2_cmd.cmd = READ_Z2(vref); 1191 - x->tx_buf = &packet->read_z2_cmd; 1192 - x->rx_buf = &packet->tc.z2; 1193 - x->len = 3; 1194 - spi_message_add_tail(x, m); 1195 - 1196 - /* ... maybe discard first sample ... */ 1197 - if (pdata->settle_delay_usecs) { 1198 - x->delay.value = pdata->settle_delay_usecs; 1199 - x->delay.unit = SPI_DELAY_UNIT_USECS; 1200 - 1201 - x++; 1202 - x->tx_buf = &packet->read_z2_cmd; 1203 - x->rx_buf = &packet->tc.z2; 1204 - x->len = 3; 1205 - spi_message_add_tail(x, m); 1206 - } 1207 - } 1208 - 1209 - /* power down */ 1210 - ts->msg_count++; 1211 - m++; 1212 - spi_message_init(m); 1213 - m->context = ts; 1214 - 1215 - x++; 1216 - packet->pwrdown_cmd.cmd = PWRDOWN; 1217 - x->tx_buf = &packet->pwrdown_cmd; 1218 - x->len = 3; 1219 - 1220 - CS_CHANGE(*x); 1221 - spi_message_add_tail(x, m); 1017 + return 0; 1222 1018 } 1223 1019 1224 1020 #ifdef CONFIG_OF
+134 -17
drivers/input/touchscreen/elants_i2c.c
··· 56 56 #define QUEUE_HEADER_SINGLE 0x62 57 57 #define QUEUE_HEADER_NORMAL 0X63 58 58 #define QUEUE_HEADER_WAIT 0x64 59 + #define QUEUE_HEADER_NORMAL2 0x66 59 60 60 61 /* Command header definition */ 61 62 #define CMD_HEADER_WRITE 0x54 ··· 70 69 #define CMD_HEADER_REK 0x66 71 70 72 71 /* FW position data */ 72 + #define PACKET_SIZE_OLD 40 73 73 #define PACKET_SIZE 55 74 74 #define MAX_CONTACT_NUM 10 75 75 #define FW_POS_HEADER 0 ··· 92 90 /* FW read command, 0x53 0x?? 0x0, 0x01 */ 93 91 #define E_ELAN_INFO_FW_VER 0x00 94 92 #define E_ELAN_INFO_BC_VER 0x10 93 + #define E_ELAN_INFO_X_RES 0x60 94 + #define E_ELAN_INFO_Y_RES 0x63 95 95 #define E_ELAN_INFO_REK 0xD0 96 96 #define E_ELAN_INFO_TEST_VER 0xE0 97 97 #define E_ELAN_INFO_FW_ID 0xF0 ··· 115 111 116 112 #define ELAN_POWERON_DELAY_USEC 500 117 113 #define ELAN_RESET_DELAY_MSEC 20 114 + 115 + enum elants_chip_id { 116 + EKTH3500, 117 + EKTF3624, 118 + }; 118 119 119 120 enum elants_state { 120 121 ELAN_STATE_NORMAL, ··· 152 143 unsigned int y_res; 153 144 unsigned int x_max; 154 145 unsigned int y_max; 146 + unsigned int phy_x; 147 + unsigned int phy_y; 155 148 struct touchscreen_properties prop; 156 149 157 150 enum elants_state state; 151 + enum elants_chip_id chip_id; 158 152 enum elants_iap_mode iap_mode; 159 153 160 154 /* Guards against concurrent access to the device via sysfs */ ··· 445 433 return 0; 446 434 } 447 435 448 - static int elants_i2c_query_ts_info(struct elants_data *ts) 436 + static int elants_i2c_query_ts_info_ektf(struct elants_data *ts) 437 + { 438 + struct i2c_client *client = ts->client; 439 + int error; 440 + u8 resp[4]; 441 + u16 phy_x, phy_y; 442 + const u8 get_xres_cmd[] = { 443 + CMD_HEADER_READ, E_ELAN_INFO_X_RES, 0x00, 0x00 444 + }; 445 + const u8 get_yres_cmd[] = { 446 + CMD_HEADER_READ, E_ELAN_INFO_Y_RES, 0x00, 0x00 447 + }; 448 + 449 + /* Get X/Y size in mm */ 450 + error = elants_i2c_execute_command(client, get_xres_cmd, 451 + sizeof(get_xres_cmd), 452 + resp, sizeof(resp), 1, 453 + "get X size"); 454 + if (error) 455 + return error; 456 + 457 + phy_x = resp[2] | ((resp[3] & 0xF0) << 4); 458 + 459 + error = elants_i2c_execute_command(client, get_yres_cmd, 460 + sizeof(get_yres_cmd), 461 + resp, sizeof(resp), 1, 462 + "get Y size"); 463 + if (error) 464 + return error; 465 + 466 + phy_y = resp[2] | ((resp[3] & 0xF0) << 4); 467 + 468 + dev_dbg(&client->dev, "phy_x=%d, phy_y=%d\n", phy_x, phy_y); 469 + 470 + ts->phy_x = phy_x; 471 + ts->phy_y = phy_y; 472 + 473 + /* eKTF doesn't report max size, set it to default values */ 474 + ts->x_max = 2240 - 1; 475 + ts->y_max = 1408 - 1; 476 + 477 + return 0; 478 + } 479 + 480 + static int elants_i2c_query_ts_info_ekth(struct elants_data *ts) 449 481 { 450 482 struct i2c_client *client = ts->client; 451 483 int error; ··· 564 508 ts->x_res = DIV_ROUND_CLOSEST(ts->x_max, phy_x); 565 509 ts->y_max = ELAN_TS_RESOLUTION(cols, osr); 566 510 ts->y_res = DIV_ROUND_CLOSEST(ts->y_max, phy_y); 511 + ts->phy_x = phy_x; 512 + ts->phy_y = phy_y; 567 513 } 568 514 569 515 return 0; ··· 645 587 error = elants_i2c_query_fw_version(ts); 646 588 if (!error) 647 589 error = elants_i2c_query_test_version(ts); 648 - if (!error) 649 - error = elants_i2c_query_ts_info(ts); 590 + 591 + switch (ts->chip_id) { 592 + case EKTH3500: 593 + if (!error) 594 + error = elants_i2c_query_ts_info_ekth(ts); 595 + break; 596 + case EKTF3624: 597 + if (!error) 598 + error = elants_i2c_query_ts_info_ektf(ts); 599 + break; 600 + default: 601 + BUG(); 602 + } 650 603 651 604 if (error) 652 605 ts->iap_mode = ELAN_IAP_RECOVERY; ··· 922 853 * Event reporting. 923 854 */ 924 855 925 - static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf) 856 + static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf, 857 + size_t packet_size) 926 858 { 927 859 struct input_dev *input = ts->input; 928 860 unsigned int n_fingers; ··· 950 880 pos = &buf[FW_POS_XY + i * 3]; 951 881 x = (((u16)pos[0] & 0xf0) << 4) | pos[1]; 952 882 y = (((u16)pos[0] & 0x0f) << 8) | pos[2]; 953 - p = buf[FW_POS_PRESSURE + i]; 954 - w = buf[FW_POS_WIDTH + i]; 883 + 884 + /* 885 + * eKTF3624 may have use "old" touch-report format, 886 + * depending on a device and TS firmware version. 887 + * For example, ASUS Transformer devices use the "old" 888 + * format, while ASUS Nexus 7 uses the "new" formant. 889 + */ 890 + if (packet_size == PACKET_SIZE_OLD && 891 + ts->chip_id == EKTF3624) { 892 + w = buf[FW_POS_WIDTH + i / 2]; 893 + w >>= 4 * (~i & 1); 894 + w |= w << 4; 895 + w |= !w; 896 + p = w; 897 + } else { 898 + p = buf[FW_POS_PRESSURE + i]; 899 + w = buf[FW_POS_WIDTH + i]; 900 + } 955 901 956 902 dev_dbg(&ts->client->dev, "i=%d x=%d y=%d p=%d w=%d\n", 957 903 i, x, y, p, w); ··· 999 913 return checksum; 1000 914 } 1001 915 1002 - static void elants_i2c_event(struct elants_data *ts, u8 *buf) 916 + static void elants_i2c_event(struct elants_data *ts, u8 *buf, 917 + size_t packet_size) 1003 918 { 1004 919 u8 checksum = elants_i2c_calculate_checksum(buf); 1005 920 ··· 1014 927 "%s: unknown packet type: %02x\n", 1015 928 __func__, buf[FW_POS_HEADER]); 1016 929 else 1017 - elants_i2c_mt_event(ts, buf); 930 + elants_i2c_mt_event(ts, buf, packet_size); 1018 931 } 1019 932 1020 933 static irqreturn_t elants_i2c_irq(int irq, void *_dev) ··· 1057 970 switch (ts->buf[FW_HDR_TYPE]) { 1058 971 case CMD_HEADER_HELLO: 1059 972 case CMD_HEADER_RESP: 1060 - case CMD_HEADER_REK: 1061 973 break; 1062 974 1063 975 case QUEUE_HEADER_WAIT: ··· 1071 985 break; 1072 986 1073 987 case QUEUE_HEADER_SINGLE: 1074 - elants_i2c_event(ts, &ts->buf[HEADER_SIZE]); 988 + elants_i2c_event(ts, &ts->buf[HEADER_SIZE], 989 + ts->buf[FW_HDR_LENGTH]); 1075 990 break; 991 + 992 + case QUEUE_HEADER_NORMAL2: /* CMD_HEADER_REK */ 993 + /* 994 + * Depending on firmware version, eKTF3624 touchscreens 995 + * may utilize one of these opcodes for the touch events: 996 + * 0x63 (NORMAL) and 0x66 (NORMAL2). The 0x63 is used by 997 + * older firmware version and differs from 0x66 such that 998 + * touch pressure value needs to be adjusted. The 0x66 999 + * opcode of newer firmware is equal to 0x63 of eKTH3500. 1000 + */ 1001 + if (ts->chip_id != EKTF3624) 1002 + break; 1003 + 1004 + fallthrough; 1076 1005 1077 1006 case QUEUE_HEADER_NORMAL: 1078 1007 report_count = ts->buf[FW_HDR_COUNT]; ··· 1099 998 } 1100 999 1101 1000 report_len = ts->buf[FW_HDR_LENGTH] / report_count; 1102 - if (report_len != PACKET_SIZE) { 1001 + 1002 + if (report_len == PACKET_SIZE_OLD && 1003 + ts->chip_id == EKTF3624) { 1004 + dev_dbg_once(&client->dev, 1005 + "using old report format\n"); 1006 + } else if (report_len != PACKET_SIZE) { 1103 1007 dev_err(&client->dev, 1104 1008 "mismatching report length: %*ph\n", 1105 1009 HEADER_SIZE, ts->buf); ··· 1113 1007 1114 1008 for (i = 0; i < report_count; i++) { 1115 1009 u8 *buf = ts->buf + HEADER_SIZE + 1116 - i * PACKET_SIZE; 1117 - elants_i2c_event(ts, buf); 1010 + i * report_len; 1011 + elants_i2c_event(ts, buf, report_len); 1118 1012 } 1119 1013 break; 1120 1014 ··· 1356 1250 init_completion(&ts->cmd_done); 1357 1251 1358 1252 ts->client = client; 1253 + ts->chip_id = (enum elants_chip_id)id->driver_data; 1359 1254 i2c_set_clientdata(client, ts); 1360 1255 1361 1256 ts->vcc33 = devm_regulator_get(&client->dev, "vcc33"); ··· 1438 1331 input_set_abs_params(ts->input, ABS_MT_PRESSURE, 0, 255, 0, 0); 1439 1332 input_set_abs_params(ts->input, ABS_MT_TOOL_TYPE, 1440 1333 0, MT_TOOL_PALM, 0, 0); 1334 + 1335 + touchscreen_parse_properties(ts->input, true, &ts->prop); 1336 + 1337 + if (ts->chip_id == EKTF3624) { 1338 + /* calculate resolution from size */ 1339 + ts->x_res = DIV_ROUND_CLOSEST(ts->prop.max_x, ts->phy_x); 1340 + ts->y_res = DIV_ROUND_CLOSEST(ts->prop.max_y, ts->phy_y); 1341 + } 1342 + 1441 1343 input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->x_res); 1442 1344 input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->y_res); 1443 1345 if (ts->major_res > 0) 1444 1346 input_abs_set_res(ts->input, ABS_MT_TOUCH_MAJOR, ts->major_res); 1445 - 1446 - touchscreen_parse_properties(ts->input, true, &ts->prop); 1447 1347 1448 1348 error = input_mt_init_slots(ts->input, MAX_CONTACT_NUM, 1449 1349 INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED); ··· 1580 1466 elants_i2c_suspend, elants_i2c_resume); 1581 1467 1582 1468 static const struct i2c_device_id elants_i2c_id[] = { 1583 - { DEVICE_NAME, 0 }, 1469 + { DEVICE_NAME, EKTH3500 }, 1470 + { "ekth3500", EKTH3500 }, 1471 + { "ektf3624", EKTF3624 }, 1584 1472 { } 1585 1473 }; 1586 1474 MODULE_DEVICE_TABLE(i2c, elants_i2c_id); 1587 1475 1588 1476 #ifdef CONFIG_ACPI 1589 1477 static const struct acpi_device_id elants_acpi_id[] = { 1590 - { "ELAN0001", 0 }, 1478 + { "ELAN0001", EKTH3500 }, 1591 1479 { } 1592 1480 }; 1593 1481 MODULE_DEVICE_TABLE(acpi, elants_acpi_id); ··· 1598 1482 #ifdef CONFIG_OF 1599 1483 static const struct of_device_id elants_of_match[] = { 1600 1484 { .compatible = "elan,ekth3500" }, 1485 + { .compatible = "elan,ektf3624" }, 1601 1486 { /* sentinel */ } 1602 1487 }; 1603 1488 MODULE_DEVICE_TABLE(of, elants_of_match);
+3 -1
drivers/input/touchscreen/elo.c
··· 341 341 switch (elo->id) { 342 342 343 343 case 0: /* 10-byte protocol */ 344 - if (elo_setup_10(elo)) 344 + if (elo_setup_10(elo)) { 345 + err = -EIO; 345 346 goto fail3; 347 + } 346 348 347 349 break; 348 350
+93 -120
drivers/input/touchscreen/iqs5xx.c
··· 2 2 /* 3 3 * Azoteq IQS550/572/525 Trackpad/Touchscreen Controller 4 4 * 5 - * Copyright (C) 2018 6 - * Author: Jeff LaBundy <jeff@labundy.com> 5 + * Copyright (C) 2018 Jeff LaBundy <jeff@labundy.com> 7 6 * 8 7 * These devices require firmware exported from a PC-based configuration tool 9 8 * made available by the vendor. Firmware files may be pushed to the device's ··· 11 12 * Link to PC-based configuration tool and data sheet: http://www.azoteq.com/ 12 13 */ 13 14 15 + #include <linux/bits.h> 14 16 #include <linux/delay.h> 15 17 #include <linux/device.h> 16 18 #include <linux/err.h> ··· 30 30 31 31 #define IQS5XX_FW_FILE_LEN 64 32 32 #define IQS5XX_NUM_RETRIES 10 33 - #define IQS5XX_NUM_POINTS 256 34 33 #define IQS5XX_NUM_CONTACTS 5 35 34 #define IQS5XX_WR_BYTES_MAX 2 35 + #define IQS5XX_XY_RES_MAX 0xFFFE 36 36 37 37 #define IQS5XX_PROD_NUM_IQS550 40 38 38 #define IQS5XX_PROD_NUM_IQS572 58 ··· 41 41 #define IQS5XX_PROJ_NUM_B000 15 42 42 #define IQS5XX_MAJOR_VER_MIN 2 43 43 44 - #define IQS5XX_RESUME 0x00 45 - #define IQS5XX_SUSPEND 0x01 44 + #define IQS5XX_SHOW_RESET BIT(7) 45 + #define IQS5XX_ACK_RESET BIT(7) 46 46 47 - #define IQS5XX_SW_INPUT_EVENT 0x10 48 - #define IQS5XX_SETUP_COMPLETE 0x40 49 - #define IQS5XX_EVENT_MODE 0x01 50 - #define IQS5XX_TP_EVENT 0x04 47 + #define IQS5XX_SUSPEND BIT(0) 48 + #define IQS5XX_RESUME 0 51 49 52 - #define IQS5XX_FLIP_X 0x01 53 - #define IQS5XX_FLIP_Y 0x02 54 - #define IQS5XX_SWITCH_XY_AXIS 0x04 50 + #define IQS5XX_SETUP_COMPLETE BIT(6) 51 + #define IQS5XX_WDT BIT(5) 52 + #define IQS5XX_ALP_REATI BIT(3) 53 + #define IQS5XX_REATI BIT(2) 54 + 55 + #define IQS5XX_TP_EVENT BIT(2) 56 + #define IQS5XX_EVENT_MODE BIT(0) 55 57 56 58 #define IQS5XX_PROD_NUM 0x0000 57 - #define IQS5XX_ABS_X 0x0016 58 - #define IQS5XX_ABS_Y 0x0018 59 + #define IQS5XX_SYS_INFO0 0x000F 60 + #define IQS5XX_SYS_INFO1 0x0010 59 61 #define IQS5XX_SYS_CTRL0 0x0431 60 62 #define IQS5XX_SYS_CTRL1 0x0432 61 63 #define IQS5XX_SYS_CFG0 0x058E 62 64 #define IQS5XX_SYS_CFG1 0x058F 63 - #define IQS5XX_TOTAL_RX 0x063D 64 - #define IQS5XX_TOTAL_TX 0x063E 65 - #define IQS5XX_XY_CFG0 0x0669 66 65 #define IQS5XX_X_RES 0x066E 67 66 #define IQS5XX_Y_RES 0x0670 68 67 #define IQS5XX_CHKSM 0x83C0 ··· 98 99 struct i2c_client *client; 99 100 struct input_dev *input; 100 101 struct gpio_desc *reset_gpio; 102 + struct touchscreen_properties prop; 101 103 struct mutex lock; 102 104 u8 bl_status; 103 105 }; ··· 124 124 __be16 abs_y; 125 125 __be16 strength; 126 126 u8 area; 127 + } __packed; 128 + 129 + struct iqs5xx_status { 130 + u8 sys_info[2]; 131 + u8 num_active; 132 + __be16 rel_x; 133 + __be16 rel_y; 134 + struct iqs5xx_touch_data touch_data[IQS5XX_NUM_CONTACTS]; 127 135 } __packed; 128 136 129 137 static int iqs5xx_read_burst(struct i2c_client *client, ··· 188 180 *val = be16_to_cpu(val_buf); 189 181 190 182 return 0; 191 - } 192 - 193 - static int iqs5xx_read_byte(struct i2c_client *client, u16 reg, u8 *val) 194 - { 195 - return iqs5xx_read_burst(client, reg, val, sizeof(*val)); 196 183 } 197 184 198 185 static int iqs5xx_write_burst(struct i2c_client *client, ··· 340 337 */ 341 338 for (i = 0; i < IQS5XX_BL_ATTEMPTS; i++) { 342 339 iqs5xx_reset(client); 340 + usleep_range(350, 400); 343 341 344 342 for (j = 0; j < IQS5XX_NUM_RETRIES; j++) { 345 343 error = iqs5xx_bl_cmd(client, IQS5XX_BL_CMD_VER, 0); 346 - if (!error || error == -EINVAL) 347 - return error; 344 + if (!error) 345 + usleep_range(10000, 10100); 346 + else if (error != -EINVAL) 347 + continue; 348 + 349 + return error; 348 350 } 349 351 } 350 352 ··· 489 481 static int iqs5xx_axis_init(struct i2c_client *client) 490 482 { 491 483 struct iqs5xx_private *iqs5xx = i2c_get_clientdata(client); 492 - struct touchscreen_properties prop; 484 + struct touchscreen_properties *prop = &iqs5xx->prop; 493 485 struct input_dev *input; 486 + u16 max_x, max_y; 494 487 int error; 495 - u16 max_x, max_x_hw; 496 - u16 max_y, max_y_hw; 497 - u8 val; 498 488 499 489 if (!iqs5xx->input) { 500 490 input = devm_input_allocate_device(&client->dev); ··· 512 506 iqs5xx->input = input; 513 507 } 514 508 515 - touchscreen_parse_properties(iqs5xx->input, true, &prop); 516 - 517 - error = iqs5xx_read_byte(client, IQS5XX_TOTAL_RX, &val); 518 - if (error) 519 - return error; 520 - max_x_hw = (val - 1) * IQS5XX_NUM_POINTS; 521 - 522 - error = iqs5xx_read_byte(client, IQS5XX_TOTAL_TX, &val); 523 - if (error) 524 - return error; 525 - max_y_hw = (val - 1) * IQS5XX_NUM_POINTS; 526 - 527 - error = iqs5xx_read_byte(client, IQS5XX_XY_CFG0, &val); 509 + error = iqs5xx_read_word(client, IQS5XX_X_RES, &max_x); 528 510 if (error) 529 511 return error; 530 512 531 - if (val & IQS5XX_SWITCH_XY_AXIS) 532 - swap(max_x_hw, max_y_hw); 533 - 534 - if (prop.swap_x_y) 535 - val ^= IQS5XX_SWITCH_XY_AXIS; 536 - 537 - if (prop.invert_x) 538 - val ^= prop.swap_x_y ? IQS5XX_FLIP_Y : IQS5XX_FLIP_X; 539 - 540 - if (prop.invert_y) 541 - val ^= prop.swap_x_y ? IQS5XX_FLIP_X : IQS5XX_FLIP_Y; 542 - 543 - error = iqs5xx_write_byte(client, IQS5XX_XY_CFG0, val); 513 + error = iqs5xx_read_word(client, IQS5XX_Y_RES, &max_y); 544 514 if (error) 545 515 return error; 546 516 547 - if (prop.max_x > max_x_hw) { 517 + input_abs_set_max(iqs5xx->input, ABS_MT_POSITION_X, max_x); 518 + input_abs_set_max(iqs5xx->input, ABS_MT_POSITION_Y, max_y); 519 + 520 + touchscreen_parse_properties(iqs5xx->input, true, prop); 521 + 522 + if (prop->max_x > IQS5XX_XY_RES_MAX) { 548 523 dev_err(&client->dev, "Invalid maximum x-coordinate: %u > %u\n", 549 - prop.max_x, max_x_hw); 524 + prop->max_x, IQS5XX_XY_RES_MAX); 550 525 return -EINVAL; 551 - } else if (prop.max_x == 0) { 552 - error = iqs5xx_read_word(client, IQS5XX_X_RES, &max_x); 526 + } else if (prop->max_x != max_x) { 527 + error = iqs5xx_write_word(client, IQS5XX_X_RES, prop->max_x); 553 528 if (error) 554 529 return error; 555 - 556 - input_abs_set_max(iqs5xx->input, 557 - prop.swap_x_y ? ABS_MT_POSITION_Y : 558 - ABS_MT_POSITION_X, 559 - max_x); 560 - } else { 561 - max_x = (u16)prop.max_x; 562 530 } 563 531 564 - if (prop.max_y > max_y_hw) { 532 + if (prop->max_y > IQS5XX_XY_RES_MAX) { 565 533 dev_err(&client->dev, "Invalid maximum y-coordinate: %u > %u\n", 566 - prop.max_y, max_y_hw); 534 + prop->max_y, IQS5XX_XY_RES_MAX); 567 535 return -EINVAL; 568 - } else if (prop.max_y == 0) { 569 - error = iqs5xx_read_word(client, IQS5XX_Y_RES, &max_y); 536 + } else if (prop->max_y != max_y) { 537 + error = iqs5xx_write_word(client, IQS5XX_Y_RES, prop->max_y); 570 538 if (error) 571 539 return error; 572 - 573 - input_abs_set_max(iqs5xx->input, 574 - prop.swap_x_y ? ABS_MT_POSITION_X : 575 - ABS_MT_POSITION_Y, 576 - max_y); 577 - } else { 578 - max_y = (u16)prop.max_y; 579 540 } 580 - 581 - /* 582 - * Write horizontal and vertical resolution to the device in case its 583 - * original defaults were overridden or swapped as per the properties 584 - * specified in the device tree. 585 - */ 586 - error = iqs5xx_write_word(client, 587 - prop.swap_x_y ? IQS5XX_Y_RES : IQS5XX_X_RES, 588 - max_x); 589 - if (error) 590 - return error; 591 - 592 - error = iqs5xx_write_word(client, 593 - prop.swap_x_y ? IQS5XX_X_RES : IQS5XX_Y_RES, 594 - max_y); 595 - if (error) 596 - return error; 597 541 598 542 error = input_mt_init_slots(iqs5xx->input, IQS5XX_NUM_CONTACTS, 599 543 INPUT_MT_DIRECT); ··· 559 603 struct iqs5xx_private *iqs5xx = i2c_get_clientdata(client); 560 604 struct iqs5xx_dev_id_info *dev_id_info; 561 605 int error; 562 - u8 val; 563 606 u8 buf[sizeof(*dev_id_info) + 1]; 564 607 565 608 error = iqs5xx_read_burst(client, IQS5XX_PROD_NUM, ··· 621 666 if (error) 622 667 return error; 623 668 624 - error = iqs5xx_read_byte(client, IQS5XX_SYS_CFG0, &val); 669 + error = iqs5xx_write_byte(client, IQS5XX_SYS_CTRL0, IQS5XX_ACK_RESET); 625 670 if (error) 626 671 return error; 627 672 628 - val |= IQS5XX_SETUP_COMPLETE; 629 - val &= ~IQS5XX_SW_INPUT_EVENT; 630 - error = iqs5xx_write_byte(client, IQS5XX_SYS_CFG0, val); 673 + error = iqs5xx_write_byte(client, IQS5XX_SYS_CFG0, 674 + IQS5XX_SETUP_COMPLETE | IQS5XX_WDT | 675 + IQS5XX_ALP_REATI | IQS5XX_REATI); 631 676 if (error) 632 677 return error; 633 678 634 - val = IQS5XX_TP_EVENT | IQS5XX_EVENT_MODE; 635 - error = iqs5xx_write_byte(client, IQS5XX_SYS_CFG1, val); 679 + error = iqs5xx_write_byte(client, IQS5XX_SYS_CFG1, 680 + IQS5XX_TP_EVENT | IQS5XX_EVENT_MODE); 636 681 if (error) 637 682 return error; 638 683 ··· 643 688 iqs5xx->bl_status = dev_id_info->bl_status; 644 689 645 690 /* 646 - * Closure of the first communication window that appears following the 647 - * release of reset appears to kick off an initialization period during 648 - * which further communication is met with clock stretching. The return 649 - * from this function is delayed so that further communication attempts 650 - * avoid this period. 691 + * The following delay allows ATI to complete before the open and close 692 + * callbacks are free to elicit I2C communication. Any attempts to read 693 + * from or write to the device during this time may face extended clock 694 + * stretching and prompt the I2C controller to report an error. 651 695 */ 652 - msleep(100); 696 + msleep(250); 653 697 654 698 return 0; 655 699 } ··· 656 702 static irqreturn_t iqs5xx_irq(int irq, void *data) 657 703 { 658 704 struct iqs5xx_private *iqs5xx = data; 659 - struct iqs5xx_touch_data touch_data[IQS5XX_NUM_CONTACTS]; 705 + struct iqs5xx_status status; 660 706 struct i2c_client *client = iqs5xx->client; 661 707 struct input_dev *input = iqs5xx->input; 662 708 int error, i; ··· 669 715 if (iqs5xx->bl_status == IQS5XX_BL_STATUS_RESET) 670 716 return IRQ_NONE; 671 717 672 - error = iqs5xx_read_burst(client, IQS5XX_ABS_X, 673 - touch_data, sizeof(touch_data)); 718 + error = iqs5xx_read_burst(client, IQS5XX_SYS_INFO0, 719 + &status, sizeof(status)); 674 720 if (error) 675 721 return IRQ_NONE; 676 722 677 - for (i = 0; i < ARRAY_SIZE(touch_data); i++) { 678 - u16 pressure = be16_to_cpu(touch_data[i].strength); 723 + if (status.sys_info[0] & IQS5XX_SHOW_RESET) { 724 + dev_err(&client->dev, "Unexpected device reset\n"); 725 + 726 + error = iqs5xx_dev_init(client); 727 + if (error) { 728 + dev_err(&client->dev, 729 + "Failed to re-initialize device: %d\n", error); 730 + return IRQ_NONE; 731 + } 732 + 733 + return IRQ_HANDLED; 734 + } 735 + 736 + for (i = 0; i < ARRAY_SIZE(status.touch_data); i++) { 737 + struct iqs5xx_touch_data *touch_data = &status.touch_data[i]; 738 + u16 pressure = be16_to_cpu(touch_data->strength); 679 739 680 740 input_mt_slot(input, i); 681 741 if (input_mt_report_slot_state(input, MT_TOOL_FINGER, 682 742 pressure != 0)) { 683 - input_report_abs(input, ABS_MT_POSITION_X, 684 - be16_to_cpu(touch_data[i].abs_x)); 685 - input_report_abs(input, ABS_MT_POSITION_Y, 686 - be16_to_cpu(touch_data[i].abs_y)); 743 + touchscreen_report_pos(iqs5xx->input, &iqs5xx->prop, 744 + be16_to_cpu(touch_data->abs_x), 745 + be16_to_cpu(touch_data->abs_y), 746 + true); 687 747 input_report_abs(input, ABS_MT_PRESSURE, pressure); 688 748 } 689 749 } ··· 852 884 static int iqs5xx_fw_file_write(struct i2c_client *client, const char *fw_file) 853 885 { 854 886 struct iqs5xx_private *iqs5xx = i2c_get_clientdata(client); 855 - int error; 887 + int error, error_bl = 0; 856 888 u8 *pmap; 857 889 858 890 if (iqs5xx->bl_status == IQS5XX_BL_STATUS_NONE) ··· 906 938 usleep_range(10000, 10100); 907 939 } 908 940 941 + error_bl = error; 909 942 error = iqs5xx_dev_init(client); 910 943 if (!error && iqs5xx->bl_status == IQS5XX_BL_STATUS_RESET) 911 944 error = -EINVAL; ··· 918 949 err_kfree: 919 950 kfree(pmap); 920 951 952 + if (error_bl) 953 + return error_bl; 954 + 921 955 return error; 922 956 } 923 957 924 - static ssize_t fw_file_store(struct device *dev, struct device_attribute *attr, 925 - const char *buf, size_t count) 958 + static ssize_t fw_file_store(struct device *dev, 959 + struct device_attribute *attr, const char *buf, 960 + size_t count) 926 961 { 927 962 struct iqs5xx_private *iqs5xx = dev_get_drvdata(dev); 928 963 struct i2c_client *client = iqs5xx->client; ··· 985 1012 struct input_dev *input = iqs5xx->input; 986 1013 int error = 0; 987 1014 988 - if (!input) 1015 + if (!input || device_may_wakeup(dev)) 989 1016 return error; 990 1017 991 1018 mutex_lock(&input->mutex); ··· 1004 1031 struct input_dev *input = iqs5xx->input; 1005 1032 int error = 0; 1006 1033 1007 - if (!input) 1034 + if (!input || device_may_wakeup(dev)) 1008 1035 return error; 1009 1036 1010 1037 mutex_lock(&input->mutex);
+4 -4
drivers/input/touchscreen/melfas_mip4.c
··· 465 465 static void mip4_report_touch(struct mip4_ts *ts, u8 *packet) 466 466 { 467 467 int id; 468 - bool hover; 469 - bool palm; 468 + bool __always_unused hover; 469 + bool __always_unused palm; 470 470 bool state; 471 471 u16 x, y; 472 - u8 pressure_stage = 0; 472 + u8 __always_unused pressure_stage = 0; 473 473 u8 pressure; 474 - u8 size; 474 + u8 __always_unused size; 475 475 u8 touch_major; 476 476 u8 touch_minor; 477 477
+2 -1
drivers/input/touchscreen/raydium_i2c_ts.c
··· 445 445 enum raydium_bl_ack state) 446 446 { 447 447 int error; 448 + static const u8 cmd[] = { 0xFF, 0x39 }; 448 449 449 450 error = raydium_i2c_send(client, RM_CMD_BOOT_WRT, data, len); 450 451 if (error) { ··· 454 453 return error; 455 454 } 456 455 457 - error = raydium_i2c_send(client, RM_CMD_BOOT_ACK, NULL, 0); 456 + error = raydium_i2c_send(client, RM_CMD_BOOT_ACK, cmd, sizeof(cmd)); 458 457 if (error) { 459 458 dev_err(&client->dev, "Ack obj command failed: %d\n", error); 460 459 return error;
+7 -2
drivers/input/touchscreen/st1232.c
··· 94 94 95 95 for (retries = 10; retries; retries--) { 96 96 error = st1232_ts_read_data(ts, REG_STATUS, 1); 97 - if (!error && ts->read_buf[0] == (STATUS_NORMAL | ERROR_NONE)) 98 - return 0; 97 + if (!error) { 98 + switch (ts->read_buf[0]) { 99 + case STATUS_NORMAL | ERROR_NONE: 100 + case STATUS_IDLE | ERROR_NONE: 101 + return 0; 102 + } 103 + } 99 104 100 105 usleep_range(1000, 2000); 101 106 }
+1
drivers/input/touchscreen/stmpe-ts.c
··· 52 52 * @idev: registered input device 53 53 * @work: a work item used to scan the device 54 54 * @dev: a pointer back to the MFD cell struct device* 55 + * @prop: Touchscreen properties 55 56 * @ave_ctrl: Sample average control 56 57 * (0 -> 1 sample, 1 -> 2 samples, 2 -> 4 samples, 3 -> 8 samples) 57 58 * @touch_det_delay: Touch detect interrupt delay
+1
drivers/input/touchscreen/sur40.c
··· 787 787 dev_err(&interface->dev, 788 788 "Unable to register video controls."); 789 789 v4l2_ctrl_handler_free(&sur40->hdl); 790 + error = sur40->hdl.error; 790 791 goto err_unreg_v4l2; 791 792 } 792 793
-2
drivers/input/touchscreen/surface3_spi.c
··· 94 94 95 95 static void surface3_spi_process_touch(struct surface3_ts_data *ts_data, u8 *data) 96 96 { 97 - u16 timestamp; 98 97 unsigned int i; 99 - timestamp = get_unaligned_le16(&data[15]); 100 98 101 99 for (i = 0; i < 13; i++) { 102 100 struct surface3_ts_data_finger *finger;
+3
drivers/input/touchscreen/usbtouchscreen.c
··· 1044 1044 1045 1045 static int nexio_read_data(struct usbtouch_usb *usbtouch, unsigned char *pkt) 1046 1046 { 1047 + struct device *dev = &usbtouch->interface->dev; 1047 1048 struct nexio_touch_packet *packet = (void *) pkt; 1048 1049 struct nexio_priv *priv = usbtouch->priv; 1049 1050 unsigned int data_len = be16_to_cpu(packet->data_len); ··· 1063 1062 1064 1063 /* send ACK */ 1065 1064 ret = usb_submit_urb(priv->ack, GFP_ATOMIC); 1065 + if (ret) 1066 + dev_warn(dev, "Failed to submit ACK URB: %d\n", ret); 1066 1067 1067 1068 if (!usbtouch->type->max_xc) { 1068 1069 usbtouch->type->max_xc = 2 * x_len;
+2 -2
drivers/input/touchscreen/zinitix.c
··· 161 161 162 162 ret = i2c_master_recv(client, (u8 *)values, length); 163 163 if (ret != length) 164 - return ret < 0 ? ret : -EIO; ; 164 + return ret < 0 ? ret : -EIO; 165 165 166 166 return 0; 167 167 } ··· 190 190 return 0; 191 191 } 192 192 193 - static bool zinitix_init_touch(struct bt541_ts_data *bt541) 193 + static int zinitix_init_touch(struct bt541_ts_data *bt541) 194 194 { 195 195 struct i2c_client *client = bt541->client; 196 196 int i;
+103
include/dt-bindings/input/cros-ec-keyboard.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * This header provides the constants of the standard Chrome OS key matrix 4 + * for cros-ec keyboard-controller bindings. 5 + * 6 + * Copyright (c) 2021 Google, Inc 7 + */ 8 + 9 + #ifndef _CROS_EC_KEYBOARD_H 10 + #define _CROS_EC_KEYBOARD_H 11 + 12 + #define CROS_STD_TOP_ROW_KEYMAP \ 13 + MATRIX_KEY(0x00, 0x02, KEY_F1) \ 14 + MATRIX_KEY(0x03, 0x02, KEY_F2) \ 15 + MATRIX_KEY(0x02, 0x02, KEY_F3) \ 16 + MATRIX_KEY(0x01, 0x02, KEY_F4) \ 17 + MATRIX_KEY(0x03, 0x04, KEY_F5) \ 18 + MATRIX_KEY(0x02, 0x04, KEY_F6) \ 19 + MATRIX_KEY(0x01, 0x04, KEY_F7) \ 20 + MATRIX_KEY(0x02, 0x09, KEY_F8) \ 21 + MATRIX_KEY(0x01, 0x09, KEY_F9) \ 22 + MATRIX_KEY(0x00, 0x04, KEY_F10) 23 + 24 + #define CROS_STD_MAIN_KEYMAP \ 25 + MATRIX_KEY(0x00, 0x01, KEY_LEFTMETA) \ 26 + MATRIX_KEY(0x00, 0x03, KEY_B) \ 27 + MATRIX_KEY(0x00, 0x05, KEY_RO) \ 28 + MATRIX_KEY(0x00, 0x06, KEY_N) \ 29 + MATRIX_KEY(0x00, 0x08, KEY_EQUAL) \ 30 + MATRIX_KEY(0x00, 0x0a, KEY_RIGHTALT) \ 31 + MATRIX_KEY(0x01, 0x01, KEY_ESC) \ 32 + MATRIX_KEY(0x01, 0x03, KEY_G) \ 33 + MATRIX_KEY(0x01, 0x06, KEY_H) \ 34 + MATRIX_KEY(0x01, 0x08, KEY_APOSTROPHE) \ 35 + MATRIX_KEY(0x01, 0x0b, KEY_BACKSPACE) \ 36 + MATRIX_KEY(0x01, 0x0c, KEY_HENKAN) \ 37 + \ 38 + MATRIX_KEY(0x02, 0x00, KEY_LEFTCTRL) \ 39 + MATRIX_KEY(0x02, 0x01, KEY_TAB) \ 40 + MATRIX_KEY(0x02, 0x03, KEY_T) \ 41 + MATRIX_KEY(0x02, 0x05, KEY_RIGHTBRACE) \ 42 + MATRIX_KEY(0x02, 0x06, KEY_Y) \ 43 + MATRIX_KEY(0x02, 0x07, KEY_102ND) \ 44 + MATRIX_KEY(0x02, 0x08, KEY_LEFTBRACE) \ 45 + MATRIX_KEY(0x02, 0x0a, KEY_YEN) \ 46 + \ 47 + MATRIX_KEY(0x03, 0x00, KEY_LEFTMETA) \ 48 + MATRIX_KEY(0x03, 0x01, KEY_GRAVE) \ 49 + MATRIX_KEY(0x03, 0x03, KEY_5) \ 50 + MATRIX_KEY(0x03, 0x06, KEY_6) \ 51 + MATRIX_KEY(0x03, 0x08, KEY_MINUS) \ 52 + MATRIX_KEY(0x03, 0x09, KEY_SLEEP) \ 53 + MATRIX_KEY(0x03, 0x0b, KEY_BACKSLASH) \ 54 + MATRIX_KEY(0x03, 0x0c, KEY_MUHENKAN) \ 55 + \ 56 + MATRIX_KEY(0x04, 0x00, KEY_RIGHTCTRL) \ 57 + MATRIX_KEY(0x04, 0x01, KEY_A) \ 58 + MATRIX_KEY(0x04, 0x02, KEY_D) \ 59 + MATRIX_KEY(0x04, 0x03, KEY_F) \ 60 + MATRIX_KEY(0x04, 0x04, KEY_S) \ 61 + MATRIX_KEY(0x04, 0x05, KEY_K) \ 62 + MATRIX_KEY(0x04, 0x06, KEY_J) \ 63 + MATRIX_KEY(0x04, 0x08, KEY_SEMICOLON) \ 64 + MATRIX_KEY(0x04, 0x09, KEY_L) \ 65 + MATRIX_KEY(0x04, 0x0a, KEY_BACKSLASH) \ 66 + MATRIX_KEY(0x04, 0x0b, KEY_ENTER) \ 67 + \ 68 + MATRIX_KEY(0x05, 0x01, KEY_Z) \ 69 + MATRIX_KEY(0x05, 0x02, KEY_C) \ 70 + MATRIX_KEY(0x05, 0x03, KEY_V) \ 71 + MATRIX_KEY(0x05, 0x04, KEY_X) \ 72 + MATRIX_KEY(0x05, 0x05, KEY_COMMA) \ 73 + MATRIX_KEY(0x05, 0x06, KEY_M) \ 74 + MATRIX_KEY(0x05, 0x07, KEY_LEFTSHIFT) \ 75 + MATRIX_KEY(0x05, 0x08, KEY_SLASH) \ 76 + MATRIX_KEY(0x05, 0x09, KEY_DOT) \ 77 + MATRIX_KEY(0x05, 0x0b, KEY_SPACE) \ 78 + \ 79 + MATRIX_KEY(0x06, 0x01, KEY_1) \ 80 + MATRIX_KEY(0x06, 0x02, KEY_3) \ 81 + MATRIX_KEY(0x06, 0x03, KEY_4) \ 82 + MATRIX_KEY(0x06, 0x04, KEY_2) \ 83 + MATRIX_KEY(0x06, 0x05, KEY_8) \ 84 + MATRIX_KEY(0x06, 0x06, KEY_7) \ 85 + MATRIX_KEY(0x06, 0x08, KEY_0) \ 86 + MATRIX_KEY(0x06, 0x09, KEY_9) \ 87 + MATRIX_KEY(0x06, 0x0a, KEY_LEFTALT) \ 88 + MATRIX_KEY(0x06, 0x0b, KEY_DOWN) \ 89 + MATRIX_KEY(0x06, 0x0c, KEY_RIGHT) \ 90 + \ 91 + MATRIX_KEY(0x07, 0x01, KEY_Q) \ 92 + MATRIX_KEY(0x07, 0x02, KEY_E) \ 93 + MATRIX_KEY(0x07, 0x03, KEY_R) \ 94 + MATRIX_KEY(0x07, 0x04, KEY_W) \ 95 + MATRIX_KEY(0x07, 0x05, KEY_I) \ 96 + MATRIX_KEY(0x07, 0x06, KEY_U) \ 97 + MATRIX_KEY(0x07, 0x07, KEY_RIGHTSHIFT) \ 98 + MATRIX_KEY(0x07, 0x08, KEY_P) \ 99 + MATRIX_KEY(0x07, 0x09, KEY_O) \ 100 + MATRIX_KEY(0x07, 0x0b, KEY_UP) \ 101 + MATRIX_KEY(0x07, 0x0c, KEY_LEFT) 102 + 103 + #endif /* _CROS_EC_KEYBOARD_H */