blob: f44032f4022fa56876681dac23e9721320bc137e [file] [log] [blame]
Dima Zavind0850132009-01-26 20:02:33 -08001/*
2 * Copyright (c) 2009, Google Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google, Inc. nor the names of its contributors
15 * may be used to endorse or promote products derived from this
16 * software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
25 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
28 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#include <dev/keys.h>
33#include <dev/gpio_keypad.h>
34
35#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
36
37/* don't turn this on without updating the ffa support */
38#define SCAN_FUNCTION_KEYS 0
39
40static unsigned int halibut_row_gpios[] = {
41 31, 32, 33, 34, 35, 41
42#if SCAN_FUNCTION_KEYS
43 , 42
44#endif
45};
46
47static unsigned int halibut_col_gpios[] = { 36, 37, 38, 39, 40 };
48
49#define KEYMAP_INDEX(row, col) ((row)*ARRAY_SIZE(halibut_col_gpios) + (col))
50
51static const unsigned short halibut_keymap[ARRAY_SIZE(halibut_col_gpios) * ARRAY_SIZE(halibut_row_gpios)] = {
52 [KEYMAP_INDEX(0, 0)] = KEY_5,
53 [KEYMAP_INDEX(0, 1)] = KEY_9,
54 [KEYMAP_INDEX(0, 2)] = KEY_SOFT1,
55 [KEYMAP_INDEX(0, 3)] = KEY_6,
56 [KEYMAP_INDEX(0, 4)] = KEY_LEFT,
57
58 [KEYMAP_INDEX(1, 0)] = KEY_0,
59 [KEYMAP_INDEX(1, 1)] = KEY_RIGHT,
60 [KEYMAP_INDEX(1, 2)] = KEY_1,
61 [KEYMAP_INDEX(1, 3)] = KEY_SHARP,
62 [KEYMAP_INDEX(1, 4)] = KEY_SEND,
63
64 [KEYMAP_INDEX(2, 0)] = KEY_VOLUMEUP,
65 [KEYMAP_INDEX(2, 1)] = KEY_HOME, /* FA */
66 [KEYMAP_INDEX(2, 2)] = KEY_F8, /* QCHT */
67 [KEYMAP_INDEX(2, 3)] = KEY_F6, /* R+ */
68 [KEYMAP_INDEX(2, 4)] = KEY_F7, /* R- */
69
70 [KEYMAP_INDEX(3, 0)] = KEY_UP,
71 [KEYMAP_INDEX(3, 1)] = KEY_CLEAR,
72 [KEYMAP_INDEX(3, 2)] = KEY_4,
73 [KEYMAP_INDEX(3, 3)] = KEY_MUTE, /* SPKR */
74 [KEYMAP_INDEX(3, 4)] = KEY_2,
75
76 [KEYMAP_INDEX(4, 0)] = KEY_SOFT2, /* SOFT2 */
77 [KEYMAP_INDEX(4, 1)] = KEY_CENTER, /* KEY_CENTER */
78 [KEYMAP_INDEX(4, 2)] = KEY_DOWN,
79 [KEYMAP_INDEX(4, 3)] = KEY_BACK, /* FB */
80 [KEYMAP_INDEX(4, 4)] = KEY_8,
81
82 [KEYMAP_INDEX(5, 0)] = KEY_VOLUMEDOWN,
83 [KEYMAP_INDEX(5, 1)] = KEY_STAR, /* KEY_STAR */
84 [KEYMAP_INDEX(5, 2)] = KEY_MAIL, /* MESG */
85 [KEYMAP_INDEX(5, 3)] = KEY_3,
86 [KEYMAP_INDEX(5, 4)] = KEY_7,
87
88#if SCAN_FUNCTION_KEYS
89 [KEYMAP_INDEX(6, 0)] = KEY_F5,
90 [KEYMAP_INDEX(6, 1)] = KEY_F4,
91 [KEYMAP_INDEX(6, 2)] = KEY_F3,
92 [KEYMAP_INDEX(6, 3)] = KEY_F2,
93 [KEYMAP_INDEX(6, 4)] = KEY_F1
94#endif
95};
96
97static struct gpio_keypad_info halibut_keypad_info = {
98 .keymap = halibut_keymap,
99 .output_gpios = halibut_row_gpios,
100 .input_gpios = halibut_col_gpios,
101 .noutputs = ARRAY_SIZE(halibut_row_gpios),
102 .ninputs = ARRAY_SIZE(halibut_col_gpios),
103 .settle_time = 5 /* msec */,
104 .poll_time = 20 /* msec */,
105 .flags = GPIOKPF_DRIVE_INACTIVE,
106};
107
108void keypad_init(void)
109{
110 gpio_keypad_init(&halibut_keypad_info);
111}