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

#include <assert.h>
#include <errno.h>
9

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

#include <arch.h>
#include <common/bl_common.h>
#include <common/debug.h>
#include <drivers/console.h>
#include <lib/mmio.h>
#include <lib/xlat_tables/xlat_mmu_helpers.h>
#include <plat/common/platform.h>
19
20
21
22
23

#include "uniphier.h"

static entry_point_info_t bl32_image_ep_info;
static entry_point_info_t bl33_image_ep_info;
24
static unsigned int uniphier_soc = UNIPHIER_SOC_UNKNOWN;
25
26
27
28
29
30
31

entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type)
{
	assert(sec_state_is_valid(type));
	return type == NON_SECURE ? &bl33_image_ep_info : &bl32_image_ep_info;
}

32
33
void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
				u_register_t arg2, u_register_t arg3)
34
{
35
36
	void *from_bl2;

37
	from_bl2 = (void *)arg0;
38

39
40
	bl_params_node_t *bl_params = ((bl_params_t *)from_bl2)->head;

41
42
43
44
45
	uniphier_soc = uniphier_get_soc_id();
	if (uniphier_soc == UNIPHIER_SOC_UNKNOWN)
		plat_error_handler(-ENOTSUP);

	uniphier_console_setup(uniphier_soc);
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

	while (bl_params) {
		if (bl_params->image_id == BL32_IMAGE_ID)
			bl32_image_ep_info = *bl_params->ep_info;

		if (bl_params->image_id == BL33_IMAGE_ID)
			bl33_image_ep_info = *bl_params->ep_info;

		bl_params = bl_params->next_params_info;
	}

	if (bl33_image_ep_info.pc == 0)
		panic();
}

61
62
63
64
65
static const uintptr_t uniphier_cntctl_base[] = {
	[UNIPHIER_SOC_LD11] = 0x60e00000,
	[UNIPHIER_SOC_LD20] = 0x60e00000,
	[UNIPHIER_SOC_PXS3] = 0x60e00000,
};
66
67
68

void bl31_platform_setup(void)
{
69
70
	uintptr_t cntctl_base;

71
	uniphier_cci_init(uniphier_soc);
72
73
74
	uniphier_cci_enable();

	/* Initialize the GIC driver, cpu and distributor interfaces */
75
	uniphier_gic_driver_init(uniphier_soc);
76
77
	uniphier_gic_init();

78
79
80
	assert(uniphier_soc < ARRAY_SIZE(uniphier_cntctl_base));
	cntctl_base = uniphier_cntctl_base[uniphier_soc];

81
	/* Enable and initialize the System level generic timer */
82
	mmio_write_32(cntctl_base + CNTCR_OFF, CNTCR_FCREQ(0U) | CNTCR_EN);
83
84

	uniphier_psci_init(uniphier_soc);
85
86
87
88
}

void bl31_plat_arch_setup(void)
{
89
	uniphier_mmap_setup();
90
91
	enable_mmu_el3(0);
}