summaryrefslogtreecommitdiff
path: root/plat/fvp/plat_setup.c
blob: 145b8bd969b318ec89fb13df4edecd0495e62385 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/** @file
*
*  Copyright (c) 2013, ARM Limited. All rights reserved.
*
*  This program and the accompanying materials
*  are licensed and made available under the terms and conditions of the BSD License
*  which accompanies this distribution.  The full text of the license may be found at
*  http://opensource.org/licenses/bsd-license.php
*
*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*
**/

#include <arch_helpers.h>
#include <arm_gic.h>
#include <assert.h>
#include <console.h>
#include <debug.h>
#include <io_storage.h>
#include <irq.h>
#include <nvm.h>
#include <platform.h>
#include <psci.h>
#include <string.h>
#include <tftf.h>
#include "fvp_def.h"
#include "fvp_private.h"

#define CLUSTER_1_MASK  0x100
#define CORE_PRESENT	1

static struct {
  unsigned int cluster_id;
  unsigned int cpu_id;
} fvp_base_aemv8a_aemv8a_cores[] = {
  /* Cluster 0 */
  { 0, 0 },
  { 0, 1 },
  { 0, 2 },
  { 0, 3 },
  /* Cluster 1 */
  { 1, 0 },
  { 1, 1 },
  { 1, 2 },
  { 1, 3 },
};

/*
 * Table of regions to map using the MMU.
 */
static const mmap_region_t tftf_mmap[] = {
	{ DEVICE0_BASE,	DEVICE0_BASE, DEVICE0_SIZE,	MT_DEVICE | MT_RW | MT_NS },
	{ DEVICE1_BASE,	DEVICE1_BASE, DEVICE1_SIZE,	MT_DEVICE | MT_RW | MT_NS },
#if USE_NVM
	{ FLASH0_BASE,	FLASH0_BASE, FLASH0_SIZE,	MT_DEVICE | MT_RW | MT_NS },
	{ FLASH1_BASE,	FLASH1_BASE, FLASH1_SIZE,	MT_DEVICE | MT_RW | MT_NS },
#endif
	{ DRAM_BASE, DRAM_BASE, TFTF_BASE - DRAM_BASE,	MT_MEMORY | MT_RW | MT_NS },
	{ TFTF_BASE, TFTF_BASE, L2_BLOCK_SIZE,	MT_MEMORY | MT_RO | MT_NS },   /* Program text */
	{ TFTF_BASE + L2_BLOCK_SIZE, TFTF_BASE + L2_BLOCK_SIZE,
	( DRAM_BASE + DRAM_SIZE) - (TFTF_BASE + L2_BLOCK_SIZE), MT_MEMORY | MT_RW | MT_NS },
	{ 0xFFFFFFFF - DRAM_TZ_SIZE + 1, 0xFFFFFFFF - DRAM_TZ_SIZE + 1, DRAM_TZ_SIZE, MT_MEMORY | MT_RW | MT_NS },
	{ 0 }
};

const mmap_region_t *tftf_platform_get_mmap(void)
{
  return tftf_mmap;
}

unsigned int tftf_platform_core_pos_to_mpid(const unsigned int core_pos)
{
	unsigned int mpid = make_mpid(
			fvp_base_aemv8a_aemv8a_cores[core_pos].cluster_id,
			fvp_base_aemv8a_aemv8a_cores[core_pos].cpu_id);
	return mpid;
}

bool tftf_platform_is_core_pos_present(unsigned int core_pos)
{
	unsigned int mpidr;

	mpidr = tftf_platform_core_pos_to_mpid(core_pos);
	return plat_get_aff_state(MPIDR_AFFLVL0, mpidr) == PSCI_AFF_PRESENT;
}

void tftf_platform_setup(void)
{
#if USE_NVM
	int ret;
	ret = fvp_io_setup();
	if (ret != IO_SUCCESS)
		WARN("IO setup failed : 0x%x\n", ret);
#endif
	/*
	 * Hardcodes to base models, TFTF does not support legacy models
	 * as of now
	 */
	arm_gic_init(BASE_GICC_BASE, BASE_GICD_BASE, BASE_GICR_BASE);
	tftf_register_gic_id();
	arm_gic_setup();
	fvp_setup_topology();
}

void tftf_early_platform_setup(void)
{
	console_init(PL011_UART0_BASE, PL011_UART0_CLK_IN_HZ, PL011_BAUDRATE);
}

void tftf_plat_arch_setup(void)
{
	tftf_plat_configure_mmu();
}

/* Terminate the model by sending EOT (End Of Transmission) on the UART */
void tftf_platform_end(void)
{
	static const char ascii_eot = 4;
	console_putc(ascii_eot);
}