From: Kuan-Wei Chiu <visitorckw@gmail.com>
To: pbonzini@redhat.com, marcandre.lureau@redhat.com,
palmer@dabbelt.com, alistair.francis@wdc.com,
christoph.muellner@vrull.eu, farosas@suse.de, lvivier@redhat.com
Cc: liwei1518@gmail.com, daniel.barboza@oss.qualcomm.com,
zhiwei_liu@linux.alibaba.com, chao.liu.zevorn@gmail.com,
jserv@ccns.ncku.edu.tw, eleanor15x@gmail.com,
marscheng@google.com, qemu-devel@nongnu.org,
qemu-riscv@nongnu.org, Kuan-Wei Chiu <visitorckw@gmail.com>
Subject: [PATCH v2 6/6] tests/qtest: Add qtest for Milk-V Duo board
Date: Thu, 14 May 2026 01:15:28 +0000 [thread overview]
Message-ID: <20260514011528.1263665-7-visitorckw@gmail.com> (raw)
In-Reply-To: <20260514011528.1263665-1-visitorckw@gmail.com>
Add minimal qtest coverage for the Milk-V Duo machine to validate basic
MMIO mapping and register access.
Currently tested:
- Verify DW8250 UART component version and type signatures.
- Test read/write access to CV1800B clock bypass register.
Tested with:
$ meson test -C build -v qemu:qtest-riscv64/milkv-duo-test
[...]
Ok: 1
Fail: 0
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
MAINTAINERS | 1 +
tests/qtest/meson.build | 3 +-
tests/qtest/milkv-duo-test.c | 70 ++++++++++++++++++++++++++++++++++++
3 files changed, 73 insertions(+), 1 deletion(-)
create mode 100644 tests/qtest/milkv-duo-test.c
diff --git a/MAINTAINERS b/MAINTAINERS
index a5649fd31f..8e62809728 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1790,6 +1790,7 @@ F: hw/riscv/milkv_duo.c
F: include/hw/char/dw8250.h
F: include/hw/misc/cv1800b_clk.h
F: include/hw/riscv/cv1800b.h
+F: tests/qtest/milkv-duo-test.c
RX Machines
-----------
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 43f83ffd3a..524340276e 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -290,7 +290,8 @@ qtests_riscv64 = ['riscv-csr-test'] + \
(unpack_edk2_blobs ? ['bios-tables-test'] : []) + \
(config_all_devices.has_key('CONFIG_IOMMU_TESTDEV') and
config_all_devices.has_key('CONFIG_RISCV_IOMMU') ?
- ['iommu-riscv-test'] : [])
+ ['iommu-riscv-test'] : []) + \
+ ['milkv-duo-test']
qos_test_ss = ss.source_set()
qos_test_ss.add(
diff --git a/tests/qtest/milkv-duo-test.c b/tests/qtest/milkv-duo-test.c
new file mode 100644
index 0000000000..06064b8733
--- /dev/null
+++ b/tests/qtest/milkv-duo-test.c
@@ -0,0 +1,70 @@
+/*
+ * QTest for Milk-V Duo Board
+ *
+ * Copyright (c) 2026 Kuan-Wei Chiu <visitorckw@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "libqtest.h"
+
+#define CV1800B_CLK_BASE 0x03002000
+#define CV1800B_CLK_BYPASS 0x030
+#define CV1800B_CLK_BYPASS_RESET 0xFFFFFFFF
+#define TEST_PATTERN_5A 0x5A5A5A5A
+#define TEST_PATTERN_A5 0xA5A5A5A5
+
+#define CV1800B_UART0_BASE 0x04140000
+#define DW_UART_UCV 0xF8
+#define DW_UART_CTR 0xFC
+#define DW_UART_VERSION_3_23A 0x3332332A
+#define DW_UART_TYPE_SIGNATURE 0x44570110
+
+static void test_milkv_duo_uart(void)
+{
+ QTestState *qts;
+ uint32_t component_version;
+ uint32_t component_type;
+
+ qts = qtest_init("-M milkv-duo");
+
+ component_version = qtest_readl(qts, CV1800B_UART0_BASE + DW_UART_UCV);
+ g_assert_cmphex(component_version, ==, DW_UART_VERSION_3_23A);
+
+ component_type = qtest_readl(qts, CV1800B_UART0_BASE + DW_UART_CTR);
+ g_assert_cmphex(component_type, ==, DW_UART_TYPE_SIGNATURE);
+
+ qtest_quit(qts);
+}
+
+static void test_milkv_duo_clk(void)
+{
+ QTestState *qts;
+ uint32_t clk_bypass_val;
+
+ qts = qtest_init("-M milkv-duo");
+
+ clk_bypass_val = qtest_readl(qts, CV1800B_CLK_BASE + CV1800B_CLK_BYPASS);
+ g_assert_cmphex(clk_bypass_val, ==, CV1800B_CLK_BYPASS_RESET);
+
+ qtest_writel(qts, CV1800B_CLK_BASE + CV1800B_CLK_BYPASS, TEST_PATTERN_5A);
+ clk_bypass_val = qtest_readl(qts, CV1800B_CLK_BASE + CV1800B_CLK_BYPASS);
+ g_assert_cmphex(clk_bypass_val, ==, TEST_PATTERN_5A);
+
+ qtest_writel(qts, CV1800B_CLK_BASE + CV1800B_CLK_BYPASS, TEST_PATTERN_A5);
+ clk_bypass_val = qtest_readl(qts, CV1800B_CLK_BASE + CV1800B_CLK_BYPASS);
+ g_assert_cmphex(clk_bypass_val, ==, TEST_PATTERN_A5);
+
+ qtest_quit(qts);
+}
+
+int main(int argc, char **argv)
+{
+ g_test_init(&argc, &argv, NULL);
+
+ qtest_add_func("/riscv/milkv-duo/uart", test_milkv_duo_uart);
+ qtest_add_func("/riscv/milkv-duo/clk", test_milkv_duo_clk);
+
+ return g_test_run();
+}
--
2.54.0.563.g4f69b47b94-goog
prev parent reply other threads:[~2026-05-14 1:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-14 1:15 [PATCH v2 0/6] hw/riscv: Add support for Milk-V Duo board Kuan-Wei Chiu
2026-05-14 1:15 ` [PATCH v2 1/6] target/riscv: Add stubs for T-Head PMU CSRs Kuan-Wei Chiu
2026-05-14 2:48 ` Chao Liu
2026-05-14 18:07 ` Kuan-Wei Chiu
2026-05-14 22:32 ` Chao Liu
2026-05-14 1:15 ` [PATCH v2 2/6] hw/char: Add dw8250 UART Kuan-Wei Chiu
2026-05-14 1:15 ` [PATCH v2 3/6] hw/misc: Add Sophgo CV1800B clock controller Kuan-Wei Chiu
2026-05-14 1:15 ` [PATCH v2 4/6] hw/riscv: Add Sophgo CV1800B SoC support Kuan-Wei Chiu
2026-05-14 1:15 ` [PATCH v2 5/6] hw/riscv: Add Milk-V Duo board support Kuan-Wei Chiu
2026-05-14 1:15 ` Kuan-Wei Chiu [this message]
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=20260514011528.1263665-7-visitorckw@gmail.com \
--to=visitorckw@gmail.com \
--cc=alistair.francis@wdc.com \
--cc=chao.liu.zevorn@gmail.com \
--cc=christoph.muellner@vrull.eu \
--cc=daniel.barboza@oss.qualcomm.com \
--cc=eleanor15x@gmail.com \
--cc=farosas@suse.de \
--cc=jserv@ccns.ncku.edu.tw \
--cc=liwei1518@gmail.com \
--cc=lvivier@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=marscheng@google.com \
--cc=palmer@dabbelt.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=zhiwei_liu@linux.alibaba.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.