blob: 440e6aa1130e4a9633d962e637df33ecdba31202 [file] [log] [blame]
Masahiro Yamada574388c2016-09-03 11:37:40 +09001/*
Masahiro Yamadaca8b80e2019-07-02 22:03:16 +09002 * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
Masahiro Yamada574388c2016-09-03 11:37:40 +09003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Masahiro Yamada574388c2016-09-03 11:37:40 +09007#include <assert.h>
Masahiro Yamada574388c2016-09-03 11:37:40 +09008#include <errno.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00009
Masahiro Yamada574388c2016-09-03 11:37:40 +090010#include <platform_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000011
12#include <arch.h>
13#include <common/bl_common.h>
14#include <common/debug.h>
15#include <drivers/console.h>
16#include <lib/mmio.h>
17#include <lib/xlat_tables/xlat_mmu_helpers.h>
18#include <plat/common/platform.h>
Masahiro Yamada574388c2016-09-03 11:37:40 +090019
20#include "uniphier.h"
21
Masahiro Yamada574388c2016-09-03 11:37:40 +090022#define BL31_SIZE ((BL31_END) - (BL31_BASE))
23
24static entry_point_info_t bl32_image_ep_info;
25static entry_point_info_t bl33_image_ep_info;
26
27entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type)
28{
29 assert(sec_state_is_valid(type));
30 return type == NON_SECURE ? &bl33_image_ep_info : &bl32_image_ep_info;
31}
32
Antonio Nino Diazcb9c5a72018-09-24 17:16:35 +010033void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
34 u_register_t arg2, u_register_t arg3)
Masahiro Yamada574388c2016-09-03 11:37:40 +090035{
Antonio Nino Diazcb9c5a72018-09-24 17:16:35 +010036 void *from_bl2;
37
Masahiro Yamada501b88b2019-07-26 20:04:28 +090038 from_bl2 = (void *)arg0;
Antonio Nino Diazcb9c5a72018-09-24 17:16:35 +010039
Masahiro Yamada574388c2016-09-03 11:37:40 +090040 bl_params_node_t *bl_params = ((bl_params_t *)from_bl2)->head;
41
42 uniphier_console_setup();
43
44 while (bl_params) {
45 if (bl_params->image_id == BL32_IMAGE_ID)
46 bl32_image_ep_info = *bl_params->ep_info;
47
48 if (bl_params->image_id == BL33_IMAGE_ID)
49 bl33_image_ep_info = *bl_params->ep_info;
50
51 bl_params = bl_params->next_params_info;
52 }
53
54 if (bl33_image_ep_info.pc == 0)
55 panic();
56}
57
58#define UNIPHIER_SYS_CNTCTL_BASE 0x60E00000
59
60void bl31_platform_setup(void)
61{
62 unsigned int soc;
63
64 soc = uniphier_get_soc_id();
65 if (soc == UNIPHIER_SOC_UNKNOWN) {
66 ERROR("unsupported SoC\n");
67 plat_error_handler(-ENOTSUP);
68 }
69
70 uniphier_cci_init(soc);
71 uniphier_cci_enable();
72
73 /* Initialize the GIC driver, cpu and distributor interfaces */
74 uniphier_gic_driver_init(soc);
75 uniphier_gic_init();
76
77 /* Enable and initialize the System level generic timer */
78 mmio_write_32(UNIPHIER_SYS_CNTCTL_BASE + CNTCR_OFF,
Masahiro Yamada501b88b2019-07-26 20:04:28 +090079 CNTCR_FCREQ(0U) | CNTCR_EN);
Masahiro Yamada574388c2016-09-03 11:37:40 +090080}
81
82void bl31_plat_arch_setup(void)
83{
84 uniphier_mmap_setup(BL31_BASE, BL31_SIZE, NULL);
85 enable_mmu_el3(0);
86}