From ce0929d222f8cb18a66611642dc0661d633ce192 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Fri, 10 Nov 2017 15:40:32 +0200 Subject: gpiolib: acpi: Add quirks field to struct acpi_gpio_mapping Some broken ACPI tables might require quirks in the OS. Introduce quirks field in struct acpi_gpio_mapping. Propagate them to struct acpi_gpio_info for further use. Signed-off-by: Andy Shevchenko Reviewed-by: Mika Westerberg Signed-off-by: Linus Walleij --- include/linux/acpi.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/linux/acpi.h') diff --git a/include/linux/acpi.h b/include/linux/acpi.h index dc1ebfeeb5ec..25fe77fccea0 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -978,6 +978,7 @@ struct acpi_gpio_mapping { const char *name; const struct acpi_gpio_params *data; unsigned int size; + unsigned int quirks; }; #if defined(CONFIG_ACPI) && defined(CONFIG_GPIOLIB) -- cgit v1.2.3 From 1b2ca32ab0b8311da84fe692522266b32ad4315e Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Fri, 10 Nov 2017 15:40:33 +0200 Subject: gpiolib: acpi: Introduce NO_RESTRICTION quirk Allow to relax IoRestriction for certain cases. One of the use case is incorrectly cooked ACPI table where interrupt pin is defined with GpioIo() macro with IoRestrictionOutputOnly. Signed-off-by: Andy Shevchenko Reviewed-by: Mika Westerberg Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib-acpi.c | 13 ++++++++++--- include/linux/acpi.h | 4 ++++ 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'include/linux/acpi.h') diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 711f64b9dd30..430a1475212d 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -496,11 +496,18 @@ int acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, struct acpi_gpio_info *info) { struct device *dev = &info->adev->dev; + enum gpiod_flags old = *flags; int ret; - ret = __acpi_gpio_update_gpiod_flags(flags, info->flags); - if (ret) - dev_dbg(dev, "Override GPIO initialization flags\n"); + ret = __acpi_gpio_update_gpiod_flags(&old, info->flags); + if (info->quirks & ACPI_GPIO_QUIRK_NO_IO_RESTRICTION) { + if (ret) + dev_warn(dev, FW_BUG "GPIO not in correct mode, fixing\n"); + } else { + if (ret) + dev_dbg(dev, "Override GPIO initialization flags\n"); + *flags = old; + } return ret; } diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 25fe77fccea0..06b6eb775115 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -978,6 +978,10 @@ struct acpi_gpio_mapping { const char *name; const struct acpi_gpio_params *data; unsigned int size; + +/* Ignore IoRestriction field */ +#define ACPI_GPIO_QUIRK_NO_IO_RESTRICTION BIT(0) + unsigned int quirks; }; -- cgit v1.2.3