blob: dc8465ed67fe95b13d9bc372783c65a87b87515b [file] [log] [blame]
John Tsichritzisd3255542018-10-10 13:13:43 +01001/*
John Tsichritzis2eafdf22019-02-25 15:31:35 +00002 * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
John Tsichritzisd3255542018-10-10 13:13:43 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <assert.h>
John Tsichritzis2eafdf22019-02-25 15:31:35 +00009#include <drivers/console.h>
10#include <drivers/arm/gic_v2.h>
John Tsichritzisd3255542018-10-10 13:13:43 +010011#include <platform.h>
12#include <platform_def.h>
13
14
15static const mmap_region_t mmap[] = {
John Tsichritzis317632b2018-10-22 15:54:44 +010016 MAP_REGION_FLAT(DRAM_BASE + TFTF_NVM_OFFSET, TFTF_NVM_SIZE, MT_MEMORY | MT_RW | MT_NS),
17 MAP_REGION_FLAT(GIC_BASE, GIC_SIZE, MT_DEVICE | MT_RW | MT_NS),
18 MAP_REGION_FLAT(SP805_WDOG_BASE, SP805_WDOG_SIZE, MT_DEVICE | MT_RW | MT_NS),
19 MAP_REGION_FLAT(SYS_CNT_BASE1, SYS_CNT_SIZE, MT_DEVICE | MT_RW | MT_NS),
20 MAP_REGION_FLAT(CRASH_CONSOLE_BASE, CRASH_CONSOLE_SIZE, MT_DEVICE | MT_RW | MT_NS),
John Tsichritzisd3255542018-10-10 13:13:43 +010021 {0}
22};
23
24/* Power Domain Tree Descriptor array */
25const unsigned char hikey960_power_domain_tree_desc[] = {
26 /* Number of root nodes */
27 1,
28 /* Number of clusters */
29 PLATFORM_CLUSTER_COUNT,
30 /* Number of children for the first cluster node */
John Tsichritzise2236992018-10-25 10:05:39 +010031 PLATFORM_CORE_COUNT_PER_CLUSTER
32 /*
33 * TODO: Re-enable this code once power management issues on Hikey [1]
34 * are resolved.
35 * [1] https://bugs.96boards.org/show_bug.cgi?id=783
36 */
John Tsichritzisd3255542018-10-10 13:13:43 +010037 /* Number of children for the second cluster node */
John Tsichritzise2236992018-10-25 10:05:39 +010038 /* PLATFORM_CORE_COUNT_PER_CLUSTER, */
John Tsichritzisd3255542018-10-10 13:13:43 +010039};
40
41
42const unsigned char *tftf_plat_get_pwr_domain_tree_desc(void)
43{
44 return hikey960_power_domain_tree_desc;
45}
46
47/*
48 * Generate the MPID from the core position.
49 */
50uint64_t tftf_plat_get_mpidr(unsigned int core_pos)
51{
52 uint64_t mpid;
53 unsigned int coreid, clusterid;
54
55 assert(core_pos < PLATFORM_CORE_COUNT);
56
57 coreid = core_pos % PLATFORM_CORE_COUNT_PER_CLUSTER;
58 clusterid = core_pos / PLATFORM_CORE_COUNT_PER_CLUSTER;
59
60 if (clusterid >= PLATFORM_CLUSTER_COUNT)
61 return INVALID_MPID;
62
63 mpid = (coreid << MPIDR_AFF0_SHIFT) | (clusterid << MPIDR_AFF1_SHIFT);
64
65 return mpid;
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,
76 PL011_BAUDRATE);
77}
78
79void tftf_platform_setup(void)
80{
81 gicv2_init(GICC_REG_BASE, GICD_REG_BASE);
John Tsichritzis0541db12018-10-22 16:34:39 +010082 gicv2_setup_distif();
John Tsichritzisd3255542018-10-10 13:13:43 +010083 gicv2_probe_gic_cpu_id();
84 gicv2_setup_cpuif();
85}
86
87const mmap_region_t *tftf_platform_get_mmap(void)
88{
89 return mmap;
90}