Chandni Cherukuri | 3aa09f7 | 2018-11-28 11:31:51 +0530 | [diff] [blame] | 1 | /* |
Rohit Mathew | 0029868 | 2024-02-10 22:12:12 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2024, 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> |
Rohit Mathew | a0dd307 | 2024-02-03 17:22:54 +0000 | [diff] [blame] | 11 | |
| 12 | #include <nrd_plat.h> |
| 13 | #include <nrd_soc_platform_def.h> |
Chandni Cherukuri | 3aa09f7 | 2018-11-28 11:31:51 +0530 | [diff] [blame] | 14 | |
Vijayenthiran Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 15 | #if defined(IMAGE_BL31) |
| 16 | static const mmap_region_t rdn1edge_dynamic_mmap[] = { |
| 17 | ARM_MAP_SHARED_RAM_REMOTE_CHIP(1), |
Rohit Mathew | aac0c3c | 2024-02-03 22:16:14 +0000 | [diff] [blame] | 18 | NRD_MAP_DEVICE_REMOTE_CHIP(1), |
Vijayenthiran Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 19 | SOC_CSS_MAP_DEVICE_REMOTE_CHIP(1) |
| 20 | }; |
| 21 | |
| 22 | static struct gic600_multichip_data rdn1e1_multichip_data __init = { |
| 23 | .rt_owner_base = PLAT_ARM_GICD_BASE, |
| 24 | .rt_owner = 0, |
Rohit Mathew | 644d9e2 | 2024-02-03 19:06:16 +0000 | [diff] [blame] | 25 | .chip_count = NRD_CHIP_COUNT, |
Vijayenthiran Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 26 | .chip_addrs = { |
| 27 | PLAT_ARM_GICD_BASE >> 16, |
Rohit Mathew | aac0c3c | 2024-02-03 22:16:14 +0000 | [diff] [blame] | 28 | (PLAT_ARM_GICD_BASE + NRD_REMOTE_CHIP_MEM_OFFSET(1)) >> 16 |
Vijayenthiran Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 29 | }, |
| 30 | .spi_ids = { |
Rohit Mathew | 0029868 | 2024-02-10 22:12:12 +0000 | [diff] [blame] | 31 | {PLAT_ARM_GICD_BASE, RDN1E1_CHIP0_SPI_START, |
| 32 | RDN1E1_CHIP0_SPI_END}, |
Varun Wadekar | 61286d2 | 2023-03-08 16:47:38 +0000 | [diff] [blame] | 33 | {0, 0, 0} |
Vijayenthiran Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 34 | } |
| 35 | }; |
| 36 | |
| 37 | static uintptr_t rdn1e1_multichip_gicr_frames[] = { |
| 38 | PLAT_ARM_GICR_BASE, /* Chip 0's GICR Base */ |
| 39 | PLAT_ARM_GICR_BASE + |
Rohit Mathew | aac0c3c | 2024-02-03 22:16:14 +0000 | [diff] [blame] | 40 | NRD_REMOTE_CHIP_MEM_OFFSET(1), /* Chip 1's GICR BASE */ |
Vijayenthiran Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 41 | UL(0) /* Zero Termination */ |
| 42 | }; |
| 43 | #endif /* IMAGE_BL31 */ |
| 44 | |
Rohit Mathew | 0ec6ed9 | 2024-02-03 18:39:10 +0000 | [diff] [blame] | 45 | unsigned int plat_arm_nrd_get_platform_id(void) |
Chandni Cherukuri | 3aa09f7 | 2018-11-28 11:31:51 +0530 | [diff] [blame] | 46 | { |
| 47 | return mmio_read_32(SID_REG_BASE + SID_SYSTEM_ID_OFFSET) |
| 48 | & SID_SYSTEM_ID_PART_NUM_MASK; |
| 49 | } |
| 50 | |
Rohit Mathew | 0ec6ed9 | 2024-02-03 18:39:10 +0000 | [diff] [blame] | 51 | unsigned int plat_arm_nrd_get_config_id(void) |
Chandni Cherukuri | 3aa09f7 | 2018-11-28 11:31:51 +0530 | [diff] [blame] | 52 | { |
| 53 | return mmio_read_32(SID_REG_BASE + SID_SYSTEM_CFG_OFFSET); |
| 54 | } |
Vijayenthiran Subramaniam | 2b4ad8d | 2019-09-23 19:32:32 +0530 | [diff] [blame] | 55 | |
Rohit Mathew | 0ec6ed9 | 2024-02-03 18:39:10 +0000 | [diff] [blame] | 56 | unsigned int plat_arm_nrd_get_multi_chip_mode(void) |
Vijayenthiran Subramaniam | 8af1843 | 2019-10-22 15:46:14 +0530 | [diff] [blame] | 57 | { |
| 58 | return (mmio_read_32(SID_REG_BASE + SID_NODE_ID_OFFSET) & |
| 59 | SID_MULTI_CHIP_MODE_MASK) >> SID_MULTI_CHIP_MODE_SHIFT; |
| 60 | } |
| 61 | |
Vijayenthiran Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 62 | /* |
| 63 | * IMAGE_BL31 macro is added to build bl31_platform_setup function only for BL31 |
| 64 | * because PLAT_XLAT_TABLES_DYNAMIC macro is set to build only for BL31 and not |
| 65 | * for other stages. |
| 66 | */ |
| 67 | #if defined(IMAGE_BL31) |
Vijayenthiran Subramaniam | 2b4ad8d | 2019-09-23 19:32:32 +0530 | [diff] [blame] | 68 | void bl31_platform_setup(void) |
| 69 | { |
Tony K Nadackal | a6e761c | 2022-12-07 20:30:33 +0000 | [diff] [blame] | 70 | unsigned int i; |
| 71 | int ret; |
Vijayenthiran Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 72 | |
Rohit Mathew | 0ec6ed9 | 2024-02-03 18:39:10 +0000 | [diff] [blame] | 73 | if (plat_arm_nrd_get_multi_chip_mode() == 0 && NRD_CHIP_COUNT > 1) { |
Vijayenthiran Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 74 | ERROR("Chip Count is set to %d but multi-chip mode not enabled\n", |
Rohit Mathew | 644d9e2 | 2024-02-03 19:06:16 +0000 | [diff] [blame] | 75 | NRD_CHIP_COUNT); |
Vijayenthiran Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 76 | panic(); |
Rohit Mathew | 0ec6ed9 | 2024-02-03 18:39:10 +0000 | [diff] [blame] | 77 | } else if (plat_arm_nrd_get_multi_chip_mode() == 1 && |
Rohit Mathew | 644d9e2 | 2024-02-03 19:06:16 +0000 | [diff] [blame] | 78 | NRD_CHIP_COUNT > 1) { |
Vijayenthiran Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 79 | INFO("Enabling support for multi-chip in RD-N1-Edge\n"); |
| 80 | |
| 81 | for (i = 0; i < ARRAY_SIZE(rdn1edge_dynamic_mmap); i++) { |
| 82 | ret = mmap_add_dynamic_region( |
| 83 | rdn1edge_dynamic_mmap[i].base_pa, |
| 84 | rdn1edge_dynamic_mmap[i].base_va, |
| 85 | rdn1edge_dynamic_mmap[i].size, |
| 86 | rdn1edge_dynamic_mmap[i].attr |
| 87 | ); |
| 88 | if (ret != 0) { |
| 89 | ERROR("Failed to add dynamic mmap entry\n"); |
| 90 | panic(); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | plat_arm_override_gicr_frames(rdn1e1_multichip_gicr_frames); |
| 95 | gic600_multichip_init(&rdn1e1_multichip_data); |
| 96 | } |
| 97 | |
Rohit Mathew | 0ec6ed9 | 2024-02-03 18:39:10 +0000 | [diff] [blame] | 98 | nrd_bl31_common_platform_setup(); |
Vijayenthiran Subramaniam | 2b4ad8d | 2019-09-23 19:32:32 +0530 | [diff] [blame] | 99 | } |
Vijayenthiran Subramaniam | c4e68a4 | 2019-10-28 14:49:48 +0530 | [diff] [blame] | 100 | #endif /* IMAGE_BL31 */ |