aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/linux/linux-2.6.34/ts72xx/0011-ts72xx_dio_keypad.patch
blob: cced7842bc215312c7dabad6c956a278fc58232f (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
From c1515f196bfc70cad5f9a755bf0038f190fd8c22 Mon Sep 17 00:00:00 2001
From: Matthieu Crapet <mcrapet@gmail.com>
Date: Sat, 19 Jun 2010 14:44:32 +0200
Subject: [PATCH 11/18] ts72xx_dio_keypad

Depends of "matrix-keypad" driver.
---
 drivers/input/keyboard/Kconfig          |   30 ++++++++
 drivers/input/keyboard/Makefile         |    2 +
 drivers/input/keyboard/ts72xx_dio_3x4.c |  110 +++++++++++++++++++++++++++++
 drivers/input/keyboard/ts72xx_dio_4x4.c |  115 +++++++++++++++++++++++++++++++
 4 files changed, 257 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/keyboard/ts72xx_dio_3x4.c
 create mode 100644 drivers/input/keyboard/ts72xx_dio_4x4.c

diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 64c1023..4ca7d48 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -201,6 +201,36 @@ config KEYBOARD_MATRIX
 	  To compile this driver as a module, choose M here: the
 	  module will be called matrix_keypad.
 
+if KEYBOARD_MATRIX
+	
+choice
+	prompt "Keypad type"
+	default TS72XX_DIO_4X4_KEYPAD
+
+config TS72XX_DIO_3X4_KEYPAD
+	tristate "TS-72xx 3x4 matrix keypad"
+	depends on MACH_TS72XX
+	help
+	  This a 12 keys (4 rows, 3 cols using DIO_0-6) keypad with the following layout:
+	  1 2 3
+	  4 5 6
+	  7 8 9
+	  * 0 #
+
+config TS72XX_DIO_4X4_KEYPAD
+	tristate "TS-72xx 4x4 matrix keypad"
+	depends on MACH_TS72XX
+	help
+	  This a 16 keys (4 rows, 4 cols using DIO_0-7) keypad with the following layout:
+	  7 8 9 F
+	  4 5 6 E
+	  1 2 3 D
+	  A 0 B C
+
+endchoice
+
+endif # KEYBOARD_MATRIX
+
 config KEYBOARD_HIL_OLD
 	tristate "HP HIL keyboard support (simple driver)"
 	depends on GSC || HP300
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 706c6b5..f81f1c1 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -40,3 +40,5 @@ obj-$(CONFIG_KEYBOARD_TOSA)		+= tosakbd.o
 obj-$(CONFIG_KEYBOARD_TWL4030)		+= twl4030_keypad.o
 obj-$(CONFIG_KEYBOARD_XTKBD)		+= xtkbd.o
 obj-$(CONFIG_KEYBOARD_W90P910)		+= w90p910_keypad.o
+obj-$(CONFIG_TS72XX_DIO_3X4_KEYPAD)	+= ts72xx_dio_3x4.o
+obj-$(CONFIG_TS72XX_DIO_4X4_KEYPAD)	+= ts72xx_dio_4x4.o
diff --git a/drivers/input/keyboard/ts72xx_dio_3x4.c b/drivers/input/keyboard/ts72xx_dio_3x4.c
new file mode 100644
index 0000000..e214335
--- /dev/null
+++ b/drivers/input/keyboard/ts72xx_dio_3x4.c
@@ -0,0 +1,110 @@
+/*
+ *  TS-72xx (3x4) keypad device driver for DIO1 header (DIO_0 thru DIO_6)
+ *
+ * (c) Copyright 2010  Matthieu Crapet <mcrapet@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/input/matrix_keypad.h>
+#include <mach/gpio.h>
+
+static const uint32_t ts72xx_kbd_keymap[] = {
+	KEY(0, 0, KEY_1),
+	KEY(0, 1, KEY_2),
+	KEY(0, 2, KEY_3),
+
+	KEY(1, 0, KEY_4),
+	KEY(1, 1, KEY_5),
+	KEY(1, 2, KEY_6),
+
+	KEY(2, 0, KEY_7),
+	KEY(2, 1, KEY_8),
+	KEY(2, 2, KEY_9),
+
+	KEY(3, 0, KEY_KPASTERISK),
+	KEY(3, 1, KEY_0),
+	KEY(3, 2, KEY_ENTER),
+};
+
+static struct matrix_keymap_data ts72xx_kbd_keymap_data = {
+	.keymap		= ts72xx_kbd_keymap,
+	.keymap_size	= ARRAY_SIZE(ts72xx_kbd_keymap),
+};
+
+static const int ts72xx_kbd_row_gpios[] = {
+	EP93XX_GPIO_LINE_EGPIO14,	// DIO_6 (row0)
+	EP93XX_GPIO_LINE_EGPIO13,
+	EP93XX_GPIO_LINE_EGPIO12,
+	EP93XX_GPIO_LINE_EGPIO11,
+};
+
+static const int ts72xx_kbd_col_gpios[] = {
+	EP93XX_GPIO_LINE_EGPIO10,	// DIO_2 (col0)
+	EP93XX_GPIO_LINE_EGPIO9,
+	EP93XX_GPIO_LINE_EGPIO8,
+};
+
+static struct matrix_keypad_platform_data ts72xx_kbd_pdata = {
+	.keymap_data		= &ts72xx_kbd_keymap_data,
+	.row_gpios		= ts72xx_kbd_row_gpios,
+	.col_gpios		= ts72xx_kbd_col_gpios,
+	.num_row_gpios		= ARRAY_SIZE(ts72xx_kbd_row_gpios),
+	.num_col_gpios		= ARRAY_SIZE(ts72xx_kbd_col_gpios),
+	.col_scan_delay_us	= 20,
+	.debounce_ms		= 20,
+	.wakeup			= 1,
+	.active_low		= 1,
+	//.no_autorep		= 1,
+};
+
+static void ts72xx_kbd_release(struct device *dev)
+{
+}
+
+static struct platform_device ts72xx_kbd_device = {
+	.name		= "matrix-keypad",
+	.id		= -1,
+	.dev		= {
+		.platform_data	= &ts72xx_kbd_pdata,
+		.release	= ts72xx_kbd_release,
+	},
+};
+
+static int __init ts72xx_dio_init(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ts72xx_kbd_row_gpios); i++) {
+		int irq = gpio_to_irq(ts72xx_kbd_row_gpios[i]);
+
+		ep93xx_gpio_int_debounce(irq, 1);
+	}
+
+	return platform_device_register(&ts72xx_kbd_device);
+}
+
+static void __exit ts72xx_dio_exit(void)
+{
+	platform_device_unregister(&ts72xx_kbd_device);
+}
+
+module_init(ts72xx_dio_init);
+module_exit(ts72xx_dio_exit);
+
+MODULE_AUTHOR("Matthieu Crapet <mcrapet@gmail.com>");
+MODULE_DESCRIPTION("Platform device 3x4 keypad");
+MODULE_LICENSE("GPL");
diff --git a/drivers/input/keyboard/ts72xx_dio_4x4.c b/drivers/input/keyboard/ts72xx_dio_4x4.c
new file mode 100644
index 0000000..790abd5
--- /dev/null
+++ b/drivers/input/keyboard/ts72xx_dio_4x4.c
@@ -0,0 +1,115 @@
+/*
+ *  TS-72xx (4x4) keypad device driver for DIO1 header (DIO_0 thru DIO_7)
+ *
+ * (c) Copyright 2010  Matthieu Crapet <mcrapet@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/input/matrix_keypad.h>
+#include <mach/gpio.h>
+
+static const uint32_t ts72xx_kbd_keymap[] = {
+	KEY(0, 0, KEY_7),
+	KEY(0, 1, KEY_8),
+	KEY(0, 2, KEY_9),
+	KEY(0, 3, KEY_F),
+
+	KEY(1, 0, KEY_4),
+	KEY(1, 1, KEY_5),
+	KEY(1, 2, KEY_6),
+	KEY(1, 3, KEY_E),
+
+	KEY(2, 0, KEY_1),
+	KEY(2, 1, KEY_2),
+	KEY(2, 2, KEY_3),
+	KEY(2, 3, KEY_D),
+
+	KEY(3, 0, KEY_A),
+	KEY(3, 1, KEY_0),
+	KEY(3, 2, KEY_B),
+	KEY(3, 3, KEY_C),
+};
+
+static struct matrix_keymap_data ts72xx_kbd_keymap_data = {
+	.keymap		= ts72xx_kbd_keymap,
+	.keymap_size	= ARRAY_SIZE(ts72xx_kbd_keymap),
+};
+
+static const int ts72xx_kbd_row_gpios[] = {
+	EP93XX_GPIO_LINE_EGPIO8,	// DIO_0 (row0)
+	EP93XX_GPIO_LINE_EGPIO9,
+	EP93XX_GPIO_LINE_EGPIO12,
+	EP93XX_GPIO_LINE_EGPIO14,
+};
+
+static const int ts72xx_kbd_col_gpios[] = {
+	EP93XX_GPIO_LINE_EGPIO15,	// DIO_7 (col0)
+	EP93XX_GPIO_LINE_EGPIO13,
+	EP93XX_GPIO_LINE_EGPIO11,
+	EP93XX_GPIO_LINE_EGPIO10,
+};
+
+static struct matrix_keypad_platform_data ts72xx_kbd_pdata = {
+	.keymap_data		= &ts72xx_kbd_keymap_data,
+	.row_gpios		= ts72xx_kbd_row_gpios,
+	.col_gpios		= ts72xx_kbd_col_gpios,
+	.num_row_gpios		= ARRAY_SIZE(ts72xx_kbd_row_gpios),
+	.num_col_gpios		= ARRAY_SIZE(ts72xx_kbd_col_gpios),
+	.col_scan_delay_us	= 20,
+	.debounce_ms		= 20,
+	.wakeup			= 1,
+	.active_low		= 1,
+	//.no_autorep		= 1,
+};
+
+static void ts72xx_kbd_release(struct device *dev)
+{
+}
+
+static struct platform_device ts72xx_kbd_device = {
+	.name		= "matrix-keypad",
+	.id		= -1,
+	.dev		= {
+		.platform_data	= &ts72xx_kbd_pdata,
+		.release	= ts72xx_kbd_release,
+	},
+};
+
+static int __init ts72xx_dio_init(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ts72xx_kbd_row_gpios); i++) {
+		int irq = gpio_to_irq(ts72xx_kbd_row_gpios[i]);
+
+		ep93xx_gpio_int_debounce(irq, 1);
+	}
+
+	return platform_device_register(&ts72xx_kbd_device);
+}
+
+static void __exit ts72xx_dio_exit(void)
+{
+	platform_device_unregister(&ts72xx_kbd_device);
+}
+
+module_init(ts72xx_dio_init);
+module_exit(ts72xx_dio_exit);
+
+MODULE_AUTHOR("Matthieu Crapet <mcrapet@gmail.com>");
+MODULE_DESCRIPTION("Platform device 4x4 keypad");
+MODULE_LICENSE("GPL");
-- 
1.7.1