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

Merge branch 'next' into for-linus

Second round of input updates for 3.19.

+299 -177
+7 -3
Documentation/devicetree/bindings/input/gpio-keys.txt
··· 10 10 Each button (key) is represented as a sub-node of "gpio-keys": 11 11 Subnode properties: 12 12 13 + - gpios: OF device-tree gpio specification. 14 + - interrupts: the interrupt line for that input. 13 15 - label: Descriptive name of the key. 14 16 - linux,code: Keycode to emit. 15 17 16 - Required mutual exclusive subnode-properties: 17 - - gpios: OF device-tree gpio specification. 18 - - interrupts: the interrupt line for that input 18 + Note that either "interrupts" or "gpios" properties can be omitted, but not 19 + both at the same time. Specifying both properties is allowed. 19 20 20 21 Optional subnode-properties: 21 22 - linux,input-type: Specify event type this button/key generates. ··· 24 23 - debounce-interval: Debouncing interval time in milliseconds. 25 24 If not specified defaults to 5. 26 25 - gpio-key,wakeup: Boolean, button can wake-up the system. 26 + - linux,can-disable: Boolean, indicates that button is connected 27 + to dedicated (not shared) interrupt which can be disabled to 28 + suppress events from the button. 27 29 28 30 Example nodes: 29 31
+2
Documentation/devicetree/bindings/input/stmpe-keypad.txt
··· 8 8 - debounce-interval : Debouncing interval time in milliseconds 9 9 - st,scan-count : Scanning cycles elapsed before key data is updated 10 10 - st,no-autorepeat : If specified device will not autorepeat 11 + - keypad,num-rows : See ./matrix-keymap.txt 12 + - keypad,num-columns : See ./matrix-keymap.txt 11 13 12 14 Example: 13 15
+44 -16
drivers/input/evdev.c
··· 28 28 #include <linux/cdev.h> 29 29 #include "input-compat.h" 30 30 31 + enum evdev_clock_type { 32 + EV_CLK_REAL = 0, 33 + EV_CLK_MONO, 34 + EV_CLK_BOOT, 35 + EV_CLK_MAX 36 + }; 37 + 31 38 struct evdev { 32 39 int open; 33 40 struct input_handle handle; ··· 56 49 struct fasync_struct *fasync; 57 50 struct evdev *evdev; 58 51 struct list_head node; 59 - int clkid; 52 + int clk_type; 60 53 bool revoked; 61 54 unsigned int bufsize; 62 55 struct input_event buffer[]; 63 56 }; 57 + 58 + static int evdev_set_clk_type(struct evdev_client *client, unsigned int clkid) 59 + { 60 + switch (clkid) { 61 + 62 + case CLOCK_REALTIME: 63 + client->clk_type = EV_CLK_REAL; 64 + break; 65 + case CLOCK_MONOTONIC: 66 + client->clk_type = EV_CLK_MONO; 67 + break; 68 + case CLOCK_BOOTTIME: 69 + client->clk_type = EV_CLK_BOOT; 70 + break; 71 + default: 72 + return -EINVAL; 73 + } 74 + 75 + return 0; 76 + } 64 77 65 78 /* flush queued events of type @type, caller must hold client->buffer_lock */ 66 79 static void __evdev_flush_queue(struct evdev_client *client, unsigned int type) ··· 135 108 struct input_event ev; 136 109 ktime_t time; 137 110 138 - time = (client->clkid == CLOCK_MONOTONIC) ? 139 - ktime_get() : ktime_get_real(); 111 + time = client->clk_type == EV_CLK_REAL ? 112 + ktime_get_real() : 113 + client->clk_type == EV_CLK_MONO ? 114 + ktime_get() : 115 + ktime_get_boottime(); 140 116 141 117 ev.time = ktime_to_timeval(time); 142 118 ev.type = EV_SYN; ··· 189 159 190 160 static void evdev_pass_values(struct evdev_client *client, 191 161 const struct input_value *vals, unsigned int count, 192 - ktime_t mono, ktime_t real) 162 + ktime_t *ev_time) 193 163 { 194 164 struct evdev *evdev = client->evdev; 195 165 const struct input_value *v; ··· 199 169 if (client->revoked) 200 170 return; 201 171 202 - event.time = ktime_to_timeval(client->clkid == CLOCK_MONOTONIC ? 203 - mono : real); 172 + event.time = ktime_to_timeval(ev_time[client->clk_type]); 204 173 205 174 /* Interrupts are disabled, just acquire the lock. */ 206 175 spin_lock(&client->buffer_lock); ··· 227 198 { 228 199 struct evdev *evdev = handle->private; 229 200 struct evdev_client *client; 230 - ktime_t time_mono, time_real; 201 + ktime_t ev_time[EV_CLK_MAX]; 231 202 232 - time_mono = ktime_get(); 233 - time_real = ktime_mono_to_real(time_mono); 203 + ev_time[EV_CLK_MONO] = ktime_get(); 204 + ev_time[EV_CLK_REAL] = ktime_mono_to_real(ev_time[EV_CLK_MONO]); 205 + ev_time[EV_CLK_BOOT] = ktime_mono_to_any(ev_time[EV_CLK_MONO], 206 + TK_OFFS_BOOT); 234 207 235 208 rcu_read_lock(); 236 209 237 210 client = rcu_dereference(evdev->grab); 238 211 239 212 if (client) 240 - evdev_pass_values(client, vals, count, time_mono, time_real); 213 + evdev_pass_values(client, vals, count, ev_time); 241 214 else 242 215 list_for_each_entry_rcu(client, &evdev->client_list, node) 243 - evdev_pass_values(client, vals, count, 244 - time_mono, time_real); 216 + evdev_pass_values(client, vals, count, ev_time); 245 217 246 218 rcu_read_unlock(); 247 219 } ··· 907 877 case EVIOCSCLOCKID: 908 878 if (copy_from_user(&i, p, sizeof(unsigned int))) 909 879 return -EFAULT; 910 - if (i != CLOCK_MONOTONIC && i != CLOCK_REALTIME) 911 - return -EINVAL; 912 - client->clkid = i; 913 - return 0; 880 + 881 + return evdev_set_clk_type(client, i); 914 882 915 883 case EVIOCGKEYCODE: 916 884 return evdev_handle_get_keycode(dev, p);
+13 -9
drivers/input/input.c
··· 1974 1974 1975 1975 events = mt_slots + 1; /* count SYN_MT_REPORT and SYN_REPORT */ 1976 1976 1977 - for (i = 0; i < ABS_CNT; i++) { 1978 - if (test_bit(i, dev->absbit)) { 1979 - if (input_is_mt_axis(i)) 1980 - events += mt_slots; 1981 - else 1982 - events++; 1977 + if (test_bit(EV_ABS, dev->evbit)) { 1978 + for (i = 0; i < ABS_CNT; i++) { 1979 + if (test_bit(i, dev->absbit)) { 1980 + if (input_is_mt_axis(i)) 1981 + events += mt_slots; 1982 + else 1983 + events++; 1984 + } 1983 1985 } 1984 1986 } 1985 1987 1986 - for (i = 0; i < REL_CNT; i++) 1987 - if (test_bit(i, dev->relbit)) 1988 - events++; 1988 + if (test_bit(EV_REL, dev->evbit)) { 1989 + for (i = 0; i < REL_CNT; i++) 1990 + if (test_bit(i, dev->relbit)) 1991 + events++; 1992 + } 1989 1993 1990 1994 /* Make room for KEY and MSC events */ 1991 1995 events += 7;
+1
drivers/input/keyboard/Kconfig
··· 559 559 config KEYBOARD_STMPE 560 560 tristate "STMPE keypad support" 561 561 depends on MFD_STMPE 562 + depends on OF 562 563 select INPUT_MATRIXKMAP 563 564 help 564 565 Say Y here if you want to use the keypad controller on STMPE I/O
+57 -57
drivers/input/keyboard/gpio_keys.c
··· 35 35 struct gpio_button_data { 36 36 const struct gpio_keys_button *button; 37 37 struct input_dev *input; 38 - struct timer_list timer; 39 - struct work_struct work; 40 - unsigned int timer_debounce; /* in msecs */ 38 + 39 + struct timer_list release_timer; 40 + unsigned int release_delay; /* in msecs, for IRQ-only buttons */ 41 + 42 + struct delayed_work work; 43 + unsigned int software_debounce; /* in msecs, for GPIO-driven buttons */ 44 + 41 45 unsigned int irq; 42 46 spinlock_t lock; 43 47 bool disabled; ··· 120 116 { 121 117 if (!bdata->disabled) { 122 118 /* 123 - * Disable IRQ and possible debouncing timer. 119 + * Disable IRQ and associated timer/work structure. 124 120 */ 125 121 disable_irq(bdata->irq); 126 - if (bdata->timer_debounce) 127 - del_timer_sync(&bdata->timer); 122 + 123 + if (gpio_is_valid(bdata->button->gpio)) 124 + cancel_delayed_work_sync(&bdata->work); 125 + else 126 + del_timer_sync(&bdata->release_timer); 128 127 129 128 bdata->disabled = true; 130 129 } ··· 350 343 static void gpio_keys_gpio_work_func(struct work_struct *work) 351 344 { 352 345 struct gpio_button_data *bdata = 353 - container_of(work, struct gpio_button_data, work); 346 + container_of(work, struct gpio_button_data, work.work); 354 347 355 348 gpio_keys_gpio_report_event(bdata); 356 349 357 350 if (bdata->button->wakeup) 358 351 pm_relax(bdata->input->dev.parent); 359 - } 360 - 361 - static void gpio_keys_gpio_timer(unsigned long _data) 362 - { 363 - struct gpio_button_data *bdata = (struct gpio_button_data *)_data; 364 - 365 - schedule_work(&bdata->work); 366 352 } 367 353 368 354 static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id) ··· 366 366 367 367 if (bdata->button->wakeup) 368 368 pm_stay_awake(bdata->input->dev.parent); 369 - if (bdata->timer_debounce) 370 - mod_timer(&bdata->timer, 371 - jiffies + msecs_to_jiffies(bdata->timer_debounce)); 372 - else 373 - schedule_work(&bdata->work); 369 + 370 + mod_delayed_work(system_wq, 371 + &bdata->work, 372 + msecs_to_jiffies(bdata->software_debounce)); 374 373 375 374 return IRQ_HANDLED; 376 375 } ··· 407 408 input_event(input, EV_KEY, button->code, 1); 408 409 input_sync(input); 409 410 410 - if (!bdata->timer_debounce) { 411 + if (!bdata->release_delay) { 411 412 input_event(input, EV_KEY, button->code, 0); 412 413 input_sync(input); 413 414 goto out; ··· 416 417 bdata->key_pressed = true; 417 418 } 418 419 419 - if (bdata->timer_debounce) 420 - mod_timer(&bdata->timer, 421 - jiffies + msecs_to_jiffies(bdata->timer_debounce)); 420 + if (bdata->release_delay) 421 + mod_timer(&bdata->release_timer, 422 + jiffies + msecs_to_jiffies(bdata->release_delay)); 422 423 out: 423 424 spin_unlock_irqrestore(&bdata->lock, flags); 424 425 return IRQ_HANDLED; ··· 428 429 { 429 430 struct gpio_button_data *bdata = data; 430 431 431 - if (bdata->timer_debounce) 432 - del_timer_sync(&bdata->timer); 433 - 434 - cancel_work_sync(&bdata->work); 432 + if (gpio_is_valid(bdata->button->gpio)) 433 + cancel_delayed_work_sync(&bdata->work); 434 + else 435 + del_timer_sync(&bdata->release_timer); 435 436 } 436 437 437 438 static int gpio_keys_setup_key(struct platform_device *pdev, ··· 465 466 button->debounce_interval * 1000); 466 467 /* use timer if gpiolib doesn't provide debounce */ 467 468 if (error < 0) 468 - bdata->timer_debounce = 469 + bdata->software_debounce = 469 470 button->debounce_interval; 470 471 } 471 472 472 - irq = gpio_to_irq(button->gpio); 473 - if (irq < 0) { 474 - error = irq; 475 - dev_err(dev, 476 - "Unable to get irq number for GPIO %d, error %d\n", 477 - button->gpio, error); 478 - return error; 473 + if (button->irq) { 474 + bdata->irq = button->irq; 475 + } else { 476 + irq = gpio_to_irq(button->gpio); 477 + if (irq < 0) { 478 + error = irq; 479 + dev_err(dev, 480 + "Unable to get irq number for GPIO %d, error %d\n", 481 + button->gpio, error); 482 + return error; 483 + } 484 + bdata->irq = irq; 479 485 } 480 - bdata->irq = irq; 481 486 482 - INIT_WORK(&bdata->work, gpio_keys_gpio_work_func); 483 - setup_timer(&bdata->timer, 484 - gpio_keys_gpio_timer, (unsigned long)bdata); 487 + INIT_DELAYED_WORK(&bdata->work, gpio_keys_gpio_work_func); 485 488 486 489 isr = gpio_keys_gpio_isr; 487 490 irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING; ··· 500 499 return -EINVAL; 501 500 } 502 501 503 - bdata->timer_debounce = button->debounce_interval; 504 - setup_timer(&bdata->timer, 502 + bdata->release_delay = button->debounce_interval; 503 + setup_timer(&bdata->release_timer, 505 504 gpio_keys_irq_timer, (unsigned long)bdata); 506 505 507 506 isr = gpio_keys_irq_isr; ··· 511 510 input_set_capability(input, button->type ?: EV_KEY, button->code); 512 511 513 512 /* 514 - * Install custom action to cancel debounce timer and 513 + * Install custom action to cancel release timer and 515 514 * workqueue item. 516 515 */ 517 516 error = devm_add_action(&pdev->dev, gpio_keys_quiesce_key, bdata); ··· 619 618 620 619 i = 0; 621 620 for_each_child_of_node(node, pp) { 622 - int gpio = -1; 623 621 enum of_gpio_flags flags; 624 622 625 623 button = &pdata->buttons[i++]; 626 624 627 - if (!of_find_property(pp, "gpios", NULL)) { 628 - button->irq = irq_of_parse_and_map(pp, 0); 629 - if (button->irq == 0) { 630 - i--; 631 - pdata->nbuttons--; 632 - dev_warn(dev, "Found button without gpios or irqs\n"); 633 - continue; 634 - } 635 - } else { 636 - gpio = of_get_gpio_flags(pp, 0, &flags); 637 - if (gpio < 0) { 638 - error = gpio; 625 + button->gpio = of_get_gpio_flags(pp, 0, &flags); 626 + if (button->gpio < 0) { 627 + error = button->gpio; 628 + if (error != -ENOENT) { 639 629 if (error != -EPROBE_DEFER) 640 630 dev_err(dev, 641 631 "Failed to get gpio flags, error: %d\n", 642 632 error); 643 633 return ERR_PTR(error); 644 634 } 635 + } else { 636 + button->active_low = flags & OF_GPIO_ACTIVE_LOW; 645 637 } 646 638 647 - button->gpio = gpio; 648 - button->active_low = flags & OF_GPIO_ACTIVE_LOW; 639 + button->irq = irq_of_parse_and_map(pp, 0); 640 + 641 + if (!gpio_is_valid(button->gpio) && !button->irq) { 642 + dev_err(dev, "Found button without gpios or irqs\n"); 643 + return ERR_PTR(-EINVAL); 644 + } 649 645 650 646 if (of_property_read_u32(pp, "linux,code", &button->code)) { 651 647 dev_err(dev, "Button without keycode: 0x%x\n", ··· 656 658 button->type = EV_KEY; 657 659 658 660 button->wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL); 661 + 662 + button->can_disable = !!of_get_property(pp, "linux,can-disable", NULL); 659 663 660 664 if (of_property_read_u32(pp, "debounce-interval", 661 665 &button->debounce_interval))
+80 -61
drivers/input/keyboard/stmpe-keypad.c
··· 45 45 #define STMPE_KEYPAD_MAX_ROWS 8 46 46 #define STMPE_KEYPAD_MAX_COLS 8 47 47 #define STMPE_KEYPAD_ROW_SHIFT 3 48 - #define STMPE_KEYPAD_KEYMAP_SIZE \ 48 + #define STMPE_KEYPAD_KEYMAP_MAX_SIZE \ 49 49 (STMPE_KEYPAD_MAX_ROWS * STMPE_KEYPAD_MAX_COLS) 50 50 51 51 /** 52 52 * struct stmpe_keypad_variant - model-specific attributes 53 53 * @auto_increment: whether the KPC_DATA_BYTE register address 54 54 * auto-increments on multiple read 55 + * @set_pullup: whether the pins need to have their pull-ups set 55 56 * @num_data: number of data bytes 56 57 * @num_normal_data: number of normal keys' data bytes 57 58 * @max_cols: maximum number of columns supported ··· 62 61 */ 63 62 struct stmpe_keypad_variant { 64 63 bool auto_increment; 64 + bool set_pullup; 65 65 int num_data; 66 66 int num_normal_data; 67 67 int max_cols; ··· 83 81 }, 84 82 [STMPE2401] = { 85 83 .auto_increment = false, 84 + .set_pullup = true, 86 85 .num_data = 3, 87 86 .num_normal_data = 2, 88 87 .max_cols = 8, ··· 93 90 }, 94 91 [STMPE2403] = { 95 92 .auto_increment = true, 93 + .set_pullup = true, 96 94 .num_data = 5, 97 95 .num_normal_data = 3, 98 96 .max_cols = 8, ··· 103 99 }, 104 100 }; 105 101 102 + /** 103 + * struct stmpe_keypad - STMPE keypad state container 104 + * @stmpe: pointer to parent STMPE device 105 + * @input: spawned input device 106 + * @variant: STMPE variant 107 + * @debounce_ms: debounce interval, in ms. Maximum is 108 + * %STMPE_KEYPAD_MAX_DEBOUNCE. 109 + * @scan_count: number of key scanning cycles to confirm key data. 110 + * Maximum is %STMPE_KEYPAD_MAX_SCAN_COUNT. 111 + * @no_autorepeat: disable key autorepeat 112 + * @rows: bitmask for the rows 113 + * @cols: bitmask for the columns 114 + * @keymap: the keymap 115 + */ 106 116 struct stmpe_keypad { 107 117 struct stmpe *stmpe; 108 118 struct input_dev *input; 109 119 const struct stmpe_keypad_variant *variant; 110 - const struct stmpe_keypad_platform_data *plat; 111 - 120 + unsigned int debounce_ms; 121 + unsigned int scan_count; 122 + bool no_autorepeat; 112 123 unsigned int rows; 113 124 unsigned int cols; 114 - 115 - unsigned short keymap[STMPE_KEYPAD_KEYMAP_SIZE]; 125 + unsigned short keymap[STMPE_KEYPAD_KEYMAP_MAX_SIZE]; 116 126 }; 117 127 118 128 static int stmpe_keypad_read_data(struct stmpe_keypad *keypad, u8 *data) ··· 189 171 unsigned int col_gpios = variant->col_gpios; 190 172 unsigned int row_gpios = variant->row_gpios; 191 173 struct stmpe *stmpe = keypad->stmpe; 174 + u8 pureg = stmpe->regs[STMPE_IDX_GPPUR_LSB]; 192 175 unsigned int pins = 0; 176 + unsigned int pu_pins = 0; 177 + int ret; 193 178 int i; 194 179 195 180 /* ··· 209 188 for (i = 0; i < variant->max_cols; i++) { 210 189 int num = __ffs(col_gpios); 211 190 212 - if (keypad->cols & (1 << i)) 191 + if (keypad->cols & (1 << i)) { 213 192 pins |= 1 << num; 193 + pu_pins |= 1 << num; 194 + } 214 195 215 196 col_gpios &= ~(1 << num); 216 197 } ··· 226 203 row_gpios &= ~(1 << num); 227 204 } 228 205 229 - return stmpe_set_altfunc(stmpe, pins, STMPE_BLOCK_KEYPAD); 206 + ret = stmpe_set_altfunc(stmpe, pins, STMPE_BLOCK_KEYPAD); 207 + if (ret) 208 + return ret; 209 + 210 + /* 211 + * On STMPE24xx, set pin bias to pull-up on all keypad input 212 + * pins (columns), this incidentally happen to be maximum 8 pins 213 + * and placed at GPIO0-7 so only the LSB of the pull up register 214 + * ever needs to be written. 215 + */ 216 + if (variant->set_pullup) { 217 + u8 val; 218 + 219 + ret = stmpe_reg_read(stmpe, pureg); 220 + if (ret) 221 + return ret; 222 + 223 + /* Do not touch unused pins, may be used for GPIO */ 224 + val = ret & ~pu_pins; 225 + val |= pu_pins; 226 + 227 + ret = stmpe_reg_write(stmpe, pureg, val); 228 + } 229 + 230 + return 0; 230 231 } 231 232 232 233 static int stmpe_keypad_chip_init(struct stmpe_keypad *keypad) 233 234 { 234 - const struct stmpe_keypad_platform_data *plat = keypad->plat; 235 235 const struct stmpe_keypad_variant *variant = keypad->variant; 236 236 struct stmpe *stmpe = keypad->stmpe; 237 237 int ret; 238 238 239 - if (plat->debounce_ms > STMPE_KEYPAD_MAX_DEBOUNCE) 239 + if (keypad->debounce_ms > STMPE_KEYPAD_MAX_DEBOUNCE) 240 240 return -EINVAL; 241 241 242 - if (plat->scan_count > STMPE_KEYPAD_MAX_SCAN_COUNT) 242 + if (keypad->scan_count > STMPE_KEYPAD_MAX_SCAN_COUNT) 243 243 return -EINVAL; 244 244 245 245 ret = stmpe_enable(stmpe, STMPE_BLOCK_KEYPAD); ··· 291 245 292 246 ret = stmpe_set_bits(stmpe, STMPE_KPC_CTRL_MSB, 293 247 STMPE_KPC_CTRL_MSB_SCAN_COUNT, 294 - plat->scan_count << 4); 248 + keypad->scan_count << 4); 295 249 if (ret < 0) 296 250 return ret; 297 251 ··· 299 253 STMPE_KPC_CTRL_LSB_SCAN | 300 254 STMPE_KPC_CTRL_LSB_DEBOUNCE, 301 255 STMPE_KPC_CTRL_LSB_SCAN | 302 - (plat->debounce_ms << 1)); 256 + (keypad->debounce_ms << 1)); 303 257 } 304 258 305 - static void stmpe_keypad_fill_used_pins(struct stmpe_keypad *keypad) 259 + static void stmpe_keypad_fill_used_pins(struct stmpe_keypad *keypad, 260 + u32 used_rows, u32 used_cols) 306 261 { 307 262 int row, col; 308 263 309 - for (row = 0; row < STMPE_KEYPAD_MAX_ROWS; row++) { 310 - for (col = 0; col < STMPE_KEYPAD_MAX_COLS; col++) { 264 + for (row = 0; row < used_rows; row++) { 265 + for (col = 0; col < used_cols; col++) { 311 266 int code = MATRIX_SCAN_CODE(row, col, 312 - STMPE_KEYPAD_ROW_SHIFT); 267 + STMPE_KEYPAD_ROW_SHIFT); 313 268 if (keypad->keymap[code] != KEY_RESERVED) { 314 269 keypad->rows |= 1 << row; 315 270 keypad->cols |= 1 << col; ··· 319 272 } 320 273 } 321 274 322 - #ifdef CONFIG_OF 323 - static const struct stmpe_keypad_platform_data * 324 - stmpe_keypad_of_probe(struct device *dev) 325 - { 326 - struct device_node *np = dev->of_node; 327 - struct stmpe_keypad_platform_data *plat; 328 - 329 - if (!np) 330 - return ERR_PTR(-ENODEV); 331 - 332 - plat = devm_kzalloc(dev, sizeof(*plat), GFP_KERNEL); 333 - if (!plat) 334 - return ERR_PTR(-ENOMEM); 335 - 336 - of_property_read_u32(np, "debounce-interval", &plat->debounce_ms); 337 - of_property_read_u32(np, "st,scan-count", &plat->scan_count); 338 - 339 - plat->no_autorepeat = of_property_read_bool(np, "st,no-autorepeat"); 340 - 341 - return plat; 342 - } 343 - #else 344 - static inline const struct stmpe_keypad_platform_data * 345 - stmpe_keypad_of_probe(struct device *dev) 346 - { 347 - return ERR_PTR(-EINVAL); 348 - } 349 - #endif 350 - 351 275 static int stmpe_keypad_probe(struct platform_device *pdev) 352 276 { 353 277 struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); 354 - const struct stmpe_keypad_platform_data *plat; 278 + struct device_node *np = pdev->dev.of_node; 355 279 struct stmpe_keypad *keypad; 356 280 struct input_dev *input; 281 + u32 rows; 282 + u32 cols; 357 283 int error; 358 284 int irq; 359 - 360 - plat = stmpe->pdata->keypad; 361 - if (!plat) { 362 - plat = stmpe_keypad_of_probe(&pdev->dev); 363 - if (IS_ERR(plat)) 364 - return PTR_ERR(plat); 365 - } 366 285 367 286 irq = platform_get_irq(pdev, 0); 368 287 if (irq < 0) ··· 339 326 if (!keypad) 340 327 return -ENOMEM; 341 328 329 + keypad->stmpe = stmpe; 330 + keypad->variant = &stmpe_keypad_variants[stmpe->partnum]; 331 + 332 + of_property_read_u32(np, "debounce-interval", &keypad->debounce_ms); 333 + of_property_read_u32(np, "st,scan-count", &keypad->scan_count); 334 + keypad->no_autorepeat = of_property_read_bool(np, "st,no-autorepeat"); 335 + 342 336 input = devm_input_allocate_device(&pdev->dev); 343 337 if (!input) 344 338 return -ENOMEM; ··· 354 334 input->id.bustype = BUS_I2C; 355 335 input->dev.parent = &pdev->dev; 356 336 357 - error = matrix_keypad_build_keymap(plat->keymap_data, NULL, 358 - STMPE_KEYPAD_MAX_ROWS, 359 - STMPE_KEYPAD_MAX_COLS, 337 + error = matrix_keypad_parse_of_params(&pdev->dev, &rows, &cols); 338 + if (error) 339 + return error; 340 + 341 + error = matrix_keypad_build_keymap(NULL, NULL, rows, cols, 360 342 keypad->keymap, input); 361 343 if (error) 362 344 return error; 363 345 364 346 input_set_capability(input, EV_MSC, MSC_SCAN); 365 - if (!plat->no_autorepeat) 347 + if (!keypad->no_autorepeat) 366 348 __set_bit(EV_REP, input->evbit); 367 349 368 - stmpe_keypad_fill_used_pins(keypad); 350 + stmpe_keypad_fill_used_pins(keypad, rows, cols); 369 351 370 - keypad->stmpe = stmpe; 371 - keypad->plat = plat; 372 352 keypad->input = input; 373 - keypad->variant = &stmpe_keypad_variants[stmpe->partnum]; 374 353 375 354 error = stmpe_keypad_chip_init(keypad); 376 355 if (error < 0)
+74 -10
drivers/input/mouse/alps.c
··· 881 881 unsigned char *pkt, 882 882 unsigned char pkt_id) 883 883 { 884 + /* 885 + * packet-fmt b7 b6 b5 b4 b3 b2 b1 b0 886 + * Byte0 TWO & MULTI L 1 R M 1 Y0-2 Y0-1 Y0-0 887 + * Byte0 NEW L 1 X1-5 1 1 Y0-2 Y0-1 Y0-0 888 + * Byte1 Y0-10 Y0-9 Y0-8 Y0-7 Y0-6 Y0-5 Y0-4 Y0-3 889 + * Byte2 X0-11 1 X0-10 X0-9 X0-8 X0-7 X0-6 X0-5 890 + * Byte3 X1-11 1 X0-4 X0-3 1 X0-2 X0-1 X0-0 891 + * Byte4 TWO X1-10 TWO X1-9 X1-8 X1-7 X1-6 X1-5 X1-4 892 + * Byte4 MULTI X1-10 TWO X1-9 X1-8 X1-7 X1-6 Y1-5 1 893 + * Byte4 NEW X1-10 TWO X1-9 X1-8 X1-7 X1-6 0 0 894 + * Byte5 TWO & NEW Y1-10 0 Y1-9 Y1-8 Y1-7 Y1-6 Y1-5 Y1-4 895 + * Byte5 MULTI Y1-10 0 Y1-9 Y1-8 Y1-7 Y1-6 F-1 F-0 896 + * L: Left button 897 + * R / M: Non-clickpads: Right / Middle button 898 + * Clickpads: When > 2 fingers are down, and some fingers 899 + * are in the button area, then the 2 coordinates reported 900 + * are for fingers outside the button area and these report 901 + * extra fingers being present in the right / left button 902 + * area. Note these fingers are not added to the F field! 903 + * so if a TWO packet is received and R = 1 then there are 904 + * 3 fingers down, etc. 905 + * TWO: 1: Two touches present, byte 0/4/5 are in TWO fmt 906 + * 0: If byte 4 bit 0 is 1, then byte 0/4/5 are in MULTI fmt 907 + * otherwise byte 0 bit 4 must be set and byte 0/4/5 are 908 + * in NEW fmt 909 + * F: Number of fingers - 3, 0 means 3 fingers, 1 means 4 ... 910 + */ 911 + 884 912 mt[0].x = ((pkt[2] & 0x80) << 4); 885 913 mt[0].x |= ((pkt[2] & 0x3F) << 5); 886 914 mt[0].x |= ((pkt[3] & 0x30) >> 1); ··· 947 919 948 920 static int alps_get_mt_count(struct input_mt_pos *mt) 949 921 { 950 - int i; 922 + int i, fingers = 0; 951 923 952 - for (i = 0; i < MAX_TOUCHES && mt[i].x != 0 && mt[i].y != 0; i++) 953 - /* empty */; 924 + for (i = 0; i < MAX_TOUCHES; i++) { 925 + if (mt[i].x != 0 || mt[i].y != 0) 926 + fingers++; 927 + } 954 928 955 - return i; 929 + return fingers; 956 930 } 957 931 958 932 static int alps_decode_packet_v7(struct alps_fields *f, 959 933 unsigned char *p, 960 934 struct psmouse *psmouse) 961 935 { 936 + struct alps_data *priv = psmouse->private; 962 937 unsigned char pkt_id; 963 938 964 939 pkt_id = alps_get_packet_id_v7(p); ··· 969 938 return 0; 970 939 if (pkt_id == V7_PACKET_ID_UNKNOWN) 971 940 return -1; 941 + /* 942 + * NEW packets are send to indicate a discontinuity in the finger 943 + * coordinate reporting. Specifically a finger may have moved from 944 + * slot 0 to 1 or vice versa. INPUT_MT_TRACK takes care of this for 945 + * us. 946 + * 947 + * NEW packets have 3 problems: 948 + * 1) They do not contain middle / right button info (on non clickpads) 949 + * this can be worked around by preserving the old button state 950 + * 2) They do not contain an accurate fingercount, and they are 951 + * typically send when the number of fingers changes. We cannot use 952 + * the old finger count as that may mismatch with the amount of 953 + * touch coordinates we've available in the NEW packet 954 + * 3) Their x data for the second touch is inaccurate leading to 955 + * a possible jump of the x coordinate by 16 units when the first 956 + * non NEW packet comes in 957 + * Since problems 2 & 3 cannot be worked around, just ignore them. 958 + */ 959 + if (pkt_id == V7_PACKET_ID_NEW) 960 + return 1; 972 961 973 962 alps_get_finger_coordinate_v7(f->mt, p, pkt_id); 974 963 975 - if (pkt_id == V7_PACKET_ID_TWO || pkt_id == V7_PACKET_ID_MULTI) { 976 - f->left = (p[0] & 0x80) >> 7; 964 + if (pkt_id == V7_PACKET_ID_TWO) 965 + f->fingers = alps_get_mt_count(f->mt); 966 + else /* pkt_id == V7_PACKET_ID_MULTI */ 967 + f->fingers = 3 + (p[5] & 0x03); 968 + 969 + f->left = (p[0] & 0x80) >> 7; 970 + if (priv->flags & ALPS_BUTTONPAD) { 971 + if (p[0] & 0x20) 972 + f->fingers++; 973 + if (p[0] & 0x10) 974 + f->fingers++; 975 + } else { 977 976 f->right = (p[0] & 0x20) >> 5; 978 977 f->middle = (p[0] & 0x10) >> 4; 979 978 } 980 979 981 - if (pkt_id == V7_PACKET_ID_TWO) 982 - f->fingers = alps_get_mt_count(f->mt); 983 - else if (pkt_id == V7_PACKET_ID_MULTI) 984 - f->fingers = 3 + (p[5] & 0x03); 980 + /* Sometimes a single touch is reported in mt[1] rather then mt[0] */ 981 + if (f->fingers == 1 && f->mt[0].x == 0 && f->mt[0].y == 0) { 982 + f->mt[0].x = f->mt[1].x; 983 + f->mt[0].y = f->mt[1].y; 984 + f->mt[1].x = 0; 985 + f->mt[1].y = 0; 986 + } 985 987 986 988 return 0; 987 989 }
+4
drivers/input/mouse/trackpoint.c
··· 227 227 TRACKPOINT_INT_ATTR(upthresh, TP_UP_THRESH, TP_DEF_UP_THRESH); 228 228 TRACKPOINT_INT_ATTR(ztime, TP_Z_TIME, TP_DEF_Z_TIME); 229 229 TRACKPOINT_INT_ATTR(jenks, TP_JENKS_CURV, TP_DEF_JENKS_CURV); 230 + TRACKPOINT_INT_ATTR(drift_time, TP_DRIFT_TIME, TP_DEF_DRIFT_TIME); 230 231 231 232 TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON, 0, 232 233 TP_DEF_PTSON); ··· 247 246 &psmouse_attr_upthresh.dattr.attr, 248 247 &psmouse_attr_ztime.dattr.attr, 249 248 &psmouse_attr_jenks.dattr.attr, 249 + &psmouse_attr_drift_time.dattr.attr, 250 250 &psmouse_attr_press_to_select.dattr.attr, 251 251 &psmouse_attr_skipback.dattr.attr, 252 252 &psmouse_attr_ext_dev.dattr.attr, ··· 314 312 TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, upthresh); 315 313 TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, ztime); 316 314 TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, jenks); 315 + TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, drift_time); 317 316 318 317 /* toggles */ 319 318 TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, press_to_select); ··· 335 332 TRACKPOINT_SET_POWER_ON_DEFAULT(tp, upthresh); 336 333 TRACKPOINT_SET_POWER_ON_DEFAULT(tp, ztime); 337 334 TRACKPOINT_SET_POWER_ON_DEFAULT(tp, jenks); 335 + TRACKPOINT_SET_POWER_ON_DEFAULT(tp, drift_time); 338 336 TRACKPOINT_SET_POWER_ON_DEFAULT(tp, inertia); 339 337 340 338 /* toggles */
+5
drivers/input/mouse/trackpoint.h
··· 70 70 #define TP_UP_THRESH 0x5A /* Used to generate a 'click' on Z-axis */ 71 71 #define TP_Z_TIME 0x5E /* How sharp of a press */ 72 72 #define TP_JENKS_CURV 0x5D /* Minimum curvature for double click */ 73 + #define TP_DRIFT_TIME 0x5F /* How long a 'hands off' condition */ 74 + /* must last (x*107ms) for drift */ 75 + /* correction to occur */ 73 76 74 77 /* 75 78 * Toggling Flag bits ··· 123 120 #define TP_DEF_UP_THRESH 0xFF 124 121 #define TP_DEF_Z_TIME 0x26 125 122 #define TP_DEF_JENKS_CURV 0x87 123 + #define TP_DEF_DRIFT_TIME 0x05 126 124 127 125 /* Toggles */ 128 126 #define TP_DEF_MB 0x00 ··· 141 137 unsigned char draghys, mindrag; 142 138 unsigned char thresh, upthresh; 143 139 unsigned char ztime, jenks; 140 + unsigned char drift_time; 144 141 145 142 /* toggles */ 146 143 unsigned char press_to_select;
+3 -1
drivers/input/touchscreen/edt-ft5x06.c
··· 850 850 } 851 851 852 852 #define EDT_ATTR_CHECKSET(name, reg) \ 853 + do { \ 853 854 if (pdata->name >= edt_ft5x06_attr_##name.limit_low && \ 854 855 pdata->name <= edt_ft5x06_attr_##name.limit_high) \ 855 - edt_ft5x06_register_write(tsdata, reg, pdata->name) 856 + edt_ft5x06_register_write(tsdata, reg, pdata->name); \ 857 + } while (0) 856 858 857 859 #define EDT_GET_PROP(name, reg) { \ 858 860 u32 val; \
+4
drivers/mfd/stmpe.c
··· 519 519 [STMPE_IDX_GPDR_LSB] = STMPE1601_REG_GPIO_SET_DIR_LSB, 520 520 [STMPE_IDX_GPRER_LSB] = STMPE1601_REG_GPIO_RE_LSB, 521 521 [STMPE_IDX_GPFER_LSB] = STMPE1601_REG_GPIO_FE_LSB, 522 + [STMPE_IDX_GPPUR_LSB] = STMPE1601_REG_GPIO_PU_LSB, 522 523 [STMPE_IDX_GPAFR_U_MSB] = STMPE1601_REG_GPIO_AF_U_MSB, 523 524 [STMPE_IDX_IEGPIOR_LSB] = STMPE1601_REG_INT_EN_GPIO_MASK_LSB, 524 525 [STMPE_IDX_ISGPIOR_MSB] = STMPE1601_REG_INT_STA_GPIO_MSB, ··· 668 667 [STMPE_IDX_GPDR_LSB] = STMPE1801_REG_GPIO_SET_DIR_LOW, 669 668 [STMPE_IDX_GPRER_LSB] = STMPE1801_REG_GPIO_RE_LOW, 670 669 [STMPE_IDX_GPFER_LSB] = STMPE1801_REG_GPIO_FE_LOW, 670 + [STMPE_IDX_GPPUR_LSB] = STMPE1801_REG_GPIO_PULL_UP_LOW, 671 671 [STMPE_IDX_IEGPIOR_LSB] = STMPE1801_REG_INT_EN_GPIO_MASK_LOW, 672 672 [STMPE_IDX_ISGPIOR_LSB] = STMPE1801_REG_INT_STA_GPIO_LOW, 673 673 }; ··· 752 750 [STMPE_IDX_GPDR_LSB] = STMPE24XX_REG_GPDR_LSB, 753 751 [STMPE_IDX_GPRER_LSB] = STMPE24XX_REG_GPRER_LSB, 754 752 [STMPE_IDX_GPFER_LSB] = STMPE24XX_REG_GPFER_LSB, 753 + [STMPE_IDX_GPPUR_LSB] = STMPE24XX_REG_GPPUR_LSB, 754 + [STMPE_IDX_GPPDR_LSB] = STMPE24XX_REG_GPPDR_LSB, 755 755 [STMPE_IDX_GPAFR_U_MSB] = STMPE24XX_REG_GPAFR_U_MSB, 756 756 [STMPE_IDX_IEGPIOR_LSB] = STMPE24XX_REG_IEGPIOR_LSB, 757 757 [STMPE_IDX_ISGPIOR_MSB] = STMPE24XX_REG_ISGPIOR_MSB,
+3
drivers/mfd/stmpe.h
··· 188 188 #define STMPE1601_REG_GPIO_ED_MSB 0x8A 189 189 #define STMPE1601_REG_GPIO_RE_LSB 0x8D 190 190 #define STMPE1601_REG_GPIO_FE_LSB 0x8F 191 + #define STMPE1601_REG_GPIO_PU_LSB 0x91 191 192 #define STMPE1601_REG_GPIO_AF_U_MSB 0x92 192 193 193 194 #define STMPE1601_SYS_CTRL_ENABLE_GPIO (1 << 3) ··· 277 276 #define STMPE24XX_REG_GPEDR_MSB 0x8C 278 277 #define STMPE24XX_REG_GPRER_LSB 0x91 279 278 #define STMPE24XX_REG_GPFER_LSB 0x94 279 + #define STMPE24XX_REG_GPPUR_LSB 0x97 280 + #define STMPE24XX_REG_GPPDR_LSB 0x9a 280 281 #define STMPE24XX_REG_GPAFR_U_MSB 0x9B 281 282 282 283 #define STMPE24XX_SYS_CTRL_ENABLE_GPIO (1 << 3)
+2 -20
include/linux/mfd/stmpe.h
··· 50 50 STMPE_IDX_GPEDR_MSB, 51 51 STMPE_IDX_GPRER_LSB, 52 52 STMPE_IDX_GPFER_LSB, 53 + STMPE_IDX_GPPUR_LSB, 54 + STMPE_IDX_GPPDR_LSB, 53 55 STMPE_IDX_GPAFR_U_MSB, 54 56 STMPE_IDX_IEGPIOR_LSB, 55 57 STMPE_IDX_ISGPIOR_LSB, ··· 114 112 enum stmpe_block block); 115 113 extern int stmpe_enable(struct stmpe *stmpe, unsigned int blocks); 116 114 extern int stmpe_disable(struct stmpe *stmpe, unsigned int blocks); 117 - 118 - struct matrix_keymap_data; 119 - 120 - /** 121 - * struct stmpe_keypad_platform_data - STMPE keypad platform data 122 - * @keymap_data: key map table and size 123 - * @debounce_ms: debounce interval, in ms. Maximum is 124 - * %STMPE_KEYPAD_MAX_DEBOUNCE. 125 - * @scan_count: number of key scanning cycles to confirm key data. 126 - * Maximum is %STMPE_KEYPAD_MAX_SCAN_COUNT. 127 - * @no_autorepeat: disable key autorepeat 128 - */ 129 - struct stmpe_keypad_platform_data { 130 - const struct matrix_keymap_data *keymap_data; 131 - unsigned int debounce_ms; 132 - unsigned int scan_count; 133 - bool no_autorepeat; 134 - }; 135 115 136 116 #define STMPE_GPIO_NOREQ_811_TOUCH (0xf0) 137 117 ··· 183 199 * @irq_gpio: gpio number over which irq will be requested (significant only if 184 200 * irq_over_gpio is true) 185 201 * @gpio: GPIO-specific platform data 186 - * @keypad: keypad-specific platform data 187 202 * @ts: touchscreen-specific platform data 188 203 */ 189 204 struct stmpe_platform_data { ··· 195 212 int autosleep_timeout; 196 213 197 214 struct stmpe_gpio_platform_data *gpio; 198 - struct stmpe_keypad_platform_data *keypad; 199 215 struct stmpe_ts_platform_data *ts; 200 216 }; 201 217