blob: daf0c45d38cbdde30f37ed3bd0d06ccd586f4e80 [file] [log] [blame]
Masahiro Yamada574388c2016-09-03 11:37:40 +09001/*
Masahiro Yamada75bfecb2017-12-19 11:56:05 +09002 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
Masahiro Yamada574388c2016-09-03 11:37:40 +09003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <bl_common.h>
8#include <debug.h>
9#include <desc_image_load.h>
10#include <errno.h>
11#include <io/io_storage.h>
12#include <platform.h>
13#include <platform_def.h>
14#include <xlat_tables_v2.h>
15
16#include "uniphier.h"
17
Masahiro Yamada574388c2016-09-03 11:37:40 +090018static int uniphier_bl2_kick_scp;
19
Masahiro Yamada75bfecb2017-12-19 11:56:05 +090020void bl2_el3_early_platform_setup(u_register_t x0, u_register_t x1,
21 u_register_t x2, u_register_t x3)
Masahiro Yamada574388c2016-09-03 11:37:40 +090022{
Masahiro Yamada574388c2016-09-03 11:37:40 +090023 uniphier_console_setup();
24}
25
26static const struct mmap_region uniphier_bl2_mmap[] = {
27 /* for SCP, BL33 */
28 MAP_REGION_FLAT(UNIPHIER_NS_DRAM_BASE, UNIPHIER_NS_DRAM_SIZE,
29 MT_MEMORY | MT_RW | MT_NS),
30 { .size = 0 },
31};
32
Masahiro Yamada75bfecb2017-12-19 11:56:05 +090033void bl2_el3_plat_arch_setup(void)
Masahiro Yamada574388c2016-09-03 11:37:40 +090034{
35 unsigned int soc;
36 int skip_scp = 0;
37 int ret;
38
39 uniphier_mmap_setup(UNIPHIER_SEC_DRAM_BASE, UNIPHIER_SEC_DRAM_SIZE,
40 uniphier_bl2_mmap);
Masahiro Yamada75bfecb2017-12-19 11:56:05 +090041 enable_mmu_el3(0);
Masahiro Yamada574388c2016-09-03 11:37:40 +090042
43 soc = uniphier_get_soc_id();
44 if (soc == UNIPHIER_SOC_UNKNOWN) {
45 ERROR("unsupported SoC\n");
46 plat_error_handler(-ENOTSUP);
47 }
48
49 ret = uniphier_io_setup(soc);
50 if (ret) {
51 ERROR("failed to setup io devices\n");
52 plat_error_handler(ret);
53 }
54
55 switch (uniphier_get_boot_master(soc)) {
56 case UNIPHIER_BOOT_MASTER_THIS:
57 INFO("Booting from this SoC\n");
58 skip_scp = 1;
59 break;
60 case UNIPHIER_BOOT_MASTER_SCP:
61 INFO("Booting from on-chip SCP\n");
62 if (uniphier_scp_is_running()) {
63 INFO("SCP is already running. SCP_BL2 load will be skipped.\n");
64 skip_scp = 1;
65 }
66
67 /*
68 * SCP must be kicked every time even if it is already running
69 * because it polls this event after the reboot of the backend.
70 */
71 uniphier_bl2_kick_scp = 1;
72 break;
73 case UNIPHIER_BOOT_MASTER_EXT:
74 INFO("Booting from external SCP\n");
75 skip_scp = 1;
76 break;
77 default:
78 plat_error_handler(-ENOTSUP);
79 }
80
81 if (!skip_scp) {
82 ret = uniphier_check_image(SCP_BL2_IMAGE_ID);
83 if (ret) {
84 WARN("SCP_BL2 image not found. SCP_BL2 load will be skipped.\n");
85 WARN("You must setup SCP by other means.\n");
86 skip_scp = 1;
87 uniphier_bl2_kick_scp = 0;
88 }
89 }
90
91 if (skip_scp)
92 uniphier_image_descs_fixup();
93}
94
95void bl2_platform_setup(void)
96{
97}
98
99void plat_flush_next_bl_params(void)
100{
101 flush_bl_params_desc();
102}
103
104bl_load_info_t *plat_get_bl_image_load_info(void)
105{
106 return get_bl_load_info_from_mem_params_desc();
107}
108
109bl_params_t *plat_get_next_bl_params(void)
110{
111 return get_next_bl_params_from_mem_params_desc();
112}
113
114int bl2_plat_handle_post_image_load(unsigned int image_id)
115{
116 if (image_id == SCP_BL2_IMAGE_ID && uniphier_bl2_kick_scp)
117 uniphier_scp_start();
118
119 return 0;
120}