blob: 35589ab4aa8cd87fa757a1f1d788334a8d41d5c6 [file] [log] [blame]
Akshay Belsare52aefd92023-04-04 10:26:40 +05301/*
2 * Copyright (c) 2022-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
17static const struct {
18 unsigned int cluster_id;
19 unsigned int cpu_id;
20} versal_cores[PLATFORM_CORE_COUNT] = {
21 { 0, 0 },
22 { 0, 1 }
23};
24
25static const mmap_region_t mmap[] = {
26 MAP_REGION_FLAT(DRAM_BASE + TFTF_NVM_OFFSET, TFTF_NVM_SIZE, MT_MEMORY | MT_RW | MT_NS),
27 MAP_REGION_FLAT(GIC_BASE, GIC_SIZE, MT_DEVICE | MT_RW | MT_NS),
28 MAP_REGION_FLAT(CRASH_CONSOLE_BASE, CRASH_CONSOLE_SIZE, MT_DEVICE | MT_RW | MT_NS),
29 MAP_REGION_FLAT(TTC_BASE, TTC_SIZE, MT_DEVICE | MT_RW | MT_NS),
30 MAP_REGION_FLAT(LPD_IOU_SLCR, LPD_IOU_SLCR_SIZE, MT_DEVICE | MT_RW | MT_NS),
31 {0}
32};
33
34/* Power Domain Tree Descriptor array */
35const unsigned char versal_pwr_tree_desc[] = {
36 /* Number of root nodes */
37 1,
38 /* Number of clusters */
39 PLATFORM_CLUSTER_COUNT,
40 /* Number of children for the first cluster node */
41 PLATFORM_CORE_COUNT_PER_CLUSTER
42};
43
44
45const unsigned char *tftf_plat_get_pwr_domain_tree_desc(void)
46{
47 return versal_pwr_tree_desc;
48}
49
50/*
51 * Generate the MPID from the core position.
52 */
53uint64_t tftf_plat_get_mpidr(unsigned int core_pos)
54{
55 assert(core_pos < PLATFORM_CORE_COUNT);
56
57 return (uint64_t)make_mpid(versal_cores[core_pos].cluster_id,
58 versal_cores[core_pos].cpu_id);
59}
60
61void tftf_plat_arch_setup(void)
62{
63 tftf_plat_configure_mmu();
64}
65
66void tftf_early_platform_setup(void)
67{
68 console_init(CRASH_CONSOLE_BASE, PL011_UART_CLK_IN_HZ, PL011_BAUDRATE);
69}
70
71void tftf_platform_setup(void)
72{
73 arm_gic_init(GICC_REG_BASE, GICD_REG_BASE, GICR_REG_BASE);
74 arm_gic_setup_global();
75 arm_gic_setup_local();
76}
77
78const mmap_region_t *tftf_platform_get_mmap(void)
79{
80 return mmap;
81}