aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-07-07 13:11:41 -0600
committerBin Meng <bmeng.cn@gmail.com>2020-07-17 14:32:24 +0800
commitf4955137f5f15e615376cf38559414a9b53e3d55 (patch)
tree699167d9e3cc6cae0fae4a0ddeb4b335c05786aa /drivers
parent2715b3623c08bf1ad2dfe6076ad86c24e3138016 (diff)
downloadu-boot-f4955137f5f15e615376cf38559414a9b53e3d55.zip
u-boot-f4955137f5f15e615376cf38559414a9b53e3d55.tar.gz
u-boot-f4955137f5f15e615376cf38559414a9b53e3d55.tar.bz2
irq: Add a method to convert an interrupt to ACPI
When generating ACPI tables we need to convert IRQs in U-Boot to the ACPI structures required by ACPI. This is a SoC-specific conversion and cannot be handled by generic code, so add a new IRQ method to do the conversion. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/misc/irq-uclass.c18
-rw-r--r--drivers/misc/irq_sandbox.c16
2 files changed, 32 insertions, 2 deletions
diff --git a/drivers/misc/irq-uclass.c b/drivers/misc/irq-uclass.c
index ec70866..8727a33 100644
--- a/drivers/misc/irq-uclass.c
+++ b/drivers/misc/irq-uclass.c
@@ -152,8 +152,6 @@ int irq_request(struct udevice *dev, struct irq *irq)
const struct irq_ops *ops;
log_debug("(dev=%p, irq=%p)\n", dev, irq);
- if (!irq)
- return 0;
ops = irq_get_ops(dev);
irq->dev = dev;
@@ -175,6 +173,22 @@ int irq_first_device_type(enum irq_dev_t type, struct udevice **devp)
return 0;
}
+#if CONFIG_IS_ENABLED(ACPIGEN)
+int irq_get_acpi(const struct irq *irq, struct acpi_irq *acpi_irq)
+{
+ struct irq_ops *ops;
+
+ if (!irq_is_valid(irq))
+ return -EINVAL;
+
+ ops = irq_get_ops(irq->dev);
+ if (!ops->get_acpi)
+ return -ENOSYS;
+
+ return ops->get_acpi(irq, acpi_irq);
+}
+#endif
+
UCLASS_DRIVER(irq) = {
.id = UCLASS_IRQ,
.name = "irq",
diff --git a/drivers/misc/irq_sandbox.c b/drivers/misc/irq_sandbox.c
index 54bc47c..a2511b3 100644
--- a/drivers/misc/irq_sandbox.c
+++ b/drivers/misc/irq_sandbox.c
@@ -8,6 +8,7 @@
#include <common.h>
#include <dm.h>
#include <irq.h>
+#include <acpi/acpi_device.h>
#include <asm/test.h>
/**
@@ -73,6 +74,18 @@ static int sandbox_irq_of_xlate(struct irq *irq,
return 0;
}
+static __maybe_unused int sandbox_get_acpi(const struct irq *irq,
+ struct acpi_irq *acpi_irq)
+{
+ acpi_irq->pin = irq->id;
+ acpi_irq->mode = ACPI_IRQ_LEVEL_TRIGGERED;
+ acpi_irq->polarity = ACPI_IRQ_ACTIVE_HIGH;
+ acpi_irq->shared = ACPI_IRQ_SHARED;
+ acpi_irq->wake = ACPI_IRQ_WAKE;
+
+ return 0;
+}
+
static const struct irq_ops sandbox_irq_ops = {
.route_pmc_gpio_gpe = sandbox_route_pmc_gpio_gpe,
.set_polarity = sandbox_set_polarity,
@@ -80,6 +93,9 @@ static const struct irq_ops sandbox_irq_ops = {
.restore_polarities = sandbox_restore_polarities,
.read_and_clear = sandbox_irq_read_and_clear,
.of_xlate = sandbox_irq_of_xlate,
+#if CONFIG_IS_ENABLED(ACPIGEN)
+ .get_acpi = sandbox_get_acpi,
+#endif
};
static const struct udevice_id sandbox_irq_ids[] = {