aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard/omap-keypad.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/input/keyboard/omap-keypad.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'drivers/input/keyboard/omap-keypad.c')
-rw-r--r--drivers/input/keyboard/omap-keypad.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c
index a72e61ddca91..33d0bdc837c0 100644
--- a/drivers/input/keyboard/omap-keypad.c
+++ b/drivers/input/keyboard/omap-keypad.c
@@ -65,7 +65,6 @@ struct omap_kp {
65 65
66static DECLARE_TASKLET_DISABLED(kp_tasklet, omap_kp_tasklet, 0); 66static DECLARE_TASKLET_DISABLED(kp_tasklet, omap_kp_tasklet, 0);
67 67
68static int *keymap;
69static unsigned int *row_gpios; 68static unsigned int *row_gpios;
70static unsigned int *col_gpios; 69static unsigned int *col_gpios;
71 70
@@ -162,20 +161,11 @@ static void omap_kp_scan_keypad(struct omap_kp *omap_kp, unsigned char *state)
162 } 161 }
163} 162}
164 163
165static inline int omap_kp_find_key(int col, int row)
166{
167 int i, key;
168
169 key = KEY(col, row, 0);
170 for (i = 0; keymap[i] != 0; i++)
171 if ((keymap[i] & 0xff000000) == key)
172 return keymap[i] & 0x00ffffff;
173 return -1;
174}
175
176static void omap_kp_tasklet(unsigned long data) 164static void omap_kp_tasklet(unsigned long data)
177{ 165{
178 struct omap_kp *omap_kp_data = (struct omap_kp *) data; 166 struct omap_kp *omap_kp_data = (struct omap_kp *) data;
167 unsigned short *keycodes = omap_kp_data->input->keycode;
168 unsigned int row_shift = get_count_order(omap_kp_data->cols);
179 unsigned char new_state[8], changed, key_down = 0; 169 unsigned char new_state[8], changed, key_down = 0;
180 int col, row; 170 int col, row;
181 int spurious = 0; 171 int spurious = 0;
@@ -199,7 +189,7 @@ static void omap_kp_tasklet(unsigned long data)
199 row, (new_state[col] & (1 << row)) ? 189 row, (new_state[col] & (1 << row)) ?
200 "pressed" : "released"); 190 "pressed" : "released");
201#else 191#else
202 key = omap_kp_find_key(col, row); 192 key = keycodes[MATRIX_SCAN_CODE(row, col, row_shift)];
203 if (key < 0) { 193 if (key < 0) {
204 printk(KERN_WARNING 194 printk(KERN_WARNING
205 "omap-keypad: Spurious key event %d-%d\n", 195 "omap-keypad: Spurious key event %d-%d\n",
@@ -219,6 +209,7 @@ static void omap_kp_tasklet(unsigned long data)
219#endif 209#endif
220 } 210 }
221 } 211 }
212 input_sync(omap_kp_data->input);
222 memcpy(keypad_state, new_state, sizeof(keypad_state)); 213 memcpy(keypad_state, new_state, sizeof(keypad_state));
223 214
224 if (key_down) { 215 if (key_down) {
@@ -298,13 +289,18 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
298 struct input_dev *input_dev; 289 struct input_dev *input_dev;
299 struct omap_kp_platform_data *pdata = pdev->dev.platform_data; 290 struct omap_kp_platform_data *pdata = pdev->dev.platform_data;
300 int i, col_idx, row_idx, irq_idx, ret; 291 int i, col_idx, row_idx, irq_idx, ret;
292 unsigned int row_shift, keycodemax;
301 293
302 if (!pdata->rows || !pdata->cols || !pdata->keymap) { 294 if (!pdata->rows || !pdata->cols || !pdata->keymap_data) {
303 printk(KERN_ERR "No rows, cols or keymap from pdata\n"); 295 printk(KERN_ERR "No rows, cols or keymap_data from pdata\n");
304 return -EINVAL; 296 return -EINVAL;
305 } 297 }
306 298
307 omap_kp = kzalloc(sizeof(struct omap_kp), GFP_KERNEL); 299 row_shift = get_count_order(pdata->cols);
300 keycodemax = pdata->rows << row_shift;
301
302 omap_kp = kzalloc(sizeof(struct omap_kp) +
303 keycodemax * sizeof(unsigned short), GFP_KERNEL);
308 input_dev = input_allocate_device(); 304 input_dev = input_allocate_device();
309 if (!omap_kp || !input_dev) { 305 if (!omap_kp || !input_dev) {
310 kfree(omap_kp); 306 kfree(omap_kp);
@@ -320,7 +316,9 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
320 if (!cpu_is_omap24xx()) 316 if (!cpu_is_omap24xx())
321 omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT); 317 omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
322 318
323 keymap = pdata->keymap; 319 input_dev->keycode = &omap_kp[1];
320 input_dev->keycodesize = sizeof(unsigned short);
321 input_dev->keycodemax = keycodemax;
324 322
325 if (pdata->rep) 323 if (pdata->rep)
326 __set_bit(EV_REP, input_dev->evbit); 324 __set_bit(EV_REP, input_dev->evbit);
@@ -374,8 +372,8 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
374 372
375 /* setup input device */ 373 /* setup input device */
376 __set_bit(EV_KEY, input_dev->evbit); 374 __set_bit(EV_KEY, input_dev->evbit);
377 for (i = 0; keymap[i] != 0; i++) 375 matrix_keypad_build_keymap(pdata->keymap_data, row_shift,
378 __set_bit(keymap[i] & KEY_MAX, input_dev->keybit); 376 input_dev->keycode, input_dev->keybit);
379 input_dev->name = "omap-keypad"; 377 input_dev->name = "omap-keypad";
380 input_dev->phys = "omap-keypad/input0"; 378 input_dev->phys = "omap-keypad/input0";
381 input_dev->dev.parent = &pdev->dev; 379 input_dev->dev.parent = &pdev->dev;
@@ -416,7 +414,7 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
416 return 0; 414 return 0;
417err5: 415err5:
418 for (i = irq_idx - 1; i >=0; i--) 416 for (i = irq_idx - 1; i >=0; i--)
419 free_irq(row_gpios[i], 0); 417 free_irq(row_gpios[i], omap_kp);
420err4: 418err4:
421 input_unregister_device(omap_kp->input); 419 input_unregister_device(omap_kp->input);
422 input_dev = NULL; 420 input_dev = NULL;
@@ -447,11 +445,11 @@ static int __devexit omap_kp_remove(struct platform_device *pdev)
447 gpio_free(col_gpios[i]); 445 gpio_free(col_gpios[i]);
448 for (i = 0; i < omap_kp->rows; i++) { 446 for (i = 0; i < omap_kp->rows; i++) {
449 gpio_free(row_gpios[i]); 447 gpio_free(row_gpios[i]);
450 free_irq(gpio_to_irq(row_gpios[i]), 0); 448 free_irq(gpio_to_irq(row_gpios[i]), omap_kp);
451 } 449 }
452 } else { 450 } else {
453 omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT); 451 omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
454 free_irq(omap_kp->irq, 0); 452 free_irq(omap_kp->irq, omap_kp);
455 } 453 }
456 454
457 del_timer_sync(&omap_kp->timer); 455 del_timer_sync(&omap_kp->timer);