summaryrefslogtreecommitdiff
path: root/src/arch/x86/include
diff options
context:
space:
mode:
authorDuncan Laurie <dlaurie@chromium.org>2016-05-09 15:38:36 -0700
committerDuncan Laurie <dlaurie@google.com>2016-05-28 03:40:35 +0200
commit6b7c1f605c67f18996c584970a83fc5296c94747 (patch)
treee75e7d6cc96a97d3b4dc18b6c2da22d4ead036aa /src/arch/x86/include
parentb3f5418ec16b1c0cdc913d0afd49bde94c26728e (diff)
acpi_device: Add support for writing ACPI Interrupt descriptors
Add definitions for ACPI device extended interrupts and a method to write an Interrupt() descriptor to the SSDT output stream. Interrupts are often tied together with other resources and some configuration items are shared (though not always compatibly) with other constructs like GPIOs and GPEs. These will get used by device drivers to write _CRS sections for devices into the SSDT. One usage is to include a "struct acpi_irq" inside a config struct for a device so it can be initialized based on settings in devicetree. Example usage: chip.h: struct drivers_i2c_generic_config { struct acpi_irq irq; }; generic.c: void acpi_fill_ssdt_generator(struct device *dev) { struct drivers_i2c_generic_config *config = dev->chip_info; ... acpi_device_write_interrupt(&config->irq); ... } devicetree.cb: device pci 15.0 on chip drivers/i2c/generic register "irq" = "IRQ_EDGE_LOW(GPP_E7_IRQ)" device i2c 10 on end end end SSDT.dsl: Interrupt (ResourceConsumer, Edge, ActiveLow, Exclusive,,,) { 31 } Change-Id: I3b64170cc2ebac178e7a17df479eda7670a42703 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://review.coreboot.org/14933 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/arch/x86/include')
-rw-r--r--src/arch/x86/include/arch/acpi_device.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/arch/x86/include/arch/acpi_device.h b/src/arch/x86/include/arch/acpi_device.h
index 2cad9b5d21..60f7e00606 100644
--- a/src/arch/x86/include/arch/acpi_device.h
+++ b/src/arch/x86/include/arch/acpi_device.h
@@ -16,10 +16,70 @@
#ifndef __ACPI_DEVICE_H
#define __ACPI_DEVICE_H
+#define ACPI_DESCRIPTOR_LARGE (1 << 7)
+#define ACPI_DESCRIPTOR_INTERRUPT (ACPI_DESCRIPTOR_LARGE | 9)
+
struct device;
const char *acpi_device_name(struct device *dev);
const char *acpi_device_path(struct device *dev);
const char *acpi_device_scope(struct device *dev);
const char *acpi_device_path_join(struct device *dev, const char *name);
+/*
+ * ACPI Descriptor for extended Interrupt()
+ */
+
+enum irq_mode {
+ IRQ_EDGE_TRIGGERED,
+ IRQ_LEVEL_TRIGGERED
+};
+
+enum irq_polarity {
+ IRQ_ACTIVE_LOW,
+ IRQ_ACTIVE_HIGH,
+ IRQ_ACTIVE_BOTH
+};
+
+enum irq_shared {
+ IRQ_EXCLUSIVE,
+ IRQ_SHARED
+};
+
+enum irq_wake {
+ IRQ_NO_WAKE,
+ IRQ_WAKE
+};
+
+struct acpi_irq {
+ unsigned int pin;
+ enum irq_mode mode;
+ enum irq_polarity polarity;
+ enum irq_shared shared;
+ enum irq_wake wake;
+};
+
+#define IRQ_EDGE_LOW(x) { \
+ .pin = (x), \
+ .mode = IRQ_EDGE_TRIGGERED, \
+ .polarity = IRQ_ACTIVE_LOW, \
+ .shared = IRQ_EXCLUSIVE, \
+ .wake = IRQ_NO_WAKE }
+
+#define IRQ_EDGE_HIGH(x) { \
+ .pin = (x), \
+ .mode = IRQ_EDGE_TRIGGERED, \
+ .polarity = IRQ_ACTIVE_HIGH, \
+ .shared = IRQ_EXCLUSIVE, \
+ .wake = IRQ_NO_WAKE }
+
+#define IRQ_LEVEL_LOW(x) { \
+ .pin = (x), \
+ .mode = IRQ_LEVEL_TRIGGERED, \
+ .polarity = IRQ_ACTIVE_LOW, \
+ .shared = IRQ_SHARED, \
+ .wake = IRQ_NO_WAKE }
+
+/* Write extended Interrupt() descriptor to SSDT AML output */
+void acpi_device_write_interrupt(const struct acpi_irq *irq);
+
#endif