Maheedhar Bollapalli | 7dbb6c1 | 2024-10-04 03:22:30 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2024, Advanced Micro Devices, Inc. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <assert.h> |
| 8 | |
| 9 | #include <arch.h> |
| 10 | #include <drivers/arm/arm_gic.h> |
| 11 | #include <drivers/console.h> |
| 12 | #include <platform.h> |
| 13 | #include <tftf_lib.h> |
| 14 | |
| 15 | #include <platform_def.h> |
| 16 | #include <util.h> |
| 17 | |
| 18 | static const struct { |
| 19 | unsigned int cluster_id; |
| 20 | unsigned int cpu_id; |
| 21 | } versal2_cores[PLATFORM_CORE_COUNT] = { |
| 22 | CLUSTER_DEF(0), |
| 23 | CLUSTER_DEF(1), |
| 24 | CLUSTER_DEF(2), |
| 25 | CLUSTER_DEF(3) |
| 26 | }; |
| 27 | |
| 28 | |
| 29 | static const mmap_region_t mmap[] = { |
| 30 | MAP_REGION_FLAT(DRAM_BASE + TFTF_NVM_OFFSET, TFTF_NVM_SIZE, MT_MEMORY | MT_RW | MT_NS), |
| 31 | MAP_REGION_FLAT(GIC_BASE, GIC_SIZE, MT_DEVICE | MT_RW | MT_NS), |
| 32 | MAP_REGION_FLAT(CRASH_CONSOLE_BASE, CRASH_CONSOLE_SIZE, MT_DEVICE | MT_RW | MT_NS), |
| 33 | MAP_REGION_FLAT(TTC_BASE, TTC_SIZE, MT_DEVICE | MT_RW | MT_NS), |
| 34 | MAP_REGION_FLAT(LPD_IOU_SLCR, LPD_IOU_SLCR_SIZE, MT_DEVICE | MT_RW | MT_NS), |
| 35 | {0} |
| 36 | }; |
| 37 | |
| 38 | /* Power Domain Tree Descriptor array */ |
| 39 | const unsigned char versal2_pwr_tree_desc[] = { |
| 40 | /* Number of root nodes */ |
| 41 | 1, |
| 42 | /* Number of clusters */ |
| 43 | PLATFORM_CLUSTER_COUNT, |
| 44 | /* Number of children for the first cluster node */ |
| 45 | PLATFORM_CORE_COUNT_PER_CLUSTER, |
| 46 | /* Number of children for the second cluster node */ |
| 47 | PLATFORM_CORE_COUNT_PER_CLUSTER, |
| 48 | /* Number of children for the third cluster node */ |
| 49 | PLATFORM_CORE_COUNT_PER_CLUSTER, |
| 50 | /* Number of children for the fourth cluster node */ |
| 51 | PLATFORM_CORE_COUNT_PER_CLUSTER |
| 52 | }; |
| 53 | |
| 54 | |
| 55 | const unsigned char *tftf_plat_get_pwr_domain_tree_desc(void) |
| 56 | { |
| 57 | return versal2_pwr_tree_desc; |
| 58 | } |
| 59 | |
| 60 | /* |
| 61 | * Generate the MPID from the core position. |
| 62 | */ |
| 63 | uint64_t tftf_plat_get_mpidr(unsigned int core_pos) |
| 64 | { |
| 65 | assert(core_pos < PLATFORM_CORE_COUNT); |
| 66 | |
| 67 | return (uint64_t)make_mpid(versal2_cores[core_pos].cluster_id, |
| 68 | versal2_cores[core_pos].cpu_id); |
| 69 | } |
| 70 | |
| 71 | void tftf_plat_arch_setup(void) |
| 72 | { |
| 73 | tftf_plat_configure_mmu(); |
| 74 | } |
| 75 | |
| 76 | void tftf_early_platform_setup(void) |
| 77 | { |
| 78 | console_init(CRASH_CONSOLE_BASE, PL011_UART_CLK_IN_HZ, PL011_BAUDRATE); |
| 79 | } |
| 80 | |
| 81 | void tftf_platform_setup(void) |
| 82 | { |
| 83 | arm_gic_init(GICC_REG_BASE, GICD_REG_BASE, GICR_REG_BASE); |
| 84 | arm_gic_setup_global(); |
| 85 | arm_gic_setup_local(); |
| 86 | } |
| 87 | |
| 88 | const mmap_region_t *tftf_platform_get_mmap(void) |
| 89 | { |
| 90 | return mmap; |
| 91 | } |