@@ -651,6 +651,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)
const struct acpi_resource_gpio *agpio = &ares->data.gpio;
bool gpioint = agpio->connection_type == ACPI_RESOURCE_GPIO_TYPE_INT;
int pin_index;
+ u16 pin;
if (lookup->info.quirks & ACPI_GPIO_QUIRK_ONLY_GPIOIO && gpioint)
lookup->index++;
@@ -662,8 +663,12 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)
if (pin_index >= agpio->pin_table_length)
return 1;
- lookup->desc = acpi_get_gpiod(agpio->resource_source.string_ptr,
- agpio->pin_table[pin_index]);
+ if (lookup->info.quirks & ACPI_GPIO_QUIRK_FORCE_PIN)
+ pin = lookup->info.quirks_data;
+ else
+ pin = agpio->pin_table[pin_index];
+
+ lookup->desc = acpi_get_gpiod(agpio->resource_source.string_ptr, pin);
lookup->info.pin_config = agpio->pin_config;
lookup->info.gpioint = gpioint;
@@ -674,6 +674,12 @@ struct acpi_gpio_mapping {
* get GpioIo type explicitly, this quirk may be used.
*/
#define ACPI_GPIO_QUIRK_ONLY_GPIOIO BIT(1)
+/*
+ * Some ACPI tables may have wrong pin defined. Allow to force the pin
+ * number if quirk is provided. New pin number should be provided via
+ * @quirks_data field.
+ */
+#define ACPI_GPIO_QUIRK_FORCE_PIN BIT(2)
unsigned int quirks;
unsigned long quirks_data;
Some ACPI tables have broken GpioInt() pin number, i.e. Intel Galileo gen 2 board, where it by some reason refers to the absolute one instead of being relative to the controller. In order to work around, introduce a new quirk to force this number. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/gpio/gpiolib-acpi.c | 9 +++++++-- include/linux/gpio/consumer.h | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-)