blob: 4378c5a121565329e2bb97538b50593ae11945ed [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 */
18#include <plat_params.h>
19#include <plat_private.h>
20
21static 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;
35 assert(next_image_info->h.type == PARAM_EP);
36
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}
44
45/*******************************************************************************
46 * Perform any BL31 early platform setup. Here is an opportunity to copy
47 * parameters passed by the calling EL (S-EL1 in BL2 & S-EL3 in BL1) before they
48 * are lost (potentially). This needs to be done before the MMU is initialized
49 * so that the memory layout can be used while creating page tables.
50 * BL2 has flushed this information to memory, so we are guaranteed to pick up
51 * good data.
52 ******************************************************************************/
53void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
54 u_register_t arg2, u_register_t arg3)
55{
56 static console_t console;
57
58 params_early_setup(arg1);
59
60#if COREBOOT
61 if (coreboot_serial.type) {
62 console_16550_register(coreboot_serial.baseaddr,
63 coreboot_serial.input_hertz,
64 coreboot_serial.baud,
65 &console);
66 }
67#else
68 console_16550_register(UART0_BASE, UART_CLOCK, UART_BAUDRATE, &console);
69#endif
70
71 NOTICE("MT8192 bl31_setup\n");
72
73 bl31_params_parse_helper(arg0, &bl32_ep_info, &bl33_ep_info);
74}
75
76
77/*******************************************************************************
78 * Perform any BL31 platform setup code
79 ******************************************************************************/
80void bl31_platform_setup(void)
81{
82}
83
84/*******************************************************************************
85 * Perform the very early platform specific architectural setup here. At the
86 * moment this is only intializes the mmu in a quick and dirty way.
87 ******************************************************************************/
88void bl31_plat_arch_setup(void)
89{
90 plat_configure_mmu_el3(BL31_START,
91 BL31_END - BL31_START,
92 BL_CODE_BASE,
93 BL_CODE_END);
94}