]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: dm: add scmi command test
authorAKASHI Takahiro <takahiro.akashi@linaro.org>
Tue, 14 Nov 2023 02:14:28 +0000 (11:14 +0900)
committerTom Rini <trini@konsulko.com>
Wed, 29 Nov 2023 03:31:03 +0000 (22:31 -0500)
In this test, "scmi" command is tested against different sub-commands.
Please note that scmi command is for debug purpose and is not intended
in production system.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
configs/sandbox_defconfig
test/dm/scmi.c

index bc5bcb2a6237bb1a86ec1e6c1949a5fdfe32b3d2..c550af93b0ca19a776be749d53eec9f9d18d8dd3 100644 (file)
@@ -121,6 +121,7 @@ CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_AES=y
 CONFIG_CMD_TPM=y
 CONFIG_CMD_TPM_TEST=y
+CONFIG_CMD_SCMI=y
 CONFIG_CMD_BTRFS=y
 CONFIG_CMD_CBFS=y
 CONFIG_CMD_CRAMFS=y
index 582485471fff19fc90e001defb4874fca52f8b69..e80667ef72a3226cbc04d5e20677c5f392fc96db 100644 (file)
@@ -19,6 +19,7 @@
 #include <scmi_agent.h>
 #include <scmi_agent-uclass.h>
 #include <scmi_protocols.h>
+#include <vsprintf.h>
 #include <asm/scmi_test.h>
 #include <dm/device-internal.h>
 #include <dm/test.h>
@@ -206,6 +207,86 @@ static int dm_test_scmi_base(struct unit_test_state *uts)
 
 DM_TEST(dm_test_scmi_base, UT_TESTF_SCAN_FDT);
 
+static int dm_test_scmi_cmd(struct unit_test_state *uts)
+{
+       struct udevice *agent_dev;
+       int num_proto = 0;
+       char cmd_out[30];
+
+       if (!CONFIG_IS_ENABLED(CMD_SCMI))
+               return -EAGAIN;
+
+       /* preparation */
+       ut_assertok(uclass_get_device_by_name(UCLASS_SCMI_AGENT, "scmi",
+                                             &agent_dev));
+       ut_assertnonnull(agent_dev);
+
+       /*
+        * Estimate the number of provided protocols.
+        * This estimation is correct as far as a corresponding
+        * protocol support is added to sandbox fake serer.
+        */
+       if (CONFIG_IS_ENABLED(POWER_DOMAIN))
+               num_proto++;
+       if (CONFIG_IS_ENABLED(CLK_SCMI))
+               num_proto++;
+       if (CONFIG_IS_ENABLED(RESET_SCMI))
+               num_proto++;
+       if (CONFIG_IS_ENABLED(DM_REGULATOR_SCMI))
+               num_proto++;
+
+       /* scmi info */
+       ut_assertok(run_command("scmi info", 0));
+
+       ut_assert_nextline("SCMI device: scmi");
+       snprintf(cmd_out, 30, "  protocol version: 0x%x",
+                SCMI_BASE_PROTOCOL_VERSION);
+       ut_assert_nextline(cmd_out);
+       ut_assert_nextline("  # of agents: 2");
+       ut_assert_nextline("      0: platform");
+       ut_assert_nextline("    > 1: OSPM");
+       snprintf(cmd_out, 30, "  # of protocols: %d", num_proto);
+       ut_assert_nextline(cmd_out);
+       if (CONFIG_IS_ENABLED(SCMI_POWER_DOMAIN))
+               ut_assert_nextline("      Power domain management");
+       if (CONFIG_IS_ENABLED(CLK_SCMI))
+               ut_assert_nextline("      Clock management");
+       if (CONFIG_IS_ENABLED(RESET_SCMI))
+               ut_assert_nextline("      Reset domain management");
+       if (CONFIG_IS_ENABLED(DM_REGULATOR_SCMI))
+               ut_assert_nextline("      Voltage domain management");
+       ut_assert_nextline("  vendor: U-Boot");
+       ut_assert_nextline("  sub vendor: Sandbox");
+       ut_assert_nextline("  impl version: 0x1");
+
+       ut_assert_console_end();
+
+       /* scmi perm_dev */
+       ut_assertok(run_command("scmi perm_dev 1 0 1", 0));
+       ut_assert_console_end();
+
+       ut_assert(run_command("scmi perm_dev 1 0 0", 0));
+       ut_assert_nextline("Denying access to device:0 failed (-13)");
+       ut_assert_console_end();
+
+       /* scmi perm_proto */
+       ut_assertok(run_command("scmi perm_proto 1 0 14 1", 0));
+       ut_assert_console_end();
+
+       ut_assert(run_command("scmi perm_proto 1 0 14 0", 0));
+       ut_assert_nextline("Denying access to protocol:0x14 on device:0 failed (-13)");
+       ut_assert_console_end();
+
+       /* scmi reset */
+       ut_assert(run_command("scmi reset 1 1", 0));
+       ut_assert_nextline("Reset failed (-13)");
+       ut_assert_console_end();
+
+       return 0;
+}
+
+DM_TEST(dm_test_scmi_cmd, UT_TESTF_SCAN_FDT);
+
 static int dm_test_scmi_power_domains(struct unit_test_state *uts)
 {
        struct sandbox_scmi_agent *agent;