Chandni Cherukuri | 3aa09f7 | 2018-11-28 11:31:51 +0530 | [diff] [blame] | 1 | /* |
Vijayenthiran Subramaniam | 2b4ad8d | 2019-09-23 19:32:32 +0530 | [diff] [blame] | 2 | * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved. |
Chandni Cherukuri | 3aa09f7 | 2018-11-28 11:31:51 +0530 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Vijayenthiran Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 7 | #include <common/debug.h> |
| 8 | #include <drivers/arm/gic600_multichip.h> |
| 9 | #include <plat/arm/common/plat_arm.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | #include <plat/common/platform.h> |
Aditya Angadi | ce79bca | 2020-11-18 08:32:30 +0530 | [diff] [blame] | 11 | #include <sgi_soc_platform_def.h> |
Vijayenthiran Subramaniam | 2b4ad8d | 2019-09-23 19:32:32 +0530 | [diff] [blame] | 12 | #include <sgi_plat.h> |
Chandni Cherukuri | 3aa09f7 | 2018-11-28 11:31:51 +0530 | [diff] [blame] | 13 | |
Vijayenthiran Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 14 | #if defined(IMAGE_BL31) |
| 15 | static 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 | |
| 21 | static 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 | |
| 35 | static 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 Cherukuri | 3aa09f7 | 2018-11-28 11:31:51 +0530 | [diff] [blame] | 43 | unsigned 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 | |
| 49 | unsigned int plat_arm_sgi_get_config_id(void) |
| 50 | { |
| 51 | return mmio_read_32(SID_REG_BASE + SID_SYSTEM_CFG_OFFSET); |
| 52 | } |
Vijayenthiran Subramaniam | 2b4ad8d | 2019-09-23 19:32:32 +0530 | [diff] [blame] | 53 | |
Vijayenthiran Subramaniam | 8af1843 | 2019-10-22 15:46:14 +0530 | [diff] [blame] | 54 | unsigned 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 Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 60 | /* |
| 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 Subramaniam | 2b4ad8d | 2019-09-23 19:32:32 +0530 | [diff] [blame] | 66 | void bl31_platform_setup(void) |
| 67 | { |
Vijayenthiran Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 68 | 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 Subramaniam | 2b4ad8d | 2019-09-23 19:32:32 +0530 | [diff] [blame] | 95 | sgi_bl31_common_platform_setup(); |
| 96 | } |
Vijayenthiran Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 97 | #endif /* IMAGE_BL31 */ |