summaryrefslogtreecommitdiff
path: root/packages/linux/linux-jlime-jornada7xx-2.6.17/Newfile-Jornada720_kbd.patch
blob: 7259647021a8a1dbed58df377d68f08fd0a3153e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
--- linux-2.6.17-vanilla/drivers/input/keyboard/jornada720_kbd.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.17/drivers/input/keyboard/jornada720_kbd.c	2006-07-10 17:06:11.000000000 +0000
@@ -0,0 +1,98 @@
+/*
+ * Jornada 720 keyboard interface
+ */
+ 
+#include <linux/input.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/slab.h>
+#include <linux/errno.h>
+#include <linux/interrupt.h>
+
+#include <asm/arch/hardware.h>
+#include <asm/arch/jornada720.h>
+#include <asm/irq.h>
+#include <asm/mach/irq.h>
+
+MODULE_AUTHOR("Alex Lange <chicken@handhelds.org>");
+MODULE_DESCRIPTION("Jornada 720 keyboard driver");
+MODULE_LICENSE("GPL");
+
+static char jornada720_kbd_name[] = "Jornada 720 keyboard";
+
+static struct input_dev *dev;
+
+static unsigned char jornada720_normal_keymap[128] = {
+	0, 1, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 87, KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_MUTE,
+	0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 0,
+	0, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 43, 14, 0, 0, 0,
+	0, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, KEY_LEFTBRACE, KEY_RIGHTBRACE, 0, 0, 0,
+	0, 44, 45, 46, 47, 48, 49, 50, 51, 52, KEY_KPMINUS, 40, 28, 0, 0, 0,
+	0, 15, 0, 42, 0, 40, 0, 0, 0, 0, 103, 0, 54, 0, 0, 0,
+	0, 0, 0, 0, 0, 56, KEY_GRAVE, 0, 0, 105, 108, 106, 0, 0, 0, 0,
+	0, 55, 29, 0, 57, 0, 0, 0, 53, 111, 0, 0, 0, 0, 0, 116,
+};
+
+static irqreturn_t jornada720_keyboard_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+	int key, keycode;
+	int count, mcu_data=0;
+	
+	jornada720_mcu_start(MCU_GetScanKeyCode);
+	count = jornada720_mcu_read();
+	
+	while (count-- > 0) {
+		key = mcu_data = jornada720_mcu_read();
+	
+		if (key > 128)
+			key = key - 128;
+
+		keycode = jornada720_normal_keymap[key];
+
+		if (mcu_data < 128) {
+			input_report_key(dev, keycode, 1);
+			input_sync(dev);
+		}
+		else {
+			input_report_key(dev, keycode, 0);
+			input_sync(dev);
+		}
+	}
+
+	jornada720_mcu_end();
+	
+	return IRQ_HANDLED;
+}
+
+static int __init jornada720_kbd_init(void)
+{
+	int i;
+	printk("jorada720_kbd: Jornada 720 keyboard\n");
+	
+	/*init_input_dev(&dev);*/
+	dev = input_allocate_device();
+	dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
+	dev->keybit[LONG(KEY_SUSPEND)] |= BIT(KEY_SUSPEND);
+	
+	for ( i=0 ; i<=128 ; i++ ) {
+		if (!(jornada720_normal_keymap[i])) {
+		}
+		else
+			set_bit(jornada720_normal_keymap[i], dev->keybit);
+	}
+	
+	dev->name = jornada720_kbd_name;
+
+	if (request_irq(GPIO_JORNADA720_KEYBOARD_IRQ, jornada720_keyboard_interrupt, SA_INTERRUPT, "Jornada720 Keyboard", NULL))
+		printk("Unable to grab Jornada 720 keyboard IRQ!\n");
+		
+	set_irq_type(GPIO_JORNADA720_KEYBOARD_IRQ, IRQT_FALLING);
+			
+	input_register_device(dev);
+	
+	return 0;
+}
+
+module_init(jornada720_kbd_init);