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