blob: 28a83880fc2503148e32bc38e48c8c3f4b0f20a3 [file] [log] [blame]
Tony Xie6fba6e02016-01-15 17:17:32 +08001/*
2 * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3 *
dp-arm82cb2c12017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Tony Xie6fba6e02016-01-15 17:17:32 +08005 */
6
7#include <arm_gic.h>
8#include <assert.h>
9#include <bl_common.h>
10#include <console.h>
Julius Werner3c250b92017-06-09 15:22:44 -070011#include <coreboot.h>
Tony Xie6fba6e02016-01-15 17:17:32 +080012#include <debug.h>
Antonio Nino Diaz6704f422016-05-05 15:25:02 +010013#include <generic_delay_timer.h>
Tony Xie6fba6e02016-01-15 17:17:32 +080014#include <mmio.h>
Tony Xie6fba6e02016-01-15 17:17:32 +080015#include <plat_private.h>
Isla Mitchellee1ebbd2017-07-14 10:46:32 +010016#include <platform.h>
Tony Xie6fba6e02016-01-15 17:17:32 +080017#include <platform_def.h>
Julius Werner3c250b92017-06-09 15:22:44 -070018#include <uart_16550.h>
Tony Xie6fba6e02016-01-15 17:17:32 +080019
20/*******************************************************************************
21 * Declarations of linker defined symbols which will help us find the layout
22 * of trusted SRAM
23 ******************************************************************************/
24unsigned long __RO_START__;
25unsigned long __RO_END__;
26
Tony Xie6fba6e02016-01-15 17:17:32 +080027/*
28 * The next 2 constants identify the extents of the code & RO data region.
29 * These addresses are used by the MMU setup code and therefore they must be
30 * page-aligned. It is the responsibility of the linker script to ensure that
31 * __RO_START__ and __RO_END__ linker symbols refer to page-aligned addresses.
32 */
33#define BL31_RO_BASE (unsigned long)(&__RO_START__)
34#define BL31_RO_LIMIT (unsigned long)(&__RO_END__)
35
Tony Xie6fba6e02016-01-15 17:17:32 +080036static entry_point_info_t bl32_ep_info;
37static entry_point_info_t bl33_ep_info;
38
39/*******************************************************************************
40 * Return a pointer to the 'entry_point_info' structure of the next image for
41 * the security state specified. BL33 corresponds to the non-secure image type
42 * while BL32 corresponds to the secure image type. A NULL pointer is returned
43 * if the image does not exist.
44 ******************************************************************************/
45entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type)
46{
47 entry_point_info_t *next_image_info;
48
49 next_image_info = (type == NON_SECURE) ? &bl33_ep_info : &bl32_ep_info;
50
51 /* None of the images on this platform can have 0x0 as the entrypoint */
52 if (next_image_info->pc)
53 return next_image_info;
54 else
55 return NULL;
56}
57
tony.xie0d5ec952017-04-24 16:18:10 +080058#pragma weak params_early_setup
59void params_early_setup(void *plat_param_from_bl2)
60{
61}
62
Tony Xie6fba6e02016-01-15 17:17:32 +080063/*******************************************************************************
64 * Perform any BL3-1 early platform setup. Here is an opportunity to copy
65 * parameters passed by the calling EL (S-EL1 in BL2 & S-EL3 in BL1) before they
66 * are lost (potentially). This needs to be done before the MMU is initialized
67 * so that the memory layout can be used while creating page tables.
68 * BL2 has flushed this information to memory, so we are guaranteed to pick up
69 * good data.
70 ******************************************************************************/
71void bl31_early_platform_setup(bl31_params_t *from_bl2,
72 void *plat_params_from_bl2)
73{
Julius Werner3c250b92017-06-09 15:22:44 -070074 params_early_setup(plat_params_from_bl2);
75
76#if COREBOOT
77 if (coreboot_serial.type)
78 console_init(coreboot_serial.baseaddr,
79 coreboot_serial.input_hertz, coreboot_serial.baud);
80#else
Tony Xie6fba6e02016-01-15 17:17:32 +080081 console_init(PLAT_RK_UART_BASE, PLAT_RK_UART_CLOCK,
82 PLAT_RK_UART_BAUDRATE);
Julius Werner3c250b92017-06-09 15:22:44 -070083#endif
Tony Xie6fba6e02016-01-15 17:17:32 +080084
85 VERBOSE("bl31_setup\n");
86
87 /* Passing a NULL context is a critical programming error */
88 assert(from_bl2);
89
90 assert(from_bl2->h.type == PARAM_BL31);
91 assert(from_bl2->h.version >= VERSION_1);
92
93 bl32_ep_info = *from_bl2->bl32_ep_info;
94 bl33_ep_info = *from_bl2->bl33_ep_info;
Tony Xie6fba6e02016-01-15 17:17:32 +080095}
96
97/*******************************************************************************
98 * Perform any BL3-1 platform setup code
99 ******************************************************************************/
100void bl31_platform_setup(void)
101{
Antonio Nino Diaz6704f422016-05-05 15:25:02 +0100102 generic_delay_timer_init();
Tony Xie6fba6e02016-01-15 17:17:32 +0800103 plat_rockchip_soc_init();
104
105 /* Initialize the gic cpu and distributor interfaces */
106 plat_rockchip_gic_driver_init();
107 plat_rockchip_gic_init();
108 plat_rockchip_pmu_init();
109}
110
111/*******************************************************************************
112 * Perform the very early platform specific architectural setup here. At the
113 * moment this is only intializes the mmu in a quick and dirty way.
114 ******************************************************************************/
115void bl31_plat_arch_setup(void)
116{
117 plat_cci_init();
118 plat_cci_enable();
119 plat_configure_mmu_el3(BL31_RO_BASE,
Masahiro Yamada47497052016-12-28 16:11:41 +0900120 BL_COHERENT_RAM_END - BL31_RO_BASE,
Tony Xie6fba6e02016-01-15 17:17:32 +0800121 BL31_RO_BASE,
122 BL31_RO_LIMIT,
Masahiro Yamada47497052016-12-28 16:11:41 +0900123 BL_COHERENT_RAM_BASE,
124 BL_COHERENT_RAM_END);
Tony Xie6fba6e02016-01-15 17:17:32 +0800125}