xref: /rk3399_ARM-atf/plat/imx/common/imx_sip_svc.c (revision c9f05a326fdd320305da007ff59a1d002eff15ee)
1 /*
2  * Copyright (c) 2015-2023, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <stdint.h>
8 #include <common/debug.h>
9 #include <common/runtime_svc.h>
10 #include <lib/pmf/pmf.h>
11 #include <tools_share/uuid.h>
12 #include <imx_sip_svc.h>
13 
14 static int32_t imx_sip_setup(void)
15 {
16 	return 0;
17 }
18 
19 static uintptr_t imx_sip_handler(unsigned int smc_fid,
20 			u_register_t x1,
21 			u_register_t x2,
22 			u_register_t x3,
23 			u_register_t x4,
24 			void *cookie,
25 			void *handle,
26 			u_register_t flags)
27 {
28 	switch (smc_fid) {
29 	case IMX_SIP_AARCH32:
30 		SMC_RET1(handle, imx_kernel_entry_handler(smc_fid, x1, x2, x3, x4));
31 		break;
32 #if defined(PLAT_imx8mq)
33 	case IMX_SIP_GET_SOC_INFO:
34 		SMC_RET1(handle, imx_soc_info_handler(smc_fid, x1, x2, x3));
35 		break;
36 	case IMX_SIP_GPC:
37 		SMC_RET1(handle, imx_gpc_handler(smc_fid, x1, x2, x3));
38 		break;
39 	case IMX_SIP_DDR_DVFS:
40 		return dram_dvfs_handler(smc_fid, handle, x1, x2, x3);
41 #endif
42 #if defined(PLAT_imx8mm) || defined(PLAT_imx8mn) || defined(PLAT_imx8mp)
43 	case IMX_SIP_DDR_DVFS:
44 		return dram_dvfs_handler(smc_fid, handle, x1, x2, x3);
45 	case IMX_SIP_GPC:
46 		SMC_RET1(handle, imx_gpc_handler(smc_fid, x1, x2, x3));
47 		break;
48 #endif
49 #if (defined(PLAT_imx8qm) || defined(PLAT_imx8qx))
50 	case  IMX_SIP_SRTC:
51 		return imx_srtc_handler(smc_fid, handle, x1, x2, x3, x4);
52 	case  IMX_SIP_CPUFREQ:
53 		SMC_RET1(handle, imx_cpufreq_handler(smc_fid, x1, x2, x3));
54 		break;
55 	case  IMX_SIP_WAKEUP_SRC:
56 		SMC_RET1(handle, imx_wakeup_src_handler(smc_fid, x1, x2, x3));
57 	case IMX_SIP_OTP_READ:
58 	case IMX_SIP_OTP_WRITE:
59 		return imx_otp_handler(smc_fid, handle, x1, x2);
60 	case IMX_SIP_MISC_SET_TEMP:
61 		SMC_RET1(handle, imx_misc_set_temp_handler(smc_fid, x1, x2, x3, x4));
62 #endif
63 #if defined(PLAT_imx8mm) || defined(PLAT_imx8mq) || defined(PLAT_imx8mn) || \
64 	defined(PLAT_imx8mp)
65 	case IMX_SIP_SRC:
66 		SMC_RET1(handle, imx_src_handler(smc_fid, x1, x2, x3, handle));
67 		break;
68 #endif
69 #if defined(PLAT_imx8mm) || defined(PLAT_imx8mn) || defined(PLAT_imx8mp)
70 	case IMX_SIP_HAB:
71 		SMC_RET1(handle, imx_hab_handler(smc_fid, x1, x2, x3, x4));
72 		break;
73 #endif
74 	case  IMX_SIP_BUILDINFO:
75 		SMC_RET1(handle, imx_buildinfo_handler(smc_fid, x1, x2, x3, x4));
76 	default:
77 		WARN("Unimplemented i.MX SiP Service Call: 0x%x\n", smc_fid);
78 		SMC_RET1(handle, SMC_UNK);
79 		break;
80 	}
81 }
82 
83 /* Define a runtime service descriptor for fast SMC calls */
84 DECLARE_RT_SVC(
85 		imx_sip_svc,
86 		OEN_SIP_START,
87 		OEN_SIP_END,
88 		SMC_TYPE_FAST,
89 		imx_sip_setup,
90 		imx_sip_handler
91 );
92