aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-03-20 01:27:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-20 01:27:06 -0400
commita952baa034ae7c2e4a66932005cbc7ebbccfe28d (patch)
treeff5abe0c77f5b129946300677d9b57b00d926a1e /drivers/input/keyboard
parent5bab188a316718a26346cdb25c4cc6b319f8f907 (diff)
parent97eb3f24352ec6632c2127b35d8087d2a809a9b9 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (64 commits) Input: tsc2005 - remove 'disable' sysfs attribute Input: tsc2005 - add open/close Input: tsc2005 - handle read errors from SPI layer Input: tsc2005 - do not rearm timer in hardirq handler Input: tsc2005 - don't use work for 'pen up' handling Input: tsc2005 - do not use 0 in place of NULL Input: tsc2005 - use true/false for boolean variables Input: tsc2005 - hide selftest attribute if we can't reset Input: tsc2005 - rework driver initialization code Input: tsc2005 - set up bus type in input device Input: tsc2005 - set up parent device Input: tsc2005 - clear driver data after unbinding Input: tsc2005 - add module description Input: tsc2005 - remove driver banner message Input: tsc2005 - remove incorrect module alias Input: tsc2005 - convert to using dev_pm_ops Input: tsc2005 - use spi_get/set_drvdata() Input: introduce tsc2005 driver Input: xen-kbdfront - move to drivers/input/misc Input: xen-kbdfront - add grant reference for shared page ...
Diffstat (limited to 'drivers/input/keyboard')
-rw-r--r--drivers/input/keyboard/Kconfig10
-rw-r--r--drivers/input/keyboard/Makefile1
-rw-r--r--drivers/input/keyboard/lm8323.c15
-rw-r--r--drivers/input/keyboard/max7359_keypad.c17
-rw-r--r--drivers/input/keyboard/mcs_touchkey.c57
-rw-r--r--drivers/input/keyboard/omap4-keypad.c74
-rw-r--r--drivers/input/keyboard/qt1070.c276
-rw-r--r--drivers/input/keyboard/tc3589x-keypad.c22
-rw-r--r--drivers/input/keyboard/tca6416-keypad.c28
9 files changed, 455 insertions, 45 deletions
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index c7a92028f450..b16bed038f72 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -112,6 +112,16 @@ config KEYBOARD_ATKBD_RDI_KEYCODES
112 right-hand column will be interpreted as the key shown in the 112 right-hand column will be interpreted as the key shown in the
113 left-hand column. 113 left-hand column.
114 114
115config KEYBOARD_QT1070
116 tristate "Atmel AT42QT1070 Touch Sensor Chip"
117 depends on I2C
118 help
119 Say Y here if you want to use Atmel AT42QT1070 QTouch
120 Sensor chip as input device.
121
122 To compile this driver as a module, choose M here:
123 the module will be called qt1070
124
115config KEYBOARD_QT2160 125config KEYBOARD_QT2160
116 tristate "Atmel AT42QT2160 Touch Sensor Chip" 126 tristate "Atmel AT42QT2160 Touch Sensor Chip"
117 depends on I2C && EXPERIMENTAL 127 depends on I2C && EXPERIMENTAL
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 468c627a2844..878e6c20deb0 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_KEYBOARD_OMAP4) += omap4-keypad.o
34obj-$(CONFIG_KEYBOARD_OPENCORES) += opencores-kbd.o 34obj-$(CONFIG_KEYBOARD_OPENCORES) += opencores-kbd.o
35obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o 35obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o
36obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o 36obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o
37obj-$(CONFIG_KEYBOARD_QT1070) += qt1070.o
37obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o 38obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o
38obj-$(CONFIG_KEYBOARD_SAMSUNG) += samsung-keypad.o 39obj-$(CONFIG_KEYBOARD_SAMSUNG) += samsung-keypad.o
39obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o 40obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o
diff --git a/drivers/input/keyboard/lm8323.c b/drivers/input/keyboard/lm8323.c
index f7c2a166576b..b732870ecc89 100644
--- a/drivers/input/keyboard/lm8323.c
+++ b/drivers/input/keyboard/lm8323.c
@@ -30,6 +30,7 @@
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/input.h> 31#include <linux/input.h>
32#include <linux/leds.h> 32#include <linux/leds.h>
33#include <linux/pm.h>
33#include <linux/i2c/lm8323.h> 34#include <linux/i2c/lm8323.h>
34#include <linux/slab.h> 35#include <linux/slab.h>
35 36
@@ -802,8 +803,9 @@ static int __devexit lm8323_remove(struct i2c_client *client)
802 * We don't need to explicitly suspend the chip, as it already switches off 803 * We don't need to explicitly suspend the chip, as it already switches off
803 * when there's no activity. 804 * when there's no activity.
804 */ 805 */
805static int lm8323_suspend(struct i2c_client *client, pm_message_t mesg) 806static int lm8323_suspend(struct device *dev)
806{ 807{
808 struct i2c_client *client = to_i2c_client(dev);
807 struct lm8323_chip *lm = i2c_get_clientdata(client); 809 struct lm8323_chip *lm = i2c_get_clientdata(client);
808 int i; 810 int i;
809 811
@@ -821,8 +823,9 @@ static int lm8323_suspend(struct i2c_client *client, pm_message_t mesg)
821 return 0; 823 return 0;
822} 824}
823 825
824static int lm8323_resume(struct i2c_client *client) 826static int lm8323_resume(struct device *dev)
825{ 827{
828 struct i2c_client *client = to_i2c_client(dev);
826 struct lm8323_chip *lm = i2c_get_clientdata(client); 829 struct lm8323_chip *lm = i2c_get_clientdata(client);
827 int i; 830 int i;
828 831
@@ -839,11 +842,10 @@ static int lm8323_resume(struct i2c_client *client)
839 842
840 return 0; 843 return 0;
841} 844}
842#else
843#define lm8323_suspend NULL
844#define lm8323_resume NULL
845#endif 845#endif
846 846
847static SIMPLE_DEV_PM_OPS(lm8323_pm_ops, lm8323_suspend, lm8323_resume);
848
847static const struct i2c_device_id lm8323_id[] = { 849static const struct i2c_device_id lm8323_id[] = {
848 { "lm8323", 0 }, 850 { "lm8323", 0 },
849 { } 851 { }
@@ -852,11 +854,10 @@ static const struct i2c_device_id lm8323_id[] = {
852static struct i2c_driver lm8323_i2c_driver = { 854static struct i2c_driver lm8323_i2c_driver = {
853 .driver = { 855 .driver = {
854 .name = "lm8323", 856 .name = "lm8323",
857 .pm = &lm8323_pm_ops,
855 }, 858 },
856 .probe = lm8323_probe, 859 .probe = lm8323_probe,
857 .remove = __devexit_p(lm8323_remove), 860 .remove = __devexit_p(lm8323_remove),
858 .suspend = lm8323_suspend,
859 .resume = lm8323_resume,
860 .id_table = lm8323_id, 861 .id_table = lm8323_id,
861}; 862};
862MODULE_DEVICE_TABLE(i2c, lm8323_id); 863MODULE_DEVICE_TABLE(i2c, lm8323_id);
diff --git a/drivers/input/keyboard/max7359_keypad.c b/drivers/input/keyboard/max7359_keypad.c
index 9091ff5ea808..5afe35ad24d3 100644
--- a/drivers/input/keyboard/max7359_keypad.c
+++ b/drivers/input/keyboard/max7359_keypad.c
@@ -17,6 +17,7 @@
17#include <linux/i2c.h> 17#include <linux/i2c.h>
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/pm.h>
20#include <linux/input.h> 21#include <linux/input.h>
21#include <linux/input/matrix_keypad.h> 22#include <linux/input/matrix_keypad.h>
22 23
@@ -271,8 +272,10 @@ static int __devexit max7359_remove(struct i2c_client *client)
271} 272}
272 273
273#ifdef CONFIG_PM 274#ifdef CONFIG_PM
274static int max7359_suspend(struct i2c_client *client, pm_message_t mesg) 275static int max7359_suspend(struct device *dev)
275{ 276{
277 struct i2c_client *client = to_i2c_client(dev);
278
276 max7359_fall_deepsleep(client); 279 max7359_fall_deepsleep(client);
277 280
278 if (device_may_wakeup(&client->dev)) 281 if (device_may_wakeup(&client->dev))
@@ -281,8 +284,10 @@ static int max7359_suspend(struct i2c_client *client, pm_message_t mesg)
281 return 0; 284 return 0;
282} 285}
283 286
284static int max7359_resume(struct i2c_client *client) 287static int max7359_resume(struct device *dev)
285{ 288{
289 struct i2c_client *client = to_i2c_client(dev);
290
286 if (device_may_wakeup(&client->dev)) 291 if (device_may_wakeup(&client->dev))
287 disable_irq_wake(client->irq); 292 disable_irq_wake(client->irq);
288 293
@@ -291,11 +296,10 @@ static int max7359_resume(struct i2c_client *client)
291 296
292 return 0; 297 return 0;
293} 298}
294#else
295#define max7359_suspend NULL
296#define max7359_resume NULL
297#endif 299#endif
298 300
301static SIMPLE_DEV_PM_OPS(max7359_pm, max7359_suspend, max7359_resume);
302
299static const struct i2c_device_id max7359_ids[] = { 303static const struct i2c_device_id max7359_ids[] = {
300 { "max7359", 0 }, 304 { "max7359", 0 },
301 { } 305 { }
@@ -305,11 +309,10 @@ MODULE_DEVICE_TABLE(i2c, max7359_ids);
305static struct i2c_driver max7359_i2c_driver = { 309static struct i2c_driver max7359_i2c_driver = {
306 .driver = { 310 .driver = {
307 .name = "max7359", 311 .name = "max7359",
312 .pm = &max7359_pm,
308 }, 313 },
309 .probe = max7359_probe, 314 .probe = max7359_probe,
310 .remove = __devexit_p(max7359_remove), 315 .remove = __devexit_p(max7359_remove),
311 .suspend = max7359_suspend,
312 .resume = max7359_resume,
313 .id_table = max7359_ids, 316 .id_table = max7359_ids,
314}; 317};
315 318
diff --git a/drivers/input/keyboard/mcs_touchkey.c b/drivers/input/keyboard/mcs_touchkey.c
index 63b849d7e90b..af1aab324a4c 100644
--- a/drivers/input/keyboard/mcs_touchkey.c
+++ b/drivers/input/keyboard/mcs_touchkey.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * mcs_touchkey.c - Touchkey driver for MELFAS MCS5000/5080 controller 2 * Touchkey driver for MELFAS MCS5000/5080 controller
3 * 3 *
4 * Copyright (C) 2010 Samsung Electronics Co.Ltd 4 * Copyright (C) 2010 Samsung Electronics Co.Ltd
5 * Author: HeungJun Kim <riverful.kim@samsung.com> 5 * Author: HeungJun Kim <riverful.kim@samsung.com>
@@ -19,6 +19,7 @@
19#include <linux/input.h> 19#include <linux/input.h>
20#include <linux/irq.h> 20#include <linux/irq.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/pm.h>
22 23
23/* MCS5000 Touchkey */ 24/* MCS5000 Touchkey */
24#define MCS5000_TOUCHKEY_STATUS 0x04 25#define MCS5000_TOUCHKEY_STATUS 0x04
@@ -45,6 +46,8 @@ struct mcs_touchkey_chip {
45}; 46};
46 47
47struct mcs_touchkey_data { 48struct mcs_touchkey_data {
49 void (*poweron)(bool);
50
48 struct i2c_client *client; 51 struct i2c_client *client;
49 struct input_dev *input_dev; 52 struct input_dev *input_dev;
50 struct mcs_touchkey_chip chip; 53 struct mcs_touchkey_chip chip;
@@ -169,6 +172,11 @@ static int __devinit mcs_touchkey_probe(struct i2c_client *client,
169 if (pdata->cfg_pin) 172 if (pdata->cfg_pin)
170 pdata->cfg_pin(); 173 pdata->cfg_pin();
171 174
175 if (pdata->poweron) {
176 data->poweron = pdata->poweron;
177 data->poweron(true);
178 }
179
172 error = request_threaded_irq(client->irq, NULL, mcs_touchkey_interrupt, 180 error = request_threaded_irq(client->irq, NULL, mcs_touchkey_interrupt,
173 IRQF_TRIGGER_FALLING, client->dev.driver->name, data); 181 IRQF_TRIGGER_FALLING, client->dev.driver->name, data);
174 if (error) { 182 if (error) {
@@ -196,12 +204,57 @@ static int __devexit mcs_touchkey_remove(struct i2c_client *client)
196 struct mcs_touchkey_data *data = i2c_get_clientdata(client); 204 struct mcs_touchkey_data *data = i2c_get_clientdata(client);
197 205
198 free_irq(client->irq, data); 206 free_irq(client->irq, data);
207 if (data->poweron)
208 data->poweron(false);
199 input_unregister_device(data->input_dev); 209 input_unregister_device(data->input_dev);
200 kfree(data); 210 kfree(data);
201 211
202 return 0; 212 return 0;
203} 213}
204 214
215static void mcs_touchkey_shutdown(struct i2c_client *client)
216{
217 struct mcs_touchkey_data *data = i2c_get_clientdata(client);
218
219 if (data->poweron)
220 data->poweron(false);
221}
222
223#ifdef CONFIG_PM_SLEEP
224static int mcs_touchkey_suspend(struct device *dev)
225{
226 struct mcs_touchkey_data *data = dev_get_drvdata(dev);
227 struct i2c_client *client = data->client;
228
229 /* Disable the work */
230 disable_irq(client->irq);
231
232 /* Finally turn off the power */
233 if (data->poweron)
234 data->poweron(false);
235
236 return 0;
237}
238
239static int mcs_touchkey_resume(struct device *dev)
240{
241 struct mcs_touchkey_data *data = dev_get_drvdata(dev);
242 struct i2c_client *client = data->client;
243
244 /* Enable the device first */
245 if (data->poweron)
246 data->poweron(true);
247
248 /* Enable irq again */
249 enable_irq(client->irq);
250
251 return 0;
252}
253#endif
254
255static SIMPLE_DEV_PM_OPS(mcs_touchkey_pm_ops,
256 mcs_touchkey_suspend, mcs_touchkey_resume);
257
205static const struct i2c_device_id mcs_touchkey_id[] = { 258static const struct i2c_device_id mcs_touchkey_id[] = {
206 { "mcs5000_touchkey", MCS5000_TOUCHKEY }, 259 { "mcs5000_touchkey", MCS5000_TOUCHKEY },
207 { "mcs5080_touchkey", MCS5080_TOUCHKEY }, 260 { "mcs5080_touchkey", MCS5080_TOUCHKEY },
@@ -213,9 +266,11 @@ static struct i2c_driver mcs_touchkey_driver = {
213 .driver = { 266 .driver = {
214 .name = "mcs_touchkey", 267 .name = "mcs_touchkey",
215 .owner = THIS_MODULE, 268 .owner = THIS_MODULE,
269 .pm = &mcs_touchkey_pm_ops,
216 }, 270 },
217 .probe = mcs_touchkey_probe, 271 .probe = mcs_touchkey_probe,
218 .remove = __devexit_p(mcs_touchkey_remove), 272 .remove = __devexit_p(mcs_touchkey_remove),
273 .shutdown = mcs_touchkey_shutdown,
219 .id_table = mcs_touchkey_id, 274 .id_table = mcs_touchkey_id,
220}; 275};
221 276
diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index 45bd0977d006..c51a3c4a7feb 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -29,6 +29,7 @@
29#include <linux/io.h> 29#include <linux/io.h>
30#include <linux/input.h> 30#include <linux/input.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/pm_runtime.h>
32 33
33#include <plat/omap4-keypad.h> 34#include <plat/omap4-keypad.h>
34 35
@@ -80,20 +81,6 @@ struct omap4_keypad {
80 unsigned short keymap[]; 81 unsigned short keymap[];
81}; 82};
82 83
83static void __devinit omap4_keypad_config(struct omap4_keypad *keypad_data)
84{
85 __raw_writel(OMAP4_VAL_FUNCTIONALCFG,
86 keypad_data->base + OMAP4_KBD_CTRL);
87 __raw_writel(OMAP4_VAL_DEBOUNCINGTIME,
88 keypad_data->base + OMAP4_KBD_DEBOUNCINGTIME);
89 __raw_writel(OMAP4_VAL_IRQDISABLE,
90 keypad_data->base + OMAP4_KBD_IRQSTATUS);
91 __raw_writel(OMAP4_DEF_IRQENABLE_EVENTEN | OMAP4_DEF_IRQENABLE_LONGKEY,
92 keypad_data->base + OMAP4_KBD_IRQENABLE);
93 __raw_writel(OMAP4_DEF_WUP_EVENT_ENA | OMAP4_DEF_WUP_LONG_KEY_ENA,
94 keypad_data->base + OMAP4_KBD_WAKEUPENABLE);
95}
96
97/* Interrupt handler */ 84/* Interrupt handler */
98static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) 85static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id)
99{ 86{
@@ -144,6 +131,49 @@ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id)
144 return IRQ_HANDLED; 131 return IRQ_HANDLED;
145} 132}
146 133
134static int omap4_keypad_open(struct input_dev *input)
135{
136 struct omap4_keypad *keypad_data = input_get_drvdata(input);
137
138 pm_runtime_get_sync(input->dev.parent);
139
140 disable_irq(keypad_data->irq);
141
142 __raw_writel(OMAP4_VAL_FUNCTIONALCFG,
143 keypad_data->base + OMAP4_KBD_CTRL);
144 __raw_writel(OMAP4_VAL_DEBOUNCINGTIME,
145 keypad_data->base + OMAP4_KBD_DEBOUNCINGTIME);
146 __raw_writel(OMAP4_VAL_IRQDISABLE,
147 keypad_data->base + OMAP4_KBD_IRQSTATUS);
148 __raw_writel(OMAP4_DEF_IRQENABLE_EVENTEN | OMAP4_DEF_IRQENABLE_LONGKEY,
149 keypad_data->base + OMAP4_KBD_IRQENABLE);
150 __raw_writel(OMAP4_DEF_WUP_EVENT_ENA | OMAP4_DEF_WUP_LONG_KEY_ENA,
151 keypad_data->base + OMAP4_KBD_WAKEUPENABLE);
152
153 enable_irq(keypad_data->irq);
154
155 return 0;
156}
157
158static void omap4_keypad_close(struct input_dev *input)
159{
160 struct omap4_keypad *keypad_data = input_get_drvdata(input);
161
162 disable_irq(keypad_data->irq);
163
164 /* Disable interrupts */
165 __raw_writel(OMAP4_VAL_IRQDISABLE,
166 keypad_data->base + OMAP4_KBD_IRQENABLE);
167
168 /* clear pending interrupts */
169 __raw_writel(__raw_readl(keypad_data->base + OMAP4_KBD_IRQSTATUS),
170 keypad_data->base + OMAP4_KBD_IRQSTATUS);
171
172 enable_irq(keypad_data->irq);
173
174 pm_runtime_put_sync(input->dev.parent);
175}
176
147static int __devinit omap4_keypad_probe(struct platform_device *pdev) 177static int __devinit omap4_keypad_probe(struct platform_device *pdev)
148{ 178{
149 const struct omap4_keypad_platform_data *pdata; 179 const struct omap4_keypad_platform_data *pdata;
@@ -225,6 +255,9 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev)
225 input_dev->id.product = 0x0001; 255 input_dev->id.product = 0x0001;
226 input_dev->id.version = 0x0001; 256 input_dev->id.version = 0x0001;
227 257
258 input_dev->open = omap4_keypad_open;
259 input_dev->close = omap4_keypad_close;
260
228 input_dev->keycode = keypad_data->keymap; 261 input_dev->keycode = keypad_data->keymap;
229 input_dev->keycodesize = sizeof(keypad_data->keymap[0]); 262 input_dev->keycodesize = sizeof(keypad_data->keymap[0]);
230 input_dev->keycodemax = max_keys; 263 input_dev->keycodemax = max_keys;
@@ -239,8 +272,6 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev)
239 matrix_keypad_build_keymap(pdata->keymap_data, row_shift, 272 matrix_keypad_build_keymap(pdata->keymap_data, row_shift,
240 input_dev->keycode, input_dev->keybit); 273 input_dev->keycode, input_dev->keybit);
241 274
242 omap4_keypad_config(keypad_data);
243
244 error = request_irq(keypad_data->irq, omap4_keypad_interrupt, 275 error = request_irq(keypad_data->irq, omap4_keypad_interrupt,
245 IRQF_TRIGGER_RISING, 276 IRQF_TRIGGER_RISING,
246 "omap4-keypad", keypad_data); 277 "omap4-keypad", keypad_data);
@@ -249,17 +280,19 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev)
249 goto err_free_input; 280 goto err_free_input;
250 } 281 }
251 282
283 pm_runtime_enable(&pdev->dev);
284
252 error = input_register_device(keypad_data->input); 285 error = input_register_device(keypad_data->input);
253 if (error < 0) { 286 if (error < 0) {
254 dev_err(&pdev->dev, "failed to register input device\n"); 287 dev_err(&pdev->dev, "failed to register input device\n");
255 goto err_free_irq; 288 goto err_pm_disable;
256 } 289 }
257 290
258
259 platform_set_drvdata(pdev, keypad_data); 291 platform_set_drvdata(pdev, keypad_data);
260 return 0; 292 return 0;
261 293
262err_free_irq: 294err_pm_disable:
295 pm_runtime_disable(&pdev->dev);
263 free_irq(keypad_data->irq, keypad_data); 296 free_irq(keypad_data->irq, keypad_data);
264err_free_input: 297err_free_input:
265 input_free_device(input_dev); 298 input_free_device(input_dev);
@@ -278,6 +311,9 @@ static int __devexit omap4_keypad_remove(struct platform_device *pdev)
278 struct resource *res; 311 struct resource *res;
279 312
280 free_irq(keypad_data->irq, keypad_data); 313 free_irq(keypad_data->irq, keypad_data);
314
315 pm_runtime_disable(&pdev->dev);
316
281 input_unregister_device(keypad_data->input); 317 input_unregister_device(keypad_data->input);
282 318
283 iounmap(keypad_data->base); 319 iounmap(keypad_data->base);
diff --git a/drivers/input/keyboard/qt1070.c b/drivers/input/keyboard/qt1070.c
new file mode 100644
index 000000000000..fba8404c7297
--- /dev/null
+++ b/drivers/input/keyboard/qt1070.c
@@ -0,0 +1,276 @@
1/*
2 * Atmel AT42QT1070 QTouch Sensor Controller
3 *
4 * Copyright (C) 2011 Atmel
5 *
6 * Authors: Bo Shen <voice.shen@atmel.com>
7 *
8 * Base on AT42QT2160 driver by:
9 * Raphael Derosso Pereira <raphaelpereira@gmail.com>
10 * Copyright (C) 2009
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */
26#include <linux/kernel.h>
27#include <linux/module.h>
28#include <linux/init.h>
29#include <linux/i2c.h>
30#include <linux/input.h>
31#include <linux/slab.h>
32#include <linux/irq.h>
33#include <linux/interrupt.h>
34#include <linux/jiffies.h>
35#include <linux/delay.h>
36
37/* Address for each register */
38#define CHIP_ID 0x00
39#define QT1070_CHIP_ID 0x2E
40
41#define FW_VERSION 0x01
42#define QT1070_FW_VERSION 0x15
43
44#define DET_STATUS 0x02
45
46#define KEY_STATUS 0x03
47
48/* Calibrate */
49#define CALIBRATE_CMD 0x38
50#define QT1070_CAL_TIME 200
51
52/* Reset */
53#define RESET 0x39
54#define QT1070_RESET_TIME 255
55
56/* AT42QT1070 support up to 7 keys */
57static const unsigned short qt1070_key2code[] = {
58 KEY_0, KEY_1, KEY_2, KEY_3,
59 KEY_4, KEY_5, KEY_6,
60};
61
62struct qt1070_data {
63 struct i2c_client *client;
64 struct input_dev *input;
65 unsigned int irq;
66 unsigned short keycodes[ARRAY_SIZE(qt1070_key2code)];
67 u8 last_keys;
68};
69
70static int qt1070_read(struct i2c_client *client, u8 reg)
71{
72 int ret;
73
74 ret = i2c_smbus_read_byte_data(client, reg);
75 if (ret < 0)
76 dev_err(&client->dev,
77 "can not read register, returned %d\n", ret);
78
79 return ret;
80}
81
82static int qt1070_write(struct i2c_client *client, u8 reg, u8 data)
83{
84 int ret;
85
86 ret = i2c_smbus_write_byte_data(client, reg, data);
87 if (ret < 0)
88 dev_err(&client->dev,
89 "can not write register, returned %d\n", ret);
90
91 return ret;
92}
93
94static bool __devinit qt1070_identify(struct i2c_client *client)
95{
96 int id, ver;
97
98 /* Read Chip ID */
99 id = qt1070_read(client, CHIP_ID);
100 if (id != QT1070_CHIP_ID) {
101 dev_err(&client->dev, "ID %d not supported\n", id);
102 return false;
103 }
104
105 /* Read firmware version */
106 ver = qt1070_read(client, FW_VERSION);
107 if (ver < 0) {
108 dev_err(&client->dev, "could not read the firmware version\n");
109 return false;
110 }
111
112 dev_info(&client->dev, "AT42QT1070 firmware version %x\n", ver);
113
114 return true;
115}
116
117static irqreturn_t qt1070_interrupt(int irq, void *dev_id)
118{
119 struct qt1070_data *data = dev_id;
120 struct i2c_client *client = data->client;
121 struct input_dev *input = data->input;
122 int i;
123 u8 new_keys, keyval, mask = 0x01;
124
125 /* Read the detected status register, thus clearing interrupt */
126 qt1070_read(client, DET_STATUS);
127
128 /* Read which key changed */
129 new_keys = qt1070_read(client, KEY_STATUS);
130
131 for (i = 0; i < ARRAY_SIZE(qt1070_key2code); i++) {
132 keyval = new_keys & mask;
133 if ((data->last_keys & mask) != keyval)
134 input_report_key(input, data->keycodes[i], keyval);
135 mask <<= 1;
136 }
137 input_sync(input);
138
139 data->last_keys = new_keys;
140 return IRQ_HANDLED;
141}
142
143static int __devinit qt1070_probe(struct i2c_client *client,
144 const struct i2c_device_id *id)
145{
146 struct qt1070_data *data;
147 struct input_dev *input;
148 int i;
149 int err;
150
151 err = i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE);
152 if (!err) {
153 dev_err(&client->dev, "%s adapter not supported\n",
154 dev_driver_string(&client->adapter->dev));
155 return -ENODEV;
156 }
157
158 if (!client->irq) {
159 dev_err(&client->dev, "please assign the irq to this device\n");
160 return -EINVAL;
161 }
162
163 /* Identify the qt1070 chip */
164 if (!qt1070_identify(client))
165 return -ENODEV;
166
167 data = kzalloc(sizeof(struct qt1070_data), GFP_KERNEL);
168 input = input_allocate_device();
169 if (!data || !input) {
170 dev_err(&client->dev, "insufficient memory\n");
171 err = -ENOMEM;
172 goto err_free_mem;
173 }
174
175 data->client = client;
176 data->input = input;
177 data->irq = client->irq;
178
179 input->name = "AT42QT1070 QTouch Sensor";
180 input->dev.parent = &client->dev;
181 input->id.bustype = BUS_I2C;
182
183 /* Add the keycode */
184 input->keycode = data->keycodes;
185 input->keycodesize = sizeof(data->keycodes[0]);
186 input->keycodemax = ARRAY_SIZE(qt1070_key2code);
187
188 __set_bit(EV_KEY, input->evbit);
189
190 for (i = 0; i < ARRAY_SIZE(qt1070_key2code); i++) {
191 data->keycodes[i] = qt1070_key2code[i];
192 __set_bit(qt1070_key2code[i], input->keybit);
193 }
194
195 /* Calibrate device */
196 qt1070_write(client, CALIBRATE_CMD, 1);
197 msleep(QT1070_CAL_TIME);
198
199 /* Soft reset */
200 qt1070_write(client, RESET, 1);
201 msleep(QT1070_RESET_TIME);
202
203 err = request_threaded_irq(client->irq, NULL, qt1070_interrupt,
204 IRQF_TRIGGER_NONE, client->dev.driver->name, data);
205 if (err) {
206 dev_err(&client->dev, "fail to request irq\n");
207 goto err_free_mem;
208 }
209
210 /* Register the input device */
211 err = input_register_device(data->input);
212 if (err) {
213 dev_err(&client->dev, "Failed to register input device\n");
214 goto err_free_irq;
215 }
216
217 i2c_set_clientdata(client, data);
218
219 /* Read to clear the chang line */
220 qt1070_read(client, DET_STATUS);
221
222 return 0;
223
224err_free_irq:
225 free_irq(client->irq, data);
226err_free_mem:
227 input_free_device(input);
228 kfree(data);
229 return err;
230}
231
232static int __devexit qt1070_remove(struct i2c_client *client)
233{
234 struct qt1070_data *data = i2c_get_clientdata(client);
235
236 /* Release IRQ */
237 free_irq(client->irq, data);
238
239 input_unregister_device(data->input);
240 kfree(data);
241
242 i2c_set_clientdata(client, NULL);
243
244 return 0;
245}
246
247static const struct i2c_device_id qt1070_id[] = {
248 { "qt1070", 0 },
249 { },
250};
251
252static struct i2c_driver qt1070_driver = {
253 .driver = {
254 .name = "qt1070",
255 .owner = THIS_MODULE,
256 },
257 .id_table = qt1070_id,
258 .probe = qt1070_probe,
259 .remove = __devexit_p(qt1070_remove),
260};
261
262static int __init qt1070_init(void)
263{
264 return i2c_add_driver(&qt1070_driver);
265}
266module_init(qt1070_init);
267
268static void __exit qt1070_exit(void)
269{
270 i2c_del_driver(&qt1070_driver);
271}
272module_exit(qt1070_exit);
273
274MODULE_AUTHOR("Bo Shen <voice.shen@atmel.com>");
275MODULE_DESCRIPTION("Driver for AT42QT1070 QTouch sensor");
276MODULE_LICENSE("GPL");
diff --git a/drivers/input/keyboard/tc3589x-keypad.c b/drivers/input/keyboard/tc3589x-keypad.c
index dbbe761778d2..99122f59e988 100644
--- a/drivers/input/keyboard/tc3589x-keypad.c
+++ b/drivers/input/keyboard/tc3589x-keypad.c
@@ -402,7 +402,7 @@ static int __devexit tc3589x_keypad_remove(struct platform_device *pdev)
402 return 0; 402 return 0;
403} 403}
404 404
405#ifdef CONFIG_PM 405#ifdef CONFIG_PM_SLEEP
406static int tc3589x_keypad_suspend(struct device *dev) 406static int tc3589x_keypad_suspend(struct device *dev)
407{ 407{
408 struct platform_device *pdev = to_platform_device(dev); 408 struct platform_device *pdev = to_platform_device(dev);
@@ -439,19 +439,19 @@ static int tc3589x_keypad_resume(struct device *dev)
439 439
440 return 0; 440 return 0;
441} 441}
442
443static const SIMPLE_DEV_PM_OPS(tc3589x_keypad_dev_pm_ops,
444 tc3589x_keypad_suspend, tc3589x_keypad_resume);
445#endif 442#endif
446 443
444static SIMPLE_DEV_PM_OPS(tc3589x_keypad_dev_pm_ops,
445 tc3589x_keypad_suspend, tc3589x_keypad_resume);
446
447static struct platform_driver tc3589x_keypad_driver = { 447static struct platform_driver tc3589x_keypad_driver = {
448 .driver.name = "tc3589x-keypad", 448 .driver = {
449 .driver.owner = THIS_MODULE, 449 .name = "tc3589x-keypad",
450#ifdef CONFIG_PM 450 .owner = THIS_MODULE,
451 .driver.pm = &tc3589x_keypad_dev_pm_ops, 451 .pm = &tc3589x_keypad_dev_pm_ops,
452#endif 452 },
453 .probe = tc3589x_keypad_probe, 453 .probe = tc3589x_keypad_probe,
454 .remove = __devexit_p(tc3589x_keypad_remove), 454 .remove = __devexit_p(tc3589x_keypad_remove),
455}; 455};
456 456
457static int __init tc3589x_keypad_init(void) 457static int __init tc3589x_keypad_init(void)
diff --git a/drivers/input/keyboard/tca6416-keypad.c b/drivers/input/keyboard/tca6416-keypad.c
index 800fbccf1f0f..3afea3f89718 100644
--- a/drivers/input/keyboard/tca6416-keypad.c
+++ b/drivers/input/keyboard/tca6416-keypad.c
@@ -297,6 +297,7 @@ static int __devinit tca6416_keypad_probe(struct i2c_client *client,
297 } 297 }
298 298
299 i2c_set_clientdata(client, chip); 299 i2c_set_clientdata(client, chip);
300 device_init_wakeup(&client->dev, 1);
300 301
301 return 0; 302 return 0;
302 303
@@ -326,10 +327,37 @@ static int __devexit tca6416_keypad_remove(struct i2c_client *client)
326 return 0; 327 return 0;
327} 328}
328 329
330#ifdef CONFIG_PM_SLEEP
331static int tca6416_keypad_suspend(struct device *dev)
332{
333 struct i2c_client *client = to_i2c_client(dev);
334 struct tca6416_keypad_chip *chip = i2c_get_clientdata(client);
335
336 if (device_may_wakeup(dev))
337 enable_irq_wake(chip->irqnum);
338
339 return 0;
340}
341
342static int tca6416_keypad_resume(struct device *dev)
343{
344 struct i2c_client *client = to_i2c_client(dev);
345 struct tca6416_keypad_chip *chip = i2c_get_clientdata(client);
346
347 if (device_may_wakeup(dev))
348 disable_irq_wake(chip->irqnum);
349
350 return 0;
351}
352#endif
353
354static SIMPLE_DEV_PM_OPS(tca6416_keypad_dev_pm_ops,
355 tca6416_keypad_suspend, tca6416_keypad_resume);
329 356
330static struct i2c_driver tca6416_keypad_driver = { 357static struct i2c_driver tca6416_keypad_driver = {
331 .driver = { 358 .driver = {
332 .name = "tca6416-keypad", 359 .name = "tca6416-keypad",
360 .pm = &tca6416_keypad_dev_pm_ops,
333 }, 361 },
334 .probe = tca6416_keypad_probe, 362 .probe = tca6416_keypad_probe,
335 .remove = __devexit_p(tca6416_keypad_remove), 363 .remove = __devexit_p(tca6416_keypad_remove),