blob: a1d875952383f2d4eddadd303450d36cbf162c9e [file] [log] [blame]
Chandan Uddarajubedca152010-06-02 23:05:15 -07001/*
Duy Truongf3ac7b32013-02-13 01:07:28 -08002 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
Chandan Uddarajubedca152010-06-02 23:05:15 -07003 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
Duy Truongf3ac7b32013-02-13 01:07:28 -080011 * * Neither the name of The Linux Foundation nor
Chandan Uddarajubedca152010-06-02 23:05:15 -070012 * the names of its contributors may be used to endorse or promote
13 * products derived from this software without specific prior written
14 * permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29
30#include <dev/keys.h>
Kinson Chikea646242011-09-01 13:53:16 -070031#include <dev/ssbi.h>
Chandan Uddarajubedca152010-06-02 23:05:15 -070032#include <dev/gpio_keypad.h>
Greg Griscod6250552011-06-29 14:40:23 -070033#include <platform.h>
Chandan Uddarajubedca152010-06-02 23:05:15 -070034
Subbaraman Narayanamurthy8f0b0452011-03-11 18:30:10 -080035#define LINUX_MACHTYPE_8660_QT 3298
Chandan Uddarajubedca152010-06-02 23:05:15 -070036#define BITS_IN_ELEMENT(x) (sizeof(x)[0] * 8)
Subbaraman Narayanamurthy8f0b0452011-03-11 18:30:10 -080037#define KEYMAP_INDEX(row, col) (row)* BITS_IN_ELEMENT(qwerty_keys_new) + (col)
Chandan Uddarajubedca152010-06-02 23:05:15 -070038
Ajay Dudanib01e5062011-12-03 23:23:42 -080039static unsigned char qwerty_keys_old[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
40static unsigned char qwerty_keys_new[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
Chandan Uddarajubedca152010-06-02 23:05:15 -070041
Subbaraman Narayanamurthy8f0b0452011-03-11 18:30:10 -080042static unsigned int qt_keymap[] = {
Ajay Dudanib01e5062011-12-03 23:23:42 -080043 [KEYMAP_INDEX(0, 3)] = KEY_BACK, /* Volume down key */
44 [KEYMAP_INDEX(1, 3)] = KEY_HOME, /* Volume up key */
Subbaraman Narayanamurthy8f0b0452011-03-11 18:30:10 -080045};
46
47static struct qwerty_keypad_info qt_keypad = {
Ajay Dudanib01e5062011-12-03 23:23:42 -080048 .keymap = qt_keymap,
49 .old_keys = qwerty_keys_old,
50 .rec_keys = qwerty_keys_new,
51 .rows = 3,
52 .columns = 1,
53 .num_of_reads = 3,
54 .rd_func = &pa1_ssbi2_read_bytes,
55 .wr_func = &pa1_ssbi2_write_bytes,
56 .settle_time = 32 /* msec */ ,
57 .poll_time = 10 /* msec */ ,
Subbaraman Narayanamurthy8f0b0452011-03-11 18:30:10 -080058};
Chandan Uddarajubedca152010-06-02 23:05:15 -070059
60static unsigned int qwerty_keymap[] = {
Ajay Dudanib01e5062011-12-03 23:23:42 -080061 [KEYMAP_INDEX(1, 3)] = KEY_BACK, /* Volume down key */
62 [KEYMAP_INDEX(0, 3)] = KEY_HOME, /* Volume up key */
Chandan Uddarajubedca152010-06-02 23:05:15 -070063};
64
65static struct qwerty_keypad_info qwerty_keypad = {
Ajay Dudanib01e5062011-12-03 23:23:42 -080066 .keymap = qwerty_keymap,
67 .old_keys = qwerty_keys_old,
68 .rec_keys = qwerty_keys_new,
69 .rows = 6,
70 .columns = 5,
71 .num_of_reads = 6,
72 .rd_func = &pa1_ssbi2_read_bytes,
73 .wr_func = &pa1_ssbi2_write_bytes,
74 .settle_time = 5 /* msec */ ,
75 .poll_time = 20 /* msec */ ,
Chandan Uddarajubedca152010-06-02 23:05:15 -070076};
77
78void keypad_init(void)
79{
Ajay Dudanib01e5062011-12-03 23:23:42 -080080 unsigned int mach_id;
Subbaraman Narayanamurthy8f0b0452011-03-11 18:30:10 -080081
Ajay Dudanib01e5062011-12-03 23:23:42 -080082 mach_id = board_machtype();
Subbaraman Narayanamurthy8f0b0452011-03-11 18:30:10 -080083
Ajay Dudanib01e5062011-12-03 23:23:42 -080084 if (mach_id == LINUX_MACHTYPE_8660_QT)
85 ssbi_keypad_init(&qt_keypad);
86 else
87 ssbi_keypad_init(&qwerty_keypad);
Chandan Uddarajubedca152010-06-02 23:05:15 -070088}