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