2 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
9 #include <desc_image_load.h>
11 #include <io/io_storage.h>
12 #include <image_decompress.h>
14 #include <platform_def.h>
15 #ifdef UNIPHIER_DECOMPRESS_GZIP
16 #include <tf_gunzip.h>
18 #include <xlat_tables_v2.h>
22 #define BL2_END (unsigned long)(&__BL2_END__)
23 #define BL2_SIZE ((BL2_END) - (BL2_BASE))
25 static int uniphier_bl2_kick_scp
;
27 void bl2_el3_early_platform_setup(u_register_t x0
, u_register_t x1
,
28 u_register_t x2
, u_register_t x3
)
30 uniphier_console_setup();
33 static const struct mmap_region uniphier_bl2_mmap
[] = {
35 MAP_REGION_FLAT(UNIPHIER_SEC_DRAM_BASE
, UNIPHIER_SEC_DRAM_SIZE
,
36 MT_MEMORY
| MT_RW
| MT_SECURE
),
38 MAP_REGION_FLAT(UNIPHIER_NS_DRAM_BASE
, UNIPHIER_NS_DRAM_SIZE
,
39 MT_MEMORY
| MT_RW
| MT_NS
),
43 void bl2_el3_plat_arch_setup(void)
49 uniphier_mmap_setup(BL2_BASE
, BL2_SIZE
, uniphier_bl2_mmap
);
52 soc
= uniphier_get_soc_id();
53 if (soc
== UNIPHIER_SOC_UNKNOWN
) {
54 ERROR("unsupported SoC\n");
55 plat_error_handler(-ENOTSUP
);
58 ret
= uniphier_io_setup(soc
);
60 ERROR("failed to setup io devices\n");
61 plat_error_handler(ret
);
64 switch (uniphier_get_boot_master(soc
)) {
65 case UNIPHIER_BOOT_MASTER_THIS
:
66 INFO("Booting from this SoC\n");
69 case UNIPHIER_BOOT_MASTER_SCP
:
70 INFO("Booting from on-chip SCP\n");
71 if (uniphier_scp_is_running()) {
72 INFO("SCP is already running. SCP_BL2 load will be skipped.\n");
77 * SCP must be kicked every time even if it is already running
78 * because it polls this event after the reboot of the backend.
80 uniphier_bl2_kick_scp
= 1;
82 case UNIPHIER_BOOT_MASTER_EXT
:
83 INFO("Booting from external SCP\n");
87 plat_error_handler(-ENOTSUP
);
92 struct image_info
*image_info
;
94 image_info
= uniphier_get_image_info(SCP_BL2_IMAGE_ID
);
95 image_info
->h
.attr
|= IMAGE_ATTRIB_SKIP_LOADING
;
99 void bl2_platform_setup(void)
103 void plat_flush_next_bl_params(void)
105 flush_bl_params_desc();
108 bl_load_info_t
*plat_get_bl_image_load_info(void)
110 return get_bl_load_info_from_mem_params_desc();
113 bl_params_t
*plat_get_next_bl_params(void)
115 return get_next_bl_params_from_mem_params_desc();
118 void bl2_plat_preload_setup(void)
120 #ifdef UNIPHIER_DECOMPRESS_GZIP
121 image_decompress_init(UNIPHIER_IMAGE_BUF_BASE
,
122 UNIPHIER_IMAGE_BUF_SIZE
,
127 int bl2_plat_handle_pre_image_load(unsigned int image_id
)
129 #ifdef UNIPHIER_DECOMPRESS_GZIP
130 image_decompress_prepare(uniphier_get_image_info(image_id
));
135 int bl2_plat_handle_post_image_load(unsigned int image_id
)
137 #ifdef UNIPHIER_DECOMPRESS_GZIP
138 struct image_info
*image_info
;
141 image_info
= uniphier_get_image_info(image_id
);
143 if (!(image_info
->h
.attr
& IMAGE_ATTRIB_SKIP_LOADING
)) {
144 ret
= image_decompress(uniphier_get_image_info(image_id
));
150 if (image_id
== SCP_BL2_IMAGE_ID
&& uniphier_bl2_kick_scp
)
151 uniphier_scp_start();