Skip to content

Commit

Permalink
gpiolib: acpi: Respect pin bias setting
Browse files Browse the repository at this point in the history
For now, we don't take into account the pin bias settings supplied by ACPI.
This change is targeting the mentioned gap.

Signed-off-by: Andy Shevchenko <[email protected]>
Acked-by: Hans de Goede <[email protected]>
Reviewed-by: Mika Westerberg <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
  • Loading branch information
andy-shev authored and linusw committed Apr 23, 2019
1 parent 606be34 commit 2d3b6db
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/gpio/gpiolib-acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,17 @@ acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, struct acpi_gpio_info *inf
int acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags,
struct acpi_gpio_info *info)
{
switch (info->pin_config) {
case ACPI_PIN_CONFIG_PULLUP:
*lookupflags |= GPIO_PULL_UP;
break;
case ACPI_PIN_CONFIG_PULLDOWN:
*lookupflags |= GPIO_PULL_DOWN;
break;
default:
break;
}

if (info->polarity == GPIO_ACTIVE_LOW)
*lookupflags |= GPIO_ACTIVE_LOW;

Expand Down Expand Up @@ -567,6 +578,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)

lookup->desc = acpi_get_gpiod(agpio->resource_source.string_ptr,
agpio->pin_table[pin_index]);
lookup->info.pin_config = agpio->pin_config;
lookup->info.gpioint = gpioint;

/*
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpio/gpiolib.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ struct gpio_device {
* @adev: reference to ACPI device which consumes GPIO resource
* @flags: GPIO initialization flags
* @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo
* @pin_config: pin bias as provided by ACPI
* @polarity: interrupt polarity as provided by ACPI
* @triggering: triggering type as provided by ACPI
* @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping
Expand All @@ -82,6 +83,7 @@ struct acpi_gpio_info {
struct acpi_device *adev;
enum gpiod_flags flags;
bool gpioint;
int pin_config;
int polarity;
int triggering;
unsigned int quirks;
Expand Down

0 comments on commit 2d3b6db

Please sign in to comment.