Chandan Uddaraju | 8adde5a | 2009-11-17 11:31:28 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2009, Google Inc. |
| 3 | * All rights reserved. |
Duy Truong | f3ac7b3 | 2013-02-13 01:07:28 -0800 | [diff] [blame] | 4 | * Copyright (c) 2009, The Linux Foundation. All rights reserved. |
Chandan Uddaraju | 8adde5a | 2009-11-17 11:31:28 -0800 | [diff] [blame] | 5 | * |
| 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 | |
| 41 | static unsigned int halibut_row_gpios[] = { |
| 42 | 31, 32, 33, 34, 35, 41 |
| 43 | #if SCAN_FUNCTION_KEYS |
| 44 | , 42 |
| 45 | #endif |
| 46 | }; |
| 47 | |
| 48 | static 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 | |
| 52 | static const unsigned short halibut_keymap[ARRAY_SIZE(halibut_col_gpios) * ARRAY_SIZE(halibut_row_gpios)] = { |
| 53 | [KEYMAP_INDEX(0, 0)] = KEY_5, |
| 54 | [KEYMAP_INDEX(0, 1)] = KEY_9, |
| 55 | [KEYMAP_INDEX(0, 2)] = KEY_SOFT1, |
| 56 | [KEYMAP_INDEX(0, 3)] = KEY_6, |
| 57 | [KEYMAP_INDEX(0, 4)] = KEY_LEFT, |
| 58 | |
| 59 | [KEYMAP_INDEX(1, 0)] = KEY_0, |
| 60 | [KEYMAP_INDEX(1, 1)] = KEY_RIGHT, |
| 61 | [KEYMAP_INDEX(1, 2)] = KEY_1, |
| 62 | [KEYMAP_INDEX(1, 3)] = KEY_SHARP, |
| 63 | [KEYMAP_INDEX(1, 4)] = KEY_SEND, |
| 64 | |
| 65 | [KEYMAP_INDEX(2, 0)] = KEY_VOLUMEUP, |
| 66 | [KEYMAP_INDEX(2, 1)] = KEY_HOME, /* FA */ |
| 67 | [KEYMAP_INDEX(2, 2)] = KEY_F8, /* QCHT */ |
| 68 | [KEYMAP_INDEX(2, 3)] = KEY_F6, /* R+ */ |
| 69 | [KEYMAP_INDEX(2, 4)] = KEY_F7, /* R- */ |
| 70 | |
| 71 | [KEYMAP_INDEX(3, 0)] = KEY_UP, |
| 72 | [KEYMAP_INDEX(3, 1)] = KEY_CLEAR, |
| 73 | [KEYMAP_INDEX(3, 2)] = KEY_4, |
| 74 | [KEYMAP_INDEX(3, 3)] = KEY_MUTE, /* SPKR */ |
| 75 | [KEYMAP_INDEX(3, 4)] = KEY_2, |
| 76 | |
| 77 | [KEYMAP_INDEX(4, 0)] = KEY_SOFT2, /* SOFT2 */ |
| 78 | [KEYMAP_INDEX(4, 1)] = KEY_CENTER, /* KEY_CENTER */ |
| 79 | [KEYMAP_INDEX(4, 2)] = KEY_DOWN, |
| 80 | [KEYMAP_INDEX(4, 3)] = KEY_BACK, /* FB */ |
| 81 | [KEYMAP_INDEX(4, 4)] = KEY_8, |
| 82 | |
| 83 | [KEYMAP_INDEX(5, 0)] = KEY_VOLUMEDOWN, |
| 84 | [KEYMAP_INDEX(5, 1)] = KEY_STAR, /* KEY_STAR */ |
| 85 | [KEYMAP_INDEX(5, 2)] = KEY_MAIL, /* MESG */ |
| 86 | [KEYMAP_INDEX(5, 3)] = KEY_3, |
| 87 | [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 | |
| 98 | static 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 | |
| 109 | void keypad_init(void) |
| 110 | { |
| 111 | gpio_keypad_init(&halibut_keypad_info); |
| 112 | } |