summaryrefslogtreecommitdiff
path: root/test/dm
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-07-07 13:11:43 -0600
committerBin Meng <bmeng.cn@gmail.com>2020-07-17 14:32:24 +0800
commitff715c6f4f7a3181fcc6a45907bb8bf0c8c6f08f (patch)
treefc8fa40ad52e564861ff98e40b38c71b2651347e /test/dm
parent61cc93396a54c1c3fcace092c83def70f3843c2a (diff)
downloadu-boot-ff715c6f4f7a3181fcc6a45907bb8bf0c8c6f08f.tar.gz
acpi: Support generation of interrupt descriptor
Add a function to write an interrupt descriptor to the generated ACPI code. 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 'test/dm')
-rw-r--r--test/dm/acpigen.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/dm/acpigen.c b/test/dm/acpigen.c
index 9ff9b68532..a4adfbfdf8 100644
--- a/test/dm/acpigen.c
+++ b/test/dm/acpigen.c
@@ -8,8 +8,10 @@
#include <common.h>
#include <dm.h>
+#include <irq.h>
#include <malloc.h>
#include <acpi/acpigen.h>
+#include <acpi/acpi_device.h>
#include <asm/unaligned.h>
#include <dm/acpi.h>
#include <dm/test.h>
@@ -70,3 +72,33 @@ static int dm_test_acpi_emit_simple(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_acpi_emit_simple, 0);
+
+/* Test emitting an interrupt descriptor */
+static int dm_test_acpi_interrupt(struct unit_test_state *uts)
+{
+ struct acpi_ctx *ctx;
+ struct udevice *dev;
+ struct irq irq;
+ u8 *ptr;
+
+ ut_assertok(alloc_context(&ctx));
+
+ ptr = acpigen_get_current(ctx);
+
+ ut_assertok(uclass_first_device_err(UCLASS_TEST_FDT, &dev));
+ ut_assertok(irq_get_by_index(dev, 0, &irq));
+
+ /* See a-test, property interrupts-extended in the device tree */
+ ut_asserteq(3, acpi_device_write_interrupt_irq(ctx, &irq));
+ ut_asserteq(9, acpigen_get_current(ctx) - ptr);
+ ut_asserteq(ACPI_DESCRIPTOR_INTERRUPT, ptr[0]);
+ ut_asserteq(6, get_unaligned((u16 *)(ptr + 1)));
+ ut_asserteq(0x19, ptr[3]);
+ ut_asserteq(1, ptr[4]);
+ ut_asserteq(3, get_unaligned((u32 *)(ptr + 5)));
+
+ free_context(&ctx);
+
+ return 0;
+}
+DM_TEST(dm_test_acpi_interrupt, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);