aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/keyboard')
-rw-r--r--drivers/input/keyboard/imx_keypad.c7
-rw-r--r--drivers/input/keyboard/max7359_keypad.c2
-rw-r--r--drivers/input/keyboard/nspire-keypad.c7
-rw-r--r--drivers/input/keyboard/omap4-keypad.c95
-rw-r--r--drivers/input/keyboard/qt1070.c27
-rw-r--r--drivers/input/keyboard/spear-keyboard.c7
-rw-r--r--drivers/input/keyboard/tegra-kbc.c7
7 files changed, 103 insertions, 49 deletions
diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
index 03c8cc5cb6c1..328cfc1eed95 100644
--- a/drivers/input/keyboard/imx_keypad.c
+++ b/drivers/input/keyboard/imx_keypad.c
@@ -442,12 +442,6 @@ static int imx_keypad_probe(struct platform_device *pdev)
442 return -EINVAL; 442 return -EINVAL;
443 } 443 }
444 444
445 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
446 if (res == NULL) {
447 dev_err(&pdev->dev, "no I/O memory defined in platform data\n");
448 return -EINVAL;
449 }
450
451 input_dev = devm_input_allocate_device(&pdev->dev); 445 input_dev = devm_input_allocate_device(&pdev->dev);
452 if (!input_dev) { 446 if (!input_dev) {
453 dev_err(&pdev->dev, "failed to allocate the input device\n"); 447 dev_err(&pdev->dev, "failed to allocate the input device\n");
@@ -468,6 +462,7 @@ static int imx_keypad_probe(struct platform_device *pdev)
468 setup_timer(&keypad->check_matrix_timer, 462 setup_timer(&keypad->check_matrix_timer,
469 imx_keypad_check_for_events, (unsigned long) keypad); 463 imx_keypad_check_for_events, (unsigned long) keypad);
470 464
465 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
471 keypad->mmio_base = devm_ioremap_resource(&pdev->dev, res); 466 keypad->mmio_base = devm_ioremap_resource(&pdev->dev, res);
472 if (IS_ERR(keypad->mmio_base)) 467 if (IS_ERR(keypad->mmio_base))
473 return PTR_ERR(keypad->mmio_base); 468 return PTR_ERR(keypad->mmio_base);
diff --git a/drivers/input/keyboard/max7359_keypad.c b/drivers/input/keyboard/max7359_keypad.c
index 7c7af2b01e65..bc2cdaf563fd 100644
--- a/drivers/input/keyboard/max7359_keypad.c
+++ b/drivers/input/keyboard/max7359_keypad.c
@@ -271,7 +271,7 @@ static int max7359_remove(struct i2c_client *client)
271 return 0; 271 return 0;
272} 272}
273 273
274#ifdef CONFIG_PM 274#ifdef CONFIG_PM_SLEEP
275static int max7359_suspend(struct device *dev) 275static int max7359_suspend(struct device *dev)
276{ 276{
277 struct i2c_client *client = to_i2c_client(dev); 277 struct i2c_client *client = to_i2c_client(dev);
diff --git a/drivers/input/keyboard/nspire-keypad.c b/drivers/input/keyboard/nspire-keypad.c
index 20d872d6f603..b3e3edab6d9f 100644
--- a/drivers/input/keyboard/nspire-keypad.c
+++ b/drivers/input/keyboard/nspire-keypad.c
@@ -171,12 +171,6 @@ static int nspire_keypad_probe(struct platform_device *pdev)
171 return -EINVAL; 171 return -EINVAL;
172 } 172 }
173 173
174 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
175 if (!res) {
176 dev_err(&pdev->dev, "missing platform resources\n");
177 return -EINVAL;
178 }
179
180 keypad = devm_kzalloc(&pdev->dev, sizeof(struct nspire_keypad), 174 keypad = devm_kzalloc(&pdev->dev, sizeof(struct nspire_keypad),
181 GFP_KERNEL); 175 GFP_KERNEL);
182 if (!keypad) { 176 if (!keypad) {
@@ -208,6 +202,7 @@ static int nspire_keypad_probe(struct platform_device *pdev)
208 return PTR_ERR(keypad->clk); 202 return PTR_ERR(keypad->clk);
209 } 203 }
210 204
205 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
211 keypad->reg_base = devm_ioremap_resource(&pdev->dev, res); 206 keypad->reg_base = devm_ioremap_resource(&pdev->dev, res);
212 if (IS_ERR(keypad->reg_base)) 207 if (IS_ERR(keypad->reg_base))
213 return PTR_ERR(keypad->reg_base); 208 return PTR_ERR(keypad->reg_base);
diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index f4aa53a1fd69..30acfd49fa6c 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -53,21 +53,17 @@
53#define OMAP4_KBD_FULLCODE63_32 0x48 53#define OMAP4_KBD_FULLCODE63_32 0x48
54 54
55/* OMAP4 bit definitions */ 55/* OMAP4 bit definitions */
56#define OMAP4_DEF_IRQENABLE_EVENTEN (1 << 0) 56#define OMAP4_DEF_IRQENABLE_EVENTEN BIT(0)
57#define OMAP4_DEF_IRQENABLE_LONGKEY (1 << 1) 57#define OMAP4_DEF_IRQENABLE_LONGKEY BIT(1)
58#define OMAP4_DEF_IRQENABLE_TIMEOUTEN (1 << 2) 58#define OMAP4_DEF_WUP_EVENT_ENA BIT(0)
59#define OMAP4_DEF_WUP_EVENT_ENA (1 << 0) 59#define OMAP4_DEF_WUP_LONG_KEY_ENA BIT(1)
60#define OMAP4_DEF_WUP_LONG_KEY_ENA (1 << 1) 60#define OMAP4_DEF_CTRL_NOSOFTMODE BIT(1)
61#define OMAP4_DEF_CTRL_NOSOFTMODE (1 << 1) 61#define OMAP4_DEF_CTRL_PTV_SHIFT 2
62#define OMAP4_DEF_CTRLPTVVALUE (1 << 2)
63#define OMAP4_DEF_CTRLPTV (1 << 1)
64 62
65/* OMAP4 values */ 63/* OMAP4 values */
66#define OMAP4_VAL_IRQDISABLE 0x00 64#define OMAP4_VAL_IRQDISABLE 0x0
67#define OMAP4_VAL_DEBOUNCINGTIME 0x07 65#define OMAP4_VAL_DEBOUNCINGTIME 0x7
68#define OMAP4_VAL_FUNCTIONALCFG 0x1E 66#define OMAP4_VAL_PVT 0x7
69
70#define OMAP4_MASK_IRQSTATUSDISABLE 0xFFFF
71 67
72enum { 68enum {
73 KBD_REVISION_OMAP4 = 0, 69 KBD_REVISION_OMAP4 = 0,
@@ -78,6 +74,7 @@ struct omap4_keypad {
78 struct input_dev *input; 74 struct input_dev *input;
79 75
80 void __iomem *base; 76 void __iomem *base;
77 bool irq_wake_enabled;
81 unsigned int irq; 78 unsigned int irq;
82 79
83 unsigned int rows; 80 unsigned int rows;
@@ -116,8 +113,22 @@ static void kbd_write_irqreg(struct omap4_keypad *keypad_data,
116} 113}
117 114
118 115
119/* Interrupt handler */ 116/* Interrupt handlers */
120static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) 117static irqreturn_t omap4_keypad_irq_handler(int irq, void *dev_id)
118{
119 struct omap4_keypad *keypad_data = dev_id;
120
121 if (kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS)) {
122 /* Disable interrupts */
123 kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE,
124 OMAP4_VAL_IRQDISABLE);
125 return IRQ_WAKE_THREAD;
126 }
127
128 return IRQ_NONE;
129}
130
131static irqreturn_t omap4_keypad_irq_thread_fn(int irq, void *dev_id)
121{ 132{
122 struct omap4_keypad *keypad_data = dev_id; 133 struct omap4_keypad *keypad_data = dev_id;
123 struct input_dev *input_dev = keypad_data->input; 134 struct input_dev *input_dev = keypad_data->input;
@@ -125,10 +136,6 @@ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id)
125 unsigned int col, row, code, changed; 136 unsigned int col, row, code, changed;
126 u32 *new_state = (u32 *) key_state; 137 u32 *new_state = (u32 *) key_state;
127 138
128 /* Disable interrupts */
129 kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE,
130 OMAP4_VAL_IRQDISABLE);
131
132 *new_state = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE31_0); 139 *new_state = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE31_0);
133 *(new_state + 1) = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE63_32); 140 *(new_state + 1) = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE63_32);
134 141
@@ -175,11 +182,13 @@ static int omap4_keypad_open(struct input_dev *input)
175 disable_irq(keypad_data->irq); 182 disable_irq(keypad_data->irq);
176 183
177 kbd_writel(keypad_data, OMAP4_KBD_CTRL, 184 kbd_writel(keypad_data, OMAP4_KBD_CTRL,
178 OMAP4_VAL_FUNCTIONALCFG); 185 OMAP4_DEF_CTRL_NOSOFTMODE |
186 (OMAP4_VAL_PVT << OMAP4_DEF_CTRL_PTV_SHIFT));
179 kbd_writel(keypad_data, OMAP4_KBD_DEBOUNCINGTIME, 187 kbd_writel(keypad_data, OMAP4_KBD_DEBOUNCINGTIME,
180 OMAP4_VAL_DEBOUNCINGTIME); 188 OMAP4_VAL_DEBOUNCINGTIME);
189 /* clear pending interrupts */
181 kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS, 190 kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS,
182 OMAP4_VAL_IRQDISABLE); 191 kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS));
183 kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE, 192 kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE,
184 OMAP4_DEF_IRQENABLE_EVENTEN | 193 OMAP4_DEF_IRQENABLE_EVENTEN |
185 OMAP4_DEF_IRQENABLE_LONGKEY); 194 OMAP4_DEF_IRQENABLE_LONGKEY);
@@ -363,14 +372,15 @@ static int omap4_keypad_probe(struct platform_device *pdev)
363 goto err_free_keymap; 372 goto err_free_keymap;
364 } 373 }
365 374
366 error = request_irq(keypad_data->irq, omap4_keypad_interrupt, 375 error = request_threaded_irq(keypad_data->irq, omap4_keypad_irq_handler,
367 IRQF_TRIGGER_RISING, 376 omap4_keypad_irq_thread_fn, 0,
368 "omap4-keypad", keypad_data); 377 "omap4-keypad", keypad_data);
369 if (error) { 378 if (error) {
370 dev_err(&pdev->dev, "failed to register interrupt\n"); 379 dev_err(&pdev->dev, "failed to register interrupt\n");
371 goto err_free_input; 380 goto err_free_input;
372 } 381 }
373 382
383 device_init_wakeup(&pdev->dev, true);
374 pm_runtime_put_sync(&pdev->dev); 384 pm_runtime_put_sync(&pdev->dev);
375 385
376 error = input_register_device(keypad_data->input); 386 error = input_register_device(keypad_data->input);
@@ -384,6 +394,7 @@ static int omap4_keypad_probe(struct platform_device *pdev)
384 394
385err_pm_disable: 395err_pm_disable:
386 pm_runtime_disable(&pdev->dev); 396 pm_runtime_disable(&pdev->dev);
397 device_init_wakeup(&pdev->dev, false);
387 free_irq(keypad_data->irq, keypad_data); 398 free_irq(keypad_data->irq, keypad_data);
388err_free_keymap: 399err_free_keymap:
389 kfree(keypad_data->keymap); 400 kfree(keypad_data->keymap);
@@ -409,6 +420,8 @@ static int omap4_keypad_remove(struct platform_device *pdev)
409 420
410 pm_runtime_disable(&pdev->dev); 421 pm_runtime_disable(&pdev->dev);
411 422
423 device_init_wakeup(&pdev->dev, false);
424
412 input_unregister_device(keypad_data->input); 425 input_unregister_device(keypad_data->input);
413 426
414 iounmap(keypad_data->base); 427 iounmap(keypad_data->base);
@@ -430,12 +443,46 @@ static const struct of_device_id omap_keypad_dt_match[] = {
430MODULE_DEVICE_TABLE(of, omap_keypad_dt_match); 443MODULE_DEVICE_TABLE(of, omap_keypad_dt_match);
431#endif 444#endif
432 445
446#ifdef CONFIG_PM_SLEEP
447static int omap4_keypad_suspend(struct device *dev)
448{
449 struct platform_device *pdev = to_platform_device(dev);
450 struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);
451 int error;
452
453 if (device_may_wakeup(&pdev->dev)) {
454 error = enable_irq_wake(keypad_data->irq);
455 if (!error)
456 keypad_data->irq_wake_enabled = true;
457 }
458
459 return 0;
460}
461
462static int omap4_keypad_resume(struct device *dev)
463{
464 struct platform_device *pdev = to_platform_device(dev);
465 struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);
466
467 if (device_may_wakeup(&pdev->dev) && keypad_data->irq_wake_enabled) {
468 disable_irq_wake(keypad_data->irq);
469 keypad_data->irq_wake_enabled = false;
470 }
471
472 return 0;
473}
474#endif
475
476static SIMPLE_DEV_PM_OPS(omap4_keypad_pm_ops,
477 omap4_keypad_suspend, omap4_keypad_resume);
478
433static struct platform_driver omap4_keypad_driver = { 479static struct platform_driver omap4_keypad_driver = {
434 .probe = omap4_keypad_probe, 480 .probe = omap4_keypad_probe,
435 .remove = omap4_keypad_remove, 481 .remove = omap4_keypad_remove,
436 .driver = { 482 .driver = {
437 .name = "omap4-keypad", 483 .name = "omap4-keypad",
438 .owner = THIS_MODULE, 484 .owner = THIS_MODULE,
485 .pm = &omap4_keypad_pm_ops,
439 .of_match_table = of_match_ptr(omap_keypad_dt_match), 486 .of_match_table = of_match_ptr(omap_keypad_dt_match),
440 }, 487 },
441}; 488};
diff --git a/drivers/input/keyboard/qt1070.c b/drivers/input/keyboard/qt1070.c
index 42b773b3125a..6c561ec3cc09 100644
--- a/drivers/input/keyboard/qt1070.c
+++ b/drivers/input/keyboard/qt1070.c
@@ -243,6 +243,32 @@ static int qt1070_remove(struct i2c_client *client)
243 return 0; 243 return 0;
244} 244}
245 245
246#ifdef CONFIG_PM_SLEEP
247static int qt1070_suspend(struct device *dev)
248{
249 struct i2c_client *client = to_i2c_client(dev);
250 struct qt1070_data *data = i2c_get_clientdata(client);
251
252 if (device_may_wakeup(dev))
253 enable_irq_wake(data->irq);
254
255 return 0;
256}
257
258static int qt1070_resume(struct device *dev)
259{
260 struct i2c_client *client = to_i2c_client(dev);
261 struct qt1070_data *data = i2c_get_clientdata(client);
262
263 if (device_may_wakeup(dev))
264 disable_irq_wake(data->irq);
265
266 return 0;
267}
268#endif
269
270static SIMPLE_DEV_PM_OPS(qt1070_pm_ops, qt1070_suspend, qt1070_resume);
271
246static const struct i2c_device_id qt1070_id[] = { 272static const struct i2c_device_id qt1070_id[] = {
247 { "qt1070", 0 }, 273 { "qt1070", 0 },
248 { }, 274 { },
@@ -253,6 +279,7 @@ static struct i2c_driver qt1070_driver = {
253 .driver = { 279 .driver = {
254 .name = "qt1070", 280 .name = "qt1070",
255 .owner = THIS_MODULE, 281 .owner = THIS_MODULE,
282 .pm = &qt1070_pm_ops,
256 }, 283 },
257 .id_table = qt1070_id, 284 .id_table = qt1070_id,
258 .probe = qt1070_probe, 285 .probe = qt1070_probe,
diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c
index 7111124b5362..85ff530d9a91 100644
--- a/drivers/input/keyboard/spear-keyboard.c
+++ b/drivers/input/keyboard/spear-keyboard.c
@@ -191,12 +191,6 @@ static int spear_kbd_probe(struct platform_device *pdev)
191 int irq; 191 int irq;
192 int error; 192 int error;
193 193
194 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
195 if (!res) {
196 dev_err(&pdev->dev, "no keyboard resource defined\n");
197 return -EBUSY;
198 }
199
200 irq = platform_get_irq(pdev, 0); 194 irq = platform_get_irq(pdev, 0);
201 if (irq < 0) { 195 if (irq < 0) {
202 dev_err(&pdev->dev, "not able to get irq for the device\n"); 196 dev_err(&pdev->dev, "not able to get irq for the device\n");
@@ -228,6 +222,7 @@ static int spear_kbd_probe(struct platform_device *pdev)
228 kbd->suspended_rate = pdata->suspended_rate; 222 kbd->suspended_rate = pdata->suspended_rate;
229 } 223 }
230 224
225 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
231 kbd->io_base = devm_ioremap_resource(&pdev->dev, res); 226 kbd->io_base = devm_ioremap_resource(&pdev->dev, res);
232 if (IS_ERR(kbd->io_base)) 227 if (IS_ERR(kbd->io_base))
233 return PTR_ERR(kbd->io_base); 228 return PTR_ERR(kbd->io_base);
diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c
index b46142f78ef2..9cd20e6905a0 100644
--- a/drivers/input/keyboard/tegra-kbc.c
+++ b/drivers/input/keyboard/tegra-kbc.c
@@ -638,12 +638,6 @@ static int tegra_kbc_probe(struct platform_device *pdev)
638 if (!tegra_kbc_check_pin_cfg(kbc, &num_rows)) 638 if (!tegra_kbc_check_pin_cfg(kbc, &num_rows))
639 return -EINVAL; 639 return -EINVAL;
640 640
641 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
642 if (!res) {
643 dev_err(&pdev->dev, "failed to get I/O memory\n");
644 return -ENXIO;
645 }
646
647 kbc->irq = platform_get_irq(pdev, 0); 641 kbc->irq = platform_get_irq(pdev, 0);
648 if (kbc->irq < 0) { 642 if (kbc->irq < 0) {
649 dev_err(&pdev->dev, "failed to get keyboard IRQ\n"); 643 dev_err(&pdev->dev, "failed to get keyboard IRQ\n");
@@ -658,6 +652,7 @@ static int tegra_kbc_probe(struct platform_device *pdev)
658 652
659 setup_timer(&kbc->timer, tegra_kbc_keypress_timer, (unsigned long)kbc); 653 setup_timer(&kbc->timer, tegra_kbc_keypress_timer, (unsigned long)kbc);
660 654
655 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
661 kbc->mmio = devm_ioremap_resource(&pdev->dev, res); 656 kbc->mmio = devm_ioremap_resource(&pdev->dev, res);
662 if (IS_ERR(kbc->mmio)) 657 if (IS_ERR(kbc->mmio))
663 return PTR_ERR(kbc->mmio); 658 return PTR_ERR(kbc->mmio);