blob: fae97509d4f703ce72454972816d763d4faabb67 [file] [log] [blame]
Anson Huangf753d462019-01-15 10:34:04 +08001/*
Jacky Baid746daa12019-11-25 13:19:37 +08002 * Copyright (c) 2015-2022, ARM Limited and Contributors. All rights reserved.
Anson Huangf753d462019-01-15 10:34:04 +08003 *
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
14static int32_t imx_sip_setup(void)
15{
16 return 0;
17}
18
19static 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) {
Peng Fandd860d12020-07-10 14:18:01 +080029 case IMX_SIP_AARCH32:
30 SMC_RET1(handle, imx_kernel_entry_handler(smc_fid, x1, x2, x3, x4));
31 break;
Leonard Crestez55119082019-05-10 13:07:41 +030032#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#endif
Jacky Baid746daa12019-11-25 13:19:37 +080037#if defined(PLAT_imx8mm) || defined(PLAT_imx8mn) || defined(PLAT_imx8mp)
38 case IMX_SIP_DDR_DVFS:
39 return dram_dvfs_handler(smc_fid, handle, x1, x2, x3);
Jacky Bai31f02322019-12-11 16:26:59 +080040 case IMX_SIP_GPC:
41 SMC_RET1(handle, imx_gpc_handler(smc_fid, x1, x2, x3));
42 break;
Jacky Baid746daa12019-11-25 13:19:37 +080043#endif
Leonard Crestezd62c1612019-05-20 11:28:50 +030044#if (defined(PLAT_imx8qm) || defined(PLAT_imx8qx))
Anson Huangf753d462019-01-15 10:34:04 +080045 case IMX_SIP_SRTC:
46 return imx_srtc_handler(smc_fid, handle, x1, x2, x3, x4);
Anson Huang922c45f2019-01-15 10:56:36 +080047 case IMX_SIP_CPUFREQ:
48 SMC_RET1(handle, imx_cpufreq_handler(smc_fid, x1, x2, x3));
49 break;
Anson Huange1d418c2019-01-18 10:01:50 +080050 case IMX_SIP_WAKEUP_SRC:
51 SMC_RET1(handle, imx_wakeup_src_handler(smc_fid, x1, x2, x3));
Anson Huang6e47de52019-01-18 10:27:48 +080052 case IMX_SIP_OTP_READ:
53 case IMX_SIP_OTP_WRITE:
54 return imx_otp_handler(smc_fid, handle, x1, x2);
Anson Huange708bfb2019-01-18 10:35:54 +080055 case IMX_SIP_MISC_SET_TEMP:
56 SMC_RET1(handle, imx_misc_set_temp_handler(smc_fid, x1, x2, x3, x4));
Anson Huangf753d462019-01-15 10:34:04 +080057#endif
Igor Opaniukf2de6812021-03-10 13:42:55 +020058#if defined(PLAT_imx8mm) || defined(PLAT_imx8mq)
59 case IMX_SIP_SRC:
60 SMC_RET1(handle, imx_src_handler(smc_fid, x1, x2, x3, handle));
61 break;
62#endif
Anson Huang971392d2019-01-18 10:43:59 +080063 case IMX_SIP_BUILDINFO:
64 SMC_RET1(handle, imx_buildinfo_handler(smc_fid, x1, x2, x3, x4));
Anson Huangf753d462019-01-15 10:34:04 +080065 default:
66 WARN("Unimplemented i.MX SiP Service Call: 0x%x\n", smc_fid);
67 SMC_RET1(handle, SMC_UNK);
68 break;
69 }
70}
71
72/* Define a runtime service descriptor for fast SMC calls */
73DECLARE_RT_SVC(
74 imx_sip_svc,
75 OEN_SIP_START,
76 OEN_SIP_END,
77 SMC_TYPE_FAST,
78 imx_sip_setup,
79 imx_sip_handler
80);