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

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

Pull input layer updates from Dmitry Torokhov:
"First set of updates for the input subsystem. You will get a new
touchscreen driver (Melfas mms114), a new keypad driver for LPC32xx
SoC, large update to Atmel mXT touchscreen driver, a lot of drivers
acquired device tree support and a slew of other fixes."

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (57 commits)
Input: add MELFAS mms114 touchscreen driver
Input: add support for key scan interface of the LPC32xx SoC
Input: omap4-keypad - add device tree support
Input: hanwang - add support for Art Master II tablet
Input: spear_keyboard - reconfigure operating frequency on suspend
Input: spear_keyboard - fix clock handling during suspend/resume
Input: ff-memless - fix a couple min_t() casts
Input: synaptics - print firmware ID and board number at init
Input: spear_keyboard - generalize keyboard frequency configuration
Input: spear_keyboard - rename bit definitions to reflect register
Input: spear_keyboard - use correct io accessors
Input: spear-keyboard - fix disable device_init_wakeup in remove
Input: wacom_i2c - fix compiler warning
Input: imx_keypad - check error returned by clk_prepare_enable()
Input: imx_keypad - adapt the new kpp clock name
Input: imx_keypad - use clk_prepare_enable/clk_disable_unprepare()
Input: ad7879 - add option to correct xy axis
Input: synaptics_usb - Remove TrackPoint name trailing whitespace
Revert "Input: atmel_mxt_ts - warn if sysfs could not be created"
Input: MT - Include win8 support
...

