From: Rahul Pon <theflyingrahul@gmail.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Len Brown <lenb@kernel.org>, Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>,
linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] ACPI: GED: Support GpioInt event resources
Date: Wed, 30 Sep 2026 16:45:05 +0530 [thread overview]
Message-ID: <20260930111505.1108-1-theflyingrahul@gmail.com> (raw)
The Generic Event Device accepts only Interrupt and ExtendedInterrupt
resources in _CRS. Some ACPI firmware signals GED events through GPIO
controllers instead: the HP OmniBook 5 16-bf1xxx (Snapdragon X2) describes
its lid (LIGE) and embedded-controller event device (ECGE) as ACPI0013 with
GpioInt resources, and both currently fail to probe with "unable to parse
IRQ resource".
Handle GpioInt resources: get the Linux IRQ with acpi_dev_gpio_irq_get(),
which applies the trigger and polarity and returns -EPROBE_DEFER until the
GPIO controller is registered, and evaluate _EVT with the GPIO pin number,
as done for GSIs above 255. GpioIo resources are skipped. On a failed walk,
free the events already requested and propagate the GPIO error (including
-EPROBE_DEFER) instead of -EINVAL.
Tested on the HP OmniBook 5 16-bf1xxx: lid close/open run _EVT and reach
the ACPI button driver and logind.
Assisted-by: LLM
Signed-off-by: Rahul Pon <theflyingrahul@gmail.com>
---
drivers/acpi/evged.c | 46 +++++++++++++++++++++++++++++++++++++++++---
1 file changed, 43 insertions(+), 3 deletions(-)
diff --git a/drivers/acpi/evged.c b/drivers/acpi/evged.c
index 5c35cbc7f6..478172ede7 100644
--- a/drivers/acpi/evged.c
+++ b/drivers/acpi/evged.c
@@ -43,6 +43,8 @@
struct acpi_ged_device {
struct device *dev;
struct list_head event_list;
+ unsigned int gpio_index;
+ int error;
};
struct acpi_ged_event {
@@ -76,7 +78,7 @@ static acpi_status acpi_ged_request_interrupt(struct acpi_resource *ares,
struct device *dev = geddev->dev;
acpi_handle handle = ACPI_HANDLE(dev);
acpi_handle evt_handle;
- struct resource r;
+ struct resource r = {};
struct acpi_resource_irq *p = &ares->data.irq;
struct acpi_resource_extended_irq *pext = &ares->data.extended_irq;
char ev_name[5];
@@ -85,6 +87,33 @@ static acpi_status acpi_ged_request_interrupt(struct acpi_resource *ares,
if (ares->type == ACPI_RESOURCE_TYPE_END_TAG)
return AE_OK;
+ if (ares->type == ACPI_RESOURCE_TYPE_GPIO) {
+ struct acpi_resource_gpio *agpio;
+ int ret;
+
+ /* GpioIo resources are not event sources. */
+ if (!acpi_gpio_get_irq_resource(ares, &agpio))
+ return AE_OK;
+
+ /* The GPIO core applies the GpioInt trigger and polarity. */
+ ret = acpi_dev_gpio_irq_get(ACPI_COMPANION(dev), geddev->gpio_index++);
+ if (ret < 0) {
+ geddev->error = ret;
+ return AE_ERROR;
+ }
+ irq = ret;
+ gsi = agpio->pin_table[0];
+ if (agpio->shareable == ACPI_SHARED)
+ r.flags |= IORESOURCE_IRQ_SHAREABLE;
+
+ /* As for GSIs above 255, GPIO-signaled events use _EVT. */
+ if (ACPI_FAILURE(acpi_get_handle(handle, "_EVT", &evt_handle))) {
+ dev_err(dev, "cannot locate _EVT method\n");
+ return AE_ERROR;
+ }
+ goto request;
+ }
+
if (!acpi_dev_resource_interrupt(ares, 0, &r)) {
dev_err(dev, "unable to parse IRQ resource\n");
return AE_ERROR;
@@ -115,6 +144,7 @@ static acpi_status acpi_ged_request_interrupt(struct acpi_resource *ares,
return AE_ERROR;
}
+request:
event = devm_kzalloc(dev, sizeof(*event), GFP_KERNEL);
if (!event)
return AE_ERROR;
@@ -138,6 +168,8 @@ static acpi_status acpi_ged_request_interrupt(struct acpi_resource *ares,
return AE_OK;
}
+static void acpi_ged_free_events(struct acpi_ged_device *geddev);
+
static int ged_probe(struct platform_device *pdev)
{
struct acpi_ged_device *geddev;
@@ -152,6 +184,10 @@ static int ged_probe(struct platform_device *pdev)
acpi_ret = acpi_walk_resources(ACPI_HANDLE(&pdev->dev), "_CRS",
acpi_ged_request_interrupt, geddev);
if (ACPI_FAILURE(acpi_ret)) {
+ acpi_ged_free_events(geddev);
+ if (geddev->error)
+ return dev_err_probe(&pdev->dev, geddev->error,
+ "unable to get GPIO event IRQ\n");
dev_err(&pdev->dev, "unable to parse the _CRS record\n");
return -EINVAL;
}
@@ -160,9 +196,8 @@ static int ged_probe(struct platform_device *pdev)
return 0;
}
-static void ged_shutdown(struct platform_device *pdev)
+static void acpi_ged_free_events(struct acpi_ged_device *geddev)
{
- struct acpi_ged_device *geddev = platform_get_drvdata(pdev);
struct acpi_ged_event *event, *next;
list_for_each_entry_safe(event, next, &geddev->event_list, node) {
@@ -173,6 +208,11 @@ static void ged_shutdown(struct platform_device *pdev)
}
}
+static void ged_shutdown(struct platform_device *pdev)
+{
+ acpi_ged_free_events(platform_get_drvdata(pdev));
+}
+
static void ged_remove(struct platform_device *pdev)
{
ged_shutdown(pdev);
base-commit: 551c722f40809618230001baccf219193e22fc5a
--
2.53.0
next reply other threads:[~2026-09-30 11:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 11:15 Rahul Pon [this message]
2026-09-30 20:22 ` Linus Walleij
2026-10-01 4:04 ` Mika Westerberg
2026-10-01 4:27 ` Rahul Pon
2026-10-01 4:18 ` Rahul Pon
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=20260930111505.1108-1-theflyingrahul@gmail.com \
--to=theflyingrahul@gmail.com \
--cc=brgl@kernel.org \
--cc=lenb@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
/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
all inboxes | Powered by JetHome®