blob: ac1ea486a6769cf4b435e4d2c9fe32d89190f519 [file] [log] [blame]
Nariman Poushin0ece80f2018-02-26 06:52:04 +00001/*
Pranav Madhue7fa8fb2024-01-22 21:41:14 +05302 * Copyright (c) 2018-2024, Arm Limited and Contributors. All rights reserved.
Nariman Poushin0ece80f2018-02-26 06:52:04 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Chandni Cherukuric8ef0452018-10-04 16:32:03 +05307#include <assert.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
Chandni Cherukuric8ef0452018-10-04 16:32:03 +05309#include <libfdt.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010
11#include <common/bl_common.h>
12#include <common/debug.h>
Antonio Nino Diaz1b0c6f12019-01-23 21:08:43 +000013#include <drivers/arm/css/css_mhu_doorbell.h>
Antonio Nino Diazc30db5b2019-01-23 20:37:32 +000014#include <drivers/arm/css/scmi.h>
Pranav Madhue7fa8fb2024-01-22 21:41:14 +053015#include <drivers/generic_delay_timer.h>
Antonio Nino Diazbd7b7402019-01-25 14:30:04 +000016#include <plat/arm/common/plat_arm.h>
Pranav Madhu078dc522022-07-27 14:01:24 +053017
Ambroise Vincentb237bca2019-02-13 15:58:00 +000018#include <plat/common/platform.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000019
Pranav Madhu078dc522022-07-27 14:01:24 +053020#include <plat/arm/css/common/css_pm.h>
21
Sughosh Ganu18f513d2018-05-16 17:22:35 +053022#include <sgi_ras.h>
Chandni Cherukuric8ef0452018-10-04 16:32:03 +053023#include <sgi_variant.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000024
Chandni Cherukuric8ef0452018-10-04 16:32:03 +053025sgi_platform_info_t sgi_plat_info;
26
Chandni Cherukuri61f3a7c2018-10-11 14:08:08 +053027static scmi_channel_plat_info_t sgi575_scmi_plat_info = {
28 .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE,
29 .db_reg_addr = PLAT_CSS_MHU_BASE + CSS_SCMI_MHU_DB_REG_OFF,
30 .db_preserve_mask = 0xfffffffe,
31 .db_modify_mask = 0x1,
32 .ring_doorbell = &mhu_ring_doorbell,
33};
34
Aditya Angadidf9904a2021-01-28 12:15:16 +053035static scmi_channel_plat_info_t plat_rd_scmi_info[] = {
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053036 {
Chandni Cherukuric8ef0452018-10-04 16:32:03 +053037 .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE,
38 .db_reg_addr = PLAT_CSS_MHU_BASE + SENDER_REG_SET(0),
39 .db_preserve_mask = 0xfffffffe,
40 .db_modify_mask = 0x1,
41 .ring_doorbell = &mhuv2_ring_doorbell,
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053042 },
43 #if (CSS_SGI_CHIP_COUNT > 1)
44 {
45 .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE +
46 CSS_SGI_REMOTE_CHIP_MEM_OFFSET(1),
47 .db_reg_addr = PLAT_CSS_MHU_BASE
48 + CSS_SGI_REMOTE_CHIP_MEM_OFFSET(1) + SENDER_REG_SET(0),
49 .db_preserve_mask = 0xfffffffe,
50 .db_modify_mask = 0x1,
51 .ring_doorbell = &mhuv2_ring_doorbell,
52 },
53 #endif
54 #if (CSS_SGI_CHIP_COUNT > 2)
55 {
56 .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE +
57 CSS_SGI_REMOTE_CHIP_MEM_OFFSET(2),
58 .db_reg_addr = PLAT_CSS_MHU_BASE +
59 CSS_SGI_REMOTE_CHIP_MEM_OFFSET(2) + SENDER_REG_SET(0),
60 .db_preserve_mask = 0xfffffffe,
61 .db_modify_mask = 0x1,
62 .ring_doorbell = &mhuv2_ring_doorbell,
63 },
64 #endif
65 #if (CSS_SGI_CHIP_COUNT > 3)
66 {
67 .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE +
68 CSS_SGI_REMOTE_CHIP_MEM_OFFSET(3),
69 .db_reg_addr = PLAT_CSS_MHU_BASE +
70 CSS_SGI_REMOTE_CHIP_MEM_OFFSET(3) + SENDER_REG_SET(0),
71 .db_preserve_mask = 0xfffffffe,
72 .db_modify_mask = 0x1,
73 .ring_doorbell = &mhuv2_ring_doorbell,
74 },
75 #endif
Chandni Cherukuric8ef0452018-10-04 16:32:03 +053076};
77
Tony K Nadackal1b116a82022-12-07 20:44:05 +000078scmi_channel_plat_info_t *plat_css_get_scmi_info(unsigned int channel_id)
Chandni Cherukuri61f3a7c2018-10-11 14:08:08 +053079{
Aditya Angadie6508952019-07-21 22:13:45 +053080 if (sgi_plat_info.platform_id == RD_N1E1_EDGE_SID_VER_PART_NUM ||
Aditya Angadied339d82020-12-15 17:10:50 +053081 sgi_plat_info.platform_id == RD_V1_SID_VER_PART_NUM ||
Aditya Angadif894b9a2021-03-20 12:15:04 +053082 sgi_plat_info.platform_id == RD_N2_SID_VER_PART_NUM ||
Joel Goddard38f35c82022-09-21 21:51:12 +053083 sgi_plat_info.platform_id == RD_V2_SID_VER_PART_NUM ||
Tony K Nadackala81a3d92021-11-24 16:09:26 +000084 sgi_plat_info.platform_id == RD_N2_CFG1_SID_VER_PART_NUM ||
85 sgi_plat_info.platform_id == RD_N2_CFG3_SID_VER_PART_NUM) {
Aditya Angadidf9904a2021-01-28 12:15:16 +053086 if (channel_id >= ARRAY_SIZE(plat_rd_scmi_info))
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053087 panic();
Aditya Angadidf9904a2021-01-28 12:15:16 +053088 return &plat_rd_scmi_info[channel_id];
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053089 }
Chandni Cherukuric8ef0452018-10-04 16:32:03 +053090 else if (sgi_plat_info.platform_id == SGI575_SSC_VER_PART_NUM)
91 return &sgi575_scmi_plat_info;
92 else
93 panic();
Ambroise Vincentb237bca2019-02-13 15:58:00 +000094}
Chandni Cherukuric8ef0452018-10-04 16:32:03 +053095
Nariman Poushin0ece80f2018-02-26 06:52:04 +000096void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
97 u_register_t arg2, u_register_t arg3)
98{
Chandni Cherukuri3aa09f72018-11-28 11:31:51 +053099 sgi_plat_info.platform_id = plat_arm_sgi_get_platform_id();
100 sgi_plat_info.config_id = plat_arm_sgi_get_config_id();
Vijayenthiran Subramaniam8af18432019-10-22 15:46:14 +0530101 sgi_plat_info.multi_chip_mode = plat_arm_sgi_get_multi_chip_mode();
Chandni Cherukuric8ef0452018-10-04 16:32:03 +0530102
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000103 arm_bl31_early_platform_setup((void *)arg0, arg1, arg2, (void *)arg3);
104}
Sughosh Ganu18f513d2018-05-16 17:22:35 +0530105
Vijayenthiran Subramaniam2b4ad8d2019-09-23 19:32:32 +0530106void sgi_bl31_common_platform_setup(void)
Sughosh Ganu18f513d2018-05-16 17:22:35 +0530107{
Pranav Madhue7fa8fb2024-01-22 21:41:14 +0530108 generic_delay_timer_init();
109
Sughosh Ganu18f513d2018-05-16 17:22:35 +0530110 arm_bl31_platform_setup();
111
Pranav Madhu078dc522022-07-27 14:01:24 +0530112 /* Configure the warm reboot SGI for primary core */
113 css_setup_cpu_pwr_down_intr();
114
115#if CSS_SYSTEM_GRACEFUL_RESET
116 /* Register priority level handlers for reboot */
117 ehf_register_priority_handler(PLAT_REBOOT_PRI,
118 css_reboot_interrupt_handler);
119#endif
Sughosh Ganu18f513d2018-05-16 17:22:35 +0530120}
Chandni Cherukurie4bf6a02018-11-14 13:43:59 +0530121
122const plat_psci_ops_t *plat_arm_psci_override_pm_ops(plat_psci_ops_t *ops)
123{
Aditya Angadie6508952019-07-21 22:13:45 +0530124 /*
Pranav Madhue0195fd2021-01-16 22:47:08 +0530125 * For RD-E1-Edge, only CPU power ON/OFF, PSCI platform callbacks are
126 * supported.
Aditya Angadie6508952019-07-21 22:13:45 +0530127 */
128 if (((sgi_plat_info.platform_id == RD_N1E1_EDGE_SID_VER_PART_NUM) &&
Pranav Madhue0195fd2021-01-16 22:47:08 +0530129 (sgi_plat_info.config_id == RD_E1_EDGE_CONFIG_ID))) {
Chandni Cherukuri2dfe1d02018-11-22 10:15:25 +0530130 ops->cpu_standby = NULL;
131 ops->system_off = NULL;
132 ops->system_reset = NULL;
133 ops->get_sys_suspend_power_state = NULL;
134 ops->pwr_domain_suspend = NULL;
135 ops->pwr_domain_suspend_finish = NULL;
136 }
137
Chandni Cherukurie4bf6a02018-11-14 13:43:59 +0530138 return css_scmi_override_pm_ops(ops);
139}