xref: /rk3399_ARM-atf/plat/xilinx/versal_net/sip_svc_setup.c (revision 1d333e69091f0c71854a224e8cfec08695b7d1f3)
1 /*
2  * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
3  * Copyright (c) 2018-2022, Xilinx, Inc. All rights reserved.
4  * Copyright (C) 2022, Advanced Micro Devices, Inc. All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 /* Top level SMC handler for SiP calls. Dispatch PM calls to PM SMC handler. */
10 
11 #include <common/debug.h>
12 #include <common/runtime_svc.h>
13 #include <tools_share/uuid.h>
14 
15 /* SMC function IDs for SiP Service queries */
16 #define VERSAL_NET_SIP_SVC_CALL_COUNT	(0x8200ff00U)
17 #define VERSAL_NET_SIP_SVC_UID		(0x8200ff01U)
18 #define VERSAL_NET_SIP_SVC_VERSION	(0x8200ff03U)
19 
20 /* SiP Service Calls version numbers */
21 #define SIP_SVC_VERSION_MAJOR		(0U)
22 #define SIP_SVC_VERSION_MINOR		(1U)
23 
24 /* SiP Service UUID */
25 DEFINE_SVC_UUID2(versal_net_sip_uuid,
26 		0x80d4c25a, 0xebaf, 0x11eb, 0x94, 0x68,
27 		0x0b, 0x4e, 0x3b, 0x8f, 0xc3, 0x60);
28 
29 /**
30  * sip_svc_setup() - Setup SiP Service
31  */
32 static int32_t sip_svc_setup(void)
33 {
34 	return 0;
35 }
36 
37 /*
38  * sip_svc_smc_handler() - Top-level SiP Service SMC handler
39  *
40  * Handler for all SiP SMC calls. Handles standard SIP requests
41  * and calls PM SMC handler if the call is for a PM-API function.
42  */
43 static uintptr_t sip_svc_smc_handler(uint32_t smc_fid,
44 			     u_register_t x1,
45 			     u_register_t x2,
46 			     u_register_t x3,
47 			     u_register_t x4,
48 			     void *cookie,
49 			     void *handle,
50 			     u_register_t flags)
51 {
52 	/* Let PM SMC handler deal with PM-related requests */
53 	switch (smc_fid) {
54 	case VERSAL_NET_SIP_SVC_CALL_COUNT:
55 		/* PM functions + default functions */
56 		SMC_RET1(handle, 2);
57 
58 	case VERSAL_NET_SIP_SVC_UID:
59 		SMC_UUID_RET(handle, versal_net_sip_uuid);
60 
61 	case VERSAL_NET_SIP_SVC_VERSION:
62 		SMC_RET2(handle, SIP_SVC_VERSION_MAJOR, SIP_SVC_VERSION_MINOR);
63 
64 	default:
65 		WARN("Unimplemented SiP Service Call: 0x%x\n", smc_fid);
66 		SMC_RET1(handle, SMC_UNK);
67 	}
68 }
69 
70 /* Register PM Service Calls as runtime service */
71 DECLARE_RT_SVC(
72 		sip_svc,
73 		OEN_SIP_START,
74 		OEN_SIP_END,
75 		SMC_TYPE_FAST,
76 		sip_svc_setup,
77 		sip_svc_smc_handler);
78