Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 1 | /* |
Tony K Nadackal | a81a3d9 | 2021-11-24 16:09:26 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2023, Arm Limited and Contributors. All rights reserved. |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Chandni Cherukuri | c8ef045 | 2018-10-04 16:32:03 +0530 | [diff] [blame] | 7 | #include <assert.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | |
Chandni Cherukuri | c8ef045 | 2018-10-04 16:32:03 +0530 | [diff] [blame] | 9 | #include <libfdt.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | |
| 11 | #include <common/bl_common.h> |
| 12 | #include <common/debug.h> |
Antonio Nino Diaz | 1b0c6f1 | 2019-01-23 21:08:43 +0000 | [diff] [blame] | 13 | #include <drivers/arm/css/css_mhu_doorbell.h> |
Antonio Nino Diaz | c30db5b | 2019-01-23 20:37:32 +0000 | [diff] [blame] | 14 | #include <drivers/arm/css/scmi.h> |
Antonio Nino Diaz | bd7b740 | 2019-01-25 14:30:04 +0000 | [diff] [blame] | 15 | #include <plat/arm/common/plat_arm.h> |
Pranav Madhu | 078dc52 | 2022-07-27 14:01:24 +0530 | [diff] [blame] | 16 | |
Ambroise Vincent | b237bca | 2019-02-13 15:58:00 +0000 | [diff] [blame] | 17 | #include <plat/common/platform.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 18 | |
Pranav Madhu | 078dc52 | 2022-07-27 14:01:24 +0530 | [diff] [blame] | 19 | #include <plat/arm/css/common/css_pm.h> |
| 20 | |
Sughosh Ganu | 18f513d | 2018-05-16 17:22:35 +0530 | [diff] [blame] | 21 | #include <sgi_ras.h> |
Chandni Cherukuri | c8ef045 | 2018-10-04 16:32:03 +0530 | [diff] [blame] | 22 | #include <sgi_variant.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 23 | |
Chandni Cherukuri | c8ef045 | 2018-10-04 16:32:03 +0530 | [diff] [blame] | 24 | sgi_platform_info_t sgi_plat_info; |
| 25 | |
Chandni Cherukuri | 61f3a7c | 2018-10-11 14:08:08 +0530 | [diff] [blame] | 26 | static scmi_channel_plat_info_t sgi575_scmi_plat_info = { |
| 27 | .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE, |
| 28 | .db_reg_addr = PLAT_CSS_MHU_BASE + CSS_SCMI_MHU_DB_REG_OFF, |
| 29 | .db_preserve_mask = 0xfffffffe, |
| 30 | .db_modify_mask = 0x1, |
| 31 | .ring_doorbell = &mhu_ring_doorbell, |
| 32 | }; |
| 33 | |
Aditya Angadi | df9904a | 2021-01-28 12:15:16 +0530 | [diff] [blame] | 34 | static scmi_channel_plat_info_t plat_rd_scmi_info[] = { |
Vijayenthiran Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 35 | { |
Chandni Cherukuri | c8ef045 | 2018-10-04 16:32:03 +0530 | [diff] [blame] | 36 | .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE, |
| 37 | .db_reg_addr = PLAT_CSS_MHU_BASE + SENDER_REG_SET(0), |
| 38 | .db_preserve_mask = 0xfffffffe, |
| 39 | .db_modify_mask = 0x1, |
| 40 | .ring_doorbell = &mhuv2_ring_doorbell, |
Vijayenthiran Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 41 | }, |
| 42 | #if (CSS_SGI_CHIP_COUNT > 1) |
| 43 | { |
| 44 | .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE + |
| 45 | CSS_SGI_REMOTE_CHIP_MEM_OFFSET(1), |
| 46 | .db_reg_addr = PLAT_CSS_MHU_BASE |
| 47 | + CSS_SGI_REMOTE_CHIP_MEM_OFFSET(1) + SENDER_REG_SET(0), |
| 48 | .db_preserve_mask = 0xfffffffe, |
| 49 | .db_modify_mask = 0x1, |
| 50 | .ring_doorbell = &mhuv2_ring_doorbell, |
| 51 | }, |
| 52 | #endif |
| 53 | #if (CSS_SGI_CHIP_COUNT > 2) |
| 54 | { |
| 55 | .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE + |
| 56 | CSS_SGI_REMOTE_CHIP_MEM_OFFSET(2), |
| 57 | .db_reg_addr = PLAT_CSS_MHU_BASE + |
| 58 | CSS_SGI_REMOTE_CHIP_MEM_OFFSET(2) + SENDER_REG_SET(0), |
| 59 | .db_preserve_mask = 0xfffffffe, |
| 60 | .db_modify_mask = 0x1, |
| 61 | .ring_doorbell = &mhuv2_ring_doorbell, |
| 62 | }, |
| 63 | #endif |
| 64 | #if (CSS_SGI_CHIP_COUNT > 3) |
| 65 | { |
| 66 | .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE + |
| 67 | CSS_SGI_REMOTE_CHIP_MEM_OFFSET(3), |
| 68 | .db_reg_addr = PLAT_CSS_MHU_BASE + |
| 69 | CSS_SGI_REMOTE_CHIP_MEM_OFFSET(3) + SENDER_REG_SET(0), |
| 70 | .db_preserve_mask = 0xfffffffe, |
| 71 | .db_modify_mask = 0x1, |
| 72 | .ring_doorbell = &mhuv2_ring_doorbell, |
| 73 | }, |
| 74 | #endif |
Chandni Cherukuri | c8ef045 | 2018-10-04 16:32:03 +0530 | [diff] [blame] | 75 | }; |
| 76 | |
Tony K Nadackal | 1b116a8 | 2022-12-07 20:44:05 +0000 | [diff] [blame] | 77 | scmi_channel_plat_info_t *plat_css_get_scmi_info(unsigned int channel_id) |
Chandni Cherukuri | 61f3a7c | 2018-10-11 14:08:08 +0530 | [diff] [blame] | 78 | { |
Aditya Angadi | e650895 | 2019-07-21 22:13:45 +0530 | [diff] [blame] | 79 | if (sgi_plat_info.platform_id == RD_N1E1_EDGE_SID_VER_PART_NUM || |
Aditya Angadi | ed339d8 | 2020-12-15 17:10:50 +0530 | [diff] [blame] | 80 | sgi_plat_info.platform_id == RD_V1_SID_VER_PART_NUM || |
Aditya Angadi | f894b9a | 2021-03-20 12:15:04 +0530 | [diff] [blame] | 81 | sgi_plat_info.platform_id == RD_N2_SID_VER_PART_NUM || |
Joel Goddard | 38f35c8 | 2022-09-21 21:51:12 +0530 | [diff] [blame] | 82 | sgi_plat_info.platform_id == RD_V2_SID_VER_PART_NUM || |
Tony K Nadackal | a81a3d9 | 2021-11-24 16:09:26 +0000 | [diff] [blame] | 83 | sgi_plat_info.platform_id == RD_N2_CFG1_SID_VER_PART_NUM || |
| 84 | sgi_plat_info.platform_id == RD_N2_CFG3_SID_VER_PART_NUM) { |
Aditya Angadi | df9904a | 2021-01-28 12:15:16 +0530 | [diff] [blame] | 85 | if (channel_id >= ARRAY_SIZE(plat_rd_scmi_info)) |
Vijayenthiran Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 86 | panic(); |
Aditya Angadi | df9904a | 2021-01-28 12:15:16 +0530 | [diff] [blame] | 87 | return &plat_rd_scmi_info[channel_id]; |
Vijayenthiran Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 88 | } |
Chandni Cherukuri | c8ef045 | 2018-10-04 16:32:03 +0530 | [diff] [blame] | 89 | else if (sgi_plat_info.platform_id == SGI575_SSC_VER_PART_NUM) |
| 90 | return &sgi575_scmi_plat_info; |
| 91 | else |
| 92 | panic(); |
Ambroise Vincent | b237bca | 2019-02-13 15:58:00 +0000 | [diff] [blame] | 93 | } |
Chandni Cherukuri | c8ef045 | 2018-10-04 16:32:03 +0530 | [diff] [blame] | 94 | |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 95 | void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, |
| 96 | u_register_t arg2, u_register_t arg3) |
| 97 | { |
Chandni Cherukuri | 3aa09f7 | 2018-11-28 11:31:51 +0530 | [diff] [blame] | 98 | sgi_plat_info.platform_id = plat_arm_sgi_get_platform_id(); |
| 99 | sgi_plat_info.config_id = plat_arm_sgi_get_config_id(); |
Vijayenthiran Subramaniam | 8af1843 | 2019-10-22 15:46:14 +0530 | [diff] [blame] | 100 | sgi_plat_info.multi_chip_mode = plat_arm_sgi_get_multi_chip_mode(); |
Chandni Cherukuri | c8ef045 | 2018-10-04 16:32:03 +0530 | [diff] [blame] | 101 | |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 102 | arm_bl31_early_platform_setup((void *)arg0, arg1, arg2, (void *)arg3); |
| 103 | } |
Sughosh Ganu | 18f513d | 2018-05-16 17:22:35 +0530 | [diff] [blame] | 104 | |
Vijayenthiran Subramaniam | 2b4ad8d | 2019-09-23 19:32:32 +0530 | [diff] [blame] | 105 | void sgi_bl31_common_platform_setup(void) |
Sughosh Ganu | 18f513d | 2018-05-16 17:22:35 +0530 | [diff] [blame] | 106 | { |
| 107 | arm_bl31_platform_setup(); |
| 108 | |
Manish Pandey | d419e22 | 2023-02-13 12:39:17 +0000 | [diff] [blame^] | 109 | #if RAS_FFH_SUPPORT |
Sughosh Ganu | 18f513d | 2018-05-16 17:22:35 +0530 | [diff] [blame] | 110 | sgi_ras_intr_handler_setup(); |
| 111 | #endif |
Pranav Madhu | 078dc52 | 2022-07-27 14:01:24 +0530 | [diff] [blame] | 112 | |
| 113 | /* Configure the warm reboot SGI for primary core */ |
| 114 | css_setup_cpu_pwr_down_intr(); |
| 115 | |
| 116 | #if CSS_SYSTEM_GRACEFUL_RESET |
| 117 | /* Register priority level handlers for reboot */ |
| 118 | ehf_register_priority_handler(PLAT_REBOOT_PRI, |
| 119 | css_reboot_interrupt_handler); |
| 120 | #endif |
Sughosh Ganu | 18f513d | 2018-05-16 17:22:35 +0530 | [diff] [blame] | 121 | } |
Chandni Cherukuri | e4bf6a0 | 2018-11-14 13:43:59 +0530 | [diff] [blame] | 122 | |
| 123 | const plat_psci_ops_t *plat_arm_psci_override_pm_ops(plat_psci_ops_t *ops) |
| 124 | { |
Aditya Angadi | e650895 | 2019-07-21 22:13:45 +0530 | [diff] [blame] | 125 | /* |
Pranav Madhu | e0195fd | 2021-01-16 22:47:08 +0530 | [diff] [blame] | 126 | * For RD-E1-Edge, only CPU power ON/OFF, PSCI platform callbacks are |
| 127 | * supported. |
Aditya Angadi | e650895 | 2019-07-21 22:13:45 +0530 | [diff] [blame] | 128 | */ |
| 129 | if (((sgi_plat_info.platform_id == RD_N1E1_EDGE_SID_VER_PART_NUM) && |
Pranav Madhu | e0195fd | 2021-01-16 22:47:08 +0530 | [diff] [blame] | 130 | (sgi_plat_info.config_id == RD_E1_EDGE_CONFIG_ID))) { |
Chandni Cherukuri | 2dfe1d0 | 2018-11-22 10:15:25 +0530 | [diff] [blame] | 131 | ops->cpu_standby = NULL; |
| 132 | ops->system_off = NULL; |
| 133 | ops->system_reset = NULL; |
| 134 | ops->get_sys_suspend_power_state = NULL; |
| 135 | ops->pwr_domain_suspend = NULL; |
| 136 | ops->pwr_domain_suspend_finish = NULL; |
| 137 | } |
| 138 | |
Chandni Cherukuri | e4bf6a0 | 2018-11-14 13:43:59 +0530 | [diff] [blame] | 139 | return css_scmi_override_pm_ops(ops); |
| 140 | } |