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-2010, 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> |
Kinson Chik | ea64624 | 2011-09-01 13:53:16 -0700 | [diff] [blame] | 34 | #include <dev/ssbi.h> |
Chandan Uddaraju | 8adde5a | 2009-11-17 11:31:28 -0800 | [diff] [blame] | 35 | #include <dev/gpio_keypad.h> |
| 36 | |
| 37 | #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) |
Chandan Uddaraju | 5fa471a | 2009-12-02 17:31:34 -0800 | [diff] [blame] | 38 | #define BITS_IN_ELEMENT(x) (sizeof(x)[0] * 8) |
Chandan Uddaraju | 8adde5a | 2009-11-17 11:31:28 -0800 | [diff] [blame] | 39 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 40 | static unsigned char qwerty_keys_old[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
| 41 | static unsigned char qwerty_keys_new[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
Chandan Uddaraju | 8adde5a | 2009-11-17 11:31:28 -0800 | [diff] [blame] | 42 | |
Chandan Uddaraju | 5fa471a | 2009-12-02 17:31:34 -0800 | [diff] [blame] | 43 | #define KEYMAP_INDEX(row, col) (row)* BITS_IN_ELEMENT(qwerty_keys_new) + (col) |
| 44 | |
| 45 | static unsigned int qwerty_keymap[] = { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 46 | [KEYMAP_INDEX(4, 2)] = KEY_BACK, /* -L on SURF & FFA */ |
| 47 | [KEYMAP_INDEX(3, 4)] = KEY_HOME, /* +R on SURF & FFA */ |
| 48 | [KEYMAP_INDEX(1, 3)] = KEY_VOLUMEUP, /* '+' of left side switch on FLUID */ |
| 49 | [KEYMAP_INDEX(1, 4)] = KEY_VOLUMEDOWN, /* '-' of left side switch on FLUID */ |
Chandan Uddaraju | 8adde5a | 2009-11-17 11:31:28 -0800 | [diff] [blame] | 50 | }; |
| 51 | |
Chandan Uddaraju | 5fa471a | 2009-12-02 17:31:34 -0800 | [diff] [blame] | 52 | static struct qwerty_keypad_info qwerty_keypad = { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 53 | .keymap = qwerty_keymap, |
| 54 | .old_keys = qwerty_keys_old, |
| 55 | .rec_keys = qwerty_keys_new, |
| 56 | .rows = 5, |
| 57 | .columns = 5, |
| 58 | .num_of_reads = 6, |
| 59 | .rd_func = &i2c_ssbi_read_bytes, |
| 60 | .wr_func = &i2c_ssbi_write_bytes, |
| 61 | .settle_time = 5 /* msec */ , |
| 62 | .poll_time = 20 /* msec */ , |
Chandan Uddaraju | 8adde5a | 2009-11-17 11:31:28 -0800 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | void keypad_init(void) |
| 66 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 67 | ssbi_keypad_init(&qwerty_keypad); |
Chandan Uddaraju | 8adde5a | 2009-11-17 11:31:28 -0800 | [diff] [blame] | 68 | } |