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

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (40 commits)
Input: ADP5589 - new driver for I2C Keypad Decoder and I/O Expander
Input: tsc2007 - add X, Y and Z fuzz factors to platform data
Input: tsc2007 - add poll_period parameter to platform data
Input: tsc2007 - add poll_delay parameter to platform data
Input: tsc2007 - add max_rt parameter to platform data
Input: tsc2007 - debounce pressure measurement
Input: ad714x - fix captouch wheel option algorithm
Input: ad714x - allow platform code to specify irqflags
Input: ad714x - fix threshold and completion interrupt masks
Input: ad714x - fix up input configuration
Input: elantech - remove support for proprietary X driver
Input: elantech - report multitouch with proper ABS_MT messages
Input: elantech - export pressure and width when supported
Input: elantech - describe further the protocol
Input: atmel_tsadcc - correct call to input_free_device
Input: add driver FSL MPR121 capacitive touch sensor
Input: remove useless synchronize_rcu() calls
Input: ads7846 - fix gpio_pendown configuration
Input: ads7846 - add possibility to use external vref on ads7846
Input: rotary-encoder - add support for half-period encoders
...

+2155 -359
+99 -22
Documentation/input/elantech.txt
··· 34 34 Currently the Linux Elantech touchpad driver is aware of two different 35 35 hardware versions unimaginatively called version 1 and version 2. Version 1 36 36 is found in "older" laptops and uses 4 bytes per packet. Version 2 seems to 37 - be introduced with the EeePC and uses 6 bytes per packet. 37 + be introduced with the EeePC and uses 6 bytes per packet, and provides 38 + additional features such as position of two fingers, and width of the touch. 38 39 39 40 The driver tries to support both hardware versions and should be compatible 40 41 with the Xorg Synaptics touchpad driver and its graphical configuration ··· 95 94 can check these bits and reject any packet that appears corrupted. Using 96 95 this knob you can bypass that check. 97 96 98 - It is not known yet whether hardware version 2 provides the same parity 99 - bits. Hence checking is disabled by default. Currently even turning it on 100 - will do nothing. 101 - 97 + Hardware version 2 does not provide the same parity bits. Only some basic 98 + data consistency checking can be done. For now checking is disabled by 99 + default. Currently even turning it on will do nothing. 102 100 103 101 ///////////////////////////////////////////////////////////////////////////// 104 102 103 + 3. Differentiating hardware versions 104 + ================================= 105 105 106 - 3. Hardware version 1 106 + To detect the hardware version, read the version number as param[0].param[1].param[2] 107 + 108 + 4 bytes version: (after the arrow is the name given in the Dell-provided driver) 109 + 02.00.22 => EF013 110 + 02.06.00 => EF019 111 + In the wild, there appear to be more versions, such as 00.01.64, 01.00.21, 112 + 02.00.00, 02.00.04, 02.00.06. 113 + 114 + 6 bytes: 115 + 02.00.30 => EF113 116 + 02.08.00 => EF023 117 + 02.08.XX => EF123 118 + 02.0B.00 => EF215 119 + 04.01.XX => Scroll_EF051 120 + 04.02.XX => EF051 121 + In the wild, there appear to be more versions, such as 04.03.01, 04.04.11. There 122 + appears to be almost no difference, except for EF113, which does not report 123 + pressure/width and has different data consistency checks. 124 + 125 + Probably all the versions with param[0] <= 01 can be considered as 126 + 4 bytes/firmware 1. The versions < 02.08.00, with the exception of 02.00.30, as 127 + 4 bytes/firmware 2. Everything >= 02.08.00 can be considered as 6 bytes. 128 + 129 + ///////////////////////////////////////////////////////////////////////////// 130 + 131 + 4. Hardware version 1 107 132 ================== 108 133 109 - 3.1 Registers 134 + 4.1 Registers 110 135 ~~~~~~~~~ 111 136 112 137 By echoing a hexadecimal value to a register it contents can be altered. ··· 195 168 smart edge activation area width? 196 169 197 170 198 - 3.2 Native relative mode 4 byte packet format 171 + 4.2 Native relative mode 4 byte packet format 199 172 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 200 173 201 174 byte 0: ··· 253 226 positive = down 254 227 255 228 256 - 3.3 Native absolute mode 4 byte packet format 229 + 4.3 Native absolute mode 4 byte packet format 257 230 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 231 + 232 + EF013 and EF019 have a special behaviour (due to a bug in the firmware?), and 233 + when 1 finger is touching, the first 2 position reports must be discarded. 234 + This counting is reset whenever a different number of fingers is reported. 258 235 259 236 byte 0: 260 237 firmware version 1.x: ··· 310 279 ///////////////////////////////////////////////////////////////////////////// 311 280 312 281 313 - 4. Hardware version 2 282 + 5. Hardware version 2 314 283 ================== 315 284 316 285 317 - 4.1 Registers 286 + 5.1 Registers 318 287 ~~~~~~~~~ 319 288 320 289 By echoing a hexadecimal value to a register it contents can be altered. ··· 347 316 0x7f = never i.e. tap again to release) 348 317 349 318 350 - 4.2 Native absolute mode 6 byte packet format 319 + 5.2 Native absolute mode 6 byte packet format 351 320 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 321 + 5.2.1 Parity checking and packet re-synchronization 322 + There is no parity checking, however some consistency checks can be performed. 352 323 353 - 4.2.1 One finger touch 324 + For instance for EF113: 325 + SA1= packet[0]; 326 + A1 = packet[1]; 327 + B1 = packet[2]; 328 + SB1= packet[3]; 329 + C1 = packet[4]; 330 + D1 = packet[5]; 331 + if( (((SA1 & 0x3C) != 0x3C) && ((SA1 & 0xC0) != 0x80)) || // check Byte 1 332 + (((SA1 & 0x0C) != 0x0C) && ((SA1 & 0xC0) == 0x80)) || // check Byte 1 (one finger pressed) 333 + (((SA1 & 0xC0) != 0x80) && (( A1 & 0xF0) != 0x00)) || // check Byte 2 334 + (((SB1 & 0x3E) != 0x38) && ((SA1 & 0xC0) != 0x80)) || // check Byte 4 335 + (((SB1 & 0x0E) != 0x08) && ((SA1 & 0xC0) == 0x80)) || // check Byte 4 (one finger pressed) 336 + (((SA1 & 0xC0) != 0x80) && (( C1 & 0xF0) != 0x00)) ) // check Byte 5 337 + // error detected 338 + 339 + For all the other ones, there are just a few constant bits: 340 + if( ((packet[0] & 0x0C) != 0x04) || 341 + ((packet[3] & 0x0f) != 0x02) ) 342 + // error detected 343 + 344 + 345 + In case an error is detected, all the packets are shifted by one (and packet[0] is discarded). 346 + 347 + 5.2.1 One/Three finger touch 354 348 ~~~~~~~~~~~~~~~~ 355 349 356 350 byte 0: 357 351 358 352 bit 7 6 5 4 3 2 1 0 359 - n1 n0 . . . . R L 353 + n1 n0 w3 w2 . . R L 360 354 361 355 L, R = 1 when Left, Right mouse button pressed 362 356 n1..n0 = numbers of fingers on touchpad ··· 389 333 byte 1: 390 334 391 335 bit 7 6 5 4 3 2 1 0 392 - . . . . . x10 x9 x8 336 + p7 p6 p5 p4 . x10 x9 x8 393 337 394 338 byte 2: 395 339 396 340 bit 7 6 5 4 3 2 1 0 397 - x7 x6 x5 x4 x4 x2 x1 x0 341 + x7 x6 x5 x4 x3 x2 x1 x0 398 342 399 343 x10..x0 = absolute x value (horizontal) 400 344 401 345 byte 3: 402 346 403 347 bit 7 6 5 4 3 2 1 0 404 - . . . . . . . . 348 + n4 vf w1 w0 . . . b2 349 + 350 + n4 = set if more than 3 fingers (only in 3 fingers mode) 351 + vf = a kind of flag ? (only on EF123, 0 when finger is over one 352 + of the buttons, 1 otherwise) 353 + w3..w0 = width of the finger touch (not EF113) 354 + b2 (on EF113 only, 0 otherwise), b2.R.L indicates one button pressed: 355 + 0 = none 356 + 1 = Left 357 + 2 = Right 358 + 3 = Middle (Left and Right) 359 + 4 = Forward 360 + 5 = Back 361 + 6 = Another one 362 + 7 = Another one 405 363 406 364 byte 4: 407 365 408 366 bit 7 6 5 4 3 2 1 0 409 - . . . . . . y9 y8 367 + p3 p1 p2 p0 . . y9 y8 368 + 369 + p7..p0 = pressure (not EF113) 410 370 411 371 byte 5: 412 372 ··· 434 362 435 363 4.2.2 Two finger touch 436 364 ~~~~~~~~~~~~~~~~ 365 + 366 + Note that the two pairs of coordinates are not exactly the coordinates of the 367 + two fingers, but only the pair of the lower-left and upper-right coordinates. 368 + So the actual fingers might be situated on the other diagonal of the square 369 + defined by these two points. 437 370 438 371 byte 0: 439 372 ··· 453 376 bit 7 6 5 4 3 2 1 0 454 377 ax7 ax6 ax5 ax4 ax3 ax2 ax1 ax0 455 378 456 - ax8..ax0 = first finger absolute x value 379 + ax8..ax0 = lower-left finger absolute x value 457 380 458 381 byte 2: 459 382 460 383 bit 7 6 5 4 3 2 1 0 461 384 ay7 ay6 ay5 ay4 ay3 ay2 ay1 ay0 462 385 463 - ay8..ay0 = first finger absolute y value 386 + ay8..ay0 = lower-left finger absolute y value 464 387 465 388 byte 3: 466 389 ··· 472 395 bit 7 6 5 4 3 2 1 0 473 396 bx7 bx6 bx5 bx4 bx3 bx2 bx1 bx0 474 397 475 - bx8..bx0 = second finger absolute x value 398 + bx8..bx0 = upper-right finger absolute x value 476 399 477 400 byte 5: 478 401 479 402 bit 7 6 5 4 3 2 1 0 480 403 by7 by8 by5 by4 by3 by2 by1 by0 481 404 482 - by8..by0 = second finger absolute y value 405 + by8..by0 = upper-right finger absolute y value
+13
Documentation/input/rotary-encoder.txt
··· 9 9 and by triggering on falling and rising edges, the turn direction can 10 10 be determined. 11 11 12 + Some encoders have both outputs low in stable states, whereas others also have 13 + a stable state with both outputs high (half-period mode). 14 + 12 15 The phase diagram of these two outputs look like this: 13 16 14 17 _____ _____ _____ ··· 29 26 |<-------->| 30 27 one step 31 28 29 + |<-->| 30 + one step (half-period mode) 32 31 33 32 For more information, please see 34 33 http://en.wikipedia.org/wiki/Rotary_encoder ··· 38 33 39 34 1. Events / state machine 40 35 ------------------------- 36 + 37 + In half-period mode, state a) and c) above are used to determine the 38 + rotational direction based on the last stable state. Events are reported in 39 + states b) and d) given that the new stable state is different from the last 40 + (i.e. the rotation was not reversed half-way). 41 + 42 + Otherwise, the following apply: 41 43 42 44 a) Rising edge on channel A, channel B in low state 43 45 This state is used to recognize a clockwise turn ··· 108 96 .gpio_b = GPIO_ROTARY_B, 109 97 .inverted_a = 0, 110 98 .inverted_b = 0, 99 + .half_period = false, 111 100 }; 112 101 113 102 static struct platform_device rotary_encoder_device = {
+1 -3
arch/arm/mach-tegra/include/mach/kbc.h
··· 50 50 unsigned int debounce_cnt; 51 51 unsigned int repeat_cnt; 52 52 53 - unsigned int wake_cnt; /* 0:wake on any key >1:wake on wake_cfg */ 54 - const struct tegra_kbc_wake_key *wake_cfg; 55 - 56 53 struct tegra_kbc_pin_cfg pin_cfg[KBC_MAX_GPIO]; 57 54 const struct matrix_keymap_data *keymap_data; 58 55 59 56 bool wakeup; 60 57 bool use_fn_map; 58 + bool use_ghost_filter; 61 59 }; 62 60 #endif
+11 -8
drivers/input/evdev.c
··· 41 41 struct evdev_client { 42 42 unsigned int head; 43 43 unsigned int tail; 44 + unsigned int packet_head; /* [future] position of the first element of next packet */ 44 45 spinlock_t buffer_lock; /* protects access to buffer, head and tail */ 45 46 struct fasync_struct *fasync; 46 47 struct evdev *evdev; ··· 73 72 client->buffer[client->tail].type = EV_SYN; 74 73 client->buffer[client->tail].code = SYN_DROPPED; 75 74 client->buffer[client->tail].value = 0; 75 + 76 + client->packet_head = client->tail; 77 + } 78 + 79 + if (event->type == EV_SYN && event->code == SYN_REPORT) { 80 + client->packet_head = client->head; 81 + kill_fasync(&client->fasync, SIGIO, POLL_IN); 76 82 } 77 83 78 84 spin_unlock(&client->buffer_lock); 79 - 80 - if (event->type == EV_SYN) 81 - kill_fasync(&client->fasync, SIGIO, POLL_IN); 82 85 } 83 86 84 87 /* ··· 164 159 return error; 165 160 166 161 rcu_assign_pointer(evdev->grab, client); 167 - synchronize_rcu(); 168 162 169 163 return 0; 170 164 } ··· 186 182 spin_lock(&evdev->client_lock); 187 183 list_add_tail_rcu(&client->node, &evdev->client_list); 188 184 spin_unlock(&evdev->client_lock); 189 - synchronize_rcu(); 190 185 } 191 186 192 187 static void evdev_detach_client(struct evdev *evdev, ··· 390 387 if (count < input_event_size()) 391 388 return -EINVAL; 392 389 393 - if (client->head == client->tail && evdev->exist && 390 + if (client->packet_head == client->tail && evdev->exist && 394 391 (file->f_flags & O_NONBLOCK)) 395 392 return -EAGAIN; 396 393 397 394 retval = wait_event_interruptible(evdev->wait, 398 - client->head != client->tail || !evdev->exist); 395 + client->packet_head != client->tail || !evdev->exist); 399 396 if (retval) 400 397 return retval; 401 398 ··· 424 421 poll_wait(file, &evdev->wait, wait); 425 422 426 423 mask = evdev->exist ? POLLOUT | POLLWRNORM : POLLHUP | POLLERR; 427 - if (client->head != client->tail) 424 + if (client->packet_head != client->tail) 428 425 mask |= POLLIN | POLLRDNORM; 429 426 430 427 return mask;
+3 -53
drivers/input/input-polldev.c
··· 13 13 #include <linux/jiffies.h> 14 14 #include <linux/slab.h> 15 15 #include <linux/mutex.h> 16 + #include <linux/workqueue.h> 16 17 #include <linux/input-polldev.h> 17 18 18 19 MODULE_AUTHOR("Dmitry Torokhov <dtor@mail.ru>"); 19 20 MODULE_DESCRIPTION("Generic implementation of a polled input device"); 20 21 MODULE_LICENSE("GPL v2"); 21 22 MODULE_VERSION("0.1"); 22 - 23 - static DEFINE_MUTEX(polldev_mutex); 24 - static int polldev_users; 25 - static struct workqueue_struct *polldev_wq; 26 - 27 - static int input_polldev_start_workqueue(void) 28 - { 29 - int retval; 30 - 31 - retval = mutex_lock_interruptible(&polldev_mutex); 32 - if (retval) 33 - return retval; 34 - 35 - if (!polldev_users) { 36 - polldev_wq = create_singlethread_workqueue("ipolldevd"); 37 - if (!polldev_wq) { 38 - pr_err("failed to create ipolldevd workqueue\n"); 39 - retval = -ENOMEM; 40 - goto out; 41 - } 42 - } 43 - 44 - polldev_users++; 45 - 46 - out: 47 - mutex_unlock(&polldev_mutex); 48 - return retval; 49 - } 50 - 51 - static void input_polldev_stop_workqueue(void) 52 - { 53 - mutex_lock(&polldev_mutex); 54 - 55 - if (!--polldev_users) 56 - destroy_workqueue(polldev_wq); 57 - 58 - mutex_unlock(&polldev_mutex); 59 - } 60 23 61 24 static void input_polldev_queue_work(struct input_polled_dev *dev) 62 25 { ··· 29 66 if (delay >= HZ) 30 67 delay = round_jiffies_relative(delay); 31 68 32 - queue_delayed_work(polldev_wq, &dev->work, delay); 69 + queue_delayed_work(system_freezable_wq, &dev->work, delay); 33 70 } 34 71 35 72 static void input_polled_device_work(struct work_struct *work) ··· 44 81 static int input_open_polled_device(struct input_dev *input) 45 82 { 46 83 struct input_polled_dev *dev = input_get_drvdata(input); 47 - int error; 48 - 49 - error = input_polldev_start_workqueue(); 50 - if (error) 51 - return error; 52 84 53 85 if (dev->open) 54 86 dev->open(dev); 55 87 56 88 /* Only start polling if polling is enabled */ 57 89 if (dev->poll_interval > 0) 58 - queue_delayed_work(polldev_wq, &dev->work, 0); 90 + queue_delayed_work(system_freezable_wq, &dev->work, 0); 59 91 60 92 return 0; 61 93 } ··· 60 102 struct input_polled_dev *dev = input_get_drvdata(input); 61 103 62 104 cancel_delayed_work_sync(&dev->work); 63 - /* 64 - * Clean up work struct to remove references to the workqueue. 65 - * It may be destroyed by the next call. This causes problems 66 - * at next device open-close in case of poll_interval == 0. 67 - */ 68 - INIT_DELAYED_WORK(&dev->work, dev->work.work.func); 69 - input_polldev_stop_workqueue(); 70 105 71 106 if (dev->close) 72 107 dev->close(dev); ··· 246 295 input_unregister_device(dev->input); 247 296 } 248 297 EXPORT_SYMBOL(input_unregister_polled_device); 249 -
-1
drivers/input/input.c
··· 451 451 } 452 452 453 453 rcu_assign_pointer(dev->grab, handle); 454 - synchronize_rcu(); 455 454 456 455 out: 457 456 mutex_unlock(&dev->mutex);
-1
drivers/input/joydev.c
··· 180 180 spin_lock(&joydev->client_lock); 181 181 list_add_tail_rcu(&client->node, &joydev->client_list); 182 182 spin_unlock(&joydev->client_lock); 183 - synchronize_rcu(); 184 183 } 185 184 186 185 static void joydev_detach_client(struct joydev *joydev,
+22
drivers/input/keyboard/Kconfig
··· 32 32 To compile this driver as a module, choose M here: the 33 33 module will be called adp5588-keys. 34 34 35 + config KEYBOARD_ADP5589 36 + tristate "ADP5589 I2C QWERTY Keypad and IO Expander" 37 + depends on I2C 38 + help 39 + Say Y here if you want to use a ADP5589 attached to your 40 + system I2C bus. 41 + 42 + To compile this driver as a module, choose M here: the 43 + module will be called adp5589-keys. 44 + 35 45 config KEYBOARD_AMIGA 36 46 tristate "Amiga keyboard" 37 47 depends on AMIGA ··· 334 324 335 325 To compile this driver as a module, choose M here: the 336 326 module will be called mcs_touchkey. 327 + 328 + config KEYBOARD_MPR121 329 + tristate "Freescale MPR121 Touchkey" 330 + depends on I2C 331 + help 332 + Say Y here if you have Freescale MPR121 touchkey controller 333 + chip in your system. 334 + 335 + If unsure, say N. 336 + 337 + To compile this driver as a module, choose M here: the 338 + module will be called mpr121_touchkey. 337 339 338 340 config KEYBOARD_IMX 339 341 tristate "IMX keypad support"
+2
drivers/input/keyboard/Makefile
··· 6 6 7 7 obj-$(CONFIG_KEYBOARD_ADP5520) += adp5520-keys.o 8 8 obj-$(CONFIG_KEYBOARD_ADP5588) += adp5588-keys.o 9 + obj-$(CONFIG_KEYBOARD_ADP5589) += adp5589-keys.o 9 10 obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o 10 11 obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o 11 12 obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o ··· 28 27 obj-$(CONFIG_KEYBOARD_MATRIX) += matrix_keypad.o 29 28 obj-$(CONFIG_KEYBOARD_MAX7359) += max7359_keypad.o 30 29 obj-$(CONFIG_KEYBOARD_MCS) += mcs_touchkey.o 30 + obj-$(CONFIG_KEYBOARD_MPR121) += mpr121_touchkey.o 31 31 obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o 32 32 obj-$(CONFIG_KEYBOARD_NOMADIK) += nomadik-ske-keypad.o 33 33 obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o
+771
drivers/input/keyboard/adp5589-keys.c
··· 1 + /* 2 + * Description: keypad driver for ADP5589 3 + * I2C QWERTY Keypad and IO Expander 4 + * Bugs: Enter bugs at http://blackfin.uclinux.org/ 5 + * 6 + * Copyright (C) 2010-2011 Analog Devices Inc. 7 + * Licensed under the GPL-2. 8 + */ 9 + 10 + #include <linux/module.h> 11 + #include <linux/version.h> 12 + #include <linux/init.h> 13 + #include <linux/interrupt.h> 14 + #include <linux/irq.h> 15 + #include <linux/workqueue.h> 16 + #include <linux/errno.h> 17 + #include <linux/pm.h> 18 + #include <linux/platform_device.h> 19 + #include <linux/input.h> 20 + #include <linux/i2c.h> 21 + #include <linux/gpio.h> 22 + #include <linux/slab.h> 23 + 24 + #include <linux/input/adp5589.h> 25 + 26 + /* GENERAL_CFG Register */ 27 + #define OSC_EN (1 << 7) 28 + #define CORE_CLK(x) (((x) & 0x3) << 5) 29 + #define LCK_TRK_LOGIC (1 << 4) 30 + #define LCK_TRK_GPI (1 << 3) 31 + #define INT_CFG (1 << 1) 32 + #define RST_CFG (1 << 0) 33 + 34 + /* INT_EN Register */ 35 + #define LOGIC2_IEN (1 << 5) 36 + #define LOGIC1_IEN (1 << 4) 37 + #define LOCK_IEN (1 << 3) 38 + #define OVRFLOW_IEN (1 << 2) 39 + #define GPI_IEN (1 << 1) 40 + #define EVENT_IEN (1 << 0) 41 + 42 + /* Interrupt Status Register */ 43 + #define LOGIC2_INT (1 << 5) 44 + #define LOGIC1_INT (1 << 4) 45 + #define LOCK_INT (1 << 3) 46 + #define OVRFLOW_INT (1 << 2) 47 + #define GPI_INT (1 << 1) 48 + #define EVENT_INT (1 << 0) 49 + 50 + /* STATUS Register */ 51 + 52 + #define LOGIC2_STAT (1 << 7) 53 + #define LOGIC1_STAT (1 << 6) 54 + #define LOCK_STAT (1 << 5) 55 + #define KEC 0xF 56 + 57 + /* PIN_CONFIG_D Register */ 58 + #define C4_EXTEND_CFG (1 << 6) /* RESET2 */ 59 + #define R4_EXTEND_CFG (1 << 5) /* RESET1 */ 60 + 61 + /* LOCK_CFG */ 62 + #define LOCK_EN (1 << 0) 63 + 64 + #define PTIME_MASK 0x3 65 + #define LTIME_MASK 0x3 66 + 67 + /* Key Event Register xy */ 68 + #define KEY_EV_PRESSED (1 << 7) 69 + #define KEY_EV_MASK (0x7F) 70 + 71 + #define KEYP_MAX_EVENT 16 72 + 73 + #define MAXGPIO 19 74 + #define ADP_BANK(offs) ((offs) >> 3) 75 + #define ADP_BIT(offs) (1u << ((offs) & 0x7)) 76 + 77 + struct adp5589_kpad { 78 + struct i2c_client *client; 79 + struct input_dev *input; 80 + unsigned short keycode[ADP5589_KEYMAPSIZE]; 81 + const struct adp5589_gpi_map *gpimap; 82 + unsigned short gpimapsize; 83 + unsigned extend_cfg; 84 + #ifdef CONFIG_GPIOLIB 85 + unsigned char gpiomap[MAXGPIO]; 86 + bool export_gpio; 87 + struct gpio_chip gc; 88 + struct mutex gpio_lock; /* Protect cached dir, dat_out */ 89 + u8 dat_out[3]; 90 + u8 dir[3]; 91 + #endif 92 + }; 93 + 94 + static int adp5589_read(struct i2c_client *client, u8 reg) 95 + { 96 + int ret = i2c_smbus_read_byte_data(client, reg); 97 + 98 + if (ret < 0) 99 + dev_err(&client->dev, "Read Error\n"); 100 + 101 + return ret; 102 + } 103 + 104 + static int adp5589_write(struct i2c_client *client, u8 reg, u8 val) 105 + { 106 + return i2c_smbus_write_byte_data(client, reg, val); 107 + } 108 + 109 + #ifdef CONFIG_GPIOLIB 110 + static int adp5589_gpio_get_value(struct gpio_chip *chip, unsigned off) 111 + { 112 + struct adp5589_kpad *kpad = container_of(chip, struct adp5589_kpad, gc); 113 + unsigned int bank = ADP_BANK(kpad->gpiomap[off]); 114 + unsigned int bit = ADP_BIT(kpad->gpiomap[off]); 115 + 116 + return !!(adp5589_read(kpad->client, ADP5589_GPI_STATUS_A + bank) & 117 + bit); 118 + } 119 + 120 + static void adp5589_gpio_set_value(struct gpio_chip *chip, 121 + unsigned off, int val) 122 + { 123 + struct adp5589_kpad *kpad = container_of(chip, struct adp5589_kpad, gc); 124 + unsigned int bank = ADP_BANK(kpad->gpiomap[off]); 125 + unsigned int bit = ADP_BIT(kpad->gpiomap[off]); 126 + 127 + mutex_lock(&kpad->gpio_lock); 128 + 129 + if (val) 130 + kpad->dat_out[bank] |= bit; 131 + else 132 + kpad->dat_out[bank] &= ~bit; 133 + 134 + adp5589_write(kpad->client, ADP5589_GPO_DATA_OUT_A + bank, 135 + kpad->dat_out[bank]); 136 + 137 + mutex_unlock(&kpad->gpio_lock); 138 + } 139 + 140 + static int adp5589_gpio_direction_input(struct gpio_chip *chip, unsigned off) 141 + { 142 + struct adp5589_kpad *kpad = container_of(chip, struct adp5589_kpad, gc); 143 + unsigned int bank = ADP_BANK(kpad->gpiomap[off]); 144 + unsigned int bit = ADP_BIT(kpad->gpiomap[off]); 145 + int ret; 146 + 147 + mutex_lock(&kpad->gpio_lock); 148 + 149 + kpad->dir[bank] &= ~bit; 150 + ret = adp5589_write(kpad->client, ADP5589_GPIO_DIRECTION_A + bank, 151 + kpad->dir[bank]); 152 + 153 + mutex_unlock(&kpad->gpio_lock); 154 + 155 + return ret; 156 + } 157 + 158 + static int adp5589_gpio_direction_output(struct gpio_chip *chip, 159 + unsigned off, int val) 160 + { 161 + struct adp5589_kpad *kpad = container_of(chip, struct adp5589_kpad, gc); 162 + unsigned int bank = ADP_BANK(kpad->gpiomap[off]); 163 + unsigned int bit = ADP_BIT(kpad->gpiomap[off]); 164 + int ret; 165 + 166 + mutex_lock(&kpad->gpio_lock); 167 + 168 + kpad->dir[bank] |= bit; 169 + 170 + if (val) 171 + kpad->dat_out[bank] |= bit; 172 + else 173 + kpad->dat_out[bank] &= ~bit; 174 + 175 + ret = adp5589_write(kpad->client, ADP5589_GPO_DATA_OUT_A + bank, 176 + kpad->dat_out[bank]); 177 + ret |= adp5589_write(kpad->client, ADP5589_GPIO_DIRECTION_A + bank, 178 + kpad->dir[bank]); 179 + 180 + mutex_unlock(&kpad->gpio_lock); 181 + 182 + return ret; 183 + } 184 + 185 + static int __devinit adp5589_build_gpiomap(struct adp5589_kpad *kpad, 186 + const struct adp5589_kpad_platform_data *pdata) 187 + { 188 + bool pin_used[MAXGPIO]; 189 + int n_unused = 0; 190 + int i; 191 + 192 + memset(pin_used, false, sizeof(pin_used)); 193 + 194 + for (i = 0; i < MAXGPIO; i++) 195 + if (pdata->keypad_en_mask & (1 << i)) 196 + pin_used[i] = true; 197 + 198 + for (i = 0; i < kpad->gpimapsize; i++) 199 + pin_used[kpad->gpimap[i].pin - ADP5589_GPI_PIN_BASE] = true; 200 + 201 + if (kpad->extend_cfg & R4_EXTEND_CFG) 202 + pin_used[4] = true; 203 + 204 + if (kpad->extend_cfg & C4_EXTEND_CFG) 205 + pin_used[12] = true; 206 + 207 + for (i = 0; i < MAXGPIO; i++) 208 + if (!pin_used[i]) 209 + kpad->gpiomap[n_unused++] = i; 210 + 211 + return n_unused; 212 + } 213 + 214 + static int __devinit adp5589_gpio_add(struct adp5589_kpad *kpad) 215 + { 216 + struct device *dev = &kpad->client->dev; 217 + const struct adp5589_kpad_platform_data *pdata = dev->platform_data; 218 + const struct adp5589_gpio_platform_data *gpio_data = pdata->gpio_data; 219 + int i, error; 220 + 221 + if (!gpio_data) 222 + return 0; 223 + 224 + kpad->gc.ngpio = adp5589_build_gpiomap(kpad, pdata); 225 + if (kpad->gc.ngpio == 0) { 226 + dev_info(dev, "No unused gpios left to export\n"); 227 + return 0; 228 + } 229 + 230 + kpad->export_gpio = true; 231 + 232 + kpad->gc.direction_input = adp5589_gpio_direction_input; 233 + kpad->gc.direction_output = adp5589_gpio_direction_output; 234 + kpad->gc.get = adp5589_gpio_get_value; 235 + kpad->gc.set = adp5589_gpio_set_value; 236 + kpad->gc.can_sleep = 1; 237 + 238 + kpad->gc.base = gpio_data->gpio_start; 239 + kpad->gc.label = kpad->client->name; 240 + kpad->gc.owner = THIS_MODULE; 241 + 242 + mutex_init(&kpad->gpio_lock); 243 + 244 + error = gpiochip_add(&kpad->gc); 245 + if (error) { 246 + dev_err(dev, "gpiochip_add failed, err: %d\n", error); 247 + return error; 248 + } 249 + 250 + for (i = 0; i <= ADP_BANK(MAXGPIO); i++) { 251 + kpad->dat_out[i] = adp5589_read(kpad->client, 252 + ADP5589_GPO_DATA_OUT_A + i); 253 + kpad->dir[i] = adp5589_read(kpad->client, 254 + ADP5589_GPIO_DIRECTION_A + i); 255 + } 256 + 257 + if (gpio_data->setup) { 258 + error = gpio_data->setup(kpad->client, 259 + kpad->gc.base, kpad->gc.ngpio, 260 + gpio_data->context); 261 + if (error) 262 + dev_warn(dev, "setup failed, %d\n", error); 263 + } 264 + 265 + return 0; 266 + } 267 + 268 + static void __devexit adp5589_gpio_remove(struct adp5589_kpad *kpad) 269 + { 270 + struct device *dev = &kpad->client->dev; 271 + const struct adp5589_kpad_platform_data *pdata = dev->platform_data; 272 + const struct adp5589_gpio_platform_data *gpio_data = pdata->gpio_data; 273 + int error; 274 + 275 + if (!kpad->export_gpio) 276 + return; 277 + 278 + if (gpio_data->teardown) { 279 + error = gpio_data->teardown(kpad->client, 280 + kpad->gc.base, kpad->gc.ngpio, 281 + gpio_data->context); 282 + if (error) 283 + dev_warn(dev, "teardown failed %d\n", error); 284 + } 285 + 286 + error = gpiochip_remove(&kpad->gc); 287 + if (error) 288 + dev_warn(dev, "gpiochip_remove failed %d\n", error); 289 + } 290 + #else 291 + static inline int adp5589_gpio_add(struct adp5589_kpad *kpad) 292 + { 293 + return 0; 294 + } 295 + 296 + static inline void adp5589_gpio_remove(struct adp5589_kpad *kpad) 297 + { 298 + } 299 + #endif 300 + 301 + static void adp5589_report_switches(struct adp5589_kpad *kpad, 302 + int key, int key_val) 303 + { 304 + int i; 305 + 306 + for (i = 0; i < kpad->gpimapsize; i++) { 307 + if (key_val == kpad->gpimap[i].pin) { 308 + input_report_switch(kpad->input, 309 + kpad->gpimap[i].sw_evt, 310 + key & KEY_EV_PRESSED); 311 + break; 312 + } 313 + } 314 + } 315 + 316 + static void adp5589_report_events(struct adp5589_kpad *kpad, int ev_cnt) 317 + { 318 + int i; 319 + 320 + for (i = 0; i < ev_cnt; i++) { 321 + int key = adp5589_read(kpad->client, ADP5589_FIFO_1 + i); 322 + int key_val = key & KEY_EV_MASK; 323 + 324 + if (key_val >= ADP5589_GPI_PIN_BASE && 325 + key_val <= ADP5589_GPI_PIN_END) { 326 + adp5589_report_switches(kpad, key, key_val); 327 + } else { 328 + input_report_key(kpad->input, 329 + kpad->keycode[key_val - 1], 330 + key & KEY_EV_PRESSED); 331 + } 332 + } 333 + } 334 + 335 + static irqreturn_t adp5589_irq(int irq, void *handle) 336 + { 337 + struct adp5589_kpad *kpad = handle; 338 + struct i2c_client *client = kpad->client; 339 + int status, ev_cnt; 340 + 341 + status = adp5589_read(client, ADP5589_INT_STATUS); 342 + 343 + if (status & OVRFLOW_INT) /* Unlikely and should never happen */ 344 + dev_err(&client->dev, "Event Overflow Error\n"); 345 + 346 + if (status & EVENT_INT) { 347 + ev_cnt = adp5589_read(client, ADP5589_STATUS) & KEC; 348 + if (ev_cnt) { 349 + adp5589_report_events(kpad, ev_cnt); 350 + input_sync(kpad->input); 351 + } 352 + } 353 + 354 + adp5589_write(client, ADP5589_INT_STATUS, status); /* Status is W1C */ 355 + 356 + return IRQ_HANDLED; 357 + } 358 + 359 + static int __devinit adp5589_get_evcode(struct adp5589_kpad *kpad, unsigned short key) 360 + { 361 + int i; 362 + 363 + for (i = 0; i < ADP5589_KEYMAPSIZE; i++) 364 + if (key == kpad->keycode[i]) 365 + return (i + 1) | KEY_EV_PRESSED; 366 + 367 + dev_err(&kpad->client->dev, "RESET/UNLOCK key not in keycode map\n"); 368 + 369 + return -EINVAL; 370 + } 371 + 372 + static int __devinit adp5589_setup(struct adp5589_kpad *kpad) 373 + { 374 + struct i2c_client *client = kpad->client; 375 + const struct adp5589_kpad_platform_data *pdata = 376 + client->dev.platform_data; 377 + int i, ret; 378 + unsigned char evt_mode1 = 0, evt_mode2 = 0, evt_mode3 = 0; 379 + unsigned char pull_mask = 0; 380 + 381 + ret = adp5589_write(client, ADP5589_PIN_CONFIG_A, 382 + pdata->keypad_en_mask & 0xFF); 383 + ret |= adp5589_write(client, ADP5589_PIN_CONFIG_B, 384 + (pdata->keypad_en_mask >> 8) & 0xFF); 385 + ret |= adp5589_write(client, ADP5589_PIN_CONFIG_C, 386 + (pdata->keypad_en_mask >> 16) & 0xFF); 387 + 388 + if (pdata->en_keylock) { 389 + ret |= adp5589_write(client, ADP5589_UNLOCK1, 390 + pdata->unlock_key1); 391 + ret |= adp5589_write(client, ADP5589_UNLOCK2, 392 + pdata->unlock_key2); 393 + ret |= adp5589_write(client, ADP5589_UNLOCK_TIMERS, 394 + pdata->unlock_timer & LTIME_MASK); 395 + ret |= adp5589_write(client, ADP5589_LOCK_CFG, LOCK_EN); 396 + } 397 + 398 + for (i = 0; i < KEYP_MAX_EVENT; i++) 399 + ret |= adp5589_read(client, ADP5589_FIFO_1 + i); 400 + 401 + for (i = 0; i < pdata->gpimapsize; i++) { 402 + unsigned short pin = pdata->gpimap[i].pin; 403 + 404 + if (pin <= ADP5589_GPI_PIN_ROW_END) { 405 + evt_mode1 |= (1 << (pin - ADP5589_GPI_PIN_ROW_BASE)); 406 + } else { 407 + evt_mode2 |= 408 + ((1 << (pin - ADP5589_GPI_PIN_COL_BASE)) & 0xFF); 409 + evt_mode3 |= 410 + ((1 << (pin - ADP5589_GPI_PIN_COL_BASE)) >> 8); 411 + } 412 + } 413 + 414 + if (pdata->gpimapsize) { 415 + ret |= adp5589_write(client, ADP5589_GPI_EVENT_EN_A, evt_mode1); 416 + ret |= adp5589_write(client, ADP5589_GPI_EVENT_EN_B, evt_mode2); 417 + ret |= adp5589_write(client, ADP5589_GPI_EVENT_EN_C, evt_mode3); 418 + } 419 + 420 + if (pdata->pull_dis_mask & pdata->pullup_en_100k & 421 + pdata->pullup_en_300k & pdata->pulldown_en_300k) 422 + dev_warn(&client->dev, "Conflicting pull resistor config\n"); 423 + 424 + for (i = 0; i < MAXGPIO; i++) { 425 + unsigned val = 0; 426 + 427 + if (pdata->pullup_en_300k & (1 << i)) 428 + val = 0; 429 + else if (pdata->pulldown_en_300k & (1 << i)) 430 + val = 1; 431 + else if (pdata->pullup_en_100k & (1 << i)) 432 + val = 2; 433 + else if (pdata->pull_dis_mask & (1 << i)) 434 + val = 3; 435 + 436 + pull_mask |= val << (2 * (i & 0x3)); 437 + 438 + if ((i & 0x3) == 0x3 || i == MAXGPIO - 1) { 439 + ret |= adp5589_write(client, 440 + ADP5589_RPULL_CONFIG_A + (i >> 2), 441 + pull_mask); 442 + pull_mask = 0; 443 + } 444 + } 445 + 446 + if (pdata->reset1_key_1 && pdata->reset1_key_2 && pdata->reset1_key_3) { 447 + ret |= adp5589_write(client, ADP5589_RESET1_EVENT_A, 448 + adp5589_get_evcode(kpad, 449 + pdata->reset1_key_1)); 450 + ret |= adp5589_write(client, ADP5589_RESET1_EVENT_B, 451 + adp5589_get_evcode(kpad, 452 + pdata->reset1_key_2)); 453 + ret |= adp5589_write(client, ADP5589_RESET1_EVENT_C, 454 + adp5589_get_evcode(kpad, 455 + pdata->reset1_key_3)); 456 + kpad->extend_cfg |= R4_EXTEND_CFG; 457 + } 458 + 459 + if (pdata->reset2_key_1 && pdata->reset2_key_2) { 460 + ret |= adp5589_write(client, ADP5589_RESET2_EVENT_A, 461 + adp5589_get_evcode(kpad, 462 + pdata->reset2_key_1)); 463 + ret |= adp5589_write(client, ADP5589_RESET2_EVENT_B, 464 + adp5589_get_evcode(kpad, 465 + pdata->reset2_key_2)); 466 + kpad->extend_cfg |= C4_EXTEND_CFG; 467 + } 468 + 469 + if (kpad->extend_cfg) { 470 + ret |= adp5589_write(client, ADP5589_RESET_CFG, 471 + pdata->reset_cfg); 472 + ret |= adp5589_write(client, ADP5589_PIN_CONFIG_D, 473 + kpad->extend_cfg); 474 + } 475 + 476 + for (i = 0; i <= ADP_BANK(MAXGPIO); i++) 477 + ret |= adp5589_write(client, ADP5589_DEBOUNCE_DIS_A + i, 478 + pdata->debounce_dis_mask >> (i * 8)); 479 + 480 + ret |= adp5589_write(client, ADP5589_POLL_PTIME_CFG, 481 + pdata->scan_cycle_time & PTIME_MASK); 482 + ret |= adp5589_write(client, ADP5589_INT_STATUS, LOGIC2_INT | 483 + LOGIC1_INT | OVRFLOW_INT | LOCK_INT | 484 + GPI_INT | EVENT_INT); /* Status is W1C */ 485 + 486 + ret |= adp5589_write(client, ADP5589_GENERAL_CFG, 487 + INT_CFG | OSC_EN | CORE_CLK(3)); 488 + ret |= adp5589_write(client, ADP5589_INT_EN, 489 + OVRFLOW_IEN | GPI_IEN | EVENT_IEN); 490 + 491 + if (ret < 0) { 492 + dev_err(&client->dev, "Write Error\n"); 493 + return ret; 494 + } 495 + 496 + return 0; 497 + } 498 + 499 + static void __devinit adp5589_report_switch_state(struct adp5589_kpad *kpad) 500 + { 501 + int gpi_stat1 = adp5589_read(kpad->client, ADP5589_GPI_STATUS_A); 502 + int gpi_stat2 = adp5589_read(kpad->client, ADP5589_GPI_STATUS_B); 503 + int gpi_stat3 = adp5589_read(kpad->client, ADP5589_GPI_STATUS_C); 504 + int gpi_stat_tmp, pin_loc; 505 + int i; 506 + 507 + for (i = 0; i < kpad->gpimapsize; i++) { 508 + unsigned short pin = kpad->gpimap[i].pin; 509 + 510 + if (pin <= ADP5589_GPI_PIN_ROW_END) { 511 + gpi_stat_tmp = gpi_stat1; 512 + pin_loc = pin - ADP5589_GPI_PIN_ROW_BASE; 513 + } else if ((pin - ADP5589_GPI_PIN_COL_BASE) < 8) { 514 + gpi_stat_tmp = gpi_stat2; 515 + pin_loc = pin - ADP5589_GPI_PIN_COL_BASE; 516 + } else { 517 + gpi_stat_tmp = gpi_stat3; 518 + pin_loc = pin - ADP5589_GPI_PIN_COL_BASE - 8; 519 + } 520 + 521 + if (gpi_stat_tmp < 0) { 522 + dev_err(&kpad->client->dev, 523 + "Can't read GPIO_DAT_STAT switch" 524 + " %d default to OFF\n", pin); 525 + gpi_stat_tmp = 0; 526 + } 527 + 528 + input_report_switch(kpad->input, 529 + kpad->gpimap[i].sw_evt, 530 + !(gpi_stat_tmp & (1 << pin_loc))); 531 + } 532 + 533 + input_sync(kpad->input); 534 + } 535 + 536 + static int __devinit adp5589_probe(struct i2c_client *client, 537 + const struct i2c_device_id *id) 538 + { 539 + struct adp5589_kpad *kpad; 540 + const struct adp5589_kpad_platform_data *pdata; 541 + struct input_dev *input; 542 + unsigned int revid; 543 + int ret, i; 544 + int error; 545 + 546 + if (!i2c_check_functionality(client->adapter, 547 + I2C_FUNC_SMBUS_BYTE_DATA)) { 548 + dev_err(&client->dev, "SMBUS Byte Data not Supported\n"); 549 + return -EIO; 550 + } 551 + 552 + pdata = client->dev.platform_data; 553 + if (!pdata) { 554 + dev_err(&client->dev, "no platform data?\n"); 555 + return -EINVAL; 556 + } 557 + 558 + if (!((pdata->keypad_en_mask & 0xFF) && 559 + (pdata->keypad_en_mask >> 8)) || !pdata->keymap) { 560 + dev_err(&client->dev, "no rows, cols or keymap from pdata\n"); 561 + return -EINVAL; 562 + } 563 + 564 + if (pdata->keymapsize != ADP5589_KEYMAPSIZE) { 565 + dev_err(&client->dev, "invalid keymapsize\n"); 566 + return -EINVAL; 567 + } 568 + 569 + if (!pdata->gpimap && pdata->gpimapsize) { 570 + dev_err(&client->dev, "invalid gpimap from pdata\n"); 571 + return -EINVAL; 572 + } 573 + 574 + if (pdata->gpimapsize > ADP5589_GPIMAPSIZE_MAX) { 575 + dev_err(&client->dev, "invalid gpimapsize\n"); 576 + return -EINVAL; 577 + } 578 + 579 + for (i = 0; i < pdata->gpimapsize; i++) { 580 + unsigned short pin = pdata->gpimap[i].pin; 581 + 582 + if (pin < ADP5589_GPI_PIN_BASE || pin > ADP5589_GPI_PIN_END) { 583 + dev_err(&client->dev, "invalid gpi pin data\n"); 584 + return -EINVAL; 585 + } 586 + 587 + if ((1 << (pin - ADP5589_GPI_PIN_ROW_BASE)) & 588 + pdata->keypad_en_mask) { 589 + dev_err(&client->dev, "invalid gpi row/col data\n"); 590 + return -EINVAL; 591 + } 592 + } 593 + 594 + if (!client->irq) { 595 + dev_err(&client->dev, "no IRQ?\n"); 596 + return -EINVAL; 597 + } 598 + 599 + kpad = kzalloc(sizeof(*kpad), GFP_KERNEL); 600 + input = input_allocate_device(); 601 + if (!kpad || !input) { 602 + error = -ENOMEM; 603 + goto err_free_mem; 604 + } 605 + 606 + kpad->client = client; 607 + kpad->input = input; 608 + 609 + ret = adp5589_read(client, ADP5589_ID); 610 + if (ret < 0) { 611 + error = ret; 612 + goto err_free_mem; 613 + } 614 + 615 + revid = (u8) ret & ADP5589_DEVICE_ID_MASK; 616 + 617 + input->name = client->name; 618 + input->phys = "adp5589-keys/input0"; 619 + input->dev.parent = &client->dev; 620 + 621 + input_set_drvdata(input, kpad); 622 + 623 + input->id.bustype = BUS_I2C; 624 + input->id.vendor = 0x0001; 625 + input->id.product = 0x0001; 626 + input->id.version = revid; 627 + 628 + input->keycodesize = sizeof(kpad->keycode[0]); 629 + input->keycodemax = pdata->keymapsize; 630 + input->keycode = kpad->keycode; 631 + 632 + memcpy(kpad->keycode, pdata->keymap, 633 + pdata->keymapsize * input->keycodesize); 634 + 635 + kpad->gpimap = pdata->gpimap; 636 + kpad->gpimapsize = pdata->gpimapsize; 637 + 638 + /* setup input device */ 639 + __set_bit(EV_KEY, input->evbit); 640 + 641 + if (pdata->repeat) 642 + __set_bit(EV_REP, input->evbit); 643 + 644 + for (i = 0; i < input->keycodemax; i++) 645 + __set_bit(kpad->keycode[i] & KEY_MAX, input->keybit); 646 + __clear_bit(KEY_RESERVED, input->keybit); 647 + 648 + if (kpad->gpimapsize) 649 + __set_bit(EV_SW, input->evbit); 650 + for (i = 0; i < kpad->gpimapsize; i++) 651 + __set_bit(kpad->gpimap[i].sw_evt, input->swbit); 652 + 653 + error = input_register_device(input); 654 + if (error) { 655 + dev_err(&client->dev, "unable to register input device\n"); 656 + goto err_free_mem; 657 + } 658 + 659 + error = request_threaded_irq(client->irq, NULL, adp5589_irq, 660 + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 661 + client->dev.driver->name, kpad); 662 + if (error) { 663 + dev_err(&client->dev, "irq %d busy?\n", client->irq); 664 + goto err_unreg_dev; 665 + } 666 + 667 + error = adp5589_setup(kpad); 668 + if (error) 669 + goto err_free_irq; 670 + 671 + if (kpad->gpimapsize) 672 + adp5589_report_switch_state(kpad); 673 + 674 + error = adp5589_gpio_add(kpad); 675 + if (error) 676 + goto err_free_irq; 677 + 678 + device_init_wakeup(&client->dev, 1); 679 + i2c_set_clientdata(client, kpad); 680 + 681 + dev_info(&client->dev, "Rev.%d keypad, irq %d\n", revid, client->irq); 682 + return 0; 683 + 684 + err_free_irq: 685 + free_irq(client->irq, kpad); 686 + err_unreg_dev: 687 + input_unregister_device(input); 688 + input = NULL; 689 + err_free_mem: 690 + input_free_device(input); 691 + kfree(kpad); 692 + 693 + return error; 694 + } 695 + 696 + static int __devexit adp5589_remove(struct i2c_client *client) 697 + { 698 + struct adp5589_kpad *kpad = i2c_get_clientdata(client); 699 + 700 + adp5589_write(client, ADP5589_GENERAL_CFG, 0); 701 + free_irq(client->irq, kpad); 702 + input_unregister_device(kpad->input); 703 + adp5589_gpio_remove(kpad); 704 + kfree(kpad); 705 + 706 + return 0; 707 + } 708 + 709 + #ifdef CONFIG_PM_SLEEP 710 + static int adp5589_suspend(struct device *dev) 711 + { 712 + struct adp5589_kpad *kpad = dev_get_drvdata(dev); 713 + struct i2c_client *client = kpad->client; 714 + 715 + disable_irq(client->irq); 716 + 717 + if (device_may_wakeup(&client->dev)) 718 + enable_irq_wake(client->irq); 719 + 720 + return 0; 721 + } 722 + 723 + static int adp5589_resume(struct device *dev) 724 + { 725 + struct adp5589_kpad *kpad = dev_get_drvdata(dev); 726 + struct i2c_client *client = kpad->client; 727 + 728 + if (device_may_wakeup(&client->dev)) 729 + disable_irq_wake(client->irq); 730 + 731 + enable_irq(client->irq); 732 + 733 + return 0; 734 + } 735 + #endif 736 + 737 + static SIMPLE_DEV_PM_OPS(adp5589_dev_pm_ops, adp5589_suspend, adp5589_resume); 738 + 739 + static const struct i2c_device_id adp5589_id[] = { 740 + {"adp5589-keys", 0}, 741 + {} 742 + }; 743 + 744 + MODULE_DEVICE_TABLE(i2c, adp5589_id); 745 + 746 + static struct i2c_driver adp5589_driver = { 747 + .driver = { 748 + .name = KBUILD_MODNAME, 749 + .owner = THIS_MODULE, 750 + .pm = &adp5589_dev_pm_ops, 751 + }, 752 + .probe = adp5589_probe, 753 + .remove = __devexit_p(adp5589_remove), 754 + .id_table = adp5589_id, 755 + }; 756 + 757 + static int __init adp5589_init(void) 758 + { 759 + return i2c_add_driver(&adp5589_driver); 760 + } 761 + module_init(adp5589_init); 762 + 763 + static void __exit adp5589_exit(void) 764 + { 765 + i2c_del_driver(&adp5589_driver); 766 + } 767 + module_exit(adp5589_exit); 768 + 769 + MODULE_LICENSE("GPL"); 770 + MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); 771 + MODULE_DESCRIPTION("ADP5589 Keypad driver");
+8 -3
drivers/input/keyboard/gpio_keys.c
··· 324 324 unsigned int type = button->type ?: EV_KEY; 325 325 int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low; 326 326 327 - input_event(input, type, button->code, !!state); 327 + if (type == EV_ABS) { 328 + if (state) 329 + input_event(input, type, button->code, button->value); 330 + } else { 331 + input_event(input, type, button->code, !!state); 332 + } 328 333 input_sync(input); 329 334 } 330 335 ··· 368 363 struct gpio_button_data *bdata, 369 364 struct gpio_keys_button *button) 370 365 { 371 - char *desc = button->desc ? button->desc : "gpio_keys"; 366 + const char *desc = button->desc ? button->desc : "gpio_keys"; 372 367 struct device *dev = &pdev->dev; 373 368 unsigned long irqflags; 374 369 int irq, error; ··· 473 468 platform_set_drvdata(pdev, ddata); 474 469 input_set_drvdata(input, ddata); 475 470 476 - input->name = pdev->name; 471 + input->name = pdata->name ? : pdev->name; 477 472 input->phys = "gpio-keys/input0"; 478 473 input->dev.parent = &pdev->dev; 479 474 input->open = gpio_keys_open;
+339
drivers/input/keyboard/mpr121_touchkey.c
··· 1 + /* 2 + * Touchkey driver for Freescale MPR121 Controllor 3 + * 4 + * Copyright (C) 2011 Freescale Semiconductor, Inc. 5 + * Author: Zhang Jiejing <jiejing.zhang@freescale.com> 6 + * 7 + * Based on mcs_touchkey.c 8 + * 9 + * This program is free software; you can redistribute it and/or modify 10 + * it under the terms of the GNU General Public License version 2 as 11 + * published by the Free Software Foundation. 12 + * 13 + */ 14 + 15 + #include <linux/module.h> 16 + #include <linux/init.h> 17 + #include <linux/input.h> 18 + #include <linux/i2c.h> 19 + #include <linux/slab.h> 20 + #include <linux/delay.h> 21 + #include <linux/bitops.h> 22 + #include <linux/interrupt.h> 23 + #include <linux/i2c/mpr121_touchkey.h> 24 + 25 + /* Register definitions */ 26 + #define ELE_TOUCH_STATUS_0_ADDR 0x0 27 + #define ELE_TOUCH_STATUS_1_ADDR 0X1 28 + #define MHD_RISING_ADDR 0x2b 29 + #define NHD_RISING_ADDR 0x2c 30 + #define NCL_RISING_ADDR 0x2d 31 + #define FDL_RISING_ADDR 0x2e 32 + #define MHD_FALLING_ADDR 0x2f 33 + #define NHD_FALLING_ADDR 0x30 34 + #define NCL_FALLING_ADDR 0x31 35 + #define FDL_FALLING_ADDR 0x32 36 + #define ELE0_TOUCH_THRESHOLD_ADDR 0x41 37 + #define ELE0_RELEASE_THRESHOLD_ADDR 0x42 38 + #define AFE_CONF_ADDR 0x5c 39 + #define FILTER_CONF_ADDR 0x5d 40 + 41 + /* 42 + * ELECTRODE_CONF_ADDR: This register configures the number of 43 + * enabled capacitance sensing inputs and its run/suspend mode. 44 + */ 45 + #define ELECTRODE_CONF_ADDR 0x5e 46 + #define AUTO_CONFIG_CTRL_ADDR 0x7b 47 + #define AUTO_CONFIG_USL_ADDR 0x7d 48 + #define AUTO_CONFIG_LSL_ADDR 0x7e 49 + #define AUTO_CONFIG_TL_ADDR 0x7f 50 + 51 + /* Threshold of touch/release trigger */ 52 + #define TOUCH_THRESHOLD 0x0f 53 + #define RELEASE_THRESHOLD 0x0a 54 + /* Masks for touch and release triggers */ 55 + #define TOUCH_STATUS_MASK 0xfff 56 + /* MPR121 has 12 keys */ 57 + #define MPR121_MAX_KEY_COUNT 12 58 + 59 + struct mpr121_touchkey { 60 + struct i2c_client *client; 61 + struct input_dev *input_dev; 62 + unsigned int key_val; 63 + unsigned int statusbits; 64 + unsigned int keycount; 65 + u16 keycodes[MPR121_MAX_KEY_COUNT]; 66 + }; 67 + 68 + struct mpr121_init_register { 69 + int addr; 70 + u8 val; 71 + }; 72 + 73 + static const struct mpr121_init_register init_reg_table[] __devinitconst = { 74 + { MHD_RISING_ADDR, 0x1 }, 75 + { NHD_RISING_ADDR, 0x1 }, 76 + { MHD_FALLING_ADDR, 0x1 }, 77 + { NHD_FALLING_ADDR, 0x1 }, 78 + { NCL_FALLING_ADDR, 0xff }, 79 + { FDL_FALLING_ADDR, 0x02 }, 80 + { FILTER_CONF_ADDR, 0x04 }, 81 + { AFE_CONF_ADDR, 0x0b }, 82 + { AUTO_CONFIG_CTRL_ADDR, 0x0b }, 83 + }; 84 + 85 + static irqreturn_t mpr_touchkey_interrupt(int irq, void *dev_id) 86 + { 87 + struct mpr121_touchkey *mpr121 = dev_id; 88 + struct i2c_client *client = mpr121->client; 89 + struct input_dev *input = mpr121->input_dev; 90 + unsigned int key_num, key_val, pressed; 91 + int reg; 92 + 93 + reg = i2c_smbus_read_byte_data(client, ELE_TOUCH_STATUS_1_ADDR); 94 + if (reg < 0) { 95 + dev_err(&client->dev, "i2c read error [%d]\n", reg); 96 + goto out; 97 + } 98 + 99 + reg <<= 8; 100 + reg |= i2c_smbus_read_byte_data(client, ELE_TOUCH_STATUS_0_ADDR); 101 + if (reg < 0) { 102 + dev_err(&client->dev, "i2c read error [%d]\n", reg); 103 + goto out; 104 + } 105 + 106 + reg &= TOUCH_STATUS_MASK; 107 + /* use old press bit to figure out which bit changed */ 108 + key_num = ffs(reg ^ mpr121->statusbits) - 1; 109 + pressed = reg & (1 << key_num); 110 + mpr121->statusbits = reg; 111 + 112 + key_val = mpr121->keycodes[key_num]; 113 + 114 + input_event(input, EV_MSC, MSC_SCAN, key_num); 115 + input_report_key(input, key_val, pressed); 116 + input_sync(input); 117 + 118 + dev_dbg(&client->dev, "key %d %d %s\n", key_num, key_val, 119 + pressed ? "pressed" : "released"); 120 + 121 + out: 122 + return IRQ_HANDLED; 123 + } 124 + 125 + static int __devinit mpr121_phys_init(const struct mpr121_platform_data *pdata, 126 + struct mpr121_touchkey *mpr121, 127 + struct i2c_client *client) 128 + { 129 + const struct mpr121_init_register *reg; 130 + unsigned char usl, lsl, tl; 131 + int i, t, vdd, ret; 132 + 133 + /* Set up touch/release threshold for ele0-ele11 */ 134 + for (i = 0; i <= MPR121_MAX_KEY_COUNT; i++) { 135 + t = ELE0_TOUCH_THRESHOLD_ADDR + (i * 2); 136 + ret = i2c_smbus_write_byte_data(client, t, TOUCH_THRESHOLD); 137 + if (ret < 0) 138 + goto err_i2c_write; 139 + ret = i2c_smbus_write_byte_data(client, t + 1, 140 + RELEASE_THRESHOLD); 141 + if (ret < 0) 142 + goto err_i2c_write; 143 + } 144 + 145 + /* Set up init register */ 146 + for (i = 0; i < ARRAY_SIZE(init_reg_table); i++) { 147 + reg = &init_reg_table[i]; 148 + ret = i2c_smbus_write_byte_data(client, reg->addr, reg->val); 149 + if (ret < 0) 150 + goto err_i2c_write; 151 + } 152 + 153 + 154 + /* 155 + * Capacitance on sensing input varies and needs to be compensated. 156 + * The internal MPR121-auto-configuration can do this if it's 157 + * registers are set properly (based on pdata->vdd_uv). 158 + */ 159 + vdd = pdata->vdd_uv / 1000; 160 + usl = ((vdd - 700) * 256) / vdd; 161 + lsl = (usl * 65) / 100; 162 + tl = (usl * 90) / 100; 163 + ret = i2c_smbus_write_byte_data(client, AUTO_CONFIG_USL_ADDR, usl); 164 + ret |= i2c_smbus_write_byte_data(client, AUTO_CONFIG_LSL_ADDR, lsl); 165 + ret |= i2c_smbus_write_byte_data(client, AUTO_CONFIG_TL_ADDR, tl); 166 + ret |= i2c_smbus_write_byte_data(client, ELECTRODE_CONF_ADDR, 167 + mpr121->keycount); 168 + if (ret != 0) 169 + goto err_i2c_write; 170 + 171 + dev_dbg(&client->dev, "set up with %x keys.\n", mpr121->keycount); 172 + 173 + return 0; 174 + 175 + err_i2c_write: 176 + dev_err(&client->dev, "i2c write error: %d\n", ret); 177 + return ret; 178 + } 179 + 180 + static int __devinit mpr_touchkey_probe(struct i2c_client *client, 181 + const struct i2c_device_id *id) 182 + { 183 + const struct mpr121_platform_data *pdata = client->dev.platform_data; 184 + struct mpr121_touchkey *mpr121; 185 + struct input_dev *input_dev; 186 + int error; 187 + int i; 188 + 189 + if (!pdata) { 190 + dev_err(&client->dev, "no platform data defined\n"); 191 + return -EINVAL; 192 + } 193 + 194 + if (!pdata->keymap || !pdata->keymap_size) { 195 + dev_err(&client->dev, "missing keymap data\n"); 196 + return -EINVAL; 197 + } 198 + 199 + if (pdata->keymap_size > MPR121_MAX_KEY_COUNT) { 200 + dev_err(&client->dev, "too many keys defined\n"); 201 + return -EINVAL; 202 + } 203 + 204 + if (!client->irq) { 205 + dev_err(&client->dev, "irq number should not be zero\n"); 206 + return -EINVAL; 207 + } 208 + 209 + mpr121 = kzalloc(sizeof(struct mpr121_touchkey), GFP_KERNEL); 210 + input_dev = input_allocate_device(); 211 + if (!mpr121 || !input_dev) { 212 + dev_err(&client->dev, "Failed to allocate memory\n"); 213 + error = -ENOMEM; 214 + goto err_free_mem; 215 + } 216 + 217 + mpr121->client = client; 218 + mpr121->input_dev = input_dev; 219 + mpr121->keycount = pdata->keymap_size; 220 + 221 + input_dev->name = "Freescale MPR121 Touchkey"; 222 + input_dev->id.bustype = BUS_I2C; 223 + input_dev->dev.parent = &client->dev; 224 + input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); 225 + 226 + input_dev->keycode = mpr121->keycodes; 227 + input_dev->keycodesize = sizeof(mpr121->keycodes[0]); 228 + input_dev->keycodemax = mpr121->keycount; 229 + 230 + for (i = 0; i < pdata->keymap_size; i++) { 231 + input_set_capability(input_dev, EV_KEY, pdata->keymap[i]); 232 + mpr121->keycodes[i] = pdata->keymap[i]; 233 + } 234 + 235 + error = mpr121_phys_init(pdata, mpr121, client); 236 + if (error) { 237 + dev_err(&client->dev, "Failed to init register\n"); 238 + goto err_free_mem; 239 + } 240 + 241 + error = request_threaded_irq(client->irq, NULL, 242 + mpr_touchkey_interrupt, 243 + IRQF_TRIGGER_FALLING, 244 + client->dev.driver->name, mpr121); 245 + if (error) { 246 + dev_err(&client->dev, "Failed to register interrupt\n"); 247 + goto err_free_mem; 248 + } 249 + 250 + error = input_register_device(input_dev); 251 + if (error) 252 + goto err_free_irq; 253 + 254 + i2c_set_clientdata(client, mpr121); 255 + device_init_wakeup(&client->dev, pdata->wakeup); 256 + 257 + return 0; 258 + 259 + err_free_irq: 260 + free_irq(client->irq, mpr121); 261 + err_free_mem: 262 + input_free_device(input_dev); 263 + kfree(mpr121); 264 + return error; 265 + } 266 + 267 + static int __devexit mpr_touchkey_remove(struct i2c_client *client) 268 + { 269 + struct mpr121_touchkey *mpr121 = i2c_get_clientdata(client); 270 + 271 + free_irq(client->irq, mpr121); 272 + input_unregister_device(mpr121->input_dev); 273 + kfree(mpr121); 274 + 275 + return 0; 276 + } 277 + 278 + #ifdef CONFIG_PM_SLEEP 279 + static int mpr_suspend(struct device *dev) 280 + { 281 + struct i2c_client *client = to_i2c_client(dev); 282 + 283 + if (device_may_wakeup(&client->dev)) 284 + enable_irq_wake(client->irq); 285 + 286 + i2c_smbus_write_byte_data(client, ELECTRODE_CONF_ADDR, 0x00); 287 + 288 + return 0; 289 + } 290 + 291 + static int mpr_resume(struct device *dev) 292 + { 293 + struct i2c_client *client = to_i2c_client(dev); 294 + struct mpr121_touchkey *mpr121 = i2c_get_clientdata(client); 295 + 296 + if (device_may_wakeup(&client->dev)) 297 + disable_irq_wake(client->irq); 298 + 299 + i2c_smbus_write_byte_data(client, ELECTRODE_CONF_ADDR, 300 + mpr121->keycount); 301 + 302 + return 0; 303 + } 304 + #endif 305 + 306 + static SIMPLE_DEV_PM_OPS(mpr121_touchkey_pm_ops, mpr_suspend, mpr_resume); 307 + 308 + static const struct i2c_device_id mpr121_id[] = { 309 + { "mpr121_touchkey", 0 }, 310 + { } 311 + }; 312 + MODULE_DEVICE_TABLE(i2c, mpr121_id); 313 + 314 + static struct i2c_driver mpr_touchkey_driver = { 315 + .driver = { 316 + .name = "mpr121", 317 + .owner = THIS_MODULE, 318 + .pm = &mpr121_touchkey_pm_ops, 319 + }, 320 + .id_table = mpr121_id, 321 + .probe = mpr_touchkey_probe, 322 + .remove = __devexit_p(mpr_touchkey_remove), 323 + }; 324 + 325 + static int __init mpr_touchkey_init(void) 326 + { 327 + return i2c_add_driver(&mpr_touchkey_driver); 328 + } 329 + module_init(mpr_touchkey_init); 330 + 331 + static void __exit mpr_touchkey_exit(void) 332 + { 333 + i2c_del_driver(&mpr_touchkey_driver); 334 + } 335 + module_exit(mpr_touchkey_exit); 336 + 337 + MODULE_LICENSE("GPL"); 338 + MODULE_AUTHOR("Zhang Jiejing <jiejing.zhang@freescale.com>"); 339 + MODULE_DESCRIPTION("Touch Key driver for Freescale MPR121 Chip");
+3 -3
drivers/input/keyboard/omap-keypad.c
··· 413 413 return 0; 414 414 err5: 415 415 for (i = irq_idx - 1; i >=0; i--) 416 - free_irq(row_gpios[i], NULL); 416 + free_irq(row_gpios[i], omap_kp); 417 417 err4: 418 418 input_unregister_device(omap_kp->input); 419 419 input_dev = NULL; ··· 444 444 gpio_free(col_gpios[i]); 445 445 for (i = 0; i < omap_kp->rows; i++) { 446 446 gpio_free(row_gpios[i]); 447 - free_irq(gpio_to_irq(row_gpios[i]), NULL); 447 + free_irq(gpio_to_irq(row_gpios[i]), omap_kp); 448 448 } 449 449 } else { 450 450 omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT); 451 - free_irq(omap_kp->irq, NULL); 451 + free_irq(omap_kp->irq, omap_kp); 452 452 } 453 453 454 454 del_timer_sync(&omap_kp->timer);
+1
drivers/input/keyboard/qt1070.c
··· 248 248 { "qt1070", 0 }, 249 249 { }, 250 250 }; 251 + MODULE_DEVICE_TABLE(i2c, qt1070_id); 251 252 252 253 static struct i2c_driver qt1070_driver = { 253 254 .driver = {
+22 -31
drivers/input/keyboard/sh_keysc.c
··· 20 20 #include <linux/input.h> 21 21 #include <linux/input/sh_keysc.h> 22 22 #include <linux/bitmap.h> 23 - #include <linux/clk.h> 23 + #include <linux/pm_runtime.h> 24 24 #include <linux/io.h> 25 25 #include <linux/slab.h> 26 26 ··· 37 37 38 38 struct sh_keysc_priv { 39 39 void __iomem *iomem_base; 40 - struct clk *clk; 41 40 DECLARE_BITMAP(last_keys, SH_KEYSC_MAXKEYS); 42 41 struct input_dev *input; 43 42 struct sh_keysc_info pdata; ··· 168 169 struct sh_keysc_info *pdata; 169 170 struct resource *res; 170 171 struct input_dev *input; 171 - char clk_name[8]; 172 172 int i; 173 173 int irq, error; 174 174 ··· 208 210 goto err1; 209 211 } 210 212 211 - snprintf(clk_name, sizeof(clk_name), "keysc%d", pdev->id); 212 - priv->clk = clk_get(&pdev->dev, clk_name); 213 - if (IS_ERR(priv->clk)) { 214 - dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name); 215 - error = PTR_ERR(priv->clk); 216 - goto err2; 217 - } 218 - 219 213 priv->input = input_allocate_device(); 220 214 if (!priv->input) { 221 215 dev_err(&pdev->dev, "failed to allocate input device\n"); 222 216 error = -ENOMEM; 223 - goto err3; 217 + goto err2; 224 218 } 225 219 226 220 input = priv->input; ··· 231 241 input->keycodesize = sizeof(pdata->keycodes[0]); 232 242 input->keycodemax = ARRAY_SIZE(pdata->keycodes); 233 243 234 - error = request_irq(irq, sh_keysc_isr, 0, pdev->name, pdev); 244 + error = request_threaded_irq(irq, NULL, sh_keysc_isr, IRQF_ONESHOT, 245 + dev_name(&pdev->dev), pdev); 235 246 if (error) { 236 247 dev_err(&pdev->dev, "failed to request IRQ\n"); 237 - goto err4; 248 + goto err3; 238 249 } 239 250 240 251 for (i = 0; i < SH_KEYSC_MAXKEYS; i++) ··· 245 254 error = input_register_device(input); 246 255 if (error) { 247 256 dev_err(&pdev->dev, "failed to register input device\n"); 248 - goto err5; 257 + goto err4; 249 258 } 250 259 251 - clk_enable(priv->clk); 260 + pm_runtime_enable(&pdev->dev); 261 + pm_runtime_get_sync(&pdev->dev); 252 262 253 263 sh_keysc_write(priv, KYCR1, (sh_keysc_mode[pdata->mode].kymd << 8) | 254 264 pdata->scan_timing); ··· 259 267 260 268 return 0; 261 269 262 - err5: 263 - free_irq(irq, pdev); 264 270 err4: 265 - input_free_device(input); 271 + free_irq(irq, pdev); 266 272 err3: 267 - clk_put(priv->clk); 273 + input_free_device(input); 268 274 err2: 269 275 iounmap(priv->iomem_base); 270 276 err1: ··· 282 292 free_irq(platform_get_irq(pdev, 0), pdev); 283 293 iounmap(priv->iomem_base); 284 294 285 - clk_disable(priv->clk); 286 - clk_put(priv->clk); 295 + pm_runtime_put_sync(&pdev->dev); 296 + pm_runtime_disable(&pdev->dev); 287 297 288 298 platform_set_drvdata(pdev, NULL); 289 299 kfree(priv); ··· 291 301 return 0; 292 302 } 293 303 304 + #if CONFIG_PM_SLEEP 294 305 static int sh_keysc_suspend(struct device *dev) 295 306 { 296 307 struct platform_device *pdev = to_platform_device(dev); ··· 302 311 value = sh_keysc_read(priv, KYCR1); 303 312 304 313 if (device_may_wakeup(dev)) { 305 - value |= 0x80; 314 + sh_keysc_write(priv, KYCR1, value | 0x80); 306 315 enable_irq_wake(irq); 307 316 } else { 308 - value &= ~0x80; 317 + sh_keysc_write(priv, KYCR1, value & ~0x80); 318 + pm_runtime_put_sync(dev); 309 319 } 310 - 311 - sh_keysc_write(priv, KYCR1, value); 312 320 313 321 return 0; 314 322 } ··· 319 329 320 330 if (device_may_wakeup(dev)) 321 331 disable_irq_wake(irq); 332 + else 333 + pm_runtime_get_sync(dev); 322 334 323 335 return 0; 324 336 } 337 + #endif 325 338 326 - static const struct dev_pm_ops sh_keysc_dev_pm_ops = { 327 - .suspend = sh_keysc_suspend, 328 - .resume = sh_keysc_resume, 329 - }; 339 + static SIMPLE_DEV_PM_OPS(sh_keysc_dev_pm_ops, 340 + sh_keysc_suspend, sh_keysc_resume); 330 341 331 - struct platform_driver sh_keysc_device_driver = { 342 + static struct platform_driver sh_keysc_device_driver = { 332 343 .probe = sh_keysc_probe, 333 344 .remove = __devexit_p(sh_keysc_remove), 334 345 .driver = {
+38 -22
drivers/input/keyboard/tegra-kbc.c
··· 66 66 void __iomem *mmio; 67 67 struct input_dev *idev; 68 68 unsigned int irq; 69 - unsigned int wake_enable_rows; 70 - unsigned int wake_enable_cols; 71 69 spinlock_t lock; 72 70 unsigned int repoll_dly; 73 71 unsigned long cp_dly_jiffies; 74 72 bool use_fn_map; 73 + bool use_ghost_filter; 75 74 const struct tegra_kbc_platform_data *pdata; 76 75 unsigned short keycode[KBC_MAX_KEY * 2]; 77 76 unsigned short current_keys[KBC_MAX_KPENT]; ··· 259 260 unsigned int num_down = 0; 260 261 unsigned long flags; 261 262 bool fn_keypress = false; 263 + bool key_in_same_row = false; 264 + bool key_in_same_col = false; 262 265 263 266 spin_lock_irqsave(&kbc->lock, flags); 264 267 for (i = 0; i < KBC_MAX_KPENT; i++) { ··· 286 285 } 287 286 288 287 /* 288 + * Matrix keyboard designs are prone to keyboard ghosting. 289 + * Ghosting occurs if there are 3 keys such that - 290 + * any 2 of the 3 keys share a row, and any 2 of them share a column. 291 + * If so ignore the key presses for this iteration. 292 + */ 293 + if ((kbc->use_ghost_filter) && (num_down >= 3)) { 294 + for (i = 0; i < num_down; i++) { 295 + unsigned int j; 296 + u8 curr_col = scancodes[i] & 0x07; 297 + u8 curr_row = scancodes[i] >> KBC_ROW_SHIFT; 298 + 299 + /* 300 + * Find 2 keys such that one key is in the same row 301 + * and the other is in the same column as the i-th key. 302 + */ 303 + for (j = i + 1; j < num_down; j++) { 304 + u8 col = scancodes[j] & 0x07; 305 + u8 row = scancodes[j] >> KBC_ROW_SHIFT; 306 + 307 + if (col == curr_col) 308 + key_in_same_col = true; 309 + if (row == curr_row) 310 + key_in_same_row = true; 311 + } 312 + } 313 + } 314 + 315 + /* 289 316 * If the platform uses Fn keymaps, translate keys on a Fn keypress. 290 317 * Function keycodes are KBC_MAX_KEY apart from the plain keycodes. 291 318 */ ··· 325 296 } 326 297 327 298 spin_unlock_irqrestore(&kbc->lock, flags); 299 + 300 + /* Ignore the key presses for this iteration? */ 301 + if (key_in_same_col && key_in_same_row) 302 + return; 328 303 329 304 tegra_kbc_report_released_keys(kbc->idev, 330 305 kbc->current_keys, kbc->num_pressed_keys, ··· 416 383 int i; 417 384 unsigned int rst_val; 418 385 419 - BUG_ON(pdata->wake_cnt > KBC_MAX_KEY); 420 - rst_val = (filter && pdata->wake_cnt) ? ~0 : 0; 386 + /* Either mask all keys or none. */ 387 + rst_val = (filter && !pdata->wakeup) ? ~0 : 0; 421 388 422 389 for (i = 0; i < KBC_MAX_ROW; i++) 423 390 writel(rst_val, kbc->mmio + KBC_ROW0_MASK_0 + i * 4); 424 - 425 - if (filter) { 426 - for (i = 0; i < pdata->wake_cnt; i++) { 427 - u32 val, addr; 428 - addr = pdata->wake_cfg[i].row * 4 + KBC_ROW0_MASK_0; 429 - val = readl(kbc->mmio + addr); 430 - val &= ~(1 << pdata->wake_cfg[i].col); 431 - writel(val, kbc->mmio + addr); 432 - } 433 - } 434 391 } 435 392 436 393 static void tegra_kbc_config_pins(struct tegra_kbc *kbc) ··· 582 559 struct resource *res; 583 560 int irq; 584 561 int err; 585 - int i; 586 562 int num_rows = 0; 587 563 unsigned int debounce_cnt; 588 564 unsigned int scan_time_rows; ··· 638 616 goto err_iounmap; 639 617 } 640 618 641 - kbc->wake_enable_rows = 0; 642 - kbc->wake_enable_cols = 0; 643 - for (i = 0; i < pdata->wake_cnt; i++) { 644 - kbc->wake_enable_rows |= (1 << pdata->wake_cfg[i].row); 645 - kbc->wake_enable_cols |= (1 << pdata->wake_cfg[i].col); 646 - } 647 - 648 619 /* 649 620 * The time delay between two consecutive reads of the FIFO is 650 621 * the sum of the repeat time and the time taken for scanning ··· 667 652 input_dev->keycodemax *= 2; 668 653 669 654 kbc->use_fn_map = pdata->use_fn_map; 655 + kbc->use_ghost_filter = pdata->use_ghost_filter; 670 656 keymap_data = pdata->keymap_data ?: &tegra_kbc_default_keymap_data; 671 657 matrix_keypad_build_keymap(keymap_data, KBC_ROW_SHIFT, 672 658 input_dev->keycode, input_dev->keybit);
+32 -93
drivers/input/misc/ad714x.c
··· 79 79 struct ad714x_wheel_drv { 80 80 int abs_pos; 81 81 int flt_pos; 82 - int pre_mean_value; 83 82 int pre_highest_stage; 84 - int pre_mean_value_no_offset; 85 - int mean_value; 86 - int mean_value_no_offset; 87 - int pos_offset; 88 - int pos_ratio; 89 83 int highest_stage; 90 84 enum ad714x_device_state state; 91 85 struct input_dev *input; ··· 152 158 unsigned short data; 153 159 unsigned short mask; 154 160 155 - mask = ((1 << (end_stage + 1)) - 1) - (1 << start_stage); 161 + mask = ((1 << (end_stage + 1)) - 1) - ((1 << start_stage) - 1); 156 162 157 163 ad714x->read(ad714x->dev, STG_COM_INT_EN_REG, &data); 158 - data |= 1 << start_stage; 164 + data |= 1 << end_stage; 159 165 ad714x->write(ad714x->dev, STG_COM_INT_EN_REG, data); 160 166 161 167 ad714x->read(ad714x->dev, STG_HIGH_INT_EN_REG, &data); ··· 169 175 unsigned short data; 170 176 unsigned short mask; 171 177 172 - mask = ((1 << (end_stage + 1)) - 1) - (1 << start_stage); 178 + mask = ((1 << (end_stage + 1)) - 1) - ((1 << start_stage) - 1); 173 179 174 180 ad714x->read(ad714x->dev, STG_COM_INT_EN_REG, &data); 175 - data &= ~(1 << start_stage); 181 + data &= ~(1 << end_stage); 176 182 ad714x->write(ad714x->dev, STG_COM_INT_EN_REG, data); 177 183 178 184 ad714x->read(ad714x->dev, STG_HIGH_INT_EN_REG, &data); ··· 398 404 ad714x_slider_cal_highest_stage(ad714x, idx); 399 405 ad714x_slider_cal_abs_pos(ad714x, idx); 400 406 ad714x_slider_cal_flt_pos(ad714x, idx); 401 - 402 407 input_report_abs(sw->input, ABS_X, sw->flt_pos); 403 408 input_report_key(sw->input, BTN_TOUCH, 1); 404 409 } else { ··· 461 468 /* 462 469 * When the scroll wheel is activated, we compute the absolute position based 463 470 * on the sensor values. To calculate the position, we first determine the 464 - * sensor that has the greatest response among the 8 sensors that constitutes 465 - * the scrollwheel. Then we determined the 2 sensors on either sides of the 471 + * sensor that has the greatest response among the sensors that constitutes 472 + * the scrollwheel. Then we determined the sensors on either sides of the 466 473 * sensor with the highest response and we apply weights to these sensors. The 467 - * result of this computation gives us the mean value which defined by the 468 - * following formula: 469 - * For i= second_before_highest_stage to i= second_after_highest_stage 470 - * v += Sensor response(i)*WEIGHT*(i+3) 471 - * w += Sensor response(i) 472 - * Mean_Value=v/w 473 - * pos_on_scrollwheel = (Mean_Value - position_offset) / position_ratio 474 + * result of this computation gives us the mean value. 474 475 */ 475 476 476 - #define WEIGHT_FACTOR 30 477 - /* This constant prevents the "PositionOffset" from reaching a big value */ 478 - #define OFFSET_POSITION_CLAMP 120 479 477 static void ad714x_wheel_cal_abs_pos(struct ad714x_chip *ad714x, int idx) 480 478 { 481 479 struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx]; 482 480 struct ad714x_wheel_drv *sw = &ad714x->sw->wheel[idx]; 483 481 int stage_num = hw->end_stage - hw->start_stage + 1; 484 - int second_before, first_before, highest, first_after, second_after; 482 + int first_before, highest, first_after; 485 483 int a_param, b_param; 486 484 487 - /* Calculate Mean value */ 488 - 489 - second_before = (sw->highest_stage + stage_num - 2) % stage_num; 490 485 first_before = (sw->highest_stage + stage_num - 1) % stage_num; 491 486 highest = sw->highest_stage; 492 487 first_after = (sw->highest_stage + stage_num + 1) % stage_num; 493 - second_after = (sw->highest_stage + stage_num + 2) % stage_num; 494 488 495 - if (((sw->highest_stage - hw->start_stage) > 1) && 496 - ((hw->end_stage - sw->highest_stage) > 1)) { 497 - a_param = ad714x->sensor_val[second_before] * 498 - (second_before - hw->start_stage + 3) + 499 - ad714x->sensor_val[first_before] * 500 - (second_before - hw->start_stage + 3) + 501 - ad714x->sensor_val[highest] * 502 - (second_before - hw->start_stage + 3) + 503 - ad714x->sensor_val[first_after] * 504 - (first_after - hw->start_stage + 3) + 505 - ad714x->sensor_val[second_after] * 506 - (second_after - hw->start_stage + 3); 507 - } else { 508 - a_param = ad714x->sensor_val[second_before] * 509 - (second_before - hw->start_stage + 1) + 510 - ad714x->sensor_val[first_before] * 511 - (second_before - hw->start_stage + 2) + 512 - ad714x->sensor_val[highest] * 513 - (second_before - hw->start_stage + 3) + 514 - ad714x->sensor_val[first_after] * 515 - (first_after - hw->start_stage + 4) + 516 - ad714x->sensor_val[second_after] * 517 - (second_after - hw->start_stage + 5); 518 - } 519 - a_param *= WEIGHT_FACTOR; 520 - 521 - b_param = ad714x->sensor_val[second_before] + 489 + a_param = ad714x->sensor_val[highest] * 490 + (highest - hw->start_stage) + 491 + ad714x->sensor_val[first_before] * 492 + (highest - hw->start_stage - 1) + 493 + ad714x->sensor_val[first_after] * 494 + (highest - hw->start_stage + 1); 495 + b_param = ad714x->sensor_val[highest] + 522 496 ad714x->sensor_val[first_before] + 523 - ad714x->sensor_val[highest] + 524 - ad714x->sensor_val[first_after] + 525 - ad714x->sensor_val[second_after]; 497 + ad714x->sensor_val[first_after]; 526 498 527 - sw->pre_mean_value = sw->mean_value; 528 - sw->mean_value = a_param / b_param; 499 + sw->abs_pos = ((hw->max_coord / (hw->end_stage - hw->start_stage)) * 500 + a_param) / b_param; 529 501 530 - /* Calculate the offset */ 531 - 532 - if ((sw->pre_highest_stage == hw->end_stage) && 533 - (sw->highest_stage == hw->start_stage)) 534 - sw->pos_offset = sw->mean_value; 535 - else if ((sw->pre_highest_stage == hw->start_stage) && 536 - (sw->highest_stage == hw->end_stage)) 537 - sw->pos_offset = sw->pre_mean_value; 538 - 539 - if (sw->pos_offset > OFFSET_POSITION_CLAMP) 540 - sw->pos_offset = OFFSET_POSITION_CLAMP; 541 - 542 - /* Calculate the mean value without the offset */ 543 - 544 - sw->pre_mean_value_no_offset = sw->mean_value_no_offset; 545 - sw->mean_value_no_offset = sw->mean_value - sw->pos_offset; 546 - if (sw->mean_value_no_offset < 0) 547 - sw->mean_value_no_offset = 0; 548 - 549 - /* Calculate ratio to scale down to NUMBER_OF_WANTED_POSITIONS */ 550 - 551 - if ((sw->pre_highest_stage == hw->end_stage) && 552 - (sw->highest_stage == hw->start_stage)) 553 - sw->pos_ratio = (sw->pre_mean_value_no_offset * 100) / 554 - hw->max_coord; 555 - else if ((sw->pre_highest_stage == hw->start_stage) && 556 - (sw->highest_stage == hw->end_stage)) 557 - sw->pos_ratio = (sw->mean_value_no_offset * 100) / 558 - hw->max_coord; 559 - sw->abs_pos = (sw->mean_value_no_offset * 100) / sw->pos_ratio; 560 502 if (sw->abs_pos > hw->max_coord) 561 503 sw->abs_pos = hw->max_coord; 504 + else if (sw->abs_pos < 0) 505 + sw->abs_pos = 0; 562 506 } 563 507 564 508 static void ad714x_wheel_cal_flt_pos(struct ad714x_chip *ad714x, int idx) ··· 569 639 ad714x_wheel_cal_highest_stage(ad714x, idx); 570 640 ad714x_wheel_cal_abs_pos(ad714x, idx); 571 641 ad714x_wheel_cal_flt_pos(ad714x, idx); 572 - 573 642 input_report_abs(sw->input, ABS_WHEEL, 574 - sw->abs_pos); 643 + sw->flt_pos); 575 644 input_report_key(sw->input, BTN_TOUCH, 1); 576 645 } else { 577 646 /* When the user lifts off the sensor, configure ··· 1078 1149 input[alloc_idx]->id.bustype = bus_type; 1079 1150 input[alloc_idx]->id.product = ad714x->product; 1080 1151 input[alloc_idx]->id.version = ad714x->version; 1152 + input[alloc_idx]->name = "ad714x_captouch_slider"; 1153 + input[alloc_idx]->dev.parent = dev; 1081 1154 1082 1155 error = input_register_device(input[alloc_idx]); 1083 1156 if (error) ··· 1110 1179 input[alloc_idx]->id.bustype = bus_type; 1111 1180 input[alloc_idx]->id.product = ad714x->product; 1112 1181 input[alloc_idx]->id.version = ad714x->version; 1182 + input[alloc_idx]->name = "ad714x_captouch_wheel"; 1183 + input[alloc_idx]->dev.parent = dev; 1113 1184 1114 1185 error = input_register_device(input[alloc_idx]); 1115 1186 if (error) ··· 1145 1212 input[alloc_idx]->id.bustype = bus_type; 1146 1213 input[alloc_idx]->id.product = ad714x->product; 1147 1214 input[alloc_idx]->id.version = ad714x->version; 1215 + input[alloc_idx]->name = "ad714x_captouch_pad"; 1216 + input[alloc_idx]->dev.parent = dev; 1148 1217 1149 1218 error = input_register_device(input[alloc_idx]); 1150 1219 if (error) ··· 1175 1240 input[alloc_idx]->id.bustype = bus_type; 1176 1241 input[alloc_idx]->id.product = ad714x->product; 1177 1242 input[alloc_idx]->id.version = ad714x->version; 1243 + input[alloc_idx]->name = "ad714x_captouch_button"; 1244 + input[alloc_idx]->dev.parent = dev; 1178 1245 1179 1246 error = input_register_device(input[alloc_idx]); 1180 1247 if (error) ··· 1186 1249 } 1187 1250 1188 1251 error = request_threaded_irq(ad714x->irq, NULL, ad714x_interrupt_thread, 1189 - IRQF_TRIGGER_FALLING, "ad714x_captouch", ad714x); 1252 + plat_data->irqflags ? 1253 + plat_data->irqflags : IRQF_TRIGGER_FALLING, 1254 + "ad714x_captouch", ad714x); 1190 1255 if (error) { 1191 1256 dev_err(dev, "can't allocate irq %d\n", ad714x->irq); 1192 1257 goto err_unreg_dev;
+6 -3
drivers/input/misc/ati_remote2.c
··· 737 737 738 738 mutex_lock(&ati_remote2_mutex); 739 739 740 - if (mask != ar2->channel_mask && !ati_remote2_setup(ar2, mask)) 741 - ar2->channel_mask = mask; 740 + if (mask != ar2->channel_mask) { 741 + r = ati_remote2_setup(ar2, mask); 742 + if (!r) 743 + ar2->channel_mask = mask; 744 + } 742 745 743 746 mutex_unlock(&ati_remote2_mutex); 744 747 745 748 usb_autopm_put_interface(ar2->intf[0]); 746 749 747 - return count; 750 + return r ? r : count; 748 751 } 749 752 750 753 static ssize_t ati_remote2_show_mode_mask(struct device *dev,
+86 -39
drivers/input/misc/rotary_encoder.c
··· 2 2 * rotary_encoder.c 3 3 * 4 4 * (c) 2009 Daniel Mack <daniel@caiaq.de> 5 + * Copyright (C) 2011 Johan Hovold <jhovold@gmail.com> 5 6 * 6 7 * state machine code inspired by code from Tim Ruetz 7 8 * ··· 39 38 40 39 bool armed; 41 40 unsigned char dir; /* 0 - clockwise, 1 - CCW */ 41 + 42 + char last_stable; 42 43 }; 44 + 45 + static int rotary_encoder_get_state(struct rotary_encoder_platform_data *pdata) 46 + { 47 + int a = !!gpio_get_value(pdata->gpio_a); 48 + int b = !!gpio_get_value(pdata->gpio_b); 49 + 50 + a ^= pdata->inverted_a; 51 + b ^= pdata->inverted_b; 52 + 53 + return ((a << 1) | b); 54 + } 55 + 56 + static void rotary_encoder_report_event(struct rotary_encoder *encoder) 57 + { 58 + struct rotary_encoder_platform_data *pdata = encoder->pdata; 59 + 60 + if (pdata->relative_axis) { 61 + input_report_rel(encoder->input, 62 + pdata->axis, encoder->dir ? -1 : 1); 63 + } else { 64 + unsigned int pos = encoder->pos; 65 + 66 + if (encoder->dir) { 67 + /* turning counter-clockwise */ 68 + if (pdata->rollover) 69 + pos += pdata->steps; 70 + if (pos) 71 + pos--; 72 + } else { 73 + /* turning clockwise */ 74 + if (pdata->rollover || pos < pdata->steps) 75 + pos++; 76 + } 77 + 78 + if (pdata->rollover) 79 + pos %= pdata->steps; 80 + 81 + encoder->pos = pos; 82 + input_report_abs(encoder->input, pdata->axis, encoder->pos); 83 + } 84 + 85 + input_sync(encoder->input); 86 + } 43 87 44 88 static irqreturn_t rotary_encoder_irq(int irq, void *dev_id) 45 89 { 46 90 struct rotary_encoder *encoder = dev_id; 47 - struct rotary_encoder_platform_data *pdata = encoder->pdata; 48 - int a = !!gpio_get_value(pdata->gpio_a); 49 - int b = !!gpio_get_value(pdata->gpio_b); 50 91 int state; 51 92 52 - a ^= pdata->inverted_a; 53 - b ^= pdata->inverted_b; 54 - state = (a << 1) | b; 93 + state = rotary_encoder_get_state(encoder->pdata); 55 94 56 95 switch (state) { 57 - 58 96 case 0x0: 59 - if (!encoder->armed) 60 - break; 61 - 62 - if (pdata->relative_axis) { 63 - input_report_rel(encoder->input, pdata->axis, 64 - encoder->dir ? -1 : 1); 65 - } else { 66 - unsigned int pos = encoder->pos; 67 - 68 - if (encoder->dir) { 69 - /* turning counter-clockwise */ 70 - if (pdata->rollover) 71 - pos += pdata->steps; 72 - if (pos) 73 - pos--; 74 - } else { 75 - /* turning clockwise */ 76 - if (pdata->rollover || pos < pdata->steps) 77 - pos++; 78 - } 79 - if (pdata->rollover) 80 - pos %= pdata->steps; 81 - encoder->pos = pos; 82 - input_report_abs(encoder->input, pdata->axis, 83 - encoder->pos); 97 + if (encoder->armed) { 98 + rotary_encoder_report_event(encoder); 99 + encoder->armed = false; 84 100 } 85 - input_sync(encoder->input); 86 - 87 - encoder->armed = false; 88 101 break; 89 102 90 103 case 0x1: ··· 115 100 return IRQ_HANDLED; 116 101 } 117 102 103 + static irqreturn_t rotary_encoder_half_period_irq(int irq, void *dev_id) 104 + { 105 + struct rotary_encoder *encoder = dev_id; 106 + int state; 107 + 108 + state = rotary_encoder_get_state(encoder->pdata); 109 + 110 + switch (state) { 111 + case 0x00: 112 + case 0x03: 113 + if (state != encoder->last_stable) { 114 + rotary_encoder_report_event(encoder); 115 + encoder->last_stable = state; 116 + } 117 + break; 118 + 119 + case 0x01: 120 + case 0x02: 121 + encoder->dir = (encoder->last_stable + state) & 0x01; 122 + break; 123 + } 124 + 125 + return IRQ_HANDLED; 126 + } 127 + 118 128 static int __devinit rotary_encoder_probe(struct platform_device *pdev) 119 129 { 120 130 struct rotary_encoder_platform_data *pdata = pdev->dev.platform_data; 121 131 struct rotary_encoder *encoder; 122 132 struct input_dev *input; 133 + irq_handler_t handler; 123 134 int err; 124 135 125 136 if (!pdata) { ··· 216 175 } 217 176 218 177 /* request the IRQs */ 219 - err = request_irq(encoder->irq_a, &rotary_encoder_irq, 178 + if (pdata->half_period) { 179 + handler = &rotary_encoder_half_period_irq; 180 + encoder->last_stable = rotary_encoder_get_state(pdata); 181 + } else { 182 + handler = &rotary_encoder_irq; 183 + } 184 + 185 + err = request_irq(encoder->irq_a, handler, 220 186 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 221 187 DRV_NAME, encoder); 222 188 if (err) { ··· 232 184 goto exit_free_gpio_b; 233 185 } 234 186 235 - err = request_irq(encoder->irq_b, &rotary_encoder_irq, 187 + err = request_irq(encoder->irq_b, handler, 236 188 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 237 189 DRV_NAME, encoder); 238 190 if (err) { ··· 300 252 301 253 MODULE_ALIAS("platform:" DRV_NAME); 302 254 MODULE_DESCRIPTION("GPIO rotary encoder driver"); 303 - MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); 255 + MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>, Johan Hovold"); 304 256 MODULE_LICENSE("GPL v2"); 305 -
+1 -1
drivers/input/misc/twl4030-pwrbutton.c
··· 89 89 return 0; 90 90 91 91 free_irq: 92 - free_irq(irq, NULL); 92 + free_irq(irq, pwr); 93 93 free_input_dev: 94 94 input_free_device(pwr); 95 95 return err;
+55 -17
drivers/input/mouse/elantech.c
··· 16 16 #include <linux/slab.h> 17 17 #include <linux/module.h> 18 18 #include <linux/input.h> 19 + #include <linux/input/mt.h> 19 20 #include <linux/serio.h> 20 21 #include <linux/libps2.h> 21 22 #include "psmouse.h" ··· 243 242 input_sync(dev); 244 243 } 245 244 245 + static void elantech_set_slot(struct input_dev *dev, int slot, bool active, 246 + unsigned int x, unsigned int y) 247 + { 248 + input_mt_slot(dev, slot); 249 + input_mt_report_slot_state(dev, MT_TOOL_FINGER, active); 250 + if (active) { 251 + input_report_abs(dev, ABS_MT_POSITION_X, x); 252 + input_report_abs(dev, ABS_MT_POSITION_Y, y); 253 + } 254 + } 255 + 256 + /* x1 < x2 and y1 < y2 when two fingers, x = y = 0 when not pressed */ 257 + static void elantech_report_semi_mt_data(struct input_dev *dev, 258 + unsigned int num_fingers, 259 + unsigned int x1, unsigned int y1, 260 + unsigned int x2, unsigned int y2) 261 + { 262 + elantech_set_slot(dev, 0, num_fingers != 0, x1, y1); 263 + elantech_set_slot(dev, 1, num_fingers == 2, x2, y2); 264 + } 265 + 246 266 /* 247 267 * Interpret complete data packets and report absolute mode input events for 248 268 * hardware version 2. (6 byte packets) 249 269 */ 250 270 static void elantech_report_absolute_v2(struct psmouse *psmouse) 251 271 { 272 + struct elantech_data *etd = psmouse->private; 252 273 struct input_dev *dev = psmouse->dev; 253 274 unsigned char *packet = psmouse->packet; 254 - int fingers, x1, y1, x2, y2; 275 + unsigned int fingers, x1 = 0, y1 = 0, x2 = 0, y2 = 0, width = 0, pres = 0; 255 276 256 277 /* byte 0: n1 n0 . . . . R L */ 257 278 fingers = (packet[0] & 0xc0) >> 6; ··· 293 270 * byte 1: . . . . . x10 x9 x8 294 271 * byte 2: x7 x6 x5 x4 x4 x2 x1 x0 295 272 */ 296 - input_report_abs(dev, ABS_X, 297 - ((packet[1] & 0x07) << 8) | packet[2]); 273 + x1 = ((packet[1] & 0x07) << 8) | packet[2]; 298 274 /* 299 275 * byte 4: . . . . . . y9 y8 300 276 * byte 5: y7 y6 y5 y4 y3 y2 y1 y0 301 277 */ 302 - input_report_abs(dev, ABS_Y, 303 - ETP_YMAX_V2 - (((packet[4] & 0x03) << 8) | packet[5])); 278 + y1 = ETP_YMAX_V2 - (((packet[4] & 0x03) << 8) | packet[5]); 279 + 280 + input_report_abs(dev, ABS_X, x1); 281 + input_report_abs(dev, ABS_Y, y1); 282 + 283 + pres = (packet[1] & 0xf0) | ((packet[4] & 0xf0) >> 4); 284 + width = ((packet[0] & 0x30) >> 2) | ((packet[3] & 0x30) >> 4); 304 285 break; 305 286 306 287 case 2: ··· 330 303 */ 331 304 input_report_abs(dev, ABS_X, x1 << 2); 332 305 input_report_abs(dev, ABS_Y, y1 << 2); 333 - /* 334 - * For compatibility with the proprietary X Elantech driver 335 - * report both coordinates as hat coordinates 336 - */ 337 - input_report_abs(dev, ABS_HAT0X, x1); 338 - input_report_abs(dev, ABS_HAT0Y, y1); 339 - input_report_abs(dev, ABS_HAT1X, x2); 340 - input_report_abs(dev, ABS_HAT1Y, y2); 306 + 307 + /* Unknown so just report sensible values */ 308 + pres = 127; 309 + width = 7; 341 310 break; 342 311 } 343 312 313 + elantech_report_semi_mt_data(dev, fingers, x1, y1, x2, y2); 344 314 input_report_key(dev, BTN_TOOL_FINGER, fingers == 1); 345 315 input_report_key(dev, BTN_TOOL_DOUBLETAP, fingers == 2); 346 316 input_report_key(dev, BTN_TOOL_TRIPLETAP, fingers == 3); 347 317 input_report_key(dev, BTN_TOOL_QUADTAP, fingers == 4); 348 318 input_report_key(dev, BTN_LEFT, packet[0] & 0x01); 349 319 input_report_key(dev, BTN_RIGHT, packet[0] & 0x02); 320 + if (etd->reports_pressure) { 321 + input_report_abs(dev, ABS_PRESSURE, pres); 322 + input_report_abs(dev, ABS_TOOL_WIDTH, width); 323 + } 350 324 351 325 input_sync(dev); 352 326 } ··· 506 478 __set_bit(BTN_TOOL_QUADTAP, dev->keybit); 507 479 input_set_abs_params(dev, ABS_X, ETP_XMIN_V2, ETP_XMAX_V2, 0, 0); 508 480 input_set_abs_params(dev, ABS_Y, ETP_YMIN_V2, ETP_YMAX_V2, 0, 0); 509 - input_set_abs_params(dev, ABS_HAT0X, ETP_2FT_XMIN, ETP_2FT_XMAX, 0, 0); 510 - input_set_abs_params(dev, ABS_HAT0Y, ETP_2FT_YMIN, ETP_2FT_YMAX, 0, 0); 511 - input_set_abs_params(dev, ABS_HAT1X, ETP_2FT_XMIN, ETP_2FT_XMAX, 0, 0); 512 - input_set_abs_params(dev, ABS_HAT1Y, ETP_2FT_YMIN, ETP_2FT_YMAX, 0, 0); 481 + if (etd->reports_pressure) { 482 + input_set_abs_params(dev, ABS_PRESSURE, ETP_PMIN_V2, 483 + ETP_PMAX_V2, 0, 0); 484 + input_set_abs_params(dev, ABS_TOOL_WIDTH, ETP_WMIN_V2, 485 + ETP_WMAX_V2, 0, 0); 486 + } 487 + __set_bit(INPUT_PROP_SEMI_MT, dev->propbit); 488 + input_mt_init_slots(dev, 2); 489 + input_set_abs_params(dev, ABS_MT_POSITION_X, ETP_XMIN_V2, ETP_XMAX_V2, 0, 0); 490 + input_set_abs_params(dev, ABS_MT_POSITION_Y, ETP_YMIN_V2, ETP_YMAX_V2, 0, 0); 513 491 break; 514 492 } 515 493 } ··· 759 725 etd->debug = 1; 760 726 /* Don't know how to do parity checking for version 2 */ 761 727 etd->paritycheck = 0; 728 + 729 + if (etd->fw_version >= 0x020800) 730 + etd->reports_pressure = true; 731 + 762 732 } else { 763 733 etd->hw_version = 1; 764 734 etd->paritycheck = 1;
+6
drivers/input/mouse/elantech.h
··· 77 77 #define ETP_YMIN_V2 ( 0 + ETP_EDGE_FUZZ_V2) 78 78 #define ETP_YMAX_V2 ( 768 - ETP_EDGE_FUZZ_V2) 79 79 80 + #define ETP_PMIN_V2 0 81 + #define ETP_PMAX_V2 255 82 + #define ETP_WMIN_V2 0 83 + #define ETP_WMAX_V2 15 84 + 80 85 /* 81 86 * For two finger touches the coordinate of each finger gets reported 82 87 * separately but with reduced resolution. ··· 107 102 unsigned char capabilities; 108 103 bool paritycheck; 109 104 bool jumpy_cursor; 105 + bool reports_pressure; 110 106 unsigned char hw_version; 111 107 unsigned int fw_version; 112 108 unsigned int single_finger_reports;
-1
drivers/input/mousedev.c
··· 508 508 spin_lock(&mousedev->client_lock); 509 509 list_add_tail_rcu(&client->node, &mousedev->client_list); 510 510 spin_unlock(&mousedev->client_lock); 511 - synchronize_rcu(); 512 511 } 513 512 514 513 static void mousedev_detach_client(struct mousedev *mousedev,
+12
drivers/input/touchscreen/Kconfig
··· 248 248 To compile this driver as a module, choose M here: the 249 249 module will be called lpc32xx_ts. 250 250 251 + config TOUCHSCREEN_MAX11801 252 + tristate "MAX11801 based touchscreens" 253 + depends on I2C 254 + help 255 + Say Y here if you have a MAX11801 based touchscreen 256 + controller. 257 + 258 + If unsure, say N. 259 + 260 + To compile this driver as a module, choose M here: the 261 + module will be called max11801_ts. 262 + 251 263 config TOUCHSCREEN_MCS5000 252 264 tristate "MELFAS MCS-5000 touchscreen" 253 265 depends on I2C
+1
drivers/input/touchscreen/Makefile
··· 27 27 obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o 28 28 obj-$(CONFIG_TOUCHSCREEN_INTEL_MID) += intel-mid-touch.o 29 29 obj-$(CONFIG_TOUCHSCREEN_LPC32XX) += lpc32xx_ts.o 30 + obj-$(CONFIG_TOUCHSCREEN_MAX11801) += max11801_ts.o 30 31 obj-$(CONFIG_TOUCHSCREEN_MC13783) += mc13783_ts.o 31 32 obj-$(CONFIG_TOUCHSCREEN_MCS5000) += mcs5000_ts.o 32 33 obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o
+18 -8
drivers/input/touchscreen/ads7846.c
··· 109 109 u16 pressure_max; 110 110 111 111 bool swap_xy; 112 + bool use_internal; 112 113 113 114 struct ads7846_packet *packet; 114 115 ··· 308 307 struct ads7846 *ts = dev_get_drvdata(dev); 309 308 struct ser_req *req; 310 309 int status; 311 - int use_internal; 312 310 313 311 req = kzalloc(sizeof *req, GFP_KERNEL); 314 312 if (!req) ··· 315 315 316 316 spi_message_init(&req->msg); 317 317 318 - /* FIXME boards with ads7846 might use external vref instead ... */ 319 - use_internal = (ts->model == 7846); 320 - 321 318 /* maybe turn on internal vREF, and let it settle */ 322 - if (use_internal) { 319 + if (ts->use_internal) { 323 320 req->ref_on = REF_ON; 324 321 req->xfer[0].tx_buf = &req->ref_on; 325 322 req->xfer[0].len = 1; ··· 328 331 /* for 1uF, settle for 800 usec; no cap, 100 usec. */ 329 332 req->xfer[1].delay_usecs = ts->vref_delay_usecs; 330 333 spi_message_add_tail(&req->xfer[1], &req->msg); 334 + 335 + /* Enable reference voltage */ 336 + command |= ADS_PD10_REF_ON; 331 337 } 338 + 339 + /* Enable ADC in every case */ 340 + command |= ADS_PD10_ADC_ON; 332 341 333 342 /* take sample */ 334 343 req->command = (u8) command; ··· 419 416 { \ 420 417 struct ads7846 *ts = dev_get_drvdata(dev); \ 421 418 ssize_t v = ads7846_read12_ser(dev, \ 422 - READ_12BIT_SER(var) | ADS_PD10_ALL_ON); \ 419 + READ_12BIT_SER(var)); \ 423 420 if (v < 0) \ 424 421 return v; \ 425 422 return sprintf(buf, "%u\n", adjust(ts, v)); \ ··· 512 509 if (!ts->vref_mv) { 513 510 dev_dbg(&spi->dev, "assuming 2.5V internal vREF\n"); 514 511 ts->vref_mv = 2500; 512 + ts->use_internal = true; 515 513 } 516 514 break; 517 515 case 7845: ··· 973 969 pdata->gpio_pendown); 974 970 return err; 975 971 } 972 + err = gpio_direction_input(pdata->gpio_pendown); 973 + if (err) { 974 + dev_err(&spi->dev, "failed to setup pendown GPIO%d\n", 975 + pdata->gpio_pendown); 976 + gpio_free(pdata->gpio_pendown); 977 + return err; 978 + } 976 979 977 980 ts->gpio_pendown = pdata->gpio_pendown; 978 981 ··· 1351 1340 if (ts->model == 7845) 1352 1341 ads7845_read12_ser(&spi->dev, PWRDOWN); 1353 1342 else 1354 - (void) ads7846_read12_ser(&spi->dev, 1355 - READ_12BIT_SER(vaux) | ADS_PD10_ALL_ON); 1343 + (void) ads7846_read12_ser(&spi->dev, READ_12BIT_SER(vaux)); 1356 1344 1357 1345 err = sysfs_create_group(&spi->dev.kobj, &ads784x_attr_group); 1358 1346 if (err)
+62 -30
drivers/input/touchscreen/atmel_mxt_ts.c
··· 17 17 #include <linux/firmware.h> 18 18 #include <linux/i2c.h> 19 19 #include <linux/i2c/atmel_mxt_ts.h> 20 - #include <linux/input.h> 20 + #include <linux/input/mt.h> 21 21 #include <linux/interrupt.h> 22 22 #include <linux/slab.h> 23 23 ··· 196 196 #define MXT_PRESS (1 << 6) 197 197 #define MXT_DETECT (1 << 7) 198 198 199 + /* Touch orient bits */ 200 + #define MXT_XY_SWITCH (1 << 0) 201 + #define MXT_X_INVERT (1 << 1) 202 + #define MXT_Y_INVERT (1 << 2) 203 + 199 204 /* Touchscreen absolute values */ 200 - #define MXT_MAX_XC 0x3ff 201 - #define MXT_MAX_YC 0x3ff 202 205 #define MXT_MAX_AREA 0xff 203 206 204 207 #define MXT_MAX_FINGER 10 ··· 249 246 struct mxt_info info; 250 247 struct mxt_finger finger[MXT_MAX_FINGER]; 251 248 unsigned int irq; 249 + unsigned int max_x; 250 + unsigned int max_y; 252 251 }; 253 252 254 253 static bool mxt_object_readable(unsigned int type) ··· 504 499 if (!finger[id].status) 505 500 continue; 506 501 507 - input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, 508 - finger[id].status != MXT_RELEASE ? 509 - finger[id].area : 0); 510 - input_report_abs(input_dev, ABS_MT_POSITION_X, 511 - finger[id].x); 512 - input_report_abs(input_dev, ABS_MT_POSITION_Y, 513 - finger[id].y); 514 - input_mt_sync(input_dev); 502 + input_mt_slot(input_dev, id); 503 + input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, 504 + finger[id].status != MXT_RELEASE); 515 505 516 - if (finger[id].status == MXT_RELEASE) 517 - finger[id].status = 0; 518 - else 506 + if (finger[id].status != MXT_RELEASE) { 519 507 finger_num++; 508 + input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, 509 + finger[id].area); 510 + input_report_abs(input_dev, ABS_MT_POSITION_X, 511 + finger[id].x); 512 + input_report_abs(input_dev, ABS_MT_POSITION_Y, 513 + finger[id].y); 514 + } else { 515 + finger[id].status = 0; 516 + } 520 517 } 521 518 522 519 input_report_key(input_dev, BTN_TOUCH, finger_num > 0); ··· 556 549 if (!(status & (MXT_PRESS | MXT_MOVE))) 557 550 return; 558 551 559 - x = (message->message[1] << 2) | ((message->message[3] & ~0x3f) >> 6); 560 - y = (message->message[2] << 2) | ((message->message[3] & ~0xf3) >> 2); 552 + x = (message->message[1] << 4) | ((message->message[3] >> 4) & 0xf); 553 + y = (message->message[2] << 4) | ((message->message[3] & 0xf)); 554 + if (data->max_x < 1024) 555 + x = x >> 2; 556 + if (data->max_y < 1024) 557 + y = y >> 2; 558 + 561 559 area = message->message[4]; 562 560 563 561 dev_dbg(dev, "[%d] %s x: %d, y: %d, area: %d\n", id, ··· 816 804 if (error) 817 805 return error; 818 806 819 - error = mxt_make_highchg(data); 820 - if (error) 821 - return error; 822 - 823 807 mxt_handle_pdata(data); 824 808 825 809 /* Backup to memory */ ··· 851 843 info->object_num); 852 844 853 845 return 0; 846 + } 847 + 848 + static void mxt_calc_resolution(struct mxt_data *data) 849 + { 850 + unsigned int max_x = data->pdata->x_size - 1; 851 + unsigned int max_y = data->pdata->y_size - 1; 852 + 853 + if (data->pdata->orient & MXT_XY_SWITCH) { 854 + data->max_x = max_y; 855 + data->max_y = max_x; 856 + } else { 857 + data->max_x = max_x; 858 + data->max_y = max_y; 859 + } 854 860 } 855 861 856 862 static ssize_t mxt_object_show(struct device *dev, ··· 1003 981 1004 982 enable_irq(data->irq); 1005 983 984 + error = mxt_make_highchg(data); 985 + if (error) 986 + return error; 987 + 1006 988 return count; 1007 989 } 1008 990 ··· 1078 1052 input_dev->open = mxt_input_open; 1079 1053 input_dev->close = mxt_input_close; 1080 1054 1055 + data->client = client; 1056 + data->input_dev = input_dev; 1057 + data->pdata = pdata; 1058 + data->irq = client->irq; 1059 + 1060 + mxt_calc_resolution(data); 1061 + 1081 1062 __set_bit(EV_ABS, input_dev->evbit); 1082 1063 __set_bit(EV_KEY, input_dev->evbit); 1083 1064 __set_bit(BTN_TOUCH, input_dev->keybit); 1084 1065 1085 1066 /* For single touch */ 1086 1067 input_set_abs_params(input_dev, ABS_X, 1087 - 0, MXT_MAX_XC, 0, 0); 1068 + 0, data->max_x, 0, 0); 1088 1069 input_set_abs_params(input_dev, ABS_Y, 1089 - 0, MXT_MAX_YC, 0, 0); 1070 + 0, data->max_y, 0, 0); 1090 1071 1091 1072 /* For multi touch */ 1073 + input_mt_init_slots(input_dev, MXT_MAX_FINGER); 1092 1074 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 1093 1075 0, MXT_MAX_AREA, 0, 0); 1094 1076 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 1095 - 0, MXT_MAX_XC, 0, 0); 1077 + 0, data->max_x, 0, 0); 1096 1078 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 1097 - 0, MXT_MAX_YC, 0, 0); 1079 + 0, data->max_y, 0, 0); 1098 1080 1099 1081 input_set_drvdata(input_dev, data); 1100 - 1101 - data->client = client; 1102 - data->input_dev = input_dev; 1103 - data->pdata = pdata; 1104 - data->irq = client->irq; 1105 - 1106 1082 i2c_set_clientdata(client, data); 1107 1083 1108 1084 error = mxt_initialize(data); ··· 1117 1089 dev_err(&client->dev, "Failed to register interrupt\n"); 1118 1090 goto err_free_object; 1119 1091 } 1092 + 1093 + error = mxt_make_highchg(data); 1094 + if (error) 1095 + goto err_free_irq; 1120 1096 1121 1097 error = input_register_device(input_dev); 1122 1098 if (error)
+1 -1
drivers/input/touchscreen/atmel_tsadcc.c
··· 317 317 err_release_mem: 318 318 release_mem_region(res->start, resource_size(res)); 319 319 err_free_dev: 320 - input_free_device(ts_dev->input); 320 + input_free_device(input_dev); 321 321 err_free_mem: 322 322 kfree(ts_dev); 323 323 return err;
+4 -4
drivers/input/touchscreen/h3600_ts_input.c
··· 396 396 set_GPIO_IRQ_edge(GPIO_BITSY_NPOWER_BUTTON, GPIO_RISING_EDGE); 397 397 398 398 if (request_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, action_button_handler, 399 - IRQF_SHARED | IRQF_DISABLED, "h3600_action", &ts->dev)) { 399 + IRQF_SHARED | IRQF_DISABLED, "h3600_action", ts->dev)) { 400 400 printk(KERN_ERR "h3600ts.c: Could not allocate Action Button IRQ!\n"); 401 401 err = -EBUSY; 402 402 goto fail1; 403 403 } 404 404 405 405 if (request_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, npower_button_handler, 406 - IRQF_SHARED | IRQF_DISABLED, "h3600_suspend", &ts->dev)) { 406 + IRQF_SHARED | IRQF_DISABLED, "h3600_suspend", ts->dev)) { 407 407 printk(KERN_ERR "h3600ts.c: Could not allocate Power Button IRQ!\n"); 408 408 err = -EBUSY; 409 409 goto fail2; ··· 439 439 { 440 440 struct h3600_dev *ts = serio_get_drvdata(serio); 441 441 442 - free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev); 443 - free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, &ts->dev); 442 + free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts->dev); 443 + free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, ts->dev); 444 444 input_get_device(ts->dev); 445 445 input_unregister_device(ts->dev); 446 446 serio_close(serio);
+272
drivers/input/touchscreen/max11801_ts.c
··· 1 + /* 2 + * Driver for MAXI MAX11801 - A Resistive touch screen controller with 3 + * i2c interface 4 + * 5 + * Copyright (C) 2011 Freescale Semiconductor, Inc. 6 + * Author: Zhang Jiejing <jiejing.zhang@freescale.com> 7 + * 8 + * Based on mcs5000_ts.c 9 + * 10 + * This program is free software; you can redistribute it and/or modify 11 + * it under the terms of the GNU General Public License as published by 12 + * the Free Software Foundation; either version 2 of the License. 13 + */ 14 + 15 + /* 16 + * This driver aims to support the series of MAXI touch chips max11801 17 + * through max11803. The main difference between these 4 chips can be 18 + * found in the table below: 19 + * ----------------------------------------------------- 20 + * | CHIP | AUTO MODE SUPPORT(FIFO) | INTERFACE | 21 + * |----------------------------------------------------| 22 + * | max11800 | YES | SPI | 23 + * | max11801 | YES | I2C | 24 + * | max11802 | NO | SPI | 25 + * | max11803 | NO | I2C | 26 + * ------------------------------------------------------ 27 + * 28 + * Currently, this driver only supports max11801. 29 + * 30 + * Data Sheet: 31 + * http://www.maxim-ic.com/datasheet/index.mvp/id/5943 32 + */ 33 + 34 + #include <linux/module.h> 35 + #include <linux/init.h> 36 + #include <linux/i2c.h> 37 + #include <linux/interrupt.h> 38 + #include <linux/input.h> 39 + #include <linux/slab.h> 40 + #include <linux/bitops.h> 41 + 42 + /* Register Address define */ 43 + #define GENERNAL_STATUS_REG 0x00 44 + #define GENERNAL_CONF_REG 0x01 45 + #define MESURE_RES_CONF_REG 0x02 46 + #define MESURE_AVER_CONF_REG 0x03 47 + #define ADC_SAMPLE_TIME_CONF_REG 0x04 48 + #define PANEL_SETUPTIME_CONF_REG 0x05 49 + #define DELAY_CONVERSION_CONF_REG 0x06 50 + #define TOUCH_DETECT_PULLUP_CONF_REG 0x07 51 + #define AUTO_MODE_TIME_CONF_REG 0x08 /* only for max11800/max11801 */ 52 + #define APERTURE_CONF_REG 0x09 /* only for max11800/max11801 */ 53 + #define AUX_MESURE_CONF_REG 0x0a 54 + #define OP_MODE_CONF_REG 0x0b 55 + 56 + /* FIFO is found only in max11800 and max11801 */ 57 + #define FIFO_RD_CMD (0x50 << 1) 58 + #define MAX11801_FIFO_INT (1 << 2) 59 + #define MAX11801_FIFO_OVERFLOW (1 << 3) 60 + 61 + #define XY_BUFSIZE 4 62 + #define XY_BUF_OFFSET 4 63 + 64 + #define MAX11801_MAX_X 0xfff 65 + #define MAX11801_MAX_Y 0xfff 66 + 67 + #define MEASURE_TAG_OFFSET 2 68 + #define MEASURE_TAG_MASK (3 << MEASURE_TAG_OFFSET) 69 + #define EVENT_TAG_OFFSET 0 70 + #define EVENT_TAG_MASK (3 << EVENT_TAG_OFFSET) 71 + #define MEASURE_X_TAG (0 << MEASURE_TAG_OFFSET) 72 + #define MEASURE_Y_TAG (1 << MEASURE_TAG_OFFSET) 73 + 74 + /* These are the state of touch event state machine */ 75 + enum { 76 + EVENT_INIT, 77 + EVENT_MIDDLE, 78 + EVENT_RELEASE, 79 + EVENT_FIFO_END 80 + }; 81 + 82 + struct max11801_data { 83 + struct i2c_client *client; 84 + struct input_dev *input_dev; 85 + }; 86 + 87 + static u8 read_register(struct i2c_client *client, int addr) 88 + { 89 + /* XXX: The chip ignores LSB of register address */ 90 + return i2c_smbus_read_byte_data(client, addr << 1); 91 + } 92 + 93 + static int max11801_write_reg(struct i2c_client *client, int addr, int data) 94 + { 95 + /* XXX: The chip ignores LSB of register address */ 96 + return i2c_smbus_write_byte_data(client, addr << 1, data); 97 + } 98 + 99 + static irqreturn_t max11801_ts_interrupt(int irq, void *dev_id) 100 + { 101 + struct max11801_data *data = dev_id; 102 + struct i2c_client *client = data->client; 103 + int status, i, ret; 104 + u8 buf[XY_BUFSIZE]; 105 + int x = -1; 106 + int y = -1; 107 + 108 + status = read_register(data->client, GENERNAL_STATUS_REG); 109 + 110 + if (status & (MAX11801_FIFO_INT | MAX11801_FIFO_OVERFLOW)) { 111 + status = read_register(data->client, GENERNAL_STATUS_REG); 112 + 113 + ret = i2c_smbus_read_i2c_block_data(client, FIFO_RD_CMD, 114 + XY_BUFSIZE, buf); 115 + 116 + /* 117 + * We should get 4 bytes buffer that contains X,Y 118 + * and event tag 119 + */ 120 + if (ret < XY_BUFSIZE) 121 + goto out; 122 + 123 + for (i = 0; i < XY_BUFSIZE; i += XY_BUFSIZE / 2) { 124 + if ((buf[i + 1] & MEASURE_TAG_MASK) == MEASURE_X_TAG) 125 + x = (buf[i] << XY_BUF_OFFSET) + 126 + (buf[i + 1] >> XY_BUF_OFFSET); 127 + else if ((buf[i + 1] & MEASURE_TAG_MASK) == MEASURE_Y_TAG) 128 + y = (buf[i] << XY_BUF_OFFSET) + 129 + (buf[i + 1] >> XY_BUF_OFFSET); 130 + } 131 + 132 + if ((buf[1] & EVENT_TAG_MASK) != (buf[3] & EVENT_TAG_MASK)) 133 + goto out; 134 + 135 + switch (buf[1] & EVENT_TAG_MASK) { 136 + case EVENT_INIT: 137 + /* fall through */ 138 + case EVENT_MIDDLE: 139 + input_report_abs(data->input_dev, ABS_X, x); 140 + input_report_abs(data->input_dev, ABS_Y, y); 141 + input_event(data->input_dev, EV_KEY, BTN_TOUCH, 1); 142 + input_sync(data->input_dev); 143 + break; 144 + 145 + case EVENT_RELEASE: 146 + input_event(data->input_dev, EV_KEY, BTN_TOUCH, 0); 147 + input_sync(data->input_dev); 148 + break; 149 + 150 + case EVENT_FIFO_END: 151 + break; 152 + } 153 + } 154 + out: 155 + return IRQ_HANDLED; 156 + } 157 + 158 + static void __devinit max11801_ts_phy_init(struct max11801_data *data) 159 + { 160 + struct i2c_client *client = data->client; 161 + 162 + /* Average X,Y, take 16 samples, average eight media sample */ 163 + max11801_write_reg(client, MESURE_AVER_CONF_REG, 0xff); 164 + /* X,Y panel setup time set to 20us */ 165 + max11801_write_reg(client, PANEL_SETUPTIME_CONF_REG, 0x11); 166 + /* Rough pullup time (2uS), Fine pullup time (10us) */ 167 + max11801_write_reg(client, TOUCH_DETECT_PULLUP_CONF_REG, 0x10); 168 + /* Auto mode init period = 5ms , scan period = 5ms*/ 169 + max11801_write_reg(client, AUTO_MODE_TIME_CONF_REG, 0xaa); 170 + /* Aperture X,Y set to +- 4LSB */ 171 + max11801_write_reg(client, APERTURE_CONF_REG, 0x33); 172 + /* Enable Power, enable Automode, enable Aperture, enable Average X,Y */ 173 + max11801_write_reg(client, OP_MODE_CONF_REG, 0x36); 174 + } 175 + 176 + static int __devinit max11801_ts_probe(struct i2c_client *client, 177 + const struct i2c_device_id *id) 178 + { 179 + struct max11801_data *data; 180 + struct input_dev *input_dev; 181 + int error; 182 + 183 + data = kzalloc(sizeof(struct max11801_data), GFP_KERNEL); 184 + input_dev = input_allocate_device(); 185 + if (!data || !input_dev) { 186 + dev_err(&client->dev, "Failed to allocate memory\n"); 187 + error = -ENOMEM; 188 + goto err_free_mem; 189 + } 190 + 191 + data->client = client; 192 + data->input_dev = input_dev; 193 + 194 + input_dev->name = "max11801_ts"; 195 + input_dev->id.bustype = BUS_I2C; 196 + input_dev->dev.parent = &client->dev; 197 + 198 + __set_bit(EV_ABS, input_dev->evbit); 199 + __set_bit(EV_KEY, input_dev->evbit); 200 + __set_bit(BTN_TOUCH, input_dev->keybit); 201 + input_set_abs_params(input_dev, ABS_X, 0, MAX11801_MAX_X, 0, 0); 202 + input_set_abs_params(input_dev, ABS_Y, 0, MAX11801_MAX_Y, 0, 0); 203 + input_set_drvdata(input_dev, data); 204 + 205 + max11801_ts_phy_init(data); 206 + 207 + error = request_threaded_irq(client->irq, NULL, max11801_ts_interrupt, 208 + IRQF_TRIGGER_LOW | IRQF_ONESHOT, 209 + "max11801_ts", data); 210 + if (error) { 211 + dev_err(&client->dev, "Failed to register interrupt\n"); 212 + goto err_free_mem; 213 + } 214 + 215 + error = input_register_device(data->input_dev); 216 + if (error) 217 + goto err_free_irq; 218 + 219 + i2c_set_clientdata(client, data); 220 + return 0; 221 + 222 + err_free_irq: 223 + free_irq(client->irq, data); 224 + err_free_mem: 225 + input_free_device(input_dev); 226 + kfree(data); 227 + return error; 228 + } 229 + 230 + static __devexit int max11801_ts_remove(struct i2c_client *client) 231 + { 232 + struct max11801_data *data = i2c_get_clientdata(client); 233 + 234 + free_irq(client->irq, data); 235 + input_unregister_device(data->input_dev); 236 + kfree(data); 237 + 238 + return 0; 239 + } 240 + 241 + static const struct i2c_device_id max11801_ts_id[] = { 242 + {"max11801", 0}, 243 + { } 244 + }; 245 + MODULE_DEVICE_TABLE(i2c, max11801_ts_id); 246 + 247 + static struct i2c_driver max11801_ts_driver = { 248 + .driver = { 249 + .name = "max11801_ts", 250 + .owner = THIS_MODULE, 251 + }, 252 + .id_table = max11801_ts_id, 253 + .probe = max11801_ts_probe, 254 + .remove = __devexit_p(max11801_ts_remove), 255 + }; 256 + 257 + static int __init max11801_ts_init(void) 258 + { 259 + return i2c_add_driver(&max11801_ts_driver); 260 + } 261 + 262 + static void __exit max11801_ts_exit(void) 263 + { 264 + i2c_del_driver(&max11801_ts_driver); 265 + } 266 + 267 + module_init(max11801_ts_init); 268 + module_exit(max11801_ts_exit); 269 + 270 + MODULE_AUTHOR("Zhang Jiejing <jiejing.zhang@freescale.com>"); 271 + MODULE_DESCRIPTION("Touchscreen driver for MAXI MAX11801 controller"); 272 + MODULE_LICENSE("GPL");
+16 -10
drivers/input/touchscreen/tsc2007.c
··· 27 27 #include <linux/i2c.h> 28 28 #include <linux/i2c/tsc2007.h> 29 29 30 - #define TS_POLL_DELAY 1 /* ms delay between samples */ 31 - #define TS_POLL_PERIOD 1 /* ms delay between samples */ 32 - 33 30 #define TSC2007_MEASURE_TEMP0 (0x0 << 4) 34 31 #define TSC2007_MEASURE_AUX (0x2 << 4) 35 32 #define TSC2007_MEASURE_TEMP1 (0x4 << 4) ··· 72 75 73 76 u16 model; 74 77 u16 x_plate_ohms; 78 + u16 max_rt; 79 + unsigned long poll_delay; 80 + unsigned long poll_period; 75 81 76 82 bool pendown; 77 83 int irq; ··· 156 156 { 157 157 struct tsc2007 *ts = 158 158 container_of(to_delayed_work(work), struct tsc2007, work); 159 + bool debounced = false; 159 160 struct ts_event tc; 160 161 u32 rt; 161 162 ··· 185 184 tsc2007_read_values(ts, &tc); 186 185 187 186 rt = tsc2007_calculate_pressure(ts, &tc); 188 - if (rt > MAX_12BIT) { 187 + if (rt > ts->max_rt) { 189 188 /* 190 189 * Sample found inconsistent by debouncing or pressure is 191 190 * beyond the maximum. Don't report it to user space, 192 191 * repeat at least once more the measurement. 193 192 */ 194 193 dev_dbg(&ts->client->dev, "ignored pressure %d\n", rt); 194 + debounced = true; 195 195 goto out; 196 196 197 197 } ··· 227 225 } 228 226 229 227 out: 230 - if (ts->pendown) 228 + if (ts->pendown || debounced) 231 229 schedule_delayed_work(&ts->work, 232 - msecs_to_jiffies(TS_POLL_PERIOD)); 230 + msecs_to_jiffies(ts->poll_period)); 233 231 else 234 232 enable_irq(ts->irq); 235 233 } ··· 241 239 if (!ts->get_pendown_state || likely(ts->get_pendown_state())) { 242 240 disable_irq_nosync(ts->irq); 243 241 schedule_delayed_work(&ts->work, 244 - msecs_to_jiffies(TS_POLL_DELAY)); 242 + msecs_to_jiffies(ts->poll_delay)); 245 243 } 246 244 247 245 if (ts->clear_penirq) ··· 294 292 295 293 ts->model = pdata->model; 296 294 ts->x_plate_ohms = pdata->x_plate_ohms; 295 + ts->max_rt = pdata->max_rt ? : MAX_12BIT; 296 + ts->poll_delay = pdata->poll_delay ? : 1; 297 + ts->poll_period = pdata->poll_period ? : 1; 297 298 ts->get_pendown_state = pdata->get_pendown_state; 298 299 ts->clear_penirq = pdata->clear_penirq; 299 300 ··· 310 305 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 311 306 input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); 312 307 313 - input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0); 314 - input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0); 315 - input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT, 0, 0); 308 + input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, pdata->fuzzx, 0); 309 + input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, pdata->fuzzy, 0); 310 + input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT, 311 + pdata->fuzzz, 0); 316 312 317 313 if (pdata->init_platform_hw) 318 314 pdata->init_platform_hw();
+5 -3
include/linux/gpio_keys.h
··· 3 3 4 4 struct gpio_keys_button { 5 5 /* Configuration parameters */ 6 - int code; /* input event code (KEY_*, SW_*) */ 6 + unsigned int code; /* input event code (KEY_*, SW_*) */ 7 7 int gpio; 8 8 int active_low; 9 - char *desc; 10 - int type; /* input event type (EV_KEY, EV_SW) */ 9 + const char *desc; 10 + unsigned int type; /* input event type (EV_KEY, EV_SW, EV_ABS) */ 11 11 int wakeup; /* configure the button as a wake-up source */ 12 12 int debounce_interval; /* debounce ticks interval in msecs */ 13 13 bool can_disable; 14 + int value; /* axis value for EV_ABS */ 14 15 }; 15 16 16 17 struct gpio_keys_platform_data { ··· 22 21 unsigned int rep:1; /* enable input subsystem auto repeat */ 23 22 int (*enable)(struct device *dev); 24 23 void (*disable)(struct device *dev); 24 + const char *name; /* input device name */ 25 25 }; 26 26 27 27 #endif
+20
include/linux/i2c/mpr121_touchkey.h
··· 1 + /* Header file for Freescale MPR121 Capacitive Touch Sensor */ 2 + 3 + #ifndef _MPR121_TOUCHKEY_H 4 + #define _MPR121_TOUCHKEY_H 5 + 6 + /** 7 + * struct mpr121_platform_data - platform data for mpr121 sensor 8 + * @keymap: pointer to array of KEY_* values representing keymap 9 + * @keymap_size: size of the keymap 10 + * @wakeup: configure the button as a wake-up source 11 + * @vdd_uv: VDD voltage in uV 12 + */ 13 + struct mpr121_platform_data { 14 + const unsigned short *keymap; 15 + unsigned int keymap_size; 16 + bool wakeup; 17 + int vdd_uv; 18 + }; 19 + 20 + #endif /* _MPR121_TOUCHKEY_H */
+7
include/linux/i2c/tsc2007.h
··· 6 6 struct tsc2007_platform_data { 7 7 u16 model; /* 2007. */ 8 8 u16 x_plate_ohms; 9 + u16 max_rt; /* max. resistance above which samples are ignored */ 10 + unsigned long poll_delay; /* delay (in ms) after pen-down event 11 + before polling starts */ 12 + unsigned long poll_period; /* time (in ms) between samples */ 13 + int fuzzx; /* fuzz factor for X, Y and pressure axes */ 14 + int fuzzy; 15 + int fuzzz; 9 16 10 17 int (*get_pendown_state)(void); 11 18 void (*clear_penirq)(void); /* If needed, clear 2nd level
+2 -1
include/linux/input/ad714x.h
··· 6 6 * The platform_data for the device's "struct device" holds this 7 7 * information. 8 8 * 9 - * Copyright 2009 Analog Devices Inc. 9 + * Copyright 2009-2011 Analog Devices Inc. 10 10 * 11 11 * Licensed under the GPL-2 or later. 12 12 */ ··· 58 58 struct ad714x_button_plat *button; 59 59 unsigned short stage_cfg_reg[STAGE_NUM][STAGE_CFGREG_NUM]; 60 60 unsigned short sys_cfg_reg[SYS_CFGREG_NUM]; 61 + unsigned long irqflags; 61 62 }; 62 63 63 64 #endif
+213
include/linux/input/adp5589.h
··· 1 + /* 2 + * Analog Devices ADP5589 I/O Expander and QWERTY Keypad Controller 3 + * 4 + * Copyright 2010-2011 Analog Devices Inc. 5 + * 6 + * Licensed under the GPL-2. 7 + */ 8 + 9 + #ifndef _ADP5589_H 10 + #define _ADP5589_H 11 + 12 + #define ADP5589_ID 0x00 13 + #define ADP5589_INT_STATUS 0x01 14 + #define ADP5589_STATUS 0x02 15 + #define ADP5589_FIFO_1 0x03 16 + #define ADP5589_FIFO_2 0x04 17 + #define ADP5589_FIFO_3 0x05 18 + #define ADP5589_FIFO_4 0x06 19 + #define ADP5589_FIFO_5 0x07 20 + #define ADP5589_FIFO_6 0x08 21 + #define ADP5589_FIFO_7 0x09 22 + #define ADP5589_FIFO_8 0x0A 23 + #define ADP5589_FIFO_9 0x0B 24 + #define ADP5589_FIFO_10 0x0C 25 + #define ADP5589_FIFO_11 0x0D 26 + #define ADP5589_FIFO_12 0x0E 27 + #define ADP5589_FIFO_13 0x0F 28 + #define ADP5589_FIFO_14 0x10 29 + #define ADP5589_FIFO_15 0x11 30 + #define ADP5589_FIFO_16 0x12 31 + #define ADP5589_GPI_INT_STAT_A 0x13 32 + #define ADP5589_GPI_INT_STAT_B 0x14 33 + #define ADP5589_GPI_INT_STAT_C 0x15 34 + #define ADP5589_GPI_STATUS_A 0x16 35 + #define ADP5589_GPI_STATUS_B 0x17 36 + #define ADP5589_GPI_STATUS_C 0x18 37 + #define ADP5589_RPULL_CONFIG_A 0x19 38 + #define ADP5589_RPULL_CONFIG_B 0x1A 39 + #define ADP5589_RPULL_CONFIG_C 0x1B 40 + #define ADP5589_RPULL_CONFIG_D 0x1C 41 + #define ADP5589_RPULL_CONFIG_E 0x1D 42 + #define ADP5589_GPI_INT_LEVEL_A 0x1E 43 + #define ADP5589_GPI_INT_LEVEL_B 0x1F 44 + #define ADP5589_GPI_INT_LEVEL_C 0x20 45 + #define ADP5589_GPI_EVENT_EN_A 0x21 46 + #define ADP5589_GPI_EVENT_EN_B 0x22 47 + #define ADP5589_GPI_EVENT_EN_C 0x23 48 + #define ADP5589_GPI_INTERRUPT_EN_A 0x24 49 + #define ADP5589_GPI_INTERRUPT_EN_B 0x25 50 + #define ADP5589_GPI_INTERRUPT_EN_C 0x26 51 + #define ADP5589_DEBOUNCE_DIS_A 0x27 52 + #define ADP5589_DEBOUNCE_DIS_B 0x28 53 + #define ADP5589_DEBOUNCE_DIS_C 0x29 54 + #define ADP5589_GPO_DATA_OUT_A 0x2A 55 + #define ADP5589_GPO_DATA_OUT_B 0x2B 56 + #define ADP5589_GPO_DATA_OUT_C 0x2C 57 + #define ADP5589_GPO_OUT_MODE_A 0x2D 58 + #define ADP5589_GPO_OUT_MODE_B 0x2E 59 + #define ADP5589_GPO_OUT_MODE_C 0x2F 60 + #define ADP5589_GPIO_DIRECTION_A 0x30 61 + #define ADP5589_GPIO_DIRECTION_B 0x31 62 + #define ADP5589_GPIO_DIRECTION_C 0x32 63 + #define ADP5589_UNLOCK1 0x33 64 + #define ADP5589_UNLOCK2 0x34 65 + #define ADP5589_EXT_LOCK_EVENT 0x35 66 + #define ADP5589_UNLOCK_TIMERS 0x36 67 + #define ADP5589_LOCK_CFG 0x37 68 + #define ADP5589_RESET1_EVENT_A 0x38 69 + #define ADP5589_RESET1_EVENT_B 0x39 70 + #define ADP5589_RESET1_EVENT_C 0x3A 71 + #define ADP5589_RESET2_EVENT_A 0x3B 72 + #define ADP5589_RESET2_EVENT_B 0x3C 73 + #define ADP5589_RESET_CFG 0x3D 74 + #define ADP5589_PWM_OFFT_LOW 0x3E 75 + #define ADP5589_PWM_OFFT_HIGH 0x3F 76 + #define ADP5589_PWM_ONT_LOW 0x40 77 + #define ADP5589_PWM_ONT_HIGH 0x41 78 + #define ADP5589_PWM_CFG 0x42 79 + #define ADP5589_CLOCK_DIV_CFG 0x43 80 + #define ADP5589_LOGIC_1_CFG 0x44 81 + #define ADP5589_LOGIC_2_CFG 0x45 82 + #define ADP5589_LOGIC_FF_CFG 0x46 83 + #define ADP5589_LOGIC_INT_EVENT_EN 0x47 84 + #define ADP5589_POLL_PTIME_CFG 0x48 85 + #define ADP5589_PIN_CONFIG_A 0x49 86 + #define ADP5589_PIN_CONFIG_B 0x4A 87 + #define ADP5589_PIN_CONFIG_C 0x4B 88 + #define ADP5589_PIN_CONFIG_D 0x4C 89 + #define ADP5589_GENERAL_CFG 0x4D 90 + #define ADP5589_INT_EN 0x4E 91 + 92 + #define ADP5589_DEVICE_ID_MASK 0xF 93 + 94 + /* Put one of these structures in i2c_board_info platform_data */ 95 + 96 + #define ADP5589_KEYMAPSIZE 88 97 + 98 + #define ADP5589_GPI_PIN_ROW0 97 99 + #define ADP5589_GPI_PIN_ROW1 98 100 + #define ADP5589_GPI_PIN_ROW2 99 101 + #define ADP5589_GPI_PIN_ROW3 100 102 + #define ADP5589_GPI_PIN_ROW4 101 103 + #define ADP5589_GPI_PIN_ROW5 102 104 + #define ADP5589_GPI_PIN_ROW6 103 105 + #define ADP5589_GPI_PIN_ROW7 104 106 + #define ADP5589_GPI_PIN_COL0 105 107 + #define ADP5589_GPI_PIN_COL1 106 108 + #define ADP5589_GPI_PIN_COL2 107 109 + #define ADP5589_GPI_PIN_COL3 108 110 + #define ADP5589_GPI_PIN_COL4 109 111 + #define ADP5589_GPI_PIN_COL5 110 112 + #define ADP5589_GPI_PIN_COL6 111 113 + #define ADP5589_GPI_PIN_COL7 112 114 + #define ADP5589_GPI_PIN_COL8 113 115 + #define ADP5589_GPI_PIN_COL9 114 116 + #define ADP5589_GPI_PIN_COL10 115 117 + #define GPI_LOGIC1 116 118 + #define GPI_LOGIC2 117 119 + 120 + #define ADP5589_GPI_PIN_ROW_BASE ADP5589_GPI_PIN_ROW0 121 + #define ADP5589_GPI_PIN_ROW_END ADP5589_GPI_PIN_ROW7 122 + #define ADP5589_GPI_PIN_COL_BASE ADP5589_GPI_PIN_COL0 123 + #define ADP5589_GPI_PIN_COL_END ADP5589_GPI_PIN_COL10 124 + 125 + #define ADP5589_GPI_PIN_BASE ADP5589_GPI_PIN_ROW_BASE 126 + #define ADP5589_GPI_PIN_END ADP5589_GPI_PIN_COL_END 127 + 128 + #define ADP5589_GPIMAPSIZE_MAX (ADP5589_GPI_PIN_END - ADP5589_GPI_PIN_BASE + 1) 129 + 130 + struct adp5589_gpi_map { 131 + unsigned short pin; 132 + unsigned short sw_evt; 133 + }; 134 + 135 + /* scan_cycle_time */ 136 + #define ADP5589_SCAN_CYCLE_10ms 0 137 + #define ADP5589_SCAN_CYCLE_20ms 1 138 + #define ADP5589_SCAN_CYCLE_30ms 2 139 + #define ADP5589_SCAN_CYCLE_40ms 3 140 + 141 + /* RESET_CFG */ 142 + #define RESET_PULSE_WIDTH_500us 0 143 + #define RESET_PULSE_WIDTH_1ms 1 144 + #define RESET_PULSE_WIDTH_2ms 2 145 + #define RESET_PULSE_WIDTH_10ms 3 146 + 147 + #define RESET_TRIG_TIME_0ms (0 << 2) 148 + #define RESET_TRIG_TIME_1000ms (1 << 2) 149 + #define RESET_TRIG_TIME_1500ms (2 << 2) 150 + #define RESET_TRIG_TIME_2000ms (3 << 2) 151 + #define RESET_TRIG_TIME_2500ms (4 << 2) 152 + #define RESET_TRIG_TIME_3000ms (5 << 2) 153 + #define RESET_TRIG_TIME_3500ms (6 << 2) 154 + #define RESET_TRIG_TIME_4000ms (7 << 2) 155 + 156 + #define RESET_PASSTHRU_EN (1 << 5) 157 + #define RESET1_POL_HIGH (1 << 6) 158 + #define RESET1_POL_LOW (0 << 6) 159 + #define RESET2_POL_HIGH (1 << 7) 160 + #define RESET2_POL_LOW (0 << 7) 161 + 162 + /* Mask Bits: 163 + * C C C C C C C C C C C | R R R R R R R R 164 + * 1 9 8 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 165 + * 0 166 + * ---------------- BIT ------------------ 167 + * 1 1 1 1 1 1 1 1 1 0 0 | 0 0 0 0 0 0 0 0 168 + * 8 7 6 5 4 3 2 1 0 9 8 | 7 6 5 4 3 2 1 0 169 + */ 170 + 171 + #define ADP_ROW(x) (1 << (x)) 172 + #define ADP_COL(x) (1 << (x + 8)) 173 + 174 + struct adp5589_kpad_platform_data { 175 + unsigned keypad_en_mask; /* Keypad (Rows/Columns) enable mask */ 176 + const unsigned short *keymap; /* Pointer to keymap */ 177 + unsigned short keymapsize; /* Keymap size */ 178 + bool repeat; /* Enable key repeat */ 179 + bool en_keylock; /* Enable key lock feature */ 180 + unsigned char unlock_key1; /* Unlock Key 1 */ 181 + unsigned char unlock_key2; /* Unlock Key 2 */ 182 + unsigned char unlock_timer; /* Time in seconds [0..7] between the two unlock keys 0=disable */ 183 + unsigned char scan_cycle_time; /* Time between consecutive scan cycles */ 184 + unsigned char reset_cfg; /* Reset config */ 185 + unsigned short reset1_key_1; /* Reset Key 1 */ 186 + unsigned short reset1_key_2; /* Reset Key 2 */ 187 + unsigned short reset1_key_3; /* Reset Key 3 */ 188 + unsigned short reset2_key_1; /* Reset Key 1 */ 189 + unsigned short reset2_key_2; /* Reset Key 2 */ 190 + unsigned debounce_dis_mask; /* Disable debounce mask */ 191 + unsigned pull_dis_mask; /* Disable all pull resistors mask */ 192 + unsigned pullup_en_100k; /* Pull-Up 100k Enable Mask */ 193 + unsigned pullup_en_300k; /* Pull-Up 300k Enable Mask */ 194 + unsigned pulldown_en_300k; /* Pull-Down 300k Enable Mask */ 195 + const struct adp5589_gpi_map *gpimap; 196 + unsigned short gpimapsize; 197 + const struct adp5589_gpio_platform_data *gpio_data; 198 + }; 199 + 200 + struct i2c_client; /* forward declaration */ 201 + 202 + struct adp5589_gpio_platform_data { 203 + int gpio_start; /* GPIO Chip base # */ 204 + int (*setup)(struct i2c_client *client, 205 + int gpio, unsigned ngpio, 206 + void *context); 207 + int (*teardown)(struct i2c_client *client, 208 + int gpio, unsigned ngpio, 209 + void *context); 210 + void *context; 211 + }; 212 + 213 + #endif
+1
include/linux/rotary_encoder.h
··· 10 10 unsigned int inverted_b; 11 11 bool relative_axis; 12 12 bool rollover; 13 + bool half_period; 13 14 }; 14 15 15 16 #endif /* __ROTARY_ENCODER_H__ */
+2 -1
include/linux/spi/ads7846.h
··· 14 14 struct ads7846_platform_data { 15 15 u16 model; /* 7843, 7845, 7846, 7873. */ 16 16 u16 vref_delay_usecs; /* 0 for external vref; etc */ 17 - u16 vref_mv; /* external vref value, milliVolts */ 17 + u16 vref_mv; /* external vref value, milliVolts 18 + * ads7846: if 0, use internal vref */ 18 19 bool keep_vref_on; /* set to keep vref on for differential 19 20 * measurements as well */ 20 21 bool swap_xy; /* swap x and y axes */