xref: /rk3399_ARM-atf/plat/st/stm32mp1/services/stm32mp1_svc_setup.c (revision 52e486f6a6192bd18d36cdcbc35c59092eefc810)
1 /*
2  * Copyright (c) 2014-2024, STMicroelectronics - All Rights Reserved
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <stdbool.h>
8 #include <stdint.h>
9 
10 #include <common/debug.h>
11 #include <common/runtime_svc.h>
12 #include <drivers/scmi-msg.h>
13 #include <lib/psci/psci.h>
14 #include <tools_share/uuid.h>
15 
16 #include <stm32mp1_smc.h>
17 #include <stm32mp_svc_setup.h>
18 
19 #include "bsec_svc.h"
20 
21 /*
22  * Platform Standard Service SMC handler. This handler will dispatch
23  * calls to features handlers.
24  */
25 void plat_svc_smc_handler(uint32_t smc_fid, u_register_t x1,
26 			  u_register_t x2, u_register_t x3,
27 			  u_register_t x4, uint32_t *ret1,
28 			  uint32_t *ret2, bool *ret2_enabled,
29 			  u_register_t flags)
30 {
31 	switch (smc_fid) {
32 	case STM32_SIP_SVC_CALL_COUNT:
33 		*ret1 = STM32_COMMON_SIP_NUM_CALLS;
34 		break;
35 	case STM32_SMC_BSEC:
36 		*ret1 = bsec_main(x1, x2, x3, ret2);
37 		*ret2_enabled = true;
38 		break;
39 
40 	case STM32_SIP_SMC_SCMI_AGENT0:
41 		scmi_smt_fastcall_smc_entry(0);
42 		break;
43 	case STM32_SIP_SMC_SCMI_AGENT1:
44 		scmi_smt_fastcall_smc_entry(1);
45 		break;
46 
47 	default:
48 		WARN("Unimplemented STM32MP1 Service Call: 0x%x\n", smc_fid);
49 		*ret1 = STM32_SMC_NOT_SUPPORTED;
50 		break;
51 	}
52 }
53