[RFC 6/6] test: dm: add SCMI pinctrl test
AKASHI Takahiro
takahiro.akashi at linaro.org
Wed Sep 6 04:40:11 CEST 2023
In this test, SCMI-based pinmux feature is exercised.
Signed-off-by: AKASHI Takahiro <takahiro.akashi at linaro.org>
---
test/dm/scmi.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/test/dm/scmi.c b/test/dm/scmi.c
index 423b6ef70b29..ca5a2e9c781e 100644
--- a/test/dm/scmi.c
+++ b/test/dm/scmi.c
@@ -21,6 +21,7 @@
#include <scmi_protocols.h>
#include <asm/scmi_test.h>
#include <dm/device-internal.h>
+#include <dm/pinctrl.h>
#include <dm/test.h>
#include <linux/kconfig.h>
#include <power/regulator.h>
@@ -395,3 +396,64 @@ static int dm_test_scmi_voltage_domains(struct unit_test_state *uts)
return release_sandbox_scmi_test_devices(uts, dev);
}
DM_TEST(dm_test_scmi_voltage_domains, UT_TESTF_SCAN_FDT);
+
+/*
+ * This part is derived from test/dm/pinmux.c, So
+ *
+ * Copyright (C) 2020 Sean Anderson <seanga2 at gmail.com>
+ */
+
+static char buf[64];
+#define test_muxing(selector, expected) do { \
+ ut_assertok(pinctrl_get_pin_muxing(dev, selector, buf, sizeof(buf))); \
+ ut_asserteq_str(expected, (char *)&buf); \
+} while (0)
+
+#define test_name(selector, expected) do { \
+ ut_assertok(pinctrl_get_pin_name(dev, selector, buf, sizeof(buf))); \
+ ut_asserteq_str(expected, (char *)&buf); \
+} while (0)
+
+static int dm_test_scmi_pinmux(struct unit_test_state *uts)
+{
+ struct udevice *dev;
+
+ ut_assertok(uclass_get_device_by_name(UCLASS_PINCTRL, "protocol at 19",
+ &dev));
+ ut_assertok(pinctrl_select_state(dev, "default"));
+ test_muxing(0, "<unknown>");
+ test_muxing(1, "<unknown>");
+ test_muxing(2, "I2S.");
+ test_muxing(3, "I2S.");
+ test_muxing(4, "I2S.");
+ test_muxing(5, "GPIO bias-pull-up.");
+ test_muxing(6, "GPIO drive-open-drain output-mode output-value.");
+ test_muxing(7, "GPIO bias-pull-down input-mode.");
+ test_muxing(8, "GPIO bias-disable.");
+
+ ut_assertok(pinctrl_select_state(dev, "alternate"));
+ test_muxing(0, "I2C drive-open-drain.");
+ test_muxing(1, "I2C drive-open-drain.");
+ test_muxing(2, "SPI.");
+ test_muxing(3, "SPI.");
+ test_muxing(4, "SPI.");
+ test_muxing(5, "CS bias-pull-up.");
+ test_muxing(6, "CS drive-open-drain output-mode output-value.");
+ test_muxing(7, "GPIO bias-pull-down input-mode.");
+ test_muxing(8, "GPIO bias-disable.");
+
+ ut_assertok(pinctrl_select_state(dev, "0"));
+ test_muxing(0, "I2C drive-open-drain.");
+ test_muxing(1, "I2C drive-open-drain.");
+ test_muxing(2, "I2S.");
+ test_muxing(3, "I2S.");
+ test_muxing(4, "I2S.");
+ test_muxing(5, "GPIO bias-pull-up.");
+ test_muxing(6, "GPIO drive-open-drain output-mode output-value.");
+ test_muxing(7, "GPIO bias-pull-down input-mode.");
+ test_muxing(8, "GPIO bias-disable.");
+
+ return 0;
+}
+
+DM_TEST(dm_test_scmi_pinmux, UT_TESTF_SCAN_FDT);
--
2.34.1
More information about the U-Boot
mailing list