Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+91 -9
+39
Documentation/devicetree/bindings/input/stmpe-keypad.txt
··· 1 + * STMPE Keypad 2 + 3 + Required properties: 4 + - compatible : "st,stmpe-keypad" 5 + - linux,keymap : See ./matrix-keymap.txt 6 + 7 + Optional properties: 8 + - debounce-interval : Debouncing interval time in milliseconds 9 + - st,scan-count : Scanning cycles elapsed before key data is updated 10 + - st,no-autorepeat : If specified device will not autorepeat 11 + 12 + Example: 13 + 14 + stmpe_keypad { 15 + compatible = "st,stmpe-keypad"; 16 + 17 + debounce-interval = <64>; 18 + st,scan-count = <8>; 19 + st,no-autorepeat; 20 + 21 + linux,keymap = <0x205006b 22 + 0x4010074 23 + 0x3050072 24 + 0x1030004 25 + 0x502006a 26 + 0x500000a 27 + 0x5008b 28 + 0x706001c 29 + 0x405000b 30 + 0x6070003 31 + 0x3040067 32 + 0x303006c 33 + 0x60400e7 34 + 0x602009e 35 + 0x4020073 36 + 0x5050002 37 + 0x4030069 38 + 0x3020008>; 39 + };
+51 -9
drivers/input/keyboard/stmpe-keypad.c
··· 257 257 (plat->debounce_ms << 1)); 258 258 } 259 259 260 + static 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 277 + static const struct stmpe_keypad_platform_data * 278 + stmpe_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 298 + static inline const struct stmpe_keypad_platform_data * 299 + stmpe_keypad_of_probe(struct device *dev) 300 + { 301 + return ERR_PTR(-EINVAL); 302 + } 303 + #endif 304 + 260 305 static int stmpe_keypad_probe(struct platform_device *pdev) 261 306 { 262 307 struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); ··· 310 265 struct input_dev *input; 311 266 int error; 312 267 int irq; 313 - int i; 314 268 315 269 plat = stmpe->pdata->keypad; 316 - if (!plat) 317 - return -ENODEV; 270 + if (!plat) { 271 + plat = stmpe_keypad_of_probe(&pdev->dev); 272 + if (IS_ERR(plat)) 273 + return PTR_ERR(plat); 274 + } 318 275 319 276 irq = platform_get_irq(pdev, 0); 320 277 if (irq < 0) ··· 346 299 if (!plat->no_autorepeat) 347 300 __set_bit(EV_REP, input->evbit); 348 301 349 - for (i = 0; i < plat->keymap_data->keymap_size; i++) { 350 - unsigned int key = plat->keymap_data->keymap[i]; 351 - 352 - keypad->cols |= 1 << KEY_COL(key); 353 - keypad->rows |= 1 << KEY_ROW(key); 354 - } 302 + stmpe_keypad_fill_used_pins(keypad); 355 303 356 304 keypad->stmpe = stmpe; 357 305 keypad->plat = plat;
+1
drivers/mfd/stmpe.c
··· 324 324 325 325 static struct mfd_cell stmpe_keypad_cell = { 326 326 .name = "stmpe-keypad", 327 + .of_compatible = "st,stmpe-keypad", 327 328 .resources = stmpe_keypad_resources, 328 329 .num_resources = ARRAY_SIZE(stmpe_keypad_resources), 329 330 };