stm32mp_svc_setup.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (c) 2014-2024, STMicroelectronics - All Rights Reserved
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <stdbool.h>
  7. #include <stdint.h>
  8. #include <common/debug.h>
  9. #include <common/runtime_svc.h>
  10. #include <drivers/scmi-msg.h>
  11. #include <lib/psci/psci.h>
  12. #include <platform_def.h>
  13. #include <tools_share/uuid.h>
  14. #include <stm32mp_svc_setup.h>
  15. /* STM32 SiP Service UUID */
  16. DEFINE_SVC_UUID2(stm32_sip_svc_uid,
  17. 0xa778aa50, 0xf49b, 0x144a, 0x8a, 0x5e,
  18. 0x26, 0x4d, 0x59, 0x94, 0xc2, 0x14);
  19. /* Setup STM32MP Standard Services */
  20. static int32_t stm32mp_svc_setup(void)
  21. {
  22. /*
  23. * PSCI is the only specification implemented as a Standard Service.
  24. * Invoke PSCI setup from here.
  25. */
  26. return 0;
  27. }
  28. /*
  29. * Top-level Standard Service SMC handler. This handler will dispatch the SMC
  30. * to the correct feature handler or default call a platform handler
  31. */
  32. static uintptr_t stm32mp_svc_smc_handler(uint32_t smc_fid, u_register_t x1,
  33. u_register_t x2, u_register_t x3,
  34. u_register_t x4, void *cookie,
  35. void *handle, u_register_t flags)
  36. {
  37. uint32_t ret1 = 0U, ret2 = 0U;
  38. bool ret_uid = false, ret2_enabled = false;
  39. switch (smc_fid) {
  40. case STM32_SIP_SVC_UID:
  41. /* Return UUID to the caller */
  42. ret_uid = true;
  43. break;
  44. case STM32_SIP_SVC_VERSION:
  45. /* Return the version of current implementation */
  46. ret1 = STM32_SIP_SVC_VERSION_MAJOR;
  47. ret2 = STM32_SIP_SVC_VERSION_MINOR;
  48. ret2_enabled = true;
  49. break;
  50. default:
  51. plat_svc_smc_handler(smc_fid, x1, x2, x3, x4, &ret1, &ret2, &ret2_enabled, flags);
  52. break;
  53. }
  54. if (ret_uid) {
  55. SMC_UUID_RET(handle, stm32_sip_svc_uid);
  56. }
  57. if (ret2_enabled) {
  58. SMC_RET2(handle, ret1, ret2);
  59. }
  60. SMC_RET1(handle, ret1);
  61. }
  62. /* Register Standard Service Calls as runtime service */
  63. DECLARE_RT_SVC(stm32mp_sip_svc,
  64. OEN_SIP_START,
  65. OEN_SIP_END,
  66. SMC_TYPE_FAST,
  67. stm32mp_svc_setup,
  68. stm32mp_svc_smc_handler
  69. );