blob: 5d7763fa798f78397e802806291c83df7eea1fa5 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/*
2 * Copyright (C) 2007 Google, Inc.
Duy Truong790f06d2013-02-13 16:38:12 -08003 * Copyright (c) 2008-2009, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004 * Author: Brian Swetland <swetland@google.com>
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16
17#include <linux/platform_device.h>
18#include <linux/gpio_event.h>
19
20#include <asm/mach-types.h>
21
22/* don't turn this on without updating the ffa support */
23#define SCAN_FUNCTION_KEYS 0
24
25/* FFA:
26 36: KEYSENSE_N(0)
27 37: KEYSENSE_N(1)
28 38: KEYSENSE_N(2)
29 39: KEYSENSE_N(3)
30 40: KEYSENSE_N(4)
31
32 31: KYPD_17
33 32: KYPD_15
34 33: KYPD_13
35 34: KYPD_11
36 35: KYPD_9
37 41: KYPD_MEMO
38*/
39
40static unsigned int keypad_row_gpios[] = {
41 31, 32, 33, 34, 35, 41
42#if SCAN_FUNCTION_KEYS
43 , 42
44#endif
45};
46
47static unsigned int keypad_col_gpios[] = { 36, 37, 38, 39, 40 };
48
49static unsigned int keypad_row_gpios_8k_ffa[] = {31, 32, 33, 34, 35, 36};
50static unsigned int keypad_col_gpios_8k_ffa[] = {38, 39, 40, 41, 42};
51
52#define KEYMAP_INDEX(row, col) ((row)*ARRAY_SIZE(keypad_col_gpios) + (col))
53#define FFA_8K_KEYMAP_INDEX(row, col) ((row)* \
54 ARRAY_SIZE(keypad_col_gpios_8k_ffa) + (col))
55
56static const unsigned short keypad_keymap_surf[ARRAY_SIZE(keypad_col_gpios) *
57 ARRAY_SIZE(keypad_row_gpios)] = {
58 [KEYMAP_INDEX(0, 0)] = KEY_5,
59 [KEYMAP_INDEX(0, 1)] = KEY_9,
60 [KEYMAP_INDEX(0, 2)] = 229, /* SOFT1 */
61 [KEYMAP_INDEX(0, 3)] = KEY_6,
62 [KEYMAP_INDEX(0, 4)] = KEY_LEFT,
63
64 [KEYMAP_INDEX(1, 0)] = KEY_0,
65 [KEYMAP_INDEX(1, 1)] = KEY_RIGHT,
66 [KEYMAP_INDEX(1, 2)] = KEY_1,
67 [KEYMAP_INDEX(1, 3)] = 228, /* KEY_SHARP */
68 [KEYMAP_INDEX(1, 4)] = KEY_SEND,
69
70 [KEYMAP_INDEX(2, 0)] = KEY_VOLUMEUP,
71 [KEYMAP_INDEX(2, 1)] = KEY_HOME, /* FA */
72 [KEYMAP_INDEX(2, 2)] = KEY_F8, /* QCHT */
73 [KEYMAP_INDEX(2, 3)] = KEY_F6, /* R+ */
74 [KEYMAP_INDEX(2, 4)] = KEY_F7, /* R- */
75
76 [KEYMAP_INDEX(3, 0)] = KEY_UP,
77 [KEYMAP_INDEX(3, 1)] = KEY_CLEAR,
78 [KEYMAP_INDEX(3, 2)] = KEY_4,
79 [KEYMAP_INDEX(3, 3)] = KEY_MUTE, /* SPKR */
80 [KEYMAP_INDEX(3, 4)] = KEY_2,
81
82 [KEYMAP_INDEX(4, 0)] = 230, /* SOFT2 */
83 [KEYMAP_INDEX(4, 1)] = 232, /* KEY_CENTER */
84 [KEYMAP_INDEX(4, 2)] = KEY_DOWN,
85 [KEYMAP_INDEX(4, 3)] = KEY_BACK, /* FB */
86 [KEYMAP_INDEX(4, 4)] = KEY_8,
87
88 [KEYMAP_INDEX(5, 0)] = KEY_VOLUMEDOWN,
89 [KEYMAP_INDEX(5, 1)] = 227, /* KEY_STAR */
90 [KEYMAP_INDEX(5, 2)] = KEY_MAIL, /* MESG */
91 [KEYMAP_INDEX(5, 3)] = KEY_3,
92 [KEYMAP_INDEX(5, 4)] = KEY_7,
93
94#if SCAN_FUNCTION_KEYS
95 [KEYMAP_INDEX(6, 0)] = KEY_F5,
96 [KEYMAP_INDEX(6, 1)] = KEY_F4,
97 [KEYMAP_INDEX(6, 2)] = KEY_F3,
98 [KEYMAP_INDEX(6, 3)] = KEY_F2,
99 [KEYMAP_INDEX(6, 4)] = KEY_F1
100#endif
101};
102
103static const unsigned short keypad_keymap_ffa[ARRAY_SIZE(keypad_col_gpios) *
104 ARRAY_SIZE(keypad_row_gpios)] = {
105 /*[KEYMAP_INDEX(0, 0)] = ,*/
106 /*[KEYMAP_INDEX(0, 1)] = ,*/
107 [KEYMAP_INDEX(0, 2)] = KEY_1,
108 [KEYMAP_INDEX(0, 3)] = KEY_SEND,
109 [KEYMAP_INDEX(0, 4)] = KEY_LEFT,
110
111 [KEYMAP_INDEX(1, 0)] = KEY_3,
112 [KEYMAP_INDEX(1, 1)] = KEY_RIGHT,
113 [KEYMAP_INDEX(1, 2)] = KEY_VOLUMEUP,
114 /*[KEYMAP_INDEX(1, 3)] = ,*/
115 [KEYMAP_INDEX(1, 4)] = KEY_6,
116
117 [KEYMAP_INDEX(2, 0)] = KEY_HOME, /* A */
118 [KEYMAP_INDEX(2, 1)] = KEY_BACK, /* B */
119 [KEYMAP_INDEX(2, 2)] = KEY_0,
120 [KEYMAP_INDEX(2, 3)] = 228, /* KEY_SHARP */
121 [KEYMAP_INDEX(2, 4)] = KEY_9,
122
123 [KEYMAP_INDEX(3, 0)] = KEY_UP,
124 [KEYMAP_INDEX(3, 1)] = 232, /* KEY_CENTER */ /* i */
125 [KEYMAP_INDEX(3, 2)] = KEY_4,
126 /*[KEYMAP_INDEX(3, 3)] = ,*/
127 [KEYMAP_INDEX(3, 4)] = KEY_2,
128
129 [KEYMAP_INDEX(4, 0)] = KEY_VOLUMEDOWN,
130 [KEYMAP_INDEX(4, 1)] = KEY_SOUND,
131 [KEYMAP_INDEX(4, 2)] = KEY_DOWN,
132 [KEYMAP_INDEX(4, 3)] = KEY_8,
133 [KEYMAP_INDEX(4, 4)] = KEY_5,
134
135 /*[KEYMAP_INDEX(5, 0)] = ,*/
136 [KEYMAP_INDEX(5, 1)] = 227, /* KEY_STAR */
137 [KEYMAP_INDEX(5, 2)] = 230, /*SOFT2*/ /* 2 */
138 [KEYMAP_INDEX(5, 3)] = KEY_MENU, /* 1 */
139 [KEYMAP_INDEX(5, 4)] = KEY_7,
140};
141
142#define QSD8x50_FFA_KEYMAP_SIZE (ARRAY_SIZE(keypad_col_gpios_8k_ffa) * \
143 ARRAY_SIZE(keypad_row_gpios_8k_ffa))
144
145static const unsigned short keypad_keymap_8k_ffa[QSD8x50_FFA_KEYMAP_SIZE] = {
146
147 [FFA_8K_KEYMAP_INDEX(0, 0)] = KEY_VOLUMEDOWN,
148 /*[KEYMAP_INDEX(0, 1)] = ,*/
149 [FFA_8K_KEYMAP_INDEX(0, 2)] = KEY_DOWN,
150 [FFA_8K_KEYMAP_INDEX(0, 3)] = KEY_8,
151 [FFA_8K_KEYMAP_INDEX(0, 4)] = KEY_5,
152
153 [FFA_8K_KEYMAP_INDEX(1, 0)] = KEY_UP,
154 [FFA_8K_KEYMAP_INDEX(1, 1)] = KEY_CLEAR,
155 [FFA_8K_KEYMAP_INDEX(1, 2)] = KEY_4,
156 /*[KEYMAP_INDEX(1, 3)] = ,*/
157 [FFA_8K_KEYMAP_INDEX(1, 4)] = KEY_2,
158
159 [FFA_8K_KEYMAP_INDEX(2, 0)] = KEY_HOME, /* A */
160 [FFA_8K_KEYMAP_INDEX(2, 1)] = KEY_BACK, /* B */
161 [FFA_8K_KEYMAP_INDEX(2, 2)] = KEY_0,
162 [FFA_8K_KEYMAP_INDEX(2, 3)] = 228, /* KEY_SHARP */
163 [FFA_8K_KEYMAP_INDEX(2, 4)] = KEY_9,
164
165 [FFA_8K_KEYMAP_INDEX(3, 0)] = KEY_3,
166 [FFA_8K_KEYMAP_INDEX(3, 1)] = KEY_RIGHT,
167 [FFA_8K_KEYMAP_INDEX(3, 2)] = KEY_VOLUMEUP,
168 /*[KEYMAP_INDEX(3, 3)] = ,*/
169 [FFA_8K_KEYMAP_INDEX(3, 4)] = KEY_6,
170
171 [FFA_8K_KEYMAP_INDEX(4, 0)] = 232, /* OK */
172 [FFA_8K_KEYMAP_INDEX(4, 1)] = KEY_SOUND,
173 [FFA_8K_KEYMAP_INDEX(4, 2)] = KEY_1,
174 [FFA_8K_KEYMAP_INDEX(4, 3)] = KEY_SEND,
175 [FFA_8K_KEYMAP_INDEX(4, 4)] = KEY_LEFT,
176
177 /*[KEYMAP_INDEX(5, 0)] = ,*/
178 [FFA_8K_KEYMAP_INDEX(5, 1)] = 227, /* KEY_STAR */
179 [FFA_8K_KEYMAP_INDEX(5, 2)] = 230, /*SOFT2*/ /* 2 */
180 [FFA_8K_KEYMAP_INDEX(5, 3)] = 229, /* 1 */
181 [FFA_8K_KEYMAP_INDEX(5, 4)] = KEY_7,
182};
183
184/* SURF keypad platform device information */
185static struct gpio_event_matrix_info surf_keypad_matrix_info = {
186 .info.func = gpio_event_matrix_func,
187 .keymap = keypad_keymap_surf,
188 .output_gpios = keypad_row_gpios,
189 .input_gpios = keypad_col_gpios,
190 .noutputs = ARRAY_SIZE(keypad_row_gpios),
191 .ninputs = ARRAY_SIZE(keypad_col_gpios),
Steve Mucklef132c6c2012-06-06 18:30:57 -0700192 .settle_time.tv64 = 40 * NSEC_PER_USEC,
193 .poll_time.tv64 = 20 * NSEC_PER_MSEC,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700194 .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_DRIVE_INACTIVE |
195 GPIOKPF_PRINT_UNMAPPED_KEYS
196};
197
198static struct gpio_event_info *surf_keypad_info[] = {
199 &surf_keypad_matrix_info.info
200};
201
202static struct gpio_event_platform_data surf_keypad_data = {
203 .name = "surf_keypad",
204 .info = surf_keypad_info,
205 .info_count = ARRAY_SIZE(surf_keypad_info)
206};
207
208struct platform_device keypad_device_surf = {
209 .name = GPIO_EVENT_DEV_NAME,
210 .id = -1,
211 .dev = {
212 .platform_data = &surf_keypad_data,
213 },
214};
215
216/* 8k FFA keypad platform device information */
217static struct gpio_event_matrix_info keypad_matrix_info_8k_ffa = {
218 .info.func = gpio_event_matrix_func,
219 .keymap = keypad_keymap_8k_ffa,
220 .output_gpios = keypad_row_gpios_8k_ffa,
221 .input_gpios = keypad_col_gpios_8k_ffa,
222 .noutputs = ARRAY_SIZE(keypad_row_gpios_8k_ffa),
223 .ninputs = ARRAY_SIZE(keypad_col_gpios_8k_ffa),
Steve Mucklef132c6c2012-06-06 18:30:57 -0700224 .settle_time.tv64 = 40 * NSEC_PER_USEC,
225 .poll_time.tv64 = 20 * NSEC_PER_MSEC,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700226 .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_DRIVE_INACTIVE |
227 GPIOKPF_PRINT_UNMAPPED_KEYS
228};
229
230static struct gpio_event_info *keypad_info_8k_ffa[] = {
231 &keypad_matrix_info_8k_ffa.info
232};
233
234static struct gpio_event_platform_data keypad_data_8k_ffa = {
235 .name = "8k_ffa_keypad",
236 .info = keypad_info_8k_ffa,
237 .info_count = ARRAY_SIZE(keypad_info_8k_ffa)
238};
239
240struct platform_device keypad_device_8k_ffa = {
241 .name = GPIO_EVENT_DEV_NAME,
242 .id = -1,
243 .dev = {
244 .platform_data = &keypad_data_8k_ffa,
245 },
246};
247
248/* 7k FFA keypad platform device information */
249static struct gpio_event_matrix_info keypad_matrix_info_7k_ffa = {
250 .info.func = gpio_event_matrix_func,
251 .keymap = keypad_keymap_ffa,
252 .output_gpios = keypad_row_gpios,
253 .input_gpios = keypad_col_gpios,
254 .noutputs = ARRAY_SIZE(keypad_row_gpios),
255 .ninputs = ARRAY_SIZE(keypad_col_gpios),
Steve Mucklef132c6c2012-06-06 18:30:57 -0700256 .settle_time.tv64 = 40 * NSEC_PER_USEC,
257 .poll_time.tv64 = 20 * NSEC_PER_MSEC,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700258 .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_DRIVE_INACTIVE |
259 GPIOKPF_PRINT_UNMAPPED_KEYS
260};
261
262static struct gpio_event_info *keypad_info_7k_ffa[] = {
263 &keypad_matrix_info_7k_ffa.info
264};
265
266static struct gpio_event_platform_data keypad_data_7k_ffa = {
267 .name = "7k_ffa_keypad",
268 .info = keypad_info_7k_ffa,
269 .info_count = ARRAY_SIZE(keypad_info_7k_ffa)
270};
271
272struct platform_device keypad_device_7k_ffa = {
273 .name = GPIO_EVENT_DEV_NAME,
274 .id = -1,
275 .dev = {
276 .platform_data = &keypad_data_7k_ffa,
277 },
278};
279