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