aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-davinci/include/mach/keyscan.h41
-rw-r--r--drivers/input/keyboard/Kconfig10
-rw-r--r--drivers/input/keyboard/Makefile1
-rw-r--r--drivers/input/keyboard/davinci_keyscan.c337
4 files changed, 389 insertions, 0 deletions
diff --git a/arch/arm/mach-davinci/include/mach/keyscan.h b/arch/arm/mach-davinci/include/mach/keyscan.h
new file mode 100644
index 000000000000..b4e21a2976d1
--- /dev/null
+++ b/arch/arm/mach-davinci/include/mach/keyscan.h
@@ -0,0 +1,41 @@
1/*
2 * Copyright (C) 2009 Texas Instruments, Inc
3 *
4 * Author: Miguel Aguilar <miguel.aguilar@ridgerun.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef DAVINCI_KEYSCAN_H
22#define DAVINCI_KEYSCAN_H
23
24#include <linux/io.h>
25
26enum davinci_matrix_types {
27 DAVINCI_KEYSCAN_MATRIX_4X4,
28 DAVINCI_KEYSCAN_MATRIX_5X3,
29};
30
31struct davinci_ks_platform_data {
32 unsigned short *keymap;
33 u32 keymapsize;
34 u8 rep:1;
35 u8 strobe;
36 u8 interval;
37 u8 matrix_type;
38};
39
40#endif
41
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index ee98b1bc5d89..203b88a82b56 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -361,6 +361,16 @@ config KEYBOARD_SH_KEYSC
361 To compile this driver as a module, choose M here: the 361 To compile this driver as a module, choose M here: the
362 module will be called sh_keysc. 362 module will be called sh_keysc.
363 363
364config KEYBOARD_DAVINCI
365 tristate "TI DaVinci Key Scan"
366 depends on ARCH_DAVINCI_DM365
367 help
368 Say Y to enable keypad module support for the TI DaVinci
369 platforms (DM365).
370
371 To compile this driver as a module, choose M here: the
372 module will be called davinci_keyscan.
373
364config KEYBOARD_OMAP 374config KEYBOARD_OMAP
365 tristate "TI OMAP keypad support" 375 tristate "TI OMAP keypad support"
366 depends on (ARCH_OMAP1 || ARCH_OMAP2) 376 depends on (ARCH_OMAP1 || ARCH_OMAP2)
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index babad5e58b77..68c017235ce9 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o
11obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o 11obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o
12obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o 12obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o
13obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o 13obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o
14obj-$(CONFIG_KEYBOARD_DAVINCI) += davinci_keyscan.o
14obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o 15obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o
15obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o 16obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o
16obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o 17obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o
diff --git a/drivers/input/keyboard/davinci_keyscan.c b/drivers/input/keyboard/davinci_keyscan.c
new file mode 100644
index 000000000000..6e52d855f637
--- /dev/null
+++ b/drivers/input/keyboard/davinci_keyscan.c
@@ -0,0 +1,337 @@
1/*
2 * DaVinci Key Scan Driver for TI platforms
3 *
4 * Copyright (C) 2009 Texas Instruments, Inc
5 *
6 * Author: Miguel Aguilar <miguel.aguilar@ridgerun.com>
7 *
8 * Intial Code: Sandeep Paulraj <s-paulraj@ti.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24#include <linux/module.h>
25#include <linux/init.h>
26#include <linux/interrupt.h>
27#include <linux/types.h>
28#include <linux/input.h>
29#include <linux/kernel.h>
30#include <linux/delay.h>
31#include <linux/platform_device.h>
32#include <linux/errno.h>
33
34#include <asm/irq.h>
35
36#include <mach/hardware.h>
37#include <mach/irqs.h>
38#include <mach/keyscan.h>
39
40/* Key scan registers */
41#define DAVINCI_KEYSCAN_KEYCTRL 0x0000
42#define DAVINCI_KEYSCAN_INTENA 0x0004
43#define DAVINCI_KEYSCAN_INTFLAG 0x0008
44#define DAVINCI_KEYSCAN_INTCLR 0x000c
45#define DAVINCI_KEYSCAN_STRBWIDTH 0x0010
46#define DAVINCI_KEYSCAN_INTERVAL 0x0014
47#define DAVINCI_KEYSCAN_CONTTIME 0x0018
48#define DAVINCI_KEYSCAN_CURRENTST 0x001c
49#define DAVINCI_KEYSCAN_PREVSTATE 0x0020
50#define DAVINCI_KEYSCAN_EMUCTRL 0x0024
51#define DAVINCI_KEYSCAN_IODFTCTRL 0x002c
52
53/* Key Control Register (KEYCTRL) */
54#define DAVINCI_KEYSCAN_KEYEN 0x00000001
55#define DAVINCI_KEYSCAN_PREVMODE 0x00000002
56#define DAVINCI_KEYSCAN_CHATOFF 0x00000004
57#define DAVINCI_KEYSCAN_AUTODET 0x00000008
58#define DAVINCI_KEYSCAN_SCANMODE 0x00000010
59#define DAVINCI_KEYSCAN_OUTTYPE 0x00000020
60
61/* Masks for the interrupts */
62#define DAVINCI_KEYSCAN_INT_CONT 0x00000008
63#define DAVINCI_KEYSCAN_INT_OFF 0x00000004
64#define DAVINCI_KEYSCAN_INT_ON 0x00000002
65#define DAVINCI_KEYSCAN_INT_CHANGE 0x00000001
66#define DAVINCI_KEYSCAN_INT_ALL 0x0000000f
67
68struct davinci_ks {
69 struct input_dev *input;
70 struct davinci_ks_platform_data *pdata;
71 int irq;
72 void __iomem *base;
73 resource_size_t pbase;
74 size_t base_size;
75 unsigned short keymap[];
76};
77
78/* Initializing the kp Module */
79static int __init davinci_ks_initialize(struct davinci_ks *davinci_ks)
80{
81 struct device *dev = &davinci_ks->input->dev;
82 struct davinci_ks_platform_data *pdata = davinci_ks->pdata;
83 u32 matrix_ctrl;
84
85 /* Enable all interrupts */
86 __raw_writel(DAVINCI_KEYSCAN_INT_ALL,
87 davinci_ks->base + DAVINCI_KEYSCAN_INTENA);
88
89 /* Clear interrupts if any */
90 __raw_writel(DAVINCI_KEYSCAN_INT_ALL,
91 davinci_ks->base + DAVINCI_KEYSCAN_INTCLR);
92
93 /* Setup the scan period = strobe + interval */
94 __raw_writel(pdata->strobe,
95 davinci_ks->base + DAVINCI_KEYSCAN_STRBWIDTH);
96 __raw_writel(pdata->interval,
97 davinci_ks->base + DAVINCI_KEYSCAN_INTERVAL);
98 __raw_writel(0x01,
99 davinci_ks->base + DAVINCI_KEYSCAN_CONTTIME);
100
101 /* Define matrix type */
102 switch (pdata->matrix_type) {
103 case DAVINCI_KEYSCAN_MATRIX_4X4:
104 matrix_ctrl = 0;
105 break;
106 case DAVINCI_KEYSCAN_MATRIX_5X3:
107 matrix_ctrl = (1 << 6);
108 break;
109 default: