aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2012-11-14 11:55:21 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2012-11-24 03:21:49 -0500
commit6ea32387a0c7fb9ca0213fd22b47c5a1ca4c2972 (patch)
treecdae4cc6b20eb6190493e4cddd602ecab3e11cf0 /drivers/input
parente2619cf78e19476bfd7ceaefa9eff0847529346e (diff)
Input: stmpe-keypad - add support for Device Tree bindings
This patch allows the STMPE driver to be successfully probed and initialised when Device Tree support is enabled. Besides the usual platform data changes, we also separate the process of filling in the 'in use' pin bitmap, as we have to extract the information from Device Tree in the DT boot case. Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/keyboard/stmpe-keypad.c60
1 files changed, 51 insertions, 9 deletions
diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c
index 7bac0524900a..5cbec56f7720 100644
--- a/drivers/input/keyboard/stmpe-keypad.c
+++ b/drivers/input/keyboard/stmpe-keypad.c
@@ -257,6 +257,51 @@ static int stmpe_keypad_chip_init(struct stmpe_keypad *keypad)
257 (plat->debounce_ms << 1)); 257 (plat->debounce_ms << 1));
258} 258}
259 259
260static void stmpe_keypad_fill_used_pins(struct stmpe_keypad *keypad)
261{
262 int row, col;
263
264 for (row = 0; row < STMPE_KEYPAD_MAX_ROWS; row++) {
265 for (col = 0; col < STMPE_KEYPAD_MAX_COLS; col++) {
266 int code = MATRIX_SCAN_CODE(row, col,
267 STMPE_KEYPAD_ROW_SHIFT);
268 if (keypad->keymap[code] != KEY_RESERVED) {
269 keypad->rows |= 1 << row;
270 keypad->cols |= 1 << col;
271 }
272 }
273 }
274}
275
276#ifdef CONFIG_OF
277static const struct stmpe_keypad_platform_data *
278stmpe_keypad_of_probe(struct device *dev)
279{
280 struct device_node *np = dev->of_node;
281 struct stmpe_keypad_platform_data *plat;
282
283 if (!np)
284 return ERR_PTR(-ENODEV);
285
286 plat = devm_kzalloc(dev, sizeof(*plat), GFP_KERNEL);
287 if (!plat)
288 return ERR_PTR(-ENOMEM);
289
290 of_property_read_u32(np, "debounce-interval", &plat->debounce_ms);
291 of_property_read_u32(np, "st,scan-count", &plat->scan_count);
292
293 plat->no_autorepeat = of_property_read_bool(np, "st,no-autorepeat");
294
295 return plat;
296}
297#else
298static inline const struct stmpe_keypad_platform_data *
299stmpe_keypad_of_probe(struct device *dev)
300{
301 return ERR_PTR(-EINVAL);
302}
303#endif
304
260static int stmpe_keypad_probe(struct platform_device *pdev) 305static int stmpe_keypad_probe(struct platform_device *pdev)
261{ 306{
262 struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); 307 struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent);
@@ -265,11 +310,13 @@ static int stmpe_keypad_probe(struct platform_device *pdev)
265 struct input_dev *input; 310 struct input_dev *input;
266 int error; 311 int error;
267 int irq; 312 int irq;
268 int i;
269 313
270 plat = stmpe->pdata->keypad; 314 plat = stmpe->pdata->keypad;
271 if (!plat) 315 if (!plat) {
272 return -ENODEV; 316 plat = stmpe_keypad_of_probe(&pdev->dev);
317 if (IS_ERR(plat))
318 return PTR_ERR(plat);
319 }
273 320
274 irq = platform_get_irq(pdev, 0); 321 irq = platform_get_irq(pdev, 0);
275 if (irq < 0) 322 if (irq < 0)
@@ -299,12 +346,7 @@ static int stmpe_keypad_probe(struct platform_device *pdev)
299 if (!plat->no_autorepeat) 346 if (!plat->no_autorepeat)
300 __set_bit(EV_REP, input->evbit); 347 __set_bit(EV_REP, input->evbit);
301 348
302 for (i = 0; i < plat->keymap_data->keymap_size; i++) { 349 stmpe_keypad_fill_used_pins(keypad);
303 unsigned int key = plat->keymap_data->keymap[i];
304
305 keypad->cols |= 1 << KEY_COL(key);
306 keypad->rows |= 1 << KEY_ROW(key);
307 }
308 350
309 keypad->stmpe = stmpe; 351 keypad->stmpe = stmpe;
310 keypad->plat = plat; 352 keypad->plat = plat;