blob: e8a967e008e1c562b5c877c36dd00b8bacaf403d [file] [log] [blame]
Aditya Angadid61740b2020-11-19 18:05:33 +05301/*
Aditya Angadiccae8a12021-08-09 09:38:58 +05302 * Copyright (c) 2020-2021, ARM Limited and Contributors. All rights reserved.
Aditya Angadid61740b2020-11-19 18:05:33 +05303 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Aditya Angadiccae8a12021-08-09 09:38:58 +05307#include <common/debug.h>
8#include <drivers/arm/gic600_multichip.h>
9#include <plat/arm/common/plat_arm.h>
Aditya Angadid61740b2020-11-19 18:05:33 +053010#include <plat/common/platform.h>
Omkar Anand Kulkarni1f425992023-06-22 15:18:07 +053011#include <rdn2_ras.h>
Aditya Angadiccae8a12021-08-09 09:38:58 +053012#include <sgi_soc_platform_def_v2.h>
Aditya Angadid61740b2020-11-19 18:05:33 +053013#include <sgi_plat.h>
14
Aditya Angadiccae8a12021-08-09 09:38:58 +053015#if defined(IMAGE_BL31)
16#if (CSS_SGI_PLATFORM_VARIANT == 2)
17static const mmap_region_t rdn2mc_dynamic_mmap[] = {
18#if CSS_SGI_CHIP_COUNT > 1
19 ARM_MAP_SHARED_RAM_REMOTE_CHIP(1),
20 CSS_SGI_MAP_DEVICE_REMOTE_CHIP(1),
21#endif
22#if CSS_SGI_CHIP_COUNT > 2
23 ARM_MAP_SHARED_RAM_REMOTE_CHIP(2),
24 CSS_SGI_MAP_DEVICE_REMOTE_CHIP(2),
25#endif
26#if CSS_SGI_CHIP_COUNT > 3
27 ARM_MAP_SHARED_RAM_REMOTE_CHIP(3),
28 CSS_SGI_MAP_DEVICE_REMOTE_CHIP(3),
29#endif
30};
31#endif
32
33#if (CSS_SGI_PLATFORM_VARIANT == 2)
34static struct gic600_multichip_data rdn2mc_multichip_data __init = {
35 .rt_owner_base = PLAT_ARM_GICD_BASE,
36 .rt_owner = 0,
37 .chip_count = CSS_SGI_CHIP_COUNT,
38 .chip_addrs = {
39 PLAT_ARM_GICD_BASE >> 16,
40#if CSS_SGI_CHIP_COUNT > 1
41 (PLAT_ARM_GICD_BASE + CSS_SGI_REMOTE_CHIP_MEM_OFFSET(1)) >> 16,
42#endif
43#if CSS_SGI_CHIP_COUNT > 2
44 (PLAT_ARM_GICD_BASE + CSS_SGI_REMOTE_CHIP_MEM_OFFSET(2)) >> 16,
45#endif
46#if CSS_SGI_CHIP_COUNT > 3
47 (PLAT_ARM_GICD_BASE + CSS_SGI_REMOTE_CHIP_MEM_OFFSET(3)) >> 16,
48#endif
49 },
50 .spi_ids = {
Varun Wadekar61286d22023-03-08 16:47:38 +000051 {PLAT_ARM_GICD_BASE, 32, 511},
Aditya Angadiccae8a12021-08-09 09:38:58 +053052 #if CSS_SGI_CHIP_COUNT > 1
Varun Wadekar61286d22023-03-08 16:47:38 +000053 {PLAT_ARM_GICD_BASE, 512, 991},
Aditya Angadiccae8a12021-08-09 09:38:58 +053054 #endif
55 #if CSS_SGI_CHIP_COUNT > 2
Varun Wadekar61286d22023-03-08 16:47:38 +000056 {PLAT_ARM_GICD_BASE, 4096, 4575},
Aditya Angadiccae8a12021-08-09 09:38:58 +053057 #endif
58 #if CSS_SGI_CHIP_COUNT > 3
Varun Wadekar61286d22023-03-08 16:47:38 +000059 {PLAT_ARM_GICD_BASE, 4576, 5055},
Aditya Angadiccae8a12021-08-09 09:38:58 +053060 #endif
61 }
62};
63#endif
64
65#if (CSS_SGI_PLATFORM_VARIANT == 2)
66static uintptr_t rdn2mc_multichip_gicr_frames[] = {
67 /* Chip 0's GICR Base */
68 PLAT_ARM_GICR_BASE,
69#if CSS_SGI_CHIP_COUNT > 1
70 /* Chip 1's GICR BASE */
71 PLAT_ARM_GICR_BASE + CSS_SGI_REMOTE_CHIP_MEM_OFFSET(1),
72#endif
73#if CSS_SGI_CHIP_COUNT > 2
74 /* Chip 2's GICR BASE */
75 PLAT_ARM_GICR_BASE + CSS_SGI_REMOTE_CHIP_MEM_OFFSET(2),
76#endif
77#if CSS_SGI_CHIP_COUNT > 3
78 /* Chip 3's GICR BASE */
79 PLAT_ARM_GICR_BASE + CSS_SGI_REMOTE_CHIP_MEM_OFFSET(3),
80#endif
81 UL(0) /* Zero Termination */
82};
83#endif
84#endif /* IMAGE_BL31 */
85
Aditya Angadid61740b2020-11-19 18:05:33 +053086unsigned int plat_arm_sgi_get_platform_id(void)
87{
88 return mmio_read_32(SID_REG_BASE + SID_SYSTEM_ID_OFFSET)
89 & SID_SYSTEM_ID_PART_NUM_MASK;
90}
91
92unsigned int plat_arm_sgi_get_config_id(void)
93{
94 return mmio_read_32(SID_REG_BASE + SID_SYSTEM_CFG_OFFSET);
95}
96
97unsigned int plat_arm_sgi_get_multi_chip_mode(void)
98{
99 return (mmio_read_32(SID_REG_BASE + SID_NODE_ID_OFFSET) &
100 SID_MULTI_CHIP_MODE_MASK) >>
101 SID_MULTI_CHIP_MODE_SHIFT;
102}
103
Aditya Angadiccae8a12021-08-09 09:38:58 +0530104#if defined(IMAGE_BL31)
Aditya Angadid61740b2020-11-19 18:05:33 +0530105void bl31_platform_setup(void)
106{
Aditya Angadiccae8a12021-08-09 09:38:58 +0530107#if (CSS_SGI_PLATFORM_VARIANT == 2)
108 int ret;
109 unsigned int i;
110
111 if (plat_arm_sgi_get_multi_chip_mode() == 0) {
112 ERROR("Chip Count is set to %u but multi-chip mode is not "
113 "enabled\n", CSS_SGI_CHIP_COUNT);
114 panic();
115 } else {
116 INFO("Enabling multi-chip support for RD-N2 variant\n");
117
118 for (i = 0; i < ARRAY_SIZE(rdn2mc_dynamic_mmap); i++) {
119 ret = mmap_add_dynamic_region(
120 rdn2mc_dynamic_mmap[i].base_pa,
121 rdn2mc_dynamic_mmap[i].base_va,
122 rdn2mc_dynamic_mmap[i].size,
123 rdn2mc_dynamic_mmap[i].attr);
124 if (ret != 0) {
125 ERROR("Failed to add dynamic mmap entry for"
126 " i: %d " "(ret=%d)\n", i, ret);
127 panic();
128 }
129 }
130
131 plat_arm_override_gicr_frames(
132 rdn2mc_multichip_gicr_frames);
133 gic600_multichip_init(&rdn2mc_multichip_data);
134 }
135#endif
136
Aditya Angadid61740b2020-11-19 18:05:33 +0530137 sgi_bl31_common_platform_setup();
Omkar Anand Kulkarni1f425992023-06-22 15:18:07 +0530138
139#if RAS_FFH_SUPPORT
140 sgi_ras_platform_setup(&ras_config);
141#endif
Aditya Angadid61740b2020-11-19 18:05:33 +0530142}
Aditya Angadiccae8a12021-08-09 09:38:58 +0530143#endif /* IMAGE_BL31 */