From: Ricardo Ribalda <ribalda@chromium.org>
To: Mika Westerberg <mika.westerberg@linux.intel.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Ricardo Ribalda <ribalda@chromium.org>
Subject: [PATCH] gpiolib: acpi: Support GpioInt with active_low polarity
Date: Wed, 28 Oct 2020 18:17:57 +0100 [thread overview]
Message-ID: <20201028171757.765866-1-ribalda@chromium.org> (raw)
On the current implementation we only support active_high polarity for
GpioInt.
There can be cases where a GPIO has active_low polarity and it is also a
IRQ source.
De-couple the irq_polarity and active_low fields instead of re-use it.
With this patch we support ACPI devices such as:
Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
{
GpioInt (Edge, ActiveBoth, Exclusive, PullDefault, 0x0000,
"\\_SB.PCI0.GPIO", 0x00, ResourceConsumer, ,
)
{ // Pin list
0x0064
}
})
Name (_DSD, Package (0x02) // _DSD: Device-Specific Data
{
ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") /* Device Properties for _DSD */,
Package (0x01)
{
Package (0x02)
{
"privacy-gpio",
Package (0x04)
{
\_SB.PCI0.XHCI.RHUB.HS07,
Zero,
Zero,
One
}
}
}
})
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
drivers/gpio/gpiolib-acpi.c | 8 ++++----
drivers/gpio/gpiolib-acpi.h | 6 ++++--
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 834a12f3219e..bc33c1056391 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -624,7 +624,7 @@ int acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags,
break;
}
- if (info->polarity == GPIO_ACTIVE_LOW)
+ if (info->active_low)
*lookupflags |= GPIO_ACTIVE_LOW;
return 0;
@@ -665,6 +665,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)
agpio->pin_table[pin_index]);
lookup->info.pin_config = agpio->pin_config;
lookup->info.gpioint = gpioint;
+ lookup->info.active_low = !!lookup->active_low;
/*
* Polarity and triggering are only specified for GpioInt
@@ -675,11 +676,10 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)
*/
if (lookup->info.gpioint) {
lookup->info.flags = GPIOD_IN;
- lookup->info.polarity = agpio->polarity;
+ lookup->info.irq_polarity = agpio->polarity;
lookup->info.triggering = agpio->triggering;
} else {
lookup->info.flags = acpi_gpio_to_gpiod_flags(agpio);
- lookup->info.polarity = lookup->active_low;
}
}
@@ -958,7 +958,7 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
return ret;
irq_flags = acpi_dev_get_irq_type(info.triggering,
- info.polarity);
+ info.irq_polarity);
/* Set type if specified and different than the current one */
if (irq_flags != IRQ_TYPE_NONE &&
diff --git a/drivers/gpio/gpiolib-acpi.h b/drivers/gpio/gpiolib-acpi.h
index 1c6d65cf0629..816a2d7a21ed 100644
--- a/drivers/gpio/gpiolib-acpi.h
+++ b/drivers/gpio/gpiolib-acpi.h
@@ -16,7 +16,8 @@ struct acpi_device;
* @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
+ * @irq_polarity: interrupt polarity as provided by ACPI
+ * @active_low: pin polarity as provided by ACPI
* @triggering: triggering type as provided by ACPI
* @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping
*/
@@ -25,7 +26,8 @@ struct acpi_gpio_info {
enum gpiod_flags flags;
bool gpioint;
int pin_config;
- int polarity;
+ int irq_polarity;
+ bool active_low;
int triggering;
unsigned int quirks;
};
--
2.29.0.rc2.309.g374f81d7ae-goog
next reply other threads:[~2020-10-29 1:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-28 17:17 Ricardo Ribalda [this message]
2020-10-28 18:27 ` [PATCH] gpiolib: acpi: Support GpioInt with active_low polarity Andy Shevchenko
2020-10-29 15:34 ` Ricardo Ribalda
2020-10-29 17:31 ` Andy Shevchenko
2020-10-29 18:08 ` Ricardo Ribalda
2020-10-29 18:14 ` 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=20201028171757.765866-1-ribalda@chromium.org \
--to=ribalda@chromium.org \
--cc=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=linux-kernel@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;
as well as URLs for NNTP newsgroup(s).