Commit c5fca485 authored by Hans de Goede's avatar Hans de Goede Committed by Dmitry Torokhov

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: https://github.com/nexus511/gpd-ubuntu-packages/issues/10
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=199207Reviewed-by: default avatarBastien Nocera <hadess@hadess.net>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20200307121505.3707-6-hdegoede@redhat.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 67abd9ee
...@@ -35,6 +35,7 @@ enum goodix_irq_pin_access_method { ...@@ -35,6 +35,7 @@ enum goodix_irq_pin_access_method {
IRQ_PIN_ACCESS_NONE, IRQ_PIN_ACCESS_NONE,
IRQ_PIN_ACCESS_GPIO, IRQ_PIN_ACCESS_GPIO,
IRQ_PIN_ACCESS_ACPI_GPIO, IRQ_PIN_ACCESS_ACPI_GPIO,
IRQ_PIN_ACCESS_ACPI_METHOD,
}; };
struct goodix_chip_data { struct goodix_chip_data {
...@@ -532,6 +533,9 @@ static int goodix_send_cfg(struct goodix_ts_data *ts, ...@@ -532,6 +533,9 @@ static int goodix_send_cfg(struct goodix_ts_data *ts,
static int goodix_irq_direction_output(struct goodix_ts_data *ts, static int goodix_irq_direction_output(struct goodix_ts_data *ts,
int value) int value)
{ {
struct device *dev = &ts->client->dev;
acpi_status status;
switch (ts->irq_pin_access_method) { switch (ts->irq_pin_access_method) {
case IRQ_PIN_ACCESS_NONE: case IRQ_PIN_ACCESS_NONE:
dev_err(&ts->client->dev, dev_err(&ts->client->dev,
...@@ -546,6 +550,10 @@ static int goodix_irq_direction_output(struct goodix_ts_data *ts, ...@@ -546,6 +550,10 @@ static int goodix_irq_direction_output(struct goodix_ts_data *ts,
* as active-low, use output_raw to avoid the value inversion. * as active-low, use output_raw to avoid the value inversion.
*/ */
return gpiod_direction_output_raw(ts->gpiod_int, value); return gpiod_direction_output_raw(ts->gpiod_int, value);
case IRQ_PIN_ACCESS_ACPI_METHOD:
status = acpi_execute_simple_method(ACPI_HANDLE(dev),
"INTO", value);
return ACPI_SUCCESS(status) ? 0 : -EIO;
} }
return -EINVAL; /* Never reached */ return -EINVAL; /* Never reached */
...@@ -553,6 +561,9 @@ static int goodix_irq_direction_output(struct goodix_ts_data *ts, ...@@ -553,6 +561,9 @@ static int goodix_irq_direction_output(struct goodix_ts_data *ts,
static int goodix_irq_direction_input(struct goodix_ts_data *ts) static int goodix_irq_direction_input(struct goodix_ts_data *ts)
{ {
struct device *dev = &ts->client->dev;
acpi_status status;
switch (ts->irq_pin_access_method) { switch (ts->irq_pin_access_method) {
case IRQ_PIN_ACCESS_NONE: case IRQ_PIN_ACCESS_NONE:
dev_err(&ts->client->dev, dev_err(&ts->client->dev,
...@@ -562,6 +573,10 @@ static int goodix_irq_direction_input(struct goodix_ts_data *ts) ...@@ -562,6 +573,10 @@ static int goodix_irq_direction_input(struct goodix_ts_data *ts)
case IRQ_PIN_ACCESS_GPIO: case IRQ_PIN_ACCESS_GPIO:
case IRQ_PIN_ACCESS_ACPI_GPIO: case IRQ_PIN_ACCESS_ACPI_GPIO:
return gpiod_direction_input(ts->gpiod_int); return gpiod_direction_input(ts->gpiod_int);
case IRQ_PIN_ACCESS_ACPI_METHOD:
status = acpi_evaluate_object(ACPI_HANDLE(dev), "INTI",
NULL, NULL);
return ACPI_SUCCESS(status) ? 0 : -EIO;
} }
return -EINVAL; /* Never reached */ return -EINVAL; /* Never reached */
...@@ -656,6 +671,11 @@ static const struct acpi_gpio_mapping acpi_goodix_int_last_gpios[] = { ...@@ -656,6 +671,11 @@ static const struct acpi_gpio_mapping acpi_goodix_int_last_gpios[] = {
{ }, { },
}; };
static const struct acpi_gpio_mapping acpi_goodix_reset_only_gpios[] = {
{ GOODIX_GPIO_RST_NAME "-gpios", &first_gpio, 1 },
{ },
};
static int goodix_resource(struct acpi_resource *ares, void *data) static int goodix_resource(struct acpi_resource *ares, void *data)
{ {
struct goodix_ts_data *ts = data; struct goodix_ts_data *ts = data;
...@@ -713,6 +733,12 @@ static int goodix_add_acpi_gpio_mappings(struct goodix_ts_data *ts) ...@@ -713,6 +733,12 @@ static int goodix_add_acpi_gpio_mappings(struct goodix_ts_data *ts)
} else if (ts->gpio_count == 2 && ts->gpio_int_idx == 1) { } else if (ts->gpio_count == 2 && ts->gpio_int_idx == 1) {
ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_GPIO; ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_GPIO;
gpio_mapping = acpi_goodix_int_last_gpios; gpio_mapping = acpi_goodix_int_last_gpios;
} else if (ts->gpio_count == 1 && ts->gpio_int_idx == -1 &&
acpi_has_method(ACPI_HANDLE(dev), "INTI") &&
acpi_has_method(ACPI_HANDLE(dev), "INTO")) {
dev_info(dev, "Using ACPI INTI and INTO methods for IRQ pin access\n");
ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_METHOD;
gpio_mapping = acpi_goodix_reset_only_gpios;
} else if (is_byt() && ts->gpio_count == 2 && ts->gpio_int_idx == -1) { } else if (is_byt() && ts->gpio_count == 2 && ts->gpio_int_idx == -1) {
dev_info(dev, "No ACPI GpioInt resource, assuming that the GPIO order is reset, int\n"); dev_info(dev, "No ACPI GpioInt resource, assuming that the GPIO order is reset, int\n");
ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_GPIO; 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) ...@@ -809,6 +835,10 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)
if (!ts->gpiod_int || !ts->gpiod_rst) if (!ts->gpiod_int || !ts->gpiod_rst)
ts->irq_pin_access_method = IRQ_PIN_ACCESS_NONE; ts->irq_pin_access_method = IRQ_PIN_ACCESS_NONE;
break; break;
case IRQ_PIN_ACCESS_ACPI_METHOD:
if (!ts->gpiod_rst)
ts->irq_pin_access_method = IRQ_PIN_ACCESS_NONE;
break;
default: default:
if (ts->gpiod_int && ts->gpiod_rst) { if (ts->gpiod_int && ts->gpiod_rst) {
ts->reset_controller_at_probe = true; ts->reset_controller_at_probe = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment