Tony Xie | 6fba6e0 | 2016-01-15 17:17:32 +0800 | [diff] [blame] | 1 | /* |
Julius Werner | c1185ff | 2019-05-24 20:37:58 -0700 | [diff] [blame^] | 2 | * Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved. |
Tony Xie | 6fba6e0 | 2016-01-15 17:17:32 +0800 | [diff] [blame] | 3 | * |
dp-arm | 82cb2c1 | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Tony Xie | 6fba6e0 | 2016-01-15 17:17:32 +0800 | [diff] [blame] | 5 | */ |
| 6 | |
Tony Xie | 6fba6e0 | 2016-01-15 17:17:32 +0800 | [diff] [blame] | 7 | #include <assert.h> |
Antonio Nino Diaz | 09d40e0 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | |
Tony Xie | 6fba6e0 | 2016-01-15 17:17:32 +0800 | [diff] [blame] | 9 | #include <platform_def.h> |
Antonio Nino Diaz | 09d40e0 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | |
| 11 | #include <common/bl_common.h> |
| 12 | #include <common/debug.h> |
| 13 | #include <drivers/console.h> |
| 14 | #include <drivers/generic_delay_timer.h> |
| 15 | #include <drivers/ti/uart/uart_16550.h> |
| 16 | #include <lib/coreboot.h> |
| 17 | #include <lib/mmio.h> |
| 18 | #include <plat_private.h> |
| 19 | #include <plat/common/platform.h> |
Tony Xie | 6fba6e0 | 2016-01-15 17:17:32 +0800 | [diff] [blame] | 20 | |
Tony Xie | 6fba6e0 | 2016-01-15 17:17:32 +0800 | [diff] [blame] | 21 | static entry_point_info_t bl32_ep_info; |
| 22 | static entry_point_info_t bl33_ep_info; |
| 23 | |
| 24 | /******************************************************************************* |
| 25 | * Return a pointer to the 'entry_point_info' structure of the next image for |
| 26 | * the security state specified. BL33 corresponds to the non-secure image type |
| 27 | * while BL32 corresponds to the secure image type. A NULL pointer is returned |
| 28 | * if the image does not exist. |
| 29 | ******************************************************************************/ |
| 30 | entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type) |
| 31 | { |
| 32 | entry_point_info_t *next_image_info; |
| 33 | |
| 34 | next_image_info = (type == NON_SECURE) ? &bl33_ep_info : &bl32_ep_info; |
| 35 | |
| 36 | /* None of the images on this platform can have 0x0 as the entrypoint */ |
| 37 | if (next_image_info->pc) |
| 38 | return next_image_info; |
| 39 | else |
| 40 | return NULL; |
| 41 | } |
| 42 | |
tony.xie | 0d5ec95 | 2017-04-24 16:18:10 +0800 | [diff] [blame] | 43 | #pragma weak params_early_setup |
Julius Werner | c1185ff | 2019-05-24 20:37:58 -0700 | [diff] [blame^] | 44 | void params_early_setup(u_register_t plat_param_from_bl2) |
tony.xie | 0d5ec95 | 2017-04-24 16:18:10 +0800 | [diff] [blame] | 45 | { |
| 46 | } |
| 47 | |
Tony Xie | 6fba6e0 | 2016-01-15 17:17:32 +0800 | [diff] [blame] | 48 | /******************************************************************************* |
| 49 | * Perform any BL3-1 early platform setup. Here is an opportunity to copy |
John Tsichritzis | a623832 | 2018-09-14 10:34:57 +0100 | [diff] [blame] | 50 | * parameters passed by the calling EL (S-EL1 in BL2 & EL3 in BL1) before they |
Tony Xie | 6fba6e0 | 2016-01-15 17:17:32 +0800 | [diff] [blame] | 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 | ******************************************************************************/ |
Antonio Nino Diaz | 2d6f1f0 | 2018-09-24 17:16:20 +0100 | [diff] [blame] | 56 | void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, |
| 57 | u_register_t arg2, u_register_t arg3) |
Tony Xie | 6fba6e0 | 2016-01-15 17:17:32 +0800 | [diff] [blame] | 58 | { |
Julius Werner | 890abc3 | 2017-08-02 16:31:04 -0700 | [diff] [blame] | 59 | static console_16550_t console; |
Antonio Nino Diaz | 2d6f1f0 | 2018-09-24 17:16:20 +0100 | [diff] [blame] | 60 | struct rockchip_bl31_params *arg_from_bl2 = (struct rockchip_bl31_params *) arg0; |
Julius Werner | 890abc3 | 2017-08-02 16:31:04 -0700 | [diff] [blame] | 61 | |
Julius Werner | c1185ff | 2019-05-24 20:37:58 -0700 | [diff] [blame^] | 62 | params_early_setup(arg1); |
Julius Werner | 3c250b9 | 2017-06-09 15:22:44 -0700 | [diff] [blame] | 63 | |
| 64 | #if COREBOOT |
| 65 | if (coreboot_serial.type) |
Julius Werner | 890abc3 | 2017-08-02 16:31:04 -0700 | [diff] [blame] | 66 | console_16550_register(coreboot_serial.baseaddr, |
| 67 | coreboot_serial.input_hertz, |
| 68 | coreboot_serial.baud, |
| 69 | &console); |
Julius Werner | 3c250b9 | 2017-06-09 15:22:44 -0700 | [diff] [blame] | 70 | #else |
Christoph Müllner | 220c33a | 2019-04-19 14:16:27 +0200 | [diff] [blame] | 71 | console_16550_register(rockchip_get_uart_base(), PLAT_RK_UART_CLOCK, |
Julius Werner | 890abc3 | 2017-08-02 16:31:04 -0700 | [diff] [blame] | 72 | PLAT_RK_UART_BAUDRATE, &console); |
Julius Werner | 3c250b9 | 2017-06-09 15:22:44 -0700 | [diff] [blame] | 73 | #endif |
Tony Xie | 6fba6e0 | 2016-01-15 17:17:32 +0800 | [diff] [blame] | 74 | |
| 75 | VERBOSE("bl31_setup\n"); |
| 76 | |
| 77 | /* Passing a NULL context is a critical programming error */ |
Antonio Nino Diaz | 2d6f1f0 | 2018-09-24 17:16:20 +0100 | [diff] [blame] | 78 | assert(arg_from_bl2); |
Tony Xie | 6fba6e0 | 2016-01-15 17:17:32 +0800 | [diff] [blame] | 79 | |
Antonio Nino Diaz | 2d6f1f0 | 2018-09-24 17:16:20 +0100 | [diff] [blame] | 80 | assert(arg_from_bl2->h.type == PARAM_BL31); |
| 81 | assert(arg_from_bl2->h.version >= VERSION_1); |
Tony Xie | 6fba6e0 | 2016-01-15 17:17:32 +0800 | [diff] [blame] | 82 | |
Antonio Nino Diaz | 2d6f1f0 | 2018-09-24 17:16:20 +0100 | [diff] [blame] | 83 | bl32_ep_info = *arg_from_bl2->bl32_ep_info; |
| 84 | bl33_ep_info = *arg_from_bl2->bl33_ep_info; |
Tony Xie | 6fba6e0 | 2016-01-15 17:17:32 +0800 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | /******************************************************************************* |
| 88 | * Perform any BL3-1 platform setup code |
| 89 | ******************************************************************************/ |
| 90 | void bl31_platform_setup(void) |
| 91 | { |
Antonio Nino Diaz | 6704f42 | 2016-05-05 15:25:02 +0100 | [diff] [blame] | 92 | generic_delay_timer_init(); |
Tony Xie | 6fba6e0 | 2016-01-15 17:17:32 +0800 | [diff] [blame] | 93 | plat_rockchip_soc_init(); |
| 94 | |
| 95 | /* Initialize the gic cpu and distributor interfaces */ |
| 96 | plat_rockchip_gic_driver_init(); |
| 97 | plat_rockchip_gic_init(); |
| 98 | plat_rockchip_pmu_init(); |
| 99 | } |
| 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 | ******************************************************************************/ |
| 105 | void bl31_plat_arch_setup(void) |
| 106 | { |
| 107 | plat_cci_init(); |
| 108 | plat_cci_enable(); |
Heiko Stuebner | 3e6945e | 2019-05-29 12:03:38 +0200 | [diff] [blame] | 109 | plat_configure_mmu_el3(BL_CODE_BASE, |
| 110 | BL_COHERENT_RAM_END - BL_CODE_BASE, |
| 111 | BL_CODE_BASE, |
| 112 | BL_CODE_END, |
Masahiro Yamada | 4749705 | 2016-12-28 16:11:41 +0900 | [diff] [blame] | 113 | BL_COHERENT_RAM_BASE, |
| 114 | BL_COHERENT_RAM_END); |
Tony Xie | 6fba6e0 | 2016-01-15 17:17:32 +0800 | [diff] [blame] | 115 | } |