From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
linux-gpio@vger.kernel.org,
Mika Westerberg <mika.westerberg@linux.intel.com>,
linux-acpi@vger.kernel.org
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 2/5] gpiolib: acpi: Introduce a quirk to force GpioInt pin
Date: Thu, 21 May 2020 00:19:13 +0300 [thread overview]
Message-ID: <20200520211916.25727-2-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20200520211916.25727-1-andriy.shevchenko@linux.intel.com>
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(-)
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 3aa976f9ad1a..93f3c833f3c7 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -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;
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index 49743a499fda..e6bacebcecb7 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -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;
--
2.26.2
next prev parent reply other threads:[~2020-05-20 21:19 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-20 21:19 [PATCH v1 1/5] gpiolib: acpi: Introduce opaque data field for quirks Andy Shevchenko
2020-05-20 21:19 ` Andy Shevchenko [this message]
2020-05-20 21:19 ` [PATCH v1 3/5] gpio: pca953x: Drop unneeded ACPI_PTR() Andy Shevchenko
2020-05-25 17:58 ` Andy Shevchenko
2020-05-27 13:13 ` Bartosz Golaszewski
2020-05-27 13:38 ` Andy Shevchenko
2020-06-03 12:05 ` Linus Walleij
2020-05-20 21:19 ` [PATCH v1 4/5] gpio: pca935x: Allow IRQ support for driver built as a module Andy Shevchenko
2020-05-25 9:38 ` Bartosz Golaszewski
2020-05-25 10:09 ` Andy Shevchenko
2020-05-20 21:19 ` [PATCH v1 5/5] gpio: pca953x: Override GpioInt() pin for Intel Galileo Gen 2 Andy Shevchenko
2020-05-25 9:20 ` Mika Westerberg
2020-05-25 9:31 ` Andy Shevchenko
2020-05-25 9:45 ` Mika Westerberg
2020-05-25 10:13 ` Andy Shevchenko
2020-05-25 11:05 ` Mika Westerberg
2020-05-25 11:35 ` Andy Shevchenko
2020-05-25 12:01 ` Andy Shevchenko
2020-05-25 12:21 ` Mika Westerberg
2020-05-25 13:01 ` Andy Shevchenko
2020-05-25 13:47 ` Mika Westerberg
2020-05-25 14:34 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200520211916.25727-2-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=bgolaszewski@baylibre.com \
--cc=linus.walleij@linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox