1 /* 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 <gpio/mtgpio.h> 19 #include <mt_gic_v3.h> 20 #include <plat_params.h> 21 #include <plat_private.h> 22 23 static entry_point_info_t bl32_ep_info; 24 static entry_point_info_t bl33_ep_info; 25 26 /******************************************************************************* 27 * Return a pointer to the 'entry_point_info' structure of the next image for 28 * the security state specified. BL33 corresponds to the non-secure image type 29 * while BL32 corresponds to the secure image type. A NULL pointer is returned 30 * if the image does not exist. 31 ******************************************************************************/ 32 entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type) 33 { 34 entry_point_info_t *next_image_info; 35 36 next_image_info = (type == NON_SECURE) ? &bl33_ep_info : &bl32_ep_info; 37 assert(next_image_info->h.type == PARAM_EP); 38 39 /* None of the images on this platform can have 0x0 as the entrypoint */ 40 if (next_image_info->pc) { 41 return next_image_info; 42 } else { 43 return NULL; 44 } 45 } 46 47 /******************************************************************************* 48 * Perform any BL31 early platform setup. Here is an opportunity to copy 49 * parameters passed by the calling EL (S-EL1 in BL2 & S-EL3 in BL1) before they 50 * are lost (potentially). This needs to be done before the MMU is initialized 51 * so that the memory layout can be used while creating page tables. 52 * BL2 has flushed this information to memory, so we are guaranteed to pick up 53 * good data. 54 ******************************************************************************/ 55 void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, 56 u_register_t arg2, u_register_t arg3) 57 { 58 static console_t console; 59 60 params_early_setup(arg1); 61 62 #if COREBOOT 63 if (coreboot_serial.type) { 64 console_16550_register(coreboot_serial.baseaddr, 65 coreboot_serial.input_hertz, 66 coreboot_serial.baud, 67 &console); 68 } 69 #else 70 console_16550_register(UART0_BASE, UART_CLOCK, UART_BAUDRATE, &console); 71 #endif 72 73 NOTICE("MT8192 bl31_setup\n"); 74 75 bl31_params_parse_helper(arg0, &bl32_ep_info, &bl33_ep_info); 76 } 77 78 79 /******************************************************************************* 80 * Perform any BL31 platform setup code 81 ******************************************************************************/ 82 void bl31_platform_setup(void) 83 { 84 /* Initialize the GIC driver, CPU and distributor interfaces */ 85 mt_gic_driver_init(); 86 mt_gic_init(); 87 plat_mt8192_gpio_init(); 88 } 89 90 /******************************************************************************* 91 * Perform the very early platform specific architectural setup here. At the 92 * moment this is only intializes the mmu in a quick and dirty way. 93 ******************************************************************************/ 94 void bl31_plat_arch_setup(void) 95 { 96 plat_configure_mmu_el3(BL31_START, 97 BL31_END - BL31_START, 98 BL_CODE_BASE, 99 BL_CODE_END); 100 } 101