blob: 1dbbf26da2dc2871ac717ef365165a601cfea155 [file] [log] [blame]
Chandni Cherukuri3aa09f72018-11-28 11:31:51 +05301/*
Vijayenthiran Subramaniam2b4ad8d2019-09-23 19:32:32 +05302 * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved.
Chandni Cherukuri3aa09f72018-11-28 11:31:51 +05303 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +05307#include <common/debug.h>
8#include <drivers/arm/gic600_multichip.h>
9#include <plat/arm/common/plat_arm.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010#include <plat/common/platform.h>
Aditya Angadice79bca2020-11-18 08:32:30 +053011#include <sgi_soc_platform_def.h>
Vijayenthiran Subramaniam2b4ad8d2019-09-23 19:32:32 +053012#include <sgi_plat.h>
Chandni Cherukuri3aa09f72018-11-28 11:31:51 +053013
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053014#if defined(IMAGE_BL31)
15static const mmap_region_t rdn1edge_dynamic_mmap[] = {
16 ARM_MAP_SHARED_RAM_REMOTE_CHIP(1),
17 CSS_SGI_MAP_DEVICE_REMOTE_CHIP(1),
18 SOC_CSS_MAP_DEVICE_REMOTE_CHIP(1)
19};
20
21static struct gic600_multichip_data rdn1e1_multichip_data __init = {
22 .rt_owner_base = PLAT_ARM_GICD_BASE,
23 .rt_owner = 0,
24 .chip_count = CSS_SGI_CHIP_COUNT,
25 .chip_addrs = {
26 PLAT_ARM_GICD_BASE >> 16,
27 (PLAT_ARM_GICD_BASE + CSS_SGI_REMOTE_CHIP_MEM_OFFSET(1)) >> 16
28 },
29 .spi_ids = {
30 {32, 255},
31 {0, 0}
32 }
33};
34
35static uintptr_t rdn1e1_multichip_gicr_frames[] = {
36 PLAT_ARM_GICR_BASE, /* Chip 0's GICR Base */
37 PLAT_ARM_GICR_BASE +
38 CSS_SGI_REMOTE_CHIP_MEM_OFFSET(1), /* Chip 1's GICR BASE */
39 UL(0) /* Zero Termination */
40};
41#endif /* IMAGE_BL31 */
42
Chandni Cherukuri3aa09f72018-11-28 11:31:51 +053043unsigned int plat_arm_sgi_get_platform_id(void)
44{
45 return mmio_read_32(SID_REG_BASE + SID_SYSTEM_ID_OFFSET)
46 & SID_SYSTEM_ID_PART_NUM_MASK;
47}
48
49unsigned int plat_arm_sgi_get_config_id(void)
50{
51 return mmio_read_32(SID_REG_BASE + SID_SYSTEM_CFG_OFFSET);
52}
Vijayenthiran Subramaniam2b4ad8d2019-09-23 19:32:32 +053053
Vijayenthiran Subramaniam8af18432019-10-22 15:46:14 +053054unsigned int plat_arm_sgi_get_multi_chip_mode(void)
55{
56 return (mmio_read_32(SID_REG_BASE + SID_NODE_ID_OFFSET) &
57 SID_MULTI_CHIP_MODE_MASK) >> SID_MULTI_CHIP_MODE_SHIFT;
58}
59
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053060/*
61 * IMAGE_BL31 macro is added to build bl31_platform_setup function only for BL31
62 * because PLAT_XLAT_TABLES_DYNAMIC macro is set to build only for BL31 and not
63 * for other stages.
64 */
65#if defined(IMAGE_BL31)
Vijayenthiran Subramaniam2b4ad8d2019-09-23 19:32:32 +053066void bl31_platform_setup(void)
67{
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053068 int i, ret;
69
70 if (plat_arm_sgi_get_multi_chip_mode() == 0 && CSS_SGI_CHIP_COUNT > 1) {
71 ERROR("Chip Count is set to %d but multi-chip mode not enabled\n",
72 CSS_SGI_CHIP_COUNT);
73 panic();
74 } else if (plat_arm_sgi_get_multi_chip_mode() == 1 &&
75 CSS_SGI_CHIP_COUNT > 1) {
76 INFO("Enabling support for multi-chip in RD-N1-Edge\n");
77
78 for (i = 0; i < ARRAY_SIZE(rdn1edge_dynamic_mmap); i++) {
79 ret = mmap_add_dynamic_region(
80 rdn1edge_dynamic_mmap[i].base_pa,
81 rdn1edge_dynamic_mmap[i].base_va,
82 rdn1edge_dynamic_mmap[i].size,
83 rdn1edge_dynamic_mmap[i].attr
84 );
85 if (ret != 0) {
86 ERROR("Failed to add dynamic mmap entry\n");
87 panic();
88 }
89 }
90
91 plat_arm_override_gicr_frames(rdn1e1_multichip_gicr_frames);
92 gic600_multichip_init(&rdn1e1_multichip_data);
93 }
94
Vijayenthiran Subramaniam2b4ad8d2019-09-23 19:32:32 +053095 sgi_bl31_common_platform_setup();
96}
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053097#endif /* IMAGE_BL31 */