blob: 59db3d85c74d6b4aea0869a79bac37806e30e83d [file] [log] [blame]
Tony Xief6118cc2016-01-15 17:17:32 +08001/*
Julius Werner65d52672019-05-24 20:37:58 -07002 * Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved.
Tony Xief6118cc2016-01-15 17:17:32 +08003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Tony Xief6118cc2016-01-15 17:17:32 +08005 */
6
Tony Xief6118cc2016-01-15 17:17:32 +08007#include <assert.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
Tony Xief6118cc2016-01-15 17:17:32 +08009#include <platform_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010
11#include <common/bl_common.h>
12#include <common/debug.h>
Julius Wernerf1d230c2019-05-30 16:57:15 -070013#include <common/desc_image_load.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000014#include <drivers/console.h>
15#include <drivers/generic_delay_timer.h>
16#include <drivers/ti/uart/uart_16550.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000017#include <lib/mmio.h>
18#include <plat_private.h>
19#include <plat/common/platform.h>
Tony Xief6118cc2016-01-15 17:17:32 +080020
Tony Xief6118cc2016-01-15 17:17:32 +080021static entry_point_info_t bl32_ep_info;
22static entry_point_info_t bl33_ep_info;
23
24/*******************************************************************************
25 * Return a pointer to the 'entry_point_info' structure of the next image for
26 * the security state specified. BL33 corresponds to the non-secure image type
27 * while BL32 corresponds to the secure image type. A NULL pointer is returned
28 * if the image does not exist.
29 ******************************************************************************/
30entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type)
31{
32 entry_point_info_t *next_image_info;
33
34 next_image_info = (type == NON_SECURE) ? &bl33_ep_info : &bl32_ep_info;
Julius Wernerf1d230c2019-05-30 16:57:15 -070035 assert(next_image_info->h.type == PARAM_EP);
Tony Xief6118cc2016-01-15 17:17:32 +080036
37 /* None of the images on this platform can have 0x0 as the entrypoint */
38 if (next_image_info->pc)
39 return next_image_info;
40 else
41 return NULL;
42}
43
tony.xie54973e72017-04-24 16:18:10 +080044#pragma weak params_early_setup
Julius Werner65d52672019-05-24 20:37:58 -070045void params_early_setup(u_register_t plat_param_from_bl2)
tony.xie54973e72017-04-24 16:18:10 +080046{
47}
48
Tony Xief6118cc2016-01-15 17:17:32 +080049/*******************************************************************************
50 * Perform any BL3-1 early platform setup. Here is an opportunity to copy
John Tsichritzisd653d332018-09-14 10:34:57 +010051 * parameters passed by the calling EL (S-EL1 in BL2 & EL3 in BL1) before they
Tony Xief6118cc2016-01-15 17:17:32 +080052 * are lost (potentially). This needs to be done before the MMU is initialized
53 * so that the memory layout can be used while creating page tables.
54 * BL2 has flushed this information to memory, so we are guaranteed to pick up
55 * good data.
56 ******************************************************************************/
Antonio Nino Diaz58230902018-09-24 17:16:20 +010057void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
58 u_register_t arg2, u_register_t arg3)
Tony Xief6118cc2016-01-15 17:17:32 +080059{
Andre Przywara98b5a112020-01-25 00:58:35 +000060 static console_t console;
Julius Wernerf39c8062017-08-02 16:31:04 -070061
Julius Werner65d52672019-05-24 20:37:58 -070062 params_early_setup(arg1);
Julius Wernerc7087782017-06-09 15:22:44 -070063
Heiko Stuebner40b3cb12019-08-05 16:40:35 +020064 if (rockchip_get_uart_base() != 0)
65 console_16550_register(rockchip_get_uart_base(),
66 rockchip_get_uart_clock(),
67 rockchip_get_uart_baudrate(), &console);
Tony Xief6118cc2016-01-15 17:17:32 +080068
69 VERBOSE("bl31_setup\n");
70
Julius Wernerf1d230c2019-05-30 16:57:15 -070071 bl31_params_parse_helper(arg0, &bl32_ep_info, &bl33_ep_info);
Tony Xief6118cc2016-01-15 17:17:32 +080072}
73
74/*******************************************************************************
75 * Perform any BL3-1 platform setup code
76 ******************************************************************************/
77void bl31_platform_setup(void)
78{
Antonio Nino Diaz2361fcc2016-05-05 15:25:02 +010079 generic_delay_timer_init();
Tony Xief6118cc2016-01-15 17:17:32 +080080 plat_rockchip_soc_init();
81
82 /* Initialize the gic cpu and distributor interfaces */
83 plat_rockchip_gic_driver_init();
84 plat_rockchip_gic_init();
85 plat_rockchip_pmu_init();
86}
87
88/*******************************************************************************
89 * Perform the very early platform specific architectural setup here. At the
Elyes Haouas2be03c02023-02-13 09:14:48 +010090 * moment this is only initializes the mmu in a quick and dirty way.
Tony Xief6118cc2016-01-15 17:17:32 +080091 ******************************************************************************/
92void bl31_plat_arch_setup(void)
93{
94 plat_cci_init();
95 plat_cci_enable();
Heiko Stuebnerabcff552019-05-29 12:03:38 +020096 plat_configure_mmu_el3(BL_CODE_BASE,
97 BL_COHERENT_RAM_END - BL_CODE_BASE,
98 BL_CODE_BASE,
99 BL_CODE_END,
Masahiro Yamada0fac5af2016-12-28 16:11:41 +0900100 BL_COHERENT_RAM_BASE,
101 BL_COHERENT_RAM_END);
Tony Xief6118cc2016-01-15 17:17:32 +0800102}