Skip to content

Commit d64123a

Browse files
andy-shevgregkh
authored andcommitted
gpiolib: acpi: Add ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER quirk
commit 62d5247 upstream. On some systems the ACPI tables has wrong pin number and instead of having a relative one it provides an absolute one in the global GPIO number space. Add ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER quirk to cope with such cases. Fixes: ba8c90c ("gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2") Depends-on: 0ea6839 ("gpio: dwapb: Convert driver to using the GPIO-lib-based IRQ-chip") Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9144b0c commit d64123a

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎drivers/gpio/gpiolib-acpi.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)
677677
if (!lookup->desc) {
678678
const struct acpi_resource_gpio *agpio = &ares->data.gpio;
679679
bool gpioint = agpio->connection_type == ACPI_RESOURCE_GPIO_TYPE_INT;
680+
struct gpio_desc *desc;
680681
u16 pin_index;
681682

682683
if (lookup->info.quirks & ACPI_GPIO_QUIRK_ONLY_GPIOIO && gpioint)
@@ -689,8 +690,12 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)
689690
if (pin_index >= agpio->pin_table_length)
690691
return 1;
691692

692-
lookup->desc = acpi_get_gpiod(agpio->resource_source.string_ptr,
693+
if (lookup->info.quirks & ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER)
694+
desc = gpio_to_desc(agpio->pin_table[pin_index]);
695+
else
696+
desc = acpi_get_gpiod(agpio->resource_source.string_ptr,
693697
agpio->pin_table[pin_index]);
698+
lookup->desc = desc;
694699
lookup->info.pin_config = agpio->pin_config;
695700
lookup->info.debounce = agpio->debounce_timeout;
696701
lookup->info.gpioint = gpioint;

‎include/linux/gpio/consumer.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,8 @@ struct acpi_gpio_mapping {
674674
* get GpioIo type explicitly, this quirk may be used.
675675
*/
676676
#define ACPI_GPIO_QUIRK_ONLY_GPIOIO BIT(1)
677+
/* Use given pin as an absolute GPIO number in the system */
678+
#define ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER BIT(2)
677679

678680
unsigned int quirks;
679681
};

0 commit comments

Comments
 (0)