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