]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: Add tests for IOMMU uclass
authorMark Kettenis <kettenis@openbsd.org>
Sat, 23 Oct 2021 14:58:02 +0000 (16:58 +0200)
committerTom Rini <trini@konsulko.com>
Sun, 31 Oct 2021 12:46:44 +0000 (08:46 -0400)
Add a set of tests for the IOMMU uclass.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/sandbox/dts/test.dts
configs/sandbox64_defconfig
configs/sandbox_defconfig
configs/sandbox_flattree_defconfig
configs/sandbox_noinst_defconfig
configs/sandbox_spl_defconfig
drivers/iommu/Makefile
drivers/iommu/sandbox_iommu.c [new file with mode: 0644]
test/dm/Makefile
test/dm/iommu.c [new file with mode: 0644]

index e27d106466b4dfca0638be4f9fdb136c2f0dfaa1..8cd688e8d267aeae85568296fb9079f0d3fa2b1f 100644 (file)
                vss-microvolts = <0>;
        };
 
+       iommu: iommu@0 {
+               compatible = "sandbox,iommu";
+               #iommu-cells = <0>;
+       };
+
        irq: irq {
                compatible = "sandbox,irq";
                interrupt-controller;
 
        usb_1: usb@1 {
                compatible = "sandbox,usb";
+               iommus = <&iommu>;
                hub {
                        compatible = "usb-hub";
                        usb,device-class = <9>;
index 838280e14726700e03a1b53172d8ade7584377ab..45828899f23624dad5153b02601772e1c9956bad 100644 (file)
@@ -130,6 +130,7 @@ CONFIG_SPL_I2C_MUX=y
 CONFIG_I2C_ARB_GPIO_CHALLENGE=y
 CONFIG_CROS_EC_KEYB=y
 CONFIG_I8042_KEYB=y
+CONFIG_IOMMU=y
 CONFIG_LED=y
 CONFIG_LED_BLINK=y
 CONFIG_LED_GPIO=y
index d07a7f302e6e5b70ec68801ccda2ee57038044ba..93858574f86fe8b5a0b750a254289d7fe4c9c096 100644 (file)
@@ -168,6 +168,7 @@ CONFIG_SPL_I2C_MUX=y
 CONFIG_I2C_ARB_GPIO_CHALLENGE=y
 CONFIG_CROS_EC_KEYB=y
 CONFIG_I8042_KEYB=y
+CONFIG_IOMMU=y
 CONFIG_LED=y
 CONFIG_LED_BLINK=y
 CONFIG_LED_GPIO=y
index 5980c8610ea8ccfdfc6a8781b281b3d529336d23..edfdac8b029b39d7425123931e8ef93febcfdad2 100644 (file)
@@ -107,6 +107,7 @@ CONFIG_SPL_I2C_MUX=y
 CONFIG_I2C_ARB_GPIO_CHALLENGE=y
 CONFIG_CROS_EC_KEYB=y
 CONFIG_I8042_KEYB=y
+CONFIG_IOMMU=y
 CONFIG_LED=y
 CONFIG_LED_BLINK=y
 CONFIG_LED_GPIO=y
index 238604f5cde15db59e58121f251edccb5d7b44c7..ab378494d29ccb02a076b23223903cd3a36ea9c3 100644 (file)
@@ -128,6 +128,7 @@ CONFIG_I2C_MUX=y
 CONFIG_I2C_ARB_GPIO_CHALLENGE=y
 CONFIG_CROS_EC_KEYB=y
 CONFIG_I8042_KEYB=y
+CONFIG_IOMMU=y
 CONFIG_LED=y
 CONFIG_LED_BLINK=y
 CONFIG_LED_GPIO=y
index b9da8dc8e97dcc7bef1d3d92bc0da2ce0a844caa..9a0a678c032bce63f65729ed448a997ab8ffb87e 100644 (file)
@@ -130,6 +130,7 @@ CONFIG_I2C_MUX=y
 CONFIG_I2C_ARB_GPIO_CHALLENGE=y
 CONFIG_CROS_EC_KEYB=y
 CONFIG_I8042_KEYB=y
+CONFIG_IOMMU=y
 CONFIG_LED=y
 CONFIG_LED_BLINK=y
 CONFIG_LED_GPIO=y
index f1ceb10150709d872f980dbbb0688953da151e05..af1c6bbb7ac54f0c9b263f534110b484c528999c 100644 (file)
@@ -1,3 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 obj-$(CONFIG_IOMMU) += iommu-uclass.o
+
+obj-$(CONFIG_SANDBOX) += sandbox_iommu.o
diff --git a/drivers/iommu/sandbox_iommu.c b/drivers/iommu/sandbox_iommu.c
new file mode 100644 (file)
index 0000000..c8161a4
--- /dev/null
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2021 Mark Kettenis <kettenis@openbsd.org>
+ */
+
+#include <common.h>
+#include <dm.h>
+
+static const struct udevice_id sandbox_iommu_ids[] = {
+       { .compatible = "sandbox,iommu" },
+       { /* sentinel */ }
+};
+
+U_BOOT_DRIVER(sandbox_iommu) = {
+       .name = "sandbox_iommu",
+       .id = UCLASS_IOMMU,
+       .of_match = sandbox_iommu_ids,
+};
index 55162e9499df7793e11f4bddfa796243fd5d6cdf..7de013f636887101248a9f140929686ee93dbb20 100644 (file)
@@ -48,6 +48,7 @@ obj-$(CONFIG_DM_I2C) += i2c.o
 obj-$(CONFIG_SOUND) += i2s.o
 obj-y += irq.o
 obj-$(CONFIG_CLK_K210_SET_RATE) += k210_pll.o
+obj-$(CONFIG_IOMMU) += iommu.o
 obj-$(CONFIG_LED) += led.o
 obj-$(CONFIG_DM_MAILBOX) += mailbox.o
 obj-$(CONFIG_DM_MDIO) += mdio.o
diff --git a/test/dm/iommu.c b/test/dm/iommu.c
new file mode 100644 (file)
index 0000000..94174a7
--- /dev/null
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2021 Mark Kettenis <kettenis@openbsd.org>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/test.h>
+#include <dm/uclass-internal.h>
+#include <iommu.h>
+#include <test/test.h>
+#include <test/ut.h>
+
+static int dm_test_iommu(struct unit_test_state *uts)
+{
+       struct udevice *dev;
+
+       ut_assertok(uclass_find_device(UCLASS_IOMMU, 0, &dev));
+       ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED));
+
+       /* Probing USB probes the IOMMU through the "iommus" property */
+       ut_assertok(uclass_probe_all(UCLASS_USB));
+       ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
+
+       return 0;
+}
+
+DM_TEST(dm_test_iommu, UT_TESTF_SCAN_FDT);