Aditya Angadi | d61740b | 2020-11-19 18:05:33 +0530 | [diff] [blame] | 1 | /* |
Aditya Angadi | ccae8a1 | 2021-08-09 09:38:58 +0530 | [diff] [blame] | 2 | * Copyright (c) 2020-2021, ARM Limited and Contributors. All rights reserved. |
Aditya Angadi | d61740b | 2020-11-19 18:05:33 +0530 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Aditya Angadi | ccae8a1 | 2021-08-09 09:38:58 +0530 | [diff] [blame] | 7 | #include <common/debug.h> |
| 8 | #include <drivers/arm/gic600_multichip.h> |
| 9 | #include <plat/arm/common/plat_arm.h> |
Aditya Angadi | d61740b | 2020-11-19 18:05:33 +0530 | [diff] [blame] | 10 | #include <plat/common/platform.h> |
Omkar Anand Kulkarni | 1f42599 | 2023-06-22 15:18:07 +0530 | [diff] [blame] | 11 | #include <rdn2_ras.h> |
Aditya Angadi | ccae8a1 | 2021-08-09 09:38:58 +0530 | [diff] [blame] | 12 | #include <sgi_soc_platform_def_v2.h> |
Aditya Angadi | d61740b | 2020-11-19 18:05:33 +0530 | [diff] [blame] | 13 | #include <sgi_plat.h> |
| 14 | |
Aditya Angadi | ccae8a1 | 2021-08-09 09:38:58 +0530 | [diff] [blame] | 15 | #if defined(IMAGE_BL31) |
| 16 | #if (CSS_SGI_PLATFORM_VARIANT == 2) |
| 17 | static 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) |
| 34 | static 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 Wadekar | 61286d2 | 2023-03-08 16:47:38 +0000 | [diff] [blame] | 51 | {PLAT_ARM_GICD_BASE, 32, 511}, |
Aditya Angadi | ccae8a1 | 2021-08-09 09:38:58 +0530 | [diff] [blame] | 52 | #if CSS_SGI_CHIP_COUNT > 1 |
Varun Wadekar | 61286d2 | 2023-03-08 16:47:38 +0000 | [diff] [blame] | 53 | {PLAT_ARM_GICD_BASE, 512, 991}, |
Aditya Angadi | ccae8a1 | 2021-08-09 09:38:58 +0530 | [diff] [blame] | 54 | #endif |
| 55 | #if CSS_SGI_CHIP_COUNT > 2 |
Varun Wadekar | 61286d2 | 2023-03-08 16:47:38 +0000 | [diff] [blame] | 56 | {PLAT_ARM_GICD_BASE, 4096, 4575}, |
Aditya Angadi | ccae8a1 | 2021-08-09 09:38:58 +0530 | [diff] [blame] | 57 | #endif |
| 58 | #if CSS_SGI_CHIP_COUNT > 3 |
Varun Wadekar | 61286d2 | 2023-03-08 16:47:38 +0000 | [diff] [blame] | 59 | {PLAT_ARM_GICD_BASE, 4576, 5055}, |
Aditya Angadi | ccae8a1 | 2021-08-09 09:38:58 +0530 | [diff] [blame] | 60 | #endif |
| 61 | } |
| 62 | }; |
| 63 | #endif |
| 64 | |
| 65 | #if (CSS_SGI_PLATFORM_VARIANT == 2) |
| 66 | static 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 Angadi | d61740b | 2020-11-19 18:05:33 +0530 | [diff] [blame] | 86 | unsigned 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 | |
| 92 | unsigned int plat_arm_sgi_get_config_id(void) |
| 93 | { |
| 94 | return mmio_read_32(SID_REG_BASE + SID_SYSTEM_CFG_OFFSET); |
| 95 | } |
| 96 | |
| 97 | unsigned 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 Angadi | ccae8a1 | 2021-08-09 09:38:58 +0530 | [diff] [blame] | 104 | #if defined(IMAGE_BL31) |
Aditya Angadi | d61740b | 2020-11-19 18:05:33 +0530 | [diff] [blame] | 105 | void bl31_platform_setup(void) |
| 106 | { |
Aditya Angadi | ccae8a1 | 2021-08-09 09:38:58 +0530 | [diff] [blame] | 107 | #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 Angadi | d61740b | 2020-11-19 18:05:33 +0530 | [diff] [blame] | 137 | sgi_bl31_common_platform_setup(); |
Omkar Anand Kulkarni | 1f42599 | 2023-06-22 15:18:07 +0530 | [diff] [blame] | 138 | |
| 139 | #if RAS_FFH_SUPPORT |
| 140 | sgi_ras_platform_setup(&ras_config); |
| 141 | #endif |
Aditya Angadi | d61740b | 2020-11-19 18:05:33 +0530 | [diff] [blame] | 142 | } |
Aditya Angadi | ccae8a1 | 2021-08-09 09:38:58 +0530 | [diff] [blame] | 143 | #endif /* IMAGE_BL31 */ |