blob: 32e124f1f556ddb03f1ea36352f5e91f247a69cd [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>
developerf13d6492020-08-05 13:53:59 +080014#include <drivers/generic_delay_timer.h>
developer2189d3a2020-04-17 17:14:23 +080015#include <drivers/ti/uart/uart_16550.h>
16#include <lib/coreboot.h>
17
18/* Platform Includes */
developer404e08b2020-09-18 09:32:31 +080019#include <gpio/mtgpio.h>
developerf9b56842020-06-09 13:38:35 +080020#include <mt_gic_v3.h>
developer57d8b882020-07-06 18:01:42 +080021#include <mt_timer.h>
developera6304632020-09-08 14:36:07 +080022#include <mtk_dcm.h>
developer2189d3a2020-04-17 17:14:23 +080023#include <plat_params.h>
24#include <plat_private.h>
25
26static entry_point_info_t bl32_ep_info;
27static entry_point_info_t bl33_ep_info;
28
29/*******************************************************************************
30 * Return a pointer to the 'entry_point_info' structure of the next image for
31 * the security state specified. BL33 corresponds to the non-secure image type
32 * while BL32 corresponds to the secure image type. A NULL pointer is returned
33 * if the image does not exist.
34 ******************************************************************************/
35entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type)
36{
37 entry_point_info_t *next_image_info;
38
39 next_image_info = (type == NON_SECURE) ? &bl33_ep_info : &bl32_ep_info;
40 assert(next_image_info->h.type == PARAM_EP);
41
42 /* None of the images on this platform can have 0x0 as the entrypoint */
43 if (next_image_info->pc) {
44 return next_image_info;
45 } else {
46 return NULL;
47 }
48}
49
50/*******************************************************************************
51 * Perform any BL31 early platform setup. Here is an opportunity to copy
52 * parameters passed by the calling EL (S-EL1 in BL2 & S-EL3 in BL1) before they
53 * are lost (potentially). This needs to be done before the MMU is initialized
54 * so that the memory layout can be used while creating page tables.
55 * BL2 has flushed this information to memory, so we are guaranteed to pick up
56 * good data.
57 ******************************************************************************/
58void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
59 u_register_t arg2, u_register_t arg3)
60{
61 static console_t console;
62
63 params_early_setup(arg1);
64
65#if COREBOOT
66 if (coreboot_serial.type) {
67 console_16550_register(coreboot_serial.baseaddr,
68 coreboot_serial.input_hertz,
69 coreboot_serial.baud,
70 &console);
71 }
72#else
73 console_16550_register(UART0_BASE, UART_CLOCK, UART_BAUDRATE, &console);
74#endif
75
76 NOTICE("MT8192 bl31_setup\n");
77
78 bl31_params_parse_helper(arg0, &bl32_ep_info, &bl33_ep_info);
79}
80
81
82/*******************************************************************************
83 * Perform any BL31 platform setup code
84 ******************************************************************************/
85void bl31_platform_setup(void)
86{
developera6304632020-09-08 14:36:07 +080087 /* Set dcm on */
88 if (!dcm_set_default()) {
89 ERROR("Failed to set default dcm on!!\n");
90 }
91
developerf9b56842020-06-09 13:38:35 +080092 /* Initialize the GIC driver, CPU and distributor interfaces */
93 mt_gic_driver_init();
94 mt_gic_init();
developer57d8b882020-07-06 18:01:42 +080095
developer404e08b2020-09-18 09:32:31 +080096 plat_mt8192_gpio_init();
developer57d8b882020-07-06 18:01:42 +080097 mt_systimer_init();
developerf13d6492020-08-05 13:53:59 +080098 generic_delay_timer_init();
developer2189d3a2020-04-17 17:14:23 +080099}
100
101/*******************************************************************************
102 * Perform the very early platform specific architectural setup here. At the
103 * moment this is only intializes the mmu in a quick and dirty way.
104 ******************************************************************************/
105void bl31_plat_arch_setup(void)
106{
107 plat_configure_mmu_el3(BL31_START,
108 BL31_END - BL31_START,
109 BL_CODE_BASE,
110 BL_CODE_END);
111}