blob: 40fe2c4f503606c048360319fe28e960938da8a4 [file] [log] [blame]
Prasad Kummari56f41cd2023-08-25 11:59:30 +05301/*
2 * Copyright (c) 2023, 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
18static const struct {
19 unsigned int cluster_id;
20 unsigned int cpu_id;
21} versal_net_cores[PLATFORM_CORE_COUNT] = {
22 CLUSTER_DEF(0),
23 CLUSTER_DEF(1),
24 CLUSTER_DEF(2),
25 CLUSTER_DEF(3)
26};
27
28
29static 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 */
39const unsigned char versal_net_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 PLATFORM_CORE_COUNT_PER_CLUSTER,
47 PLATFORM_CORE_COUNT_PER_CLUSTER,
48 PLATFORM_CORE_COUNT_PER_CLUSTER
49};
50
51
52const unsigned char *tftf_plat_get_pwr_domain_tree_desc(void)
53{
54 return versal_net_pwr_tree_desc;
55}
56
57/*
58 * Generate the MPID from the core position.
59 */
60uint64_t tftf_plat_get_mpidr(unsigned int core_pos)
61{
62 assert(core_pos < PLATFORM_CORE_COUNT);
63
64 return (uint64_t)make_mpid(versal_net_cores[core_pos].cluster_id,
65 versal_net_cores[core_pos].cpu_id);
66}
67
68void tftf_plat_arch_setup(void)
69{
70 tftf_plat_configure_mmu();
71}
72
73void tftf_early_platform_setup(void)
74{
75 console_init(CRASH_CONSOLE_BASE, PL011_UART_CLK_IN_HZ, PL011_BAUDRATE);
76}
77
78void tftf_platform_setup(void)
79{
80 arm_gic_init(GICC_REG_BASE, GICD_REG_BASE, GICR_REG_BASE);
81 arm_gic_setup_global();
82 arm_gic_setup_local();
83}
84
85const mmap_region_t *tftf_platform_get_mmap(void)
86{
87 return mmap;
88}