d8c1e71f127a8cc15a2791a316eeda6ef2b7119f
[pandora-u-boot.git] / test / dm / scmi.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (C) 2020, Linaro Limited
4  *
5  * Tests scmi_agent uclass and the SCMI drivers implemented in other
6  * uclass devices probe when a SCMI server exposes resources.
7  *
8  * Note in test.dts the protocol@10 node in agent 1. Protocol 0x10 is not
9  * implemented in U-Boot SCMI components but the implementation is exepected
10  * to not complain on unknown protocol IDs, as long as it is not used. Note
11  * in test.dts tests that SCMI drivers probing does not fail for such an
12  * unknown SCMI protocol ID.
13  */
14
15 #include <common.h>
16 #include <dm.h>
17 #include <asm/scmi_test.h>
18 #include <dm/device-internal.h>
19 #include <dm/test.h>
20 #include <test/ut.h>
21
22 /*
23  * Test SCMI states when loading and releasing resources
24  * related to SCMI drivers.
25  */
26 static int dm_test_scmi_sandbox_agent(struct unit_test_state *uts)
27 {
28         struct sandbox_scmi_service *scmi_ctx = sandbox_scmi_service_ctx();
29
30         ut_assertnonnull(scmi_ctx);
31         ut_asserteq(2, scmi_ctx->agent_count);
32         ut_assertnull(scmi_ctx->agent[0]);
33         ut_assertnull(scmi_ctx->agent[1]);
34
35         return 0;
36 }
37
38 DM_TEST(dm_test_scmi_sandbox_agent, UT_TESTF_SCAN_FDT);