arm_tsp_setup.c 2.46 KB
Newer Older
1
/*
Paul Beesley's avatar
Paul Beesley committed
2
 * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved.
3
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
5
6
 */

7
#include <assert.h>
8

9
#include <platform_def.h>
10
11
12
13
14
15
16
17

#include <bl32/tsp/platform_tsp.h>
#include <common/bl_common.h>
#include <common/debug.h>
#include <drivers/arm/pl011.h>
#include <drivers/console.h>

#include <plat_arm.h>
18
19
20
21
22
23
24
25

#define BL32_END (unsigned long)(&__BL32_END__)

/* Weak definitions may be overridden in specific ARM standard platform */
#pragma weak tsp_early_platform_setup
#pragma weak tsp_platform_setup
#pragma weak tsp_plat_arch_setup

26
27
28
29
#define MAP_BL_TSP_TOTAL	MAP_REGION_FLAT(			\
					BL32_BASE,			\
					BL32_END - BL32_BASE,		\
					MT_MEMORY | MT_RW | MT_SECURE)
30
31
32
33

/*******************************************************************************
 * Initialize the UART
 ******************************************************************************/
34
35
36
37
#if MULTI_CONSOLE_API
static console_pl011_t arm_tsp_runtime_console;
#endif

38
39
void arm_tsp_early_platform_setup(void)
{
40
#if MULTI_CONSOLE_API
41
42
43
44
	/*
	 * Initialize a different console than already in use to display
	 * messages from TSP
	 */
45
46
47
48
49
50
51
52
53
54
	int rc = console_pl011_register(PLAT_ARM_TSP_UART_BASE,
					PLAT_ARM_TSP_UART_CLK_IN_HZ,
					ARM_CONSOLE_BAUDRATE,
					&arm_tsp_runtime_console);
	if (rc == 0)
		panic();

	console_set_scope(&arm_tsp_runtime_console.console,
			  CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME);
#else
55
56
	console_init(PLAT_ARM_TSP_UART_BASE, PLAT_ARM_TSP_UART_CLK_IN_HZ,
			ARM_CONSOLE_BAUDRATE);
57
#endif /* MULTI_CONSOLE_API */
58
59
60
61
62
63
64
65
66
67
68
69
}

void tsp_early_platform_setup(void)
{
	arm_tsp_early_platform_setup();
}

/*******************************************************************************
 * Perform platform specific setup placeholder
 ******************************************************************************/
void tsp_platform_setup(void)
{
70
	plat_arm_gic_driver_init();
71
72
73
74
75
76
77
78
79
}

/*******************************************************************************
 * Perform the very early platform specific architectural setup here. At the
 * moment this is only intializes the MMU
 ******************************************************************************/
void tsp_plat_arch_setup(void)
{
#if USE_COHERENT_MEM
Paul Beesley's avatar
Paul Beesley committed
80
	/* Ensure ARM platforms don't use coherent memory in TSP */
81
	assert((BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE) == 0U);
82
#endif
83
84
85

	const mmap_region_t bl_regions[] = {
		MAP_BL_TSP_TOTAL,
86
		ARM_MAP_BL_RO,
87
88
89
		{0}
	};

90
	setup_page_tables(bl_regions, plat_arm_get_mmap());
91
	enable_mmu_el1(0);
92
}