blob: 49c1075627d324d0994a2643295f4b81d1cec90a [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* linux/arch/arm/mach-msm/board-halibut-keypad.c
2 *
3 * Copyright (C) 2007 Google, Inc.
4 * 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 <asm/mach-types.h>
18#include <linux/platform_device.h>
19#include <linux/gpio_event.h>
20
21#undef MODULE_PARAM_PREFIX
22#define MODULE_PARAM_PREFIX "board_halibut."
23static int halibut_ffa;
24module_param_named(ffa, halibut_ffa, int, S_IRUGO | S_IWUSR | S_IWGRP);
25
26#define SCAN_FUNCTION_KEYS 0 /* don't turn this on without updating the ffa support */
27
28static unsigned int halibut_row_gpios[] = {
29 31, 32, 33, 34, 35, 41
30#if SCAN_FUNCTION_KEYS
31 , 42
32#endif
33};
34
35static unsigned int halibut_col_gpios[] = { 36, 37, 38, 39, 40 };
36
37/* FFA:
38 36: KEYSENSE_N(0)
39 37: KEYSENSE_N(1)
40 38: KEYSENSE_N(2)
41 39: KEYSENSE_N(3)
42 40: KEYSENSE_N(4)
43
44 31: KYPD_17
45 32: KYPD_15
46 33: KYPD_13
47 34: KYPD_11
48 35: KYPD_9
49 41: KYPD_MEMO
50*/
51
52#define KEYMAP_INDEX(row, col) ((row)*ARRAY_SIZE(halibut_col_gpios) + (col))
53
54static const unsigned short halibut_keymap[ARRAY_SIZE(halibut_col_gpios) * ARRAY_SIZE(halibut_row_gpios)] = {
55 [KEYMAP_INDEX(0, 0)] = KEY_5,
56 [KEYMAP_INDEX(0, 1)] = KEY_9,
57 [KEYMAP_INDEX(0, 2)] = 229, /* SOFT1 */
58 [KEYMAP_INDEX(0, 3)] = KEY_6,
59 [KEYMAP_INDEX(0, 4)] = KEY_LEFT,
60
61 [KEYMAP_INDEX(1, 0)] = KEY_0,
62 [KEYMAP_INDEX(1, 1)] = KEY_RIGHT,
63 [KEYMAP_INDEX(1, 2)] = KEY_1,
64 [KEYMAP_INDEX(1, 3)] = 228, /* KEY_SHARP */
65 [KEYMAP_INDEX(1, 4)] = KEY_SEND,
66
67 [KEYMAP_INDEX(2, 0)] = KEY_VOLUMEUP,
68 [KEYMAP_INDEX(2, 1)] = KEY_HOME, /* FA */
69 [KEYMAP_INDEX(2, 2)] = KEY_F8, /* QCHT */
70 [KEYMAP_INDEX(2, 3)] = KEY_F6, /* R+ */
71 [KEYMAP_INDEX(2, 4)] = KEY_F7, /* R- */
72
73 [KEYMAP_INDEX(3, 0)] = KEY_UP,
74 [KEYMAP_INDEX(3, 1)] = KEY_CLEAR,
75 [KEYMAP_INDEX(3, 2)] = KEY_4,
76 [KEYMAP_INDEX(3, 3)] = KEY_MUTE, /* SPKR */
77 [KEYMAP_INDEX(3, 4)] = KEY_2,
78
79 [KEYMAP_INDEX(4, 0)] = 230, /* SOFT2 */
80 [KEYMAP_INDEX(4, 1)] = 232, /* KEY_CENTER */
81 [KEYMAP_INDEX(4, 2)] = KEY_DOWN,
82 [KEYMAP_INDEX(4, 3)] = KEY_BACK, /* FB */
83 [KEYMAP_INDEX(4, 4)] = KEY_8,
84
85 [KEYMAP_INDEX(5, 0)] = KEY_VOLUMEDOWN,
86 [KEYMAP_INDEX(5, 1)] = 227, /* KEY_STAR */
87 [KEYMAP_INDEX(5, 2)] = KEY_MAIL, /* MESG */
88 [KEYMAP_INDEX(5, 3)] = KEY_3,
89 [KEYMAP_INDEX(5, 4)] = KEY_7,
90
91#if SCAN_FUNCTION_KEYS
92 [KEYMAP_INDEX(6, 0)] = KEY_F5,
93 [KEYMAP_INDEX(6, 1)] = KEY_F4,
94 [KEYMAP_INDEX(6, 2)] = KEY_F3,
95 [KEYMAP_INDEX(6, 3)] = KEY_F2,
96 [KEYMAP_INDEX(6, 4)] = KEY_F1
97#endif
98};
99
100static const unsigned short halibut_keymap_ffa[ARRAY_SIZE(halibut_col_gpios) * ARRAY_SIZE(halibut_row_gpios)] = {
101 /*[KEYMAP_INDEX(0, 0)] = ,*/
102 /*[KEYMAP_INDEX(0, 1)] = ,*/
103 [KEYMAP_INDEX(0, 2)] = KEY_1,
104 [KEYMAP_INDEX(0, 3)] = KEY_SEND,
105 [KEYMAP_INDEX(0, 4)] = KEY_LEFT,
106
107 [KEYMAP_INDEX(1, 0)] = KEY_3,
108 [KEYMAP_INDEX(1, 1)] = KEY_RIGHT,
109 [KEYMAP_INDEX(1, 2)] = KEY_VOLUMEUP,
110 /*[KEYMAP_INDEX(1, 3)] = ,*/
111 [KEYMAP_INDEX(1, 4)] = KEY_6,
112
113 [KEYMAP_INDEX(2, 0)] = KEY_HOME, /* A */
114 [KEYMAP_INDEX(2, 1)] = KEY_BACK, /* B */
115 [KEYMAP_INDEX(2, 2)] = KEY_0,
116 [KEYMAP_INDEX(2, 3)] = 228, /* KEY_SHARP */
117 [KEYMAP_INDEX(2, 4)] = KEY_9,
118
119 [KEYMAP_INDEX(3, 0)] = KEY_UP,
120 [KEYMAP_INDEX(3, 1)] = 232, /* KEY_CENTER */ /* i */
121 [KEYMAP_INDEX(3, 2)] = KEY_4,
122 /*[KEYMAP_INDEX(3, 3)] = ,*/
123 [KEYMAP_INDEX(3, 4)] = KEY_2,
124
125 [KEYMAP_INDEX(4, 0)] = KEY_VOLUMEDOWN,
126 [KEYMAP_INDEX(4, 1)] = KEY_SOUND,
127 [KEYMAP_INDEX(4, 2)] = KEY_DOWN,
128 [KEYMAP_INDEX(4, 3)] = KEY_8,
129 [KEYMAP_INDEX(4, 4)] = KEY_5,
130
131 /*[KEYMAP_INDEX(5, 0)] = ,*/
132 [KEYMAP_INDEX(5, 1)] = 227, /* KEY_STAR */
133 [KEYMAP_INDEX(5, 2)] = 230, /*SOFT2*/ /* 2 */
134 [KEYMAP_INDEX(5, 3)] = KEY_MENU, /* 1 */
135 [KEYMAP_INDEX(5, 4)] = KEY_7,
136};
137
138static struct gpio_event_matrix_info halibut_matrix_info = {
139 .info.func = gpio_event_matrix_func,
140 .keymap = halibut_keymap,
141 .output_gpios = halibut_row_gpios,
142 .input_gpios = halibut_col_gpios,
143 .noutputs = ARRAY_SIZE(halibut_row_gpios),
144 .ninputs = ARRAY_SIZE(halibut_col_gpios),
145 .settle_time.tv.nsec = 0,
146 .poll_time.tv.nsec = 20 * NSEC_PER_MSEC,
147 .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_DRIVE_INACTIVE | GPIOKPF_PRINT_UNMAPPED_KEYS /*| GPIOKPF_PRINT_MAPPED_KEYS*/
148};
149
150struct gpio_event_info *halibut_keypad_info[] = {
151 &halibut_matrix_info.info
152};
153
154static struct gpio_event_platform_data halibut_keypad_data = {
155 .name = "halibut_keypad",
156 .info = halibut_keypad_info,
157 .info_count = ARRAY_SIZE(halibut_keypad_info)
158};
159
160static struct platform_device halibut_keypad_device = {
161 .name = GPIO_EVENT_DEV_NAME,
162 .id = -1,
163 .dev = {
164 .platform_data = &halibut_keypad_data,
165 },
166};
167
168static int __init halibut_init_keypad(void)
169{
170 if (!machine_is_halibut())
171 return 0;
172 if (halibut_ffa)
173 halibut_matrix_info.keymap = halibut_keymap_ffa;
174 return platform_device_register(&halibut_keypad_device);
175}
176
177device_initcall(halibut_init_keypad);