blob: 29563367044cf3faf7858373475ef497a83955be [file] [log] [blame]
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
* Copyright (c) 2009, Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google, Inc. nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <dev/keys.h>
#include <dev/gpio_keypad.h>
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
/* don't turn this on without updating the ffa support */
#define SCAN_FUNCTION_KEYS 0
static unsigned int halibut_row_gpios[] = {
31, 32, 33, 34, 35, 36
#if SCAN_FUNCTION_KEYS
, 42
#endif
};
static unsigned int halibut_col_gpios[] = { 38, 39, 40, 41, 42 };
#define KEYMAP_INDEX(row, col) ((row)*ARRAY_SIZE(halibut_col_gpios) + (col))
static const unsigned short halibut_keymap[ARRAY_SIZE(halibut_col_gpios) * ARRAY_SIZE(halibut_row_gpios)] = {
[KEYMAP_INDEX(0, 0)] = KEY_VOLUMEDOWN,
/*[KEYMAP_INDEX(0, 1)] = ,*/
[KEYMAP_INDEX(0, 2)] = KEY_DOWN,
[KEYMAP_INDEX(0, 3)] = KEY_8,
[KEYMAP_INDEX(0, 4)] = KEY_5,
[KEYMAP_INDEX(1, 0)] = KEY_UP,
[KEYMAP_INDEX(1, 1)] = KEY_CLEAR,
[KEYMAP_INDEX(1, 2)] = KEY_4,
/*[KEYMAP_INDEX(1, 3)] = ,*/
[KEYMAP_INDEX(1, 4)] = KEY_2,
[KEYMAP_INDEX(2, 0)] = KEY_HOME, /* A */
[KEYMAP_INDEX(2, 1)] = KEY_BACK, /* B */
[KEYMAP_INDEX(2, 2)] = KEY_0,
[KEYMAP_INDEX(2, 3)] = 228, /* KEY_SHARP */
[KEYMAP_INDEX(2, 4)] = KEY_9,
[KEYMAP_INDEX(3, 0)] = KEY_3,
[KEYMAP_INDEX(3, 1)] = KEY_RIGHT,
[KEYMAP_INDEX(3, 2)] = KEY_VOLUMEUP,
/*[KEYMAP_INDEX(3, 3)] = ,*/
[KEYMAP_INDEX(3, 4)] = KEY_6,
[KEYMAP_INDEX(4, 0)] = 232, /* OK */
[KEYMAP_INDEX(4, 1)] = KEY_SOUND,
[KEYMAP_INDEX(4, 2)] = KEY_1,
[KEYMAP_INDEX(4, 3)] = KEY_SEND,
[KEYMAP_INDEX(4, 4)] = KEY_LEFT,
/*[KEYMAP_INDEX(5, 0)] = ,*/
[KEYMAP_INDEX(5, 1)] = 227, /* KEY_STAR */
[KEYMAP_INDEX(5, 2)] = 230, /* (SOFT2)2 */
[KEYMAP_INDEX(5, 3)] = KEY_MENU, /* 1 */
[KEYMAP_INDEX(5, 4)] = KEY_7,
#if SCAN_FUNCTION_KEYS
[KEYMAP_INDEX(6, 0)] = KEY_F5,
[KEYMAP_INDEX(6, 1)] = KEY_F4,
[KEYMAP_INDEX(6, 2)] = KEY_F3,
[KEYMAP_INDEX(6, 3)] = KEY_F2,
[KEYMAP_INDEX(6, 4)] = KEY_F1
#endif
};
static struct gpio_keypad_info halibut_keypad_info = {
.keymap = halibut_keymap,
.output_gpios = halibut_row_gpios,
.input_gpios = halibut_col_gpios,
.noutputs = ARRAY_SIZE(halibut_row_gpios),
.ninputs = ARRAY_SIZE(halibut_col_gpios),
.settle_time = 5 /* msec */,
.poll_time = 20 /* msec */,
.flags = GPIOKPF_DRIVE_INACTIVE,
};
void keypad_init(void)
{
gpio_keypad_init(&halibut_keypad_info);
}