uniphier_xlat_setup.c 1.63 KB
Newer Older
1
/*
2
 * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved.
3
4
5
6
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

7
8
#include <assert.h>

9
#include <platform_def.h>
10
11
12

#include <common/debug.h>
#include <lib/xlat_tables/xlat_tables_v2.h>
13

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "uniphier.h"

struct uniphier_reg_region {
	uintptr_t base;
	size_t size;
};

static const struct uniphier_reg_region uniphier_reg_region[] = {
	[UNIPHIER_SOC_LD11] = {
		.base = 0x50000000UL,
		.size = 0x20000000UL,
	},
	[UNIPHIER_SOC_LD20] = {
		.base = 0x50000000UL,
		.size = 0x20000000UL,
	},
	[UNIPHIER_SOC_PXS3] = {
		.base = 0x50000000UL,
		.size = 0x20000000UL,
	},
};
35

36
void uniphier_mmap_setup(unsigned int soc)
37
38
{
	VERBOSE("Trusted RAM seen by this BL image: %p - %p\n",
39
40
41
		(void *)BL_CODE_BASE, (void *)BL_END);
	mmap_add_region(BL_CODE_BASE, BL_CODE_BASE,
			round_up(BL_END, PAGE_SIZE) - BL_CODE_BASE,
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
			MT_MEMORY | MT_RW | MT_SECURE);

	/* remap the code section */
	VERBOSE("Code region: %p - %p\n",
		(void *)BL_CODE_BASE, (void *)BL_CODE_END);
	mmap_add_region(BL_CODE_BASE, BL_CODE_BASE,
			round_up(BL_CODE_END, PAGE_SIZE) - BL_CODE_BASE,
			MT_CODE | MT_SECURE);

	/* remap the coherent memory region */
	VERBOSE("Coherent region: %p - %p\n",
		(void *)BL_COHERENT_RAM_BASE, (void *)BL_COHERENT_RAM_END);
	mmap_add_region(BL_COHERENT_RAM_BASE, BL_COHERENT_RAM_BASE,
			BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE,
			MT_DEVICE | MT_RW | MT_SECURE);

	/* register region */
59
60
61
62
	assert(soc < ARRAY_SIZE(uniphier_reg_region));
	mmap_add_region(uniphier_reg_region[soc].base,
			uniphier_reg_region[soc].base,
			uniphier_reg_region[soc].size,
63
64
65
66
			MT_DEVICE | MT_RW | MT_SECURE);

	init_xlat_tables();
}