blob: a22c799dde02f2f3f091ed3b0e070e2591a7a079 [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#include <plat/arm/css/common/css_pm.h>
Rohit Mathewa0dd3072024-02-03 17:22:54 +000018#include <plat/common/platform.h>
Pranav Madhu078dc522022-07-27 14:01:24 +053019
Rohit Mathewa0dd3072024-02-03 17:22:54 +000020#include <nrd_ras.h>
21#include <nrd_variant.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000022
Rohit Mathew0ec6ed92024-02-03 18:39:10 +000023nrd_platform_info_t nrd_plat_info;
Chandni Cherukuric8ef0452018-10-04 16:32:03 +053024
Chandni Cherukuri61f3a7c2018-10-11 14:08:08 +053025static scmi_channel_plat_info_t sgi575_scmi_plat_info = {
26 .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE,
27 .db_reg_addr = PLAT_CSS_MHU_BASE + CSS_SCMI_MHU_DB_REG_OFF,
28 .db_preserve_mask = 0xfffffffe,
29 .db_modify_mask = 0x1,
30 .ring_doorbell = &mhu_ring_doorbell,
31};
32
Aditya Angadidf9904a2021-01-28 12:15:16 +053033static scmi_channel_plat_info_t plat_rd_scmi_info[] = {
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053034 {
Chandni Cherukuric8ef0452018-10-04 16:32:03 +053035 .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE,
36 .db_reg_addr = PLAT_CSS_MHU_BASE + SENDER_REG_SET(0),
37 .db_preserve_mask = 0xfffffffe,
38 .db_modify_mask = 0x1,
39 .ring_doorbell = &mhuv2_ring_doorbell,
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053040 },
Rohit Mathew644d9e22024-02-03 19:06:16 +000041 #if (NRD_CHIP_COUNT > 1)
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053042 {
43 .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE +
Rohit Mathewaac0c3c2024-02-03 22:16:14 +000044 NRD_REMOTE_CHIP_MEM_OFFSET(1),
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053045 .db_reg_addr = PLAT_CSS_MHU_BASE
Rohit Mathewaac0c3c2024-02-03 22:16:14 +000046 + NRD_REMOTE_CHIP_MEM_OFFSET(1) + SENDER_REG_SET(0),
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053047 .db_preserve_mask = 0xfffffffe,
48 .db_modify_mask = 0x1,
49 .ring_doorbell = &mhuv2_ring_doorbell,
50 },
51 #endif
Rohit Mathew644d9e22024-02-03 19:06:16 +000052 #if (NRD_CHIP_COUNT > 2)
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053053 {
54 .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE +
Rohit Mathewaac0c3c2024-02-03 22:16:14 +000055 NRD_REMOTE_CHIP_MEM_OFFSET(2),
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053056 .db_reg_addr = PLAT_CSS_MHU_BASE +
Rohit Mathewaac0c3c2024-02-03 22:16:14 +000057 NRD_REMOTE_CHIP_MEM_OFFSET(2) + SENDER_REG_SET(0),
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053058 .db_preserve_mask = 0xfffffffe,
59 .db_modify_mask = 0x1,
60 .ring_doorbell = &mhuv2_ring_doorbell,
61 },
62 #endif
Rohit Mathew644d9e22024-02-03 19:06:16 +000063 #if (NRD_CHIP_COUNT > 3)
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053064 {
65 .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE +
Rohit Mathewaac0c3c2024-02-03 22:16:14 +000066 NRD_REMOTE_CHIP_MEM_OFFSET(3),
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053067 .db_reg_addr = PLAT_CSS_MHU_BASE +
Rohit Mathewaac0c3c2024-02-03 22:16:14 +000068 NRD_REMOTE_CHIP_MEM_OFFSET(3) + SENDER_REG_SET(0),
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053069 .db_preserve_mask = 0xfffffffe,
70 .db_modify_mask = 0x1,
71 .ring_doorbell = &mhuv2_ring_doorbell,
72 },
73 #endif
Chandni Cherukuric8ef0452018-10-04 16:32:03 +053074};
75
Tony K Nadackal1b116a82022-12-07 20:44:05 +000076scmi_channel_plat_info_t *plat_css_get_scmi_info(unsigned int channel_id)
Chandni Cherukuri61f3a7c2018-10-11 14:08:08 +053077{
Rohit Mathew0ec6ed92024-02-03 18:39:10 +000078 if (nrd_plat_info.platform_id == RD_N1E1_EDGE_SID_VER_PART_NUM ||
79 nrd_plat_info.platform_id == RD_V1_SID_VER_PART_NUM ||
80 nrd_plat_info.platform_id == RD_N2_SID_VER_PART_NUM ||
81 nrd_plat_info.platform_id == RD_V2_SID_VER_PART_NUM ||
82 nrd_plat_info.platform_id == RD_N2_CFG1_SID_VER_PART_NUM ||
83 nrd_plat_info.platform_id == RD_N2_CFG3_SID_VER_PART_NUM) {
Rohit Mathew5ea005f2024-02-06 10:48:25 +000084 if (channel_id >= ARRAY_SIZE(plat_rd_scmi_info)) {
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053085 panic();
Rohit Mathew5ea005f2024-02-06 10:48:25 +000086 }
Aditya Angadidf9904a2021-01-28 12:15:16 +053087 return &plat_rd_scmi_info[channel_id];
Rohit Mathew0ec6ed92024-02-03 18:39:10 +000088 } else if (nrd_plat_info.platform_id == SGI575_SSC_VER_PART_NUM) {
Chandni Cherukuric8ef0452018-10-04 16:32:03 +053089 return &sgi575_scmi_plat_info;
Rohit Mathew5ea005f2024-02-06 10:48:25 +000090 } else {
Chandni Cherukuric8ef0452018-10-04 16:32:03 +053091 panic();
Rohit Mathew5ea005f2024-02-06 10:48:25 +000092 }
Ambroise Vincentb237bca2019-02-13 15:58:00 +000093}
Chandni Cherukuric8ef0452018-10-04 16:32:03 +053094
Nariman Poushin0ece80f2018-02-26 06:52:04 +000095void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
96 u_register_t arg2, u_register_t arg3)
97{
Rohit Mathew0ec6ed92024-02-03 18:39:10 +000098 nrd_plat_info.platform_id = plat_arm_nrd_get_platform_id();
99 nrd_plat_info.config_id = plat_arm_nrd_get_config_id();
100 nrd_plat_info.multi_chip_mode = plat_arm_nrd_get_multi_chip_mode();
Chandni Cherukuric8ef0452018-10-04 16:32:03 +0530101
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000102 arm_bl31_early_platform_setup((void *)arg0, arg1, arg2, (void *)arg3);
103}
Sughosh Ganu18f513d2018-05-16 17:22:35 +0530104
Rohit Mathew0ec6ed92024-02-03 18:39:10 +0000105void nrd_bl31_common_platform_setup(void)
Sughosh Ganu18f513d2018-05-16 17:22:35 +0530106{
Pranav Madhue7fa8fb2024-01-22 21:41:14 +0530107 generic_delay_timer_init();
108
Sughosh Ganu18f513d2018-05-16 17:22:35 +0530109 arm_bl31_platform_setup();
110
Pranav Madhu078dc522022-07-27 14:01:24 +0530111 /* Configure the warm reboot SGI for primary core */
112 css_setup_cpu_pwr_down_intr();
113
114#if CSS_SYSTEM_GRACEFUL_RESET
115 /* Register priority level handlers for reboot */
116 ehf_register_priority_handler(PLAT_REBOOT_PRI,
117 css_reboot_interrupt_handler);
118#endif
Sughosh Ganu18f513d2018-05-16 17:22:35 +0530119}
Chandni Cherukurie4bf6a02018-11-14 13:43:59 +0530120
121const plat_psci_ops_t *plat_arm_psci_override_pm_ops(plat_psci_ops_t *ops)
122{
Aditya Angadie6508952019-07-21 22:13:45 +0530123 /*
Pranav Madhue0195fd2021-01-16 22:47:08 +0530124 * For RD-E1-Edge, only CPU power ON/OFF, PSCI platform callbacks are
125 * supported.
Aditya Angadie6508952019-07-21 22:13:45 +0530126 */
Rohit Mathew0ec6ed92024-02-03 18:39:10 +0000127 if (((nrd_plat_info.platform_id == RD_N1E1_EDGE_SID_VER_PART_NUM) &&
128 (nrd_plat_info.config_id == RD_E1_EDGE_CONFIG_ID))) {
Chandni Cherukuri2dfe1d02018-11-22 10:15:25 +0530129 ops->cpu_standby = NULL;
130 ops->system_off = NULL;
131 ops->system_reset = NULL;
132 ops->get_sys_suspend_power_state = NULL;
133 ops->pwr_domain_suspend = NULL;
134 ops->pwr_domain_suspend_finish = NULL;
135 }
136
Chandni Cherukurie4bf6a02018-11-14 13:43:59 +0530137 return css_scmi_override_pm_ops(ops);
138}