blob: 3734f91be9aad343adb319382bef0b53ac7b90b3 [file] [log] [blame]
Rex-BC Chen749b2112021-09-28 11:24:09 +08001/*
2 * Copyright (c) 2021, 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>
Rex-BC Chen0bee8f92021-10-06 19:00:13 +080014#include <drivers/generic_delay_timer.h>
Rex-BC Chen749b2112021-09-28 11:24:09 +080015#include <drivers/ti/uart/uart_16550.h>
16#include <lib/coreboot.h>
17
18/* Platform Includes */
Penny Janfb70fb42021-10-03 10:11:04 +080019#include <emi_mpu.h>
Rex-BC Chend24c05d2021-10-06 18:55:53 +080020#include <mt_timer.h>
Rex-BC Chen749b2112021-09-28 11:24:09 +080021#include <plat_params.h>
22#include <plat_private.h>
23
24static entry_point_info_t bl32_ep_info;
25static entry_point_info_t bl33_ep_info;
26
27/*******************************************************************************
28 * Return a pointer to the 'entry_point_info' structure of the next image for
29 * the security state specified. BL33 corresponds to the non-secure image type
30 * while BL32 corresponds to the secure image type. A NULL pointer is returned
31 * if the image does not exist.
32 ******************************************************************************/
33entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type)
34{
35 entry_point_info_t *next_image_info;
36
37 next_image_info = (type == NON_SECURE) ? &bl33_ep_info : &bl32_ep_info;
38 assert(next_image_info->h.type == PARAM_EP);
39
40 /* None of the images on this platform can have 0x0 as the entrypoint */
41 if (next_image_info->pc) {
42 return next_image_info;
43 } else {
44 return NULL;
45 }
46}
47
48/*******************************************************************************
49 * Perform any BL31 early platform setup. Here is an opportunity to copy
50 * parameters passed by the calling EL (S-EL1 in BL2 & S-EL3 in BL1) before they
51 * are lost (potentially). This needs to be done before the MMU is initialized
52 * so that the memory layout can be used while creating page tables.
53 * BL2 has flushed this information to memory, so we are guaranteed to pick up
54 * good data.
55 ******************************************************************************/
56void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
57 u_register_t arg2, u_register_t arg3)
58{
59 static console_t console;
60
61 params_early_setup(arg1);
62
63#if COREBOOT
64 if (coreboot_serial.type) {
65 console_16550_register(coreboot_serial.baseaddr,
66 coreboot_serial.input_hertz,
67 coreboot_serial.baud,
68 &console);
69 }
70#else
71 console_16550_register(UART0_BASE, UART_CLOCK, UART_BAUDRATE, &console);
72#endif
73
74 INFO("MT8186 bl31_setup\n");
75
76 bl31_params_parse_helper(arg0, &bl32_ep_info, &bl33_ep_info);
77}
78
79
80/*******************************************************************************
81 * Perform any BL31 platform setup code
82 ******************************************************************************/
83void bl31_platform_setup(void)
84{
Rex-BC Chend24c05d2021-10-06 18:55:53 +080085 mt_systimer_init();
Rex-BC Chen0bee8f92021-10-06 19:00:13 +080086 generic_delay_timer_init();
87
Penny Janfb70fb42021-10-03 10:11:04 +080088 emi_mpu_init();
Rex-BC Chen749b2112021-09-28 11:24:09 +080089}
90
91/*******************************************************************************
92 * Perform the very early platform specific architectural setup here. At the
93 * moment this is only intializes the mmu in a quick and dirty way.
94 ******************************************************************************/
95void bl31_plat_arch_setup(void)
96{
97 plat_configure_mmu_el3(BL31_START,
98 BL31_END - BL31_START,
99 BL_CODE_BASE,
100 BL_CODE_END);
101}