Chandan Uddaraju | bedca15 | 2010-06-02 23:05:15 -0700 | [diff] [blame] | 1 | /* |
Duy Truong | f3ac7b3 | 2013-02-13 01:07:28 -0800 | [diff] [blame] | 2 | * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. |
Chandan Uddaraju | bedca15 | 2010-06-02 23:05:15 -0700 | [diff] [blame] | 3 | * |
| 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 Truong | f3ac7b3 | 2013-02-13 01:07:28 -0800 | [diff] [blame] | 11 | * * Neither the name of The Linux Foundation nor |
Chandan Uddaraju | bedca15 | 2010-06-02 23:05:15 -0700 | [diff] [blame] | 12 | * 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 Chik | ea64624 | 2011-09-01 13:53:16 -0700 | [diff] [blame] | 31 | #include <dev/ssbi.h> |
Chandan Uddaraju | bedca15 | 2010-06-02 23:05:15 -0700 | [diff] [blame] | 32 | #include <dev/gpio_keypad.h> |
Greg Grisco | d625055 | 2011-06-29 14:40:23 -0700 | [diff] [blame] | 33 | #include <platform.h> |
Chandan Uddaraju | bedca15 | 2010-06-02 23:05:15 -0700 | [diff] [blame] | 34 | |
Subbaraman Narayanamurthy | 8f0b045 | 2011-03-11 18:30:10 -0800 | [diff] [blame] | 35 | #define LINUX_MACHTYPE_8660_QT 3298 |
Chandan Uddaraju | bedca15 | 2010-06-02 23:05:15 -0700 | [diff] [blame] | 36 | #define BITS_IN_ELEMENT(x) (sizeof(x)[0] * 8) |
Subbaraman Narayanamurthy | 8f0b045 | 2011-03-11 18:30:10 -0800 | [diff] [blame] | 37 | #define KEYMAP_INDEX(row, col) (row)* BITS_IN_ELEMENT(qwerty_keys_new) + (col) |
Chandan Uddaraju | bedca15 | 2010-06-02 23:05:15 -0700 | [diff] [blame] | 38 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 39 | static unsigned char qwerty_keys_old[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
| 40 | static unsigned char qwerty_keys_new[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
Chandan Uddaraju | bedca15 | 2010-06-02 23:05:15 -0700 | [diff] [blame] | 41 | |
Subbaraman Narayanamurthy | 8f0b045 | 2011-03-11 18:30:10 -0800 | [diff] [blame] | 42 | static unsigned int qt_keymap[] = { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 43 | [KEYMAP_INDEX(0, 3)] = KEY_BACK, /* Volume down key */ |
| 44 | [KEYMAP_INDEX(1, 3)] = KEY_HOME, /* Volume up key */ |
Subbaraman Narayanamurthy | 8f0b045 | 2011-03-11 18:30:10 -0800 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | static struct qwerty_keypad_info qt_keypad = { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 48 | .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 Narayanamurthy | 8f0b045 | 2011-03-11 18:30:10 -0800 | [diff] [blame] | 58 | }; |
Chandan Uddaraju | bedca15 | 2010-06-02 23:05:15 -0700 | [diff] [blame] | 59 | |
| 60 | static unsigned int qwerty_keymap[] = { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 61 | [KEYMAP_INDEX(1, 3)] = KEY_BACK, /* Volume down key */ |
| 62 | [KEYMAP_INDEX(0, 3)] = KEY_HOME, /* Volume up key */ |
Chandan Uddaraju | bedca15 | 2010-06-02 23:05:15 -0700 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | static struct qwerty_keypad_info qwerty_keypad = { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 66 | .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 Uddaraju | bedca15 | 2010-06-02 23:05:15 -0700 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | void keypad_init(void) |
| 79 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 80 | unsigned int mach_id; |
Subbaraman Narayanamurthy | 8f0b045 | 2011-03-11 18:30:10 -0800 | [diff] [blame] | 81 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 82 | mach_id = board_machtype(); |
Subbaraman Narayanamurthy | 8f0b045 | 2011-03-11 18:30:10 -0800 | [diff] [blame] | 83 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 84 | if (mach_id == LINUX_MACHTYPE_8660_QT) |
| 85 | ssbi_keypad_init(&qt_keypad); |
| 86 | else |
| 87 | ssbi_keypad_init(&qwerty_keypad); |
Chandan Uddaraju | bedca15 | 2010-06-02 23:05:15 -0700 | [diff] [blame] | 88 | } |