+1841 -504
+28
Documentation/devicetree/bindings/input/lpc32xx-key.txt
··· 1 + NXP LPC32xx Key Scan Interface 2 + 3 + Required Properties: 4 + - compatible: Should be "nxp,lpc3220-key" 5 + - reg: Physical base address of the controller and length of memory mapped 6 + region. 7 + - interrupts: The interrupt number to the cpu. 8 + - keypad,num-rows: Number of rows and columns, e.g. 1: 1x1, 6: 6x6 9 + - keypad,num-columns: Must be equal to keypad,num-rows since LPC32xx only 10 + supports square matrices 11 + - nxp,debounce-delay-ms: Debounce delay in ms 12 + - nxp,scan-delay-ms: Repeated scan period in ms 13 + - linux,keymap: the key-code to be reported when the key is pressed 14 + and released, see also 15 + Documentation/devicetree/bindings/input/matrix-keymap.txt 16 + 17 + Example: 18 + 19 + key@40050000 { 20 + compatible = "nxp,lpc3220-key"; 21 + reg = <0x40050000 0x1000>; 22 + interrupts = <54 0>; 23 + keypad,num-rows = <1>; 24 + keypad,num-columns = <1>; 25 + nxp,debounce-delay-ms = <3>; 26 + nxp,scan-delay-ms = <34>; 27 + linux,keymap = <0x00000002>; 28 + };
+31
Documentation/devicetree/bindings/input/omap-keypad.txt
··· 1 + * TI's Keypad Controller device tree bindings 2 + 3 + TI's Keypad controller is used to interface a SoC with a matrix-type 4 + keypad device. The keypad controller supports multiple row and column lines. 5 + A key can be placed at each intersection of a unique row and a unique column. 6 + The keypad controller can sense a key-press and key-release and report the 7 + event using a interrupt to the cpu. 8 + 9 + Required SoC Specific Properties: 10 + - compatible: should be one of the following 11 + - "ti,omap4-keypad": For controllers compatible with omap4 keypad 12 + controller. 13 + 14 + Required Board Specific Properties, in addition to those specified by 15 + the shared matrix-keyboard bindings: 16 + - keypad,num-rows: Number of row lines connected to the keypad 17 + controller. 18 + 19 + - keypad,num-columns: Number of column lines connected to the 20 + keypad controller. 21 + 22 + Optional Properties specific to linux: 23 + - linux,keypad-no-autorepeat: do no enable autorepeat feature. 24 + 25 + Example: 26 + keypad@4ae1c000{ 27 + compatible = "ti,omap4-keypad"; 28 + keypad,num-rows = <2>; 29 + keypad,num-columns = <8>; 30 + linux,keypad-no-autorepeat; 31 + };
-37
Documentation/devicetree/bindings/input/twl6040-vibra.txt
··· 1 - Vibra driver for the twl6040 family 2 - 3 - The vibra driver is a child of the twl6040 MFD dirver. 4 - Documentation/devicetree/bindings/mfd/twl6040.txt 5 - 6 - Required properties: 7 - - compatible : Must be "ti,twl6040-vibra"; 8 - - interrupts: 4, Vibra overcurrent interrupt 9 - - vddvibl-supply: Regulator supplying the left vibra motor 10 - - vddvibr-supply: Regulator supplying the right vibra motor 11 - - vibldrv_res: Board specific left driver resistance 12 - - vibrdrv_res: Board specific right driver resistance 13 - - viblmotor_res: Board specific left motor resistance 14 - - vibrmotor_res: Board specific right motor resistance 15 - 16 - Optional properties: 17 - - vddvibl_uV: If the vddvibl default voltage need to be changed 18 - - vddvibr_uV: If the vddvibr default voltage need to be changed 19 - 20 - Example: 21 - /* 22 - * 8-channel high quality low-power audio codec 23 - * http://www.ti.com/lit/ds/symlink/twl6040.pdf 24 - */ 25 - twl6040: twl6040@4b { 26 - ... 27 - twl6040_vibra: twl6040@1 { 28 - compatible = "ti,twl6040-vibra"; 29 - interrupts = <4>; 30 - vddvibl-supply = <&vbat>; 31 - vddvibr-supply = <&vbat>; 32 - vibldrv_res = <8>; 33 - vibrdrv_res = <3>; 34 - viblmotor_res = <10>; 35 - vibrmotor_res = <10>; 36 - }; 37 - };
+92 -26
Documentation/input/multi-touch-protocol.txt
··· 162 162 minimum set consists of ABS_MT_POSITION_X and ABS_MT_POSITION_Y, which 163 163 allows for multiple contacts to be tracked. If the device supports it, the 164 164 ABS_MT_TOUCH_MAJOR and ABS_MT_WIDTH_MAJOR may be used to provide the size 165 - of the contact area and approaching contact, respectively. 165 + of the contact area and approaching tool, respectively. 166 166 167 167 The TOUCH and WIDTH parameters have a geometrical interpretation; imagine 168 168 looking through a window at someone gently holding a finger against the 169 169 glass. You will see two regions, one inner region consisting of the part 170 170 of the finger actually touching the glass, and one outer region formed by 171 - the perimeter of the finger. The diameter of the inner region is the 172 - ABS_MT_TOUCH_MAJOR, the diameter of the outer region is 173 - ABS_MT_WIDTH_MAJOR. Now imagine the person pressing the finger harder 174 - against the glass. The inner region will increase, and in general, the 175 - ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR, which is always smaller than 176 - unity, is related to the contact pressure. For pressure-based devices, 171 + the perimeter of the finger. The center of the touching region (a) is 172 + ABS_MT_POSITION_X/Y and the center of the approaching finger (b) is 173 + ABS_MT_TOOL_X/Y. The touch diameter is ABS_MT_TOUCH_MAJOR and the finger 174 + diameter is ABS_MT_WIDTH_MAJOR. Now imagine the person pressing the finger 175 + harder against the glass. The touch region will increase, and in general, 176 + the ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR, which is always smaller 177 + than unity, is related to the contact pressure. For pressure-based devices, 177 178 ABS_MT_PRESSURE may be used to provide the pressure on the contact area 178 179 instead. Devices capable of contact hovering can use ABS_MT_DISTANCE to 179 180 indicate the distance between the contact and the surface. 180 181 181 - In addition to the MAJOR parameters, the oval shape of the contact can be 182 - described by adding the MINOR parameters, such that MAJOR and MINOR are the 183 - major and minor axis of an ellipse. Finally, the orientation of the oval 184 - shape can be describe with the ORIENTATION parameter. 182 + 183 + Linux MT Win8 184 + __________ _______________________ 185 + / \ | | 186 + / \ | | 187 + / ____ \ | | 188 + / / \ \ | | 189 + \ \ a \ \ | a | 190 + \ \____/ \ | | 191 + \ \ | | 192 + \ b \ | b | 193 + \ \ | | 194 + \ \ | | 195 + \ \ | | 196 + \ / | | 197 + \ / | | 198 + \ / | | 199 + \__________/ |_______________________| 200 + 201 + 202 + In addition to the MAJOR parameters, the oval shape of the touch and finger 203 + regions can be described by adding the MINOR parameters, such that MAJOR 204 + and MINOR are the major and minor axis of an ellipse. The orientation of 205 + the touch ellipse can be described with the ORIENTATION parameter, and the 206 + direction of the finger ellipse is given by the vector (a - b). 185 207 186 208 For type A devices, further specification of the touch shape is possible 187 209 via ABS_MT_BLOB_ID. ··· 246 224 The above four values can be used to derive additional information about 247 225 the contact. The ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR approximates 248 226 the notion of pressure. The fingers of the hand and the palm all have 249 - different characteristic widths [1]. 227 + different characteristic widths. 250 228 251 229 ABS_MT_PRESSURE 252 230 ··· 262 240 263 241 ABS_MT_ORIENTATION 264 242 265 - The orientation of the ellipse. The value should describe a signed quarter 266 - of a revolution clockwise around the touch center. The signed value range 267 - is arbitrary, but zero should be returned for a finger aligned along the Y 268 - axis of the surface, a negative value when finger is turned to the left, and 269 - a positive value when finger turned to the right. When completely aligned with 270 - the X axis, the range max should be returned. Orientation can be omitted 271 - if the touching object is circular, or if the information is not available 272 - in the kernel driver. Partial orientation support is possible if the device 273 - can distinguish between the two axis, but not (uniquely) any values in 274 - between. In such cases, the range of ABS_MT_ORIENTATION should be [0, 1] 275 - [4]. 243 + The orientation of the touching ellipse. The value should describe a signed 244 + quarter of a revolution clockwise around the touch center. The signed value 245 + range is arbitrary, but zero should be returned for an ellipse aligned with 246 + the Y axis of the surface, a negative value when the ellipse is turned to 247 + the left, and a positive value when the ellipse is turned to the 248 + right. When completely aligned with the X axis, the range max should be 249 + returned. 250 + 251 + Touch ellipsis are symmetrical by default. For devices capable of true 360 252 + degree orientation, the reported orientation must exceed the range max to 253 + indicate more than a quarter of a revolution. For an upside-down finger, 254 + range max * 2 should be returned. 255 + 256 + Orientation can be omitted if the touch area is circular, or if the 257 + information is not available in the kernel driver. Partial orientation 258 + support is possible if the device can distinguish between the two axis, but 259 + not (uniquely) any values in between. In such cases, the range of 260 + ABS_MT_ORIENTATION should be [0, 1] [4]. 276 261 277 262 ABS_MT_POSITION_X 278 263 ··· 288 259 ABS_MT_POSITION_Y 289 260 290 261 The surface Y coordinate of the center of the touching ellipse. 262 + 263 + ABS_MT_TOOL_X 264 + 265 + The surface X coordinate of the center of the approaching tool. Omit if 266 + the device cannot distinguish between the intended touch point and the 267 + tool itself. 268 + 269 + ABS_MT_TOOL_Y 270 + 271 + The surface Y coordinate of the center of the approaching tool. Omit if the 272 + device cannot distinguish between the intended touch point and the tool 273 + itself. 274 + 275 + The four position values can be used to separate the position of the touch 276 + from the position of the tool. If both positions are present, the major 277 + tool axis points towards the touch point [1]. Otherwise, the tool axes are 278 + aligned with the touch axes. 291 279 292 280 ABS_MT_TOOL_TYPE 293 281 ··· 351 305 the device can distinguish between a finger along the Y axis (0) and a 352 306 finger along the X axis (1). 353 307 308 + For win8 devices with both T and C coordinates, the position mapping is 309 + 310 + ABS_MT_POSITION_X := T_X 311 + ABS_MT_POSITION_Y := T_Y 312 + ABS_MT_TOOL_X := C_X 313 + ABS_MT_TOOL_X := C_Y 314 + 315 + Unfortunately, there is not enough information to specify both the touching 316 + ellipse and the tool ellipse, so one has to resort to approximations. One 317 + simple scheme, which is compatible with earlier usage, is: 318 + 319 + ABS_MT_TOUCH_MAJOR := min(X, Y) 320 + ABS_MT_TOUCH_MINOR := <not used> 321 + ABS_MT_ORIENTATION := <not used> 322 + ABS_MT_WIDTH_MAJOR := min(X, Y) + distance(T, C) 323 + ABS_MT_WIDTH_MINOR := min(X, Y) 324 + 325 + Rationale: We have no information about the orientation of the touching 326 + ellipse, so approximate it with an inscribed circle instead. The tool 327 + ellipse should align with the the vector (T - C), so the diameter must 328 + increase with distance(T, C). Finally, assume that the touch diameter is 329 + equal to the tool thickness, and we arrive at the formulas above. 354 330 355 331 Finger Tracking 356 332 --------------- ··· 406 338 For example usage of the type A protocol, see the bcm5974 driver. For 407 339 example usage of the type B protocol, see the hid-egalax driver. 408 340 409 - [1] With the extension ABS_MT_APPROACH_X and ABS_MT_APPROACH_Y, the 410 - difference between the contact position and the approaching tool position 411 - could be used to derive tilt. 341 + [1] Also, the difference (TOOL_X - POSITION_X) can be used to model tilt. 412 342 [2] The list can of course be extended. 413 343 [3] The mtdev project: http://bitmath.org/code/mtdev/. 414 344 [4] See the section on event computation.
+2
arch/arm/plat-spear/include/plat/keyboard.h
··· 149 149 * keymap: pointer to keymap data (table and size) 150 150 * rep: enables key autorepeat 151 151 * mode: choose keyboard support(9x9, 6x6, 2x2) 152 + * suspended_rate: rate at which keyboard would operate in suspended mode 152 153 * 153 154 * This structure is supposed to be used by platform code to supply 154 155 * keymaps to drivers that implement keyboards. ··· 158 157 const struct matrix_keymap_data *keymap; 159 158 bool rep; 160 159 unsigned int mode; 160 + unsigned int suspended_rate; 161 161 }; 162 162 163 163 #endif /* __PLAT_KEYBOARD_H */
+2 -2
drivers/input/ff-memless.c
··· 176 176 value, envelope->attack_level); 177 177 time_from_level = jiffies_to_msecs(now - state->play_at); 178 178 time_of_envelope = envelope->attack_length; 179 - envelope_level = min_t(__s16, envelope->attack_level, 0x7fff); 179 + envelope_level = min_t(u16, envelope->attack_level, 0x7fff); 180 180 181 181 } else if (envelope->fade_length && effect->replay.length && 182 182 time_after(now, ··· 184 184 time_before(now, state->stop_at)) { 185 185 time_from_level = jiffies_to_msecs(state->stop_at - now); 186 186 time_of_envelope = envelope->fade_length; 187 - envelope_level = min_t(__s16, envelope->fade_level, 0x7fff); 187 + envelope_level = min_t(u16, envelope->fade_level, 0x7fff); 188 188 } else 189 189 return value; 190 190
+1 -1
drivers/input/input-mt.c
··· 135 135 */ 136 136 void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count) 137 137 { 138 - struct input_mt_slot *oldest = 0; 138 + struct input_mt_slot *oldest = NULL; 139 139 int oldid = dev->trkid; 140 140 int count = 0; 141 141 int i;
+10
drivers/input/keyboard/Kconfig
··· 332 332 To compile this driver as a module, choose M here: the 333 333 module will be called locomokbd. 334 334 335 + config KEYBOARD_LPC32XX 336 + tristate "LPC32XX matrix key scanner support" 337 + depends on ARCH_LPC32XX && OF 338 + help 339 + Say Y here if you want to use NXP LPC32XX SoC key scanner interface, 340 + connected to a key matrix. 341 + 342 + To compile this driver as a module, choose M here: the 343 + module will be called lpc32xx-keys. 344 + 335 345 config KEYBOARD_MAPLE 336 346 tristate "Maple bus keyboard" 337 347 depends on SH_DREAMCAST && MAPLE
+1
drivers/input/keyboard/Makefile
··· 26 26 obj-$(CONFIG_KEYBOARD_LM8323) += lm8323.o 27 27 obj-$(CONFIG_KEYBOARD_LM8333) += lm8333.o 28 28 obj-$(CONFIG_KEYBOARD_LOCOMO) += locomokbd.o 29 + obj-$(CONFIG_KEYBOARD_LPC32XX) += lpc32xx-keys.o 29 30 obj-$(CONFIG_KEYBOARD_MAPLE) += maple_keyb.o 30 31 obj-$(CONFIG_KEYBOARD_MATRIX) += matrix_keypad.o 31 32 obj-$(CONFIG_KEYBOARD_MAX7359) += max7359_keypad.o
-1
drivers/input/keyboard/gpio_keys.c
··· 559 559 pdata->rep = !!of_get_property(node, "autorepeat", NULL); 560 560 561 561 /* First count the subnodes */ 562 - pdata->nbuttons = 0; 563 562 pp = NULL; 564 563 while ((pp = of_get_next_child(node, pp))) 565 564 pdata->nbuttons++;
+17 -8
drivers/input/keyboard/imx_keypad.c
··· 378 378 imx_keypad_inhibit(keypad); 379 379 380 380 /* Disable clock unit */ 381 - clk_disable(keypad->clk); 381 + clk_disable_unprepare(keypad->clk); 382 382 } 383 383 384 384 static int imx_keypad_open(struct input_dev *dev) 385 385 { 386 386 struct imx_keypad *keypad = input_get_drvdata(dev); 387 + int error; 387 388 388 389 dev_dbg(&dev->dev, ">%s\n", __func__); 390 + 391 + /* Enable the kpp clock */ 392 + error = clk_prepare_enable(keypad->clk); 393 + if (error) 394 + return error; 389 395 390 396 /* We became active from now */ 391 397 keypad->enabled = true; 392 398 393 - /* Enable the kpp clock */ 394 - clk_enable(keypad->clk); 395 399 imx_keypad_config(keypad); 396 400 397 401 /* Sanity control, not all the rows must be actived now. */ ··· 471 467 goto failed_free_priv; 472 468 } 473 469 474 - keypad->clk = clk_get(&pdev->dev, "kpp"); 470 + keypad->clk = clk_get(&pdev->dev, NULL); 475 471 if (IS_ERR(keypad->clk)) { 476 472 dev_err(&pdev->dev, "failed to get keypad clock\n"); 477 473 error = PTR_ERR(keypad->clk); ··· 585 581 mutex_lock(&input_dev->mutex); 586 582 587 583 if (input_dev->users) 588 - clk_disable(kbd->clk); 584 + clk_disable_unprepare(kbd->clk); 589 585 590 586 mutex_unlock(&input_dev->mutex); 591 587 ··· 600 596 struct platform_device *pdev = to_platform_device(dev); 601 597 struct imx_keypad *kbd = platform_get_drvdata(pdev); 602 598 struct input_dev *input_dev = kbd->input_dev; 599 + int ret = 0; 603 600 604 601 if (device_may_wakeup(&pdev->dev)) 605 602 disable_irq_wake(kbd->irq); 606 603 607 604 mutex_lock(&input_dev->mutex); 608 605 609 - if (input_dev->users) 610 - clk_enable(kbd->clk); 606 + if (input_dev->users) { 607 + ret = clk_prepare_enable(kbd->clk); 608 + if (ret) 609 + goto err_clk; 610 + } 611 611 612 + err_clk: 612 613 mutex_unlock(&input_dev->mutex); 613 614 614 - return 0; 615 + return ret; 615 616 } 616 617 #endif 617 618
+394
drivers/input/keyboard/lpc32xx-keys.c
··· 1 + /* 2 + * NXP LPC32xx SoC Key Scan Interface 3 + * 4 + * Authors: 5 + * Kevin Wells <kevin.wells@nxp.com> 6 + * Roland Stigge <stigge@antcom.de> 7 + * 8 + * Copyright (C) 2010 NXP Semiconductors 9 + * Copyright (C) 2012 Roland Stigge 10 + * 11 + * This program is free software; you can redistribute it and/or modify 12 + * it under the terms of the GNU General Public License as published by 13 + * the Free Software Foundation; either version 2 of the License, or 14 + * (at your option) any later version. 15 + * 16 + * This program is distributed in the hope that it will be useful, 17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 + * GNU General Public License for more details. 20 + * 21 + * 22 + * This controller supports square key matrices from 1x1 up to 8x8 23 + */ 24 + 25 + #include <linux/module.h> 26 + #include <linux/interrupt.h> 27 + #include <linux/slab.h> 28 + #include <linux/irq.h> 29 + #include <linux/pm.h> 30 + #include <linux/platform_device.h> 31 + #include <linux/input.h> 32 + #include <linux/clk.h> 33 + #include <linux/io.h> 34 + #include <linux/of.h> 35 + #include <linux/input/matrix_keypad.h> 36 + 37 + #define DRV_NAME "lpc32xx_keys" 38 + 39 + /* 40 + * Key scanner register offsets 41 + */ 42 + #define LPC32XX_KS_DEB(x) ((x) + 0x00) 43 + #define LPC32XX_KS_STATE_COND(x) ((x) + 0x04) 44 + #define LPC32XX_KS_IRQ(x) ((x) + 0x08) 45 + #define LPC32XX_KS_SCAN_CTL(x) ((x) + 0x0C) 46 + #define LPC32XX_KS_FAST_TST(x) ((x) + 0x10) 47 + #define LPC32XX_KS_MATRIX_DIM(x) ((x) + 0x14) /* 1..8 */ 48 + #define LPC32XX_KS_DATA(x, y) ((x) + 0x40 + ((y) << 2)) 49 + 50 + #define LPC32XX_KSCAN_DEB_NUM_DEB_PASS(n) ((n) & 0xFF) 51 + 52 + #define LPC32XX_KSCAN_SCOND_IN_IDLE 0x0 53 + #define LPC32XX_KSCAN_SCOND_IN_SCANONCE 0x1 54 + #define LPC32XX_KSCAN_SCOND_IN_IRQGEN 0x2 55 + #define LPC32XX_KSCAN_SCOND_IN_SCAN_MATRIX 0x3 56 + 57 + #define LPC32XX_KSCAN_IRQ_PENDING_CLR 0x1 58 + 59 + #define LPC32XX_KSCAN_SCTRL_SCAN_DELAY(n) ((n) & 0xFF) 60 + 61 + #define LPC32XX_KSCAN_FTST_FORCESCANONCE 0x1 62 + #define LPC32XX_KSCAN_FTST_USE32K_CLK 0x2 63 + 64 + #define LPC32XX_KSCAN_MSEL_SELECT(n) ((n) & 0xF) 65 + 66 + struct lpc32xx_kscan_drv { 67 + struct input_dev *input; 68 + struct clk *clk; 69 + struct resource *iores; 70 + void __iomem *kscan_base; 71 + unsigned int irq; 72 + 73 + u32 matrix_sz; /* Size of matrix in XxY, ie. 3 = 3x3 */ 74 + u32 deb_clks; /* Debounce clocks (based on 32KHz clock) */ 75 + u32 scan_delay; /* Scan delay (based on 32KHz clock) */ 76 + 77 + unsigned short *keymap; /* Pointer to key map for the scan matrix */ 78 + unsigned int row_shift; 79 + 80 + u8 lastkeystates[8]; 81 + }; 82 + 83 + static void lpc32xx_mod_states(struct lpc32xx_kscan_drv *kscandat, int col) 84 + { 85 + struct input_dev *input = kscandat->input; 86 + unsigned row, changed, scancode, keycode; 87 + u8 key; 88 + 89 + key = readl(LPC32XX_KS_DATA(kscandat->kscan_base, col)); 90 + changed = key ^ kscandat->lastkeystates[col]; 91 + kscandat->lastkeystates[col] = key; 92 + 93 + for (row = 0; changed; row++, changed >>= 1) { 94 + if (changed & 1) { 95 + /* Key state changed, signal an event */ 96 + scancode = MATRIX_SCAN_CODE(row, col, 97 + kscandat->row_shift); 98 + keycode = kscandat->keymap[scancode]; 99 + input_event(input, EV_MSC, MSC_SCAN, scancode); 100 + input_report_key(input, keycode, key & (1 << row)); 101 + } 102 + } 103 + } 104 + 105 + static irqreturn_t lpc32xx_kscan_irq(int irq, void *dev_id) 106 + { 107 + struct lpc32xx_kscan_drv *kscandat = dev_id; 108 + int i; 109 + 110 + for (i = 0; i < kscandat->matrix_sz; i++) 111 + lpc32xx_mod_states(kscandat, i); 112 + 113 + writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base)); 114 + 115 + input_sync(kscandat->input); 116 + 117 + return IRQ_HANDLED; 118 + } 119 + 120 + static int lpc32xx_kscan_open(struct input_dev *dev) 121 + { 122 + struct lpc32xx_kscan_drv *kscandat = input_get_drvdata(dev); 123 + int error; 124 + 125 + error = clk_prepare_enable(kscandat->clk); 126 + if (error) 127 + return error; 128 + 129 + writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base)); 130 + 131 + return 0; 132 + } 133 + 134 + static void lpc32xx_kscan_close(struct input_dev *dev) 135 + { 136 + struct lpc32xx_kscan_drv *kscandat = input_get_drvdata(dev); 137 + 138 + writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base)); 139 + clk_disable_unprepare(kscandat->clk); 140 + } 141 + 142 + static int __devinit lpc32xx_parse_dt(struct device *dev, 143 + struct lpc32xx_kscan_drv *kscandat) 144 + { 145 + struct device_node *np = dev->of_node; 146 + u32 rows = 0, columns = 0; 147 + 148 + of_property_read_u32(np, "keypad,num-rows", &rows); 149 + of_property_read_u32(np, "keypad,num-columns", &columns); 150 + if (!rows || rows != columns) { 151 + dev_err(dev, 152 + "rows and columns must be specified and be equal!\n"); 153 + return -EINVAL; 154 + } 155 + 156 + kscandat->matrix_sz = rows; 157 + kscandat->row_shift = get_count_order(columns); 158 + 159 + of_property_read_u32(np, "nxp,debounce-delay-ms", &kscandat->deb_clks); 160 + of_property_read_u32(np, "nxp,scan-delay-ms", &kscandat->scan_delay); 161 + if (!kscandat->deb_clks || !kscandat->scan_delay) { 162 + dev_err(dev, "debounce or scan delay not specified\n"); 163 + return -EINVAL; 164 + } 165 + 166 + return 0; 167 + } 168 + 169 + static int __devinit lpc32xx_kscan_probe(struct platform_device *pdev) 170 + { 171 + struct lpc32xx_kscan_drv *kscandat; 172 + struct input_dev *input; 173 + struct resource *res; 174 + size_t keymap_size; 175 + int error; 176 + int irq; 177 + 178 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 179 + if (!res) { 180 + dev_err(&pdev->dev, "failed to get platform I/O memory\n"); 181 + return -EINVAL; 182 + } 183 + 184 + irq = platform_get_irq(pdev, 0); 185 + if (irq < 0 || irq >= NR_IRQS) { 186 + dev_err(&pdev->dev, "failed to get platform irq\n"); 187 + return -EINVAL; 188 + } 189 + 190 + kscandat = kzalloc(sizeof(struct lpc32xx_kscan_drv), GFP_KERNEL); 191 + if (!kscandat) { 192 + dev_err(&pdev->dev, "failed to allocate memory\n"); 193 + return -ENOMEM; 194 + } 195 + 196 + error = lpc32xx_parse_dt(&pdev->dev, kscandat); 197 + if (error) { 198 + dev_err(&pdev->dev, "failed to parse device tree\n"); 199 + goto err_free_mem; 200 + } 201 + 202 + keymap_size = sizeof(kscandat->keymap[0]) * 203 + (kscandat->matrix_sz << kscandat->row_shift); 204 + kscandat->keymap = kzalloc(keymap_size, GFP_KERNEL); 205 + if (!kscandat->keymap) { 206 + dev_err(&pdev->dev, "could not allocate memory for keymap\n"); 207 + error = -ENOMEM; 208 + goto err_free_mem; 209 + } 210 + 211 + kscandat->input = input = input_allocate_device(); 212 + if (!input) { 213 + dev_err(&pdev->dev, "failed to allocate input device\n"); 214 + error = -ENOMEM; 215 + goto err_free_keymap; 216 + } 217 + 218 + /* Setup key input */ 219 + input->name = pdev->name; 220 + input->phys = "lpc32xx/input0"; 221 + input->id.vendor = 0x0001; 222 + input->id.product = 0x0001; 223 + input->id.version = 0x0100; 224 + input->open = lpc32xx_kscan_open; 225 + input->close = lpc32xx_kscan_close; 226 + input->dev.parent = &pdev->dev; 227 + 228 + input_set_capability(input, EV_MSC, MSC_SCAN); 229 + 230 + error = matrix_keypad_build_keymap(NULL, NULL, 231 + kscandat->matrix_sz, 232 + kscandat->matrix_sz, 233 + kscandat->keymap, kscandat->input); 234 + if (error) { 235 + dev_err(&pdev->dev, "failed to build keymap\n"); 236 + goto err_free_input; 237 + } 238 + 239 + input_set_drvdata(kscandat->input, kscandat); 240 + 241 + kscandat->iores = request_mem_region(res->start, resource_size(res), 242 + pdev->name); 243 + if (!kscandat->iores) { 244 + dev_err(&pdev->dev, "failed to request I/O memory\n"); 245 + error = -EBUSY; 246 + goto err_free_input; 247 + } 248 + 249 + kscandat->kscan_base = ioremap(kscandat->iores->start, 250 + resource_size(kscandat->iores)); 251 + if (!kscandat->kscan_base) { 252 + dev_err(&pdev->dev, "failed to remap I/O memory\n"); 253 + error = -EBUSY; 254 + goto err_release_memregion; 255 + } 256 + 257 + /* Get the key scanner clock */ 258 + kscandat->clk = clk_get(&pdev->dev, NULL); 259 + if (IS_ERR(kscandat->clk)) { 260 + dev_err(&pdev->dev, "failed to get clock\n"); 261 + error = PTR_ERR(kscandat->clk); 262 + goto err_unmap; 263 + } 264 + 265 + /* Configure the key scanner */ 266 + error = clk_prepare_enable(kscandat->clk); 267 + if (error) 268 + goto err_clk_put; 269 + 270 + writel(kscandat->deb_clks, LPC32XX_KS_DEB(kscandat->kscan_base)); 271 + writel(kscandat->scan_delay, LPC32XX_KS_SCAN_CTL(kscandat->kscan_base)); 272 + writel(LPC32XX_KSCAN_FTST_USE32K_CLK, 273 + LPC32XX_KS_FAST_TST(kscandat->kscan_base)); 274 + writel(kscandat->matrix_sz, 275 + LPC32XX_KS_MATRIX_DIM(kscandat->kscan_base)); 276 + writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base)); 277 + clk_disable_unprepare(kscandat->clk); 278 + 279 + error = request_irq(irq, lpc32xx_kscan_irq, 0, pdev->name, kscandat); 280 + if (error) { 281 + dev_err(&pdev->dev, "failed to request irq\n"); 282 + goto err_clk_put; 283 + } 284 + 285 + error = input_register_device(kscandat->input); 286 + if (error) { 287 + dev_err(&pdev->dev, "failed to register input device\n"); 288 + goto err_free_irq; 289 + } 290 + 291 + platform_set_drvdata(pdev, kscandat); 292 + return 0; 293 + 294 + err_free_irq: 295 + free_irq(irq, kscandat); 296 + err_clk_put: 297 + clk_put(kscandat->clk); 298 + err_unmap: 299 + iounmap(kscandat->kscan_base); 300 + err_release_memregion: 301 + release_mem_region(kscandat->iores->start, 302 + resource_size(kscandat->iores)); 303 + err_free_input: 304 + input_free_device(kscandat->input); 305 + err_free_keymap: 306 + kfree(kscandat->keymap); 307 + err_free_mem: 308 + kfree(kscandat); 309 + 310 + return error; 311 + } 312 + 313 + static int __devexit lpc32xx_kscan_remove(struct platform_device *pdev) 314 + { 315 + struct lpc32xx_kscan_drv *kscandat = platform_get_drvdata(pdev); 316 + 317 + free_irq(platform_get_irq(pdev, 0), kscandat); 318 + clk_put(kscandat->clk); 319 + iounmap(kscandat->kscan_base); 320 + release_mem_region(kscandat->iores->start, 321 + resource_size(kscandat->iores)); 322 + input_unregister_device(kscandat->input); 323 + kfree(kscandat->keymap); 324 + kfree(kscandat); 325 + 326 + return 0; 327 + } 328 + 329 + #ifdef CONFIG_PM_SLEEP 330 + static int lpc32xx_kscan_suspend(struct device *dev) 331 + { 332 + struct platform_device *pdev = to_platform_device(dev); 333 + struct lpc32xx_kscan_drv *kscandat = platform_get_drvdata(pdev); 334 + struct input_dev *input = kscandat->input; 335 + 336 + mutex_lock(&input->mutex); 337 + 338 + if (input->users) { 339 + /* Clear IRQ and disable clock */ 340 + writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base)); 341 + clk_disable_unprepare(kscandat->clk); 342 + } 343 + 344 + mutex_unlock(&input->mutex); 345 + return 0; 346 + } 347 + 348 + static int lpc32xx_kscan_resume(struct device *dev) 349 + { 350 + struct platform_device *pdev = to_platform_device(dev); 351 + struct lpc32xx_kscan_drv *kscandat = platform_get_drvdata(pdev); 352 + struct input_dev *input = kscandat->input; 353 + int retval = 0; 354 + 355 + mutex_lock(&input->mutex); 356 + 357 + if (input->users) { 358 + /* Enable clock and clear IRQ */ 359 + retval = clk_prepare_enable(kscandat->clk); 360 + if (retval == 0) 361 + writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base)); 362 + } 363 + 364 + mutex_unlock(&input->mutex); 365 + return retval; 366 + } 367 + #endif 368 + 369 + static SIMPLE_DEV_PM_OPS(lpc32xx_kscan_pm_ops, lpc32xx_kscan_suspend, 370 + lpc32xx_kscan_resume); 371 + 372 + static const struct of_device_id lpc32xx_kscan_match[] = { 373 + { .compatible = "nxp,lpc3220-key" }, 374 + {}, 375 + }; 376 + MODULE_DEVICE_TABLE(of, lpc32xx_kscan_match); 377 + 378 + static struct platform_driver lpc32xx_kscan_driver = { 379 + .probe = lpc32xx_kscan_probe, 380 + .remove = __devexit_p(lpc32xx_kscan_remove), 381 + .driver = { 382 + .name = DRV_NAME, 383 + .owner = THIS_MODULE, 384 + .pm = &lpc32xx_kscan_pm_ops, 385 + .of_match_table = of_match_ptr(lpc32xx_kscan_match), 386 + } 387 + }; 388 + 389 + module_platform_driver(lpc32xx_kscan_driver); 390 + 391 + MODULE_LICENSE("GPL"); 392 + MODULE_AUTHOR("Kevin Wells <kevin.wells@nxp.com>"); 393 + MODULE_AUTHOR("Roland Stigge <stigge@antcom.de>"); 394 + MODULE_DESCRIPTION("Key scanner driver for LPC32XX devices");
+49 -29
drivers/input/keyboard/nomadik-ske-keypad.c
··· 49 49 #define SKE_ASR3 0x2C 50 50 51 51 #define SKE_NUM_ASRX_REGISTERS (4) 52 + #define KEY_PRESSED_DELAY 10 52 53 53 54 /** 54 55 * struct ske_keypad - data structure used by keypad driver ··· 93 92 static int __init ske_keypad_chip_init(struct ske_keypad *keypad) 94 93 { 95 94 u32 value; 96 - int timeout = 50; 95 + int timeout = keypad->board->debounce_ms; 97 96 98 97 /* check SKE_RIS to be 0 */ 99 98 while ((readl(keypad->reg_base + SKE_RIS) != 0x00000000) && timeout--) ··· 136 135 return 0; 137 136 } 138 137 138 + static void ske_keypad_report(struct ske_keypad *keypad, u8 status, int col) 139 + { 140 + int row = 0, code, pos; 141 + struct input_dev *input = keypad->input; 142 + u32 ske_ris; 143 + int key_pressed; 144 + int num_of_rows; 145 + 146 + /* find out the row */ 147 + num_of_rows = hweight8(status); 148 + do { 149 + pos = __ffs(status); 150 + row = pos; 151 + status &= ~(1 << pos); 152 + 153 + code = MATRIX_SCAN_CODE(row, col, SKE_KEYPAD_ROW_SHIFT); 154 + ske_ris = readl(keypad->reg_base + SKE_RIS); 155 + key_pressed = ske_ris & SKE_KPRISA; 156 + 157 + input_event(input, EV_MSC, MSC_SCAN, code); 158 + input_report_key(input, keypad->keymap[code], key_pressed); 159 + input_sync(input); 160 + num_of_rows--; 161 + } while (num_of_rows); 162 + } 163 + 139 164 static void ske_keypad_read_data(struct ske_keypad *keypad) 140 165 { 141 - struct input_dev *input = keypad->input; 142 - u16 status; 143 - int col = 0, row = 0, code; 144 - int ske_asr, ske_ris, key_pressed, i; 166 + u8 status; 167 + int col = 0; 168 + int ske_asr, i; 145 169 146 170 /* 147 171 * Read the auto scan registers ··· 180 154 if (!ske_asr) 181 155 continue; 182 156 183 - /* now that ASRx is zero, find out the column x and row y*/ 184 - if (ske_asr & 0xff) { 157 + /* now that ASRx is zero, find out the coloumn x and row y */ 158 + status = ske_asr & 0xff; 159 + if (status) { 185 160 col = i * 2; 186 - status = ske_asr & 0xff; 187 - } else { 188 - col = (i * 2) + 1; 189 - status = (ske_asr & 0xff00) >> 8; 161 + ske_keypad_report(keypad, status, col); 190 162 } 191 - 192 - /* find out the row */ 193 - row = __ffs(status); 194 - 195 - code = MATRIX_SCAN_CODE(row, col, SKE_KEYPAD_ROW_SHIFT); 196 - ske_ris = readl(keypad->reg_base + SKE_RIS); 197 - key_pressed = ske_ris & SKE_KPRISA; 198 - 199 - input_event(input, EV_MSC, MSC_SCAN, code); 200 - input_report_key(input, keypad->keymap[code], key_pressed); 201 - input_sync(input); 163 + status = (ske_asr & 0xff00) >> 8; 164 + if (status) { 165 + col = (i * 2) + 1; 166 + ske_keypad_report(keypad, status, col); 167 + } 202 168 } 203 169 } 204 170 205 171 static irqreturn_t ske_keypad_irq(int irq, void *dev_id) 206 172 { 207 173 struct ske_keypad *keypad = dev_id; 208 - int retries = 20; 174 + int timeout = keypad->board->debounce_ms; 209 175 210 176 /* disable auto scan interrupt; mask the interrupt generated */ 211 177 ske_keypad_set_bits(keypad, SKE_IMSC, ~SKE_KPIMA, 0x0); 212 178 ske_keypad_set_bits(keypad, SKE_ICR, 0x0, SKE_KPICA); 213 179 214 - while ((readl(keypad->reg_base + SKE_CR) & SKE_KPASON) && --retries) 215 - msleep(5); 180 + while ((readl(keypad->reg_base + SKE_CR) & SKE_KPASON) && --timeout) 181 + cpu_relax(); 216 182 217 - if (retries) { 218 - /* SKEx registers are stable and can be read */ 219 - ske_keypad_read_data(keypad); 220 - } 183 + /* SKEx registers are stable and can be read */ 184 + ske_keypad_read_data(keypad); 185 + 186 + /* wait until raw interrupt is clear */ 187 + while ((readl(keypad->reg_base + SKE_RIS)) && --timeout) 188 + msleep(KEY_PRESSED_DELAY); 221 189 222 190 /* enable auto scan interrupts */ 223 191 ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA);
+88 -41
drivers/input/keyboard/omap4-keypad.c
··· 27 27 #include <linux/platform_device.h> 28 28 #include <linux/errno.h> 29 29 #include <linux/io.h> 30 + #include <linux/of.h> 30 31 #include <linux/input.h> 31 32 #include <linux/slab.h> 32 33 #include <linux/pm_runtime.h> ··· 85 84 u32 reg_offset; 86 85 u32 irqreg_offset; 87 86 unsigned int row_shift; 87 + bool no_autorepeat; 88 88 unsigned char key_state[8]; 89 - unsigned short keymap[]; 89 + unsigned short *keymap; 90 90 }; 91 91 92 92 static int kbd_readl(struct omap4_keypad *keypad_data, u32 offset) ··· 210 208 pm_runtime_put_sync(input->dev.parent); 211 209 } 212 210 211 + #ifdef CONFIG_OF 212 + static int __devinit omap4_keypad_parse_dt(struct device *dev, 213 + struct omap4_keypad *keypad_data) 214 + { 215 + struct device_node *np = dev->of_node; 216 + 217 + if (!np) { 218 + dev_err(dev, "missing DT data"); 219 + return -EINVAL; 220 + } 221 + 222 + of_property_read_u32(np, "keypad,num-rows", &keypad_data->rows); 223 + of_property_read_u32(np, "keypad,num-columns", &keypad_data->cols); 224 + if (!keypad_data->rows || !keypad_data->cols) { 225 + dev_err(dev, "number of keypad rows/columns not specified\n"); 226 + return -EINVAL; 227 + } 228 + 229 + if (of_get_property(np, "linux,input-no-autorepeat", NULL)) 230 + keypad_data->no_autorepeat = true; 231 + 232 + return 0; 233 + } 234 + #else 235 + static inline int omap4_keypad_parse_dt(struct device *dev, 236 + struct omap4_keypad *keypad_data) 237 + { 238 + return -ENOSYS; 239 + } 240 + #endif 241 + 213 242 static int __devinit omap4_keypad_probe(struct platform_device *pdev) 214 243 { 215 - const struct omap4_keypad_platform_data *pdata; 244 + const struct omap4_keypad_platform_data *pdata = 245 + dev_get_platdata(&pdev->dev); 246 + const struct matrix_keymap_data *keymap_data = 247 + pdata ? pdata->keymap_data : NULL; 216 248 struct omap4_keypad *keypad_data; 217 249 struct input_dev *input_dev; 218 250 struct resource *res; 219 - resource_size_t size; 220 - unsigned int row_shift, max_keys; 251 + unsigned int max_keys; 221 252 int rev; 222 253 int irq; 223 254 int error; 224 - 225 - /* platform data */ 226 - pdata = pdev->dev.platform_data; 227 - if (!pdata) { 228 - dev_err(&pdev->dev, "no platform data defined\n"); 229 - return -EINVAL; 230 - } 231 255 232 256 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 233 257 if (!res) { ··· 267 239 return -EINVAL; 268 240 } 269 241 270 - if (!pdata->keymap_data) { 271 - dev_err(&pdev->dev, "no keymap data defined\n"); 272 - return -EINVAL; 273 - } 274 - 275 - row_shift = get_count_order(pdata->cols); 276 - max_keys = pdata->rows << row_shift; 277 - 278 - keypad_data = kzalloc(sizeof(struct omap4_keypad) + 279 - max_keys * sizeof(keypad_data->keymap[0]), 280 - GFP_KERNEL); 242 + keypad_data = kzalloc(sizeof(struct omap4_keypad), GFP_KERNEL); 281 243 if (!keypad_data) { 282 244 dev_err(&pdev->dev, "keypad_data memory allocation failed\n"); 283 245 return -ENOMEM; 284 246 } 285 247 286 - size = resource_size(res); 248 + keypad_data->irq = irq; 287 249 288 - res = request_mem_region(res->start, size, pdev->name); 250 + if (pdata) { 251 + keypad_data->rows = pdata->rows; 252 + keypad_data->cols = pdata->cols; 253 + } else { 254 + error = omap4_keypad_parse_dt(&pdev->dev, keypad_data); 255 + if (error) 256 + return error; 257 + } 258 + 259 + res = request_mem_region(res->start, resource_size(res), pdev->name); 289 260 if (!res) { 290 261 dev_err(&pdev->dev, "can't request mem region\n"); 291 262 error = -EBUSY; ··· 298 271 goto err_release_mem; 299 272 } 300 273 301 - keypad_data->irq = irq; 302 - keypad_data->row_shift = row_shift; 303 - keypad_data->rows = pdata->rows; 304 - keypad_data->cols = pdata->cols; 305 274 306 275 /* 307 - * Enable clocks for the keypad module so that we can read 308 - * revision register. 309 - */ 276 + * Enable clocks for the keypad module so that we can read 277 + * revision register. 278 + */ 310 279 pm_runtime_enable(&pdev->dev); 311 280 error = pm_runtime_get_sync(&pdev->dev); 312 281 if (error) { ··· 345 322 input_dev->open = omap4_keypad_open; 346 323 input_dev->close = omap4_keypad_close; 347 324 348 - error = matrix_keypad_build_keymap(pdata->keymap_data, NULL, 349 - pdata->rows, pdata->cols, 350 - keypad_data->keymap, input_dev); 351 - if (error) { 352 - dev_err(&pdev->dev, "failed to build keymap\n"); 325 + input_set_capability(input_dev, EV_MSC, MSC_SCAN); 326 + if (!keypad_data->no_autorepeat) 327 + __set_bit(EV_REP, input_dev->evbit); 328 + 329 + input_set_drvdata(input_dev, keypad_data); 330 + 331 + keypad_data->row_shift = get_count_order(keypad_data->cols); 332 + max_keys = keypad_data->rows << keypad_data->row_shift; 333 + keypad_data->keymap = kzalloc(max_keys * sizeof(keypad_data->keymap[0]), 334 + GFP_KERNEL); 335 + if (!keypad_data->keymap) { 336 + dev_err(&pdev->dev, "Not enough memory for keymap\n"); 337 + error = -ENOMEM; 353 338 goto err_free_input; 354 339 } 355 340 356 - __set_bit(EV_REP, input_dev->evbit); 357 - input_set_capability(input_dev, EV_MSC, MSC_SCAN); 358 - 359 - input_set_drvdata(input_dev, keypad_data); 341 + error = matrix_keypad_build_keymap(keymap_data, NULL, 342 + keypad_data->rows, keypad_data->cols, 343 + keypad_data->keymap, input_dev); 344 + if (error) { 345 + dev_err(&pdev->dev, "failed to build keymap\n"); 346 + goto err_free_keymap; 347 + } 360 348 361 349 error = request_irq(keypad_data->irq, omap4_keypad_interrupt, 362 350 IRQF_TRIGGER_RISING, ··· 391 357 err_pm_disable: 392 358 pm_runtime_disable(&pdev->dev); 393 359 free_irq(keypad_data->irq, keypad_data); 360 + err_free_keymap: 361 + kfree(keypad_data->keymap); 394 362 err_free_input: 395 363 input_free_device(input_dev); 396 364 err_pm_put_sync: ··· 400 364 err_unmap: 401 365 iounmap(keypad_data->base); 402 366 err_release_mem: 403 - release_mem_region(res->start, size); 367 + release_mem_region(res->start, resource_size(res)); 404 368 err_free_keypad: 405 369 kfree(keypad_data); 406 370 return error; ··· 422 386 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 423 387 release_mem_region(res->start, resource_size(res)); 424 388 389 + kfree(keypad_data->keymap); 425 390 kfree(keypad_data); 391 + 426 392 platform_set_drvdata(pdev, NULL); 427 393 428 394 return 0; 429 395 } 396 + 397 + #ifdef CONFIG_OF 398 + static const struct of_device_id omap_keypad_dt_match[] = { 399 + { .compatible = "ti,omap4-keypad" }, 400 + {}, 401 + }; 402 + MODULE_DEVICE_TABLE(of, omap_keypad_dt_match); 403 + #endif 430 404 431 405 static struct platform_driver omap4_keypad_driver = { 432 406 .probe = omap4_keypad_probe, ··· 444 398 .driver = { 445 399 .name = "omap4-keypad", 446 400 .owner = THIS_MODULE, 401 + .of_match_table = of_match_ptr(omap_keypad_dt_match), 447 402 }, 448 403 }; 449 404 module_platform_driver(omap4_keypad_driver);
+92 -45
drivers/input/keyboard/spear-keyboard.c
··· 27 27 #include <plat/keyboard.h> 28 28 29 29 /* Keyboard Registers */ 30 - #define MODE_REG 0x00 /* 16 bit reg */ 31 - #define STATUS_REG 0x0C /* 2 bit reg */ 32 - #define DATA_REG 0x10 /* 8 bit reg */ 30 + #define MODE_CTL_REG 0x00 31 + #define STATUS_REG 0x0C 32 + #define DATA_REG 0x10 33 33 #define INTR_MASK 0x54 34 34 35 35 /* Register Values */ 36 - /* 37 - * pclk freq mask = (APB FEQ -1)= 82 MHZ.Programme bit 15-9 in mode 38 - * control register as 1010010(82MHZ) 39 - */ 40 - #define PCLK_FREQ_MSK 0xA400 /* 82 MHz */ 41 - #define START_SCAN 0x0100 42 - #define SCAN_RATE_10 0x0000 43 - #define SCAN_RATE_20 0x0004 44 - #define SCAN_RATE_40 0x0008 45 - #define SCAN_RATE_80 0x000C 46 - #define MODE_KEYBOARD 0x0002 47 - #define DATA_AVAIL 0x2 48 - 49 - #define KEY_MASK 0xFF000000 50 - #define KEY_VALUE 0x00FFFFFF 51 - #define ROW_MASK 0xF0 52 - #define COLUMN_MASK 0x0F 53 36 #define NUM_ROWS 16 54 37 #define NUM_COLS 16 38 + #define MODE_CTL_PCLK_FREQ_SHIFT 9 39 + #define MODE_CTL_PCLK_FREQ_MSK 0x7F 55 40 56 - #define KEY_MATRIX_SHIFT 6 41 + #define MODE_CTL_KEYBOARD (0x2 << 0) 42 + #define MODE_CTL_SCAN_RATE_10 (0x0 << 2) 43 + #define MODE_CTL_SCAN_RATE_20 (0x1 << 2) 44 + #define MODE_CTL_SCAN_RATE_40 (0x2 << 2) 45 + #define MODE_CTL_SCAN_RATE_80 (0x3 << 2) 46 + #define MODE_CTL_KEYNUM_SHIFT 6 47 + #define MODE_CTL_START_SCAN (0x1 << 8) 48 + 49 + #define STATUS_DATA_AVAIL (0x1 << 1) 50 + 51 + #define DATA_ROW_MASK 0xF0 52 + #define DATA_COLUMN_MASK 0x0F 53 + 54 + #define ROW_SHIFT 4 57 55 58 56 struct spear_kbd { 59 57 struct input_dev *input; ··· 63 65 unsigned short last_key; 64 66 unsigned short keycodes[NUM_ROWS * NUM_COLS]; 65 67 bool rep; 68 + unsigned int suspended_rate; 69 + u32 mode_ctl_reg; 66 70 }; 67 71 68 72 static irqreturn_t spear_kbd_interrupt(int irq, void *dev_id) ··· 72 72 struct spear_kbd *kbd = dev_id; 73 73 struct input_dev *input = kbd->input; 74 74 unsigned int key; 75 - u8 sts, val; 75 + u32 sts, val; 76 76 77 - sts = readb(kbd->io_base + STATUS_REG); 78 - if (!(sts & DATA_AVAIL)) 77 + sts = readl_relaxed(kbd->io_base + STATUS_REG); 78 + if (!(sts & STATUS_DATA_AVAIL)) 79 79 return IRQ_NONE; 80 80 81 81 if (kbd->last_key != KEY_RESERVED) { ··· 84 84 } 85 85 86 86 /* following reads active (row, col) pair */ 87 - val = readb(kbd->io_base + DATA_REG); 87 + val = readl_relaxed(kbd->io_base + DATA_REG) & 88 + (DATA_ROW_MASK | DATA_COLUMN_MASK); 88 89 key = kbd->keycodes[val]; 89 90 90 91 input_event(input, EV_MSC, MSC_SCAN, val); ··· 95 94 kbd->last_key = key; 96 95 97 96 /* clear interrupt */ 98 - writeb(0, kbd->io_base + STATUS_REG); 97 + writel_relaxed(0, kbd->io_base + STATUS_REG); 99 98 100 99 return IRQ_HANDLED; 101 100 } ··· 104 103 { 105 104 struct spear_kbd *kbd = input_get_drvdata(dev); 106 105 int error; 107 - u16 val; 106 + u32 val; 108 107 109 108 kbd->last_key = KEY_RESERVED; 110 109 ··· 112 111 if (error) 113 112 return error; 114 113 114 + /* keyboard rate to be programmed is input clock (in MHz) - 1 */ 115 + val = clk_get_rate(kbd->clk) / 1000000 - 1; 116 + val = (val & MODE_CTL_PCLK_FREQ_MSK) << MODE_CTL_PCLK_FREQ_SHIFT; 117 + 115 118 /* program keyboard */ 116 - val = SCAN_RATE_80 | MODE_KEYBOARD | PCLK_FREQ_MSK | 117 - (kbd->mode << KEY_MATRIX_SHIFT); 118 - writew(val, kbd->io_base + MODE_REG); 119 - writeb(1, kbd->io_base + STATUS_REG); 119 + val = MODE_CTL_SCAN_RATE_80 | MODE_CTL_KEYBOARD | val | 120 + (kbd->mode << MODE_CTL_KEYNUM_SHIFT); 121 + writel_relaxed(val, kbd->io_base + MODE_CTL_REG); 122 + writel_relaxed(1, kbd->io_base + STATUS_REG); 120 123 121 124 /* start key scan */ 122 - val = readw(kbd->io_base + MODE_REG); 123 - val |= START_SCAN; 124 - writew(val, kbd->io_base + MODE_REG); 125 + val = readl_relaxed(kbd->io_base + MODE_CTL_REG); 126 + val |= MODE_CTL_START_SCAN; 127 + writel_relaxed(val, kbd->io_base + MODE_CTL_REG); 125 128 126 129 return 0; 127 130 } ··· 133 128 static void spear_kbd_close(struct input_dev *dev) 134 129 { 135 130 struct spear_kbd *kbd = input_get_drvdata(dev); 136 - u16 val; 131 + u32 val; 137 132 138 133 /* stop key scan */ 139 - val = readw(kbd->io_base + MODE_REG); 140 - val &= ~START_SCAN; 141 - writew(val, kbd->io_base + MODE_REG); 134 + val = readl_relaxed(kbd->io_base + MODE_CTL_REG); 135 + val &= ~MODE_CTL_START_SCAN; 136 + writel_relaxed(val, kbd->io_base + MODE_CTL_REG); 142 137 143 138 clk_disable(kbd->clk); 144 139 ··· 151 146 { 152 147 struct device_node *np = pdev->dev.of_node; 153 148 int error; 154 - u32 val; 149 + u32 val, suspended_rate; 155 150 156 151 if (!np) { 157 152 dev_err(&pdev->dev, "Missing DT data\n"); ··· 160 155 161 156 if (of_property_read_bool(np, "autorepeat")) 162 157 kbd->rep = true; 158 + 159 + if (of_property_read_u32(np, "suspended_rate", &suspended_rate)) 160 + kbd->suspended_rate = suspended_rate; 163 161 164 162 error = of_property_read_u32(np, "st,mode", &val); 165 163 if (error) { ··· 221 213 } else { 222 214 kbd->mode = pdata->mode; 223 215 kbd->rep = pdata->rep; 216 + kbd->suspended_rate = pdata->suspended_rate; 224 217 } 225 218 226 219 kbd->res = request_mem_region(res->start, resource_size(res), ··· 311 302 release_mem_region(kbd->res->start, resource_size(kbd->res)); 312 303 kfree(kbd); 313 304 314 - device_init_wakeup(&pdev->dev, 1); 305 + device_init_wakeup(&pdev->dev, 0); 315 306 platform_set_drvdata(pdev, NULL); 316 307 317 308 return 0; ··· 323 314 struct platform_device *pdev = to_platform_device(dev); 324 315 struct spear_kbd *kbd = platform_get_drvdata(pdev); 325 316 struct input_dev *input_dev = kbd->input; 317 + unsigned int rate = 0, mode_ctl_reg, val; 326 318 327 319 mutex_lock(&input_dev->mutex); 328 320 329 - if (input_dev->users) 330 - clk_enable(kbd->clk); 321 + /* explicitly enable clock as we may program device */ 322 + clk_enable(kbd->clk); 331 323 332 - if (device_may_wakeup(&pdev->dev)) 324 + mode_ctl_reg = readl_relaxed(kbd->io_base + MODE_CTL_REG); 325 + 326 + if (device_may_wakeup(&pdev->dev)) { 333 327 enable_irq_wake(kbd->irq); 328 + 329 + /* 330 + * reprogram the keyboard operating frequency as on some 331 + * platform it may change during system suspended 332 + */ 333 + if (kbd->suspended_rate) 334 + rate = kbd->suspended_rate / 1000000 - 1; 335 + else 336 + rate = clk_get_rate(kbd->clk) / 1000000 - 1; 337 + 338 + val = mode_ctl_reg & 339 + ~(MODE_CTL_PCLK_FREQ_MSK << MODE_CTL_PCLK_FREQ_SHIFT); 340 + val |= (rate & MODE_CTL_PCLK_FREQ_MSK) 341 + << MODE_CTL_PCLK_FREQ_SHIFT; 342 + writel_relaxed(val, kbd->io_base + MODE_CTL_REG); 343 + 344 + } else { 345 + if (input_dev->users) { 346 + writel_relaxed(mode_ctl_reg & ~MODE_CTL_START_SCAN, 347 + kbd->io_base + MODE_CTL_REG); 348 + clk_disable(kbd->clk); 349 + } 350 + } 351 + 352 + /* store current configuration */ 353 + if (input_dev->users) 354 + kbd->mode_ctl_reg = mode_ctl_reg; 355 + 356 + /* restore previous clk state */ 357 + clk_disable(kbd->clk); 334 358 335 359 mutex_unlock(&input_dev->mutex); 336 360 ··· 378 336 379 337 mutex_lock(&input_dev->mutex); 380 338 381 - if (device_may_wakeup(&pdev->dev)) 339 + if (device_may_wakeup(&pdev->dev)) { 382 340 disable_irq_wake(kbd->irq); 341 + } else { 342 + if (input_dev->users) 343 + clk_enable(kbd->clk); 344 + } 383 345 346 + /* restore current configuration */ 384 347 if (input_dev->users) 385 - clk_enable(kbd->clk); 348 + writel_relaxed(kbd->mode_ctl_reg, kbd->io_base + MODE_CTL_REG); 386 349 387 350 mutex_unlock(&input_dev->mutex); 388 351
+9
drivers/input/misc/ab8500-ponkey.c
··· 13 13 #include <linux/input.h> 14 14 #include <linux/interrupt.h> 15 15 #include <linux/mfd/abx500/ab8500.h> 16 + #include <linux/of.h> 16 17 #include <linux/slab.h> 17 18 18 19 /** ··· 132 131 return 0; 133 132 } 134 133 134 + #ifdef CONFIG_OF 135 + static const struct of_device_id ab8500_ponkey_match[] = { 136 + { .compatible = "stericsson,ab8500-ponkey", }, 137 + {} 138 + }; 139 + #endif 140 + 135 141 static struct platform_driver ab8500_ponkey_driver = { 136 142 .driver = { 137 143 .name = "ab8500-poweron-key", 138 144 .owner = THIS_MODULE, 145 + .of_match_table = of_match_ptr(ab8500_ponkey_match), 139 146 }, 140 147 .probe = ab8500_ponkey_probe, 141 148 .remove = __devexit_p(ab8500_ponkey_remove),
+24 -18
drivers/input/misc/twl6040-vibra.c
··· 251 251 252 252 return 0; 253 253 } 254 - 255 254 #endif 256 255 257 256 static SIMPLE_DEV_PM_OPS(twl6040_vibra_pm_ops, twl6040_vibra_suspend, NULL); ··· 258 259 static int __devinit twl6040_vibra_probe(struct platform_device *pdev) 259 260 { 260 261 struct twl6040_vibra_data *pdata = pdev->dev.platform_data; 261 - struct device_node *node = pdev->dev.of_node; 262 + struct device *twl6040_core_dev = pdev->dev.parent; 263 + struct device_node *twl6040_core_node = NULL; 262 264 struct vibra_info *info; 263 265 int vddvibl_uV = 0; 264 266 int vddvibr_uV = 0; 265 267 int ret; 266 268 267 - if (!pdata && !node) { 269 + #ifdef CONFIG_OF 270 + twl6040_core_node = of_find_node_by_name(twl6040_core_dev->of_node, 271 + "vibra"); 272 + #endif 273 + 274 + if (!pdata && !twl6040_core_node) { 268 275 dev_err(&pdev->dev, "platform_data not available\n"); 269 276 return -EINVAL; 270 277 } ··· 292 287 vddvibl_uV = pdata->vddvibl_uV; 293 288 vddvibr_uV = pdata->vddvibr_uV; 294 289 } else { 295 - of_property_read_u32(node, "vibldrv_res", &info->vibldrv_res); 296 - of_property_read_u32(node, "vibrdrv_res", &info->vibrdrv_res); 297 - of_property_read_u32(node, "viblmotor_res", 290 + of_property_read_u32(twl6040_core_node, "ti,vibldrv-res", 291 + &info->vibldrv_res); 292 + of_property_read_u32(twl6040_core_node, "ti,vibrdrv-res", 293 + &info->vibrdrv_res); 294 + of_property_read_u32(twl6040_core_node, "ti,viblmotor-res", 298 295 &info->viblmotor_res); 299 - of_property_read_u32(node, "vibrmotor_res", 296 + of_property_read_u32(twl6040_core_node, "ti,vibrmotor-res", 300 297 &info->vibrmotor_res); 301 - of_property_read_u32(node, "vddvibl_uV", &vddvibl_uV); 302 - of_property_read_u32(node, "vddvibr_uV", &vddvibr_uV); 298 + of_property_read_u32(twl6040_core_node, "ti,vddvibl-uV", 299 + &vddvibl_uV); 300 + of_property_read_u32(twl6040_core_node, "ti,vddvibr-uV", 301 + &vddvibr_uV); 303 302 } 304 303 305 304 if ((!info->vibldrv_res && !info->viblmotor_res) || ··· 360 351 361 352 info->supplies[0].supply = "vddvibl"; 362 353 info->supplies[1].supply = "vddvibr"; 363 - ret = regulator_bulk_get(info->dev, ARRAY_SIZE(info->supplies), 364 - info->supplies); 354 + /* 355 + * When booted with Device tree the regulators are attached to the 356 + * parent device (twl6040 MFD core) 357 + */ 358 + ret = regulator_bulk_get(pdata ? info->dev : twl6040_core_dev, 359 + ARRAY_SIZE(info->supplies), info->supplies); 365 360 if (ret) { 366 361 dev_err(info->dev, "couldn't get regulators %d\n", ret); 367 362 goto err_regulator; ··· 431 418 return 0; 432 419 } 433 420 434 - static const struct of_device_id twl6040_vibra_of_match[] = { 435 - {.compatible = "ti,twl6040-vibra", }, 436 - { }, 437 - }; 438 - MODULE_DEVICE_TABLE(of, twl6040_vibra_of_match); 439 - 440 421 static struct platform_driver twl6040_vibra_driver = { 441 422 .probe = twl6040_vibra_probe, 442 423 .remove = __devexit_p(twl6040_vibra_remove), ··· 438 431 .name = "twl6040-vibra", 439 432 .owner = THIS_MODULE, 440 433 .pm = &twl6040_vibra_pm_ops, 441 - .of_match_table = twl6040_vibra_of_match, 442 434 }, 443 435 }; 444 436 module_platform_driver(twl6040_vibra_driver);
+36 -2
drivers/input/mouse/synaptics.c
··· 139 139 } 140 140 141 141 /* 142 + * Read the board id from the touchpad 143 + * The board id is encoded in the "QUERY MODES" response 144 + */ 145 + static int synaptics_board_id(struct psmouse *psmouse) 146 + { 147 + struct synaptics_data *priv = psmouse->private; 148 + unsigned char bid[3]; 149 + 150 + if (synaptics_send_cmd(psmouse, SYN_QUE_MODES, bid)) 151 + return -1; 152 + priv->board_id = ((bid[0] & 0xfc) << 6) | bid[1]; 153 + return 0; 154 + } 155 + 156 + /* 157 + * Read the firmware id from the touchpad 158 + */ 159 + static int synaptics_firmware_id(struct psmouse *psmouse) 160 + { 161 + struct synaptics_data *priv = psmouse->private; 162 + unsigned char fwid[3]; 163 + 164 + if (synaptics_send_cmd(psmouse, SYN_QUE_FIRMWARE_ID, fwid)) 165 + return -1; 166 + priv->firmware_id = (fwid[0] << 16) | (fwid[1] << 8) | fwid[2]; 167 + return 0; 168 + } 169 + 170 + /* 142 171 * Read the capability-bits from the touchpad 143 172 * see also the SYN_CAP_* macros 144 173 */ ··· 289 260 if (synaptics_identify(psmouse)) 290 261 return -1; 291 262 if (synaptics_model_id(psmouse)) 263 + return -1; 264 + if (synaptics_firmware_id(psmouse)) 265 + return -1; 266 + if (synaptics_board_id(psmouse)) 292 267 return -1; 293 268 if (synaptics_capability(psmouse)) 294 269 return -1; ··· 1468 1435 priv->pkt_type = SYN_MODEL_NEWABS(priv->model_id) ? SYN_NEWABS : SYN_OLDABS; 1469 1436 1470 1437 psmouse_info(psmouse, 1471 - "Touchpad model: %ld, fw: %ld.%ld, id: %#lx, caps: %#lx/%#lx/%#lx\n", 1438 + "Touchpad model: %ld, fw: %ld.%ld, id: %#lx, caps: %#lx/%#lx/%#lx, board id: %lu, fw id: %lu\n", 1472 1439 SYN_ID_MODEL(priv->identity), 1473 1440 SYN_ID_MAJOR(priv->identity), SYN_ID_MINOR(priv->identity), 1474 1441 priv->model_id, 1475 - priv->capabilities, priv->ext_cap, priv->ext_cap_0c); 1442 + priv->capabilities, priv->ext_cap, priv->ext_cap_0c, 1443 + priv->board_id, priv->firmware_id); 1476 1444 1477 1445 set_input_params(psmouse->dev, priv); 1478 1446
+3
drivers/input/mouse/synaptics.h
··· 18 18 #define SYN_QUE_SERIAL_NUMBER_SUFFIX 0x07 19 19 #define SYN_QUE_RESOLUTION 0x08 20 20 #define SYN_QUE_EXT_CAPAB 0x09 21 + #define SYN_QUE_FIRMWARE_ID 0x0a 21 22 #define SYN_QUE_EXT_CAPAB_0C 0x0c 22 23 #define SYN_QUE_EXT_MAX_COORDS 0x0d 23 24 #define SYN_QUE_EXT_MIN_COORDS 0x0f ··· 149 148 struct synaptics_data { 150 149 /* Data read from the touchpad */ 151 150 unsigned long int model_id; /* Model-ID */ 151 + unsigned long int firmware_id; /* Firmware-ID */ 152 + unsigned long int board_id; /* Board-ID */ 152 153 unsigned long int capabilities; /* Capabilities */ 153 154 unsigned long int ext_cap; /* Extended Capabilities */ 154 155 unsigned long int ext_cap_0c; /* Ext Caps from 0x0c query */
+1 -1
drivers/input/mouse/synaptics_usb.c
··· 364 364 le16_to_cpu(udev->descriptor.idProduct)); 365 365 366 366 if (synusb->flags & SYNUSB_STICK) 367 - strlcat(synusb->name, " (Stick) ", sizeof(synusb->name)); 367 + strlcat(synusb->name, " (Stick)", sizeof(synusb->name)); 368 368 369 369 usb_make_path(udev, synusb->phys, sizeof(synusb->phys)); 370 370 strlcat(synusb->phys, "/input0", sizeof(synusb->phys));
+42 -15
drivers/input/tablet/hanwang.c
··· 63 63 enum hanwang_tablet_type { 64 64 HANWANG_ART_MASTER_III, 65 65 HANWANG_ART_MASTER_HD, 66 + HANWANG_ART_MASTER_II, 66 67 }; 67 68 68 69 struct hanwang { ··· 100 99 ART_MASTER_PKGLEN_MAX, 0x7f00, 0x4f60, 0x3f, 0x7f, 2048 }, 101 100 { 0x8401, "Hanwang Art Master HD 5012", HANWANG_ART_MASTER_HD, 102 101 ART_MASTER_PKGLEN_MAX, 0x678e, 0x4150, 0x3f, 0x7f, 1024 }, 102 + { 0x8503, "Hanwang Art Master II", HANWANG_ART_MASTER_II, 103 + ART_MASTER_PKGLEN_MAX, 0x27de, 0x1cfe, 0x3f, 0x7f, 1024 }, 103 104 }; 104 105 105 106 static const int hw_eventtypes[] = { ··· 130 127 struct usb_device *dev = hanwang->usbdev; 131 128 enum hanwang_tablet_type type = hanwang->features->type; 132 129 int i; 133 - u16 x, y, p; 130 + u16 p; 131 + 132 + if (type == HANWANG_ART_MASTER_II) { 133 + hanwang->current_tool = BTN_TOOL_PEN; 134 + hanwang->current_id = STYLUS_DEVICE_ID; 135 + } 134 136 135 137 switch (data[0]) { 136 138 case 0x02: /* data packet */ 137 139 switch (data[1]) { 138 140 case 0x80: /* tool prox out */ 139 - hanwang->current_id = 0; 140 - input_report_key(input_dev, hanwang->current_tool, 0); 141 + if (type != HANWANG_ART_MASTER_II) { 142 + hanwang->current_id = 0; 143 + input_report_key(input_dev, 144 + hanwang->current_tool, 0); 145 + } 146 + break; 147 + 148 + case 0x00: /* artmaster ii pen leave */ 149 + if (type == HANWANG_ART_MASTER_II) { 150 + hanwang->current_id = 0; 151 + input_report_key(input_dev, 152 + hanwang->current_tool, 0); 153 + } 141 154 break; 142 155 143 156 case 0xc2: /* first time tool prox in */ ··· 173 154 default: 174 155 hanwang->current_id = 0; 175 156 dev_dbg(&dev->dev, 176 - "unknown tablet tool %02x ", data[0]); 157 + "unknown tablet tool %02x\n", data[0]); 177 158 break; 178 159 } 179 160 break; 180 161 181 162 default: /* tool data packet */ 182 - x = (data[2] << 8) | data[3]; 183 - y = (data[4] << 8) | data[5]; 184 - 185 163 switch (type) { 186 164 case HANWANG_ART_MASTER_III: 187 165 p = (data[6] << 3) | ··· 187 171 break; 188 172 189 173 case HANWANG_ART_MASTER_HD: 174 + case HANWANG_ART_MASTER_II: 190 175 p = (data[7] >> 6) | (data[6] << 2); 191 176 break; 192 177 ··· 197 180 } 198 181 199 182 input_report_abs(input_dev, ABS_X, 200 - le16_to_cpup((__le16 *)&x)); 183 + be16_to_cpup((__be16 *)&data[2])); 201 184 input_report_abs(input_dev, ABS_Y, 202 - le16_to_cpup((__le16 *)&y)); 203 - input_report_abs(input_dev, ABS_PRESSURE, 204 - le16_to_cpup((__le16 *)&p)); 185 + be16_to_cpup((__be16 *)&data[4])); 186 + input_report_abs(input_dev, ABS_PRESSURE, p); 205 187 input_report_abs(input_dev, ABS_TILT_X, data[7] & 0x3f); 206 188 input_report_abs(input_dev, ABS_TILT_Y, data[8] & 0x7f); 207 189 input_report_key(input_dev, BTN_STYLUS, data[1] & 0x02); 208 - input_report_key(input_dev, BTN_STYLUS2, data[1] & 0x04); 190 + 191 + if (type != HANWANG_ART_MASTER_II) 192 + input_report_key(input_dev, BTN_STYLUS2, 193 + data[1] & 0x04); 194 + else 195 + input_report_key(input_dev, BTN_TOOL_PEN, 1); 196 + 209 197 break; 210 198 } 199 + 211 200 input_report_abs(input_dev, ABS_MISC, hanwang->current_id); 212 201 input_event(input_dev, EV_MSC, MSC_SERIAL, 213 202 hanwang->features->pid); ··· 225 202 226 203 switch (type) { 227 204 case HANWANG_ART_MASTER_III: 228 - input_report_key(input_dev, BTN_TOOL_FINGER, data[1] || 229 - data[2] || data[3]); 205 + input_report_key(input_dev, BTN_TOOL_FINGER, 206 + data[1] || data[2] || data[3]); 230 207 input_report_abs(input_dev, ABS_WHEEL, data[1]); 231 208 input_report_key(input_dev, BTN_0, data[2]); 232 209 for (i = 0; i < 8; i++) ··· 250 227 BTN_5 + i, data[6] & (1 << i)); 251 228 } 252 229 break; 230 + 231 + case HANWANG_ART_MASTER_II: 232 + dev_dbg(&dev->dev, "error packet %02x\n", data[0]); 233 + return; 253 234 } 254 235 255 236 input_report_abs(input_dev, ABS_MISC, hanwang->current_id); ··· 261 234 break; 262 235 263 236 default: 264 - dev_dbg(&dev->dev, "error packet %02x ", data[0]); 237 + dev_dbg(&dev->dev, "error packet %02x\n", data[0]); 265 238 break; 266 239 } 267 240
+60 -41
drivers/input/tablet/wacom_sys.c
··· 445 445 /* ask to report Wacom data */ 446 446 if (features->device_type == BTN_TOOL_FINGER) { 447 447 /* if it is an MT Tablet PC touch */ 448 - if (features->type == TABLETPC2FG || 449 - features->type == MTSCREEN) { 448 + if (features->type > TABLETPC) { 450 449 do { 451 450 rep_data[0] = 3; 452 451 rep_data[1] = 4; ··· 464 465 } while ((error < 0 || rep_data[1] != 4) && 465 466 limit++ < WAC_MSG_RETRIES); 466 467 } 467 - } else if (features->type != TABLETPC && 468 + } else if (features->type <= BAMBOO_PT && 468 469 features->type != WIRELESS && 469 470 features->device_type == BTN_TOOL_PEN) { 470 471 do { ··· 508 509 if (intf->cur_altsetting->desc.bInterfaceNumber == 0) { 509 510 features->device_type = 0; 510 511 } else if (intf->cur_altsetting->desc.bInterfaceNumber == 2) { 511 - features->device_type = BTN_TOOL_DOUBLETAP; 512 + features->device_type = BTN_TOOL_FINGER; 512 513 features->pktlen = WACOM_PKGLEN_BBTOUCH3; 513 514 } 514 515 } 515 516 516 517 /* only devices that support touch need to retrieve the info */ 517 - if (features->type != TABLETPC && 518 - features->type != TABLETPC2FG && 519 - features->type != BAMBOO_PT && 520 - features->type != MTSCREEN) { 518 + if (features->type < BAMBOO_PT) { 521 519 goto out; 522 520 } 523 521 ··· 856 860 857 861 /* Initialize default values */ 858 862 switch (wacom->wacom_wac.features.type) { 863 + case INTUOS4S: 859 864 case INTUOS4: 860 865 case INTUOS4L: 861 866 wacom->led.select[0] = 0; ··· 910 913 static void wacom_destroy_leds(struct wacom *wacom) 911 914 { 912 915 switch (wacom->wacom_wac.features.type) { 916 + case INTUOS4S: 913 917 case INTUOS4: 914 918 case INTUOS4L: 915 919 sysfs_remove_group(&wacom->intf->dev.kobj, ··· 970 972 971 973 error = power_supply_register(&wacom->usbdev->dev, 972 974 &wacom->battery); 975 + 976 + if (!error) 977 + power_supply_powers(&wacom->battery, 978 + &wacom->usbdev->dev); 973 979 } 974 980 975 981 return error; ··· 981 979 982 980 static void wacom_destroy_battery(struct wacom *wacom) 983 981 { 984 - if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_MONITOR) 982 + if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_MONITOR && 983 + wacom->battery.dev) { 985 984 power_supply_unregister(&wacom->battery); 985 + wacom->battery.dev = NULL; 986 + } 986 987 } 987 988 988 989 static int wacom_register_input(struct wacom *wacom) ··· 1032 1027 struct wacom *wacom = container_of(work, struct wacom, work); 1033 1028 struct usb_device *usbdev = wacom->usbdev; 1034 1029 struct wacom_wac *wacom_wac = &wacom->wacom_wac; 1030 + struct wacom *wacom1, *wacom2; 1031 + struct wacom_wac *wacom_wac1, *wacom_wac2; 1032 + int error; 1035 1033 1036 1034 /* 1037 1035 * Regardless if this is a disconnect or a new tablet, 1038 - * remove any existing input devices. 1036 + * remove any existing input and battery devices. 1039 1037 */ 1040 1038 1039 + wacom_destroy_battery(wacom); 1040 + 1041 1041 /* Stylus interface */ 1042 - wacom = usb_get_intfdata(usbdev->config->interface[1]); 1043 - if (wacom->wacom_wac.input) 1044 - input_unregister_device(wacom->wacom_wac.input); 1045 - wacom->wacom_wac.input = NULL; 1042 + wacom1 = usb_get_intfdata(usbdev->config->interface[1]); 1043 + wacom_wac1 = &(wacom1->wacom_wac); 1044 + if (wacom_wac1->input) 1045 + input_unregister_device(wacom_wac1->input); 1046 + wacom_wac1->input = NULL; 1046 1047 1047 1048 /* Touch interface */ 1048 - wacom = usb_get_intfdata(usbdev->config->interface[2]); 1049 - if (wacom->wacom_wac.input) 1050 - input_unregister_device(wacom->wacom_wac.input); 1051 - wacom->wacom_wac.input = NULL; 1049 + wacom2 = usb_get_intfdata(usbdev->config->interface[2]); 1050 + wacom_wac2 = &(wacom2->wacom_wac); 1051 + if (wacom_wac2->input) 1052 + input_unregister_device(wacom_wac2->input); 1053 + wacom_wac2->input = NULL; 1052 1054 1053 1055 if (wacom_wac->pid == 0) { 1054 1056 dev_info(&wacom->intf->dev, "wireless tablet disconnected\n"); ··· 1080 1068 } 1081 1069 1082 1070 /* Stylus interface */ 1083 - wacom = usb_get_intfdata(usbdev->config->interface[1]); 1084 - wacom_wac = &wacom->wacom_wac; 1085 - wacom_wac->features = 1071 + wacom_wac1->features = 1086 1072 *((struct wacom_features *)id->driver_info); 1087 - wacom_wac->features.device_type = BTN_TOOL_PEN; 1088 - wacom_register_input(wacom); 1073 + wacom_wac1->features.device_type = BTN_TOOL_PEN; 1074 + error = wacom_register_input(wacom1); 1075 + if (error) 1076 + goto fail1; 1089 1077 1090 1078 /* Touch interface */ 1091 - wacom = usb_get_intfdata(usbdev->config->interface[2]); 1092 - wacom_wac = &wacom->wacom_wac; 1093 - wacom_wac->features = 1079 + wacom_wac2->features = 1094 1080 *((struct wacom_features *)id->driver_info); 1095 - wacom_wac->features.pktlen = WACOM_PKGLEN_BBTOUCH3; 1096 - wacom_wac->features.device_type = BTN_TOOL_FINGER; 1097 - wacom_set_phy_from_res(&wacom_wac->features); 1098 - wacom_wac->features.x_max = wacom_wac->features.y_max = 4096; 1099 - wacom_register_input(wacom); 1081 + wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3; 1082 + wacom_wac2->features.device_type = BTN_TOOL_FINGER; 1083 + wacom_set_phy_from_res(&wacom_wac2->features); 1084 + wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096; 1085 + error = wacom_register_input(wacom2); 1086 + if (error) 1087 + goto fail2; 1088 + 1089 + error = wacom_initialize_battery(wacom); 1090 + if (error) 1091 + goto fail3; 1100 1092 } 1093 + 1094 + return; 1095 + 1096 + fail3: 1097 + input_unregister_device(wacom_wac2->input); 1098 + wacom_wac2->input = NULL; 1099 + fail2: 1100 + input_unregister_device(wacom_wac1->input); 1101 + wacom_wac1->input = NULL; 1102 + fail1: 1103 + return; 1101 1104 } 1102 1105 1103 1106 static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) ··· 1176 1149 features->device_type = BTN_TOOL_FINGER; 1177 1150 features->pktlen = WACOM_PKGLEN_BBTOUCH3; 1178 1151 1179 - features->x_phy = 1180 - (features->x_max * 100) / features->x_resolution; 1181 - features->y_phy = 1182 - (features->y_max * 100) / features->y_resolution; 1152 + wacom_set_phy_from_res(features); 1183 1153 1184 1154 features->x_max = 4096; 1185 1155 features->y_max = 4096; ··· 1212 1188 if (error) 1213 1189 goto fail4; 1214 1190 1215 - error = wacom_initialize_battery(wacom); 1216 - if (error) 1217 - goto fail5; 1218 - 1219 1191 if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) { 1220 1192 error = wacom_register_input(wacom); 1221 1193 if (error) 1222 - goto fail6; 1194 + goto fail5; 1223 1195 } 1224 1196 1225 1197 /* Note that if query fails it is not a hard failure */ ··· 1230 1210 1231 1211 return 0; 1232 1212 1233 - fail6: wacom_destroy_battery(wacom); 1234 1213 fail5: wacom_destroy_leds(wacom); 1235 1214 fail4: wacom_remove_shared_data(wacom_wac); 1236 1215 fail3: usb_free_urb(wacom->irq);
+19 -8
drivers/input/tablet/wacom_wac.c
··· 248 248 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); 249 249 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); 250 250 if (wacom->tool[0] != BTN_TOOL_MOUSE) { 251 - input_report_abs(input, ABS_PRESSURE, data[6] | ((data[7] & 0x01) << 8)); 251 + input_report_abs(input, ABS_PRESSURE, data[6] | ((data[7] & 0x03) << 8)); 252 252 input_report_key(input, BTN_TOUCH, data[1] & 0x01); 253 253 input_report_key(input, BTN_STYLUS, data[1] & 0x02); 254 254 input_report_key(input, BTN_STYLUS2, data[1] & 0x04); ··· 888 888 prox = data[0] & 0x01; 889 889 x = get_unaligned_le16(&data[1]); 890 890 y = get_unaligned_le16(&data[3]); 891 - } else { /* with capacity */ 891 + } else { 892 892 prox = data[1] & 0x01; 893 893 x = le16_to_cpup((__le16 *)&data[2]); 894 894 y = le16_to_cpup((__le16 *)&data[4]); ··· 961 961 case WACOM_REPORT_TPC1FG: 962 962 case WACOM_REPORT_TPCHID: 963 963 case WACOM_REPORT_TPCST: 964 + case WACOM_REPORT_TPC1FGE: 964 965 return wacom_tpc_single_touch(wacom, len); 965 966 966 967 case WACOM_REPORT_TPCMT: ··· 1245 1244 break; 1246 1245 1247 1246 case TABLETPC: 1247 + case TABLETPCE: 1248 1248 case TABLETPC2FG: 1249 1249 case MTSCREEN: 1250 1250 sync = wacom_tpc_irq(wacom_wac, len); ··· 1319 1317 } 1320 1318 1321 1319 /* these device have multiple inputs */ 1322 - if (features->type == TABLETPC || features->type == TABLETPC2FG || 1323 - features->type == BAMBOO_PT || features->type == WIRELESS || 1324 - (features->type >= INTUOS5S && features->type <= INTUOS5L) || 1325 - features->type == MTSCREEN) 1320 + if (features->type >= WIRELESS || 1321 + (features->type >= INTUOS5S && features->type <= INTUOS5L)) 1326 1322 features->quirks |= WACOM_QUIRK_MULTI_INPUT; 1327 1323 1328 1324 /* quirk for bamboo touch with 2 low res touches */ ··· 1547 1547 __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 1548 1548 break; 1549 1549 1550 - case TABLETPC2FG: 1551 1550 case MTSCREEN: 1552 1551 if (features->device_type == BTN_TOOL_FINGER) { 1553 - 1554 1552 wacom_wac->slots = kmalloc(features->touch_max * 1555 1553 sizeof(int), 1556 1554 GFP_KERNEL); ··· 1557 1559 1558 1560 for (i = 0; i < features->touch_max; i++) 1559 1561 wacom_wac->slots[i] = -1; 1562 + } 1563 + /* fall through */ 1560 1564 1565 + case TABLETPC2FG: 1566 + if (features->device_type == BTN_TOOL_FINGER) { 1561 1567 input_mt_init_slots(input_dev, features->touch_max); 1562 1568 input_set_abs_params(input_dev, ABS_MT_TOOL_TYPE, 1563 1569 0, MT_TOOL_MAX, 0, 0); ··· 1573 1571 /* fall through */ 1574 1572 1575 1573 case TABLETPC: 1574 + case TABLETPCE: 1576 1575 __clear_bit(ABS_MISC, input_dev->absbit); 1577 1576 1578 1577 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); ··· 1891 1888 static const struct wacom_features wacom_features_0xEC = 1892 1889 { "Wacom ISDv4 EC", WACOM_PKGLEN_GRAPHIRE, 25710, 14500, 255, 1893 1890 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 1891 + static const struct wacom_features wacom_features_0xED = 1892 + { "Wacom ISDv4 ED", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 1893 + 0, TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 1894 + static const struct wacom_features wacom_features_0xEF = 1895 + { "Wacom ISDv4 EF", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 1896 + 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 1894 1897 static const struct wacom_features wacom_features_0x47 = 1895 1898 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 1896 1899 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; ··· 2071 2062 { USB_DEVICE_WACOM(0xE5) }, 2072 2063 { USB_DEVICE_WACOM(0xE6) }, 2073 2064 { USB_DEVICE_WACOM(0xEC) }, 2065 + { USB_DEVICE_WACOM(0xED) }, 2066 + { USB_DEVICE_WACOM(0xEF) }, 2074 2067 { USB_DEVICE_WACOM(0x47) }, 2075 2068 { USB_DEVICE_WACOM(0xF4) }, 2076 2069 { USB_DEVICE_LENOVO(0x6004) },
+5 -3
drivers/input/tablet/wacom_wac.h
··· 48 48 #define WACOM_REPORT_TPCMT 13 49 49 #define WACOM_REPORT_TPCHID 15 50 50 #define WACOM_REPORT_TPCST 16 51 + #define WACOM_REPORT_TPC1FGE 18 51 52 52 53 /* device quirks */ 53 54 #define WACOM_QUIRK_MULTI_INPUT 0x0001 ··· 63 62 PTU, 64 63 PL, 65 64 DTU, 66 - BAMBOO_PT, 67 - WIRELESS, 68 65 INTUOS, 69 66 INTUOS3S, 70 67 INTUOS3, ··· 78 79 CINTIQ, 79 80 WACOM_BEE, 80 81 WACOM_MO, 81 - TABLETPC, 82 + WIRELESS, 83 + BAMBOO_PT, 84 + TABLETPC, /* add new TPC below */ 85 + TABLETPCE, 82 86 TABLETPC2FG, 83 87 MTSCREEN, 84 88 MAX_TYPE
+12
drivers/input/touchscreen/Kconfig
··· 369 369 To compile this driver as a module, choose M here: the 370 370 module will be called mcs5000_ts. 371 371 372 + config TOUCHSCREEN_MMS114 373 + tristate "MELFAS MMS114 touchscreen" 374 + depends on I2C 375 + help 376 + Say Y here if you have the MELFAS MMS114 touchscreen controller 377 + chip in your system. 378 + 379 + If unsure, say N. 380 + 381 + To compile this driver as a module, choose M here: the 382 + module will be called mms114. 383 + 372 384 config TOUCHSCREEN_MTOUCH 373 385 tristate "MicroTouch serial touchscreens" 374 386 select SERIO
+1
drivers/input/touchscreen/Makefile
··· 38 38 obj-$(CONFIG_TOUCHSCREEN_MC13783) += mc13783_ts.o 39 39 obj-$(CONFIG_TOUCHSCREEN_MCS5000) += mcs5000_ts.o 40 40 obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o 41 + obj-$(CONFIG_TOUCHSCREEN_MMS114) += mms114.o 41 42 obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o 42 43 obj-$(CONFIG_TOUCHSCREEN_MK712) += mk712.o 43 44 obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680_ts_input.o
+5
drivers/input/touchscreen/ad7879.c
··· 118 118 unsigned int irq; 119 119 bool disabled; /* P: input->mutex */ 120 120 bool suspended; /* P: input->mutex */ 121 + bool swap_xy; 121 122 u16 conversion_data[AD7879_NR_SENSE]; 122 123 char phys[32]; 123 124 u8 first_conversion_delay; ··· 161 160 y = ts->conversion_data[AD7879_SEQ_YPOS] & MAX_12BIT; 162 161 z1 = ts->conversion_data[AD7879_SEQ_Z1] & MAX_12BIT; 163 162 z2 = ts->conversion_data[AD7879_SEQ_Z2] & MAX_12BIT; 163 + 164 + if (ts->swap_xy) 165 + swap(x, y); 164 166 165 167 /* 166 168 * The samples processed here are already preprocessed by the AD7879. ··· 524 520 ts->dev = dev; 525 521 ts->input = input_dev; 526 522 ts->irq = irq; 523 + ts->swap_xy = pdata->swap_xy; 527 524 528 525 setup_timer(&ts->timer, ad7879_timer, (unsigned long) ts); 529 526
+241 -222
drivers/input/touchscreen/atmel_mxt_ts.c
··· 36 36 #define MXT_FW_NAME "maxtouch.fw" 37 37 38 38 /* Registers */ 39 + #define MXT_INFO 0x00 39 40 #define MXT_FAMILY_ID 0x00 40 41 #define MXT_VARIANT_ID 0x01 41 42 #define MXT_VERSION 0x02 ··· 195 194 #define MXT_BOOT_STATUS_MASK 0x3f 196 195 197 196 /* Touch status */ 197 + #define MXT_UNGRIP (1 << 0) 198 198 #define MXT_SUPPRESS (1 << 1) 199 199 #define MXT_AMP (1 << 2) 200 200 #define MXT_VECTOR (1 << 3) ··· 212 210 /* Touchscreen absolute values */ 213 211 #define MXT_MAX_AREA 0xff 214 212 215 - #define MXT_MAX_FINGER 10 216 - 217 213 struct mxt_info { 218 214 u8 family_id; 219 215 u8 variant_id; ··· 225 225 struct mxt_object { 226 226 u8 type; 227 227 u16 start_address; 228 - u8 size; 229 - u8 instances; 228 + u8 size; /* Size of each instance - 1 */ 229 + u8 instances; /* Number of instances - 1 */ 230 230 u8 num_report_ids; 231 - 232 - /* to map object and message */ 233 - u8 max_reportid; 234 - }; 231 + } __packed; 235 232 236 233 struct mxt_message { 237 234 u8 reportid; 238 235 u8 message[7]; 239 236 }; 240 237 241 - struct mxt_finger { 242 - int status; 243 - int x; 244 - int y; 245 - int area; 246 - int pressure; 247 - }; 248 - 249 238 /* Each client has this additional data */ 250 239 struct mxt_data { 251 240 struct i2c_client *client; 252 241 struct input_dev *input_dev; 242 + char phys[64]; /* device physical location */ 253 243 const struct mxt_platform_data *pdata; 254 244 struct mxt_object *object_table; 255 245 struct mxt_info info; 256 - struct mxt_finger finger[MXT_MAX_FINGER]; 257 246 unsigned int irq; 258 247 unsigned int max_x; 259 248 unsigned int max_y; 249 + 250 + /* Cached parameters from object table */ 251 + u8 T6_reportid; 252 + u8 T9_reportid_min; 253 + u8 T9_reportid_max; 260 254 }; 261 255 262 256 static bool mxt_object_readable(unsigned int type) 263 257 { 264 258 switch (type) { 265 - case MXT_GEN_MESSAGE_T5: 266 259 case MXT_GEN_COMMAND_T6: 267 260 case MXT_GEN_POWER_T7: 268 261 case MXT_GEN_ACQUIRE_T8: ··· 389 396 { 390 397 struct i2c_msg xfer[2]; 391 398 u8 buf[2]; 399 + int ret; 392 400 393 401 buf[0] = reg & 0xff; 394 402 buf[1] = (reg >> 8) & 0xff; ··· 406 412 xfer[1].len = len; 407 413 xfer[1].buf = val; 408 414 409 - if (i2c_transfer(client->adapter, xfer, 2) != 2) { 410 - dev_err(&client->dev, "%s: i2c transfer failed\n", __func__); 411 - return -EIO; 415 + ret = i2c_transfer(client->adapter, xfer, 2); 416 + if (ret == 2) { 417 + ret = 0; 418 + } else { 419 + if (ret >= 0) 420 + ret = -EIO; 421 + dev_err(&client->dev, "%s: i2c transfer failed (%d)\n", 422 + __func__, ret); 412 423 } 413 424 414 - return 0; 425 + return ret; 415 426 } 416 427 417 428 static int mxt_read_reg(struct i2c_client *client, u16 reg, u8 *val) ··· 424 425 return __mxt_read_reg(client, reg, 1, val); 425 426 } 426 427 427 - static int mxt_write_reg(struct i2c_client *client, u16 reg, u8 val) 428 + static int __mxt_write_reg(struct i2c_client *client, u16 reg, u16 len, 429 + const void *val) 428 430 { 429 - u8 buf[3]; 431 + u8 *buf; 432 + size_t count; 433 + int ret; 434 + 435 + count = len + 2; 436 + buf = kmalloc(count, GFP_KERNEL); 437 + if (!buf) 438 + return -ENOMEM; 430 439 431 440 buf[0] = reg & 0xff; 432 441 buf[1] = (reg >> 8) & 0xff; 433 - buf[2] = val; 442 + memcpy(&buf[2], val, len); 434 443 435 - if (i2c_master_send(client, buf, 3) != 3) { 436 - dev_err(&client->dev, "%s: i2c send failed\n", __func__); 437 - return -EIO; 444 + ret = i2c_master_send(client, buf, count); 445 + if (ret == count) { 446 + ret = 0; 447 + } else { 448 + if (ret >= 0) 449 + ret = -EIO; 450 + dev_err(&client->dev, "%s: i2c send failed (%d)\n", 451 + __func__, ret); 438 452 } 439 453 440 - return 0; 454 + kfree(buf); 455 + return ret; 441 456 } 442 457 443 - static int mxt_read_object_table(struct i2c_client *client, 444 - u16 reg, u8 *object_buf) 458 + static int mxt_write_reg(struct i2c_client *client, u16 reg, u8 val) 445 459 { 446 - return __mxt_read_reg(client, reg, MXT_OBJECT_SIZE, 447 - object_buf); 460 + return __mxt_write_reg(client, reg, 1, &val); 448 461 } 449 462 450 463 static struct mxt_object * ··· 490 479 sizeof(struct mxt_message), message); 491 480 } 492 481 493 - static int mxt_read_object(struct mxt_data *data, 494 - u8 type, u8 offset, u8 *val) 495 - { 496 - struct mxt_object *object; 497 - u16 reg; 498 - 499 - object = mxt_get_object(data, type); 500 - if (!object) 501 - return -EINVAL; 502 - 503 - reg = object->start_address; 504 - return __mxt_read_reg(data->client, reg + offset, 1, val); 505 - } 506 - 507 482 static int mxt_write_object(struct mxt_data *data, 508 483 u8 type, u8 offset, u8 val) 509 484 { ··· 504 507 return mxt_write_reg(data->client, reg + offset, val); 505 508 } 506 509 507 - static void mxt_input_report(struct mxt_data *data, int single_id) 508 - { 509 - struct mxt_finger *finger = data->finger; 510 - struct input_dev *input_dev = data->input_dev; 511 - int status = finger[single_id].status; 512 - int finger_num = 0; 513 - int id; 514 - 515 - for (id = 0; id < MXT_MAX_FINGER; id++) { 516 - if (!finger[id].status) 517 - continue; 518 - 519 - input_mt_slot(input_dev, id); 520 - input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, 521 - finger[id].status != MXT_RELEASE); 522 - 523 - if (finger[id].status != MXT_RELEASE) { 524 - finger_num++; 525 - input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, 526 - finger[id].area); 527 - input_report_abs(input_dev, ABS_MT_POSITION_X, 528 - finger[id].x); 529 - input_report_abs(input_dev, ABS_MT_POSITION_Y, 530 - finger[id].y); 531 - input_report_abs(input_dev, ABS_MT_PRESSURE, 532 - finger[id].pressure); 533 - } else { 534 - finger[id].status = 0; 535 - } 536 - } 537 - 538 - input_report_key(input_dev, BTN_TOUCH, finger_num > 0); 539 - 540 - if (status != MXT_RELEASE) { 541 - input_report_abs(input_dev, ABS_X, finger[single_id].x); 542 - input_report_abs(input_dev, ABS_Y, finger[single_id].y); 543 - input_report_abs(input_dev, 544 - ABS_PRESSURE, finger[single_id].pressure); 545 - } 546 - 547 - input_sync(input_dev); 548 - } 549 - 550 510 static void mxt_input_touchevent(struct mxt_data *data, 551 511 struct mxt_message *message, int id) 552 512 { 553 - struct mxt_finger *finger = data->finger; 554 513 struct device *dev = &data->client->dev; 555 514 u8 status = message->message[0]; 515 + struct input_dev *input_dev = data->input_dev; 556 516 int x; 557 517 int y; 558 518 int area; 559 519 int pressure; 560 - 561 - /* Check the touch is present on the screen */ 562 - if (!(status & MXT_DETECT)) { 563 - if (status & MXT_RELEASE) { 564 - dev_dbg(dev, "[%d] released\n", id); 565 - 566 - finger[id].status = MXT_RELEASE; 567 - mxt_input_report(data, id); 568 - } 569 - return; 570 - } 571 - 572 - /* Check only AMP detection */ 573 - if (!(status & (MXT_PRESS | MXT_MOVE))) 574 - return; 575 520 576 521 x = (message->message[1] << 4) | ((message->message[3] >> 4) & 0xf); 577 522 y = (message->message[2] << 4) | ((message->message[3] & 0xf)); ··· 525 586 area = message->message[4]; 526 587 pressure = message->message[5]; 527 588 528 - dev_dbg(dev, "[%d] %s x: %d, y: %d, area: %d\n", id, 529 - status & MXT_MOVE ? "moved" : "pressed", 530 - x, y, area); 589 + dev_dbg(dev, 590 + "[%u] %c%c%c%c%c%c%c%c x: %5u y: %5u area: %3u amp: %3u\n", 591 + id, 592 + (status & MXT_DETECT) ? 'D' : '.', 593 + (status & MXT_PRESS) ? 'P' : '.', 594 + (status & MXT_RELEASE) ? 'R' : '.', 595 + (status & MXT_MOVE) ? 'M' : '.', 596 + (status & MXT_VECTOR) ? 'V' : '.', 597 + (status & MXT_AMP) ? 'A' : '.', 598 + (status & MXT_SUPPRESS) ? 'S' : '.', 599 + (status & MXT_UNGRIP) ? 'U' : '.', 600 + x, y, area, pressure); 531 601 532 - finger[id].status = status & MXT_MOVE ? 533 - MXT_MOVE : MXT_PRESS; 534 - finger[id].x = x; 535 - finger[id].y = y; 536 - finger[id].area = area; 537 - finger[id].pressure = pressure; 602 + input_mt_slot(input_dev, id); 603 + input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, 604 + status & MXT_DETECT); 538 605 539 - mxt_input_report(data, id); 606 + if (status & MXT_DETECT) { 607 + input_report_abs(input_dev, ABS_MT_POSITION_X, x); 608 + input_report_abs(input_dev, ABS_MT_POSITION_Y, y); 609 + input_report_abs(input_dev, ABS_MT_PRESSURE, pressure); 610 + input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, area); 611 + } 612 + } 613 + 614 + static unsigned mxt_extract_T6_csum(const u8 *csum) 615 + { 616 + return csum[0] | (csum[1] << 8) | (csum[2] << 16); 617 + } 618 + 619 + static bool mxt_is_T9_message(struct mxt_data *data, struct mxt_message *msg) 620 + { 621 + u8 id = msg->reportid; 622 + return (id >= data->T9_reportid_min && id <= data->T9_reportid_max); 540 623 } 541 624 542 625 static irqreturn_t mxt_interrupt(int irq, void *dev_id) 543 626 { 544 627 struct mxt_data *data = dev_id; 545 628 struct mxt_message message; 546 - struct mxt_object *object; 629 + const u8 *payload = &message.message[0]; 547 630 struct device *dev = &data->client->dev; 548 - int id; 549 631 u8 reportid; 550 - u8 max_reportid; 551 - u8 min_reportid; 632 + bool update_input = false; 552 633 553 634 do { 554 635 if (mxt_read_message(data, &message)) { ··· 578 619 579 620 reportid = message.reportid; 580 621 581 - /* whether reportid is thing of MXT_TOUCH_MULTI_T9 */ 582 - object = mxt_get_object(data, MXT_TOUCH_MULTI_T9); 583 - if (!object) 584 - goto end; 585 - 586 - max_reportid = object->max_reportid; 587 - min_reportid = max_reportid - object->num_report_ids + 1; 588 - id = reportid - min_reportid; 589 - 590 - if (reportid >= min_reportid && reportid <= max_reportid) 622 + if (reportid == data->T6_reportid) { 623 + u8 status = payload[0]; 624 + unsigned csum = mxt_extract_T6_csum(&payload[1]); 625 + dev_dbg(dev, "Status: %02x Config Checksum: %06x\n", 626 + status, csum); 627 + } else if (mxt_is_T9_message(data, &message)) { 628 + int id = reportid - data->T9_reportid_min; 591 629 mxt_input_touchevent(data, &message, id); 592 - else 630 + update_input = true; 631 + } else { 593 632 mxt_dump_message(dev, &message); 633 + } 594 634 } while (reportid != 0xff); 635 + 636 + if (update_input) { 637 + input_mt_report_pointer_emulation(data->input_dev, false); 638 + input_sync(data->input_dev); 639 + } 595 640 596 641 end: 597 642 return IRQ_HANDLED; ··· 607 644 struct mxt_object *object; 608 645 struct device *dev = &data->client->dev; 609 646 int index = 0; 610 - int i, j, config_offset; 647 + int i, size; 648 + int ret; 611 649 612 650 if (!pdata->config) { 613 651 dev_dbg(dev, "No cfg data defined, skipping reg init\n"); ··· 621 657 if (!mxt_object_writable(object->type)) 622 658 continue; 623 659 624 - for (j = 0; 625 - j < (object->size + 1) * (object->instances + 1); 626 - j++) { 627 - config_offset = index + j; 628 - if (config_offset > pdata->config_length) { 629 - dev_err(dev, "Not enough config data!\n"); 630 - return -EINVAL; 631 - } 632 - mxt_write_object(data, object->type, j, 633 - pdata->config[config_offset]); 660 + size = (object->size + 1) * (object->instances + 1); 661 + if (index + size > pdata->config_length) { 662 + dev_err(dev, "Not enough config data!\n"); 663 + return -EINVAL; 634 664 } 635 - index += (object->size + 1) * (object->instances + 1); 665 + 666 + ret = __mxt_write_reg(data->client, object->start_address, 667 + size, &pdata->config[index]); 668 + if (ret) 669 + return ret; 670 + index += size; 636 671 } 637 672 638 673 return 0; ··· 712 749 struct i2c_client *client = data->client; 713 750 struct mxt_info *info = &data->info; 714 751 int error; 715 - u8 val; 716 752 717 - error = mxt_read_reg(client, MXT_FAMILY_ID, &val); 753 + /* Read 7-byte info block starting at address 0 */ 754 + error = __mxt_read_reg(client, MXT_INFO, sizeof(*info), info); 718 755 if (error) 719 756 return error; 720 - info->family_id = val; 721 - 722 - error = mxt_read_reg(client, MXT_VARIANT_ID, &val); 723 - if (error) 724 - return error; 725 - info->variant_id = val; 726 - 727 - error = mxt_read_reg(client, MXT_VERSION, &val); 728 - if (error) 729 - return error; 730 - info->version = val; 731 - 732 - error = mxt_read_reg(client, MXT_BUILD, &val); 733 - if (error) 734 - return error; 735 - info->build = val; 736 - 737 - error = mxt_read_reg(client, MXT_OBJECT_NUM, &val); 738 - if (error) 739 - return error; 740 - info->object_num = val; 741 757 742 758 return 0; 743 759 } 744 760 745 761 static int mxt_get_object_table(struct mxt_data *data) 746 762 { 763 + struct i2c_client *client = data->client; 764 + size_t table_size; 747 765 int error; 748 766 int i; 749 - u16 reg; 750 - u8 reportid = 0; 751 - u8 buf[MXT_OBJECT_SIZE]; 767 + u8 reportid; 752 768 769 + table_size = data->info.object_num * sizeof(struct mxt_object); 770 + error = __mxt_read_reg(client, MXT_OBJECT_START, table_size, 771 + data->object_table); 772 + if (error) 773 + return error; 774 + 775 + /* Valid Report IDs start counting from 1 */ 776 + reportid = 1; 753 777 for (i = 0; i < data->info.object_num; i++) { 754 778 struct mxt_object *object = data->object_table + i; 779 + u8 min_id, max_id; 755 780 756 - reg = MXT_OBJECT_START + MXT_OBJECT_SIZE * i; 757 - error = mxt_read_object_table(data->client, reg, buf); 758 - if (error) 759 - return error; 760 - 761 - object->type = buf[0]; 762 - object->start_address = (buf[2] << 8) | buf[1]; 763 - object->size = buf[3]; 764 - object->instances = buf[4]; 765 - object->num_report_ids = buf[5]; 781 + le16_to_cpus(&object->start_address); 766 782 767 783 if (object->num_report_ids) { 784 + min_id = reportid; 768 785 reportid += object->num_report_ids * 769 786 (object->instances + 1); 770 - object->max_reportid = reportid; 787 + max_id = reportid - 1; 788 + } else { 789 + min_id = 0; 790 + max_id = 0; 791 + } 792 + 793 + dev_dbg(&data->client->dev, 794 + "Type %2d Start %3d Size %3d Instances %2d ReportIDs %3u : %3u\n", 795 + object->type, object->start_address, object->size + 1, 796 + object->instances + 1, min_id, max_id); 797 + 798 + switch (object->type) { 799 + case MXT_GEN_COMMAND_T6: 800 + data->T6_reportid = min_id; 801 + break; 802 + case MXT_TOUCH_MULTI_T9: 803 + data->T9_reportid_min = min_id; 804 + data->T9_reportid_max = max_id; 805 + break; 771 806 } 772 807 } 773 808 774 809 return 0; 810 + } 811 + 812 + static void mxt_free_object_table(struct mxt_data *data) 813 + { 814 + kfree(data->object_table); 815 + data->object_table = NULL; 816 + data->T6_reportid = 0; 817 + data->T9_reportid_min = 0; 818 + data->T9_reportid_max = 0; 819 + 775 820 } 776 821 777 822 static int mxt_initialize(struct mxt_data *data) ··· 804 833 /* Get object table information */ 805 834 error = mxt_get_object_table(data); 806 835 if (error) 807 - return error; 836 + goto err_free_object_table; 808 837 809 838 /* Check register init values */ 810 839 error = mxt_check_reg_init(data); 811 840 if (error) 812 - return error; 841 + goto err_free_object_table; 813 842 814 843 mxt_handle_pdata(data); 815 844 ··· 827 856 /* Update matrix size at info struct */ 828 857 error = mxt_read_reg(client, MXT_MATRIX_X_SIZE, &val); 829 858 if (error) 830 - return error; 859 + goto err_free_object_table; 831 860 info->matrix_xsize = val; 832 861 833 862 error = mxt_read_reg(client, MXT_MATRIX_Y_SIZE, &val); 834 863 if (error) 835 - return error; 864 + goto err_free_object_table; 836 865 info->matrix_ysize = val; 837 866 838 867 dev_info(&client->dev, 839 - "Family ID: %d Variant ID: %d Version: %d Build: %d\n", 840 - info->family_id, info->variant_id, info->version, 841 - info->build); 868 + "Family ID: %u Variant ID: %u Major.Minor.Build: %u.%u.%02X\n", 869 + info->family_id, info->variant_id, info->version >> 4, 870 + info->version & 0xf, info->build); 842 871 843 872 dev_info(&client->dev, 844 - "Matrix X Size: %d Matrix Y Size: %d Object Num: %d\n", 873 + "Matrix X Size: %u Matrix Y Size: %u Object Num: %u\n", 845 874 info->matrix_xsize, info->matrix_ysize, 846 875 info->object_num); 847 876 848 877 return 0; 878 + 879 + err_free_object_table: 880 + mxt_free_object_table(data); 881 + return error; 849 882 } 850 883 851 884 static void mxt_calc_resolution(struct mxt_data *data) ··· 866 891 } 867 892 } 868 893 894 + /* Firmware Version is returned as Major.Minor.Build */ 895 + static ssize_t mxt_fw_version_show(struct device *dev, 896 + struct device_attribute *attr, char *buf) 897 + { 898 + struct mxt_data *data = dev_get_drvdata(dev); 899 + struct mxt_info *info = &data->info; 900 + return scnprintf(buf, PAGE_SIZE, "%u.%u.%02X\n", 901 + info->version >> 4, info->version & 0xf, info->build); 902 + } 903 + 904 + /* Hardware Version is returned as FamilyID.VariantID */ 905 + static ssize_t mxt_hw_version_show(struct device *dev, 906 + struct device_attribute *attr, char *buf) 907 + { 908 + struct mxt_data *data = dev_get_drvdata(dev); 909 + struct mxt_info *info = &data->info; 910 + return scnprintf(buf, PAGE_SIZE, "%u.%u\n", 911 + info->family_id, info->variant_id); 912 + } 913 + 914 + static ssize_t mxt_show_instance(char *buf, int count, 915 + struct mxt_object *object, int instance, 916 + const u8 *val) 917 + { 918 + int i; 919 + 920 + if (object->instances > 0) 921 + count += scnprintf(buf + count, PAGE_SIZE - count, 922 + "Instance %u\n", instance); 923 + 924 + for (i = 0; i < object->size + 1; i++) 925 + count += scnprintf(buf + count, PAGE_SIZE - count, 926 + "\t[%2u]: %02x (%d)\n", i, val[i], val[i]); 927 + count += scnprintf(buf + count, PAGE_SIZE - count, "\n"); 928 + 929 + return count; 930 + } 931 + 869 932 static ssize_t mxt_object_show(struct device *dev, 870 933 struct device_attribute *attr, char *buf) 871 934 { ··· 912 899 int count = 0; 913 900 int i, j; 914 901 int error; 915 - u8 val; 902 + u8 *obuf; 916 903 904 + /* Pre-allocate buffer large enough to hold max sized object. */ 905 + obuf = kmalloc(256, GFP_KERNEL); 906 + if (!obuf) 907 + return -ENOMEM; 908 + 909 + error = 0; 917 910 for (i = 0; i < data->info.object_num; i++) { 918 911 object = data->object_table + i; 919 912 920 - count += snprintf(buf + count, PAGE_SIZE - count, 921 - "Object[%d] (Type %d)\n", 922 - i + 1, object->type); 923 - if (count >= PAGE_SIZE) 924 - return PAGE_SIZE - 1; 925 - 926 - if (!mxt_object_readable(object->type)) { 927 - count += snprintf(buf + count, PAGE_SIZE - count, 928 - "\n"); 929 - if (count >= PAGE_SIZE) 930 - return PAGE_SIZE - 1; 913 + if (!mxt_object_readable(object->type)) 931 914 continue; 932 - } 933 915 934 - for (j = 0; j < object->size + 1; j++) { 935 - error = mxt_read_object(data, 936 - object->type, j, &val); 916 + count += scnprintf(buf + count, PAGE_SIZE - count, 917 + "T%u:\n", object->type); 918 + 919 + for (j = 0; j < object->instances + 1; j++) { 920 + u16 size = object->size + 1; 921 + u16 addr = object->start_address + j * size; 922 + 923 + error = __mxt_read_reg(data->client, addr, size, obuf); 937 924 if (error) 938 - return error; 925 + goto done; 939 926 940 - count += snprintf(buf + count, PAGE_SIZE - count, 941 - "\t[%2d]: %02x (%d)\n", j, val, val); 942 - if (count >= PAGE_SIZE) 943 - return PAGE_SIZE - 1; 927 + count = mxt_show_instance(buf, count, object, j, obuf); 944 928 } 945 - 946 - count += snprintf(buf + count, PAGE_SIZE - count, "\n"); 947 - if (count >= PAGE_SIZE) 948 - return PAGE_SIZE - 1; 949 929 } 950 930 951 - return count; 931 + done: 932 + kfree(obuf); 933 + return error ?: count; 952 934 } 953 935 954 936 static int mxt_load_fw(struct device *dev, const char *fn) ··· 1036 1028 /* Wait for reset */ 1037 1029 msleep(MXT_FWRESET_TIME); 1038 1030 1039 - kfree(data->object_table); 1040 - data->object_table = NULL; 1031 + mxt_free_object_table(data); 1041 1032 1042 1033 mxt_initialize(data); 1043 1034 } ··· 1050 1043 return count; 1051 1044 } 1052 1045 1046 + static DEVICE_ATTR(fw_version, S_IRUGO, mxt_fw_version_show, NULL); 1047 + static DEVICE_ATTR(hw_version, S_IRUGO, mxt_hw_version_show, NULL); 1053 1048 static DEVICE_ATTR(object, S_IRUGO, mxt_object_show, NULL); 1054 1049 static DEVICE_ATTR(update_fw, S_IWUSR, NULL, mxt_update_fw_store); 1055 1050 1056 1051 static struct attribute *mxt_attrs[] = { 1052 + &dev_attr_fw_version.attr, 1053 + &dev_attr_hw_version.attr, 1057 1054 &dev_attr_object.attr, 1058 1055 &dev_attr_update_fw.attr, 1059 1056 NULL ··· 1104 1093 struct mxt_data *data; 1105 1094 struct input_dev *input_dev; 1106 1095 int error; 1096 + unsigned int num_mt_slots; 1107 1097 1108 1098 if (!pdata) 1109 1099 return -EINVAL; ··· 1118 1106 } 1119 1107 1120 1108 input_dev->name = "Atmel maXTouch Touchscreen"; 1109 + snprintf(data->phys, sizeof(data->phys), "i2c-%u-%04x/input0", 1110 + client->adapter->nr, client->addr); 1111 + input_dev->phys = data->phys; 1112 + 1121 1113 input_dev->id.bustype = BUS_I2C; 1122 1114 input_dev->dev.parent = &client->dev; 1123 1115 input_dev->open = mxt_input_open; ··· 1133 1117 data->irq = client->irq; 1134 1118 1135 1119 mxt_calc_resolution(data); 1120 + 1121 + error = mxt_initialize(data); 1122 + if (error) 1123 + goto err_free_mem; 1136 1124 1137 1125 __set_bit(EV_ABS, input_dev->evbit); 1138 1126 __set_bit(EV_KEY, input_dev->evbit); ··· 1151 1131 0, 255, 0, 0); 1152 1132 1153 1133 /* For multi touch */ 1154 - input_mt_init_slots(input_dev, MXT_MAX_FINGER); 1134 + num_mt_slots = data->T9_reportid_max - data->T9_reportid_min + 1; 1135 + error = input_mt_init_slots(input_dev, num_mt_slots); 1136 + if (error) 1137 + goto err_free_object; 1155 1138 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 1156 1139 0, MXT_MAX_AREA, 0, 0); 1157 1140 input_set_abs_params(input_dev, ABS_MT_POSITION_X, ··· 1167 1144 input_set_drvdata(input_dev, data); 1168 1145 i2c_set_clientdata(client, data); 1169 1146 1170 - error = mxt_initialize(data); 1171 - if (error) 1172 - goto err_free_object; 1173 - 1174 1147 error = request_threaded_irq(client->irq, NULL, mxt_interrupt, 1175 1148 pdata->irqflags | IRQF_ONESHOT, 1176 - client->dev.driver->name, data); 1149 + client->name, data); 1177 1150 if (error) { 1178 1151 dev_err(&client->dev, "Failed to register interrupt\n"); 1179 1152 goto err_free_object;
+544
drivers/input/touchscreen/mms114.c
··· 1 + /* 2 + * Copyright (C) 2012 Samsung Electronics Co.Ltd 3 + * Author: Joonyoung Shim <jy0922.shim@samsung.com> 4 + * 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License version 2 as 7 + * published by the Free Software Foundation. 8 + */ 9 + 10 + #include <linux/module.h> 11 + #include <linux/init.h> 12 + #include <linux/delay.h> 13 + #include <linux/i2c.h> 14 + #include <linux/i2c/mms114.h> 15 + #include <linux/input/mt.h> 16 + #include <linux/interrupt.h> 17 + #include <linux/regulator/consumer.h> 18 + #include <linux/slab.h> 19 + 20 + /* Write only registers */ 21 + #define MMS114_MODE_CONTROL 0x01 22 + #define MMS114_OPERATION_MODE_MASK 0xE 23 + #define MMS114_ACTIVE (1 << 1) 24 + 25 + #define MMS114_XY_RESOLUTION_H 0x02 26 + #define MMS114_X_RESOLUTION 0x03 27 + #define MMS114_Y_RESOLUTION 0x04 28 + #define MMS114_CONTACT_THRESHOLD 0x05 29 + #define MMS114_MOVING_THRESHOLD 0x06 30 + 31 + /* Read only registers */ 32 + #define MMS114_PACKET_SIZE 0x0F 33 + #define MMS114_INFOMATION 0x10 34 + #define MMS114_TSP_REV 0xF0 35 + 36 + /* Minimum delay time is 50us between stop and start signal of i2c */ 37 + #define MMS114_I2C_DELAY 50 38 + 39 + /* 200ms needs after power on */ 40 + #define MMS114_POWERON_DELAY 200 41 + 42 + /* Touchscreen absolute values */ 43 + #define MMS114_MAX_AREA 0xff 44 + 45 + #define MMS114_MAX_TOUCH 10 46 + #define MMS114_PACKET_NUM 8 47 + 48 + /* Touch type */ 49 + #define MMS114_TYPE_NONE 0 50 + #define MMS114_TYPE_TOUCHSCREEN 1 51 + #define MMS114_TYPE_TOUCHKEY 2 52 + 53 + struct mms114_data { 54 + struct i2c_client *client; 55 + struct input_dev *input_dev; 56 + struct regulator *core_reg; 57 + struct regulator *io_reg; 58 + const struct mms114_platform_data *pdata; 59 + 60 + /* Use cache data for mode control register(write only) */ 61 + u8 cache_mode_control; 62 + }; 63 + 64 + struct mms114_touch { 65 + u8 id:4, reserved_bit4:1, type:2, pressed:1; 66 + u8 x_hi:4, y_hi:4; 67 + u8 x_lo; 68 + u8 y_lo; 69 + u8 width; 70 + u8 strength; 71 + u8 reserved[2]; 72 + } __packed; 73 + 74 + static int __mms114_read_reg(struct mms114_data *data, unsigned int reg, 75 + unsigned int len, u8 *val) 76 + { 77 + struct i2c_client *client = data->client; 78 + struct i2c_msg xfer[2]; 79 + u8 buf = reg & 0xff; 80 + int error; 81 + 82 + if (reg <= MMS114_MODE_CONTROL && reg + len > MMS114_MODE_CONTROL) 83 + BUG(); 84 + 85 + /* Write register: use repeated start */ 86 + xfer[0].addr = client->addr; 87 + xfer[0].flags = I2C_M_TEN | I2C_M_NOSTART; 88 + xfer[0].len = 1; 89 + xfer[0].buf = &buf; 90 + 91 + /* Read data */ 92 + xfer[1].addr = client->addr; 93 + xfer[1].flags = I2C_M_RD; 94 + xfer[1].len = len; 95 + xfer[1].buf = val; 96 + 97 + error = i2c_transfer(client->adapter, xfer, 2); 98 + if (error != 2) { 99 + dev_err(&client->dev, 100 + "%s: i2c transfer failed (%d)\n", __func__, error); 101 + return error < 0 ? error : -EIO; 102 + } 103 + udelay(MMS114_I2C_DELAY); 104 + 105 + return 0; 106 + } 107 + 108 + static int mms114_read_reg(struct mms114_data *data, unsigned int reg) 109 + { 110 + u8 val; 111 + int error; 112 + 113 + if (reg == MMS114_MODE_CONTROL) 114 + return data->cache_mode_control; 115 + 116 + error = __mms114_read_reg(data, reg, 1, &val); 117 + return error < 0 ? error : val; 118 + } 119 + 120 + static int mms114_write_reg(struct mms114_data *data, unsigned int reg, 121 + unsigned int val) 122 + { 123 + struct i2c_client *client = data->client; 124 + u8 buf[2]; 125 + int error; 126 + 127 + buf[0] = reg & 0xff; 128 + buf[1] = val & 0xff; 129 + 130 + error = i2c_master_send(client, buf, 2); 131 + if (error != 2) { 132 + dev_err(&client->dev, 133 + "%s: i2c send failed (%d)\n", __func__, error); 134 + return error < 0 ? error : -EIO; 135 + } 136 + udelay(MMS114_I2C_DELAY); 137 + 138 + if (reg == MMS114_MODE_CONTROL) 139 + data->cache_mode_control = val; 140 + 141 + return 0; 142 + } 143 + 144 + static void mms114_process_mt(struct mms114_data *data, struct mms114_touch *touch) 145 + { 146 + const struct mms114_platform_data *pdata = data->pdata; 147 + struct i2c_client *client = data->client; 148 + struct input_dev *input_dev = data->input_dev; 149 + unsigned int id; 150 + unsigned int x; 151 + unsigned int y; 152 + 153 + if (touch->id > MMS114_MAX_TOUCH) { 154 + dev_err(&client->dev, "Wrong touch id (%d)\n", touch->id); 155 + return; 156 + } 157 + 158 + if (touch->type != MMS114_TYPE_TOUCHSCREEN) { 159 + dev_err(&client->dev, "Wrong touch type (%d)\n", touch->type); 160 + return; 161 + } 162 + 163 + id = touch->id - 1; 164 + x = touch->x_lo | touch->x_hi << 8; 165 + y = touch->y_lo | touch->y_hi << 8; 166 + if (x > pdata->x_size || y > pdata->y_size) { 167 + dev_dbg(&client->dev, 168 + "Wrong touch coordinates (%d, %d)\n", x, y); 169 + return; 170 + } 171 + 172 + if (pdata->x_invert) 173 + x = pdata->x_size - x; 174 + if (pdata->y_invert) 175 + y = pdata->y_size - y; 176 + 177 + dev_dbg(&client->dev, 178 + "id: %d, type: %d, pressed: %d, x: %d, y: %d, width: %d, strength: %d\n", 179 + id, touch->type, touch->pressed, 180 + x, y, touch->width, touch->strength); 181 + 182 + input_mt_slot(input_dev, id); 183 + input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, touch->pressed); 184 + 185 + if (touch->pressed) { 186 + input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, touch->width); 187 + input_report_abs(input_dev, ABS_MT_POSITION_X, x); 188 + input_report_abs(input_dev, ABS_MT_POSITION_Y, y); 189 + input_report_abs(input_dev, ABS_MT_PRESSURE, touch->strength); 190 + } 191 + } 192 + 193 + static irqreturn_t mms114_interrupt(int irq, void *dev_id) 194 + { 195 + struct mms114_data *data = dev_id; 196 + struct input_dev *input_dev = data->input_dev; 197 + struct mms114_touch touch[MMS114_MAX_TOUCH]; 198 + int packet_size; 199 + int touch_size; 200 + int index; 201 + int error; 202 + 203 + mutex_lock(&input_dev->mutex); 204 + if (!input_dev->users) { 205 + mutex_unlock(&input_dev->mutex); 206 + goto out; 207 + } 208 + mutex_unlock(&input_dev->mutex); 209 + 210 + packet_size = mms114_read_reg(data, MMS114_PACKET_SIZE); 211 + if (packet_size <= 0) 212 + goto out; 213 + 214 + touch_size = packet_size / MMS114_PACKET_NUM; 215 + 216 + error = __mms114_read_reg(data, MMS114_INFOMATION, packet_size, 217 + (u8 *)touch); 218 + if (error < 0) 219 + goto out; 220 + 221 + for (index = 0; index < touch_size; index++) 222 + mms114_process_mt(data, touch + index); 223 + 224 + input_mt_report_pointer_emulation(data->input_dev, true); 225 + input_sync(data->input_dev); 226 + 227 + out: 228 + return IRQ_HANDLED; 229 + } 230 + 231 + static int mms114_set_active(struct mms114_data *data, bool active) 232 + { 233 + int val; 234 + 235 + val = mms114_read_reg(data, MMS114_MODE_CONTROL); 236 + if (val < 0) 237 + return val; 238 + 239 + val &= ~MMS114_OPERATION_MODE_MASK; 240 + 241 + /* If active is false, sleep mode */ 242 + if (active) 243 + val |= MMS114_ACTIVE; 244 + 245 + return mms114_write_reg(data, MMS114_MODE_CONTROL, val); 246 + } 247 + 248 + static int mms114_get_version(struct mms114_data *data) 249 + { 250 + struct device *dev = &data->client->dev; 251 + u8 buf[6]; 252 + int error; 253 + 254 + error = __mms114_read_reg(data, MMS114_TSP_REV, 6, buf); 255 + if (error < 0) 256 + return error; 257 + 258 + dev_info(dev, "TSP Rev: 0x%x, HW Rev: 0x%x, Firmware Ver: 0x%x\n", 259 + buf[0], buf[1], buf[3]); 260 + 261 + return 0; 262 + } 263 + 264 + static int mms114_setup_regs(struct mms114_data *data) 265 + { 266 + const struct mms114_platform_data *pdata = data->pdata; 267 + int val; 268 + int error; 269 + 270 + error = mms114_get_version(data); 271 + if (error < 0) 272 + return error; 273 + 274 + error = mms114_set_active(data, true); 275 + if (error < 0) 276 + return error; 277 + 278 + val = (pdata->x_size >> 8) & 0xf; 279 + val |= ((pdata->y_size >> 8) & 0xf) << 4; 280 + error = mms114_write_reg(data, MMS114_XY_RESOLUTION_H, val); 281 + if (error < 0) 282 + return error; 283 + 284 + val = pdata->x_size & 0xff; 285 + error = mms114_write_reg(data, MMS114_X_RESOLUTION, val); 286 + if (error < 0) 287 + return error; 288 + 289 + val = pdata->y_size & 0xff; 290 + error = mms114_write_reg(data, MMS114_Y_RESOLUTION, val); 291 + if (error < 0) 292 + return error; 293 + 294 + if (pdata->contact_threshold) { 295 + error = mms114_write_reg(data, MMS114_CONTACT_THRESHOLD, 296 + pdata->contact_threshold); 297 + if (error < 0) 298 + return error; 299 + } 300 + 301 + if (pdata->moving_threshold) { 302 + error = mms114_write_reg(data, MMS114_MOVING_THRESHOLD, 303 + pdata->moving_threshold); 304 + if (error < 0) 305 + return error; 306 + } 307 + 308 + return 0; 309 + } 310 + 311 + static int mms114_start(struct mms114_data *data) 312 + { 313 + struct i2c_client *client = data->client; 314 + int error; 315 + 316 + if (data->core_reg) 317 + regulator_enable(data->core_reg); 318 + if (data->io_reg) 319 + regulator_enable(data->io_reg); 320 + mdelay(MMS114_POWERON_DELAY); 321 + 322 + error = mms114_setup_regs(data); 323 + if (error < 0) 324 + return error; 325 + 326 + if (data->pdata->cfg_pin) 327 + data->pdata->cfg_pin(true); 328 + 329 + enable_irq(client->irq); 330 + 331 + return 0; 332 + } 333 + 334 + static void mms114_stop(struct mms114_data *data) 335 + { 336 + struct i2c_client *client = data->client; 337 + 338 + disable_irq(client->irq); 339 + 340 + if (data->pdata->cfg_pin) 341 + data->pdata->cfg_pin(false); 342 + 343 + if (data->io_reg) 344 + regulator_disable(data->io_reg); 345 + if (data->core_reg) 346 + regulator_disable(data->core_reg); 347 + } 348 + 349 + static int mms114_input_open(struct input_dev *dev) 350 + { 351 + struct mms114_data *data = input_get_drvdata(dev); 352 + 353 + return mms114_start(data); 354 + } 355 + 356 + static void mms114_input_close(struct input_dev *dev) 357 + { 358 + struct mms114_data *data = input_get_drvdata(dev); 359 + 360 + mms114_stop(data); 361 + } 362 + 363 + static int __devinit mms114_probe(struct i2c_client *client, 364 + const struct i2c_device_id *id) 365 + { 366 + struct mms114_data *data; 367 + struct input_dev *input_dev; 368 + int error; 369 + 370 + if (!client->dev.platform_data) { 371 + dev_err(&client->dev, "Need platform data\n"); 372 + return -EINVAL; 373 + } 374 + 375 + if (!i2c_check_functionality(client->adapter, 376 + I2C_FUNC_PROTOCOL_MANGLING)) { 377 + dev_err(&client->dev, 378 + "Need i2c bus that supports protocol mangling\n"); 379 + return -ENODEV; 380 + } 381 + 382 + data = kzalloc(sizeof(struct mms114_data), GFP_KERNEL); 383 + input_dev = input_allocate_device(); 384 + if (!data || !input_dev) { 385 + dev_err(&client->dev, "Failed to allocate memory\n"); 386 + error = -ENOMEM; 387 + goto err_free_mem; 388 + } 389 + 390 + data->client = client; 391 + data->input_dev = input_dev; 392 + data->pdata = client->dev.platform_data; 393 + 394 + input_dev->name = "MELPAS MMS114 Touchscreen"; 395 + input_dev->id.bustype = BUS_I2C; 396 + input_dev->dev.parent = &client->dev; 397 + input_dev->open = mms114_input_open; 398 + input_dev->close = mms114_input_close; 399 + 400 + __set_bit(EV_ABS, input_dev->evbit); 401 + __set_bit(EV_KEY, input_dev->evbit); 402 + __set_bit(BTN_TOUCH, input_dev->keybit); 403 + input_set_abs_params(input_dev, ABS_X, 0, data->pdata->x_size, 0, 0); 404 + input_set_abs_params(input_dev, ABS_Y, 0, data->pdata->y_size, 0, 0); 405 + 406 + /* For multi touch */ 407 + input_mt_init_slots(input_dev, MMS114_MAX_TOUCH); 408 + input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 409 + 0, MMS114_MAX_AREA, 0, 0); 410 + input_set_abs_params(input_dev, ABS_MT_POSITION_X, 411 + 0, data->pdata->x_size, 0, 0); 412 + input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 413 + 0, data->pdata->y_size, 0, 0); 414 + input_set_abs_params(input_dev, ABS_MT_PRESSURE, 0, 255, 0, 0); 415 + 416 + input_set_drvdata(input_dev, data); 417 + i2c_set_clientdata(client, data); 418 + 419 + data->core_reg = regulator_get(&client->dev, "avdd"); 420 + if (IS_ERR(data->core_reg)) { 421 + error = PTR_ERR(data->core_reg); 422 + dev_err(&client->dev, 423 + "Unable to get the Core regulator (%d)\n", error); 424 + goto err_free_mem; 425 + } 426 + 427 + data->io_reg = regulator_get(&client->dev, "vdd"); 428 + if (IS_ERR(data->io_reg)) { 429 + error = PTR_ERR(data->io_reg); 430 + dev_err(&client->dev, 431 + "Unable to get the IO regulator (%d)\n", error); 432 + goto err_core_reg; 433 + } 434 + 435 + error = request_threaded_irq(client->irq, NULL, mms114_interrupt, 436 + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "mms114", data); 437 + if (error) { 438 + dev_err(&client->dev, "Failed to register interrupt\n"); 439 + goto err_io_reg; 440 + } 441 + disable_irq(client->irq); 442 + 443 + error = input_register_device(data->input_dev); 444 + if (error) 445 + goto err_free_irq; 446 + 447 + return 0; 448 + 449 + err_free_irq: 450 + free_irq(client->irq, data); 451 + err_io_reg: 452 + regulator_put(data->io_reg); 453 + err_core_reg: 454 + regulator_put(data->core_reg); 455 + err_free_mem: 456 + input_free_device(input_dev); 457 + kfree(data); 458 + return error; 459 + } 460 + 461 + static int __devexit mms114_remove(struct i2c_client *client) 462 + { 463 + struct mms114_data *data = i2c_get_clientdata(client); 464 + 465 + free_irq(client->irq, data); 466 + regulator_put(data->io_reg); 467 + regulator_put(data->core_reg); 468 + input_unregister_device(data->input_dev); 469 + kfree(data); 470 + 471 + return 0; 472 + } 473 + 474 + #ifdef CONFIG_PM_SLEEP 475 + static int mms114_suspend(struct device *dev) 476 + { 477 + struct i2c_client *client = to_i2c_client(dev); 478 + struct mms114_data *data = i2c_get_clientdata(client); 479 + struct input_dev *input_dev = data->input_dev; 480 + int id; 481 + 482 + /* Release all touch */ 483 + for (id = 0; id < MMS114_MAX_TOUCH; id++) { 484 + input_mt_slot(input_dev, id); 485 + input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, false); 486 + } 487 + 488 + input_mt_report_pointer_emulation(input_dev, true); 489 + input_sync(input_dev); 490 + 491 + mutex_lock(&input_dev->mutex); 492 + if (input_dev->users) 493 + mms114_stop(data); 494 + mutex_unlock(&input_dev->mutex); 495 + 496 + return 0; 497 + } 498 + 499 + static int mms114_resume(struct device *dev) 500 + { 501 + struct i2c_client *client = to_i2c_client(dev); 502 + struct mms114_data *data = i2c_get_clientdata(client); 503 + struct input_dev *input_dev = data->input_dev; 504 + int error; 505 + 506 + mutex_lock(&input_dev->mutex); 507 + if (input_dev->users) { 508 + error = mms114_start(data); 509 + if (error < 0) { 510 + mutex_unlock(&input_dev->mutex); 511 + return error; 512 + } 513 + } 514 + mutex_unlock(&input_dev->mutex); 515 + 516 + return 0; 517 + } 518 + #endif 519 + 520 + static SIMPLE_DEV_PM_OPS(mms114_pm_ops, mms114_suspend, mms114_resume); 521 + 522 + static const struct i2c_device_id mms114_id[] = { 523 + { "mms114", 0 }, 524 + { } 525 + }; 526 + MODULE_DEVICE_TABLE(i2c, mms114_id); 527 + 528 + static struct i2c_driver mms114_driver = { 529 + .driver = { 530 + .name = "mms114", 531 + .owner = THIS_MODULE, 532 + .pm = &mms114_pm_ops, 533 + }, 534 + .probe = mms114_probe, 535 + .remove = __devexit_p(mms114_remove), 536 + .id_table = mms114_id, 537 + }; 538 + 539 + module_i2c_driver(mms114_driver); 540 + 541 + /* Module information */ 542 + MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>"); 543 + MODULE_DESCRIPTION("MELFAS mms114 Touchscreen driver"); 544 + MODULE_LICENSE("GPL");
+1 -1
drivers/input/touchscreen/wacom_i2c.c
··· 149 149 { 150 150 struct wacom_i2c *wac_i2c; 151 151 struct input_dev *input; 152 - struct wacom_features features; 152 + struct wacom_features features = { 0 }; 153 153 int error; 154 154 155 155 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+24
include/linux/i2c/mms114.h
··· 1 + /* 2 + * Copyright (C) 2012 Samsung Electronics Co.Ltd 3 + * Author: Joonyoung Shim <jy0922.shim@samsung.com> 4 + * 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License version 2 as 7 + * published by the Free Software Foundationr 8 + */ 9 + 10 + #ifndef __LINUX_MMS114_H 11 + #define __LINUX_MMS114_H 12 + 13 + struct mms114_platform_data { 14 + unsigned int x_size; 15 + unsigned int y_size; 16 + unsigned int contact_threshold; 17 + unsigned int moving_threshold; 18 + bool x_invert; 19 + bool y_invert; 20 + 21 + void (*cfg_pin)(bool); 22 + }; 23 + 24 + #endif /* __LINUX_MMS114_H */
+5 -3
include/linux/input.h
··· 807 807 #define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */ 808 808 #define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */ 809 809 #define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */ 810 - #define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */ 811 - #define ABS_MT_POSITION_Y 0x36 /* Center Y ellipse position */ 810 + #define ABS_MT_POSITION_X 0x35 /* Center X touch position */ 811 + #define ABS_MT_POSITION_Y 0x36 /* Center Y touch position */ 812 812 #define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */ 813 813 #define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */ 814 814 #define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */ 815 815 #define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */ 816 816 #define ABS_MT_DISTANCE 0x3b /* Contact hover distance */ 817 + #define ABS_MT_TOOL_X 0x3c /* Center X tool position */ 818 + #define ABS_MT_TOOL_Y 0x3d /* Center Y tool position */ 817 819 818 820 #ifdef __KERNEL__ 819 821 /* Implementation details, userspace should not care about these */ 820 822 #define ABS_MT_FIRST ABS_MT_TOUCH_MAJOR 821 - #define ABS_MT_LAST ABS_MT_DISTANCE 823 + #define ABS_MT_LAST ABS_MT_TOOL_Y 822 824 #endif 823 825 824 826 #define ABS_MAX 0x3f
+2
include/linux/spi/ad7879.h
··· 12 12 u16 y_min, y_max; 13 13 u16 pressure_min, pressure_max; 14 14 15 + bool swap_xy; /* swap x and y axes */ 16 + 15 17 /* [0..255] 0=OFF Starts at 1=550us and goes 16 18 * all the way to 9.440ms in steps of 35us. 17 19 */