diff options
Diffstat (limited to 'drivers/input')
36 files changed, 2832 insertions, 455 deletions
diff --git a/drivers/input/ff-memless.c b/drivers/input/ff-memless.c index 5f558851d646..b107922514fb 100644 --- a/drivers/input/ff-memless.c +++ b/drivers/input/ff-memless.c | |||
@@ -176,7 +176,7 @@ static int apply_envelope(struct ml_effect_state *state, int value, | |||
176 | value, envelope->attack_level); | 176 | value, envelope->attack_level); |
177 | time_from_level = jiffies_to_msecs(now - state->play_at); | 177 | time_from_level = jiffies_to_msecs(now - state->play_at); |
178 | time_of_envelope = envelope->attack_length; | 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 | } else if (envelope->fade_length && effect->replay.length && | 181 | } else if (envelope->fade_length && effect->replay.length && |
182 | time_after(now, | 182 | time_after(now, |
@@ -184,7 +184,7 @@ static int apply_envelope(struct ml_effect_state *state, int value, | |||
184 | time_before(now, state->stop_at)) { | 184 | time_before(now, state->stop_at)) { |
185 | time_from_level = jiffies_to_msecs(state->stop_at - now); | 185 | time_from_level = jiffies_to_msecs(state->stop_at - now); |
186 | time_of_envelope = envelope->fade_length; | 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 | } else | 188 | } else |
189 | return value; | 189 | return value; |
190 | 190 | ||
diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c index f658086fbbe0..70a16c7da8cc 100644 --- a/drivers/input/input-mt.c +++ b/drivers/input/input-mt.c | |||
@@ -135,7 +135,7 @@ EXPORT_SYMBOL(input_mt_report_finger_count); | |||
135 | */ | 135 | */ |
136 | void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count) | 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 | int oldid = dev->trkid; | 139 | int oldid = dev->trkid; |
140 | int count = 0; | 140 | int count = 0; |
141 | int i; | 141 | int i; |
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index c0e11ecc646f..c50fa75416f8 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig | |||
@@ -332,6 +332,16 @@ config KEYBOARD_LOCOMO | |||
332 | To compile this driver as a module, choose M here: the | 332 | To compile this driver as a module, choose M here: the |
333 | module will be called locomokbd. | 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 | config KEYBOARD_MAPLE | 345 | config KEYBOARD_MAPLE |
336 | tristate "Maple bus keyboard" | 346 | tristate "Maple bus keyboard" |
337 | depends on SH_DREAMCAST && MAPLE | 347 | depends on SH_DREAMCAST && MAPLE |
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index b03b02456a82..44e76002f54b 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile | |||
@@ -26,6 +26,7 @@ obj-$(CONFIG_KEYBOARD_LKKBD) += lkkbd.o | |||
26 | obj-$(CONFIG_KEYBOARD_LM8323) += lm8323.o | 26 | obj-$(CONFIG_KEYBOARD_LM8323) += lm8323.o |
27 | obj-$(CONFIG_KEYBOARD_LM8333) += lm8333.o | 27 | obj-$(CONFIG_KEYBOARD_LM8333) += lm8333.o |
28 | obj-$(CONFIG_KEYBOARD_LOCOMO) += locomokbd.o | 28 | obj-$(CONFIG_KEYBOARD_LOCOMO) += locomokbd.o |
29 | obj-$(CONFIG_KEYBOARD_LPC32XX) += lpc32xx-keys.o | ||
29 | obj-$(CONFIG_KEYBOARD_MAPLE) += maple_keyb.o | 30 | obj-$(CONFIG_KEYBOARD_MAPLE) += maple_keyb.o |
30 | obj-$(CONFIG_KEYBOARD_MATRIX) += matrix_keypad.o | 31 | obj-$(CONFIG_KEYBOARD_MATRIX) += matrix_keypad.o |
31 | obj-$(CONFIG_KEYBOARD_MAX7359) += max7359_keypad.o | 32 | obj-$(CONFIG_KEYBOARD_MAX7359) += max7359_keypad.o |
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 62bfce468f9f..cbb1add43d5e 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c | |||
@@ -559,7 +559,6 @@ static int gpio_keys_get_devtree_pdata(struct device *dev, | |||
559 | pdata->rep = !!of_get_property(node, "autorepeat", NULL); | 559 | pdata->rep = !!of_get_property(node, "autorepeat", NULL); |
560 | 560 | ||
561 | /* First count the subnodes */ | 561 | /* First count the subnodes */ |
562 | pdata->nbuttons = 0; | ||
563 | pp = NULL; | 562 | pp = NULL; |
564 | while ((pp = of_get_next_child(node, pp))) | 563 | while ((pp = of_get_next_child(node, pp))) |
565 | pdata->nbuttons++; | 564 | pdata->nbuttons++; |
diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c index 6ee7421e2321..ce68e361558c 100644 --- a/drivers/input/keyboard/imx_keypad.c +++ b/drivers/input/keyboard/imx_keypad.c | |||
@@ -358,6 +358,7 @@ static void imx_keypad_inhibit(struct imx_keypad *keypad) | |||
358 | /* Inhibit KDI and KRI interrupts. */ | 358 | /* Inhibit KDI and KRI interrupts. */ |
359 | reg_val = readw(keypad->mmio_base + KPSR); | 359 | reg_val = readw(keypad->mmio_base + KPSR); |
360 | reg_val &= ~(KBD_STAT_KRIE | KBD_STAT_KDIE); | 360 | reg_val &= ~(KBD_STAT_KRIE | KBD_STAT_KDIE); |
361 | reg_val |= KBD_STAT_KPKR | KBD_STAT_KPKD; | ||
361 | writew(reg_val, keypad->mmio_base + KPSR); | 362 | writew(reg_val, keypad->mmio_base + KPSR); |
362 | 363 | ||
363 | /* Colums as open drain and disable all rows */ | 364 | /* Colums as open drain and disable all rows */ |
@@ -378,20 +379,24 @@ static void imx_keypad_close(struct input_dev *dev) | |||
378 | imx_keypad_inhibit(keypad); | 379 | imx_keypad_inhibit(keypad); |
379 | 380 | ||
380 | /* Disable clock unit */ | 381 | /* Disable clock unit */ |
381 | clk_disable(keypad->clk); | 382 | clk_disable_unprepare(keypad->clk); |
382 | } | 383 | } |
383 | 384 | ||
384 | static int imx_keypad_open(struct input_dev *dev) | 385 | static int imx_keypad_open(struct input_dev *dev) |
385 | { | 386 | { |
386 | struct imx_keypad *keypad = input_get_drvdata(dev); | 387 | struct imx_keypad *keypad = input_get_drvdata(dev); |
388 | int error; | ||
387 | 389 | ||
388 | dev_dbg(&dev->dev, ">%s\n", __func__); | 390 | dev_dbg(&dev->dev, ">%s\n", __func__); |
389 | 391 | ||
392 | /* Enable the kpp clock */ | ||
393 | error = clk_prepare_enable(keypad->clk); | ||
394 | if (error) | ||
395 | return error; | ||
396 | |||
390 | /* We became active from now */ | 397 | /* We became active from now */ |
391 | keypad->enabled = true; | 398 | keypad->enabled = true; |
392 | 399 | ||
393 | /* Enable the kpp clock */ | ||
394 | clk_enable(keypad->clk); | ||
395 | imx_keypad_config(keypad); | 400 | imx_keypad_config(keypad); |
396 | 401 | ||
397 | /* Sanity control, not all the rows must be actived now. */ | 402 | /* Sanity control, not all the rows must be actived now. */ |
@@ -467,7 +472,7 @@ static int __devinit imx_keypad_probe(struct platform_device *pdev) | |||
467 | goto failed_free_priv; | 472 | goto failed_free_priv; |
468 | } | 473 | } |
469 | 474 | ||
470 | keypad->clk = clk_get(&pdev->dev, "kpp"); | 475 | keypad->clk = clk_get(&pdev->dev, NULL); |
471 | if (IS_ERR(keypad->clk)) { | 476 | if (IS_ERR(keypad->clk)) { |
472 | dev_err(&pdev->dev, "failed to get keypad clock\n"); | 477 | dev_err(&pdev->dev, "failed to get keypad clock\n"); |
473 | error = PTR_ERR(keypad->clk); | 478 | error = PTR_ERR(keypad->clk); |
@@ -511,7 +516,9 @@ static int __devinit imx_keypad_probe(struct platform_device *pdev) | |||
511 | input_set_drvdata(input_dev, keypad); | 516 | input_set_drvdata(input_dev, keypad); |
512 | 517 | ||
513 | /* Ensure that the keypad will stay dormant until opened */ | 518 | /* Ensure that the keypad will stay dormant until opened */ |
519 | clk_enable(keypad->clk); | ||
514 | imx_keypad_inhibit(keypad); | 520 | imx_keypad_inhibit(keypad); |
521 | clk_disable(keypad->clk); | ||
515 | 522 | ||
516 | error = request_irq(irq, imx_keypad_irq_handler, 0, | 523 | error = request_irq(irq, imx_keypad_irq_handler, 0, |
517 | pdev->name, keypad); | 524 | pdev->name, keypad); |
@@ -581,7 +588,7 @@ static int imx_kbd_suspend(struct device *dev) | |||
581 | mutex_lock(&input_dev->mutex); | 588 | mutex_lock(&input_dev->mutex); |
582 | 589 | ||
583 | if (input_dev->users) | 590 | if (input_dev->users) |
584 | clk_disable(kbd->clk); | 591 | clk_disable_unprepare(kbd->clk); |
585 | 592 | ||
586 | mutex_unlock(&input_dev->mutex); | 593 | mutex_unlock(&input_dev->mutex); |
587 | 594 | ||
@@ -596,18 +603,23 @@ static int imx_kbd_resume(struct device *dev) | |||
596 | struct platform_device *pdev = to_platform_device(dev); | 603 | struct platform_device *pdev = to_platform_device(dev); |
597 | struct imx_keypad *kbd = platform_get_drvdata(pdev); | 604 | struct imx_keypad *kbd = platform_get_drvdata(pdev); |
598 | struct input_dev *input_dev = kbd->input_dev; | 605 | struct input_dev *input_dev = kbd->input_dev; |
606 | int ret = 0; | ||
599 | 607 | ||
600 | if (device_may_wakeup(&pdev->dev)) | 608 | if (device_may_wakeup(&pdev->dev)) |
601 | disable_irq_wake(kbd->irq); | 609 | disable_irq_wake(kbd->irq); |
602 | 610 | ||
603 | mutex_lock(&input_dev->mutex); | 611 | mutex_lock(&input_dev->mutex); |
604 | 612 | ||
605 | if (input_dev->users) | 613 | if (input_dev->users) { |
606 | clk_enable(kbd->clk); | 614 | ret = clk_prepare_enable(kbd->clk); |
615 | if (ret) | ||
616 | goto err_clk; | ||
617 | } | ||
607 | 618 | ||
619 | err_clk: | ||
608 | mutex_unlock(&input_dev->mutex); | 620 | mutex_unlock(&input_dev->mutex); |
609 | 621 | ||
610 | return 0; | 622 | return ret; |
611 | } | 623 | } |
612 | #endif | 624 | #endif |
613 | 625 | ||
diff --git a/drivers/input/keyboard/lm8333.c b/drivers/input/keyboard/lm8333.c index ca168a6679de..081fd9effa8c 100644 --- a/drivers/input/keyboard/lm8333.c +++ b/drivers/input/keyboard/lm8333.c | |||
@@ -91,7 +91,7 @@ static void lm8333_key_handler(struct lm8333 *lm8333) | |||
91 | return; | 91 | return; |
92 | } | 92 | } |
93 | 93 | ||
94 | for (i = 0; keys[i] && i < LM8333_FIFO_TRANSFER_SIZE; i++) { | 94 | for (i = 0; i < LM8333_FIFO_TRANSFER_SIZE && keys[i]; i++) { |
95 | pressed = keys[i] & 0x80; | 95 | pressed = keys[i] & 0x80; |
96 | code = keys[i] & 0x7f; | 96 | code = keys[i] & 0x7f; |
97 | 97 | ||
diff --git a/drivers/input/keyboard/lpc32xx-keys.c b/drivers/input/keyboard/lpc32xx-keys.c new file mode 100644 index 000000000000..dd786c8a7584 --- /dev/null +++ b/drivers/input/keyboard/lpc32xx-keys.c | |||
@@ -0,0 +1,394 @@ | |||
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"); | ||
diff --git a/drivers/input/keyboard/nomadik-ske-keypad.c b/drivers/input/keyboard/nomadik-ske-keypad.c index 4ea4341a68c5..a880e7414202 100644 --- a/drivers/input/keyboard/nomadik-ske-keypad.c +++ b/drivers/input/keyboard/nomadik-ske-keypad.c | |||
@@ -49,6 +49,7 @@ | |||
49 | #define SKE_ASR3 0x2C | 49 | #define SKE_ASR3 0x2C |
50 | 50 | ||
51 | #define SKE_NUM_ASRX_REGISTERS (4) | 51 | #define SKE_NUM_ASRX_REGISTERS (4) |
52 | #define KEY_PRESSED_DELAY 10 | ||
52 | 53 | ||
53 | /** | 54 | /** |
54 | * struct ske_keypad - data structure used by keypad driver | 55 | * struct ske_keypad - data structure used by keypad driver |
@@ -92,7 +93,7 @@ static void ske_keypad_set_bits(struct ske_keypad *keypad, u16 addr, | |||
92 | static int __init ske_keypad_chip_init(struct ske_keypad *keypad) | 93 | static int __init ske_keypad_chip_init(struct ske_keypad *keypad) |
93 | { | 94 | { |
94 | u32 value; | 95 | u32 value; |
95 | int timeout = 50; | 96 | int timeout = keypad->board->debounce_ms; |
96 | 97 | ||
97 | /* check SKE_RIS to be 0 */ | 98 | /* check SKE_RIS to be 0 */ |
98 | while ((readl(keypad->reg_base + SKE_RIS) != 0x00000000) && timeout--) | 99 | while ((readl(keypad->reg_base + SKE_RIS) != 0x00000000) && timeout--) |
@@ -135,12 +136,37 @@ static int __init ske_keypad_chip_init(struct ske_keypad *keypad) | |||
135 | return 0; | 136 | return 0; |
136 | } | 137 | } |
137 | 138 | ||
138 | static void ske_keypad_read_data(struct ske_keypad *keypad) | 139 | static void ske_keypad_report(struct ske_keypad *keypad, u8 status, int col) |
139 | { | 140 | { |
141 | int row = 0, code, pos; | ||
140 | struct input_dev *input = keypad->input; | 142 | struct input_dev *input = keypad->input; |
141 | u16 status; | 143 | u32 ske_ris; |
142 | int col = 0, row = 0, code; | 144 | int key_pressed; |
143 | int ske_asr, ske_ris, key_pressed, i; | 145 | int num_of_rows; |
146 | |||
147 | /* find out the row */ | ||
148 | num_of_rows = hweight8(status); | ||
149 | do { | ||
150 | pos = __ffs(status); | ||
151 | row = pos; | ||
152 | status &= ~(1 << pos); | ||
153 | |||
154 | code = MATRIX_SCAN_CODE(row, col, SKE_KEYPAD_ROW_SHIFT); | ||
155 | ske_ris = readl(keypad->reg_base + SKE_RIS); | ||
156 | key_pressed = ske_ris & SKE_KPRISA; | ||
157 | |||
158 | input_event(input, EV_MSC, MSC_SCAN, code); | ||
159 | input_report_key(input, keypad->keymap[code], key_pressed); | ||
160 | input_sync(input); | ||
161 | num_of_rows--; | ||
162 | } while (num_of_rows); | ||
163 | } | ||
164 | |||
165 | static void ske_keypad_read_data(struct ske_keypad *keypad) | ||
166 | { | ||
167 | u8 status; | ||
168 | int col = 0; | ||
169 | int ske_asr, i; | ||
144 | 170 | ||
145 | /* | 171 | /* |
146 | * Read the auto scan registers | 172 | * Read the auto scan registers |
@@ -154,44 +180,38 @@ static void ske_keypad_read_data(struct ske_keypad *keypad) | |||
154 | if (!ske_asr) | 180 | if (!ske_asr) |
155 | continue; | 181 | continue; |
156 | 182 | ||
157 | /* now that ASRx is zero, find out the column x and row y*/ | 183 | /* now that ASRx is zero, find out the coloumn x and row y */ |
158 | if (ske_asr & 0xff) { | 184 | status = ske_asr & 0xff; |
185 | if (status) { | ||
159 | col = i * 2; | 186 | col = i * 2; |
160 | status = ske_asr & 0xff; | 187 | ske_keypad_report(keypad, status, col); |
161 | } else { | 188 | } |
189 | status = (ske_asr & 0xff00) >> 8; | ||
190 | if (status) { | ||
162 | col = (i * 2) + 1; | 191 | col = (i * 2) + 1; |
163 | status = (ske_asr & 0xff00) >> 8; | 192 | ske_keypad_report(keypad, status, col); |
164 | } | 193 | } |
165 | |||
166 | /* find out the row */ | ||
167 | row = __ffs(status); | ||
168 | |||
169 | code = MATRIX_SCAN_CODE(row, col, SKE_KEYPAD_ROW_SHIFT); | ||
170 | ske_ris = readl(keypad->reg_base + SKE_RIS); | ||
171 | key_pressed = ske_ris & SKE_KPRISA; | ||
172 | |||
173 | input_event(input, EV_MSC, MSC_SCAN, code); | ||
174 | input_report_key(input, keypad->keymap[code], key_pressed); | ||
175 | input_sync(input); | ||
176 | } | 194 | } |
177 | } | 195 | } |
178 | 196 | ||
179 | static irqreturn_t ske_keypad_irq(int irq, void *dev_id) | 197 | static irqreturn_t ske_keypad_irq(int irq, void *dev_id) |
180 | { | 198 | { |
181 | struct ske_keypad *keypad = dev_id; | 199 | struct ske_keypad *keypad = dev_id; |
182 | int retries = 20; | 200 | int timeout = keypad->board->debounce_ms; |
183 | 201 | ||
184 | /* disable auto scan interrupt; mask the interrupt generated */ | 202 | /* disable auto scan interrupt; mask the interrupt generated */ |
185 | ske_keypad_set_bits(keypad, SKE_IMSC, ~SKE_KPIMA, 0x0); | 203 | ske_keypad_set_bits(keypad, SKE_IMSC, ~SKE_KPIMA, 0x0); |
186 | ske_keypad_set_bits(keypad, SKE_ICR, 0x0, SKE_KPICA); | 204 | ske_keypad_set_bits(keypad, SKE_ICR, 0x0, SKE_KPICA); |
187 | 205 | ||
188 | while ((readl(keypad->reg_base + SKE_CR) & SKE_KPASON) && --retries) | 206 | while ((readl(keypad->reg_base + SKE_CR) & SKE_KPASON) && --timeout) |
189 | msleep(5); | 207 | cpu_relax(); |
190 | 208 | ||
191 | if (retries) { | 209 | /* SKEx registers are stable and can be read */ |
192 | /* SKEx registers are stable and can be read */ | 210 | ske_keypad_read_data(keypad); |
193 | ske_keypad_read_data(keypad); | 211 | |
194 | } | 212 | /* wait until raw interrupt is clear */ |
213 | while ((readl(keypad->reg_base + SKE_RIS)) && --timeout) | ||
214 | msleep(KEY_PRESSED_DELAY); | ||
195 | 215 | ||
196 | /* enable auto scan interrupts */ | 216 | /* enable auto scan interrupts */ |
197 | ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA); | 217 | ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA); |
diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index aed5f6999ce2..c05f98c41410 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/platform_device.h> | 27 | #include <linux/platform_device.h> |
28 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
29 | #include <linux/io.h> | 29 | #include <linux/io.h> |
30 | #include <linux/of.h> | ||
30 | #include <linux/input.h> | 31 | #include <linux/input.h> |
31 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
32 | #include <linux/pm_runtime.h> | 33 | #include <linux/pm_runtime.h> |
@@ -84,8 +85,9 @@ struct omap4_keypad { | |||
84 | u32 reg_offset; | 85 | u32 reg_offset; |
85 | u32 irqreg_offset; | 86 | u32 irqreg_offset; |
86 | unsigned int row_shift; | 87 | unsigned int row_shift; |
88 | bool no_autorepeat; | ||
87 | unsigned char key_state[8]; | 89 | unsigned char key_state[8]; |
88 | unsigned short keymap[]; | 90 | unsigned short *keymap; |
89 | }; | 91 | }; |
90 | 92 | ||
91 | static int kbd_readl(struct omap4_keypad *keypad_data, u32 offset) | 93 | static int kbd_readl(struct omap4_keypad *keypad_data, u32 offset) |
@@ -208,25 +210,51 @@ static void omap4_keypad_close(struct input_dev *input) | |||
208 | pm_runtime_put_sync(input->dev.parent); | 210 | pm_runtime_put_sync(input->dev.parent); |
209 | } | 211 | } |
210 | 212 | ||
213 | #ifdef CONFIG_OF | ||
214 | static int __devinit omap4_keypad_parse_dt(struct device *dev, | ||
215 | struct omap4_keypad *keypad_data) | ||
216 | { | ||
217 | struct device_node *np = dev->of_node; | ||
218 | |||
219 | if (!np) { | ||
220 | dev_err(dev, "missing DT data"); | ||
221 | return -EINVAL; | ||
222 | } | ||
223 | |||
224 | of_property_read_u32(np, "keypad,num-rows", &keypad_data->rows); | ||
225 | of_property_read_u32(np, "keypad,num-columns", &keypad_data->cols); | ||
226 | if (!keypad_data->rows || !keypad_data->cols) { | ||
227 | dev_err(dev, "number of keypad rows/columns not specified\n"); | ||
228 | return -EINVAL; | ||
229 | } | ||
230 | |||
231 | if (of_get_property(np, "linux,input-no-autorepeat", NULL)) | ||
232 | keypad_data->no_autorepeat = true; | ||
233 | |||
234 | return 0; | ||
235 | } | ||
236 | #else | ||
237 | static inline int omap4_keypad_parse_dt(struct device *dev, | ||
238 | struct omap4_keypad *keypad_data) | ||
239 | { | ||
240 | return -ENOSYS; | ||
241 | } | ||
242 | #endif | ||
243 | |||
211 | static int __devinit omap4_keypad_probe(struct platform_device *pdev) | 244 | static int __devinit omap4_keypad_probe(struct platform_device *pdev) |
212 | { | 245 | { |
213 | const struct omap4_keypad_platform_data *pdata; | 246 | const struct omap4_keypad_platform_data *pdata = |
247 | dev_get_platdata(&pdev->dev); | ||
248 | const struct matrix_keymap_data *keymap_data = | ||
249 | pdata ? pdata->keymap_data : NULL; | ||
214 | struct omap4_keypad *keypad_data; | 250 | struct omap4_keypad *keypad_data; |
215 | struct input_dev *input_dev; | 251 | struct input_dev *input_dev; |
216 | struct resource *res; | 252 | struct resource *res; |
217 | resource_size_t size; | 253 | unsigned int max_keys; |
218 | unsigned int row_shift, max_keys; | ||
219 | int rev; | 254 | int rev; |
220 | int irq; | 255 | int irq; |
221 | int error; | 256 | int error; |
222 | 257 | ||
223 | /* platform data */ | ||
224 | pdata = pdev->dev.platform_data; | ||
225 | if (!pdata) { | ||
226 | dev_err(&pdev->dev, "no platform data defined\n"); | ||
227 | return -EINVAL; | ||
228 | } | ||
229 | |||
230 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 258 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
231 | if (!res) { | 259 | if (!res) { |
232 | dev_err(&pdev->dev, "no base address specified\n"); | 260 | dev_err(&pdev->dev, "no base address specified\n"); |
@@ -239,25 +267,24 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev) | |||
239 | return -EINVAL; | 267 | return -EINVAL; |
240 | } | 268 | } |
241 | 269 | ||
242 | if (!pdata->keymap_data) { | 270 | keypad_data = kzalloc(sizeof(struct omap4_keypad), GFP_KERNEL); |
243 | dev_err(&pdev->dev, "no keymap data defined\n"); | ||
244 | return -EINVAL; | ||
245 | } | ||
246 | |||
247 | row_shift = get_count_order(pdata->cols); | ||
248 | max_keys = pdata->rows << row_shift; | ||
249 | |||
250 | keypad_data = kzalloc(sizeof(struct omap4_keypad) + | ||
251 | max_keys * sizeof(keypad_data->keymap[0]), | ||
252 | GFP_KERNEL); | ||
253 | if (!keypad_data) { | 271 | if (!keypad_data) { |
254 | dev_err(&pdev->dev, "keypad_data memory allocation failed\n"); | 272 | dev_err(&pdev->dev, "keypad_data memory allocation failed\n"); |
255 | return -ENOMEM; | 273 | return -ENOMEM; |
256 | } | 274 | } |
257 | 275 | ||
258 | size = resource_size(res); | 276 | keypad_data->irq = irq; |
277 | |||
278 | if (pdata) { | ||
279 | keypad_data->rows = pdata->rows; | ||
280 | keypad_data->cols = pdata->cols; | ||
281 | } else { | ||
282 | error = omap4_keypad_parse_dt(&pdev->dev, keypad_data); | ||
283 | if (error) | ||
284 | return error; | ||
285 | } | ||
259 | 286 | ||
260 | res = request_mem_region(res->start, size, pdev->name); | 287 | res = request_mem_region(res->start, resource_size(res), pdev->name); |
261 | if (!res) { | 288 | if (!res) { |
262 | dev_err(&pdev->dev, "can't request mem region\n"); | 289 | dev_err(&pdev->dev, "can't request mem region\n"); |
263 | error = -EBUSY; | 290 | error = -EBUSY; |
@@ -271,15 +298,11 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev) | |||
271 | goto err_release_mem; | 298 | goto err_release_mem; |
272 | } | 299 | } |
273 | 300 | ||
274 | keypad_data->irq = irq; | ||
275 | keypad_data->row_shift = row_shift; | ||
276 | keypad_data->rows = pdata->rows; | ||
277 | keypad_data->cols = pdata->cols; | ||
278 | 301 | ||
279 | /* | 302 | /* |
280 | * Enable clocks for the keypad module so that we can read | 303 | * Enable clocks for the keypad module so that we can read |
281 | * revision register. | 304 | * revision register. |
282 | */ | 305 | */ |
283 | pm_runtime_enable(&pdev->dev); | 306 | pm_runtime_enable(&pdev->dev); |
284 | error = pm_runtime_get_sync(&pdev->dev); | 307 | error = pm_runtime_get_sync(&pdev->dev); |
285 | if (error) { | 308 | if (error) { |
@@ -322,19 +345,30 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev) | |||
322 | input_dev->open = omap4_keypad_open; | 345 | input_dev->open = omap4_keypad_open; |
323 | input_dev->close = omap4_keypad_close; | 346 | input_dev->close = omap4_keypad_close; |
324 | 347 | ||
325 | error = matrix_keypad_build_keymap(pdata->keymap_data, NULL, | 348 | input_set_capability(input_dev, EV_MSC, MSC_SCAN); |
326 | pdata->rows, pdata->cols, | 349 | if (!keypad_data->no_autorepeat) |
350 | __set_bit(EV_REP, input_dev->evbit); | ||
351 | |||
352 | input_set_drvdata(input_dev, keypad_data); | ||
353 | |||
354 | keypad_data->row_shift = get_count_order(keypad_data->cols); | ||
355 | max_keys = keypad_data->rows << keypad_data->row_shift; | ||
356 | keypad_data->keymap = kzalloc(max_keys * sizeof(keypad_data->keymap[0]), | ||
357 | GFP_KERNEL); | ||
358 | if (!keypad_data->keymap) { | ||
359 | dev_err(&pdev->dev, "Not enough memory for keymap\n"); | ||
360 | error = -ENOMEM; | ||
361 | goto err_free_input; | ||
362 | } | ||
363 | |||
364 | error = matrix_keypad_build_keymap(keymap_data, NULL, | ||
365 | keypad_data->rows, keypad_data->cols, | ||
327 | keypad_data->keymap, input_dev); | 366 | keypad_data->keymap, input_dev); |
328 | if (error) { | 367 | if (error) { |
329 | dev_err(&pdev->dev, "failed to build keymap\n"); | 368 | dev_err(&pdev->dev, "failed to build keymap\n"); |
330 | goto err_free_input; | 369 | goto err_free_keymap; |
331 | } | 370 | } |
332 | 371 | ||
333 | __set_bit(EV_REP, input_dev->evbit); | ||
334 | input_set_capability(input_dev, EV_MSC, MSC_SCAN); | ||
335 | |||
336 | input_set_drvdata(input_dev, keypad_data); | ||
337 | |||
338 | error = request_irq(keypad_data->irq, omap4_keypad_interrupt, | 372 | error = request_irq(keypad_data->irq, omap4_keypad_interrupt, |
339 | IRQF_TRIGGER_RISING, | 373 | IRQF_TRIGGER_RISING, |
340 | "omap4-keypad", keypad_data); | 374 | "omap4-keypad", keypad_data); |
@@ -357,6 +391,8 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev) | |||
357 | err_pm_disable: | 391 | err_pm_disable: |
358 | pm_runtime_disable(&pdev->dev); | 392 | pm_runtime_disable(&pdev->dev); |
359 | free_irq(keypad_data->irq, keypad_data); | 393 | free_irq(keypad_data->irq, keypad_data); |
394 | err_free_keymap: | ||
395 | kfree(keypad_data->keymap); | ||
360 | err_free_input: | 396 | err_free_input: |
361 | input_free_device(input_dev); | 397 | input_free_device(input_dev); |
362 | err_pm_put_sync: | 398 | err_pm_put_sync: |
@@ -364,7 +400,7 @@ err_pm_put_sync: | |||
364 | err_unmap: | 400 | err_unmap: |
365 | iounmap(keypad_data->base); | 401 | iounmap(keypad_data->base); |
366 | err_release_mem: | 402 | err_release_mem: |
367 | release_mem_region(res->start, size); | 403 | release_mem_region(res->start, resource_size(res)); |
368 | err_free_keypad: | 404 | err_free_keypad: |
369 | kfree(keypad_data); | 405 | kfree(keypad_data); |
370 | return error; | 406 | return error; |
@@ -386,18 +422,29 @@ static int __devexit omap4_keypad_remove(struct platform_device *pdev) | |||
386 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 422 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
387 | release_mem_region(res->start, resource_size(res)); | 423 | release_mem_region(res->start, resource_size(res)); |
388 | 424 | ||
425 | kfree(keypad_data->keymap); | ||
389 | kfree(keypad_data); | 426 | kfree(keypad_data); |
427 | |||
390 | platform_set_drvdata(pdev, NULL); | 428 | platform_set_drvdata(pdev, NULL); |
391 | 429 | ||
392 | return 0; | 430 | return 0; |
393 | } | 431 | } |
394 | 432 | ||
433 | #ifdef CONFIG_OF | ||
434 | static const struct of_device_id omap_keypad_dt_match[] = { | ||
435 | { .compatible = "ti,omap4-keypad" }, | ||
436 | {}, | ||
437 | }; | ||
438 | MODULE_DEVICE_TABLE(of, omap_keypad_dt_match); | ||
439 | #endif | ||
440 | |||
395 | static struct platform_driver omap4_keypad_driver = { | 441 | static struct platform_driver omap4_keypad_driver = { |
396 | .probe = omap4_keypad_probe, | 442 | .probe = omap4_keypad_probe, |
397 | .remove = __devexit_p(omap4_keypad_remove), | 443 | .remove = __devexit_p(omap4_keypad_remove), |
398 | .driver = { | 444 | .driver = { |
399 | .name = "omap4-keypad", | 445 | .name = "omap4-keypad", |
400 | .owner = THIS_MODULE, | 446 | .owner = THIS_MODULE, |
447 | .of_match_table = of_match_ptr(omap_keypad_dt_match), | ||
401 | }, | 448 | }, |
402 | }; | 449 | }; |
403 | module_platform_driver(omap4_keypad_driver); | 450 | module_platform_driver(omap4_keypad_driver); |
diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c index 6f287f7e1538..72ef01be3360 100644 --- a/drivers/input/keyboard/spear-keyboard.c +++ b/drivers/input/keyboard/spear-keyboard.c | |||
@@ -27,33 +27,31 @@ | |||
27 | #include <plat/keyboard.h> | 27 | #include <plat/keyboard.h> |
28 | 28 | ||
29 | /* Keyboard Registers */ | 29 | /* Keyboard Registers */ |
30 | #define MODE_REG 0x00 /* 16 bit reg */ | 30 | #define MODE_CTL_REG 0x00 |
31 | #define STATUS_REG 0x0C /* 2 bit reg */ | 31 | #define STATUS_REG 0x0C |
32 | #define DATA_REG 0x10 /* 8 bit reg */ | 32 | #define DATA_REG 0x10 |
33 | #define INTR_MASK 0x54 | 33 | #define INTR_MASK 0x54 |
34 | 34 | ||
35 | /* Register Values */ | 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 | #define NUM_ROWS 16 | 36 | #define NUM_ROWS 16 |
54 | #define NUM_COLS 16 | 37 | #define NUM_COLS 16 |
38 | #define MODE_CTL_PCLK_FREQ_SHIFT 9 | ||
39 | #define MODE_CTL_PCLK_FREQ_MSK 0x7F | ||
40 | |||
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) | ||
55 | 48 | ||
56 | #define KEY_MATRIX_SHIFT 6 | 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 | struct spear_kbd { | 56 | struct spear_kbd { |
59 | struct input_dev *input; | 57 | struct input_dev *input; |
@@ -65,6 +63,8 @@ struct spear_kbd { | |||
65 | unsigned short last_key; | 63 | unsigned short last_key; |
66 | unsigned short keycodes[NUM_ROWS * NUM_COLS]; | 64 | unsigned short keycodes[NUM_ROWS * NUM_COLS]; |
67 | bool rep; | 65 | bool rep; |
66 | unsigned int suspended_rate; | ||
67 | u32 mode_ctl_reg; | ||
68 | }; | 68 | }; |
69 | 69 | ||
70 | static irqreturn_t spear_kbd_interrupt(int irq, void *dev_id) | 70 | static irqreturn_t spear_kbd_interrupt(int irq, void *dev_id) |
@@ -72,10 +72,10 @@ static irqreturn_t spear_kbd_interrupt(int irq, void *dev_id) | |||
72 | struct spear_kbd *kbd = dev_id; | 72 | struct spear_kbd *kbd = dev_id; |
73 | struct input_dev *input = kbd->input; | 73 | struct input_dev *input = kbd->input; |
74 | unsigned int key; | 74 | unsigned int key; |
75 | u8 sts, val; | 75 | u32 sts, val; |
76 | 76 | ||
77 | sts = readb(kbd->io_base + STATUS_REG); | 77 | sts = readl_relaxed(kbd->io_base + STATUS_REG); |
78 | if (!(sts & DATA_AVAIL)) | 78 | if (!(sts & STATUS_DATA_AVAIL)) |
79 | return IRQ_NONE; | 79 | return IRQ_NONE; |
80 | 80 | ||
81 | if (kbd->last_key != KEY_RESERVED) { | 81 | if (kbd->last_key != KEY_RESERVED) { |
@@ -84,7 +84,8 @@ static irqreturn_t spear_kbd_interrupt(int irq, void *dev_id) | |||
84 | } | 84 | } |
85 | 85 | ||
86 | /* following reads active (row, col) pair */ | 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 | key = kbd->keycodes[val]; | 89 | key = kbd->keycodes[val]; |
89 | 90 | ||
90 | input_event(input, EV_MSC, MSC_SCAN, val); | 91 | input_event(input, EV_MSC, MSC_SCAN, val); |
@@ -94,7 +95,7 @@ static irqreturn_t spear_kbd_interrupt(int irq, void *dev_id) | |||
94 | kbd->last_key = key; | 95 | kbd->last_key = key; |
95 | 96 | ||
96 | /* clear interrupt */ | 97 | /* clear interrupt */ |
97 | writeb(0, kbd->io_base + STATUS_REG); | 98 | writel_relaxed(0, kbd->io_base + STATUS_REG); |
98 | 99 | ||
99 | return IRQ_HANDLED; | 100 | return IRQ_HANDLED; |
100 | } | 101 | } |
@@ -103,7 +104,7 @@ static int spear_kbd_open(struct input_dev *dev) | |||
103 | { | 104 | { |
104 | struct spear_kbd *kbd = input_get_drvdata(dev); | 105 | struct spear_kbd *kbd = input_get_drvdata(dev); |
105 | int error; | 106 | int error; |
106 | u16 val; | 107 | u32 val; |
107 | 108 | ||
108 | kbd->last_key = KEY_RESERVED; | 109 | kbd->last_key = KEY_RESERVED; |
109 | 110 | ||
@@ -111,16 +112,20 @@ static int spear_kbd_open(struct input_dev *dev) | |||
111 | if (error) | 112 | if (error) |
112 | return error; | 113 | return error; |
113 | 114 | ||
115 | /* keyboard rate to be programmed is input clock (in MHz) - 1 */ | ||
116 | val = clk_get_rate(kbd->clk) / 1000000 - 1; | ||
117 | val = (val & MODE_CTL_PCLK_FREQ_MSK) << MODE_CTL_PCLK_FREQ_SHIFT; | ||
118 | |||
114 | /* program keyboard */ | 119 | /* program keyboard */ |
115 | val = SCAN_RATE_80 | MODE_KEYBOARD | PCLK_FREQ_MSK | | 120 | val = MODE_CTL_SCAN_RATE_80 | MODE_CTL_KEYBOARD | val | |
116 | (kbd->mode << KEY_MATRIX_SHIFT); | 121 | (kbd->mode << MODE_CTL_KEYNUM_SHIFT); |
117 | writew(val, kbd->io_base + MODE_REG); | 122 | writel_relaxed(val, kbd->io_base + MODE_CTL_REG); |
118 | writeb(1, kbd->io_base + STATUS_REG); | 123 | writel_relaxed(1, kbd->io_base + STATUS_REG); |
119 | 124 | ||
120 | /* start key scan */ | 125 | /* start key scan */ |
121 | val = readw(kbd->io_base + MODE_REG); | 126 | val = readl_relaxed(kbd->io_base + MODE_CTL_REG); |
122 | val |= START_SCAN; | 127 | val |= MODE_CTL_START_SCAN; |
123 | writew(val, kbd->io_base + MODE_REG); | 128 | writel_relaxed(val, kbd->io_base + MODE_CTL_REG); |
124 | 129 | ||
125 | return 0; | 130 | return 0; |
126 | } | 131 | } |
@@ -128,12 +133,12 @@ static int spear_kbd_open(struct input_dev *dev) | |||
128 | static void spear_kbd_close(struct input_dev *dev) | 133 | static void spear_kbd_close(struct input_dev *dev) |
129 | { | 134 | { |
130 | struct spear_kbd *kbd = input_get_drvdata(dev); | 135 | struct spear_kbd *kbd = input_get_drvdata(dev); |
131 | u16 val; | 136 | u32 val; |
132 | 137 | ||
133 | /* stop key scan */ | 138 | /* stop key scan */ |
134 | val = readw(kbd->io_base + MODE_REG); | 139 | val = readl_relaxed(kbd->io_base + MODE_CTL_REG); |
135 | val &= ~START_SCAN; | 140 | val &= ~MODE_CTL_START_SCAN; |
136 | writew(val, kbd->io_base + MODE_REG); | 141 | writel_relaxed(val, kbd->io_base + MODE_CTL_REG); |
137 | 142 | ||
138 | clk_disable(kbd->clk); | 143 | clk_disable(kbd->clk); |
139 | 144 | ||
@@ -146,7 +151,7 @@ static int __devinit spear_kbd_parse_dt(struct platform_device *pdev, | |||
146 | { | 151 | { |
147 | struct device_node *np = pdev->dev.of_node; | 152 | struct device_node *np = pdev->dev.of_node; |
148 | int error; | 153 | int error; |
149 | u32 val; | 154 | u32 val, suspended_rate; |
150 | 155 | ||
151 | if (!np) { | 156 | if (!np) { |
152 | dev_err(&pdev->dev, "Missing DT data\n"); | 157 | dev_err(&pdev->dev, "Missing DT data\n"); |
@@ -156,6 +161,9 @@ static int __devinit spear_kbd_parse_dt(struct platform_device *pdev, | |||
156 | if (of_property_read_bool(np, "autorepeat")) | 161 | if (of_property_read_bool(np, "autorepeat")) |
157 | kbd->rep = true; | 162 | kbd->rep = true; |
158 | 163 | ||
164 | if (of_property_read_u32(np, "suspended_rate", &suspended_rate)) | ||
165 | kbd->suspended_rate = suspended_rate; | ||
166 | |||
159 | error = of_property_read_u32(np, "st,mode", &val); | 167 | error = of_property_read_u32(np, "st,mode", &val); |
160 | if (error) { | 168 | if (error) { |
161 | dev_err(&pdev->dev, "DT: Invalid or missing mode\n"); | 169 | dev_err(&pdev->dev, "DT: Invalid or missing mode\n"); |
@@ -213,6 +221,7 @@ static int __devinit spear_kbd_probe(struct platform_device *pdev) | |||
213 | } else { | 221 | } else { |
214 | kbd->mode = pdata->mode; | 222 | kbd->mode = pdata->mode; |
215 | kbd->rep = pdata->rep; | 223 | kbd->rep = pdata->rep; |
224 | kbd->suspended_rate = pdata->suspended_rate; | ||
216 | } | 225 | } |
217 | 226 | ||
218 | kbd->res = request_mem_region(res->start, resource_size(res), | 227 | kbd->res = request_mem_region(res->start, resource_size(res), |
@@ -302,7 +311,7 @@ static int __devexit spear_kbd_remove(struct platform_device *pdev) | |||
302 | release_mem_region(kbd->res->start, resource_size(kbd->res)); | 311 | release_mem_region(kbd->res->start, resource_size(kbd->res)); |
303 | kfree(kbd); | 312 | kfree(kbd); |
304 | 313 | ||
305 | device_init_wakeup(&pdev->dev, 1); | 314 | device_init_wakeup(&pdev->dev, 0); |
306 | platform_set_drvdata(pdev, NULL); | 315 | platform_set_drvdata(pdev, NULL); |
307 | 316 | ||
308 | return 0; | 317 | return 0; |
@@ -314,15 +323,48 @@ static int spear_kbd_suspend(struct device *dev) | |||
314 | struct platform_device *pdev = to_platform_device(dev); | 323 | struct platform_device *pdev = to_platform_device(dev); |
315 | struct spear_kbd *kbd = platform_get_drvdata(pdev); | 324 | struct spear_kbd *kbd = platform_get_drvdata(pdev); |
316 | struct input_dev *input_dev = kbd->input; | 325 | struct input_dev *input_dev = kbd->input; |
326 | unsigned int rate = 0, mode_ctl_reg, val; | ||
317 | 327 | ||
318 | mutex_lock(&input_dev->mutex); | 328 | mutex_lock(&input_dev->mutex); |
319 | 329 | ||
320 | if (input_dev->users) | 330 | /* explicitly enable clock as we may program device */ |
321 | clk_enable(kbd->clk); | 331 | clk_enable(kbd->clk); |
322 | 332 | ||
323 | if (device_may_wakeup(&pdev->dev)) | 333 | mode_ctl_reg = readl_relaxed(kbd->io_base + MODE_CTL_REG); |
334 | |||
335 | if (device_may_wakeup(&pdev->dev)) { | ||
324 | enable_irq_wake(kbd->irq); | 336 | enable_irq_wake(kbd->irq); |
325 | 337 | ||
338 | /* | ||
339 | * reprogram the keyboard operating frequency as on some | ||
340 | * platform it may change during system suspended | ||
341 | */ | ||
342 | if (kbd->suspended_rate) | ||
343 | rate = kbd->suspended_rate / 1000000 - 1; | ||
344 | else | ||
345 | rate = clk_get_rate(kbd->clk) / 1000000 - 1; | ||
346 | |||
347 | val = mode_ctl_reg & | ||
348 | ~(MODE_CTL_PCLK_FREQ_MSK << MODE_CTL_PCLK_FREQ_SHIFT); | ||
349 | val |= (rate & MODE_CTL_PCLK_FREQ_MSK) | ||
350 | << MODE_CTL_PCLK_FREQ_SHIFT; | ||
351 | writel_relaxed(val, kbd->io_base + MODE_CTL_REG); | ||
352 | |||
353 | } else { | ||
354 | if (input_dev->users) { | ||
355 | writel_relaxed(mode_ctl_reg & ~MODE_CTL_START_SCAN, | ||
356 | kbd->io_base + MODE_CTL_REG); | ||
357 | clk_disable(kbd->clk); | ||
358 | } | ||
359 | } | ||
360 | |||
361 | /* store current configuration */ | ||
362 | if (input_dev->users) | ||
363 | kbd->mode_ctl_reg = mode_ctl_reg; | ||
364 | |||
365 | /* restore previous clk state */ | ||
366 | clk_disable(kbd->clk); | ||
367 | |||
326 | mutex_unlock(&input_dev->mutex); | 368 | mutex_unlock(&input_dev->mutex); |
327 | 369 | ||
328 | return 0; | 370 | return 0; |
@@ -336,11 +378,16 @@ static int spear_kbd_resume(struct device *dev) | |||
336 | 378 | ||
337 | mutex_lock(&input_dev->mutex); | 379 | mutex_lock(&input_dev->mutex); |
338 | 380 | ||
339 | if (device_may_wakeup(&pdev->dev)) | 381 | if (device_may_wakeup(&pdev->dev)) { |
340 | disable_irq_wake(kbd->irq); | 382 | disable_irq_wake(kbd->irq); |
383 | } else { | ||
384 | if (input_dev->users) | ||
385 | clk_enable(kbd->clk); | ||
386 | } | ||
341 | 387 | ||
388 | /* restore current configuration */ | ||
342 | if (input_dev->users) | 389 | if (input_dev->users) |
343 | clk_enable(kbd->clk); | 390 | writel_relaxed(kbd->mode_ctl_reg, kbd->io_base + MODE_CTL_REG); |
344 | 391 | ||
345 | mutex_unlock(&input_dev->mutex); | 392 | mutex_unlock(&input_dev->mutex); |
346 | 393 | ||
diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c index 4ffe64d53107..2c1c9ed1bd9f 100644 --- a/drivers/input/keyboard/tegra-kbc.c +++ b/drivers/input/keyboard/tegra-kbc.c | |||
@@ -492,7 +492,7 @@ static int tegra_kbc_start(struct tegra_kbc *kbc) | |||
492 | unsigned int debounce_cnt; | 492 | unsigned int debounce_cnt; |
493 | u32 val = 0; | 493 | u32 val = 0; |
494 | 494 | ||
495 | clk_enable(kbc->clk); | 495 | clk_prepare_enable(kbc->clk); |
496 | 496 | ||
497 | /* Reset the KBC controller to clear all previous status.*/ | 497 | /* Reset the KBC controller to clear all previous status.*/ |
498 | tegra_periph_reset_assert(kbc->clk); | 498 | tegra_periph_reset_assert(kbc->clk); |
@@ -556,7 +556,7 @@ static void tegra_kbc_stop(struct tegra_kbc *kbc) | |||
556 | disable_irq(kbc->irq); | 556 | disable_irq(kbc->irq); |
557 | del_timer_sync(&kbc->timer); | 557 | del_timer_sync(&kbc->timer); |
558 | 558 | ||
559 | clk_disable(kbc->clk); | 559 | clk_disable_unprepare(kbc->clk); |
560 | } | 560 | } |
561 | 561 | ||
562 | static int tegra_kbc_open(struct input_dev *dev) | 562 | static int tegra_kbc_open(struct input_dev *dev) |
diff --git a/drivers/input/misc/88pm80x_onkey.c b/drivers/input/misc/88pm80x_onkey.c new file mode 100644 index 000000000000..7f26e7b6c228 --- /dev/null +++ b/drivers/input/misc/88pm80x_onkey.c | |||
@@ -0,0 +1,168 @@ | |||
1 | /* | ||
2 | * Marvell 88PM80x ONKEY driver | ||
3 | * | ||
4 | * Copyright (C) 2012 Marvell International Ltd. | ||
5 | * Haojian Zhuang <haojian.zhuang@marvell.com> | ||
6 | * Qiao Zhou <zhouqiao@marvell.com> | ||
7 | * | ||
8 | * This file is subject to the terms and conditions of the GNU General | ||
9 | * Public License. See the file "COPYING" in the main directory of this | ||
10 | * archive for more details. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | ||
21 | |||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/input.h> | ||
25 | #include <linux/mfd/88pm80x.h> | ||
26 | #include <linux/regmap.h> | ||
27 | #include <linux/slab.h> | ||
28 | |||
29 | #define PM800_LONG_ONKEY_EN (1 << 0) | ||
30 | #define PM800_LONG_KEY_DELAY (8) /* 1 .. 16 seconds */ | ||
31 | #define PM800_LONKEY_PRESS_TIME ((PM800_LONG_KEY_DELAY-1) << 4) | ||
32 | #define PM800_LONKEY_PRESS_TIME_MASK (0xF0) | ||
33 | #define PM800_SW_PDOWN (1 << 5) | ||
34 | |||
35 | struct pm80x_onkey_info { | ||
36 | struct input_dev *idev; | ||
37 | struct pm80x_chip *pm80x; | ||
38 | struct regmap *map; | ||
39 | int irq; | ||
40 | }; | ||
41 | |||
42 | /* 88PM80x gives us an interrupt when ONKEY is held */ | ||
43 | static irqreturn_t pm80x_onkey_handler(int irq, void *data) | ||
44 | { | ||
45 | struct pm80x_onkey_info *info = data; | ||
46 | int ret = 0; | ||
47 | unsigned int val; | ||
48 | |||
49 | ret = regmap_read(info->map, PM800_STATUS_1, &val); | ||
50 | if (ret < 0) { | ||
51 | dev_err(info->idev->dev.parent, "failed to read status: %d\n", ret); | ||
52 | return IRQ_NONE; | ||
53 | } | ||
54 | val &= PM800_ONKEY_STS1; | ||
55 | |||
56 | input_report_key(info->idev, KEY_POWER, val); | ||
57 | input_sync(info->idev); | ||
58 | |||
59 | return IRQ_HANDLED; | ||
60 | } | ||
61 | |||
62 | static SIMPLE_DEV_PM_OPS(pm80x_onkey_pm_ops, pm80x_dev_suspend, | ||
63 | pm80x_dev_resume); | ||
64 | |||
65 | static int __devinit pm80x_onkey_probe(struct platform_device *pdev) | ||
66 | { | ||
67 | |||
68 | struct pm80x_chip *chip = dev_get_drvdata(pdev->dev.parent); | ||
69 | struct pm80x_onkey_info *info; | ||
70 | int err; | ||
71 | |||
72 | info = kzalloc(sizeof(struct pm80x_onkey_info), GFP_KERNEL); | ||
73 | if (!info) | ||
74 | return -ENOMEM; | ||
75 | |||
76 | info->pm80x = chip; | ||
77 | |||
78 | info->irq = platform_get_irq(pdev, 0); | ||
79 | if (info->irq < 0) { | ||
80 | dev_err(&pdev->dev, "No IRQ resource!\n"); | ||
81 | err = -EINVAL; | ||
82 | goto out; | ||
83 | } | ||
84 | |||
85 | info->map = info->pm80x->regmap; | ||
86 | if (!info->map) { | ||
87 | dev_err(&pdev->dev, "no regmap!\n"); | ||
88 | err = -EINVAL; | ||
89 | goto out; | ||
90 | } | ||
91 | |||
92 | info->idev = input_allocate_device(); | ||
93 | if (!info->idev) { | ||
94 | dev_err(&pdev->dev, "Failed to allocate input dev\n"); | ||
95 | err = -ENOMEM; | ||
96 | goto out; | ||
97 | } | ||
98 | |||
99 | info->idev->name = "88pm80x_on"; | ||
100 | info->idev->phys = "88pm80x_on/input0"; | ||
101 | info->idev->id.bustype = BUS_I2C; | ||
102 | info->idev->dev.parent = &pdev->dev; | ||
103 | info->idev->evbit[0] = BIT_MASK(EV_KEY); | ||
104 | __set_bit(KEY_POWER, info->idev->keybit); | ||
105 | |||
106 | err = pm80x_request_irq(info->pm80x, info->irq, pm80x_onkey_handler, | ||
107 | IRQF_ONESHOT, "onkey", info); | ||
108 | if (err < 0) { | ||
109 | dev_err(&pdev->dev, "Failed to request IRQ: #%d: %d\n", | ||
110 | info->irq, err); | ||
111 | goto out_reg; | ||
112 | } | ||
113 | |||
114 | err = input_register_device(info->idev); | ||
115 | if (err) { | ||
116 | dev_err(&pdev->dev, "Can't register input device: %d\n", err); | ||
117 | goto out_irq; | ||
118 | } | ||
119 | |||
120 | platform_set_drvdata(pdev, info); | ||
121 | |||
122 | /* Enable long onkey detection */ | ||
123 | regmap_update_bits(info->map, PM800_RTC_MISC4, PM800_LONG_ONKEY_EN, | ||
124 | PM800_LONG_ONKEY_EN); | ||
125 | /* Set 8-second interval */ | ||
126 | regmap_update_bits(info->map, PM800_RTC_MISC3, | ||
127 | PM800_LONKEY_PRESS_TIME_MASK, | ||
128 | PM800_LONKEY_PRESS_TIME); | ||
129 | |||
130 | device_init_wakeup(&pdev->dev, 1); | ||
131 | return 0; | ||
132 | |||
133 | out_irq: | ||
134 | pm80x_free_irq(info->pm80x, info->irq, info); | ||
135 | out_reg: | ||
136 | input_free_device(info->idev); | ||
137 | out: | ||
138 | kfree(info); | ||
139 | return err; | ||
140 | } | ||
141 | |||
142 | static int __devexit pm80x_onkey_remove(struct platform_device *pdev) | ||
143 | { | ||
144 | struct pm80x_onkey_info *info = platform_get_drvdata(pdev); | ||
145 | |||
146 | device_init_wakeup(&pdev->dev, 0); | ||
147 | pm80x_free_irq(info->pm80x, info->irq, info); | ||
148 | input_unregister_device(info->idev); | ||
149 | kfree(info); | ||
150 | return 0; | ||
151 | } | ||
152 | |||
153 | static struct platform_driver pm80x_onkey_driver = { | ||
154 | .driver = { | ||
155 | .name = "88pm80x-onkey", | ||
156 | .owner = THIS_MODULE, | ||
157 | .pm = &pm80x_onkey_pm_ops, | ||
158 | }, | ||
159 | .probe = pm80x_onkey_probe, | ||
160 | .remove = __devexit_p(pm80x_onkey_remove), | ||
161 | }; | ||
162 | |||
163 | module_platform_driver(pm80x_onkey_driver); | ||
164 | |||
165 | MODULE_LICENSE("GPL"); | ||
166 | MODULE_DESCRIPTION("Marvell 88PM80x ONKEY driver"); | ||
167 | MODULE_AUTHOR("Qiao Zhou <zhouqiao@marvell.com>"); | ||
168 | MODULE_ALIAS("platform:88pm80x-onkey"); | ||
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 7faf4a7fcaa9..7c0f1ecfdd7a 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig | |||
@@ -22,6 +22,16 @@ config INPUT_88PM860X_ONKEY | |||
22 | To compile this driver as a module, choose M here: the module | 22 | To compile this driver as a module, choose M here: the module |
23 | will be called 88pm860x_onkey. | 23 | will be called 88pm860x_onkey. |
24 | 24 | ||
25 | config INPUT_88PM80X_ONKEY | ||
26 | tristate "88PM80x ONKEY support" | ||
27 | depends on MFD_88PM800 | ||
28 | help | ||
29 | Support the ONKEY of Marvell 88PM80x PMICs as an input device | ||
30 | reporting power button status. | ||
31 | |||
32 | To compile this driver as a module, choose M here: the module | ||
33 | will be called 88pm80x_onkey. | ||
34 | |||
25 | config INPUT_AB8500_PONKEY | 35 | config INPUT_AB8500_PONKEY |
26 | tristate "AB8500 Pon (PowerOn) Key" | 36 | tristate "AB8500 Pon (PowerOn) Key" |
27 | depends on AB8500_CORE | 37 | depends on AB8500_CORE |
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index f55cdf4916fa..83fe6f5b77d1 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile | |||
@@ -5,6 +5,7 @@ | |||
5 | # Each configuration option enables a list of files. | 5 | # Each configuration option enables a list of files. |
6 | 6 | ||
7 | obj-$(CONFIG_INPUT_88PM860X_ONKEY) += 88pm860x_onkey.o | 7 | obj-$(CONFIG_INPUT_88PM860X_ONKEY) += 88pm860x_onkey.o |
8 | obj-$(CONFIG_INPUT_88PM80X_ONKEY) += 88pm80x_onkey.o | ||
8 | obj-$(CONFIG_INPUT_AB8500_PONKEY) += ab8500-ponkey.o | 9 | obj-$(CONFIG_INPUT_AB8500_PONKEY) += ab8500-ponkey.o |
9 | obj-$(CONFIG_INPUT_AD714X) += ad714x.o | 10 | obj-$(CONFIG_INPUT_AD714X) += ad714x.o |
10 | obj-$(CONFIG_INPUT_AD714X_I2C) += ad714x-i2c.o | 11 | obj-$(CONFIG_INPUT_AD714X_I2C) += ad714x-i2c.o |
diff --git a/drivers/input/misc/ab8500-ponkey.c b/drivers/input/misc/ab8500-ponkey.c index 350fd0c385d2..f06231b7cab1 100644 --- a/drivers/input/misc/ab8500-ponkey.c +++ b/drivers/input/misc/ab8500-ponkey.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/input.h> | 13 | #include <linux/input.h> |
14 | #include <linux/interrupt.h> | 14 | #include <linux/interrupt.h> |
15 | #include <linux/mfd/abx500/ab8500.h> | 15 | #include <linux/mfd/abx500/ab8500.h> |
16 | #include <linux/of.h> | ||
16 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
17 | 18 | ||
18 | /** | 19 | /** |
@@ -73,8 +74,8 @@ static int __devinit ab8500_ponkey_probe(struct platform_device *pdev) | |||
73 | 74 | ||
74 | ponkey->idev = input; | 75 | ponkey->idev = input; |
75 | ponkey->ab8500 = ab8500; | 76 | ponkey->ab8500 = ab8500; |
76 | ponkey->irq_dbf = irq_dbf; | 77 | ponkey->irq_dbf = ab8500_irq_get_virq(ab8500, irq_dbf); |
77 | ponkey->irq_dbr = irq_dbr; | 78 | ponkey->irq_dbr = ab8500_irq_get_virq(ab8500, irq_dbr); |
78 | 79 | ||
79 | input->name = "AB8500 POn(PowerOn) Key"; | 80 | input->name = "AB8500 POn(PowerOn) Key"; |
80 | input->dev.parent = &pdev->dev; | 81 | input->dev.parent = &pdev->dev; |
@@ -131,10 +132,18 @@ static int __devexit ab8500_ponkey_remove(struct platform_device *pdev) | |||
131 | return 0; | 132 | return 0; |
132 | } | 133 | } |
133 | 134 | ||
135 | #ifdef CONFIG_OF | ||
136 | static const struct of_device_id ab8500_ponkey_match[] = { | ||
137 | { .compatible = "stericsson,ab8500-ponkey", }, | ||
138 | {} | ||
139 | }; | ||
140 | #endif | ||
141 | |||
134 | static struct platform_driver ab8500_ponkey_driver = { | 142 | static struct platform_driver ab8500_ponkey_driver = { |
135 | .driver = { | 143 | .driver = { |
136 | .name = "ab8500-poweron-key", | 144 | .name = "ab8500-poweron-key", |
137 | .owner = THIS_MODULE, | 145 | .owner = THIS_MODULE, |
146 | .of_match_table = of_match_ptr(ab8500_ponkey_match), | ||
138 | }, | 147 | }, |
139 | .probe = ab8500_ponkey_probe, | 148 | .probe = ab8500_ponkey_probe, |
140 | .remove = __devexit_p(ab8500_ponkey_remove), | 149 | .remove = __devexit_p(ab8500_ponkey_remove), |
diff --git a/drivers/input/misc/cma3000_d0x.c b/drivers/input/misc/cma3000_d0x.c index a3735a01e9fd..df9b756594f8 100644 --- a/drivers/input/misc/cma3000_d0x.c +++ b/drivers/input/misc/cma3000_d0x.c | |||
@@ -58,7 +58,7 @@ | |||
58 | 58 | ||
59 | /* | 59 | /* |
60 | * Bit weights in mg for bit 0, other bits need | 60 | * Bit weights in mg for bit 0, other bits need |
61 | * multipy factor 2^n. Eight bit is the sign bit. | 61 | * multiply factor 2^n. Eight bit is the sign bit. |
62 | */ | 62 | */ |
63 | #define BIT_TO_2G 18 | 63 | #define BIT_TO_2G 18 |
64 | #define BIT_TO_8G 71 | 64 | #define BIT_TO_8G 71 |
diff --git a/drivers/input/misc/twl6040-vibra.c b/drivers/input/misc/twl6040-vibra.c index c34f6c0371c4..c8a288ae1d5b 100644 --- a/drivers/input/misc/twl6040-vibra.c +++ b/drivers/input/misc/twl6040-vibra.c | |||
@@ -251,7 +251,6 @@ static int twl6040_vibra_suspend(struct device *dev) | |||
251 | 251 | ||
252 | return 0; | 252 | return 0; |
253 | } | 253 | } |
254 | |||
255 | #endif | 254 | #endif |
256 | 255 | ||
257 | static SIMPLE_DEV_PM_OPS(twl6040_vibra_pm_ops, twl6040_vibra_suspend, NULL); | 256 | static SIMPLE_DEV_PM_OPS(twl6040_vibra_pm_ops, twl6040_vibra_suspend, NULL); |
@@ -259,13 +258,19 @@ static SIMPLE_DEV_PM_OPS(twl6040_vibra_pm_ops, twl6040_vibra_suspend, NULL); | |||
259 | static int __devinit twl6040_vibra_probe(struct platform_device *pdev) | 258 | static int __devinit twl6040_vibra_probe(struct platform_device *pdev) |
260 | { | 259 | { |
261 | struct twl6040_vibra_data *pdata = pdev->dev.platform_data; | 260 | struct twl6040_vibra_data *pdata = pdev->dev.platform_data; |
262 | struct device_node *node = pdev->dev.of_node; | 261 | struct device *twl6040_core_dev = pdev->dev.parent; |
262 | struct device_node *twl6040_core_node = NULL; | ||
263 | struct vibra_info *info; | 263 | struct vibra_info *info; |
264 | int vddvibl_uV = 0; | 264 | int vddvibl_uV = 0; |
265 | int vddvibr_uV = 0; | 265 | int vddvibr_uV = 0; |
266 | int ret; | 266 | int ret; |
267 | 267 | ||
268 | if (!pdata && !node) { | 268 | #ifdef CONFIG_OF |
269 | twl6040_core_node = of_find_node_by_name(twl6040_core_dev->of_node, | ||
270 | "vibra"); | ||
271 | #endif | ||
272 | |||
273 | if (!pdata && !twl6040_core_node) { | ||
269 | dev_err(&pdev->dev, "platform_data not available\n"); | 274 | dev_err(&pdev->dev, "platform_data not available\n"); |
270 | return -EINVAL; | 275 | return -EINVAL; |
271 | } | 276 | } |
@@ -287,14 +292,18 @@ static int __devinit twl6040_vibra_probe(struct platform_device *pdev) | |||
287 | vddvibl_uV = pdata->vddvibl_uV; | 292 | vddvibl_uV = pdata->vddvibl_uV; |
288 | vddvibr_uV = pdata->vddvibr_uV; | 293 | vddvibr_uV = pdata->vddvibr_uV; |
289 | } else { | 294 | } else { |
290 | of_property_read_u32(node, "vibldrv_res", &info->vibldrv_res); | 295 | of_property_read_u32(twl6040_core_node, "ti,vibldrv-res", |
291 | of_property_read_u32(node, "vibrdrv_res", &info->vibrdrv_res); | 296 | &info->vibldrv_res); |
292 | of_property_read_u32(node, "viblmotor_res", | 297 | of_property_read_u32(twl6040_core_node, "ti,vibrdrv-res", |
298 | &info->vibrdrv_res); | ||
299 | of_property_read_u32(twl6040_core_node, "ti,viblmotor-res", | ||
293 | &info->viblmotor_res); | 300 | &info->viblmotor_res); |
294 | of_property_read_u32(node, "vibrmotor_res", | 301 | of_property_read_u32(twl6040_core_node, "ti,vibrmotor-res", |
295 | &info->vibrmotor_res); | 302 | &info->vibrmotor_res); |
296 | of_property_read_u32(node, "vddvibl_uV", &vddvibl_uV); | 303 | of_property_read_u32(twl6040_core_node, "ti,vddvibl-uV", |
297 | of_property_read_u32(node, "vddvibr_uV", &vddvibr_uV); | 304 | &vddvibl_uV); |
305 | of_property_read_u32(twl6040_core_node, "ti,vddvibr-uV", | ||
306 | &vddvibr_uV); | ||
298 | } | 307 | } |
299 | 308 | ||
300 | if ((!info->vibldrv_res && !info->viblmotor_res) || | 309 | if ((!info->vibldrv_res && !info->viblmotor_res) || |
@@ -351,8 +360,12 @@ static int __devinit twl6040_vibra_probe(struct platform_device *pdev) | |||
351 | 360 | ||
352 | info->supplies[0].supply = "vddvibl"; | 361 | info->supplies[0].supply = "vddvibl"; |
353 | info->supplies[1].supply = "vddvibr"; | 362 | info->supplies[1].supply = "vddvibr"; |
354 | ret = regulator_bulk_get(info->dev, ARRAY_SIZE(info->supplies), | 363 | /* |
355 | info->supplies); | 364 | * When booted with Device tree the regulators are attached to the |
365 | * parent device (twl6040 MFD core) | ||
366 | */ | ||
367 | ret = regulator_bulk_get(pdata ? info->dev : twl6040_core_dev, | ||
368 | ARRAY_SIZE(info->supplies), info->supplies); | ||
356 | if (ret) { | 369 | if (ret) { |
357 | dev_err(info->dev, "couldn't get regulators %d\n", ret); | 370 | dev_err(info->dev, "couldn't get regulators %d\n", ret); |
358 | goto err_regulator; | 371 | goto err_regulator; |
@@ -418,12 +431,6 @@ static int __devexit twl6040_vibra_remove(struct platform_device *pdev) | |||
418 | return 0; | 431 | return 0; |
419 | } | 432 | } |
420 | 433 | ||
421 | static const struct of_device_id twl6040_vibra_of_match[] = { | ||
422 | {.compatible = "ti,twl6040-vibra", }, | ||
423 | { }, | ||
424 | }; | ||
425 | MODULE_DEVICE_TABLE(of, twl6040_vibra_of_match); | ||
426 | |||
427 | static struct platform_driver twl6040_vibra_driver = { | 434 | static struct platform_driver twl6040_vibra_driver = { |
428 | .probe = twl6040_vibra_probe, | 435 | .probe = twl6040_vibra_probe, |
429 | .remove = __devexit_p(twl6040_vibra_remove), | 436 | .remove = __devexit_p(twl6040_vibra_remove), |
@@ -431,7 +438,6 @@ static struct platform_driver twl6040_vibra_driver = { | |||
431 | .name = "twl6040-vibra", | 438 | .name = "twl6040-vibra", |
432 | .owner = THIS_MODULE, | 439 | .owner = THIS_MODULE, |
433 | .pm = &twl6040_vibra_pm_ops, | 440 | .pm = &twl6040_vibra_pm_ops, |
434 | .of_match_table = twl6040_vibra_of_match, | ||
435 | }, | 441 | }, |
436 | }; | 442 | }; |
437 | module_platform_driver(twl6040_vibra_driver); | 443 | module_platform_driver(twl6040_vibra_driver); |
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c index c703d53be3a0..14eaecea2b70 100644 --- a/drivers/input/mouse/synaptics.c +++ b/drivers/input/mouse/synaptics.c | |||
@@ -40,11 +40,27 @@ | |||
40 | * Note that newer firmware allows querying device for maximum useable | 40 | * Note that newer firmware allows querying device for maximum useable |
41 | * coordinates. | 41 | * coordinates. |
42 | */ | 42 | */ |
43 | #define XMIN 0 | ||
44 | #define XMAX 6143 | ||
45 | #define YMIN 0 | ||
46 | #define YMAX 6143 | ||
43 | #define XMIN_NOMINAL 1472 | 47 | #define XMIN_NOMINAL 1472 |
44 | #define XMAX_NOMINAL 5472 | 48 | #define XMAX_NOMINAL 5472 |
45 | #define YMIN_NOMINAL 1408 | 49 | #define YMIN_NOMINAL 1408 |
46 | #define YMAX_NOMINAL 4448 | 50 | #define YMAX_NOMINAL 4448 |
47 | 51 | ||
52 | /* Size in bits of absolute position values reported by the hardware */ | ||
53 | #define ABS_POS_BITS 13 | ||
54 | |||
55 | /* | ||
56 | * Any position values from the hardware above the following limits are | ||
57 | * treated as "wrapped around negative" values that have been truncated to | ||
58 | * the 13-bit reporting range of the hardware. These are just reasonable | ||
59 | * guesses and can be adjusted if hardware is found that operates outside | ||
60 | * of these parameters. | ||
61 | */ | ||
62 | #define X_MAX_POSITIVE (((1 << ABS_POS_BITS) + XMAX) / 2) | ||
63 | #define Y_MAX_POSITIVE (((1 << ABS_POS_BITS) + YMAX) / 2) | ||
48 | 64 | ||
49 | /***************************************************************************** | 65 | /***************************************************************************** |
50 | * Stuff we need even when we do not want native Synaptics support | 66 | * Stuff we need even when we do not want native Synaptics support |
@@ -139,6 +155,35 @@ static int synaptics_model_id(struct psmouse *psmouse) | |||
139 | } | 155 | } |
140 | 156 | ||
141 | /* | 157 | /* |
158 | * Read the board id from the touchpad | ||
159 | * The board id is encoded in the "QUERY MODES" response | ||
160 | */ | ||
161 | static int synaptics_board_id(struct psmouse *psmouse) | ||
162 | { | ||
163 | struct synaptics_data *priv = psmouse->private; | ||
164 | unsigned char bid[3]; | ||
165 | |||
166 | if (synaptics_send_cmd(psmouse, SYN_QUE_MODES, bid)) | ||
167 | return -1; | ||
168 | priv->board_id = ((bid[0] & 0xfc) << 6) | bid[1]; | ||
169 | return 0; | ||
170 | } | ||
171 | |||
172 | /* | ||
173 | * Read the firmware id from the touchpad | ||
174 | */ | ||
175 | static int synaptics_firmware_id(struct psmouse *psmouse) | ||
176 | { | ||
177 | struct synaptics_data *priv = psmouse->private; | ||
178 | unsigned char fwid[3]; | ||
179 | |||
180 | if (synaptics_send_cmd(psmouse, SYN_QUE_FIRMWARE_ID, fwid)) | ||
181 | return -1; | ||
182 | priv->firmware_id = (fwid[0] << 16) | (fwid[1] << 8) | fwid[2]; | ||
183 | return 0; | ||
184 | } | ||
185 | |||
186 | /* | ||
142 | * Read the capability-bits from the touchpad | 187 | * Read the capability-bits from the touchpad |
143 | * see also the SYN_CAP_* macros | 188 | * see also the SYN_CAP_* macros |
144 | */ | 189 | */ |
@@ -261,6 +306,10 @@ static int synaptics_query_hardware(struct psmouse *psmouse) | |||
261 | return -1; | 306 | return -1; |
262 | if (synaptics_model_id(psmouse)) | 307 | if (synaptics_model_id(psmouse)) |
263 | return -1; | 308 | return -1; |
309 | if (synaptics_firmware_id(psmouse)) | ||
310 | return -1; | ||
311 | if (synaptics_board_id(psmouse)) | ||
312 | return -1; | ||
264 | if (synaptics_capability(psmouse)) | 313 | if (synaptics_capability(psmouse)) |
265 | return -1; | 314 | return -1; |
266 | if (synaptics_resolution(psmouse)) | 315 | if (synaptics_resolution(psmouse)) |
@@ -555,6 +604,12 @@ static int synaptics_parse_hw_state(const unsigned char buf[], | |||
555 | hw->right = (buf[0] & 0x02) ? 1 : 0; | 604 | hw->right = (buf[0] & 0x02) ? 1 : 0; |
556 | } | 605 | } |
557 | 606 | ||
607 | /* Convert wrap-around values to negative */ | ||
608 | if (hw->x > X_MAX_POSITIVE) | ||
609 | hw->x -= 1 << ABS_POS_BITS; | ||
610 | if (hw->y > Y_MAX_POSITIVE) | ||
611 | hw->y -= 1 << ABS_POS_BITS; | ||
612 | |||
558 | return 0; | 613 | return 0; |
559 | } | 614 | } |
560 | 615 | ||
@@ -1435,11 +1490,12 @@ static int __synaptics_init(struct psmouse *psmouse, bool absolute_mode) | |||
1435 | priv->pkt_type = SYN_MODEL_NEWABS(priv->model_id) ? SYN_NEWABS : SYN_OLDABS; | 1490 | priv->pkt_type = SYN_MODEL_NEWABS(priv->model_id) ? SYN_NEWABS : SYN_OLDABS; |
1436 | 1491 | ||
1437 | psmouse_info(psmouse, | 1492 | psmouse_info(psmouse, |
1438 | "Touchpad model: %ld, fw: %ld.%ld, id: %#lx, caps: %#lx/%#lx/%#lx\n", | 1493 | "Touchpad model: %ld, fw: %ld.%ld, id: %#lx, caps: %#lx/%#lx/%#lx, board id: %lu, fw id: %lu\n", |
1439 | SYN_ID_MODEL(priv->identity), | 1494 | SYN_ID_MODEL(priv->identity), |
1440 | SYN_ID_MAJOR(priv->identity), SYN_ID_MINOR(priv->identity), | 1495 | SYN_ID_MAJOR(priv->identity), SYN_ID_MINOR(priv->identity), |
1441 | priv->model_id, | 1496 | priv->model_id, |
1442 | priv->capabilities, priv->ext_cap, priv->ext_cap_0c); | 1497 | priv->capabilities, priv->ext_cap, priv->ext_cap_0c, |
1498 | priv->board_id, priv->firmware_id); | ||
1443 | 1499 | ||
1444 | set_input_params(psmouse->dev, priv); | 1500 | set_input_params(psmouse->dev, priv); |
1445 | 1501 | ||
diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h index fd26ccca13d7..e594af0b264b 100644 --- a/drivers/input/mouse/synaptics.h +++ b/drivers/input/mouse/synaptics.h | |||
@@ -18,6 +18,7 @@ | |||
18 | #define SYN_QUE_SERIAL_NUMBER_SUFFIX 0x07 | 18 | #define SYN_QUE_SERIAL_NUMBER_SUFFIX 0x07 |
19 | #define SYN_QUE_RESOLUTION 0x08 | 19 | #define SYN_QUE_RESOLUTION 0x08 |
20 | #define SYN_QUE_EXT_CAPAB 0x09 | 20 | #define SYN_QUE_EXT_CAPAB 0x09 |
21 | #define SYN_QUE_FIRMWARE_ID 0x0a | ||
21 | #define SYN_QUE_EXT_CAPAB_0C 0x0c | 22 | #define SYN_QUE_EXT_CAPAB_0C 0x0c |
22 | #define SYN_QUE_EXT_MAX_COORDS 0x0d | 23 | #define SYN_QUE_EXT_MAX_COORDS 0x0d |
23 | #define SYN_QUE_EXT_MIN_COORDS 0x0f | 24 | #define SYN_QUE_EXT_MIN_COORDS 0x0f |
@@ -148,6 +149,8 @@ struct synaptics_hw_state { | |||
148 | struct synaptics_data { | 149 | struct synaptics_data { |
149 | /* Data read from the touchpad */ | 150 | /* Data read from the touchpad */ |
150 | unsigned long int model_id; /* Model-ID */ | 151 | unsigned long int model_id; /* Model-ID */ |
152 | unsigned long int firmware_id; /* Firmware-ID */ | ||
153 | unsigned long int board_id; /* Board-ID */ | ||
151 | unsigned long int capabilities; /* Capabilities */ | 154 | unsigned long int capabilities; /* Capabilities */ |
152 | unsigned long int ext_cap; /* Extended Capabilities */ | 155 | unsigned long int ext_cap; /* Extended Capabilities */ |
153 | unsigned long int ext_cap_0c; /* Ext Caps from 0x0c query */ | 156 | unsigned long int ext_cap_0c; /* Ext Caps from 0x0c query */ |
diff --git a/drivers/input/mouse/synaptics_usb.c b/drivers/input/mouse/synaptics_usb.c index 3c5eaaa5d154..64cf34ea7604 100644 --- a/drivers/input/mouse/synaptics_usb.c +++ b/drivers/input/mouse/synaptics_usb.c | |||
@@ -364,7 +364,7 @@ static int synusb_probe(struct usb_interface *intf, | |||
364 | le16_to_cpu(udev->descriptor.idProduct)); | 364 | le16_to_cpu(udev->descriptor.idProduct)); |
365 | 365 | ||
366 | if (synusb->flags & SYNUSB_STICK) | 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 | usb_make_path(udev, synusb->phys, sizeof(synusb->phys)); | 369 | usb_make_path(udev, synusb->phys, sizeof(synusb->phys)); |
370 | strlcat(synusb->phys, "/input0", sizeof(synusb->phys)); | 370 | strlcat(synusb->phys, "/input0", sizeof(synusb->phys)); |
diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c index 09a089996ded..d7a7e54f6465 100644 --- a/drivers/input/serio/hp_sdc.c +++ b/drivers/input/serio/hp_sdc.c | |||
@@ -878,7 +878,7 @@ static int __init hp_sdc_init(void) | |||
878 | #endif | 878 | #endif |
879 | 879 | ||
880 | errstr = "IRQ not available for"; | 880 | errstr = "IRQ not available for"; |
881 | if (request_irq(hp_sdc.irq, &hp_sdc_isr, IRQF_SHARED|IRQF_SAMPLE_RANDOM, | 881 | if (request_irq(hp_sdc.irq, &hp_sdc_isr, IRQF_SHARED, |
882 | "HP SDC", &hp_sdc)) | 882 | "HP SDC", &hp_sdc)) |
883 | goto err1; | 883 | goto err1; |
884 | 884 | ||
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index 5ec774d6c82b..6918773ce024 100644 --- a/drivers/input/serio/i8042-x86ia64io.h +++ b/drivers/input/serio/i8042-x86ia64io.h | |||
@@ -177,6 +177,20 @@ static const struct dmi_system_id __initconst i8042_dmi_noloop_table[] = { | |||
177 | }, | 177 | }, |
178 | }, | 178 | }, |
179 | { | 179 | { |
180 | /* Gigabyte T1005 - defines wrong chassis type ("Other") */ | ||
181 | .matches = { | ||
182 | DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"), | ||
183 | DMI_MATCH(DMI_PRODUCT_NAME, "T1005"), | ||
184 | }, | ||
185 | }, | ||
186 | { | ||
187 | /* Gigabyte T1005M/P - defines wrong chassis type ("Other") */ | ||
188 | .matches = { | ||
189 | DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"), | ||
190 | DMI_MATCH(DMI_PRODUCT_NAME, "T1005M/P"), | ||
191 | }, | ||
192 | }, | ||
193 | { | ||
180 | .matches = { | 194 | .matches = { |
181 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), | 195 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), |
182 | DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv9700"), | 196 | DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv9700"), |
diff --git a/drivers/input/tablet/hanwang.c b/drivers/input/tablet/hanwang.c index b2db3cfe3084..5cc04124995c 100644 --- a/drivers/input/tablet/hanwang.c +++ b/drivers/input/tablet/hanwang.c | |||
@@ -63,6 +63,7 @@ MODULE_LICENSE(DRIVER_LICENSE); | |||
63 | enum hanwang_tablet_type { | 63 | enum hanwang_tablet_type { |
64 | HANWANG_ART_MASTER_III, | 64 | HANWANG_ART_MASTER_III, |
65 | HANWANG_ART_MASTER_HD, | 65 | HANWANG_ART_MASTER_HD, |
66 | HANWANG_ART_MASTER_II, | ||
66 | }; | 67 | }; |
67 | 68 | ||
68 | struct hanwang { | 69 | struct hanwang { |
@@ -99,6 +100,8 @@ static const struct hanwang_features features_array[] = { | |||
99 | ART_MASTER_PKGLEN_MAX, 0x7f00, 0x4f60, 0x3f, 0x7f, 2048 }, | 100 | ART_MASTER_PKGLEN_MAX, 0x7f00, 0x4f60, 0x3f, 0x7f, 2048 }, |
100 | { 0x8401, "Hanwang Art Master HD 5012", HANWANG_ART_MASTER_HD, | 101 | { 0x8401, "Hanwang Art Master HD 5012", HANWANG_ART_MASTER_HD, |
101 | ART_MASTER_PKGLEN_MAX, 0x678e, 0x4150, 0x3f, 0x7f, 1024 }, | 102 | ART_MASTER_PKGLEN_MAX, 0x678e, 0x4150, 0x3f, 0x7f, 1024 }, |
103 | { 0x8503, "Hanwang Art Master II", HANWANG_ART_MASTER_II, | ||
104 | ART_MASTER_PKGLEN_MAX, 0x27de, 0x1cfe, 0x3f, 0x7f, 1024 }, | ||
102 | }; | 105 | }; |
103 | 106 | ||
104 | static const int hw_eventtypes[] = { | 107 | static const int hw_eventtypes[] = { |
@@ -127,14 +130,30 @@ static void hanwang_parse_packet(struct hanwang *hanwang) | |||
127 | struct usb_device *dev = hanwang->usbdev; | 130 | struct usb_device *dev = hanwang->usbdev; |
128 | enum hanwang_tablet_type type = hanwang->features->type; | 131 | enum hanwang_tablet_type type = hanwang->features->type; |
129 | int i; | 132 | int i; |
130 | u16 x, y, p; | 133 | u16 p; |
134 | |||
135 | if (type == HANWANG_ART_MASTER_II) { | ||
136 | hanwang->current_tool = BTN_TOOL_PEN; | ||
137 | hanwang->current_id = STYLUS_DEVICE_ID; | ||
138 | } | ||
131 | 139 | ||
132 | switch (data[0]) { | 140 | switch (data[0]) { |
133 | case 0x02: /* data packet */ | 141 | case 0x02: /* data packet */ |
134 | switch (data[1]) { | 142 | switch (data[1]) { |
135 | case 0x80: /* tool prox out */ | 143 | case 0x80: /* tool prox out */ |
136 | hanwang->current_id = 0; | 144 | if (type != HANWANG_ART_MASTER_II) { |
137 | input_report_key(input_dev, hanwang->current_tool, 0); | 145 | hanwang->current_id = 0; |
146 | input_report_key(input_dev, | ||
147 | hanwang->current_tool, 0); | ||
148 | } | ||
149 | break; | ||
150 | |||
151 | case 0x00: /* artmaster ii pen leave */ | ||
152 | if (type == HANWANG_ART_MASTER_II) { | ||
153 | hanwang->current_id = 0; | ||
154 | input_report_key(input_dev, | ||
155 | hanwang->current_tool, 0); | ||
156 | } | ||
138 | break; | 157 | break; |
139 | 158 | ||
140 | case 0xc2: /* first time tool prox in */ | 159 | case 0xc2: /* first time tool prox in */ |
@@ -154,15 +173,12 @@ static void hanwang_parse_packet(struct hanwang *hanwang) | |||
154 | default: | 173 | default: |
155 | hanwang->current_id = 0; | 174 | hanwang->current_id = 0; |
156 | dev_dbg(&dev->dev, | 175 | dev_dbg(&dev->dev, |
157 | "unknown tablet tool %02x ", data[0]); | 176 | "unknown tablet tool %02x\n", data[0]); |
158 | break; | 177 | break; |
159 | } | 178 | } |
160 | break; | 179 | break; |
161 | 180 | ||
162 | default: /* tool data packet */ | 181 | default: /* tool data packet */ |
163 | x = (data[2] << 8) | data[3]; | ||
164 | y = (data[4] << 8) | data[5]; | ||
165 | |||
166 | switch (type) { | 182 | switch (type) { |
167 | case HANWANG_ART_MASTER_III: | 183 | case HANWANG_ART_MASTER_III: |
168 | p = (data[6] << 3) | | 184 | p = (data[6] << 3) | |
@@ -171,6 +187,7 @@ static void hanwang_parse_packet(struct hanwang *hanwang) | |||
171 | break; | 187 | break; |
172 | 188 | ||
173 | case HANWANG_ART_MASTER_HD: | 189 | case HANWANG_ART_MASTER_HD: |
190 | case HANWANG_ART_MASTER_II: | ||
174 | p = (data[7] >> 6) | (data[6] << 2); | 191 | p = (data[7] >> 6) | (data[6] << 2); |
175 | break; | 192 | break; |
176 | 193 | ||
@@ -180,17 +197,23 @@ static void hanwang_parse_packet(struct hanwang *hanwang) | |||
180 | } | 197 | } |
181 | 198 | ||
182 | input_report_abs(input_dev, ABS_X, | 199 | input_report_abs(input_dev, ABS_X, |
183 | le16_to_cpup((__le16 *)&x)); | 200 | be16_to_cpup((__be16 *)&data[2])); |
184 | input_report_abs(input_dev, ABS_Y, | 201 | input_report_abs(input_dev, ABS_Y, |
185 | le16_to_cpup((__le16 *)&y)); | 202 | be16_to_cpup((__be16 *)&data[4])); |
186 | input_report_abs(input_dev, ABS_PRESSURE, | 203 | input_report_abs(input_dev, ABS_PRESSURE, p); |
187 | le16_to_cpup((__le16 *)&p)); | ||
188 | input_report_abs(input_dev, ABS_TILT_X, data[7] & 0x3f); | 204 | input_report_abs(input_dev, ABS_TILT_X, data[7] & 0x3f); |
189 | input_report_abs(input_dev, ABS_TILT_Y, data[8] & 0x7f); | 205 | input_report_abs(input_dev, ABS_TILT_Y, data[8] & 0x7f); |
190 | input_report_key(input_dev, BTN_STYLUS, data[1] & 0x02); | 206 | input_report_key(input_dev, BTN_STYLUS, data[1] & 0x02); |
191 | input_report_key(input_dev, BTN_STYLUS2, data[1] & 0x04); | 207 | |
208 | if (type != HANWANG_ART_MASTER_II) | ||
209 | input_report_key(input_dev, BTN_STYLUS2, | ||
210 | data[1] & 0x04); | ||
211 | else | ||
212 | input_report_key(input_dev, BTN_TOOL_PEN, 1); | ||
213 | |||
192 | break; | 214 | break; |
193 | } | 215 | } |
216 | |||
194 | input_report_abs(input_dev, ABS_MISC, hanwang->current_id); | 217 | input_report_abs(input_dev, ABS_MISC, hanwang->current_id); |
195 | input_event(input_dev, EV_MSC, MSC_SERIAL, | 218 | input_event(input_dev, EV_MSC, MSC_SERIAL, |
196 | hanwang->features->pid); | 219 | hanwang->features->pid); |
@@ -202,8 +225,8 @@ static void hanwang_parse_packet(struct hanwang *hanwang) | |||
202 | 225 | ||
203 | switch (type) { | 226 | switch (type) { |
204 | case HANWANG_ART_MASTER_III: | 227 | case HANWANG_ART_MASTER_III: |
205 | input_report_key(input_dev, BTN_TOOL_FINGER, data[1] || | 228 | input_report_key(input_dev, BTN_TOOL_FINGER, |
206 | data[2] || data[3]); | 229 | data[1] || data[2] || data[3]); |
207 | input_report_abs(input_dev, ABS_WHEEL, data[1]); | 230 | input_report_abs(input_dev, ABS_WHEEL, data[1]); |
208 | input_report_key(input_dev, BTN_0, data[2]); | 231 | input_report_key(input_dev, BTN_0, data[2]); |
209 | for (i = 0; i < 8; i++) | 232 | for (i = 0; i < 8; i++) |
@@ -227,6 +250,10 @@ static void hanwang_parse_packet(struct hanwang *hanwang) | |||
227 | BTN_5 + i, data[6] & (1 << i)); | 250 | BTN_5 + i, data[6] & (1 << i)); |
228 | } | 251 | } |
229 | break; | 252 | break; |
253 | |||
254 | case HANWANG_ART_MASTER_II: | ||
255 | dev_dbg(&dev->dev, "error packet %02x\n", data[0]); | ||
256 | return; | ||
230 | } | 257 | } |
231 | 258 | ||
232 | input_report_abs(input_dev, ABS_MISC, hanwang->current_id); | 259 | input_report_abs(input_dev, ABS_MISC, hanwang->current_id); |
@@ -234,7 +261,7 @@ static void hanwang_parse_packet(struct hanwang *hanwang) | |||
234 | break; | 261 | break; |
235 | 262 | ||
236 | default: | 263 | default: |
237 | dev_dbg(&dev->dev, "error packet %02x ", data[0]); | 264 | dev_dbg(&dev->dev, "error packet %02x\n", data[0]); |
238 | break; | 265 | break; |
239 | } | 266 | } |
240 | 267 | ||
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index 8b31473a81fe..0d3219f29744 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c | |||
@@ -445,8 +445,7 @@ static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_feat | |||
445 | /* ask to report Wacom data */ | 445 | /* ask to report Wacom data */ |
446 | if (features->device_type == BTN_TOOL_FINGER) { | 446 | if (features->device_type == BTN_TOOL_FINGER) { |
447 | /* if it is an MT Tablet PC touch */ | 447 | /* if it is an MT Tablet PC touch */ |
448 | if (features->type == TABLETPC2FG || | 448 | if (features->type > TABLETPC) { |
449 | features->type == MTSCREEN) { | ||
450 | do { | 449 | do { |
451 | rep_data[0] = 3; | 450 | rep_data[0] = 3; |
452 | rep_data[1] = 4; | 451 | rep_data[1] = 4; |
@@ -465,7 +464,7 @@ static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_feat | |||
465 | } while ((error < 0 || rep_data[1] != 4) && | 464 | } while ((error < 0 || rep_data[1] != 4) && |
466 | limit++ < WAC_MSG_RETRIES); | 465 | limit++ < WAC_MSG_RETRIES); |
467 | } | 466 | } |
468 | } else if (features->type != TABLETPC && | 467 | } else if (features->type <= BAMBOO_PT && |
469 | features->type != WIRELESS && | 468 | features->type != WIRELESS && |
470 | features->device_type == BTN_TOOL_PEN) { | 469 | features->device_type == BTN_TOOL_PEN) { |
471 | do { | 470 | do { |
@@ -509,16 +508,13 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf, | |||
509 | if (intf->cur_altsetting->desc.bInterfaceNumber == 0) { | 508 | if (intf->cur_altsetting->desc.bInterfaceNumber == 0) { |
510 | features->device_type = 0; | 509 | features->device_type = 0; |
511 | } else if (intf->cur_altsetting->desc.bInterfaceNumber == 2) { | 510 | } else if (intf->cur_altsetting->desc.bInterfaceNumber == 2) { |
512 | features->device_type = BTN_TOOL_DOUBLETAP; | 511 | features->device_type = BTN_TOOL_FINGER; |
513 | features->pktlen = WACOM_PKGLEN_BBTOUCH3; | 512 | features->pktlen = WACOM_PKGLEN_BBTOUCH3; |
514 | } | 513 | } |
515 | } | 514 | } |
516 | 515 | ||
517 | /* only devices that support touch need to retrieve the info */ | 516 | /* only devices that support touch need to retrieve the info */ |
518 | if (features->type != TABLETPC && | 517 | if (features->type < BAMBOO_PT) { |
519 | features->type != TABLETPC2FG && | ||
520 | features->type != BAMBOO_PT && | ||
521 | features->type != MTSCREEN) { | ||
522 | goto out; | 518 | goto out; |
523 | } | 519 | } |
524 | 520 | ||
@@ -860,6 +856,7 @@ static int wacom_initialize_leds(struct wacom *wacom) | |||
860 | 856 | ||
861 | /* Initialize default values */ | 857 | /* Initialize default values */ |
862 | switch (wacom->wacom_wac.features.type) { | 858 | switch (wacom->wacom_wac.features.type) { |
859 | case INTUOS4S: | ||
863 | case INTUOS4: | 860 | case INTUOS4: |
864 | case INTUOS4L: | 861 | case INTUOS4L: |
865 | wacom->led.select[0] = 0; | 862 | wacom->led.select[0] = 0; |
@@ -913,6 +910,7 @@ static int wacom_initialize_leds(struct wacom *wacom) | |||
913 | static void wacom_destroy_leds(struct wacom *wacom) | 910 | static void wacom_destroy_leds(struct wacom *wacom) |
914 | { | 911 | { |
915 | switch (wacom->wacom_wac.features.type) { | 912 | switch (wacom->wacom_wac.features.type) { |
913 | case INTUOS4S: | ||
916 | case INTUOS4: | 914 | case INTUOS4: |
917 | case INTUOS4L: | 915 | case INTUOS4L: |
918 | sysfs_remove_group(&wacom->intf->dev.kobj, | 916 | sysfs_remove_group(&wacom->intf->dev.kobj, |
@@ -972,6 +970,10 @@ static int wacom_initialize_battery(struct wacom *wacom) | |||
972 | 970 | ||
973 | error = power_supply_register(&wacom->usbdev->dev, | 971 | error = power_supply_register(&wacom->usbdev->dev, |
974 | &wacom->battery); | 972 | &wacom->battery); |
973 | |||
974 | if (!error) | ||
975 | power_supply_powers(&wacom->battery, | ||
976 | &wacom->usbdev->dev); | ||
975 | } | 977 | } |
976 | 978 | ||
977 | return error; | 979 | return error; |
@@ -979,8 +981,11 @@ static int wacom_initialize_battery(struct wacom *wacom) | |||
979 | 981 | ||
980 | static void wacom_destroy_battery(struct wacom *wacom) | 982 | static void wacom_destroy_battery(struct wacom *wacom) |
981 | { | 983 | { |
982 | if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_MONITOR) | 984 | if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_MONITOR && |
985 | wacom->battery.dev) { | ||
983 | power_supply_unregister(&wacom->battery); | 986 | power_supply_unregister(&wacom->battery); |
987 | wacom->battery.dev = NULL; | ||
988 | } | ||
984 | } | 989 | } |
985 | 990 | ||
986 | static int wacom_register_input(struct wacom *wacom) | 991 | static int wacom_register_input(struct wacom *wacom) |
@@ -1027,23 +1032,30 @@ static void wacom_wireless_work(struct work_struct *work) | |||
1027 | struct wacom *wacom = container_of(work, struct wacom, work); | 1032 | struct wacom *wacom = container_of(work, struct wacom, work); |
1028 | struct usb_device *usbdev = wacom->usbdev; | 1033 | struct usb_device *usbdev = wacom->usbdev; |
1029 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | 1034 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
1035 | struct wacom *wacom1, *wacom2; | ||
1036 | struct wacom_wac *wacom_wac1, *wacom_wac2; | ||
1037 | int error; | ||
1030 | 1038 | ||
1031 | /* | 1039 | /* |
1032 | * Regardless if this is a disconnect or a new tablet, | 1040 | * Regardless if this is a disconnect or a new tablet, |
1033 | * remove any existing input devices. | 1041 | * remove any existing input and battery devices. |
1034 | */ | 1042 | */ |
1035 | 1043 | ||
1044 | wacom_destroy_battery(wacom); | ||
1045 | |||
1036 | /* Stylus interface */ | 1046 | /* Stylus interface */ |
1037 | wacom = usb_get_intfdata(usbdev->config->interface[1]); | 1047 | wacom1 = usb_get_intfdata(usbdev->config->interface[1]); |
1038 | if (wacom->wacom_wac.input) | 1048 | wacom_wac1 = &(wacom1->wacom_wac); |
1039 | input_unregister_device(wacom->wacom_wac.input); | 1049 | if (wacom_wac1->input) |
1040 | wacom->wacom_wac.input = NULL; | 1050 | input_unregister_device(wacom_wac1->input); |
1051 | wacom_wac1->input = NULL; | ||
1041 | 1052 | ||
1042 | /* Touch interface */ | 1053 | /* Touch interface */ |
1043 | wacom = usb_get_intfdata(usbdev->config->interface[2]); | 1054 | wacom2 = usb_get_intfdata(usbdev->config->interface[2]); |
1044 | if (wacom->wacom_wac.input) | 1055 | wacom_wac2 = &(wacom2->wacom_wac); |
1045 | input_unregister_device(wacom->wacom_wac.input); | 1056 | if (wacom_wac2->input) |
1046 | wacom->wacom_wac.input = NULL; | 1057 | input_unregister_device(wacom_wac2->input); |
1058 | wacom_wac2->input = NULL; | ||
1047 | 1059 | ||
1048 | if (wacom_wac->pid == 0) { | 1060 | if (wacom_wac->pid == 0) { |
1049 | dev_info(&wacom->intf->dev, "wireless tablet disconnected\n"); | 1061 | dev_info(&wacom->intf->dev, "wireless tablet disconnected\n"); |
@@ -1068,24 +1080,39 @@ static void wacom_wireless_work(struct work_struct *work) | |||
1068 | } | 1080 | } |
1069 | 1081 | ||
1070 | /* Stylus interface */ | 1082 | /* Stylus interface */ |
1071 | wacom = usb_get_intfdata(usbdev->config->interface[1]); | 1083 | wacom_wac1->features = |
1072 | wacom_wac = &wacom->wacom_wac; | ||
1073 | wacom_wac->features = | ||
1074 | *((struct wacom_features *)id->driver_info); | 1084 | *((struct wacom_features *)id->driver_info); |
1075 | wacom_wac->features.device_type = BTN_TOOL_PEN; | 1085 | wacom_wac1->features.device_type = BTN_TOOL_PEN; |
1076 | wacom_register_input(wacom); | 1086 | error = wacom_register_input(wacom1); |
1087 | if (error) | ||
1088 | goto fail1; | ||
1077 | 1089 | ||
1078 | /* Touch interface */ | 1090 | /* Touch interface */ |
1079 | wacom = usb_get_intfdata(usbdev->config->interface[2]); | 1091 | wacom_wac2->features = |
1080 | wacom_wac = &wacom->wacom_wac; | ||
1081 | wacom_wac->features = | ||
1082 | *((struct wacom_features *)id->driver_info); | 1092 | *((struct wacom_features *)id->driver_info); |
1083 | wacom_wac->features.pktlen = WACOM_PKGLEN_BBTOUCH3; | 1093 | wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3; |
1084 | wacom_wac->features.device_type = BTN_TOOL_FINGER; | 1094 | wacom_wac2->features.device_type = BTN_TOOL_FINGER; |
1085 | wacom_set_phy_from_res(&wacom_wac->features); | 1095 | wacom_set_phy_from_res(&wacom_wac2->features); |
1086 | wacom_wac->features.x_max = wacom_wac->features.y_max = 4096; | 1096 | wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096; |
1087 | wacom_register_input(wacom); | 1097 | error = wacom_register_input(wacom2); |
1098 | if (error) | ||
1099 | goto fail2; | ||
1100 | |||
1101 | error = wacom_initialize_battery(wacom); | ||
1102 | if (error) | ||
1103 | goto fail3; | ||
1088 | } | 1104 | } |
1105 | |||
1106 | return; | ||
1107 | |||
1108 | fail3: | ||
1109 | input_unregister_device(wacom_wac2->input); | ||
1110 | wacom_wac2->input = NULL; | ||
1111 | fail2: | ||
1112 | input_unregister_device(wacom_wac1->input); | ||
1113 | wacom_wac1->input = NULL; | ||
1114 | fail1: | ||
1115 | return; | ||
1089 | } | 1116 | } |
1090 | 1117 | ||
1091 | static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) | 1118 | static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) |
@@ -1149,10 +1176,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
1149 | features->device_type = BTN_TOOL_FINGER; | 1176 | features->device_type = BTN_TOOL_FINGER; |
1150 | features->pktlen = WACOM_PKGLEN_BBTOUCH3; | 1177 | features->pktlen = WACOM_PKGLEN_BBTOUCH3; |
1151 | 1178 | ||
1152 | features->x_phy = | 1179 | wacom_set_phy_from_res(features); |
1153 | (features->x_max * 100) / features->x_resolution; | ||
1154 | features->y_phy = | ||
1155 | (features->y_max * 100) / features->y_resolution; | ||
1156 | 1180 | ||
1157 | features->x_max = 4096; | 1181 | features->x_max = 4096; |
1158 | features->y_max = 4096; | 1182 | features->y_max = 4096; |
@@ -1188,14 +1212,10 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
1188 | if (error) | 1212 | if (error) |
1189 | goto fail4; | 1213 | goto fail4; |
1190 | 1214 | ||
1191 | error = wacom_initialize_battery(wacom); | ||
1192 | if (error) | ||
1193 | goto fail5; | ||
1194 | |||
1195 | if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) { | 1215 | if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) { |
1196 | error = wacom_register_input(wacom); | 1216 | error = wacom_register_input(wacom); |
1197 | if (error) | 1217 | if (error) |
1198 | goto fail6; | 1218 | goto fail5; |
1199 | } | 1219 | } |
1200 | 1220 | ||
1201 | /* Note that if query fails it is not a hard failure */ | 1221 | /* Note that if query fails it is not a hard failure */ |
@@ -1210,7 +1230,6 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
1210 | 1230 | ||
1211 | return 0; | 1231 | return 0; |
1212 | 1232 | ||
1213 | fail6: wacom_destroy_battery(wacom); | ||
1214 | fail5: wacom_destroy_leds(wacom); | 1233 | fail5: wacom_destroy_leds(wacom); |
1215 | fail4: wacom_remove_shared_data(wacom_wac); | 1234 | fail4: wacom_remove_shared_data(wacom_wac); |
1216 | fail3: usb_free_urb(wacom->irq); | 1235 | fail3: usb_free_urb(wacom->irq); |
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index 004bc1bb1544..532d067a9e07 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c | |||
@@ -248,7 +248,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom) | |||
248 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); | 248 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); |
249 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); | 249 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); |
250 | if (wacom->tool[0] != BTN_TOOL_MOUSE) { | 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 | input_report_key(input, BTN_TOUCH, data[1] & 0x01); | 252 | input_report_key(input, BTN_TOUCH, data[1] & 0x01); |
253 | input_report_key(input, BTN_STYLUS, data[1] & 0x02); | 253 | input_report_key(input, BTN_STYLUS, data[1] & 0x02); |
254 | input_report_key(input, BTN_STYLUS2, data[1] & 0x04); | 254 | input_report_key(input, BTN_STYLUS2, data[1] & 0x04); |
@@ -464,7 +464,7 @@ static void wacom_intuos_general(struct wacom_wac *wacom) | |||
464 | t = (data[6] << 2) | ((data[7] >> 6) & 3); | 464 | t = (data[6] << 2) | ((data[7] >> 6) & 3); |
465 | if ((features->type >= INTUOS4S && features->type <= INTUOS4L) || | 465 | if ((features->type >= INTUOS4S && features->type <= INTUOS4L) || |
466 | (features->type >= INTUOS5S && features->type <= INTUOS5L) || | 466 | (features->type >= INTUOS5S && features->type <= INTUOS5L) || |
467 | features->type == WACOM_21UX2 || features->type == WACOM_24HD) { | 467 | (features->type >= WACOM_21UX2 && features->type <= WACOM_24HD)) { |
468 | t = (t << 1) | (data[1] & 1); | 468 | t = (t << 1) | (data[1] & 1); |
469 | } | 469 | } |
470 | input_report_abs(input, ABS_PRESSURE, t); | 470 | input_report_abs(input, ABS_PRESSURE, t); |
@@ -614,7 +614,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom) | |||
614 | input_report_abs(input, ABS_MISC, 0); | 614 | input_report_abs(input, ABS_MISC, 0); |
615 | } | 615 | } |
616 | } else { | 616 | } else { |
617 | if (features->type == WACOM_21UX2) { | 617 | if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) { |
618 | input_report_key(input, BTN_0, (data[5] & 0x01)); | 618 | input_report_key(input, BTN_0, (data[5] & 0x01)); |
619 | input_report_key(input, BTN_1, (data[6] & 0x01)); | 619 | input_report_key(input, BTN_1, (data[6] & 0x01)); |
620 | input_report_key(input, BTN_2, (data[6] & 0x02)); | 620 | input_report_key(input, BTN_2, (data[6] & 0x02)); |
@@ -633,6 +633,12 @@ static int wacom_intuos_irq(struct wacom_wac *wacom) | |||
633 | input_report_key(input, BTN_Z, (data[8] & 0x20)); | 633 | input_report_key(input, BTN_Z, (data[8] & 0x20)); |
634 | input_report_key(input, BTN_BASE, (data[8] & 0x40)); | 634 | input_report_key(input, BTN_BASE, (data[8] & 0x40)); |
635 | input_report_key(input, BTN_BASE2, (data[8] & 0x80)); | 635 | input_report_key(input, BTN_BASE2, (data[8] & 0x80)); |
636 | |||
637 | if (features->type == WACOM_22HD) { | ||
638 | input_report_key(input, KEY_PROG1, data[9] & 0x01); | ||
639 | input_report_key(input, KEY_PROG2, data[9] & 0x02); | ||
640 | input_report_key(input, KEY_PROG3, data[9] & 0x04); | ||
641 | } | ||
636 | } else { | 642 | } else { |
637 | input_report_key(input, BTN_0, (data[5] & 0x01)); | 643 | input_report_key(input, BTN_0, (data[5] & 0x01)); |
638 | input_report_key(input, BTN_1, (data[5] & 0x02)); | 644 | input_report_key(input, BTN_1, (data[5] & 0x02)); |
@@ -888,7 +894,7 @@ static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len) | |||
888 | prox = data[0] & 0x01; | 894 | prox = data[0] & 0x01; |
889 | x = get_unaligned_le16(&data[1]); | 895 | x = get_unaligned_le16(&data[1]); |
890 | y = get_unaligned_le16(&data[3]); | 896 | y = get_unaligned_le16(&data[3]); |
891 | } else { /* with capacity */ | 897 | } else { |
892 | prox = data[1] & 0x01; | 898 | prox = data[1] & 0x01; |
893 | x = le16_to_cpup((__le16 *)&data[2]); | 899 | x = le16_to_cpup((__le16 *)&data[2]); |
894 | y = le16_to_cpup((__le16 *)&data[4]); | 900 | y = le16_to_cpup((__le16 *)&data[4]); |
@@ -961,6 +967,7 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len) | |||
961 | case WACOM_REPORT_TPC1FG: | 967 | case WACOM_REPORT_TPC1FG: |
962 | case WACOM_REPORT_TPCHID: | 968 | case WACOM_REPORT_TPCHID: |
963 | case WACOM_REPORT_TPCST: | 969 | case WACOM_REPORT_TPCST: |
970 | case WACOM_REPORT_TPC1FGE: | ||
964 | return wacom_tpc_single_touch(wacom, len); | 971 | return wacom_tpc_single_touch(wacom, len); |
965 | 972 | ||
966 | case WACOM_REPORT_TPCMT: | 973 | case WACOM_REPORT_TPCMT: |
@@ -1230,6 +1237,7 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len) | |||
1230 | case CINTIQ: | 1237 | case CINTIQ: |
1231 | case WACOM_BEE: | 1238 | case WACOM_BEE: |
1232 | case WACOM_21UX2: | 1239 | case WACOM_21UX2: |
1240 | case WACOM_22HD: | ||
1233 | case WACOM_24HD: | 1241 | case WACOM_24HD: |
1234 | sync = wacom_intuos_irq(wacom_wac); | 1242 | sync = wacom_intuos_irq(wacom_wac); |
1235 | break; | 1243 | break; |
@@ -1244,6 +1252,7 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len) | |||
1244 | break; | 1252 | break; |
1245 | 1253 | ||
1246 | case TABLETPC: | 1254 | case TABLETPC: |
1255 | case TABLETPCE: | ||
1247 | case TABLETPC2FG: | 1256 | case TABLETPC2FG: |
1248 | case MTSCREEN: | 1257 | case MTSCREEN: |
1249 | sync = wacom_tpc_irq(wacom_wac, len); | 1258 | sync = wacom_tpc_irq(wacom_wac, len); |
@@ -1317,10 +1326,8 @@ void wacom_setup_device_quirks(struct wacom_features *features) | |||
1317 | } | 1326 | } |
1318 | 1327 | ||
1319 | /* these device have multiple inputs */ | 1328 | /* these device have multiple inputs */ |
1320 | if (features->type == TABLETPC || features->type == TABLETPC2FG || | 1329 | if (features->type >= WIRELESS || |
1321 | features->type == BAMBOO_PT || features->type == WIRELESS || | 1330 | (features->type >= INTUOS5S && features->type <= INTUOS5L)) |
1322 | (features->type >= INTUOS5S && features->type <= INTUOS5L) || | ||
1323 | features->type == MTSCREEN) | ||
1324 | features->quirks |= WACOM_QUIRK_MULTI_INPUT; | 1331 | features->quirks |= WACOM_QUIRK_MULTI_INPUT; |
1325 | 1332 | ||
1326 | /* quirk for bamboo touch with 2 low res touches */ | 1333 | /* quirk for bamboo touch with 2 low res touches */ |
@@ -1432,6 +1439,12 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev, | |||
1432 | wacom_setup_cintiq(wacom_wac); | 1439 | wacom_setup_cintiq(wacom_wac); |
1433 | break; | 1440 | break; |
1434 | 1441 | ||
1442 | case WACOM_22HD: | ||
1443 | __set_bit(KEY_PROG1, input_dev->keybit); | ||
1444 | __set_bit(KEY_PROG2, input_dev->keybit); | ||
1445 | __set_bit(KEY_PROG3, input_dev->keybit); | ||
1446 | /* fall through */ | ||
1447 | |||
1435 | case WACOM_21UX2: | 1448 | case WACOM_21UX2: |
1436 | __set_bit(BTN_A, input_dev->keybit); | 1449 | __set_bit(BTN_A, input_dev->keybit); |
1437 | __set_bit(BTN_B, input_dev->keybit); | 1450 | __set_bit(BTN_B, input_dev->keybit); |
@@ -1547,10 +1560,8 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev, | |||
1547 | __set_bit(INPUT_PROP_POINTER, input_dev->propbit); | 1560 | __set_bit(INPUT_PROP_POINTER, input_dev->propbit); |
1548 | break; | 1561 | break; |
1549 | 1562 | ||
1550 | case TABLETPC2FG: | ||
1551 | case MTSCREEN: | 1563 | case MTSCREEN: |
1552 | if (features->device_type == BTN_TOOL_FINGER) { | 1564 | if (features->device_type == BTN_TOOL_FINGER) { |
1553 | |||
1554 | wacom_wac->slots = kmalloc(features->touch_max * | 1565 | wacom_wac->slots = kmalloc(features->touch_max * |
1555 | sizeof(int), | 1566 | sizeof(int), |
1556 | GFP_KERNEL); | 1567 | GFP_KERNEL); |
@@ -1559,7 +1570,11 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev, | |||
1559 | 1570 | ||
1560 | for (i = 0; i < features->touch_max; i++) | 1571 | for (i = 0; i < features->touch_max; i++) |
1561 | wacom_wac->slots[i] = -1; | 1572 | wacom_wac->slots[i] = -1; |
1573 | } | ||
1574 | /* fall through */ | ||
1562 | 1575 | ||
1576 | case TABLETPC2FG: | ||
1577 | if (features->device_type == BTN_TOOL_FINGER) { | ||
1563 | input_mt_init_slots(input_dev, features->touch_max); | 1578 | input_mt_init_slots(input_dev, features->touch_max); |
1564 | input_set_abs_params(input_dev, ABS_MT_TOOL_TYPE, | 1579 | input_set_abs_params(input_dev, ABS_MT_TOOL_TYPE, |
1565 | 0, MT_TOOL_MAX, 0, 0); | 1580 | 0, MT_TOOL_MAX, 0, 0); |
@@ -1571,6 +1586,7 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev, | |||
1571 | /* fall through */ | 1586 | /* fall through */ |
1572 | 1587 | ||
1573 | case TABLETPC: | 1588 | case TABLETPC: |
1589 | case TABLETPCE: | ||
1574 | __clear_bit(ABS_MISC, input_dev->absbit); | 1590 | __clear_bit(ABS_MISC, input_dev->absbit); |
1575 | 1591 | ||
1576 | __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); | 1592 | __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); |
@@ -1832,7 +1848,10 @@ static const struct wacom_features wacom_features_0x2A = | |||
1832 | { "Wacom Intuos5 M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047, | 1848 | { "Wacom Intuos5 M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047, |
1833 | 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; | 1849 | 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; |
1834 | static const struct wacom_features wacom_features_0xF4 = | 1850 | static const struct wacom_features wacom_features_0xF4 = |
1835 | { "Wacom Cintiq 24HD", WACOM_PKGLEN_INTUOS, 104480, 65600, 2047, | 1851 | { "Wacom Cintiq 24HD", WACOM_PKGLEN_INTUOS, 104480, 65600, 2047, |
1852 | 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; | ||
1853 | static const struct wacom_features wacom_features_0xF8 = | ||
1854 | { "Wacom Cintiq 24HD touch", WACOM_PKGLEN_INTUOS, 104480, 65600, 2047, | ||
1836 | 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; | 1855 | 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; |
1837 | static const struct wacom_features wacom_features_0x3F = | 1856 | static const struct wacom_features wacom_features_0x3F = |
1838 | { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023, | 1857 | { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023, |
@@ -1855,6 +1874,9 @@ static const struct wacom_features wacom_features_0xF0 = | |||
1855 | static const struct wacom_features wacom_features_0xCC = | 1874 | static const struct wacom_features wacom_features_0xCC = |
1856 | { "Wacom Cintiq 21UX2", WACOM_PKGLEN_INTUOS, 87200, 65600, 2047, | 1875 | { "Wacom Cintiq 21UX2", WACOM_PKGLEN_INTUOS, 87200, 65600, 2047, |
1857 | 63, WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; | 1876 | 63, WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; |
1877 | static const struct wacom_features wacom_features_0xFA = | ||
1878 | { "Wacom Cintiq 22HD", WACOM_PKGLEN_INTUOS, 95840, 54260, 2047, | ||
1879 | 63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; | ||
1858 | static const struct wacom_features wacom_features_0x90 = | 1880 | static const struct wacom_features wacom_features_0x90 = |
1859 | { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, | 1881 | { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, |
1860 | 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | 1882 | 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
@@ -1888,6 +1910,12 @@ static const struct wacom_features wacom_features_0xE6 = | |||
1888 | static const struct wacom_features wacom_features_0xEC = | 1910 | static const struct wacom_features wacom_features_0xEC = |
1889 | { "Wacom ISDv4 EC", WACOM_PKGLEN_GRAPHIRE, 25710, 14500, 255, | 1911 | { "Wacom ISDv4 EC", WACOM_PKGLEN_GRAPHIRE, 25710, 14500, 255, |
1890 | 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | 1912 | 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
1913 | static const struct wacom_features wacom_features_0xED = | ||
1914 | { "Wacom ISDv4 ED", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, | ||
1915 | 0, TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | ||
1916 | static const struct wacom_features wacom_features_0xEF = | ||
1917 | { "Wacom ISDv4 EF", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, | ||
1918 | 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | ||
1891 | static const struct wacom_features wacom_features_0x47 = | 1919 | static const struct wacom_features wacom_features_0x47 = |
1892 | { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, | 1920 | { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, |
1893 | 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | 1921 | 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
@@ -2062,8 +2090,12 @@ const struct usb_device_id wacom_ids[] = { | |||
2062 | { USB_DEVICE_WACOM(0xE5) }, | 2090 | { USB_DEVICE_WACOM(0xE5) }, |
2063 | { USB_DEVICE_WACOM(0xE6) }, | 2091 | { USB_DEVICE_WACOM(0xE6) }, |
2064 | { USB_DEVICE_WACOM(0xEC) }, | 2092 | { USB_DEVICE_WACOM(0xEC) }, |
2093 | { USB_DEVICE_WACOM(0xED) }, | ||
2094 | { USB_DEVICE_WACOM(0xEF) }, | ||
2065 | { USB_DEVICE_WACOM(0x47) }, | 2095 | { USB_DEVICE_WACOM(0x47) }, |
2066 | { USB_DEVICE_WACOM(0xF4) }, | 2096 | { USB_DEVICE_WACOM(0xF4) }, |
2097 | { USB_DEVICE_WACOM(0xF8) }, | ||
2098 | { USB_DEVICE_WACOM(0xFA) }, | ||
2067 | { USB_DEVICE_LENOVO(0x6004) }, | 2099 | { USB_DEVICE_LENOVO(0x6004) }, |
2068 | { } | 2100 | { } |
2069 | }; | 2101 | }; |
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h index 78fbd3f42009..96c185cc301e 100644 --- a/drivers/input/tablet/wacom_wac.h +++ b/drivers/input/tablet/wacom_wac.h | |||
@@ -48,6 +48,7 @@ | |||
48 | #define WACOM_REPORT_TPCMT 13 | 48 | #define WACOM_REPORT_TPCMT 13 |
49 | #define WACOM_REPORT_TPCHID 15 | 49 | #define WACOM_REPORT_TPCHID 15 |
50 | #define WACOM_REPORT_TPCST 16 | 50 | #define WACOM_REPORT_TPCST 16 |
51 | #define WACOM_REPORT_TPC1FGE 18 | ||
51 | 52 | ||
52 | /* device quirks */ | 53 | /* device quirks */ |
53 | #define WACOM_QUIRK_MULTI_INPUT 0x0001 | 54 | #define WACOM_QUIRK_MULTI_INPUT 0x0001 |
@@ -62,8 +63,6 @@ enum { | |||
62 | PTU, | 63 | PTU, |
63 | PL, | 64 | PL, |
64 | DTU, | 65 | DTU, |
65 | BAMBOO_PT, | ||
66 | WIRELESS, | ||
67 | INTUOS, | 66 | INTUOS, |
68 | INTUOS3S, | 67 | INTUOS3S, |
69 | INTUOS3, | 68 | INTUOS3, |
@@ -74,12 +73,16 @@ enum { | |||
74 | INTUOS5S, | 73 | INTUOS5S, |
75 | INTUOS5, | 74 | INTUOS5, |
76 | INTUOS5L, | 75 | INTUOS5L, |
77 | WACOM_24HD, | ||
78 | WACOM_21UX2, | 76 | WACOM_21UX2, |
77 | WACOM_22HD, | ||
78 | WACOM_24HD, | ||
79 | CINTIQ, | 79 | CINTIQ, |
80 | WACOM_BEE, | 80 | WACOM_BEE, |
81 | WACOM_MO, | 81 | WACOM_MO, |
82 | TABLETPC, | 82 | WIRELESS, |
83 | BAMBOO_PT, | ||
84 | TABLETPC, /* add new TPC below */ | ||
85 | TABLETPCE, | ||
83 | TABLETPC2FG, | 86 | TABLETPC2FG, |
84 | MTSCREEN, | 87 | MTSCREEN, |
85 | MAX_TYPE | 88 | MAX_TYPE |
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 98d263504eea..1ba232cbc09d 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig | |||
@@ -369,6 +369,18 @@ config TOUCHSCREEN_MCS5000 | |||
369 | To compile this driver as a module, choose M here: the | 369 | To compile this driver as a module, choose M here: the |
370 | module will be called mcs5000_ts. | 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 | config TOUCHSCREEN_MTOUCH | 384 | config TOUCHSCREEN_MTOUCH |
373 | tristate "MicroTouch serial touchscreens" | 385 | tristate "MicroTouch serial touchscreens" |
374 | select SERIO | 386 | select SERIO |
@@ -460,6 +472,19 @@ config TOUCHSCREEN_PENMOUNT | |||
460 | To compile this driver as a module, choose M here: the | 472 | To compile this driver as a module, choose M here: the |
461 | module will be called penmount. | 473 | module will be called penmount. |
462 | 474 | ||
475 | config TOUCHSCREEN_EDT_FT5X06 | ||
476 | tristate "EDT FocalTech FT5x06 I2C Touchscreen support" | ||
477 | depends on I2C | ||
478 | help | ||
479 | Say Y here if you have an EDT "Polytouch" touchscreen based | ||
480 | on the FocalTech FT5x06 family of controllers connected to | ||
481 | your system. | ||
482 | |||
483 | If unsure, say N. | ||
484 | |||
485 | To compile this driver as a module, choose M here: the | ||
486 | module will be called edt-ft5x06. | ||
487 | |||
463 | config TOUCHSCREEN_MIGOR | 488 | config TOUCHSCREEN_MIGOR |
464 | tristate "Renesas MIGO-R touchscreen" | 489 | tristate "Renesas MIGO-R touchscreen" |
465 | depends on SH_MIGOR && I2C | 490 | depends on SH_MIGOR && I2C |
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index eb8bfe1c1a46..178eb128d90f 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile | |||
@@ -24,6 +24,7 @@ obj-$(CONFIG_TOUCHSCREEN_CYTTSP_SPI) += cyttsp_spi.o | |||
24 | obj-$(CONFIG_TOUCHSCREEN_DA9034) += da9034-ts.o | 24 | obj-$(CONFIG_TOUCHSCREEN_DA9034) += da9034-ts.o |
25 | obj-$(CONFIG_TOUCHSCREEN_DA9052) += da9052_tsi.o | 25 | obj-$(CONFIG_TOUCHSCREEN_DA9052) += da9052_tsi.o |
26 | obj-$(CONFIG_TOUCHSCREEN_DYNAPRO) += dynapro.o | 26 | obj-$(CONFIG_TOUCHSCREEN_DYNAPRO) += dynapro.o |
27 | obj-$(CONFIG_TOUCHSCREEN_EDT_FT5X06) += edt-ft5x06.o | ||
27 | obj-$(CONFIG_TOUCHSCREEN_HAMPSHIRE) += hampshire.o | 28 | obj-$(CONFIG_TOUCHSCREEN_HAMPSHIRE) += hampshire.o |
28 | obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o | 29 | obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o |
29 | obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o | 30 | obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o |
@@ -38,6 +39,7 @@ obj-$(CONFIG_TOUCHSCREEN_MAX11801) += max11801_ts.o | |||
38 | obj-$(CONFIG_TOUCHSCREEN_MC13783) += mc13783_ts.o | 39 | obj-$(CONFIG_TOUCHSCREEN_MC13783) += mc13783_ts.o |
39 | obj-$(CONFIG_TOUCHSCREEN_MCS5000) += mcs5000_ts.o | 40 | obj-$(CONFIG_TOUCHSCREEN_MCS5000) += mcs5000_ts.o |
40 | obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o | 41 | obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o |
42 | obj-$(CONFIG_TOUCHSCREEN_MMS114) += mms114.o | ||
41 | obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o | 43 | obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o |
42 | obj-$(CONFIG_TOUCHSCREEN_MK712) += mk712.o | 44 | obj-$(CONFIG_TOUCHSCREEN_MK712) += mk712.o |
43 | obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680_ts_input.o | 45 | obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680_ts_input.o |
diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c index bd4eb4277697..facd3057b62d 100644 --- a/drivers/input/touchscreen/ad7879.c +++ b/drivers/input/touchscreen/ad7879.c | |||
@@ -118,6 +118,7 @@ struct ad7879 { | |||
118 | unsigned int irq; | 118 | unsigned int irq; |
119 | bool disabled; /* P: input->mutex */ | 119 | bool disabled; /* P: input->mutex */ |
120 | bool suspended; /* P: input->mutex */ | 120 | bool suspended; /* P: input->mutex */ |
121 | bool swap_xy; | ||
121 | u16 conversion_data[AD7879_NR_SENSE]; | 122 | u16 conversion_data[AD7879_NR_SENSE]; |
122 | char phys[32]; | 123 | char phys[32]; |
123 | u8 first_conversion_delay; | 124 | u8 first_conversion_delay; |
@@ -161,6 +162,9 @@ static int ad7879_report(struct ad7879 *ts) | |||
161 | z1 = ts->conversion_data[AD7879_SEQ_Z1] & MAX_12BIT; | 162 | z1 = ts->conversion_data[AD7879_SEQ_Z1] & MAX_12BIT; |
162 | z2 = ts->conversion_data[AD7879_SEQ_Z2] & MAX_12BIT; | 163 | z2 = ts->conversion_data[AD7879_SEQ_Z2] & MAX_12BIT; |
163 | 164 | ||
165 | if (ts->swap_xy) | ||
166 | swap(x, y); | ||
167 | |||
164 | /* | 168 | /* |
165 | * The samples processed here are already preprocessed by the AD7879. | 169 | * The samples processed here are already preprocessed by the AD7879. |
166 | * The preprocessing function consists of a median and an averaging | 170 | * The preprocessing function consists of a median and an averaging |
@@ -520,6 +524,7 @@ struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned int irq, | |||
520 | ts->dev = dev; | 524 | ts->dev = dev; |
521 | ts->input = input_dev; | 525 | ts->input = input_dev; |
522 | ts->irq = irq; | 526 | ts->irq = irq; |
527 | ts->swap_xy = pdata->swap_xy; | ||
523 | 528 | ||
524 | setup_timer(&ts->timer, ad7879_timer, (unsigned long) ts); | 529 | setup_timer(&ts->timer, ad7879_timer, (unsigned long) ts); |
525 | 530 | ||
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 25fd0561a17d..4623cc69fc60 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #define MXT_FW_NAME "maxtouch.fw" | 36 | #define MXT_FW_NAME "maxtouch.fw" |
37 | 37 | ||
38 | /* Registers */ | 38 | /* Registers */ |
39 | #define MXT_INFO 0x00 | ||
39 | #define MXT_FAMILY_ID 0x00 | 40 | #define MXT_FAMILY_ID 0x00 |
40 | #define MXT_VARIANT_ID 0x01 | 41 | #define MXT_VARIANT_ID 0x01 |
41 | #define MXT_VERSION 0x02 | 42 | #define MXT_VERSION 0x02 |
@@ -194,6 +195,7 @@ | |||
194 | #define MXT_BOOT_STATUS_MASK 0x3f | 195 | #define MXT_BOOT_STATUS_MASK 0x3f |
195 | 196 | ||
196 | /* Touch status */ | 197 | /* Touch status */ |
198 | #define MXT_UNGRIP (1 << 0) | ||
197 | #define MXT_SUPPRESS (1 << 1) | 199 | #define MXT_SUPPRESS (1 << 1) |
198 | #define MXT_AMP (1 << 2) | 200 | #define MXT_AMP (1 << 2) |
199 | #define MXT_VECTOR (1 << 3) | 201 | #define MXT_VECTOR (1 << 3) |
@@ -210,8 +212,6 @@ | |||
210 | /* Touchscreen absolute values */ | 212 | /* Touchscreen absolute values */ |
211 | #define MXT_MAX_AREA 0xff | 213 | #define MXT_MAX_AREA 0xff |
212 | 214 | ||
213 | #define MXT_MAX_FINGER 10 | ||
214 | |||
215 | struct mxt_info { | 215 | struct mxt_info { |
216 | u8 family_id; | 216 | u8 family_id; |
217 | u8 variant_id; | 217 | u8 variant_id; |
@@ -225,44 +225,37 @@ struct mxt_info { | |||
225 | struct mxt_object { | 225 | struct mxt_object { |
226 | u8 type; | 226 | u8 type; |
227 | u16 start_address; | 227 | u16 start_address; |
228 | u8 size; | 228 | u8 size; /* Size of each instance - 1 */ |
229 | u8 instances; | 229 | u8 instances; /* Number of instances - 1 */ |
230 | u8 num_report_ids; | 230 | u8 num_report_ids; |
231 | 231 | } __packed; | |
232 | /* to map object and message */ | ||
233 | u8 max_reportid; | ||
234 | }; | ||
235 | 232 | ||
236 | struct mxt_message { | 233 | struct mxt_message { |
237 | u8 reportid; | 234 | u8 reportid; |
238 | u8 message[7]; | 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 | /* Each client has this additional data */ | 238 | /* Each client has this additional data */ |
250 | struct mxt_data { | 239 | struct mxt_data { |
251 | struct i2c_client *client; | 240 | struct i2c_client *client; |
252 | struct input_dev *input_dev; | 241 | struct input_dev *input_dev; |
242 | char phys[64]; /* device physical location */ | ||
253 | const struct mxt_platform_data *pdata; | 243 | const struct mxt_platform_data *pdata; |
254 | struct mxt_object *object_table; | 244 | struct mxt_object *object_table; |
255 | struct mxt_info info; | 245 | struct mxt_info info; |
256 | struct mxt_finger finger[MXT_MAX_FINGER]; | ||
257 | unsigned int irq; | 246 | unsigned int irq; |
258 | unsigned int max_x; | 247 | unsigned int max_x; |
259 | unsigned int max_y; | 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 | static bool mxt_object_readable(unsigned int type) | 256 | static bool mxt_object_readable(unsigned int type) |
263 | { | 257 | { |
264 | switch (type) { | 258 | switch (type) { |
265 | case MXT_GEN_MESSAGE_T5: | ||
266 | case MXT_GEN_COMMAND_T6: | 259 | case MXT_GEN_COMMAND_T6: |
267 | case MXT_GEN_POWER_T7: | 260 | case MXT_GEN_POWER_T7: |
268 | case MXT_GEN_ACQUIRE_T8: | 261 | case MXT_GEN_ACQUIRE_T8: |
@@ -396,6 +389,7 @@ static int __mxt_read_reg(struct i2c_client *client, | |||
396 | { | 389 | { |
397 | struct i2c_msg xfer[2]; | 390 | struct i2c_msg xfer[2]; |
398 | u8 buf[2]; | 391 | u8 buf[2]; |
392 | int ret; | ||
399 | 393 | ||
400 | buf[0] = reg & 0xff; | 394 | buf[0] = reg & 0xff; |
401 | buf[1] = (reg >> 8) & 0xff; | 395 | buf[1] = (reg >> 8) & 0xff; |
@@ -412,12 +406,17 @@ static int __mxt_read_reg(struct i2c_client *client, | |||
412 | xfer[1].len = len; | 406 | xfer[1].len = len; |
413 | xfer[1].buf = val; | 407 | xfer[1].buf = val; |
414 | 408 | ||
415 | if (i2c_transfer(client->adapter, xfer, 2) != 2) { | 409 | ret = i2c_transfer(client->adapter, xfer, 2); |
416 | dev_err(&client->dev, "%s: i2c transfer failed\n", __func__); | 410 | if (ret == 2) { |
417 | return -EIO; | 411 | ret = 0; |
412 | } else { | ||
413 | if (ret >= 0) | ||
414 | ret = -EIO; | ||
415 | dev_err(&client->dev, "%s: i2c transfer failed (%d)\n", | ||
416 | __func__, ret); | ||
418 | } | 417 | } |
419 | 418 | ||
420 | return 0; | 419 | return ret; |
421 | } | 420 | } |
422 | 421 | ||
423 | static int mxt_read_reg(struct i2c_client *client, u16 reg, u8 *val) | 422 | static int mxt_read_reg(struct i2c_client *client, u16 reg, u8 *val) |
@@ -425,27 +424,39 @@ static int mxt_read_reg(struct i2c_client *client, u16 reg, u8 *val) | |||
425 | return __mxt_read_reg(client, reg, 1, val); | 424 | return __mxt_read_reg(client, reg, 1, val); |
426 | } | 425 | } |
427 | 426 | ||
428 | static int mxt_write_reg(struct i2c_client *client, u16 reg, u8 val) | 427 | static int __mxt_write_reg(struct i2c_client *client, u16 reg, u16 len, |
428 | const void *val) | ||
429 | { | 429 | { |
430 | u8 buf[3]; | 430 | u8 *buf; |
431 | size_t count; | ||
432 | int ret; | ||
433 | |||
434 | count = len + 2; | ||
435 | buf = kmalloc(count, GFP_KERNEL); | ||
436 | if (!buf) | ||
437 | return -ENOMEM; | ||
431 | 438 | ||
432 | buf[0] = reg & 0xff; | 439 | buf[0] = reg & 0xff; |
433 | buf[1] = (reg >> 8) & 0xff; | 440 | buf[1] = (reg >> 8) & 0xff; |
434 | buf[2] = val; | 441 | memcpy(&buf[2], val, len); |
435 | 442 | ||
436 | if (i2c_master_send(client, buf, 3) != 3) { | 443 | ret = i2c_master_send(client, buf, count); |
437 | dev_err(&client->dev, "%s: i2c send failed\n", __func__); | 444 | if (ret == count) { |
438 | return -EIO; | 445 | ret = 0; |
446 | } else { | ||
447 | if (ret >= 0) | ||
448 | ret = -EIO; | ||
449 | dev_err(&client->dev, "%s: i2c send failed (%d)\n", | ||
450 | __func__, ret); | ||
439 | } | 451 | } |
440 | 452 | ||
441 | return 0; | 453 | kfree(buf); |
454 | return ret; | ||
442 | } | 455 | } |
443 | 456 | ||
444 | static int mxt_read_object_table(struct i2c_client *client, | 457 | static int mxt_write_reg(struct i2c_client *client, u16 reg, u8 val) |
445 | u16 reg, u8 *object_buf) | ||
446 | { | 458 | { |
447 | return __mxt_read_reg(client, reg, MXT_OBJECT_SIZE, | 459 | return __mxt_write_reg(client, reg, 1, &val); |
448 | object_buf); | ||
449 | } | 460 | } |
450 | 461 | ||
451 | static struct mxt_object * | 462 | static struct mxt_object * |
@@ -479,20 +490,6 @@ static int mxt_read_message(struct mxt_data *data, | |||
479 | sizeof(struct mxt_message), message); | 490 | sizeof(struct mxt_message), message); |
480 | } | 491 | } |
481 | 492 | ||
482 | static int mxt_read_object(struct mxt_data *data, | ||
483 | u8 type, u8 offset, u8 *val) | ||
484 | { | ||
485 | struct mxt_object *object; | ||
486 | u16 reg; | ||
487 | |||
488 | object = mxt_get_object(data, type); | ||
489 | if (!object) | ||
490 | return -EINVAL; | ||
491 | |||
492 | reg = object->start_address; | ||
493 | return __mxt_read_reg(data->client, reg + offset, 1, val); | ||
494 | } | ||
495 | |||
496 | static int mxt_write_object(struct mxt_data *data, | 493 | static int mxt_write_object(struct mxt_data *data, |
497 | u8 type, u8 offset, u8 val) | 494 | u8 type, u8 offset, u8 val) |
498 | { | 495 | { |
@@ -507,75 +504,17 @@ static int mxt_write_object(struct mxt_data *data, | |||
507 | return mxt_write_reg(data->client, reg + offset, val); | 504 | return mxt_write_reg(data->client, reg + offset, val); |
508 | } | 505 | } |
509 | 506 | ||
510 | static void mxt_input_report(struct mxt_data *data, int single_id) | ||
511 | { | ||
512 | struct mxt_finger *finger = data->finger; | ||
513 | struct input_dev *input_dev = data->input_dev; | ||
514 | int status = finger[single_id].status; | ||
515 | int finger_num = 0; | ||
516 | int id; | ||
517 | |||
518 | for (id = 0; id < MXT_MAX_FINGER; id++) { | ||
519 | if (!finger[id].status) | ||
520 | continue; | ||
521 | |||
522 | input_mt_slot(input_dev, id); | ||
523 | input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, | ||
524 | finger[id].status != MXT_RELEASE); | ||
525 | |||
526 | if (finger[id].status != MXT_RELEASE) { | ||
527 | finger_num++; | ||
528 | input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, | ||
529 | finger[id].area); | ||
530 | input_report_abs(input_dev, ABS_MT_POSITION_X, | ||
531 | finger[id].x); | ||
532 | input_report_abs(input_dev, ABS_MT_POSITION_Y, | ||
533 | finger[id].y); | ||
534 | input_report_abs(input_dev, ABS_MT_PRESSURE, | ||
535 | finger[id].pressure); | ||
536 | } else { | ||
537 | finger[id].status = 0; | ||
538 | } | ||
539 | } | ||
540 | |||
541 | input_report_key(input_dev, BTN_TOUCH, finger_num > 0); | ||
542 | |||
543 | if (status != MXT_RELEASE) { | ||
544 | input_report_abs(input_dev, ABS_X, finger[single_id].x); | ||
545 | input_report_abs(input_dev, ABS_Y, finger[single_id].y); | ||
546 | input_report_abs(input_dev, | ||
547 | ABS_PRESSURE, finger[single_id].pressure); | ||
548 | } | ||
549 | |||
550 | input_sync(input_dev); | ||
551 | } | ||
552 | |||
553 | static void mxt_input_touchevent(struct mxt_data *data, | 507 | static void mxt_input_touchevent(struct mxt_data *data, |
554 | struct mxt_message *message, int id) | 508 | struct mxt_message *message, int id) |
555 | { | 509 | { |
556 | struct mxt_finger *finger = data->finger; | ||
557 | struct device *dev = &data->client->dev; | 510 | struct device *dev = &data->client->dev; |
558 | u8 status = message->message[0]; | 511 | u8 status = message->message[0]; |
512 | struct input_dev *input_dev = data->input_dev; | ||
559 | int x; | 513 | int x; |
560 | int y; | 514 | int y; |
561 | int area; | 515 | int area; |
562 | int pressure; | 516 | int pressure; |
563 | 517 | ||
564 | /* Check the touch is present on the screen */ | ||
565 | if (!(status & MXT_DETECT)) { | ||
566 | if (status & MXT_RELEASE) { | ||
567 | dev_dbg(dev, "[%d] released\n", id); | ||
568 | |||
569 | finger[id].status = MXT_RELEASE; | ||
570 | mxt_input_report(data, id); | ||
571 | } | ||
572 | return; | ||
573 | } | ||
574 | |||
575 | /* Check only AMP detection */ | ||
576 | if (!(status & (MXT_PRESS | MXT_MOVE))) | ||
577 | return; | ||
578 | |||
579 | x = (message->message[1] << 4) | ((message->message[3] >> 4) & 0xf); | 518 | x = (message->message[1] << 4) | ((message->message[3] >> 4) & 0xf); |
580 | y = (message->message[2] << 4) | ((message->message[3] & 0xf)); | 519 | y = (message->message[2] << 4) | ((message->message[3] & 0xf)); |
581 | if (data->max_x < 1024) | 520 | if (data->max_x < 1024) |
@@ -586,30 +525,50 @@ static void mxt_input_touchevent(struct mxt_data *data, | |||
586 | area = message->message[4]; | 525 | area = message->message[4]; |
587 | pressure = message->message[5]; | 526 | pressure = message->message[5]; |
588 | 527 | ||
589 | dev_dbg(dev, "[%d] %s x: %d, y: %d, area: %d\n", id, | 528 | dev_dbg(dev, |
590 | status & MXT_MOVE ? "moved" : "pressed", | 529 | "[%u] %c%c%c%c%c%c%c%c x: %5u y: %5u area: %3u amp: %3u\n", |
591 | x, y, area); | 530 | id, |
531 | (status & MXT_DETECT) ? 'D' : '.', | ||
532 | (status & MXT_PRESS) ? 'P' : '.', | ||
533 | (status & MXT_RELEASE) ? 'R' : '.', | ||
534 | (status & MXT_MOVE) ? 'M' : '.', | ||
535 | (status & MXT_VECTOR) ? 'V' : '.', | ||
536 | (status & MXT_AMP) ? 'A' : '.', | ||
537 | (status & MXT_SUPPRESS) ? 'S' : '.', | ||
538 | (status & MXT_UNGRIP) ? 'U' : '.', | ||
539 | x, y, area, pressure); | ||
540 | |||
541 | input_mt_slot(input_dev, id); | ||
542 | input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, | ||
543 | status & MXT_DETECT); | ||
544 | |||
545 | if (status & MXT_DETECT) { | ||
546 | input_report_abs(input_dev, ABS_MT_POSITION_X, x); | ||
547 | input_report_abs(input_dev, ABS_MT_POSITION_Y, y); | ||
548 | input_report_abs(input_dev, ABS_MT_PRESSURE, pressure); | ||
549 | input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, area); | ||
550 | } | ||
551 | } | ||
592 | 552 | ||
593 | finger[id].status = status & MXT_MOVE ? | 553 | static unsigned mxt_extract_T6_csum(const u8 *csum) |
594 | MXT_MOVE : MXT_PRESS; | 554 | { |
595 | finger[id].x = x; | 555 | return csum[0] | (csum[1] << 8) | (csum[2] << 16); |
596 | finger[id].y = y; | 556 | } |
597 | finger[id].area = area; | ||
598 | finger[id].pressure = pressure; | ||
599 | 557 | ||
600 | mxt_input_report(data, id); | 558 | static bool mxt_is_T9_message(struct mxt_data *data, struct mxt_message *msg) |
559 | { | ||
560 | u8 id = msg->reportid; | ||
561 | return (id >= data->T9_reportid_min && id <= data->T9_reportid_max); | ||
601 | } | 562 | } |
602 | 563 | ||
603 | static irqreturn_t mxt_interrupt(int irq, void *dev_id) | 564 | static irqreturn_t mxt_interrupt(int irq, void *dev_id) |
604 | { | 565 | { |
605 | struct mxt_data *data = dev_id; | 566 | struct mxt_data *data = dev_id; |
606 | struct mxt_message message; | 567 | struct mxt_message message; |
607 | struct mxt_object *object; | 568 | const u8 *payload = &message.message[0]; |
608 | struct device *dev = &data->client->dev; | 569 | struct device *dev = &data->client->dev; |
609 | int id; | ||
610 | u8 reportid; | 570 | u8 reportid; |
611 | u8 max_reportid; | 571 | bool update_input = false; |
612 | u8 min_reportid; | ||
613 | 572 | ||
614 | do { | 573 | do { |
615 | if (mxt_read_message(data, &message)) { | 574 | if (mxt_read_message(data, &message)) { |
@@ -619,21 +578,25 @@ static irqreturn_t mxt_interrupt(int irq, void *dev_id) | |||
619 | 578 | ||
620 | reportid = message.reportid; | 579 | reportid = message.reportid; |
621 | 580 | ||
622 | /* whether reportid is thing of MXT_TOUCH_MULTI_T9 */ | 581 | if (reportid == data->T6_reportid) { |
623 | object = mxt_get_object(data, MXT_TOUCH_MULTI_T9); | 582 | u8 status = payload[0]; |
624 | if (!object) | 583 | unsigned csum = mxt_extract_T6_csum(&payload[1]); |
625 | goto end; | 584 | dev_dbg(dev, "Status: %02x Config Checksum: %06x\n", |
626 | 585 | status, csum); | |
627 | max_reportid = object->max_reportid; | 586 | } else if (mxt_is_T9_message(data, &message)) { |
628 | min_reportid = max_reportid - object->num_report_ids + 1; | 587 | int id = reportid - data->T9_reportid_min; |
629 | id = reportid - min_reportid; | ||
630 | |||
631 | if (reportid >= min_reportid && reportid <= max_reportid) | ||
632 | mxt_input_touchevent(data, &message, id); | 588 | mxt_input_touchevent(data, &message, id); |
633 | else | 589 | update_input = true; |
590 | } else { | ||
634 | mxt_dump_message(dev, &message); | 591 | mxt_dump_message(dev, &message); |
592 | } | ||
635 | } while (reportid != 0xff); | 593 | } while (reportid != 0xff); |
636 | 594 | ||
595 | if (update_input) { | ||
596 | input_mt_report_pointer_emulation(data->input_dev, false); | ||
597 | input_sync(data->input_dev); | ||
598 | } | ||
599 | |||
637 | end: | 600 | end: |
638 | return IRQ_HANDLED; | 601 | return IRQ_HANDLED; |
639 | } | 602 | } |
@@ -644,7 +607,8 @@ static int mxt_check_reg_init(struct mxt_data *data) | |||
644 | struct mxt_object *object; | 607 | struct mxt_object *object; |
645 | struct device *dev = &data->client->dev; | 608 | struct device *dev = &data->client->dev; |
646 | int index = 0; | 609 | int index = 0; |
647 | int i, j, config_offset; | 610 | int i, size; |
611 | int ret; | ||
648 | 612 | ||
649 | if (!pdata->config) { | 613 | if (!pdata->config) { |
650 | dev_dbg(dev, "No cfg data defined, skipping reg init\n"); | 614 | dev_dbg(dev, "No cfg data defined, skipping reg init\n"); |
@@ -657,18 +621,17 @@ static int mxt_check_reg_init(struct mxt_data *data) | |||
657 | if (!mxt_object_writable(object->type)) | 621 | if (!mxt_object_writable(object->type)) |
658 | continue; | 622 | continue; |
659 | 623 | ||
660 | for (j = 0; | 624 | size = (object->size + 1) * (object->instances + 1); |
661 | j < (object->size + 1) * (object->instances + 1); | 625 | if (index + size > pdata->config_length) { |
662 | j++) { | 626 | dev_err(dev, "Not enough config data!\n"); |
663 | config_offset = index + j; | 627 | return -EINVAL; |
664 | if (config_offset > pdata->config_length) { | ||
665 | dev_err(dev, "Not enough config data!\n"); | ||
666 | return -EINVAL; | ||
667 | } | ||
668 | mxt_write_object(data, object->type, j, | ||
669 | pdata->config[config_offset]); | ||
670 | } | 628 | } |
671 | index += (object->size + 1) * (object->instances + 1); | 629 | |
630 | ret = __mxt_write_reg(data->client, object->start_address, | ||
631 | size, &pdata->config[index]); | ||
632 | if (ret) | ||
633 | return ret; | ||
634 | index += size; | ||
672 | } | 635 | } |
673 | 636 | ||
674 | return 0; | 637 | return 0; |
@@ -749,68 +712,76 @@ static int mxt_get_info(struct mxt_data *data) | |||
749 | struct i2c_client *client = data->client; | 712 | struct i2c_client *client = data->client; |
750 | struct mxt_info *info = &data->info; | 713 | struct mxt_info *info = &data->info; |
751 | int error; | 714 | int error; |
752 | u8 val; | ||
753 | 715 | ||
754 | error = mxt_read_reg(client, MXT_FAMILY_ID, &val); | 716 | /* Read 7-byte info block starting at address 0 */ |
717 | error = __mxt_read_reg(client, MXT_INFO, sizeof(*info), info); | ||
755 | if (error) | 718 | if (error) |
756 | return error; | 719 | return error; |
757 | info->family_id = val; | ||
758 | |||
759 | error = mxt_read_reg(client, MXT_VARIANT_ID, &val); | ||
760 | if (error) | ||
761 | return error; | ||
762 | info->variant_id = val; | ||
763 | |||
764 | error = mxt_read_reg(client, MXT_VERSION, &val); | ||
765 | if (error) | ||
766 | return error; | ||
767 | info->version = val; | ||
768 | |||
769 | error = mxt_read_reg(client, MXT_BUILD, &val); | ||
770 | if (error) | ||
771 | return error; | ||
772 | info->build = val; | ||
773 | |||
774 | error = mxt_read_reg(client, MXT_OBJECT_NUM, &val); | ||
775 | if (error) | ||
776 | return error; | ||
777 | info->object_num = val; | ||
778 | 720 | ||
779 | return 0; | 721 | return 0; |
780 | } | 722 | } |
781 | 723 | ||
782 | static int mxt_get_object_table(struct mxt_data *data) | 724 | static int mxt_get_object_table(struct mxt_data *data) |
783 | { | 725 | { |
726 | struct i2c_client *client = data->client; | ||
727 | size_t table_size; | ||
784 | int error; | 728 | int error; |
785 | int i; | 729 | int i; |
786 | u16 reg; | 730 | u8 reportid; |
787 | u8 reportid = 0; | 731 | |
788 | u8 buf[MXT_OBJECT_SIZE]; | 732 | table_size = data->info.object_num * sizeof(struct mxt_object); |
733 | error = __mxt_read_reg(client, MXT_OBJECT_START, table_size, | ||
734 | data->object_table); | ||
735 | if (error) | ||
736 | return error; | ||
789 | 737 | ||
738 | /* Valid Report IDs start counting from 1 */ | ||
739 | reportid = 1; | ||
790 | for (i = 0; i < data->info.object_num; i++) { | 740 | for (i = 0; i < data->info.object_num; i++) { |
791 | struct mxt_object *object = data->object_table + i; | 741 | struct mxt_object *object = data->object_table + i; |
742 | u8 min_id, max_id; | ||
792 | 743 | ||
793 | reg = MXT_OBJECT_START + MXT_OBJECT_SIZE * i; | 744 | le16_to_cpus(&object->start_address); |
794 | error = mxt_read_object_table(data->client, reg, buf); | ||
795 | if (error) | ||
796 | return error; | ||
797 | |||
798 | object->type = buf[0]; | ||
799 | object->start_address = (buf[2] << 8) | buf[1]; | ||
800 | object->size = buf[3]; | ||
801 | object->instances = buf[4]; | ||
802 | object->num_report_ids = buf[5]; | ||
803 | 745 | ||
804 | if (object->num_report_ids) { | 746 | if (object->num_report_ids) { |
747 | min_id = reportid; | ||
805 | reportid += object->num_report_ids * | 748 | reportid += object->num_report_ids * |
806 | (object->instances + 1); | 749 | (object->instances + 1); |
807 | object->max_reportid = reportid; | 750 | max_id = reportid - 1; |
751 | } else { | ||
752 | min_id = 0; | ||
753 | max_id = 0; | ||
754 | } | ||
755 | |||
756 | dev_dbg(&data->client->dev, | ||
757 | "Type %2d Start %3d Size %3d Instances %2d ReportIDs %3u : %3u\n", | ||
758 | object->type, object->start_address, object->size + 1, | ||
759 | object->instances + 1, min_id, max_id); | ||
760 | |||
761 | switch (object->type) { | ||
762 | case MXT_GEN_COMMAND_T6: | ||
763 | data->T6_reportid = min_id; | ||
764 | break; | ||
765 | case MXT_TOUCH_MULTI_T9: | ||
766 | data->T9_reportid_min = min_id; | ||
767 | data->T9_reportid_max = max_id; | ||
768 | break; | ||
808 | } | 769 | } |
809 | } | 770 | } |
810 | 771 | ||
811 | return 0; | 772 | return 0; |
812 | } | 773 | } |
813 | 774 | ||
775 | static void mxt_free_object_table(struct mxt_data *data) | ||
776 | { | ||
777 | kfree(data->object_table); | ||
778 | data->object_table = NULL; | ||
779 | data->T6_reportid = 0; | ||
780 | data->T9_reportid_min = 0; | ||
781 | data->T9_reportid_max = 0; | ||
782 | |||
783 | } | ||
784 | |||
814 | static int mxt_initialize(struct mxt_data *data) | 785 | static int mxt_initialize(struct mxt_data *data) |
815 | { | 786 | { |
816 | struct i2c_client *client = data->client; | 787 | struct i2c_client *client = data->client; |
@@ -833,12 +804,12 @@ static int mxt_initialize(struct mxt_data *data) | |||
833 | /* Get object table information */ | 804 | /* Get object table information */ |
834 | error = mxt_get_object_table(data); | 805 | error = mxt_get_object_table(data); |
835 | if (error) | 806 | if (error) |
836 | return error; | 807 | goto err_free_object_table; |
837 | 808 | ||
838 | /* Check register init values */ | 809 | /* Check register init values */ |
839 | error = mxt_check_reg_init(data); | 810 | error = mxt_check_reg_init(data); |
840 | if (error) | 811 | if (error) |
841 | return error; | 812 | goto err_free_object_table; |
842 | 813 | ||
843 | mxt_handle_pdata(data); | 814 | mxt_handle_pdata(data); |
844 | 815 | ||
@@ -856,25 +827,29 @@ static int mxt_initialize(struct mxt_data *data) | |||
856 | /* Update matrix size at info struct */ | 827 | /* Update matrix size at info struct */ |
857 | error = mxt_read_reg(client, MXT_MATRIX_X_SIZE, &val); | 828 | error = mxt_read_reg(client, MXT_MATRIX_X_SIZE, &val); |
858 | if (error) | 829 | if (error) |
859 | return error; | 830 | goto err_free_object_table; |
860 | info->matrix_xsize = val; | 831 | info->matrix_xsize = val; |
861 | 832 | ||
862 | error = mxt_read_reg(client, MXT_MATRIX_Y_SIZE, &val); | 833 | error = mxt_read_reg(client, MXT_MATRIX_Y_SIZE, &val); |
863 | if (error) | 834 | if (error) |
864 | return error; | 835 | goto err_free_object_table; |
865 | info->matrix_ysize = val; | 836 | info->matrix_ysize = val; |
866 | 837 | ||
867 | dev_info(&client->dev, | 838 | dev_info(&client->dev, |
868 | "Family ID: %d Variant ID: %d Version: %d Build: %d\n", | 839 | "Family ID: %u Variant ID: %u Major.Minor.Build: %u.%u.%02X\n", |
869 | info->family_id, info->variant_id, info->version, | 840 | info->family_id, info->variant_id, info->version >> 4, |
870 | info->build); | 841 | info->version & 0xf, info->build); |
871 | 842 | ||
872 | dev_info(&client->dev, | 843 | dev_info(&client->dev, |
873 | "Matrix X Size: %d Matrix Y Size: %d Object Num: %d\n", | 844 | "Matrix X Size: %u Matrix Y Size: %u Object Num: %u\n", |
874 | info->matrix_xsize, info->matrix_ysize, | 845 | info->matrix_xsize, info->matrix_ysize, |
875 | info->object_num); | 846 | info->object_num); |
876 | 847 | ||
877 | return 0; | 848 | return 0; |
849 | |||
850 | err_free_object_table: | ||
851 | mxt_free_object_table(data); | ||
852 | return error; | ||
878 | } | 853 | } |
879 | 854 | ||
880 | static void mxt_calc_resolution(struct mxt_data *data) | 855 | static void mxt_calc_resolution(struct mxt_data *data) |
@@ -891,6 +866,44 @@ static void mxt_calc_resolution(struct mxt_data *data) | |||
891 | } | 866 | } |
892 | } | 867 | } |
893 | 868 | ||
869 | /* Firmware Version is returned as Major.Minor.Build */ | ||
870 | static ssize_t mxt_fw_version_show(struct device *dev, | ||
871 | struct device_attribute *attr, char *buf) | ||
872 | { | ||
873 | struct mxt_data *data = dev_get_drvdata(dev); | ||
874 | struct mxt_info *info = &data->info; | ||
875 | return scnprintf(buf, PAGE_SIZE, "%u.%u.%02X\n", | ||
876 | info->version >> 4, info->version & 0xf, info->build); | ||
877 | } | ||
878 | |||
879 | /* Hardware Version is returned as FamilyID.VariantID */ | ||
880 | static ssize_t mxt_hw_version_show(struct device *dev, | ||
881 | struct device_attribute *attr, char *buf) | ||
882 | { | ||
883 | struct mxt_data *data = dev_get_drvdata(dev); | ||
884 | struct mxt_info *info = &data->info; | ||
885 | return scnprintf(buf, PAGE_SIZE, "%u.%u\n", | ||
886 | info->family_id, info->variant_id); | ||
887 | } | ||
888 | |||
889 | static ssize_t mxt_show_instance(char *buf, int count, | ||
890 | struct mxt_object *object, int instance, | ||
891 | const u8 *val) | ||
892 | { | ||
893 | int i; | ||
894 | |||
895 | if (object->instances > 0) | ||
896 | count += scnprintf(buf + count, PAGE_SIZE - count, | ||
897 | "Instance %u\n", instance); | ||
898 | |||
899 | for (i = 0; i < object->size + 1; i++) | ||
900 | count += scnprintf(buf + count, PAGE_SIZE - count, | ||
901 | "\t[%2u]: %02x (%d)\n", i, val[i], val[i]); | ||
902 | count += scnprintf(buf + count, PAGE_SIZE - count, "\n"); | ||
903 | |||
904 | return count; | ||
905 | } | ||
906 | |||
894 | static ssize_t mxt_object_show(struct device *dev, | 907 | static ssize_t mxt_object_show(struct device *dev, |
895 | struct device_attribute *attr, char *buf) | 908 | struct device_attribute *attr, char *buf) |
896 | { | 909 | { |
@@ -899,43 +912,38 @@ static ssize_t mxt_object_show(struct device *dev, | |||
899 | int count = 0; | 912 | int count = 0; |
900 | int i, j; | 913 | int i, j; |
901 | int error; | 914 | int error; |
902 | u8 val; | 915 | u8 *obuf; |
903 | 916 | ||
917 | /* Pre-allocate buffer large enough to hold max sized object. */ | ||
918 | obuf = kmalloc(256, GFP_KERNEL); | ||
919 | if (!obuf) | ||
920 | return -ENOMEM; | ||
921 | |||
922 | error = 0; | ||
904 | for (i = 0; i < data->info.object_num; i++) { | 923 | for (i = 0; i < data->info.object_num; i++) { |
905 | object = data->object_table + i; | 924 | object = data->object_table + i; |
906 | 925 | ||
907 | count += snprintf(buf + count, PAGE_SIZE - count, | 926 | if (!mxt_object_readable(object->type)) |
908 | "Object[%d] (Type %d)\n", | ||
909 | i + 1, object->type); | ||
910 | if (count >= PAGE_SIZE) | ||
911 | return PAGE_SIZE - 1; | ||
912 | |||
913 | if (!mxt_object_readable(object->type)) { | ||
914 | count += snprintf(buf + count, PAGE_SIZE - count, | ||
915 | "\n"); | ||
916 | if (count >= PAGE_SIZE) | ||
917 | return PAGE_SIZE - 1; | ||
918 | continue; | 927 | continue; |
919 | } | ||
920 | 928 | ||
921 | for (j = 0; j < object->size + 1; j++) { | 929 | count += scnprintf(buf + count, PAGE_SIZE - count, |
922 | error = mxt_read_object(data, | 930 | "T%u:\n", object->type); |
923 | object->type, j, &val); | 931 | |
932 | for (j = 0; j < object->instances + 1; j++) { | ||
933 | u16 size = object->size + 1; | ||
934 | u16 addr = object->start_address + j * size; | ||
935 | |||
936 | error = __mxt_read_reg(data->client, addr, size, obuf); | ||
924 | if (error) | 937 | if (error) |
925 | return error; | 938 | goto done; |
926 | 939 | ||
927 | count += snprintf(buf + count, PAGE_SIZE - count, | 940 | count = mxt_show_instance(buf, count, object, j, obuf); |
928 | "\t[%2d]: %02x (%d)\n", j, val, val); | ||
929 | if (count >= PAGE_SIZE) | ||
930 | return PAGE_SIZE - 1; | ||
931 | } | 941 | } |
932 | |||
933 | count += snprintf(buf + count, PAGE_SIZE - count, "\n"); | ||
934 | if (count >= PAGE_SIZE) | ||
935 | return PAGE_SIZE - 1; | ||
936 | } | 942 | } |
937 | 943 | ||
938 | return count; | 944 | done: |
945 | kfree(obuf); | ||
946 | return error ?: count; | ||
939 | } | 947 | } |
940 | 948 | ||
941 | static int mxt_load_fw(struct device *dev, const char *fn) | 949 | static int mxt_load_fw(struct device *dev, const char *fn) |
@@ -1028,8 +1036,7 @@ static ssize_t mxt_update_fw_store(struct device *dev, | |||
1028 | /* Wait for reset */ | 1036 | /* Wait for reset */ |
1029 | msleep(MXT_FWRESET_TIME); | 1037 | msleep(MXT_FWRESET_TIME); |
1030 | 1038 | ||
1031 | kfree(data->object_table); | 1039 | mxt_free_object_table(data); |
1032 | data->object_table = NULL; | ||
1033 | 1040 | ||
1034 | mxt_initialize(data); | 1041 | mxt_initialize(data); |
1035 | } | 1042 | } |
@@ -1043,10 +1050,14 @@ static ssize_t mxt_update_fw_store(struct device *dev, | |||
1043 | return count; | 1050 | return count; |
1044 | } | 1051 | } |
1045 | 1052 | ||
1053 | static DEVICE_ATTR(fw_version, S_IRUGO, mxt_fw_version_show, NULL); | ||
1054 | static DEVICE_ATTR(hw_version, S_IRUGO, mxt_hw_version_show, NULL); | ||
1046 | static DEVICE_ATTR(object, S_IRUGO, mxt_object_show, NULL); | 1055 | static DEVICE_ATTR(object, S_IRUGO, mxt_object_show, NULL); |
1047 | static DEVICE_ATTR(update_fw, S_IWUSR, NULL, mxt_update_fw_store); | 1056 | static DEVICE_ATTR(update_fw, S_IWUSR, NULL, mxt_update_fw_store); |
1048 | 1057 | ||
1049 | static struct attribute *mxt_attrs[] = { | 1058 | static struct attribute *mxt_attrs[] = { |
1059 | &dev_attr_fw_version.attr, | ||
1060 | &dev_attr_hw_version.attr, | ||
1050 | &dev_attr_object.attr, | 1061 | &dev_attr_object.attr, |
1051 | &dev_attr_update_fw.attr, | 1062 | &dev_attr_update_fw.attr, |
1052 | NULL | 1063 | NULL |
@@ -1093,6 +1104,7 @@ static int __devinit mxt_probe(struct i2c_client *client, | |||
1093 | struct mxt_data *data; | 1104 | struct mxt_data *data; |
1094 | struct input_dev *input_dev; | 1105 | struct input_dev *input_dev; |
1095 | int error; | 1106 | int error; |
1107 | unsigned int num_mt_slots; | ||
1096 | 1108 | ||
1097 | if (!pdata) | 1109 | if (!pdata) |
1098 | return -EINVAL; | 1110 | return -EINVAL; |
@@ -1106,6 +1118,10 @@ static int __devinit mxt_probe(struct i2c_client *client, | |||
1106 | } | 1118 | } |
1107 | 1119 | ||
1108 | input_dev->name = "Atmel maXTouch Touchscreen"; | 1120 | input_dev->name = "Atmel maXTouch Touchscreen"; |
1121 | snprintf(data->phys, sizeof(data->phys), "i2c-%u-%04x/input0", | ||
1122 | client->adapter->nr, client->addr); | ||
1123 | input_dev->phys = data->phys; | ||
1124 | |||
1109 | input_dev->id.bustype = BUS_I2C; | 1125 | input_dev->id.bustype = BUS_I2C; |
1110 | input_dev->dev.parent = &client->dev; | 1126 | input_dev->dev.parent = &client->dev; |
1111 | input_dev->open = mxt_input_open; | 1127 | input_dev->open = mxt_input_open; |
@@ -1118,6 +1134,10 @@ static int __devinit mxt_probe(struct i2c_client *client, | |||
1118 | 1134 | ||
1119 | mxt_calc_resolution(data); | 1135 | mxt_calc_resolution(data); |
1120 | 1136 | ||
1137 | error = mxt_initialize(data); | ||
1138 | if (error) | ||
1139 | goto err_free_mem; | ||
1140 | |||
1121 | __set_bit(EV_ABS, input_dev->evbit); | 1141 | __set_bit(EV_ABS, input_dev->evbit); |
1122 | __set_bit(EV_KEY, input_dev->evbit); | 1142 | __set_bit(EV_KEY, input_dev->evbit); |
1123 | __set_bit(BTN_TOUCH, input_dev->keybit); | 1143 | __set_bit(BTN_TOUCH, input_dev->keybit); |
@@ -1131,7 +1151,10 @@ static int __devinit mxt_probe(struct i2c_client *client, | |||
1131 | 0, 255, 0, 0); | 1151 | 0, 255, 0, 0); |
1132 | 1152 | ||
1133 | /* For multi touch */ | 1153 | /* For multi touch */ |
1134 | input_mt_init_slots(input_dev, MXT_MAX_FINGER); | 1154 | num_mt_slots = data->T9_reportid_max - data->T9_reportid_min + 1; |
1155 | error = input_mt_init_slots(input_dev, num_mt_slots); | ||
1156 | if (error) | ||
1157 | goto err_free_object; | ||
1135 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, | 1158 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, |
1136 | 0, MXT_MAX_AREA, 0, 0); | 1159 | 0, MXT_MAX_AREA, 0, 0); |
1137 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, | 1160 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, |
@@ -1144,13 +1167,9 @@ static int __devinit mxt_probe(struct i2c_client *client, | |||
1144 | input_set_drvdata(input_dev, data); | 1167 | input_set_drvdata(input_dev, data); |
1145 | i2c_set_clientdata(client, data); | 1168 | i2c_set_clientdata(client, data); |
1146 | 1169 | ||
1147 | error = mxt_initialize(data); | ||
1148 | if (error) | ||
1149 | goto err_free_object; | ||
1150 | |||
1151 | error = request_threaded_irq(client->irq, NULL, mxt_interrupt, | 1170 | error = request_threaded_irq(client->irq, NULL, mxt_interrupt, |
1152 | pdata->irqflags | IRQF_ONESHOT, | 1171 | pdata->irqflags | IRQF_ONESHOT, |
1153 | client->dev.driver->name, data); | 1172 | client->name, data); |
1154 | if (error) { | 1173 | if (error) { |
1155 | dev_err(&client->dev, "Failed to register interrupt\n"); | 1174 | dev_err(&client->dev, "Failed to register interrupt\n"); |
1156 | goto err_free_object; | 1175 | goto err_free_object; |
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c new file mode 100644 index 000000000000..b06a5e3a665e --- /dev/null +++ b/drivers/input/touchscreen/edt-ft5x06.c | |||
@@ -0,0 +1,898 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012 Simon Budig, <simon.budig@kernelconcepts.de> | ||
3 | * | ||
4 | * This software is licensed under the terms of the GNU General Public | ||
5 | * License version 2, as published by the Free Software Foundation, and | ||
6 | * may be copied, distributed, and modified under those terms. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public | ||
14 | * License along with this library; if not, write to the Free Software | ||
15 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
16 | */ | ||
17 | |||
18 | /* | ||
19 | * This is a driver for the EDT "Polytouch" family of touch controllers | ||
20 | * based on the FocalTech FT5x06 line of chips. | ||
21 | * | ||
22 | * Development of this driver has been sponsored by Glyn: | ||
23 | * http://www.glyn.com/Products/Displays | ||
24 | */ | ||
25 | |||
26 | #include <linux/module.h> | ||
27 | #include <linux/ratelimit.h> | ||
28 | #include <linux/interrupt.h> | ||
29 | #include <linux/input.h> | ||
30 | #include <linux/i2c.h> | ||
31 | #include <linux/uaccess.h> | ||
32 | #include <linux/delay.h> | ||
33 | #include <linux/debugfs.h> | ||
34 | #include <linux/slab.h> | ||
35 | #include <linux/gpio.h> | ||
36 | #include <linux/input/mt.h> | ||
37 | #include <linux/input/edt-ft5x06.h> | ||
38 | |||
39 | #define MAX_SUPPORT_POINTS 5 | ||
40 | |||
41 | #define WORK_REGISTER_THRESHOLD 0x00 | ||
42 | #define WORK_REGISTER_REPORT_RATE 0x08 | ||
43 | #define WORK_REGISTER_GAIN 0x30 | ||
44 | #define WORK_REGISTER_OFFSET 0x31 | ||
45 | #define WORK_REGISTER_NUM_X 0x33 | ||
46 | #define WORK_REGISTER_NUM_Y 0x34 | ||
47 | |||
48 | #define WORK_REGISTER_OPMODE 0x3c | ||
49 | #define FACTORY_REGISTER_OPMODE 0x01 | ||
50 | |||
51 | #define TOUCH_EVENT_DOWN 0x00 | ||
52 | #define TOUCH_EVENT_UP 0x01 | ||
53 | #define TOUCH_EVENT_ON 0x02 | ||
54 | #define TOUCH_EVENT_RESERVED 0x03 | ||
55 | |||
56 | #define EDT_NAME_LEN 23 | ||
57 | #define EDT_SWITCH_MODE_RETRIES 10 | ||
58 | #define EDT_SWITCH_MODE_DELAY 5 /* msec */ | ||
59 | #define EDT_RAW_DATA_RETRIES 100 | ||
60 | #define EDT_RAW_DATA_DELAY 1 /* msec */ | ||
61 | |||
62 | struct edt_ft5x06_ts_data { | ||
63 | struct i2c_client *client; | ||
64 | struct input_dev *input; | ||
65 | u16 num_x; | ||
66 | u16 num_y; | ||
67 | |||
68 | #if defined(CONFIG_DEBUG_FS) | ||
69 | struct dentry *debug_dir; | ||
70 | u8 *raw_buffer; | ||
71 | size_t raw_bufsize; | ||
72 | #endif | ||
73 | |||
74 | struct mutex mutex; | ||
75 | bool factory_mode; | ||
76 | int threshold; | ||
77 | int gain; | ||
78 | int offset; | ||
79 | int report_rate; | ||
80 | |||
81 | char name[EDT_NAME_LEN]; | ||
82 | }; | ||
83 | |||
84 | static int edt_ft5x06_ts_readwrite(struct i2c_client *client, | ||
85 | u16 wr_len, u8 *wr_buf, | ||
86 | u16 rd_len, u8 *rd_buf) | ||
87 | { | ||
88 | struct i2c_msg wrmsg[2]; | ||
89 | int i = 0; | ||
90 | int ret; | ||
91 | |||
92 | if (wr_len) { | ||
93 | wrmsg[i].addr = client->addr; | ||
94 | wrmsg[i].flags = 0; | ||
95 | wrmsg[i].len = wr_len; | ||
96 | wrmsg[i].buf = wr_buf; | ||
97 | i++; | ||
98 | } | ||
99 | if (rd_len) { | ||
100 | wrmsg[i].addr = client->addr; | ||
101 | wrmsg[i].flags = I2C_M_RD; | ||
102 | wrmsg[i].len = rd_len; | ||
103 | wrmsg[i].buf = rd_buf; | ||
104 | i++; | ||
105 | } | ||
106 | |||
107 | ret = i2c_transfer(client->adapter, wrmsg, i); | ||
108 | if (ret < 0) | ||
109 | return ret; | ||
110 | if (ret != i) | ||
111 | return -EIO; | ||
112 | |||
113 | return 0; | ||
114 | } | ||
115 | |||
116 | static bool edt_ft5x06_ts_check_crc(struct edt_ft5x06_ts_data *tsdata, | ||
117 | u8 *buf, int buflen) | ||
118 | { | ||
119 | int i; | ||
120 | u8 crc = 0; | ||
121 | |||
122 | for (i = 0; i < buflen - 1; i++) | ||
123 | crc ^= buf[i]; | ||
124 | |||
125 | if (crc != buf[buflen-1]) { | ||
126 | dev_err_ratelimited(&tsdata->client->dev, | ||
127 | "crc error: 0x%02x expected, got 0x%02x\n", | ||
128 | crc, buf[buflen-1]); | ||
129 | return false; | ||
130 | } | ||
131 | |||
132 | return true; | ||
133 | } | ||
134 | |||
135 | static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id) | ||
136 | { | ||
137 | struct edt_ft5x06_ts_data *tsdata = dev_id; | ||
138 | struct device *dev = &tsdata->client->dev; | ||
139 | u8 cmd = 0xf9; | ||
140 | u8 rdbuf[26]; | ||
141 | int i, type, x, y, id; | ||
142 | int error; | ||
143 | |||
144 | memset(rdbuf, 0, sizeof(rdbuf)); | ||
145 | |||
146 | error = edt_ft5x06_ts_readwrite(tsdata->client, | ||
147 | sizeof(cmd), &cmd, | ||
148 | sizeof(rdbuf), rdbuf); | ||
149 | if (error) { | ||
150 | dev_err_ratelimited(dev, "Unable to fetch data, error: %d\n", | ||
151 | error); | ||
152 | goto out; | ||
153 | } | ||
154 | |||
155 | if (rdbuf[0] != 0xaa || rdbuf[1] != 0xaa || rdbuf[2] != 26) { | ||
156 | dev_err_ratelimited(dev, "Unexpected header: %02x%02x%02x!\n", | ||
157 | rdbuf[0], rdbuf[1], rdbuf[2]); | ||
158 | goto out; | ||
159 | } | ||
160 | |||
161 | if (!edt_ft5x06_ts_check_crc(tsdata, rdbuf, 26)) | ||
162 | goto out; | ||
163 | |||
164 | for (i = 0; i < MAX_SUPPORT_POINTS; i++) { | ||
165 | u8 *buf = &rdbuf[i * 4 + 5]; | ||
166 | bool down; | ||
167 | |||
168 | type = buf[0] >> 6; | ||
169 | /* ignore Reserved events */ | ||
170 | if (type == TOUCH_EVENT_RESERVED) | ||
171 | continue; | ||
172 | |||
173 | x = ((buf[0] << 8) | buf[1]) & 0x0fff; | ||
174 | y = ((buf[2] << 8) | buf[3]) & 0x0fff; | ||
175 | id = (buf[2] >> 4) & 0x0f; | ||
176 | down = (type != TOUCH_EVENT_UP); | ||
177 | |||
178 | input_mt_slot(tsdata->input, id); | ||
179 | input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, down); | ||
180 | |||
181 | if (!down) | ||
182 | continue; | ||
183 | |||
184 | input_report_abs(tsdata->input, ABS_MT_POSITION_X, x); | ||
185 | input_report_abs(tsdata->input, ABS_MT_POSITION_Y, y); | ||
186 | } | ||
187 | |||
188 | input_mt_report_pointer_emulation(tsdata->input, true); | ||
189 | input_sync(tsdata->input); | ||
190 | |||
191 | out: | ||
192 | return IRQ_HANDLED; | ||
193 | } | ||
194 | |||
195 | static int edt_ft5x06_register_write(struct edt_ft5x06_ts_data *tsdata, | ||
196 | u8 addr, u8 value) | ||
197 | { | ||
198 | u8 wrbuf[4]; | ||
199 | |||
200 | wrbuf[0] = tsdata->factory_mode ? 0xf3 : 0xfc; | ||
201 | wrbuf[1] = tsdata->factory_mode ? addr & 0x7f : addr & 0x3f; | ||
202 | wrbuf[2] = value; | ||
203 | wrbuf[3] = wrbuf[0] ^ wrbuf[1] ^ wrbuf[2]; | ||
204 | |||
205 | return edt_ft5x06_ts_readwrite(tsdata->client, 4, wrbuf, 0, NULL); | ||
206 | } | ||
207 | |||
208 | static int edt_ft5x06_register_read(struct edt_ft5x06_ts_data *tsdata, | ||
209 | u8 addr) | ||
210 | { | ||
211 | u8 wrbuf[2], rdbuf[2]; | ||
212 | int error; | ||
213 | |||
214 | wrbuf[0] = tsdata->factory_mode ? 0xf3 : 0xfc; | ||
215 | wrbuf[1] = tsdata->factory_mode ? addr & 0x7f : addr & 0x3f; | ||
216 | wrbuf[1] |= tsdata->factory_mode ? 0x80 : 0x40; | ||
217 | |||
218 | error = edt_ft5x06_ts_readwrite(tsdata->client, 2, wrbuf, 2, rdbuf); | ||
219 | if (error) | ||
220 | return error; | ||
221 | |||
222 | if ((wrbuf[0] ^ wrbuf[1] ^ rdbuf[0]) != rdbuf[1]) { | ||
223 | dev_err(&tsdata->client->dev, | ||
224 | "crc error: 0x%02x expected, got 0x%02x\n", | ||
225 | wrbuf[0] ^ wrbuf[1] ^ rdbuf[0], rdbuf[1]); | ||
226 | return -EIO; | ||
227 | } | ||
228 | |||
229 | return rdbuf[0]; | ||
230 | } | ||
231 | |||
232 | struct edt_ft5x06_attribute { | ||
233 | struct device_attribute dattr; | ||
234 | size_t field_offset; | ||
235 | u8 limit_low; | ||
236 | u8 limit_high; | ||
237 | u8 addr; | ||
238 | }; | ||
239 | |||
240 | #define EDT_ATTR(_field, _mode, _addr, _limit_low, _limit_high) \ | ||
241 | struct edt_ft5x06_attribute edt_ft5x06_attr_##_field = { \ | ||
242 | .dattr = __ATTR(_field, _mode, \ | ||
243 | edt_ft5x06_setting_show, \ | ||
244 | edt_ft5x06_setting_store), \ | ||
245 | .field_offset = \ | ||
246 | offsetof(struct edt_ft5x06_ts_data, _field), \ | ||
247 | .limit_low = _limit_low, \ | ||
248 | .limit_high = _limit_high, \ | ||
249 | .addr = _addr, \ | ||
250 | } | ||
251 | |||
252 | static ssize_t edt_ft5x06_setting_show(struct device *dev, | ||
253 | struct device_attribute *dattr, | ||
254 | char *buf) | ||
255 | { | ||
256 | struct i2c_client *client = to_i2c_client(dev); | ||
257 | struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client); | ||
258 | struct edt_ft5x06_attribute *attr = | ||
259 | container_of(dattr, struct edt_ft5x06_attribute, dattr); | ||
260 | u8 *field = (u8 *)((char *)tsdata + attr->field_offset); | ||
261 | int val; | ||
262 | size_t count = 0; | ||
263 | int error = 0; | ||
264 | |||
265 | mutex_lock(&tsdata->mutex); | ||
266 | |||
267 | if (tsdata->factory_mode) { | ||
268 | error = -EIO; | ||
269 | goto out; | ||
270 | } | ||
271 | |||
272 | val = edt_ft5x06_register_read(tsdata, attr->addr); | ||
273 | if (val < 0) { | ||
274 | error = val; | ||
275 | dev_err(&tsdata->client->dev, | ||
276 | "Failed to fetch attribute %s, error %d\n", | ||
277 | dattr->attr.name, error); | ||
278 | goto out; | ||
279 | } | ||
280 | |||
281 | if (val != *field) { | ||
282 | dev_warn(&tsdata->client->dev, | ||
283 | "%s: read (%d) and stored value (%d) differ\n", | ||
284 | dattr->attr.name, val, *field); | ||
285 | *field = val; | ||
286 | } | ||
287 | |||
288 | count = scnprintf(buf, PAGE_SIZE, "%d\n", val); | ||
289 | out: | ||
290 | mutex_unlock(&tsdata->mutex); | ||
291 | return error ?: count; | ||
292 | } | ||
293 | |||
294 | static ssize_t edt_ft5x06_setting_store(struct device *dev, | ||
295 | struct device_attribute *dattr, | ||
296 | const char *buf, size_t count) | ||
297 | { | ||
298 | struct i2c_client *client = to_i2c_client(dev); | ||
299 | struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client); | ||
300 | struct edt_ft5x06_attribute *attr = | ||
301 | container_of(dattr, struct edt_ft5x06_attribute, dattr); | ||
302 | u8 *field = (u8 *)((char *)tsdata + attr->field_offset); | ||
303 | unsigned int val; | ||
304 | int error; | ||
305 | |||
306 | mutex_lock(&tsdata->mutex); | ||
307 | |||
308 | if (tsdata->factory_mode) { | ||
309 | error = -EIO; | ||
310 | goto out; | ||
311 | } | ||
312 | |||
313 | error = kstrtouint(buf, 0, &val); | ||
314 | if (error) | ||
315 | goto out; | ||
316 | |||
317 | if (val < attr->limit_low || val > attr->limit_high) { | ||
318 | error = -ERANGE; | ||
319 | goto out; | ||
320 | } | ||
321 | |||
322 | error = edt_ft5x06_register_write(tsdata, attr->addr, val); | ||
323 | if (error) { | ||
324 | dev_err(&tsdata->client->dev, | ||
325 | "Failed to update attribute %s, error: %d\n", | ||
326 | dattr->attr.name, error); | ||
327 | goto out; | ||
328 | } | ||
329 | |||
330 | *field = val; | ||
331 | |||
332 | out: | ||
333 | mutex_unlock(&tsdata->mutex); | ||
334 | return error ?: count; | ||
335 | } | ||
336 | |||
337 | static EDT_ATTR(gain, S_IWUSR | S_IRUGO, WORK_REGISTER_GAIN, 0, 31); | ||
338 | static EDT_ATTR(offset, S_IWUSR | S_IRUGO, WORK_REGISTER_OFFSET, 0, 31); | ||
339 | static EDT_ATTR(threshold, S_IWUSR | S_IRUGO, | ||
340 | WORK_REGISTER_THRESHOLD, 20, 80); | ||
341 | static EDT_ATTR(report_rate, S_IWUSR | S_IRUGO, | ||
342 | WORK_REGISTER_REPORT_RATE, 3, 14); | ||
343 | |||
344 | static struct attribute *edt_ft5x06_attrs[] = { | ||
345 | &edt_ft5x06_attr_gain.dattr.attr, | ||
346 | &edt_ft5x06_attr_offset.dattr.attr, | ||
347 | &edt_ft5x06_attr_threshold.dattr.attr, | ||
348 | &edt_ft5x06_attr_report_rate.dattr.attr, | ||
349 | NULL | ||
350 | }; | ||
351 | |||
352 | static const struct attribute_group edt_ft5x06_attr_group = { | ||
353 | .attrs = edt_ft5x06_attrs, | ||
354 | }; | ||
355 | |||
356 | #ifdef CONFIG_DEBUG_FS | ||
357 | static int edt_ft5x06_factory_mode(struct edt_ft5x06_ts_data *tsdata) | ||
358 | { | ||
359 | struct i2c_client *client = tsdata->client; | ||
360 | int retries = EDT_SWITCH_MODE_RETRIES; | ||
361 | int ret; | ||
362 | int error; | ||
363 | |||
364 | disable_irq(client->irq); | ||
365 | |||
366 | if (!tsdata->raw_buffer) { | ||
367 | tsdata->raw_bufsize = tsdata->num_x * tsdata->num_y * | ||
368 | sizeof(u16); | ||
369 | tsdata->raw_buffer = kzalloc(tsdata->raw_bufsize, GFP_KERNEL); | ||
370 | if (!tsdata->raw_buffer) { | ||
371 | error = -ENOMEM; | ||
372 | goto err_out; | ||
373 | } | ||
374 | } | ||
375 | |||
376 | /* mode register is 0x3c when in the work mode */ | ||
377 | error = edt_ft5x06_register_write(tsdata, WORK_REGISTER_OPMODE, 0x03); | ||
378 | if (error) { | ||
379 | dev_err(&client->dev, | ||
380 | "failed to switch to factory mode, error %d\n", error); | ||
381 | goto err_out; | ||
382 | } | ||
383 | |||
384 | tsdata->factory_mode = true; | ||
385 | do { | ||
386 | mdelay(EDT_SWITCH_MODE_DELAY); | ||
387 | /* mode register is 0x01 when in factory mode */ | ||
388 | ret = edt_ft5x06_register_read(tsdata, FACTORY_REGISTER_OPMODE); | ||
389 | if (ret == 0x03) | ||
390 | break; | ||
391 | } while (--retries > 0); | ||
392 | |||
393 | if (retries == 0) { | ||
394 | dev_err(&client->dev, "not in factory mode after %dms.\n", | ||
395 | EDT_SWITCH_MODE_RETRIES * EDT_SWITCH_MODE_DELAY); | ||
396 | error = -EIO; | ||
397 | goto err_out; | ||
398 | } | ||
399 | |||
400 | return 0; | ||
401 | |||
402 | err_out: | ||
403 | kfree(tsdata->raw_buffer); | ||
404 | tsdata->raw_buffer = NULL; | ||
405 | tsdata->factory_mode = false; | ||
406 | enable_irq(client->irq); | ||
407 | |||
408 | return error; | ||
409 | } | ||
410 | |||
411 | static int edt_ft5x06_work_mode(struct edt_ft5x06_ts_data *tsdata) | ||
412 | { | ||
413 | struct i2c_client *client = tsdata->client; | ||
414 | int retries = EDT_SWITCH_MODE_RETRIES; | ||
415 | int ret; | ||
416 | int error; | ||
417 | |||
418 | /* mode register is 0x01 when in the factory mode */ | ||
419 | error = edt_ft5x06_register_write(tsdata, FACTORY_REGISTER_OPMODE, 0x1); | ||
420 | if (error) { | ||
421 | dev_err(&client->dev, | ||
422 | "failed to switch to work mode, error: %d\n", error); | ||
423 | return error; | ||
424 | } | ||
425 | |||
426 | tsdata->factory_mode = false; | ||
427 | |||
428 | do { | ||
429 | mdelay(EDT_SWITCH_MODE_DELAY); | ||
430 | /* mode register is 0x01 when in factory mode */ | ||
431 | ret = edt_ft5x06_register_read(tsdata, WORK_REGISTER_OPMODE); | ||
432 | if (ret == 0x01) | ||
433 | break; | ||
434 | } while (--retries > 0); | ||
435 | |||
436 | if (retries == 0) { | ||
437 | dev_err(&client->dev, "not in work mode after %dms.\n", | ||
438 | EDT_SWITCH_MODE_RETRIES * EDT_SWITCH_MODE_DELAY); | ||
439 | tsdata->factory_mode = true; | ||
440 | return -EIO; | ||
441 | } | ||
442 | |||
443 | if (tsdata->raw_buffer) | ||
444 | kfree(tsdata->raw_buffer); | ||
445 | tsdata->raw_buffer = NULL; | ||
446 | |||
447 | /* restore parameters */ | ||
448 | edt_ft5x06_register_write(tsdata, WORK_REGISTER_THRESHOLD, | ||
449 | tsdata->threshold); | ||
450 | edt_ft5x06_register_write(tsdata, WORK_REGISTER_GAIN, | ||
451 | tsdata->gain); | ||
452 | edt_ft5x06_register_write(tsdata, WORK_REGISTER_OFFSET, | ||
453 | tsdata->offset); | ||
454 | edt_ft5x06_register_write(tsdata, WORK_REGISTER_REPORT_RATE, | ||
455 | tsdata->report_rate); | ||
456 | |||
457 | enable_irq(client->irq); | ||
458 | |||
459 | return 0; | ||
460 | } | ||
461 | |||
462 | static int edt_ft5x06_debugfs_mode_get(void *data, u64 *mode) | ||
463 | { | ||
464 | struct edt_ft5x06_ts_data *tsdata = data; | ||
465 | |||
466 | *mode = tsdata->factory_mode; | ||
467 | |||
468 | return 0; | ||
469 | }; | ||
470 | |||
471 | static int edt_ft5x06_debugfs_mode_set(void *data, u64 mode) | ||
472 | { | ||
473 | struct edt_ft5x06_ts_data *tsdata = data; | ||
474 | int retval = 0; | ||
475 | |||
476 | if (mode > 1) | ||
477 | return -ERANGE; | ||
478 | |||
479 | mutex_lock(&tsdata->mutex); | ||
480 | |||
481 | if (mode != tsdata->factory_mode) { | ||
482 | retval = mode ? edt_ft5x06_factory_mode(tsdata) : | ||
483 | edt_ft5x06_work_mode(tsdata); | ||
484 | } | ||
485 | |||
486 | mutex_unlock(&tsdata->mutex); | ||
487 | |||
488 | return retval; | ||
489 | }; | ||
490 | |||
491 | DEFINE_SIMPLE_ATTRIBUTE(debugfs_mode_fops, edt_ft5x06_debugfs_mode_get, | ||
492 | edt_ft5x06_debugfs_mode_set, "%llu\n"); | ||
493 | |||
494 | static int edt_ft5x06_debugfs_raw_data_open(struct inode *inode, | ||
495 | struct file *file) | ||
496 | { | ||
497 | file->private_data = inode->i_private; | ||
498 | |||
499 | return 0; | ||
500 | } | ||
501 | |||
502 | static ssize_t edt_ft5x06_debugfs_raw_data_read(struct file *file, | ||
503 | char __user *buf, size_t count, loff_t *off) | ||
504 | { | ||
505 | struct edt_ft5x06_ts_data *tsdata = file->private_data; | ||
506 | struct i2c_client *client = tsdata->client; | ||
507 | int retries = EDT_RAW_DATA_RETRIES; | ||
508 | int val, i, error; | ||
509 | size_t read = 0; | ||
510 | int colbytes; | ||
511 | char wrbuf[3]; | ||
512 | u8 *rdbuf; | ||
513 | |||
514 | if (*off < 0 || *off >= tsdata->raw_bufsize) | ||
515 | return 0; | ||
516 | |||
517 | mutex_lock(&tsdata->mutex); | ||
518 | |||
519 | if (!tsdata->factory_mode || !tsdata->raw_buffer) { | ||
520 | error = -EIO; | ||
521 | goto out; | ||
522 | } | ||
523 | |||
524 | error = edt_ft5x06_register_write(tsdata, 0x08, 0x01); | ||
525 | if (error) { | ||
526 | dev_dbg(&client->dev, | ||
527 | "failed to write 0x08 register, error %d\n", error); | ||
528 | goto out; | ||
529 | } | ||
530 | |||
531 | do { | ||
532 | msleep(EDT_RAW_DATA_DELAY); | ||
533 | val = edt_ft5x06_register_read(tsdata, 0x08); | ||
534 | if (val < 1) | ||
535 | break; | ||
536 | } while (--retries > 0); | ||
537 | |||
538 | if (val < 0) { | ||
539 | error = val; | ||
540 | dev_dbg(&client->dev, | ||
541 | "failed to read 0x08 register, error %d\n", error); | ||
542 | goto out; | ||
543 | } | ||
544 | |||
545 | if (retries == 0) { | ||
546 | dev_dbg(&client->dev, | ||
547 | "timed out waiting for register to settle\n"); | ||
548 | error = -ETIMEDOUT; | ||
549 | goto out; | ||
550 | } | ||
551 | |||
552 | rdbuf = tsdata->raw_buffer; | ||
553 | colbytes = tsdata->num_y * sizeof(u16); | ||
554 | |||
555 | wrbuf[0] = 0xf5; | ||
556 | wrbuf[1] = 0x0e; | ||
557 | for (i = 0; i < tsdata->num_x; i++) { | ||
558 | wrbuf[2] = i; /* column index */ | ||
559 | error = edt_ft5x06_ts_readwrite(tsdata->client, | ||
560 | sizeof(wrbuf), wrbuf, | ||
561 | colbytes, rdbuf); | ||
562 | if (error) | ||
563 | goto out; | ||
564 | |||
565 | rdbuf += colbytes; | ||
566 | } | ||
567 | |||
568 | read = min_t(size_t, count, tsdata->raw_bufsize - *off); | ||
569 | error = copy_to_user(buf, tsdata->raw_buffer + *off, read); | ||
570 | if (!error) | ||
571 | *off += read; | ||
572 | out: | ||
573 | mutex_unlock(&tsdata->mutex); | ||
574 | return error ?: read; | ||
575 | }; | ||
576 | |||
577 | |||
578 | static const struct file_operations debugfs_raw_data_fops = { | ||
579 | .open = edt_ft5x06_debugfs_raw_data_open, | ||
580 | .read = edt_ft5x06_debugfs_raw_data_read, | ||
581 | }; | ||
582 | |||
583 | static void __devinit | ||
584 | edt_ft5x06_ts_prepare_debugfs(struct edt_ft5x06_ts_data *tsdata, | ||
585 | const char *debugfs_name) | ||
586 | { | ||
587 | tsdata->debug_dir = debugfs_create_dir(debugfs_name, NULL); | ||
588 | if (!tsdata->debug_dir) | ||
589 | return; | ||
590 | |||
591 | debugfs_create_u16("num_x", S_IRUSR, tsdata->debug_dir, &tsdata->num_x); | ||
592 | debugfs_create_u16("num_y", S_IRUSR, tsdata->debug_dir, &tsdata->num_y); | ||
593 | |||
594 | debugfs_create_file("mode", S_IRUSR | S_IWUSR, | ||
595 | tsdata->debug_dir, tsdata, &debugfs_mode_fops); | ||
596 | debugfs_create_file("raw_data", S_IRUSR, | ||
597 | tsdata->debug_dir, tsdata, &debugfs_raw_data_fops); | ||
598 | } | ||
599 | |||
600 | static void __devexit | ||
601 | edt_ft5x06_ts_teardown_debugfs(struct edt_ft5x06_ts_data *tsdata) | ||
602 | { | ||
603 | if (tsdata->debug_dir) | ||
604 | debugfs_remove_recursive(tsdata->debug_dir); | ||
605 | kfree(tsdata->raw_buffer); | ||
606 | } | ||
607 | |||
608 | #else | ||
609 | |||
610 | static inline void | ||
611 | edt_ft5x06_ts_prepare_debugfs(struct edt_ft5x06_ts_data *tsdata, | ||
612 | const char *debugfs_name) | ||
613 | { | ||
614 | } | ||
615 | |||
616 | static inline void | ||
617 | edt_ft5x06_ts_teardown_debugfs(struct edt_ft5x06_ts_data *tsdata) | ||
618 | { | ||
619 | } | ||
620 | |||
621 | #endif /* CONFIG_DEBUGFS */ | ||
622 | |||
623 | |||
624 | |||
625 | static int __devinit edt_ft5x06_ts_reset(struct i2c_client *client, | ||
626 | int reset_pin) | ||
627 | { | ||
628 | int error; | ||
629 | |||
630 | if (gpio_is_valid(reset_pin)) { | ||
631 | /* this pulls reset down, enabling the low active reset */ | ||
632 | error = gpio_request_one(reset_pin, GPIOF_OUT_INIT_LOW, | ||
633 | "edt-ft5x06 reset"); | ||
634 | if (error) { | ||
635 | dev_err(&client->dev, | ||
636 | "Failed to request GPIO %d as reset pin, error %d\n", | ||
637 | reset_pin, error); | ||
638 | return error; | ||
639 | } | ||
640 | |||
641 | mdelay(50); | ||
642 | gpio_set_value(reset_pin, 1); | ||
643 | mdelay(100); | ||
644 | } | ||
645 | |||
646 | return 0; | ||
647 | } | ||
648 | |||
649 | static int __devinit edt_ft5x06_ts_identify(struct i2c_client *client, | ||
650 | char *model_name, | ||
651 | char *fw_version) | ||
652 | { | ||
653 | u8 rdbuf[EDT_NAME_LEN]; | ||
654 | char *p; | ||
655 | int error; | ||
656 | |||
657 | error = edt_ft5x06_ts_readwrite(client, 1, "\xbb", | ||
658 | EDT_NAME_LEN - 1, rdbuf); | ||
659 | if (error) | ||
660 | return error; | ||
661 | |||
662 | /* remove last '$' end marker */ | ||
663 | rdbuf[EDT_NAME_LEN - 1] = '\0'; | ||
664 | if (rdbuf[EDT_NAME_LEN - 2] == '$') | ||
665 | rdbuf[EDT_NAME_LEN - 2] = '\0'; | ||
666 | |||
667 | /* look for Model/Version separator */ | ||
668 | p = strchr(rdbuf, '*'); | ||
669 | if (p) | ||
670 | *p++ = '\0'; | ||
671 | |||
672 | strlcpy(model_name, rdbuf + 1, EDT_NAME_LEN); | ||
673 | strlcpy(fw_version, p ? p : "", EDT_NAME_LEN); | ||
674 | |||
675 | return 0; | ||
676 | } | ||
677 | |||
678 | #define EDT_ATTR_CHECKSET(name, reg) \ | ||
679 | if (pdata->name >= edt_ft5x06_attr_##name.limit_low && \ | ||
680 | pdata->name <= edt_ft5x06_attr_##name.limit_high) \ | ||
681 | edt_ft5x06_register_write(tsdata, reg, pdata->name) | ||
682 | |||
683 | static void __devinit | ||
684 | edt_ft5x06_ts_get_defaults(struct edt_ft5x06_ts_data *tsdata, | ||
685 | const struct edt_ft5x06_platform_data *pdata) | ||
686 | { | ||
687 | if (!pdata->use_parameters) | ||
688 | return; | ||
689 | |||
690 | /* pick up defaults from the platform data */ | ||
691 | EDT_ATTR_CHECKSET(threshold, WORK_REGISTER_THRESHOLD); | ||
692 | EDT_ATTR_CHECKSET(gain, WORK_REGISTER_GAIN); | ||
693 | EDT_ATTR_CHECKSET(offset, WORK_REGISTER_OFFSET); | ||
694 | EDT_ATTR_CHECKSET(report_rate, WORK_REGISTER_REPORT_RATE); | ||
695 | } | ||
696 | |||
697 | static void __devinit | ||
698 | edt_ft5x06_ts_get_parameters(struct edt_ft5x06_ts_data *tsdata) | ||
699 | { | ||
700 | tsdata->threshold = edt_ft5x06_register_read(tsdata, | ||
701 | WORK_REGISTER_THRESHOLD); | ||
702 | tsdata->gain = edt_ft5x06_register_read(tsdata, WORK_REGISTER_GAIN); | ||
703 | tsdata->offset = edt_ft5x06_register_read(tsdata, WORK_REGISTER_OFFSET); | ||
704 | tsdata->report_rate = edt_ft5x06_register_read(tsdata, | ||
705 | WORK_REGISTER_REPORT_RATE); | ||
706 | tsdata->num_x = edt_ft5x06_register_read(tsdata, WORK_REGISTER_NUM_X); | ||
707 | tsdata->num_y = edt_ft5x06_register_read(tsdata, WORK_REGISTER_NUM_Y); | ||
708 | } | ||
709 | |||
710 | static int __devinit edt_ft5x06_ts_probe(struct i2c_client *client, | ||
711 | const struct i2c_device_id *id) | ||
712 | { | ||
713 | const struct edt_ft5x06_platform_data *pdata = | ||
714 | client->dev.platform_data; | ||
715 | struct edt_ft5x06_ts_data *tsdata; | ||
716 | struct input_dev *input; | ||
717 | int error; | ||
718 | char fw_version[EDT_NAME_LEN]; | ||
719 | |||
720 | dev_dbg(&client->dev, "probing for EDT FT5x06 I2C\n"); | ||
721 | |||
722 | if (!pdata) { | ||
723 | dev_err(&client->dev, "no platform data?\n"); | ||
724 | return -EINVAL; | ||
725 | } | ||
726 | |||
727 | error = edt_ft5x06_ts_reset(client, pdata->reset_pin); | ||
728 | if (error) | ||
729 | return error; | ||
730 | |||
731 | if (gpio_is_valid(pdata->irq_pin)) { | ||
732 | error = gpio_request_one(pdata->irq_pin, | ||
733 | GPIOF_IN, "edt-ft5x06 irq"); | ||
734 | if (error) { | ||
735 | dev_err(&client->dev, | ||
736 | "Failed to request GPIO %d, error %d\n", | ||
737 | pdata->irq_pin, error); | ||
738 | return error; | ||
739 | } | ||
740 | } | ||
741 | |||
742 | tsdata = kzalloc(sizeof(*tsdata), GFP_KERNEL); | ||
743 | input = input_allocate_device(); | ||
744 | if (!tsdata || !input) { | ||
745 | dev_err(&client->dev, "failed to allocate driver data.\n"); | ||
746 | error = -ENOMEM; | ||
747 | goto err_free_mem; | ||
748 | } | ||
749 | |||
750 | mutex_init(&tsdata->mutex); | ||
751 | tsdata->client = client; | ||
752 | tsdata->input = input; | ||
753 | tsdata->factory_mode = false; | ||
754 | |||
755 | error = edt_ft5x06_ts_identify(client, tsdata->name, fw_version); | ||
756 | if (error) { | ||
757 | dev_err(&client->dev, "touchscreen probe failed\n"); | ||
758 | goto err_free_mem; | ||
759 | } | ||
760 | |||
761 | edt_ft5x06_ts_get_defaults(tsdata, pdata); | ||
762 | edt_ft5x06_ts_get_parameters(tsdata); | ||
763 | |||
764 | dev_dbg(&client->dev, | ||
765 | "Model \"%s\", Rev. \"%s\", %dx%d sensors\n", | ||
766 | tsdata->name, fw_version, tsdata->num_x, tsdata->num_y); | ||
767 | |||
768 | input->name = tsdata->name; | ||
769 | input->id.bustype = BUS_I2C; | ||
770 | input->dev.parent = &client->dev; | ||
771 | |||
772 | __set_bit(EV_SYN, input->evbit); | ||
773 | __set_bit(EV_KEY, input->evbit); | ||
774 | __set_bit(EV_ABS, input->evbit); | ||
775 | __set_bit(BTN_TOUCH, input->keybit); | ||
776 | input_set_abs_params(input, ABS_X, 0, tsdata->num_x * 64 - 1, 0, 0); | ||
777 | input_set_abs_params(input, ABS_Y, 0, tsdata->num_y * 64 - 1, 0, 0); | ||
778 | input_set_abs_params(input, ABS_MT_POSITION_X, | ||
779 | 0, tsdata->num_x * 64 - 1, 0, 0); | ||
780 | input_set_abs_params(input, ABS_MT_POSITION_Y, | ||
781 | 0, tsdata->num_y * 64 - 1, 0, 0); | ||
782 | error = input_mt_init_slots(input, MAX_SUPPORT_POINTS); | ||
783 | if (error) { | ||
784 | dev_err(&client->dev, "Unable to init MT slots.\n"); | ||
785 | goto err_free_mem; | ||
786 | } | ||
787 | |||
788 | input_set_drvdata(input, tsdata); | ||
789 | i2c_set_clientdata(client, tsdata); | ||
790 | |||
791 | error = request_threaded_irq(client->irq, NULL, edt_ft5x06_ts_isr, | ||
792 | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, | ||
793 | client->name, tsdata); | ||
794 | if (error) { | ||
795 | dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); | ||
796 | goto err_free_mem; | ||
797 | } | ||
798 | |||
799 | error = sysfs_create_group(&client->dev.kobj, &edt_ft5x06_attr_group); | ||
800 | if (error) | ||
801 | goto err_free_irq; | ||
802 | |||
803 | error = input_register_device(input); | ||
804 | if (error) | ||
805 | goto err_remove_attrs; | ||
806 | |||
807 | edt_ft5x06_ts_prepare_debugfs(tsdata, dev_driver_string(&client->dev)); | ||
808 | device_init_wakeup(&client->dev, 1); | ||
809 | |||
810 | dev_dbg(&client->dev, | ||
811 | "EDT FT5x06 initialized: IRQ pin %d, Reset pin %d.\n", | ||
812 | pdata->irq_pin, pdata->reset_pin); | ||
813 | |||
814 | return 0; | ||
815 | |||
816 | err_remove_attrs: | ||
817 | sysfs_remove_group(&client->dev.kobj, &edt_ft5x06_attr_group); | ||
818 | err_free_irq: | ||
819 | free_irq(client->irq, tsdata); | ||
820 | err_free_mem: | ||
821 | input_free_device(input); | ||
822 | kfree(tsdata); | ||
823 | |||
824 | if (gpio_is_valid(pdata->irq_pin)) | ||
825 | gpio_free(pdata->irq_pin); | ||
826 | |||
827 | return error; | ||
828 | } | ||
829 | |||
830 | static int __devexit edt_ft5x06_ts_remove(struct i2c_client *client) | ||
831 | { | ||
832 | const struct edt_ft5x06_platform_data *pdata = | ||
833 | dev_get_platdata(&client->dev); | ||
834 | struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client); | ||
835 | |||
836 | edt_ft5x06_ts_teardown_debugfs(tsdata); | ||
837 | sysfs_remove_group(&client->dev.kobj, &edt_ft5x06_attr_group); | ||
838 | |||
839 | free_irq(client->irq, tsdata); | ||
840 | input_unregister_device(tsdata->input); | ||
841 | |||
842 | if (gpio_is_valid(pdata->irq_pin)) | ||
843 | gpio_free(pdata->irq_pin); | ||
844 | if (gpio_is_valid(pdata->reset_pin)) | ||
845 | gpio_free(pdata->reset_pin); | ||
846 | |||
847 | kfree(tsdata); | ||
848 | |||
849 | return 0; | ||
850 | } | ||
851 | |||
852 | #ifdef CONFIG_PM_SLEEP | ||
853 | static int edt_ft5x06_ts_suspend(struct device *dev) | ||
854 | { | ||
855 | struct i2c_client *client = to_i2c_client(dev); | ||
856 | |||
857 | if (device_may_wakeup(dev)) | ||
858 | enable_irq_wake(client->irq); | ||
859 | |||
860 | return 0; | ||
861 | } | ||
862 | |||
863 | static int edt_ft5x06_ts_resume(struct device *dev) | ||
864 | { | ||
865 | struct i2c_client *client = to_i2c_client(dev); | ||
866 | |||
867 | if (device_may_wakeup(dev)) | ||
868 | disable_irq_wake(client->irq); | ||
869 | |||
870 | return 0; | ||
871 | } | ||
872 | #endif | ||
873 | |||
874 | static SIMPLE_DEV_PM_OPS(edt_ft5x06_ts_pm_ops, | ||
875 | edt_ft5x06_ts_suspend, edt_ft5x06_ts_resume); | ||
876 | |||
877 | static const struct i2c_device_id edt_ft5x06_ts_id[] = { | ||
878 | { "edt-ft5x06", 0 }, | ||
879 | { } | ||
880 | }; | ||
881 | MODULE_DEVICE_TABLE(i2c, edt_ft5x06_ts_id); | ||
882 | |||
883 | static struct i2c_driver edt_ft5x06_ts_driver = { | ||
884 | .driver = { | ||
885 | .owner = THIS_MODULE, | ||
886 | .name = "edt_ft5x06", | ||
887 | .pm = &edt_ft5x06_ts_pm_ops, | ||
888 | }, | ||
889 | .id_table = edt_ft5x06_ts_id, | ||
890 | .probe = edt_ft5x06_ts_probe, | ||
891 | .remove = __devexit_p(edt_ft5x06_ts_remove), | ||
892 | }; | ||
893 | |||
894 | module_i2c_driver(edt_ft5x06_ts_driver); | ||
895 | |||
896 | MODULE_AUTHOR("Simon Budig <simon.budig@kernelconcepts.de>"); | ||
897 | MODULE_DESCRIPTION("EDT FT5x06 I2C Touchscreen Driver"); | ||
898 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c index 503c7096ed36..908407efc672 100644 --- a/drivers/input/touchscreen/eeti_ts.c +++ b/drivers/input/touchscreen/eeti_ts.c | |||
@@ -48,7 +48,7 @@ struct eeti_ts_priv { | |||
48 | struct input_dev *input; | 48 | struct input_dev *input; |
49 | struct work_struct work; | 49 | struct work_struct work; |
50 | struct mutex mutex; | 50 | struct mutex mutex; |
51 | int irq, irq_active_high; | 51 | int irq_gpio, irq, irq_active_high; |
52 | }; | 52 | }; |
53 | 53 | ||
54 | #define EETI_TS_BITDEPTH (11) | 54 | #define EETI_TS_BITDEPTH (11) |
@@ -62,7 +62,7 @@ struct eeti_ts_priv { | |||
62 | 62 | ||
63 | static inline int eeti_ts_irq_active(struct eeti_ts_priv *priv) | 63 | static inline int eeti_ts_irq_active(struct eeti_ts_priv *priv) |
64 | { | 64 | { |
65 | return gpio_get_value(irq_to_gpio(priv->irq)) == priv->irq_active_high; | 65 | return gpio_get_value(priv->irq_gpio) == priv->irq_active_high; |
66 | } | 66 | } |
67 | 67 | ||
68 | static void eeti_ts_read(struct work_struct *work) | 68 | static void eeti_ts_read(struct work_struct *work) |
@@ -157,7 +157,7 @@ static void eeti_ts_close(struct input_dev *dev) | |||
157 | static int __devinit eeti_ts_probe(struct i2c_client *client, | 157 | static int __devinit eeti_ts_probe(struct i2c_client *client, |
158 | const struct i2c_device_id *idp) | 158 | const struct i2c_device_id *idp) |
159 | { | 159 | { |
160 | struct eeti_ts_platform_data *pdata; | 160 | struct eeti_ts_platform_data *pdata = client->dev.platform_data; |
161 | struct eeti_ts_priv *priv; | 161 | struct eeti_ts_priv *priv; |
162 | struct input_dev *input; | 162 | struct input_dev *input; |
163 | unsigned int irq_flags; | 163 | unsigned int irq_flags; |
@@ -199,9 +199,12 @@ static int __devinit eeti_ts_probe(struct i2c_client *client, | |||
199 | 199 | ||
200 | priv->client = client; | 200 | priv->client = client; |
201 | priv->input = input; | 201 | priv->input = input; |
202 | priv->irq = client->irq; | 202 | priv->irq_gpio = pdata->irq_gpio; |
203 | priv->irq = gpio_to_irq(pdata->irq_gpio); | ||
203 | 204 | ||
204 | pdata = client->dev.platform_data; | 205 | err = gpio_request_one(pdata->irq_gpio, GPIOF_IN, client->name); |
206 | if (err < 0) | ||
207 | goto err1; | ||
205 | 208 | ||
206 | if (pdata) | 209 | if (pdata) |
207 | priv->irq_active_high = pdata->irq_active_high; | 210 | priv->irq_active_high = pdata->irq_active_high; |
@@ -215,13 +218,13 @@ static int __devinit eeti_ts_probe(struct i2c_client *client, | |||
215 | 218 | ||
216 | err = input_register_device(input); | 219 | err = input_register_device(input); |
217 | if (err) | 220 | if (err) |
218 | goto err1; | 221 | goto err2; |
219 | 222 | ||
220 | err = request_irq(priv->irq, eeti_ts_isr, irq_flags, | 223 | err = request_irq(priv->irq, eeti_ts_isr, irq_flags, |
221 | client->name, priv); | 224 | client->name, priv); |
222 | if (err) { | 225 | if (err) { |
223 | dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); | 226 | dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); |
224 | goto err2; | 227 | goto err3; |
225 | } | 228 | } |
226 | 229 | ||
227 | /* | 230 | /* |
@@ -233,9 +236,11 @@ static int __devinit eeti_ts_probe(struct i2c_client *client, | |||
233 | device_init_wakeup(&client->dev, 0); | 236 | device_init_wakeup(&client->dev, 0); |
234 | return 0; | 237 | return 0; |
235 | 238 | ||
236 | err2: | 239 | err3: |
237 | input_unregister_device(input); | 240 | input_unregister_device(input); |
238 | input = NULL; /* so we dont try to free it below */ | 241 | input = NULL; /* so we dont try to free it below */ |
242 | err2: | ||
243 | gpio_free(pdata->irq_gpio); | ||
239 | err1: | 244 | err1: |
240 | input_free_device(input); | 245 | input_free_device(input); |
241 | kfree(priv); | 246 | kfree(priv); |
diff --git a/drivers/input/touchscreen/jornada720_ts.c b/drivers/input/touchscreen/jornada720_ts.c index d9be6eac99b1..7f03d1bd916e 100644 --- a/drivers/input/touchscreen/jornada720_ts.c +++ b/drivers/input/touchscreen/jornada720_ts.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/io.h> | ||
22 | 23 | ||
23 | #include <mach/hardware.h> | 24 | #include <mach/hardware.h> |
24 | #include <mach/jornada720.h> | 25 | #include <mach/jornada720.h> |
diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c new file mode 100644 index 000000000000..49c44bbf548d --- /dev/null +++ b/drivers/input/touchscreen/mms114.c | |||
@@ -0,0 +1,544 @@ | |||
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"); | ||
diff --git a/drivers/input/touchscreen/wacom_i2c.c b/drivers/input/touchscreen/wacom_i2c.c index 35572575d34a..0c01657132fd 100644 --- a/drivers/input/touchscreen/wacom_i2c.c +++ b/drivers/input/touchscreen/wacom_i2c.c | |||
@@ -149,7 +149,7 @@ static int __devinit wacom_i2c_probe(struct i2c_client *client, | |||
149 | { | 149 | { |
150 | struct wacom_i2c *wac_i2c; | 150 | struct wacom_i2c *wac_i2c; |
151 | struct input_dev *input; | 151 | struct input_dev *input; |
152 | struct wacom_features features; | 152 | struct wacom_features features = { 0 }; |
153 | int error; | 153 | int error; |
154 | 154 | ||
155 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { | 155 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { |