aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard/tc3589x-keypad.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/keyboard/tc3589x-keypad.c')
-rw-r--r--drivers/input/keyboard/tc3589x-keypad.c41
1 files changed, 18 insertions, 23 deletions
diff --git a/drivers/input/keyboard/tc3589x-keypad.c b/drivers/input/keyboard/tc3589x-keypad.c
index 2dee3e4e7c6f..7d498e698508 100644
--- a/drivers/input/keyboard/tc3589x-keypad.c
+++ b/drivers/input/keyboard/tc3589x-keypad.c
@@ -78,7 +78,7 @@
78 * @input: pointer to input device object 78 * @input: pointer to input device object
79 * @board: keypad platform device 79 * @board: keypad platform device
80 * @krow: number of rows 80 * @krow: number of rows
81 * @kcol: number of coloumns 81 * @kcol: number of columns
82 * @keymap: matrix scan code table for keycodes 82 * @keymap: matrix scan code table for keycodes
83 * @keypad_stopped: holds keypad status 83 * @keypad_stopped: holds keypad status
84 */ 84 */
@@ -96,21 +96,15 @@ static int tc3589x_keypad_init_key_hardware(struct tc_keypad *keypad)
96{ 96{
97 int ret; 97 int ret;
98 struct tc3589x *tc3589x = keypad->tc3589x; 98 struct tc3589x *tc3589x = keypad->tc3589x;
99 u8 settle_time = keypad->board->settle_time; 99 const struct tc3589x_keypad_platform_data *board = keypad->board;
100 u8 dbounce_period = keypad->board->debounce_period; 100
101 u8 rows = keypad->board->krow & 0xf; /* mask out the nibble */ 101 /* validate platform configuration */
102 u8 column = keypad->board->kcol & 0xf; /* mask out the nibble */ 102 if (board->kcol > TC3589x_MAX_KPCOL || board->krow > TC3589x_MAX_KPROW)
103
104 /* validate platform configurations */
105 if (keypad->board->kcol > TC3589x_MAX_KPCOL ||
106 keypad->board->krow > TC3589x_MAX_KPROW ||
107 keypad->board->debounce_period > TC3589x_MAX_DEBOUNCE_SETTLE ||
108 keypad->board->settle_time > TC3589x_MAX_DEBOUNCE_SETTLE)
109 return -EINVAL; 103 return -EINVAL;
110 104
111 /* configure KBDSIZE 4 LSbits for cols and 4 MSbits for rows */ 105 /* configure KBDSIZE 4 LSbits for cols and 4 MSbits for rows */
112 ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSIZE, 106 ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSIZE,
113 (rows << KP_ROW_SHIFT) | column); 107 (board->krow << KP_ROW_SHIFT) | board->kcol);
114 if (ret < 0) 108 if (ret < 0)
115 return ret; 109 return ret;
116 110
@@ -124,12 +118,14 @@ static int tc3589x_keypad_init_key_hardware(struct tc_keypad *keypad)
124 return ret; 118 return ret;
125 119
126 /* Configure settle time */ 120 /* Configure settle time */
127 ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSETTLE_REG, settle_time); 121 ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSETTLE_REG,
122 board->settle_time);
128 if (ret < 0) 123 if (ret < 0)
129 return ret; 124 return ret;
130 125
131 /* Configure debounce time */ 126 /* Configure debounce time */
132 ret = tc3589x_reg_write(tc3589x, TC3589x_KBDBOUNCE, dbounce_period); 127 ret = tc3589x_reg_write(tc3589x, TC3589x_KBDBOUNCE,
128 board->debounce_period);
133 if (ret < 0) 129 if (ret < 0)
134 return ret; 130 return ret;
135 131
@@ -337,23 +333,22 @@ static int __devinit tc3589x_keypad_probe(struct platform_device *pdev)
337 input->name = pdev->name; 333 input->name = pdev->name;
338 input->dev.parent = &pdev->dev; 334 input->dev.parent = &pdev->dev;
339 335
340 input->keycode = keypad->keymap;
341 input->keycodesize = sizeof(keypad->keymap[0]);
342 input->keycodemax = ARRAY_SIZE(keypad->keymap);
343
344 input->open = tc3589x_keypad_open; 336 input->open = tc3589x_keypad_open;
345 input->close = tc3589x_keypad_close; 337 input->close = tc3589x_keypad_close;
346 338
347 input_set_drvdata(input, keypad); 339 error = matrix_keypad_build_keymap(plat->keymap_data, NULL,
340 TC3589x_MAX_KPROW, TC3589x_MAX_KPCOL,
341 keypad->keymap, input);
342 if (error) {
343 dev_err(&pdev->dev, "Failed to build keymap\n");
344 goto err_free_mem;
345 }
348 346
349 input_set_capability(input, EV_MSC, MSC_SCAN); 347 input_set_capability(input, EV_MSC, MSC_SCAN);
350
351 __set_bit(EV_KEY, input->evbit);
352 if (!plat->no_autorepeat) 348 if (!plat->no_autorepeat)
353 __set_bit(EV_REP, input->evbit); 349 __set_bit(EV_REP, input->evbit);
354 350
355 matrix_keypad_build_keymap(plat->keymap_data, 0x3, 351 input_set_drvdata(input, keypad);
356 input->keycode, input->keybit);
357 352
358 error = request_threaded_irq(irq, NULL, 353 error = request_threaded_irq(irq, NULL,
359 tc3589x_keypad_irq, plat->irqtype, 354 tc3589x_keypad_irq, plat->irqtype,