24 #include <linux/module.h>
27 #include <linux/types.h>
28 #include <linux/input.h>
29 #include <linux/kernel.h>
32 #include <linux/errno.h>
33 #include <linux/slab.h>
37 #include <mach/hardware.h>
38 #include <mach/irqs.h>
42 #define DAVINCI_KEYSCAN_KEYCTRL 0x0000
43 #define DAVINCI_KEYSCAN_INTENA 0x0004
44 #define DAVINCI_KEYSCAN_INTFLAG 0x0008
45 #define DAVINCI_KEYSCAN_INTCLR 0x000c
46 #define DAVINCI_KEYSCAN_STRBWIDTH 0x0010
47 #define DAVINCI_KEYSCAN_INTERVAL 0x0014
48 #define DAVINCI_KEYSCAN_CONTTIME 0x0018
49 #define DAVINCI_KEYSCAN_CURRENTST 0x001c
50 #define DAVINCI_KEYSCAN_PREVSTATE 0x0020
51 #define DAVINCI_KEYSCAN_EMUCTRL 0x0024
52 #define DAVINCI_KEYSCAN_IODFTCTRL 0x002c
55 #define DAVINCI_KEYSCAN_KEYEN 0x00000001
56 #define DAVINCI_KEYSCAN_PREVMODE 0x00000002
57 #define DAVINCI_KEYSCAN_CHATOFF 0x00000004
58 #define DAVINCI_KEYSCAN_AUTODET 0x00000008
59 #define DAVINCI_KEYSCAN_SCANMODE 0x00000010
60 #define DAVINCI_KEYSCAN_OUTTYPE 0x00000020
63 #define DAVINCI_KEYSCAN_INT_CONT 0x00000008
64 #define DAVINCI_KEYSCAN_INT_OFF 0x00000004
65 #define DAVINCI_KEYSCAN_INT_ON 0x00000002
66 #define DAVINCI_KEYSCAN_INT_CHANGE 0x00000001
67 #define DAVINCI_KEYSCAN_INT_ALL 0x0000000f
108 matrix_ctrl = (1 << 6);
126 unsigned short *keymap = davinci_ks->
keymap;
127 int keymapsize = davinci_ks->
pdata->keymapsize;
140 changed = prev_status ^ new_status;
147 for (i = 0 ; i < keymapsize; i++) {
148 if ((changed>>i) & 0x1) {
150 release = (new_status >>
i) & 0x1;
152 release ?
"released" :
"pressed");
153 input_report_key(davinci_ks->
input, keycode,
155 input_sync(davinci_ks->
input);
171 struct davinci_ks *davinci_ks;
172 struct input_dev *key_dev;
181 dev_dbg(dev,
"device enable function failed\n");
187 dev_dbg(dev,
"no keymap from pdata\n");
191 davinci_ks = kzalloc(
sizeof(
struct davinci_ks) +
194 dev_dbg(dev,
"could not allocate memory for private data\n");
201 key_dev = input_allocate_device();
203 dev_dbg(dev,
"could not allocate input device\n");
208 davinci_ks->
input = key_dev;
211 if (davinci_ks->
irq < 0) {
212 dev_err(dev,
"no key scan irq\n");
213 error = davinci_ks->
irq;
219 dev_err(dev,
"no mem resource\n");
225 davinci_ks->
base_size = resource_size(res);
230 dev_err(dev,
"key scan registers at %08x are not free\n",
237 if (!davinci_ks->
base) {
238 dev_err(dev,
"can't ioremap MEM resource.\n");
253 for (i = 0; i < davinci_ks->
pdata->keymapsize; i++)
256 key_dev->name =
"davinci_keyscan";
257 key_dev->phys =
"davinci_keyscan/input0";
258 key_dev->dev.parent = &pdev->
dev;
260 key_dev->id.vendor = 0x0001;
261 key_dev->id.product = 0x0001;
262 key_dev->id.version = 0x0001;
263 key_dev->keycode = davinci_ks->
keymap;
264 key_dev->keycodesize =
sizeof(davinci_ks->
keymap[0]);
265 key_dev->keycodemax = davinci_ks->
pdata->keymapsize;
267 error = input_register_device(davinci_ks->
input);
269 dev_err(dev,
"unable to register davinci key scan device\n");
274 0, pdev->
name, davinci_ks);
276 dev_err(dev,
"unable to register davinci key scan interrupt\n");
280 error = davinci_ks_initialize(davinci_ks);
282 dev_err(dev,
"unable to initialize davinci key scan device\n");
286 platform_set_drvdata(pdev, davinci_ks);
292 input_unregister_device(davinci_ks->
input);
299 input_free_device(key_dev);
308 struct davinci_ks *davinci_ks = platform_get_drvdata(pdev);
312 input_unregister_device(davinci_ks->
input);
317 platform_set_drvdata(pdev,
NULL);
326 .name =
"davinci_keyscan",
332 static int __init davinci_ks_init(
void)
338 static void __exit davinci_ks_exit(
void)