16fba6e04STony Xie /* 2*9f85f9e3SJoel Hutton * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. 36fba6e04STony Xie * 482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 56fba6e04STony Xie */ 66fba6e04STony Xie 76fba6e04STony Xie #include <arm_gic.h> 86fba6e04STony Xie #include <assert.h> 96fba6e04STony Xie #include <bl_common.h> 106fba6e04STony Xie #include <console.h> 113c250b9aSJulius Werner #include <coreboot.h> 126fba6e04STony Xie #include <debug.h> 136704f425SAntonio Nino Diaz #include <generic_delay_timer.h> 146fba6e04STony Xie #include <mmio.h> 156fba6e04STony Xie #include <plat_private.h> 16ee1ebbd1SIsla Mitchell #include <platform.h> 176fba6e04STony Xie #include <platform_def.h> 183c250b9aSJulius Werner #include <uart_16550.h> 196fba6e04STony Xie 206fba6e04STony Xie /* 216fba6e04STony Xie * The next 2 constants identify the extents of the code & RO data region. 226fba6e04STony Xie * These addresses are used by the MMU setup code and therefore they must be 236fba6e04STony Xie * page-aligned. It is the responsibility of the linker script to ensure that 246fba6e04STony Xie * __RO_START__ and __RO_END__ linker symbols refer to page-aligned addresses. 256fba6e04STony Xie */ 26*9f85f9e3SJoel Hutton IMPORT_SYM(unsigned long, __RO_START__, BL31_RO_BASE); 27*9f85f9e3SJoel Hutton IMPORT_SYM(unsigned long, __RO_END__, BL31_RO_LIMIT); 286fba6e04STony Xie 296fba6e04STony Xie static entry_point_info_t bl32_ep_info; 306fba6e04STony Xie static entry_point_info_t bl33_ep_info; 316fba6e04STony Xie 326fba6e04STony Xie /******************************************************************************* 336fba6e04STony Xie * Return a pointer to the 'entry_point_info' structure of the next image for 346fba6e04STony Xie * the security state specified. BL33 corresponds to the non-secure image type 356fba6e04STony Xie * while BL32 corresponds to the secure image type. A NULL pointer is returned 366fba6e04STony Xie * if the image does not exist. 376fba6e04STony Xie ******************************************************************************/ 386fba6e04STony Xie entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type) 396fba6e04STony Xie { 406fba6e04STony Xie entry_point_info_t *next_image_info; 416fba6e04STony Xie 426fba6e04STony Xie next_image_info = (type == NON_SECURE) ? &bl33_ep_info : &bl32_ep_info; 436fba6e04STony Xie 446fba6e04STony Xie /* None of the images on this platform can have 0x0 as the entrypoint */ 456fba6e04STony Xie if (next_image_info->pc) 466fba6e04STony Xie return next_image_info; 476fba6e04STony Xie else 486fba6e04STony Xie return NULL; 496fba6e04STony Xie } 506fba6e04STony Xie 510d5ec955Stony.xie #pragma weak params_early_setup 520d5ec955Stony.xie void params_early_setup(void *plat_param_from_bl2) 530d5ec955Stony.xie { 540d5ec955Stony.xie } 550d5ec955Stony.xie 566fba6e04STony Xie /******************************************************************************* 576fba6e04STony Xie * Perform any BL3-1 early platform setup. Here is an opportunity to copy 586fba6e04STony Xie * parameters passed by the calling EL (S-EL1 in BL2 & S-EL3 in BL1) before they 596fba6e04STony Xie * are lost (potentially). This needs to be done before the MMU is initialized 606fba6e04STony Xie * so that the memory layout can be used while creating page tables. 616fba6e04STony Xie * BL2 has flushed this information to memory, so we are guaranteed to pick up 626fba6e04STony Xie * good data. 636fba6e04STony Xie ******************************************************************************/ 646fba6e04STony Xie void bl31_early_platform_setup(bl31_params_t *from_bl2, 656fba6e04STony Xie void *plat_params_from_bl2) 666fba6e04STony Xie { 67890abc33SJulius Werner static console_16550_t console; 68890abc33SJulius Werner 693c250b9aSJulius Werner params_early_setup(plat_params_from_bl2); 703c250b9aSJulius Werner 713c250b9aSJulius Werner #if COREBOOT 723c250b9aSJulius Werner if (coreboot_serial.type) 73890abc33SJulius Werner console_16550_register(coreboot_serial.baseaddr, 74890abc33SJulius Werner coreboot_serial.input_hertz, 75890abc33SJulius Werner coreboot_serial.baud, 76890abc33SJulius Werner &console); 773c250b9aSJulius Werner #else 78890abc33SJulius Werner console_16550_register(PLAT_RK_UART_BASE, PLAT_RK_UART_CLOCK, 79890abc33SJulius Werner PLAT_RK_UART_BAUDRATE, &console); 803c250b9aSJulius Werner #endif 816fba6e04STony Xie 826fba6e04STony Xie VERBOSE("bl31_setup\n"); 836fba6e04STony Xie 846fba6e04STony Xie /* Passing a NULL context is a critical programming error */ 856fba6e04STony Xie assert(from_bl2); 866fba6e04STony Xie 876fba6e04STony Xie assert(from_bl2->h.type == PARAM_BL31); 886fba6e04STony Xie assert(from_bl2->h.version >= VERSION_1); 896fba6e04STony Xie 906fba6e04STony Xie bl32_ep_info = *from_bl2->bl32_ep_info; 916fba6e04STony Xie bl33_ep_info = *from_bl2->bl33_ep_info; 926fba6e04STony Xie } 936fba6e04STony Xie 946fba6e04STony Xie /******************************************************************************* 956fba6e04STony Xie * Perform any BL3-1 platform setup code 966fba6e04STony Xie ******************************************************************************/ 976fba6e04STony Xie void bl31_platform_setup(void) 986fba6e04STony Xie { 996704f425SAntonio Nino Diaz generic_delay_timer_init(); 1006fba6e04STony Xie plat_rockchip_soc_init(); 1016fba6e04STony Xie 1026fba6e04STony Xie /* Initialize the gic cpu and distributor interfaces */ 1036fba6e04STony Xie plat_rockchip_gic_driver_init(); 1046fba6e04STony Xie plat_rockchip_gic_init(); 1056fba6e04STony Xie plat_rockchip_pmu_init(); 1066fba6e04STony Xie } 1076fba6e04STony Xie 1086fba6e04STony Xie /******************************************************************************* 1096fba6e04STony Xie * Perform the very early platform specific architectural setup here. At the 1106fba6e04STony Xie * moment this is only intializes the mmu in a quick and dirty way. 1116fba6e04STony Xie ******************************************************************************/ 1126fba6e04STony Xie void bl31_plat_arch_setup(void) 1136fba6e04STony Xie { 1146fba6e04STony Xie plat_cci_init(); 1156fba6e04STony Xie plat_cci_enable(); 1166fba6e04STony Xie plat_configure_mmu_el3(BL31_RO_BASE, 11747497053SMasahiro Yamada BL_COHERENT_RAM_END - BL31_RO_BASE, 1186fba6e04STony Xie BL31_RO_BASE, 1196fba6e04STony Xie BL31_RO_LIMIT, 12047497053SMasahiro Yamada BL_COHERENT_RAM_BASE, 12147497053SMasahiro Yamada BL_COHERENT_RAM_END); 1226fba6e04STony Xie } 123