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