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