blob: 61215a862351b2fbbdf5cd2f5e3f078c01eb8b54 [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 */
developer47aad1c2021-02-09 11:28:00 +080019#include <devapc/devapc.h>
developerbd481152020-11-02 10:45:34 +080020#include <emi_mpu/emi_mpu.h>
developer404e08b2020-09-18 09:32:31 +080021#include <gpio/mtgpio.h>
developerf9b56842020-06-09 13:38:35 +080022#include <mt_gic_v3.h>
developer5f735162021-01-04 00:02:34 +080023#include <mt_spm.h>
developer57d8b882020-07-06 18:01:42 +080024#include <mt_timer.h>
developera6304632020-09-08 14:36:07 +080025#include <mtk_dcm.h>
developer2189d3a2020-04-17 17:14:23 +080026#include <plat_params.h>
27#include <plat_private.h>
28
29static entry_point_info_t bl32_ep_info;
30static entry_point_info_t bl33_ep_info;
31
32/*******************************************************************************
33 * Return a pointer to the 'entry_point_info' structure of the next image for
34 * the security state specified. BL33 corresponds to the non-secure image type
35 * while BL32 corresponds to the secure image type. A NULL pointer is returned
36 * if the image does not exist.
37 ******************************************************************************/
38entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type)
39{
40 entry_point_info_t *next_image_info;
41
42 next_image_info = (type == NON_SECURE) ? &bl33_ep_info : &bl32_ep_info;
43 assert(next_image_info->h.type == PARAM_EP);
44
45 /* None of the images on this platform can have 0x0 as the entrypoint */
46 if (next_image_info->pc) {
47 return next_image_info;
48 } else {
49 return NULL;
50 }
51}
52
53/*******************************************************************************
54 * Perform any BL31 early platform setup. Here is an opportunity to copy
55 * parameters passed by the calling EL (S-EL1 in BL2 & S-EL3 in BL1) before they
56 * are lost (potentially). This needs to be done before the MMU is initialized
57 * so that the memory layout can be used while creating page tables.
58 * BL2 has flushed this information to memory, so we are guaranteed to pick up
59 * good data.
60 ******************************************************************************/
61void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
62 u_register_t arg2, u_register_t arg3)
63{
64 static console_t console;
65
66 params_early_setup(arg1);
67
68#if COREBOOT
69 if (coreboot_serial.type) {
70 console_16550_register(coreboot_serial.baseaddr,
71 coreboot_serial.input_hertz,
72 coreboot_serial.baud,
73 &console);
74 }
75#else
76 console_16550_register(UART0_BASE, UART_CLOCK, UART_BAUDRATE, &console);
77#endif
78
79 NOTICE("MT8192 bl31_setup\n");
80
81 bl31_params_parse_helper(arg0, &bl32_ep_info, &bl33_ep_info);
82}
83
84
85/*******************************************************************************
86 * Perform any BL31 platform setup code
87 ******************************************************************************/
88void bl31_platform_setup(void)
89{
developera6304632020-09-08 14:36:07 +080090 /* Set dcm on */
91 if (!dcm_set_default()) {
92 ERROR("Failed to set default dcm on!!\n");
93 }
94
developerbd481152020-11-02 10:45:34 +080095 /* MPU Init */
96 emi_mpu_init();
97
developer47aad1c2021-02-09 11:28:00 +080098 /* DAPC Init */
99 devapc_init();
100
developerf9b56842020-06-09 13:38:35 +0800101 /* Initialize the GIC driver, CPU and distributor interfaces */
102 mt_gic_driver_init();
103 mt_gic_init();
developer57d8b882020-07-06 18:01:42 +0800104
developer404e08b2020-09-18 09:32:31 +0800105 plat_mt8192_gpio_init();
developer57d8b882020-07-06 18:01:42 +0800106 mt_systimer_init();
developerf13d6492020-08-05 13:53:59 +0800107 generic_delay_timer_init();
developer5f735162021-01-04 00:02:34 +0800108 spm_boot_init();
developer2189d3a2020-04-17 17:14:23 +0800109}
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_configure_mmu_el3(BL31_START,
118 BL31_END - BL31_START,
119 BL_CODE_BASE,
120 BL_CODE_END);
121}