blob: f96528196bf0d389f3be8b005f57c0b3bbf9b798 [file] [log] [blame]
developer2189d3a2020-04-17 17:14:23 +08001/*
2 * Copyright (c) 2020, MediaTek Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7/* System Includes */
8#include <assert.h>
9
10/* Project Includes */
11#include <common/bl_common.h>
12#include <common/debug.h>
13#include <common/desc_image_load.h>
14#include <drivers/ti/uart/uart_16550.h>
15#include <lib/coreboot.h>
16
17/* Platform Includes */
developerf9b56842020-06-09 13:38:35 +080018#include <mt_gic_v3.h>
developer2189d3a2020-04-17 17:14:23 +080019#include <plat_params.h>
20#include <plat_private.h>
21
22static entry_point_info_t bl32_ep_info;
23static entry_point_info_t bl33_ep_info;
24
25/*******************************************************************************
26 * Return a pointer to the 'entry_point_info' structure of the next image for
27 * the security state specified. BL33 corresponds to the non-secure image type
28 * while BL32 corresponds to the secure image type. A NULL pointer is returned
29 * if the image does not exist.
30 ******************************************************************************/
31entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type)
32{
33 entry_point_info_t *next_image_info;
34
35 next_image_info = (type == NON_SECURE) ? &bl33_ep_info : &bl32_ep_info;
36 assert(next_image_info->h.type == PARAM_EP);
37
38 /* None of the images on this platform can have 0x0 as the entrypoint */
39 if (next_image_info->pc) {
40 return next_image_info;
41 } else {
42 return NULL;
43 }
44}
45
46/*******************************************************************************
47 * Perform any BL31 early platform setup. Here is an opportunity to copy
48 * parameters passed by the calling EL (S-EL1 in BL2 & S-EL3 in BL1) before they
49 * are lost (potentially). This needs to be done before the MMU is initialized
50 * so that the memory layout can be used while creating page tables.
51 * BL2 has flushed this information to memory, so we are guaranteed to pick up
52 * good data.
53 ******************************************************************************/
54void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
55 u_register_t arg2, u_register_t arg3)
56{
57 static console_t console;
58
59 params_early_setup(arg1);
60
61#if COREBOOT
62 if (coreboot_serial.type) {
63 console_16550_register(coreboot_serial.baseaddr,
64 coreboot_serial.input_hertz,
65 coreboot_serial.baud,
66 &console);
67 }
68#else
69 console_16550_register(UART0_BASE, UART_CLOCK, UART_BAUDRATE, &console);
70#endif
71
72 NOTICE("MT8192 bl31_setup\n");
73
74 bl31_params_parse_helper(arg0, &bl32_ep_info, &bl33_ep_info);
75}
76
77
78/*******************************************************************************
79 * Perform any BL31 platform setup code
80 ******************************************************************************/
81void bl31_platform_setup(void)
82{
developerf9b56842020-06-09 13:38:35 +080083 /* Initialize the GIC driver, CPU and distributor interfaces */
84 mt_gic_driver_init();
85 mt_gic_init();
developer2189d3a2020-04-17 17:14:23 +080086}
87
88/*******************************************************************************
89 * Perform the very early platform specific architectural setup here. At the
90 * moment this is only intializes the mmu in a quick and dirty way.
91 ******************************************************************************/
92void bl31_plat_arch_setup(void)
93{
94 plat_configure_mmu_el3(BL31_START,
95 BL31_END - BL31_START,
96 BL_CODE_BASE,
97 BL_CODE_END);
98}