xref: /rk3399_ARM-atf/plat/socionext/synquacer/sq_bl2_setup.c (revision a8dc2595ab7e10dac8285d2c0b6da7ebbcd0edb0)
1 /*
2  * Copyright (c) 2022, Socionext Inc. All rights reserved.
3  * Copyright (c) 2025, Arm Limited and Contributors. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #include <errno.h>
9 
10 #include <common/bl_common.h>
11 #include <common/debug.h>
12 #include <common/desc_image_load.h>
13 #include <common/image_decompress.h>
14 #include <drivers/arm/pl011.h>
15 #include <drivers/io/io_storage.h>
16 #include <lib/xlat_tables/xlat_tables_v2.h>
17 #include <plat/common/platform.h>
18 
19 #include <platform_def.h>
20 #include <sq_common.h>
21 
22 static console_t console;
23 
24 void bl2_early_platform_setup2(u_register_t x0, u_register_t x1,
25 				  u_register_t x2, u_register_t x3)
26 {
27 	/* Initialize the console to provide early debug support */
28 	(void)console_pl011_register(PLAT_SQ_BOOT_UART_BASE,
29 			       PLAT_SQ_BOOT_UART_CLK_IN_HZ,
30 			       SQ_CONSOLE_BAUDRATE, &console);
31 	console_set_scope(&console, CONSOLE_FLAG_BOOT);
32 }
33 
34 void bl2_plat_arch_setup(void)
35 {
36 	int ret;
37 
38 	sq_mmap_setup(BL2_BASE, BL2_SIZE, NULL);
39 
40 	ret = sq_io_setup();
41 	if (ret) {
42 		ERROR("failed to setup io devices\n");
43 		plat_error_handler(ret);
44 	}
45 }
46 
47 void bl2_platform_setup(void)
48 {
49 }
50 
51 void plat_flush_next_bl_params(void)
52 {
53 	flush_bl_params_desc();
54 }
55 
56 bl_load_info_t *plat_get_bl_image_load_info(void)
57 {
58 	return get_bl_load_info_from_mem_params_desc();
59 }
60 
61 bl_params_t *plat_get_next_bl_params(void)
62 {
63 	return get_next_bl_params_from_mem_params_desc();
64 }
65 
66 void bl2_plat_preload_setup(void)
67 {
68 }
69 
70 int bl2_plat_handle_pre_image_load(unsigned int image_id)
71 {
72 	struct image_info *image_info;
73 
74 	image_info = sq_get_image_info(image_id);
75 
76 	return mmap_add_dynamic_region(image_info->image_base,
77 				      image_info->image_base,
78 				      image_info->image_max_size,
79 				      MT_MEMORY | MT_RW | MT_NS);
80 }
81 
82 int bl2_plat_handle_post_image_load(unsigned int image_id)
83 {
84 	return 0;
85 }
86