imx_sip_svc.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (c) 2015-2024, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <stdint.h>
  7. #include <common/debug.h>
  8. #include <common/runtime_svc.h>
  9. #include <drivers/scmi-msg.h>
  10. #include <lib/pmf/pmf.h>
  11. #include <tools_share/uuid.h>
  12. #include <imx_sip_svc.h>
  13. static int32_t imx_sip_setup(void)
  14. {
  15. return 0;
  16. }
  17. static uintptr_t imx_sip_handler(unsigned int smc_fid,
  18. u_register_t x1,
  19. u_register_t x2,
  20. u_register_t x3,
  21. u_register_t x4,
  22. void *cookie,
  23. void *handle,
  24. u_register_t flags)
  25. {
  26. switch (smc_fid) {
  27. case IMX_SIP_AARCH32:
  28. SMC_RET1(handle, imx_kernel_entry_handler(smc_fid, x1, x2, x3, x4));
  29. break;
  30. #if defined(PLAT_imx8ulp)
  31. case IMX_SIP_SCMI:
  32. scmi_smt_fastcall_smc_entry(0);
  33. SMC_RET1(handle, 0);
  34. break;
  35. case IMX_SIP_HIFI_XRDC:
  36. SMC_RET1(handle, imx_hifi_xrdc(smc_fid));
  37. break;
  38. case IMX_SIP_DDR_DVFS:
  39. return dram_dvfs_handler(smc_fid, handle, x1, x2, x3);
  40. #endif
  41. #if defined(PLAT_imx8mq)
  42. case IMX_SIP_GET_SOC_INFO:
  43. SMC_RET1(handle, imx_soc_info_handler(smc_fid, x1, x2, x3));
  44. break;
  45. case IMX_SIP_GPC:
  46. SMC_RET1(handle, imx_gpc_handler(smc_fid, x1, x2, x3));
  47. break;
  48. case IMX_SIP_DDR_DVFS:
  49. return dram_dvfs_handler(smc_fid, handle, x1, x2, x3);
  50. #endif
  51. #if defined(PLAT_imx8mm) || defined(PLAT_imx8mn) || defined(PLAT_imx8mp)
  52. case IMX_SIP_DDR_DVFS:
  53. return dram_dvfs_handler(smc_fid, handle, x1, x2, x3);
  54. case IMX_SIP_GPC:
  55. SMC_RET1(handle, imx_gpc_handler(smc_fid, x1, x2, x3));
  56. break;
  57. #endif
  58. #if (defined(PLAT_imx8qm) || defined(PLAT_imx8qx))
  59. case IMX_SIP_SRTC:
  60. return imx_srtc_handler(smc_fid, handle, x1, x2, x3, x4);
  61. case IMX_SIP_CPUFREQ:
  62. SMC_RET1(handle, imx_cpufreq_handler(smc_fid, x1, x2, x3));
  63. break;
  64. case IMX_SIP_WAKEUP_SRC:
  65. SMC_RET1(handle, imx_wakeup_src_handler(smc_fid, x1, x2, x3));
  66. case IMX_SIP_OTP_READ:
  67. case IMX_SIP_OTP_WRITE:
  68. return imx_otp_handler(smc_fid, handle, x1, x2);
  69. case IMX_SIP_MISC_SET_TEMP:
  70. SMC_RET1(handle, imx_misc_set_temp_handler(smc_fid, x1, x2, x3, x4));
  71. #endif
  72. #if defined(PLAT_imx8mm) || defined(PLAT_imx8mq) || defined(PLAT_imx8mn) || \
  73. defined(PLAT_imx8mp)
  74. case IMX_SIP_SRC:
  75. SMC_RET1(handle, imx_src_handler(smc_fid, x1, x2, x3, handle));
  76. break;
  77. #endif
  78. #if defined(PLAT_imx8mm) || defined(PLAT_imx8mn) || defined(PLAT_imx8mp) || \
  79. defined(PLAT_imx8mq)
  80. case IMX_SIP_HAB:
  81. SMC_RET1(handle, imx_hab_handler(smc_fid, x1, x2, x3, x4));
  82. break;
  83. #endif
  84. case IMX_SIP_BUILDINFO:
  85. SMC_RET1(handle, imx_buildinfo_handler(smc_fid, x1, x2, x3, x4));
  86. default:
  87. WARN("Unimplemented i.MX SiP Service Call: 0x%x\n", smc_fid);
  88. SMC_RET1(handle, SMC_UNK);
  89. break;
  90. }
  91. }
  92. /* Define a runtime service descriptor for fast SMC calls */
  93. DECLARE_RT_SVC(
  94. imx_sip_svc,
  95. OEN_SIP_START,
  96. OEN_SIP_END,
  97. SMC_TYPE_FAST,
  98. imx_sip_setup,
  99. imx_sip_handler
  100. );