blob: a816c8073f96e46232fba8623212cc14d3041cde [file] [log] [blame]
Anson Huang025514b2019-01-15 10:34:04 +08001/*
Jacky Bai88a26462020-01-08 16:56:01 +08002 * Copyright (c) 2015-2023, ARM Limited and Contributors. All rights reserved.
Anson Huang025514b2019-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 Fan4a0ac3e2020-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 Crestez72196cb2019-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;
Jacky Bai88a26462020-01-08 16:56:01 +080036 case IMX_SIP_GPC:
37 SMC_RET1(handle, imx_gpc_handler(smc_fid, x1, x2, x3));
38 break;
Leonard Crestez72196cb2019-05-10 13:07:41 +030039#endif
Jacky Bai9c336f62019-11-25 13:19:37 +080040#if defined(PLAT_imx8mm) || defined(PLAT_imx8mn) || defined(PLAT_imx8mp)
41 case IMX_SIP_DDR_DVFS:
42 return dram_dvfs_handler(smc_fid, handle, x1, x2, x3);
Jacky Bai44dea542019-12-11 16:26:59 +080043 case IMX_SIP_GPC:
44 SMC_RET1(handle, imx_gpc_handler(smc_fid, x1, x2, x3));
45 break;
Jacky Bai9c336f62019-11-25 13:19:37 +080046#endif
Leonard Crestezf56afc12019-05-20 11:28:50 +030047#if (defined(PLAT_imx8qm) || defined(PLAT_imx8qx))
Anson Huang025514b2019-01-15 10:34:04 +080048 case IMX_SIP_SRTC:
49 return imx_srtc_handler(smc_fid, handle, x1, x2, x3, x4);
Anson Huangd3996c52019-01-15 10:56:36 +080050 case IMX_SIP_CPUFREQ:
51 SMC_RET1(handle, imx_cpufreq_handler(smc_fid, x1, x2, x3));
52 break;
Anson Huangebdbc252019-01-18 10:01:50 +080053 case IMX_SIP_WAKEUP_SRC:
54 SMC_RET1(handle, imx_wakeup_src_handler(smc_fid, x1, x2, x3));
Anson Huangdbfa45e2019-01-18 10:27:48 +080055 case IMX_SIP_OTP_READ:
56 case IMX_SIP_OTP_WRITE:
57 return imx_otp_handler(smc_fid, handle, x1, x2);
Anson Huang869eebc2019-01-18 10:35:54 +080058 case IMX_SIP_MISC_SET_TEMP:
59 SMC_RET1(handle, imx_misc_set_temp_handler(smc_fid, x1, x2, x3, x4));
Anson Huang025514b2019-01-15 10:34:04 +080060#endif
Igor Opaniuk9ce232f2021-03-10 13:42:55 +020061#if defined(PLAT_imx8mm) || defined(PLAT_imx8mq)
62 case IMX_SIP_SRC:
63 SMC_RET1(handle, imx_src_handler(smc_fid, x1, x2, x3, handle));
64 break;
65#endif
Andrey Zhizhikin720e7b62022-09-26 22:25:33 +020066#if defined(PLAT_imx8mm) || defined(PLAT_imx8mn) || defined(PLAT_imx8mp)
67 case IMX_SIP_HAB:
68 SMC_RET1(handle, imx_hab_handler(smc_fid, x1, x2, x3, x4));
69 break;
70#endif
Anson Huang760f7942019-01-18 10:43:59 +080071 case IMX_SIP_BUILDINFO:
72 SMC_RET1(handle, imx_buildinfo_handler(smc_fid, x1, x2, x3, x4));
Anson Huang025514b2019-01-15 10:34:04 +080073 default:
74 WARN("Unimplemented i.MX SiP Service Call: 0x%x\n", smc_fid);
75 SMC_RET1(handle, SMC_UNK);
76 break;
77 }
78}
79
80/* Define a runtime service descriptor for fast SMC calls */
81DECLARE_RT_SVC(
82 imx_sip_svc,
83 OEN_SIP_START,
84 OEN_SIP_END,
85 SMC_TYPE_FAST,
86 imx_sip_setup,
87 imx_sip_handler
88);