Skip to content

Commit

Permalink
gpiolib: acpi: Add quirks field to struct acpi_gpio_mapping
Browse files Browse the repository at this point in the history
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 <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Andy Shevchenko authored and Linus Walleij committed Nov 30, 2017
1 parent 5c34b6c commit ce0929d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions drivers/gpio/gpiolib-acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,8 @@ EXPORT_SYMBOL_GPL(devm_acpi_dev_remove_driver_gpios);

static bool acpi_get_driver_gpio_data(struct acpi_device *adev,
const char *name, int index,
struct acpi_reference_args *args)
struct acpi_reference_args *args,
unsigned int *quirks)
{
const struct acpi_gpio_mapping *gm;

Expand All @@ -430,6 +431,8 @@ static bool acpi_get_driver_gpio_data(struct acpi_device *adev,
args->args[1] = par->line_index;
args->args[2] = par->active_low;
args->nargs = 3;

*quirks = gm->quirks;
return true;
}

Expand Down Expand Up @@ -580,6 +583,7 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode,
struct acpi_gpio_lookup *lookup)
{
struct acpi_reference_args args;
unsigned int quirks = 0;
int ret;

memset(&args, 0, sizeof(args));
Expand All @@ -591,7 +595,8 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode,
if (!adev)
return ret;

if (!acpi_get_driver_gpio_data(adev, propname, index, &args))
if (!acpi_get_driver_gpio_data(adev, propname, index, &args,
&quirks))
return ret;
}
/*
Expand All @@ -606,6 +611,7 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode,
lookup->active_low = !!args.args[2];

lookup->info.adev = args.adev;
lookup->info.quirks = quirks;
return 0;
}

Expand Down
2 changes: 2 additions & 0 deletions drivers/gpio/gpiolib.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ struct gpio_device {
* @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo
* @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
*/
struct acpi_gpio_info {
struct acpi_device *adev;
enum gpiod_flags flags;
bool gpioint;
int polarity;
int triggering;
unsigned int quirks;
};

/* gpio suffixes used for ACPI and device tree lookup */
Expand Down
1 change: 1 addition & 0 deletions include/linux/acpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ce0929d

Please sign in to comment.