]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: dm: add protocol-specific channel test
authorAKASHI Takahiro <takahiro.akashi@linaro.org>
Wed, 11 Oct 2023 10:06:59 +0000 (19:06 +0900)
committerTom Rini <trini@konsulko.com>
Fri, 13 Oct 2023 20:59:23 +0000 (16:59 -0400)
Any SCMI protocol may have its own channel.
Test this feature on sandbox as the necessary framework was added
in a prior commit.

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>
arch/sandbox/dts/test.dts
test/dm/scmi.c

index 6abce9e3963025c2b9058ea5a0a3c473482d67c4..50c8715f769cba18cb9b754c7bca8b8eccca3495 100644 (file)
                        clk_scmi: protocol@14 {
                                reg = <0x14>;
                                #clock-cells = <1>;
+                               linaro,sandbox-channel-id = <0x14>;
                        };
 
                        reset_scmi: protocol@16 {
index d87e2731ce42a89b25c190e93ff295254726f0f0..8db3ad32f85ee4683f368d3e81333ab61e97e4a2 100644 (file)
@@ -16,6 +16,8 @@
 #include <clk.h>
 #include <dm.h>
 #include <reset.h>
+#include <scmi_agent.h>
+#include <scmi_protocols.h>
 #include <asm/scmi_test.h>
 #include <dm/device-internal.h>
 #include <dm/test.h>
@@ -109,7 +111,7 @@ static int dm_test_scmi_clocks(struct unit_test_state *uts)
        struct sandbox_scmi_devices *scmi_devices;
        struct sandbox_scmi_service *scmi_ctx;
        struct sandbox_scmi_agent *agent;
-       struct udevice *dev;
+       struct udevice *agent_dev, *clock_dev, *dev;
        int ret_dev;
        int ret;
 
@@ -124,6 +126,14 @@ static int dm_test_scmi_clocks(struct unit_test_state *uts)
        agent = scmi_ctx->agent;
        ut_assertnonnull(agent);
 
+       /* Sandbox SCMI clock protocol has its own channel */
+       ut_assertok(uclass_get_device_by_name(UCLASS_SCMI_AGENT, "scmi",
+                                             &agent_dev));
+       ut_assertnonnull(agent_dev);
+       clock_dev = scmi_get_protocol(agent_dev, SCMI_PROTOCOL_ID_CLOCK);
+       ut_assertnonnull(clock_dev);
+       ut_asserteq(0x14, sandbox_scmi_channel_id(clock_dev));
+
        /* Test SCMI clocks rate manipulation */
        ut_asserteq(333, agent->clk[0].rate);
        ut_asserteq(200, agent->clk[1].rate);
@@ -172,7 +182,7 @@ static int dm_test_scmi_resets(struct unit_test_state *uts)
        struct sandbox_scmi_devices *scmi_devices;
        struct sandbox_scmi_service *scmi_ctx;
        struct sandbox_scmi_agent *agent;
-       struct udevice *dev = NULL;
+       struct udevice *agent_dev, *reset_dev, *dev = NULL;
        int ret;
 
        ret = load_sandbox_scmi_test_devices(uts, &dev);
@@ -186,6 +196,14 @@ static int dm_test_scmi_resets(struct unit_test_state *uts)
        agent = scmi_ctx->agent;
        ut_assertnonnull(agent);
 
+       /* Sandbox SCMI reset protocol doesn't have its own channel */
+       ut_assertok(uclass_get_device_by_name(UCLASS_SCMI_AGENT, "scmi",
+                                             &agent_dev));
+       ut_assertnonnull(agent_dev);
+       reset_dev = scmi_get_protocol(agent_dev, SCMI_PROTOCOL_ID_RESET_DOMAIN);
+       ut_assertnonnull(reset_dev);
+       ut_asserteq(0x0, sandbox_scmi_channel_id(reset_dev));
+
        /* Test SCMI resect controller manipulation */
        ut_assert(!agent->reset[0].asserted);