morello_bl31_setup.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright (c) 2020-2024, Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <drivers/arm/css/css_mhu_doorbell.h>
  7. #include <drivers/arm/css/scmi.h>
  8. #include <drivers/arm/css/sds.h>
  9. #include <lib/smccc.h>
  10. #include <plat/arm/common/plat_arm.h>
  11. #include <services/arm_arch_svc.h>
  12. #include "morello_def.h"
  13. #include "morello_private.h"
  14. #include <platform_def.h>
  15. #ifdef TARGET_PLATFORM_SOC
  16. struct morello_plat_info plat_info;
  17. #endif
  18. static scmi_channel_plat_info_t morello_scmi_plat_info = {
  19. .scmi_mbx_mem = MORELLO_SCMI_PAYLOAD_BASE,
  20. .db_reg_addr = PLAT_CSS_MHU_BASE + CSS_SCMI_MHU_DB_REG_OFF,
  21. .db_preserve_mask = 0xfffffffe,
  22. .db_modify_mask = 0x1,
  23. .ring_doorbell = &mhu_ring_doorbell
  24. };
  25. scmi_channel_plat_info_t *plat_css_get_scmi_info(unsigned int channel_id)
  26. {
  27. return &morello_scmi_plat_info;
  28. }
  29. const plat_psci_ops_t *plat_arm_psci_override_pm_ops(plat_psci_ops_t *ops)
  30. {
  31. ops->pwr_domain_off = morello_pwr_domain_off;
  32. return css_scmi_override_pm_ops(ops);
  33. }
  34. void bl31_platform_setup(void)
  35. {
  36. #ifdef TARGET_PLATFORM_SOC
  37. int ret;
  38. ret = sds_init(SDS_SCP_AP_REGION_ID);
  39. if (ret != SDS_OK) {
  40. ERROR("SDS initialization failed. ret:%d\n", ret);
  41. panic();
  42. }
  43. ret = sds_struct_read(SDS_SCP_AP_REGION_ID,
  44. MORELLO_SDS_PLATFORM_INFO_STRUCT_ID,
  45. MORELLO_SDS_PLATFORM_INFO_OFFSET,
  46. &plat_info,
  47. MORELLO_SDS_PLATFORM_INFO_SIZE,
  48. SDS_ACCESS_MODE_NON_CACHED);
  49. if (ret != SDS_OK) {
  50. ERROR("Error getting platform info from SDS. ret:%d\n", ret);
  51. panic();
  52. }
  53. #endif
  54. arm_bl31_platform_setup();
  55. }
  56. #ifdef TARGET_PLATFORM_SOC
  57. /*****************************************************************************
  58. * plat_is_smccc_feature_available() - This function checks whether SMCCC
  59. * feature is availabile for platform.
  60. * @fid: SMCCC function id
  61. *
  62. * Return SMC_ARCH_CALL_SUCCESS if SMCCC feature is available and
  63. * SMC_ARCH_CALL_NOT_SUPPORTED otherwise.
  64. *****************************************************************************/
  65. int32_t plat_is_smccc_feature_available(u_register_t fid)
  66. {
  67. switch (fid) {
  68. case SMCCC_ARCH_SOC_ID:
  69. return SMC_ARCH_CALL_SUCCESS;
  70. default:
  71. return SMC_ARCH_CALL_NOT_SUPPORTED;
  72. }
  73. }
  74. /* Get SOC version */
  75. int32_t plat_get_soc_version(void)
  76. {
  77. int ssc_version;
  78. ssc_version = mmio_read_32(SSC_VERSION);
  79. return (int32_t)
  80. (SOC_ID_SET_JEP_106(ARM_SOC_CONTINUATION_CODE,
  81. ARM_SOC_IDENTIFICATION_CODE) |
  82. (GET_SSC_VERSION_PART_NUM(ssc_version) & SOC_ID_IMPL_DEF_MASK));
  83. }
  84. /* Get SOC revision */
  85. int32_t plat_get_soc_revision(void)
  86. {
  87. return (int32_t)plat_info.silicon_revision;
  88. }
  89. #endif