Anson Huang | f753d46 | 2019-01-15 10:34:04 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2019, 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) { |
Peng Fan | dd860d1 | 2020-07-10 14:18:01 +0800 | [diff] [blame] | 29 | case IMX_SIP_AARCH32: |
| 30 | SMC_RET1(handle, imx_kernel_entry_handler(smc_fid, x1, x2, x3, x4)); |
| 31 | break; |
Leonard Crestez | 5511908 | 2019-05-10 13:07:41 +0300 | [diff] [blame] | 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 | #endif |
Leonard Crestez | d62c161 | 2019-05-20 11:28:50 +0300 | [diff] [blame] | 37 | #if (defined(PLAT_imx8qm) || defined(PLAT_imx8qx)) |
Anson Huang | f753d46 | 2019-01-15 10:34:04 +0800 | [diff] [blame] | 38 | case IMX_SIP_SRTC: |
| 39 | return imx_srtc_handler(smc_fid, handle, x1, x2, x3, x4); |
Anson Huang | 922c45f | 2019-01-15 10:56:36 +0800 | [diff] [blame] | 40 | case IMX_SIP_CPUFREQ: |
| 41 | SMC_RET1(handle, imx_cpufreq_handler(smc_fid, x1, x2, x3)); |
| 42 | break; |
Anson Huang | e1d418c | 2019-01-18 10:01:50 +0800 | [diff] [blame] | 43 | case IMX_SIP_WAKEUP_SRC: |
| 44 | SMC_RET1(handle, imx_wakeup_src_handler(smc_fid, x1, x2, x3)); |
Anson Huang | 6e47de5 | 2019-01-18 10:27:48 +0800 | [diff] [blame] | 45 | case IMX_SIP_OTP_READ: |
| 46 | case IMX_SIP_OTP_WRITE: |
| 47 | return imx_otp_handler(smc_fid, handle, x1, x2); |
Anson Huang | e708bfb | 2019-01-18 10:35:54 +0800 | [diff] [blame] | 48 | case IMX_SIP_MISC_SET_TEMP: |
| 49 | SMC_RET1(handle, imx_misc_set_temp_handler(smc_fid, x1, x2, x3, x4)); |
Anson Huang | f753d46 | 2019-01-15 10:34:04 +0800 | [diff] [blame] | 50 | #endif |
Igor Opaniuk | f2de681 | 2021-03-10 13:42:55 +0200 | [diff] [blame] | 51 | #if defined(PLAT_imx8mm) || defined(PLAT_imx8mq) |
| 52 | case IMX_SIP_SRC: |
| 53 | SMC_RET1(handle, imx_src_handler(smc_fid, x1, x2, x3, handle)); |
| 54 | break; |
| 55 | #endif |
Anson Huang | 971392d | 2019-01-18 10:43:59 +0800 | [diff] [blame] | 56 | case IMX_SIP_BUILDINFO: |
| 57 | SMC_RET1(handle, imx_buildinfo_handler(smc_fid, x1, x2, x3, x4)); |
Anson Huang | f753d46 | 2019-01-15 10:34:04 +0800 | [diff] [blame] | 58 | default: |
| 59 | WARN("Unimplemented i.MX SiP Service Call: 0x%x\n", smc_fid); |
| 60 | SMC_RET1(handle, SMC_UNK); |
| 61 | break; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | /* Define a runtime service descriptor for fast SMC calls */ |
| 66 | DECLARE_RT_SVC( |
| 67 | imx_sip_svc, |
| 68 | OEN_SIP_START, |
| 69 | OEN_SIP_END, |
| 70 | SMC_TYPE_FAST, |
| 71 | imx_sip_setup, |
| 72 | imx_sip_handler |
| 73 | ); |