Skip to content

Commit c5fca48

Browse files
jwrdegoededtor
authored andcommitted
Input: goodix - add support for controlling the IRQ pin through ACPI methods
Some Apollo Lake (x86, UEFI + ACPI) devices only list the reset GPIO in their _CRS table and the bit-banging of the IRQ line necessary to wake-up the controller from suspend can be done by calling 2 Goodix custom / specific ACPI methods. This commit adds support for controlling the IRQ line in this matter, allowing us to properly suspend the touchscreen controller on such devices. BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1786317 BugLink: nexus511/gpd-ubuntu-packages#10 BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=199207 Reviewed-by: Bastien Nocera <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 67abd9e commit c5fca48

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

drivers/input/touchscreen/goodix.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ enum goodix_irq_pin_access_method {
3535
IRQ_PIN_ACCESS_NONE,
3636
IRQ_PIN_ACCESS_GPIO,
3737
IRQ_PIN_ACCESS_ACPI_GPIO,
38+
IRQ_PIN_ACCESS_ACPI_METHOD,
3839
};
3940

4041
struct goodix_chip_data {
@@ -532,6 +533,9 @@ static int goodix_send_cfg(struct goodix_ts_data *ts,
532533
static int goodix_irq_direction_output(struct goodix_ts_data *ts,
533534
int value)
534535
{
536+
struct device *dev = &ts->client->dev;
537+
acpi_status status;
538+
535539
switch (ts->irq_pin_access_method) {
536540
case IRQ_PIN_ACCESS_NONE:
537541
dev_err(&ts->client->dev,
@@ -546,13 +550,20 @@ static int goodix_irq_direction_output(struct goodix_ts_data *ts,
546550
* as active-low, use output_raw to avoid the value inversion.
547551
*/
548552
return gpiod_direction_output_raw(ts->gpiod_int, value);
553+
case IRQ_PIN_ACCESS_ACPI_METHOD:
554+
status = acpi_execute_simple_method(ACPI_HANDLE(dev),
555+
"INTO", value);
556+
return ACPI_SUCCESS(status) ? 0 : -EIO;
549557
}
550558

551559
return -EINVAL; /* Never reached */
552560
}
553561

554562
static int goodix_irq_direction_input(struct goodix_ts_data *ts)
555563
{
564+
struct device *dev = &ts->client->dev;
565+
acpi_status status;
566+
556567
switch (ts->irq_pin_access_method) {
557568
case IRQ_PIN_ACCESS_NONE:
558569
dev_err(&ts->client->dev,
@@ -562,6 +573,10 @@ static int goodix_irq_direction_input(struct goodix_ts_data *ts)
562573
case IRQ_PIN_ACCESS_GPIO:
563574
case IRQ_PIN_ACCESS_ACPI_GPIO:
564575
return gpiod_direction_input(ts->gpiod_int);
576+
case IRQ_PIN_ACCESS_ACPI_METHOD:
577+
status = acpi_evaluate_object(ACPI_HANDLE(dev), "INTI",
578+
NULL, NULL);
579+
return ACPI_SUCCESS(status) ? 0 : -EIO;
565580
}
566581

567582
return -EINVAL; /* Never reached */
@@ -656,6 +671,11 @@ static const struct acpi_gpio_mapping acpi_goodix_int_last_gpios[] = {
656671
{ },
657672
};
658673

674+
static const struct acpi_gpio_mapping acpi_goodix_reset_only_gpios[] = {
675+
{ GOODIX_GPIO_RST_NAME "-gpios", &first_gpio, 1 },
676+
{ },
677+
};
678+
659679
static int goodix_resource(struct acpi_resource *ares, void *data)
660680
{
661681
struct goodix_ts_data *ts = data;
@@ -713,6 +733,12 @@ static int goodix_add_acpi_gpio_mappings(struct goodix_ts_data *ts)
713733
} else if (ts->gpio_count == 2 && ts->gpio_int_idx == 1) {
714734
ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_GPIO;
715735
gpio_mapping = acpi_goodix_int_last_gpios;
736+
} else if (ts->gpio_count == 1 && ts->gpio_int_idx == -1 &&
737+
acpi_has_method(ACPI_HANDLE(dev), "INTI") &&
738+
acpi_has_method(ACPI_HANDLE(dev), "INTO")) {
739+
dev_info(dev, "Using ACPI INTI and INTO methods for IRQ pin access\n");
740+
ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_METHOD;
741+
gpio_mapping = acpi_goodix_reset_only_gpios;
716742
} else if (is_byt() && ts->gpio_count == 2 && ts->gpio_int_idx == -1) {
717743
dev_info(dev, "No ACPI GpioInt resource, assuming that the GPIO order is reset, int\n");
718744
ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_GPIO;
@@ -809,6 +835,10 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)
809835
if (!ts->gpiod_int || !ts->gpiod_rst)
810836
ts->irq_pin_access_method = IRQ_PIN_ACCESS_NONE;
811837
break;
838+
case IRQ_PIN_ACCESS_ACPI_METHOD:
839+
if (!ts->gpiod_rst)
840+
ts->irq_pin_access_method = IRQ_PIN_ACCESS_NONE;
841+
break;
812842
default:
813843
if (ts->gpiod_int && ts->gpiod_rst) {
814844
ts->reset_controller_at_probe = true;

0 commit comments

Comments
 (0)