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