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

Configure Feed

Select the types of activity you want to include in your feed.

Input: adp5588-keys - add support for pure gpio

Keypad specific setup is relaxed if no keypad rows/columns are specified,
enabling a purely gpio operation.

Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Signed-off-by: Utsav Agarwal <utsav.agarwal@analog.com>
Link: https://lore.kernel.org/r/20240826-adp5588_gpio_support-v11-2-3e5ac2bd31b7@analog.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Utsav Agarwal and committed by
Dmitry Torokhov
dc748812 f0da2679

+35 -13
+35 -13
drivers/input/keyboard/adp5588-keys.c
··· 188 188 u32 cols; 189 189 u32 unlock_keys[2]; 190 190 int nkeys_unlock; 191 + bool gpio_only; 191 192 unsigned short keycode[ADP5588_KEYMAPSIZE]; 192 193 unsigned char gpiomap[ADP5588_MAXGPIO]; 193 194 struct gpio_chip gc; ··· 432 431 kpad->gc.label = kpad->client->name; 433 432 kpad->gc.owner = THIS_MODULE; 434 433 435 - girq = &kpad->gc.irq; 436 - gpio_irq_chip_set_chip(girq, &adp5588_irq_chip); 437 - girq->handler = handle_bad_irq; 438 - girq->threaded = true; 434 + if (device_property_present(dev, "interrupt-controller")) { 435 + if (!kpad->client->irq) { 436 + dev_err(dev, "Unable to serve as interrupt controller without interrupt"); 437 + return -EINVAL; 438 + } 439 + 440 + girq = &kpad->gc.irq; 441 + gpio_irq_chip_set_chip(girq, &adp5588_irq_chip); 442 + girq->handler = handle_bad_irq; 443 + girq->threaded = true; 444 + } 439 445 440 446 mutex_init(&kpad->gpio_lock); 441 447 ··· 640 632 struct i2c_client *client = kpad->client; 641 633 int ret, i; 642 634 635 + /* 636 + * Check if the device is to be operated purely in GPIO mode. To do 637 + * so, check that no keypad rows or columns have been specified, 638 + * since all GPINS should be configured as GPIO. 639 + */ 640 + if (!device_property_present(&client->dev, "keypad,num-rows") && 641 + !device_property_present(&client->dev, "keypad,num-columns")) { 642 + /* If purely GPIO, skip keypad setup */ 643 + kpad->gpio_only = true; 644 + return 0; 645 + } 646 + 643 647 ret = matrix_keypad_parse_properties(&client->dev, &kpad->rows, 644 648 &kpad->cols); 645 649 if (ret) ··· 795 775 if (error) 796 776 return error; 797 777 798 - error = devm_request_threaded_irq(&client->dev, client->irq, 799 - adp5588_hard_irq, adp5588_thread_irq, 800 - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 801 - client->dev.driver->name, kpad); 802 - if (error) { 803 - dev_err(&client->dev, "failed to request irq %d: %d\n", 804 - client->irq, error); 805 - return error; 778 + if (client->irq) { 779 + error = devm_request_threaded_irq(&client->dev, client->irq, 780 + adp5588_hard_irq, adp5588_thread_irq, 781 + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 782 + client->dev.driver->name, kpad); 783 + if (error) { 784 + dev_err(&client->dev, "failed to request irq %d: %d\n", 785 + client->irq, error); 786 + return error; 787 + } 806 788 } 807 789 808 - dev_info(&client->dev, "Rev.%d keypad, irq %d\n", revid, client->irq); 790 + dev_info(&client->dev, "Rev.%d controller\n", revid); 809 791 return 0; 810 792 } 811 793