1 From 917491ccf4546bbd34d999cd4878c3b10b621c1c Mon Sep 17 00:00:00 2001
2 From: Grazvydas Ignotas <notasas@gmail.com>
3 Date: Tue, 3 Nov 2009 15:15:00 +0200
4 Subject: [PATCH 1/7] input: remove old twl4030keypad to replace it with mainline version
7 drivers/input/keyboard/Kconfig | 10 -
8 drivers/input/keyboard/Makefile | 1 -
9 drivers/input/keyboard/omap-twl4030keypad.c | 422 ---------------------------
10 drivers/input/keyboard/twl4030-keypad.h | 82 ------
11 4 files changed, 0 insertions(+), 515 deletions(-)
12 delete mode 100644 drivers/input/keyboard/omap-twl4030keypad.c
13 delete mode 100644 drivers/input/keyboard/twl4030-keypad.h
15 diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
16 index 616ce41..59ad05a 100644
17 --- a/drivers/input/keyboard/Kconfig
18 +++ b/drivers/input/keyboard/Kconfig
19 @@ -259,16 +259,6 @@ config KEYBOARD_OMAP
20 To compile this driver as a module, choose M here: the
21 module will be called omap-keypad.
23 -config KEYBOARD_TWL4030
24 - tristate "TI TWL4030 keypad support"
25 - depends on TWL4030_CORE && (MACH_OMAP_2430SDP || MACH_OMAP2EVM || MACH_OMAP_3430SDP || MACH_OMAP3EVM || MACH_OMAP3_PANDORA)
27 - Say Y here if you want to use the OMAP TWL4030 keypad.
29 - To compile this driver as a module, choose M here: the
30 - module will be called omap-twl4030keypad. This driver depends on
31 - TWL4030 Core and TWL4030 GPIO I2C client driver
34 tristate "TI OMAP Innovator 1510 PS/2 keyboard & mouse support"
35 depends on ARCH_OMAP15XX && MACH_OMAP_INNOVATOR
36 diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
37 index ae47fff..81e59f7 100644
38 --- a/drivers/input/keyboard/Makefile
39 +++ b/drivers/input/keyboard/Makefile
40 @@ -22,7 +22,6 @@ obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o
41 obj-$(CONFIG_OMAP_PS2) += innovator_ps2.o
42 obj-$(CONFIG_KEYBOARD_TSC2301) += tsc2301_kp.o
43 obj-$(CONFIG_KEYBOARD_LM8323) += lm8323.o
44 -obj-$(CONFIG_KEYBOARD_TWL4030) += omap-twl4030keypad.o
45 obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o
46 obj-$(CONFIG_KEYBOARD_AAED2000) += aaed2000_kbd.o
47 obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o
48 diff --git a/drivers/input/keyboard/omap-twl4030keypad.c b/drivers/input/keyboard/omap-twl4030keypad.c
49 deleted file mode 100644
50 index f6f1ad8..0000000
51 --- a/drivers/input/keyboard/omap-twl4030keypad.c
55 - * drivers/input/keyboard/omap-twl4030keypad.c
57 - * Copyright (C) 2007 Texas Instruments, Inc.
58 - * Copyright (C) 2008 Nokia Corporation
60 - * Code re-written for 2430SDP by:
61 - * Syed Mohammed Khasim <x0khasim@ti.com>
64 - * Manjunatha G K <manjugk@ti.com>
66 - * This program is free software; you can redistribute it and/or modify
67 - * it under the terms of the GNU General Public License as published by
68 - * the Free Software Foundation; either version 2 of the License, or
69 - * (at your option) any later version.
71 - * This program is distributed in the hope that it will be useful,
72 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
73 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74 - * GNU General Public License for more details.
76 - * You should have received a copy of the GNU General Public License
77 - * along with this program; if not, write to the Free Software
78 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
81 -#include <linux/module.h>
82 -#include <linux/init.h>
83 -#include <linux/interrupt.h>
84 -#include <linux/types.h>
85 -#include <linux/input.h>
86 -#include <linux/kernel.h>
87 -#include <linux/mutex.h>
88 -#include <linux/delay.h>
89 -#include <linux/bitops.h>
90 -#include <linux/platform_device.h>
91 -#include <linux/i2c.h>
92 -#include <linux/i2c/twl4030.h>
93 -#include <linux/irq.h>
94 -#include "twl4030-keypad.h"
96 -#define PTV_PRESCALER 4
98 -#define MAX_ROWS 8 /* TWL4030 hardlimit */
99 -#define ROWCOL_MASK 0xFF000000
100 -#define KEYNUM_MASK 0x00FFFFFF
101 -#define KEY(col, row, val) (((col) << 28) | ((row) << 24) | (val))
103 -/* Global variables */
105 -struct omap_keypad {
107 - unsigned int keymapsize;
108 - u16 kp_state[MAX_ROWS];
113 - struct device *dbg_dev;
114 - struct input_dev *omap_twl4030kp;
116 - /* sync read/write */
117 - struct mutex mutex;
120 -static int twl4030_kpread(struct omap_keypad *kp,
121 - u32 module, u8 *data, u32 reg, u8 num_bytes)
125 - ret = twl4030_i2c_read(module, data, reg, num_bytes);
127 - dev_warn(kp->dbg_dev,
128 - "Couldn't read TWL4030: %X - ret %d[%x]\n",
135 -static int twl4030_kpwrite_u8(struct omap_keypad *kp,
136 - u32 module, u8 data, u32 reg)
140 - ret = twl4030_i2c_write_u8(module, data, reg);
142 - dev_warn(kp->dbg_dev,
143 - "Could not write TWL4030: %X - ret %d[%x]\n",
150 -static int omap_kp_find_key(struct omap_keypad *kp, int col, int row)
154 - rc = KEY(col, row, 0);
155 - for (i = 0; i < kp->keymapsize; i++)
156 - if ((kp->keymap[i] & ROWCOL_MASK) == rc)
157 - return kp->keymap[i] & KEYNUM_MASK;
162 -static inline u16 omap_kp_col_xlate(struct omap_keypad *kp, u8 col)
164 - /* If all bits in a row are active for all coloumns then
165 - * we have that row line connected to gnd. Mark this
166 - * key on as if it was on matrix position n_cols (ie
167 - * one higher than the size of the matrix).
170 - return 1 << kp->n_cols;
172 - return col & ((1 << kp->n_cols) - 1);
175 -static int omap_kp_read_kp_matrix_state(struct omap_keypad *kp, u16 *state)
177 - u8 new_state[MAX_ROWS];
179 - int ret = twl4030_kpread(kp, TWL4030_MODULE_KEYPAD,
180 - new_state, KEYP_FULL_CODE_7_0, kp->n_rows);
182 - for (row = 0; row < kp->n_rows; row++)
183 - state[row] = omap_kp_col_xlate(kp, new_state[row]);
188 -static int omap_kp_is_in_ghost_state(struct omap_keypad *kp, u16 *key_state)
193 - for (i = 0; i < kp->n_rows; i++) {
194 - u16 col = key_state[i];
196 - if ((col & check) && hweight16(col) > 1)
204 -static void twl4030_kp_scan(struct omap_keypad *kp, int release_all)
206 - u16 new_state[MAX_ROWS];
210 - memset(new_state, 0, sizeof(new_state));
212 - /* check for any changes */
213 - int ret = omap_kp_read_kp_matrix_state(kp, new_state);
214 - if (ret < 0) /* panic ... */
217 - if (omap_kp_is_in_ghost_state(kp, new_state))
221 - mutex_lock(&kp->mutex);
223 - /* check for changes and print those */
224 - for (row = 0; row < kp->n_rows; row++) {
225 - int changed = new_state[row] ^ kp->kp_state[row];
230 - for (col = 0; col < kp->n_cols; col++) {
233 - if (!(changed & (1 << col)))
236 - dev_dbg(kp->dbg_dev, "key [%d:%d] %s\n", row, col,
237 - (new_state[row] & (1 << col)) ?
238 - "press" : "release");
240 - key = omap_kp_find_key(kp, col, row);
242 - dev_warn(kp->dbg_dev,
243 - "Spurious key event %d-%d\n",
246 - input_report_key(kp->omap_twl4030kp, key,
247 - new_state[row] & (1 << col));
249 - kp->kp_state[row] = new_state[row];
252 - mutex_unlock(&kp->mutex);
256 - * Keypad interrupt handler
258 -static irqreturn_t do_kp_irq(int irq, void *_kp)
260 - struct omap_keypad *kp = _kp;
264 -#ifdef CONFIG_LOCKDEP
265 - /* WORKAROUND for lockdep forcing IRQF_DISABLED on us, which
266 - * we don't want and can't tolerate. Although it might be
267 - * friendlier not to borrow this thread context...
269 - local_irq_enable();
272 - /* Read & Clear TWL4030 pending interrupt */
273 - ret = twl4030_kpread(kp, TWL4030_MODULE_KEYPAD, ®, KEYP_ISR1, 1);
275 - /* Release all keys if I2C has gone bad or
276 - * the KEYP has gone to idle state */
277 - if ((ret >= 0) && (reg & KEYP_IMR1_KP))
278 - twl4030_kp_scan(kp, 0);
280 - twl4030_kp_scan(kp, 1);
282 - return IRQ_HANDLED;
286 - * Registers keypad device with input sub system
287 - * and configures TWL4030 keypad registers
289 -static int __init omap_kp_probe(struct platform_device *pdev)
294 - struct omap_keypad *kp;
295 - struct twl4030_keypad_data *pdata = pdev->dev.platform_data;
297 - kp = kzalloc(sizeof(*kp), GFP_KERNEL);
301 - if (!pdata->rows || !pdata->cols || !pdata->keymap) {
302 - dev_err(&pdev->dev, "No rows, cols or keymap from pdata\n");
307 - dev_set_drvdata(&pdev->dev, kp);
309 - /* Get the debug Device */
310 - kp->dbg_dev = &pdev->dev;
312 - kp->omap_twl4030kp = input_allocate_device();
313 - if (!kp->omap_twl4030kp) {
318 - mutex_init(&kp->mutex);
320 - kp->keymap = pdata->keymap;
321 - kp->keymapsize = pdata->keymapsize;
322 - kp->n_rows = pdata->rows;
323 - kp->n_cols = pdata->cols;
324 - kp->irq = pdata->irq;
326 - /* setup input device */
327 - set_bit(EV_KEY, kp->omap_twl4030kp->evbit);
329 - /* Enable auto repeat feature of Linux input subsystem */
331 - set_bit(EV_REP, kp->omap_twl4030kp->evbit);
333 - for (i = 0; i < kp->keymapsize; i++)
334 - set_bit(kp->keymap[i] & KEYNUM_MASK,
335 - kp->omap_twl4030kp->keybit);
337 - kp->omap_twl4030kp->name = "omap_twl4030keypad";
338 - kp->omap_twl4030kp->phys = "omap_twl4030keypad/input0";
339 - kp->omap_twl4030kp->dev.parent = &pdev->dev;
341 - kp->omap_twl4030kp->id.bustype = BUS_HOST;
342 - kp->omap_twl4030kp->id.vendor = 0x0001;
343 - kp->omap_twl4030kp->id.product = 0x0001;
344 - kp->omap_twl4030kp->id.version = 0x0003;
346 - kp->omap_twl4030kp->keycode = kp->keymap;
347 - kp->omap_twl4030kp->keycodesize = sizeof(unsigned int);
348 - kp->omap_twl4030kp->keycodemax = kp->keymapsize;
350 - ret = input_register_device(kp->omap_twl4030kp);
352 - dev_err(kp->dbg_dev,
353 - "Unable to register twl4030 keypad device\n");
357 - /* Disable auto-repeat */
358 - reg = KEYP_CTRL_NOAUTORPT;
359 - ret = twl4030_kpwrite_u8(kp, TWL4030_MODULE_KEYPAD, reg, KEYP_CTRL);
363 - /* Enable TO rising and KP rising and falling edge detection */
364 - reg = KEYP_EDR_KP_BOTH | KEYP_EDR_TO_RISING;
365 - ret = twl4030_kpwrite_u8(kp, TWL4030_MODULE_KEYPAD, reg, KEYP_EDR);
369 - /* Set PTV prescaler Field */
370 - reg = (PTV_PRESCALER << KEYP_LK_PTV_PTV_SHIFT);
371 - ret = twl4030_kpwrite_u8(kp, TWL4030_MODULE_KEYPAD, reg, KEYP_LK_PTV);
375 - /* Set key debounce time to 20 ms */
376 - i = KEYP_PERIOD_US(20000, PTV_PRESCALER);
377 - ret = twl4030_kpwrite_u8(kp, TWL4030_MODULE_KEYPAD, i, KEYP_DEB);
381 - /* Set timeout period to 100 ms */
382 - i = KEYP_PERIOD_US(200000, PTV_PRESCALER);
383 - ret = twl4030_kpwrite_u8(kp, TWL4030_MODULE_KEYPAD,
384 - (i & 0xFF), KEYP_TIMEOUT_L);
388 - ret = twl4030_kpwrite_u8(kp, TWL4030_MODULE_KEYPAD,
389 - (i >> 8), KEYP_TIMEOUT_H);
393 - /* Enable Clear-on-Read */
394 - reg = KEYP_SIH_CTRL_COR | KEYP_SIH_CTRL_PEND_DIS;
395 - ret = twl4030_kpwrite_u8(kp, TWL4030_MODULE_KEYPAD,
396 - reg, KEYP_SIH_CTRL);
401 - * This ISR will always execute in kernel thread context because of
402 - * the need to access the TWL4030 over the I2C bus.
404 - ret = request_irq(kp->irq, do_kp_irq, 0, pdev->name, kp);
406 - dev_info(kp->dbg_dev, "request_irq failed for irq no=%d\n",
410 - /* Enable KP and TO interrupts now. */
411 - reg = ~(KEYP_IMR1_KP | KEYP_IMR1_TO);
412 - ret = twl4030_kpwrite_u8(kp, TWL4030_MODULE_KEYPAD,
418 - ret = omap_kp_read_kp_matrix_state(kp, kp->kp_state);
424 - /* mask all events - we don't care about the result */
425 - (void) twl4030_kpwrite_u8(kp, TWL4030_MODULE_KEYPAD, 0xff, KEYP_IMR1);
427 - free_irq(kp->irq, NULL);
429 - input_unregister_device(kp->omap_twl4030kp);
431 - input_free_device(kp->omap_twl4030kp);
436 -static int omap_kp_remove(struct platform_device *pdev)
438 - struct omap_keypad *kp = dev_get_drvdata(&pdev->dev);
440 - free_irq(kp->irq, kp);
441 - input_unregister_device(kp->omap_twl4030kp);
448 -static struct platform_driver omap_kp_driver = {
449 - .probe = omap_kp_probe,
450 - .remove = __devexit_p(omap_kp_remove),
452 - .name = "twl4030_keypad",
453 - .owner = THIS_MODULE,
458 - * OMAP TWL4030 Keypad init
460 -static int __devinit omap_kp_init(void)
462 - return platform_driver_register(&omap_kp_driver);
465 -static void __exit omap_kp_exit(void)
467 - platform_driver_unregister(&omap_kp_driver);
470 -module_init(omap_kp_init);
471 -module_exit(omap_kp_exit);
472 -MODULE_ALIAS("platform:twl4030_keypad");
473 -MODULE_AUTHOR("Texas Instruments");
474 -MODULE_DESCRIPTION("OMAP TWL4030 Keypad Driver");
475 -MODULE_LICENSE("GPL");
476 diff --git a/drivers/input/keyboard/twl4030-keypad.h b/drivers/input/keyboard/twl4030-keypad.h
477 deleted file mode 100644
478 index b903a77..0000000
479 --- a/drivers/input/keyboard/twl4030-keypad.h
483 - * drivers/input/keyboard/twl4030-keypad.h
485 - * Copyright (C) 2006-2007 Texas Instruments, Inc.
488 - * Syed Mohammed Khasim <x0khasim@ti.com>
490 - * This program is free software; you can redistribute it and/or modify
491 - * it under the terms of the GNU General Public License as published by
492 - * the Free Software Foundation; either version 2 of the License, or
493 - * (at your option) any later version.
495 - * This program is distributed in the hope that it will be useful,
496 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
497 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
498 - * GNU General Public License for more details.
500 - * You should have received a copy of the GNU General Public License
501 - * along with this program; if not, write to the Free Software
502 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
504 -#ifndef __TWL4030_KEYPAD_H__
505 -#define __TWL4030_KEYPAD_H__
507 -/* Register Definitions */
508 -#define KEYP_CTRL 0x00
509 -#define KEYP_DEB 0x01
510 -#define KEYP_LONG_KEY 0x02
511 -#define KEYP_LK_PTV 0x03
512 -#define KEYP_TIMEOUT_L 0x04
513 -#define KEYP_TIMEOUT_H 0x05
514 -#define KEYP_FULL_CODE_7_0 0x09
515 -#define KEYP_ISR1 0x11
516 -#define KEYP_IMR1 0x12
517 -#define KEYP_EDR 0x16
518 -#define KEYP_SIH_CTRL 0x17
520 -/* KEYP_CTRL_REG Fields */
521 -#define KEYP_CTRL_SOFT_NRST 0x01
522 -#define KEYP_CTRL_SOFTMODEN 0x02
523 -#define KEYP_CTRL_LK_EN 0x04
524 -#define KEYP_CTRL_TOE_EN 0x08
525 -#define KEYP_CTRL_TOLE_EN 0x10
526 -#define KEYP_CTRL_RP_EN 0x20
527 -#define KEYP_CTRL_KBD_ON 0x40
530 -#define KEYP_CTRL_NOAUTORPT (KEYP_CTRL_SOFT_NRST | \
531 - KEYP_CTRL_SOFTMODEN | \
532 - KEYP_CTRL_TOE_EN | \
535 -/* KEYP_DEB, KEYP_LONG_KEY, KEYP_TIMEOUT_x*/
536 -#define KEYP_PERIOD_US(T, prescale) (T / (31 << (prescale + 1)) - 1)
538 -/* KEYP_LK_PTV_REG Fields */
539 -#define KEYP_LK_PTV_PTV_SHIFT 5
541 -/* KEYP_IMR1 Fields */
542 -#define KEYP_IMR1_MIS 0x08
543 -#define KEYP_IMR1_TO 0x04
544 -#define KEYP_IMR1_LK 0x02
545 -#define KEYP_IMR1_KP 0x01
547 -/* KEYP_EDR Fields */
548 -#define KEYP_EDR_KP_FALLING 0x01
549 -#define KEYP_EDR_KP_RISING 0x02
550 -#define KEYP_EDR_KP_BOTH 0x03
551 -#define KEYP_EDR_LK_FALLING 0x04
552 -#define KEYP_EDR_LK_RISING 0x08
553 -#define KEYP_EDR_TO_FALLING 0x10
554 -#define KEYP_EDR_TO_RISING 0x20
555 -#define KEYP_EDR_MIS_FALLING 0x40
556 -#define KEYP_EDR_MIS_RISING 0x80
558 -/* KEYP_SIH_CTRL Fields */
559 -#define KEYP_SIH_CTRL_COR 0x04
560 -#define KEYP_SIH_CTRL_PEND_DIS 0x02
561 -#define KEYP_SIH_CTRL_EXCL_EN 0x01
563 -#endif /* End of __TWL4030-KEYPAD_H__ */