blob: b6b8ff8657a70c736ee3f46ee7e1258d3a552b01 [file] [log] [blame]
Anson Huangf753d462019-01-15 10:34:04 +08001/*
Jacky Bai4d93d1d2020-07-02 14:39:58 +08002 * Copyright (c) 2015-2024, 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>
Jacky Bai4d93d1d2020-07-02 14:39:58 +08008
Anson Huangf753d462019-01-15 10:34:04 +08009#include <common/debug.h>
10#include <common/runtime_svc.h>
Jacky Bai4d93d1d2020-07-02 14:39:58 +080011#include <drivers/scmi-msg.h>
Anson Huangf753d462019-01-15 10:34:04 +080012#include <lib/pmf/pmf.h>
13#include <tools_share/uuid.h>
Jacky Bai4d93d1d2020-07-02 14:39:58 +080014
Anson Huangf753d462019-01-15 10:34:04 +080015#include <imx_sip_svc.h>
16
17static int32_t imx_sip_setup(void)
18{
19 return 0;
20}
21
22static uintptr_t imx_sip_handler(unsigned int smc_fid,
23 u_register_t x1,
24 u_register_t x2,
25 u_register_t x3,
26 u_register_t x4,
27 void *cookie,
28 void *handle,
29 u_register_t flags)
30{
31 switch (smc_fid) {
Peng Fandd860d12020-07-10 14:18:01 +080032 case IMX_SIP_AARCH32:
33 SMC_RET1(handle, imx_kernel_entry_handler(smc_fid, x1, x2, x3, x4));
34 break;
Jacky Bai4d93d1d2020-07-02 14:39:58 +080035#if defined(PLAT_imx8ulp)
36 case IMX_SIP_SCMI:
37 scmi_smt_fastcall_smc_entry(0);
38 SMC_RET1(handle, 0);
39 break;
Jacky Bai7ec94512023-09-21 14:01:37 +080040 case IMX_SIP_HIFI_XRDC:
41 SMC_RET1(handle, imx_hifi_xrdc(smc_fid));
42 break;
Jacky Bai4d93d1d2020-07-02 14:39:58 +080043#endif
Leonard Crestez55119082019-05-10 13:07:41 +030044#if defined(PLAT_imx8mq)
45 case IMX_SIP_GET_SOC_INFO:
46 SMC_RET1(handle, imx_soc_info_handler(smc_fid, x1, x2, x3));
47 break;
Jacky Baia9407992020-01-08 16:56:01 +080048 case IMX_SIP_GPC:
49 SMC_RET1(handle, imx_gpc_handler(smc_fid, x1, x2, x3));
50 break;
Jacky Baia51b11a2020-01-14 14:19:05 +080051 case IMX_SIP_DDR_DVFS:
52 return dram_dvfs_handler(smc_fid, handle, x1, x2, x3);
Leonard Crestez55119082019-05-10 13:07:41 +030053#endif
Jacky Baid746daa2019-11-25 13:19:37 +080054#if defined(PLAT_imx8mm) || defined(PLAT_imx8mn) || defined(PLAT_imx8mp)
55 case IMX_SIP_DDR_DVFS:
56 return dram_dvfs_handler(smc_fid, handle, x1, x2, x3);
Jacky Bai31f02322019-12-11 16:26:59 +080057 case IMX_SIP_GPC:
58 SMC_RET1(handle, imx_gpc_handler(smc_fid, x1, x2, x3));
59 break;
Jacky Baid746daa2019-11-25 13:19:37 +080060#endif
Leonard Crestezd62c1612019-05-20 11:28:50 +030061#if (defined(PLAT_imx8qm) || defined(PLAT_imx8qx))
Anson Huangf753d462019-01-15 10:34:04 +080062 case IMX_SIP_SRTC:
63 return imx_srtc_handler(smc_fid, handle, x1, x2, x3, x4);
Anson Huang922c45f2019-01-15 10:56:36 +080064 case IMX_SIP_CPUFREQ:
65 SMC_RET1(handle, imx_cpufreq_handler(smc_fid, x1, x2, x3));
66 break;
Anson Huange1d418c2019-01-18 10:01:50 +080067 case IMX_SIP_WAKEUP_SRC:
68 SMC_RET1(handle, imx_wakeup_src_handler(smc_fid, x1, x2, x3));
Anson Huang6e47de52019-01-18 10:27:48 +080069 case IMX_SIP_OTP_READ:
70 case IMX_SIP_OTP_WRITE:
71 return imx_otp_handler(smc_fid, handle, x1, x2);
Anson Huange708bfb2019-01-18 10:35:54 +080072 case IMX_SIP_MISC_SET_TEMP:
73 SMC_RET1(handle, imx_misc_set_temp_handler(smc_fid, x1, x2, x3, x4));
Anson Huangf753d462019-01-15 10:34:04 +080074#endif
Igor Opaniuke1ff4602023-10-31 17:10:35 +010075#if defined(PLAT_imx8mm) || defined(PLAT_imx8mq) || defined(PLAT_imx8mn) || \
76 defined(PLAT_imx8mp)
Igor Opaniukf2de6812021-03-10 13:42:55 +020077 case IMX_SIP_SRC:
78 SMC_RET1(handle, imx_src_handler(smc_fid, x1, x2, x3, handle));
79 break;
80#endif
Andrey Zhizhikin10a4d862022-09-26 22:25:33 +020081#if defined(PLAT_imx8mm) || defined(PLAT_imx8mn) || defined(PLAT_imx8mp)
82 case IMX_SIP_HAB:
83 SMC_RET1(handle, imx_hab_handler(smc_fid, x1, x2, x3, x4));
84 break;
85#endif
Anson Huang971392d2019-01-18 10:43:59 +080086 case IMX_SIP_BUILDINFO:
87 SMC_RET1(handle, imx_buildinfo_handler(smc_fid, x1, x2, x3, x4));
Anson Huangf753d462019-01-15 10:34:04 +080088 default:
89 WARN("Unimplemented i.MX SiP Service Call: 0x%x\n", smc_fid);
90 SMC_RET1(handle, SMC_UNK);
91 break;
92 }
93}
94
95/* Define a runtime service descriptor for fast SMC calls */
96DECLARE_RT_SVC(
97 imx_sip_svc,
98 OEN_SIP_START,
99 OEN_SIP_END,
100 SMC_TYPE_FAST,
101 imx_sip_setup,
102 imx_sip_handler
103);