Anson Huang | f753d46 | 2019-01-15 10:34:04 +0800 | [diff] [blame] | 1 | /* |
Jacky Bai | 4d93d1d | 2020-07-02 14:39:58 +0800 | [diff] [blame] | 2 | * Copyright (c) 2015-2024, ARM Limited and Contributors. All rights reserved. |
Anson Huang | f753d46 | 2019-01-15 10:34:04 +0800 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <stdint.h> |
Jacky Bai | 4d93d1d | 2020-07-02 14:39:58 +0800 | [diff] [blame] | 8 | |
Anson Huang | f753d46 | 2019-01-15 10:34:04 +0800 | [diff] [blame] | 9 | #include <common/debug.h> |
| 10 | #include <common/runtime_svc.h> |
Jacky Bai | 4d93d1d | 2020-07-02 14:39:58 +0800 | [diff] [blame] | 11 | #include <drivers/scmi-msg.h> |
Anson Huang | f753d46 | 2019-01-15 10:34:04 +0800 | [diff] [blame] | 12 | #include <lib/pmf/pmf.h> |
| 13 | #include <tools_share/uuid.h> |
Jacky Bai | 4d93d1d | 2020-07-02 14:39:58 +0800 | [diff] [blame] | 14 | |
Anson Huang | f753d46 | 2019-01-15 10:34:04 +0800 | [diff] [blame] | 15 | #include <imx_sip_svc.h> |
| 16 | |
| 17 | static int32_t imx_sip_setup(void) |
| 18 | { |
| 19 | return 0; |
| 20 | } |
| 21 | |
| 22 | static 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 Fan | dd860d1 | 2020-07-10 14:18:01 +0800 | [diff] [blame] | 32 | case IMX_SIP_AARCH32: |
| 33 | SMC_RET1(handle, imx_kernel_entry_handler(smc_fid, x1, x2, x3, x4)); |
| 34 | break; |
Jacky Bai | 4d93d1d | 2020-07-02 14:39:58 +0800 | [diff] [blame] | 35 | #if defined(PLAT_imx8ulp) |
| 36 | case IMX_SIP_SCMI: |
| 37 | scmi_smt_fastcall_smc_entry(0); |
| 38 | SMC_RET1(handle, 0); |
| 39 | break; |
Jacky Bai | 7ec9451 | 2023-09-21 14:01:37 +0800 | [diff] [blame] | 40 | case IMX_SIP_HIFI_XRDC: |
| 41 | SMC_RET1(handle, imx_hifi_xrdc(smc_fid)); |
| 42 | break; |
Jacky Bai | 9f6e5d9 | 2022-01-25 16:34:58 +0800 | [diff] [blame] | 43 | case IMX_SIP_DDR_DVFS: |
| 44 | return dram_dvfs_handler(smc_fid, handle, x1, x2, x3); |
Jacky Bai | 4d93d1d | 2020-07-02 14:39:58 +0800 | [diff] [blame] | 45 | #endif |
Leonard Crestez | 5511908 | 2019-05-10 13:07:41 +0300 | [diff] [blame] | 46 | #if defined(PLAT_imx8mq) |
| 47 | case IMX_SIP_GET_SOC_INFO: |
| 48 | SMC_RET1(handle, imx_soc_info_handler(smc_fid, x1, x2, x3)); |
| 49 | break; |
Jacky Bai | a940799 | 2020-01-08 16:56:01 +0800 | [diff] [blame] | 50 | case IMX_SIP_GPC: |
| 51 | SMC_RET1(handle, imx_gpc_handler(smc_fid, x1, x2, x3)); |
| 52 | break; |
Jacky Bai | a51b11a | 2020-01-14 14:19:05 +0800 | [diff] [blame] | 53 | case IMX_SIP_DDR_DVFS: |
| 54 | return dram_dvfs_handler(smc_fid, handle, x1, x2, x3); |
Leonard Crestez | 5511908 | 2019-05-10 13:07:41 +0300 | [diff] [blame] | 55 | #endif |
Jacky Bai | d746daa1 | 2019-11-25 13:19:37 +0800 | [diff] [blame] | 56 | #if defined(PLAT_imx8mm) || defined(PLAT_imx8mn) || defined(PLAT_imx8mp) |
| 57 | case IMX_SIP_DDR_DVFS: |
| 58 | return dram_dvfs_handler(smc_fid, handle, x1, x2, x3); |
Jacky Bai | 31f0232 | 2019-12-11 16:26:59 +0800 | [diff] [blame] | 59 | case IMX_SIP_GPC: |
| 60 | SMC_RET1(handle, imx_gpc_handler(smc_fid, x1, x2, x3)); |
| 61 | break; |
Jacky Bai | d746daa1 | 2019-11-25 13:19:37 +0800 | [diff] [blame] | 62 | #endif |
Leonard Crestez | d62c161 | 2019-05-20 11:28:50 +0300 | [diff] [blame] | 63 | #if (defined(PLAT_imx8qm) || defined(PLAT_imx8qx)) |
Anson Huang | f753d46 | 2019-01-15 10:34:04 +0800 | [diff] [blame] | 64 | case IMX_SIP_SRTC: |
| 65 | return imx_srtc_handler(smc_fid, handle, x1, x2, x3, x4); |
Anson Huang | 922c45f | 2019-01-15 10:56:36 +0800 | [diff] [blame] | 66 | case IMX_SIP_CPUFREQ: |
| 67 | SMC_RET1(handle, imx_cpufreq_handler(smc_fid, x1, x2, x3)); |
| 68 | break; |
Anson Huang | e1d418c | 2019-01-18 10:01:50 +0800 | [diff] [blame] | 69 | case IMX_SIP_WAKEUP_SRC: |
| 70 | SMC_RET1(handle, imx_wakeup_src_handler(smc_fid, x1, x2, x3)); |
Anson Huang | 6e47de5 | 2019-01-18 10:27:48 +0800 | [diff] [blame] | 71 | case IMX_SIP_OTP_READ: |
| 72 | case IMX_SIP_OTP_WRITE: |
| 73 | return imx_otp_handler(smc_fid, handle, x1, x2); |
Anson Huang | e708bfb | 2019-01-18 10:35:54 +0800 | [diff] [blame] | 74 | case IMX_SIP_MISC_SET_TEMP: |
| 75 | 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] | 76 | #endif |
Igor Opaniuk | e1ff460 | 2023-10-31 17:10:35 +0100 | [diff] [blame] | 77 | #if defined(PLAT_imx8mm) || defined(PLAT_imx8mq) || defined(PLAT_imx8mn) || \ |
| 78 | defined(PLAT_imx8mp) |
Igor Opaniuk | f2de681 | 2021-03-10 13:42:55 +0200 | [diff] [blame] | 79 | case IMX_SIP_SRC: |
| 80 | SMC_RET1(handle, imx_src_handler(smc_fid, x1, x2, x3, handle)); |
| 81 | break; |
| 82 | #endif |
Andrey Zhizhikin | 10a4d86 | 2022-09-26 22:25:33 +0200 | [diff] [blame] | 83 | #if defined(PLAT_imx8mm) || defined(PLAT_imx8mn) || defined(PLAT_imx8mp) |
| 84 | case IMX_SIP_HAB: |
| 85 | SMC_RET1(handle, imx_hab_handler(smc_fid, x1, x2, x3, x4)); |
| 86 | break; |
| 87 | #endif |
Anson Huang | 971392d | 2019-01-18 10:43:59 +0800 | [diff] [blame] | 88 | case IMX_SIP_BUILDINFO: |
| 89 | SMC_RET1(handle, imx_buildinfo_handler(smc_fid, x1, x2, x3, x4)); |
Anson Huang | f753d46 | 2019-01-15 10:34:04 +0800 | [diff] [blame] | 90 | default: |
| 91 | WARN("Unimplemented i.MX SiP Service Call: 0x%x\n", smc_fid); |
| 92 | SMC_RET1(handle, SMC_UNK); |
| 93 | break; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | /* Define a runtime service descriptor for fast SMC calls */ |
| 98 | DECLARE_RT_SVC( |
| 99 | imx_sip_svc, |
| 100 | OEN_SIP_START, |
| 101 | OEN_SIP_END, |
| 102 | SMC_TYPE_FAST, |
| 103 | imx_sip_setup, |
| 104 | imx_sip_handler |
| 105 | ); |