Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 Google, Inc. |
Duy Truong | 790f06d | 2013-02-13 16:38:12 -0800 | [diff] [blame] | 3 | * Copyright (c) 2008-2009, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4 | * Author: Brian Swetland <swetland@google.com> |
| 5 | * |
| 6 | * This software is licensed under the terms of the GNU General Public |
| 7 | * License version 2, as published by the Free Software Foundation, and |
| 8 | * may be copied, distributed, and modified under those terms. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #include <linux/platform_device.h> |
| 18 | #include <linux/gpio_event.h> |
| 19 | |
| 20 | #include <asm/mach-types.h> |
| 21 | |
| 22 | /* don't turn this on without updating the ffa support */ |
| 23 | #define SCAN_FUNCTION_KEYS 0 |
| 24 | |
| 25 | /* FFA: |
| 26 | 36: KEYSENSE_N(0) |
| 27 | 37: KEYSENSE_N(1) |
| 28 | 38: KEYSENSE_N(2) |
| 29 | 39: KEYSENSE_N(3) |
| 30 | 40: KEYSENSE_N(4) |
| 31 | |
| 32 | 31: KYPD_17 |
| 33 | 32: KYPD_15 |
| 34 | 33: KYPD_13 |
| 35 | 34: KYPD_11 |
| 36 | 35: KYPD_9 |
| 37 | 41: KYPD_MEMO |
| 38 | */ |
| 39 | |
| 40 | static unsigned int keypad_row_gpios[] = { |
| 41 | 31, 32, 33, 34, 35, 41 |
| 42 | #if SCAN_FUNCTION_KEYS |
| 43 | , 42 |
| 44 | #endif |
| 45 | }; |
| 46 | |
| 47 | static unsigned int keypad_col_gpios[] = { 36, 37, 38, 39, 40 }; |
| 48 | |
| 49 | static unsigned int keypad_row_gpios_8k_ffa[] = {31, 32, 33, 34, 35, 36}; |
| 50 | static unsigned int keypad_col_gpios_8k_ffa[] = {38, 39, 40, 41, 42}; |
| 51 | |
| 52 | #define KEYMAP_INDEX(row, col) ((row)*ARRAY_SIZE(keypad_col_gpios) + (col)) |
| 53 | #define FFA_8K_KEYMAP_INDEX(row, col) ((row)* \ |
| 54 | ARRAY_SIZE(keypad_col_gpios_8k_ffa) + (col)) |
| 55 | |
| 56 | static const unsigned short keypad_keymap_surf[ARRAY_SIZE(keypad_col_gpios) * |
| 57 | ARRAY_SIZE(keypad_row_gpios)] = { |
| 58 | [KEYMAP_INDEX(0, 0)] = KEY_5, |
| 59 | [KEYMAP_INDEX(0, 1)] = KEY_9, |
| 60 | [KEYMAP_INDEX(0, 2)] = 229, /* SOFT1 */ |
| 61 | [KEYMAP_INDEX(0, 3)] = KEY_6, |
| 62 | [KEYMAP_INDEX(0, 4)] = KEY_LEFT, |
| 63 | |
| 64 | [KEYMAP_INDEX(1, 0)] = KEY_0, |
| 65 | [KEYMAP_INDEX(1, 1)] = KEY_RIGHT, |
| 66 | [KEYMAP_INDEX(1, 2)] = KEY_1, |
| 67 | [KEYMAP_INDEX(1, 3)] = 228, /* KEY_SHARP */ |
| 68 | [KEYMAP_INDEX(1, 4)] = KEY_SEND, |
| 69 | |
| 70 | [KEYMAP_INDEX(2, 0)] = KEY_VOLUMEUP, |
| 71 | [KEYMAP_INDEX(2, 1)] = KEY_HOME, /* FA */ |
| 72 | [KEYMAP_INDEX(2, 2)] = KEY_F8, /* QCHT */ |
| 73 | [KEYMAP_INDEX(2, 3)] = KEY_F6, /* R+ */ |
| 74 | [KEYMAP_INDEX(2, 4)] = KEY_F7, /* R- */ |
| 75 | |
| 76 | [KEYMAP_INDEX(3, 0)] = KEY_UP, |
| 77 | [KEYMAP_INDEX(3, 1)] = KEY_CLEAR, |
| 78 | [KEYMAP_INDEX(3, 2)] = KEY_4, |
| 79 | [KEYMAP_INDEX(3, 3)] = KEY_MUTE, /* SPKR */ |
| 80 | [KEYMAP_INDEX(3, 4)] = KEY_2, |
| 81 | |
| 82 | [KEYMAP_INDEX(4, 0)] = 230, /* SOFT2 */ |
| 83 | [KEYMAP_INDEX(4, 1)] = 232, /* KEY_CENTER */ |
| 84 | [KEYMAP_INDEX(4, 2)] = KEY_DOWN, |
| 85 | [KEYMAP_INDEX(4, 3)] = KEY_BACK, /* FB */ |
| 86 | [KEYMAP_INDEX(4, 4)] = KEY_8, |
| 87 | |
| 88 | [KEYMAP_INDEX(5, 0)] = KEY_VOLUMEDOWN, |
| 89 | [KEYMAP_INDEX(5, 1)] = 227, /* KEY_STAR */ |
| 90 | [KEYMAP_INDEX(5, 2)] = KEY_MAIL, /* MESG */ |
| 91 | [KEYMAP_INDEX(5, 3)] = KEY_3, |
| 92 | [KEYMAP_INDEX(5, 4)] = KEY_7, |
| 93 | |
| 94 | #if SCAN_FUNCTION_KEYS |
| 95 | [KEYMAP_INDEX(6, 0)] = KEY_F5, |
| 96 | [KEYMAP_INDEX(6, 1)] = KEY_F4, |
| 97 | [KEYMAP_INDEX(6, 2)] = KEY_F3, |
| 98 | [KEYMAP_INDEX(6, 3)] = KEY_F2, |
| 99 | [KEYMAP_INDEX(6, 4)] = KEY_F1 |
| 100 | #endif |
| 101 | }; |
| 102 | |
| 103 | static const unsigned short keypad_keymap_ffa[ARRAY_SIZE(keypad_col_gpios) * |
| 104 | ARRAY_SIZE(keypad_row_gpios)] = { |
| 105 | /*[KEYMAP_INDEX(0, 0)] = ,*/ |
| 106 | /*[KEYMAP_INDEX(0, 1)] = ,*/ |
| 107 | [KEYMAP_INDEX(0, 2)] = KEY_1, |
| 108 | [KEYMAP_INDEX(0, 3)] = KEY_SEND, |
| 109 | [KEYMAP_INDEX(0, 4)] = KEY_LEFT, |
| 110 | |
| 111 | [KEYMAP_INDEX(1, 0)] = KEY_3, |
| 112 | [KEYMAP_INDEX(1, 1)] = KEY_RIGHT, |
| 113 | [KEYMAP_INDEX(1, 2)] = KEY_VOLUMEUP, |
| 114 | /*[KEYMAP_INDEX(1, 3)] = ,*/ |
| 115 | [KEYMAP_INDEX(1, 4)] = KEY_6, |
| 116 | |
| 117 | [KEYMAP_INDEX(2, 0)] = KEY_HOME, /* A */ |
| 118 | [KEYMAP_INDEX(2, 1)] = KEY_BACK, /* B */ |
| 119 | [KEYMAP_INDEX(2, 2)] = KEY_0, |
| 120 | [KEYMAP_INDEX(2, 3)] = 228, /* KEY_SHARP */ |
| 121 | [KEYMAP_INDEX(2, 4)] = KEY_9, |
| 122 | |
| 123 | [KEYMAP_INDEX(3, 0)] = KEY_UP, |
| 124 | [KEYMAP_INDEX(3, 1)] = 232, /* KEY_CENTER */ /* i */ |
| 125 | [KEYMAP_INDEX(3, 2)] = KEY_4, |
| 126 | /*[KEYMAP_INDEX(3, 3)] = ,*/ |
| 127 | [KEYMAP_INDEX(3, 4)] = KEY_2, |
| 128 | |
| 129 | [KEYMAP_INDEX(4, 0)] = KEY_VOLUMEDOWN, |
| 130 | [KEYMAP_INDEX(4, 1)] = KEY_SOUND, |
| 131 | [KEYMAP_INDEX(4, 2)] = KEY_DOWN, |
| 132 | [KEYMAP_INDEX(4, 3)] = KEY_8, |
| 133 | [KEYMAP_INDEX(4, 4)] = KEY_5, |
| 134 | |
| 135 | /*[KEYMAP_INDEX(5, 0)] = ,*/ |
| 136 | [KEYMAP_INDEX(5, 1)] = 227, /* KEY_STAR */ |
| 137 | [KEYMAP_INDEX(5, 2)] = 230, /*SOFT2*/ /* 2 */ |
| 138 | [KEYMAP_INDEX(5, 3)] = KEY_MENU, /* 1 */ |
| 139 | [KEYMAP_INDEX(5, 4)] = KEY_7, |
| 140 | }; |
| 141 | |
| 142 | #define QSD8x50_FFA_KEYMAP_SIZE (ARRAY_SIZE(keypad_col_gpios_8k_ffa) * \ |
| 143 | ARRAY_SIZE(keypad_row_gpios_8k_ffa)) |
| 144 | |
| 145 | static const unsigned short keypad_keymap_8k_ffa[QSD8x50_FFA_KEYMAP_SIZE] = { |
| 146 | |
| 147 | [FFA_8K_KEYMAP_INDEX(0, 0)] = KEY_VOLUMEDOWN, |
| 148 | /*[KEYMAP_INDEX(0, 1)] = ,*/ |
| 149 | [FFA_8K_KEYMAP_INDEX(0, 2)] = KEY_DOWN, |
| 150 | [FFA_8K_KEYMAP_INDEX(0, 3)] = KEY_8, |
| 151 | [FFA_8K_KEYMAP_INDEX(0, 4)] = KEY_5, |
| 152 | |
| 153 | [FFA_8K_KEYMAP_INDEX(1, 0)] = KEY_UP, |
| 154 | [FFA_8K_KEYMAP_INDEX(1, 1)] = KEY_CLEAR, |
| 155 | [FFA_8K_KEYMAP_INDEX(1, 2)] = KEY_4, |
| 156 | /*[KEYMAP_INDEX(1, 3)] = ,*/ |
| 157 | [FFA_8K_KEYMAP_INDEX(1, 4)] = KEY_2, |
| 158 | |
| 159 | [FFA_8K_KEYMAP_INDEX(2, 0)] = KEY_HOME, /* A */ |
| 160 | [FFA_8K_KEYMAP_INDEX(2, 1)] = KEY_BACK, /* B */ |
| 161 | [FFA_8K_KEYMAP_INDEX(2, 2)] = KEY_0, |
| 162 | [FFA_8K_KEYMAP_INDEX(2, 3)] = 228, /* KEY_SHARP */ |
| 163 | [FFA_8K_KEYMAP_INDEX(2, 4)] = KEY_9, |
| 164 | |
| 165 | [FFA_8K_KEYMAP_INDEX(3, 0)] = KEY_3, |
| 166 | [FFA_8K_KEYMAP_INDEX(3, 1)] = KEY_RIGHT, |
| 167 | [FFA_8K_KEYMAP_INDEX(3, 2)] = KEY_VOLUMEUP, |
| 168 | /*[KEYMAP_INDEX(3, 3)] = ,*/ |
| 169 | [FFA_8K_KEYMAP_INDEX(3, 4)] = KEY_6, |
| 170 | |
| 171 | [FFA_8K_KEYMAP_INDEX(4, 0)] = 232, /* OK */ |
| 172 | [FFA_8K_KEYMAP_INDEX(4, 1)] = KEY_SOUND, |
| 173 | [FFA_8K_KEYMAP_INDEX(4, 2)] = KEY_1, |
| 174 | [FFA_8K_KEYMAP_INDEX(4, 3)] = KEY_SEND, |
| 175 | [FFA_8K_KEYMAP_INDEX(4, 4)] = KEY_LEFT, |
| 176 | |
| 177 | /*[KEYMAP_INDEX(5, 0)] = ,*/ |
| 178 | [FFA_8K_KEYMAP_INDEX(5, 1)] = 227, /* KEY_STAR */ |
| 179 | [FFA_8K_KEYMAP_INDEX(5, 2)] = 230, /*SOFT2*/ /* 2 */ |
| 180 | [FFA_8K_KEYMAP_INDEX(5, 3)] = 229, /* 1 */ |
| 181 | [FFA_8K_KEYMAP_INDEX(5, 4)] = KEY_7, |
| 182 | }; |
| 183 | |
| 184 | /* SURF keypad platform device information */ |
| 185 | static struct gpio_event_matrix_info surf_keypad_matrix_info = { |
| 186 | .info.func = gpio_event_matrix_func, |
| 187 | .keymap = keypad_keymap_surf, |
| 188 | .output_gpios = keypad_row_gpios, |
| 189 | .input_gpios = keypad_col_gpios, |
| 190 | .noutputs = ARRAY_SIZE(keypad_row_gpios), |
| 191 | .ninputs = ARRAY_SIZE(keypad_col_gpios), |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 192 | .settle_time.tv64 = 40 * NSEC_PER_USEC, |
| 193 | .poll_time.tv64 = 20 * NSEC_PER_MSEC, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 194 | .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_DRIVE_INACTIVE | |
| 195 | GPIOKPF_PRINT_UNMAPPED_KEYS |
| 196 | }; |
| 197 | |
| 198 | static struct gpio_event_info *surf_keypad_info[] = { |
| 199 | &surf_keypad_matrix_info.info |
| 200 | }; |
| 201 | |
| 202 | static struct gpio_event_platform_data surf_keypad_data = { |
| 203 | .name = "surf_keypad", |
| 204 | .info = surf_keypad_info, |
| 205 | .info_count = ARRAY_SIZE(surf_keypad_info) |
| 206 | }; |
| 207 | |
| 208 | struct platform_device keypad_device_surf = { |
| 209 | .name = GPIO_EVENT_DEV_NAME, |
| 210 | .id = -1, |
| 211 | .dev = { |
| 212 | .platform_data = &surf_keypad_data, |
| 213 | }, |
| 214 | }; |
| 215 | |
| 216 | /* 8k FFA keypad platform device information */ |
| 217 | static struct gpio_event_matrix_info keypad_matrix_info_8k_ffa = { |
| 218 | .info.func = gpio_event_matrix_func, |
| 219 | .keymap = keypad_keymap_8k_ffa, |
| 220 | .output_gpios = keypad_row_gpios_8k_ffa, |
| 221 | .input_gpios = keypad_col_gpios_8k_ffa, |
| 222 | .noutputs = ARRAY_SIZE(keypad_row_gpios_8k_ffa), |
| 223 | .ninputs = ARRAY_SIZE(keypad_col_gpios_8k_ffa), |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 224 | .settle_time.tv64 = 40 * NSEC_PER_USEC, |
| 225 | .poll_time.tv64 = 20 * NSEC_PER_MSEC, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 226 | .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_DRIVE_INACTIVE | |
| 227 | GPIOKPF_PRINT_UNMAPPED_KEYS |
| 228 | }; |
| 229 | |
| 230 | static struct gpio_event_info *keypad_info_8k_ffa[] = { |
| 231 | &keypad_matrix_info_8k_ffa.info |
| 232 | }; |
| 233 | |
| 234 | static struct gpio_event_platform_data keypad_data_8k_ffa = { |
| 235 | .name = "8k_ffa_keypad", |
| 236 | .info = keypad_info_8k_ffa, |
| 237 | .info_count = ARRAY_SIZE(keypad_info_8k_ffa) |
| 238 | }; |
| 239 | |
| 240 | struct platform_device keypad_device_8k_ffa = { |
| 241 | .name = GPIO_EVENT_DEV_NAME, |
| 242 | .id = -1, |
| 243 | .dev = { |
| 244 | .platform_data = &keypad_data_8k_ffa, |
| 245 | }, |
| 246 | }; |
| 247 | |
| 248 | /* 7k FFA keypad platform device information */ |
| 249 | static struct gpio_event_matrix_info keypad_matrix_info_7k_ffa = { |
| 250 | .info.func = gpio_event_matrix_func, |
| 251 | .keymap = keypad_keymap_ffa, |
| 252 | .output_gpios = keypad_row_gpios, |
| 253 | .input_gpios = keypad_col_gpios, |
| 254 | .noutputs = ARRAY_SIZE(keypad_row_gpios), |
| 255 | .ninputs = ARRAY_SIZE(keypad_col_gpios), |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 256 | .settle_time.tv64 = 40 * NSEC_PER_USEC, |
| 257 | .poll_time.tv64 = 20 * NSEC_PER_MSEC, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 258 | .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_DRIVE_INACTIVE | |
| 259 | GPIOKPF_PRINT_UNMAPPED_KEYS |
| 260 | }; |
| 261 | |
| 262 | static struct gpio_event_info *keypad_info_7k_ffa[] = { |
| 263 | &keypad_matrix_info_7k_ffa.info |
| 264 | }; |
| 265 | |
| 266 | static struct gpio_event_platform_data keypad_data_7k_ffa = { |
| 267 | .name = "7k_ffa_keypad", |
| 268 | .info = keypad_info_7k_ffa, |
| 269 | .info_count = ARRAY_SIZE(keypad_info_7k_ffa) |
| 270 | }; |
| 271 | |
| 272 | struct platform_device keypad_device_7k_ffa = { |
| 273 | .name = GPIO_EVENT_DEV_NAME, |
| 274 | .id = -1, |
| 275 | .dev = { |
| 276 | .platform_data = &keypad_data_7k_ffa, |
| 277 | }, |
| 278 | }; |
| 279 | |