1*91f16700Schasinglulu /* 2*91f16700Schasinglulu * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. 3*91f16700Schasinglulu * 4*91f16700Schasinglulu * SPDX-License-Identifier: BSD-3-Clause 5*91f16700Schasinglulu */ 6*91f16700Schasinglulu 7*91f16700Schasinglulu #include <assert.h> 8*91f16700Schasinglulu #include <common/bl_common.h> 9*91f16700Schasinglulu #include <common/interrupt_props.h> 10*91f16700Schasinglulu #include <drivers/arm/gicv2.h> 11*91f16700Schasinglulu #include <lib/xlat_tables/xlat_mmu_helpers.h> 12*91f16700Schasinglulu #include <plat/common/platform.h> 13*91f16700Schasinglulu #include <platform_def.h> 14*91f16700Schasinglulu 15*91f16700Schasinglulu #include "aml_private.h" 16*91f16700Schasinglulu 17*91f16700Schasinglulu /* 18*91f16700Schasinglulu * Placeholder variables for copying the arguments that have been passed to 19*91f16700Schasinglulu * BL31 from BL2. 20*91f16700Schasinglulu */ 21*91f16700Schasinglulu static entry_point_info_t bl33_image_ep_info; 22*91f16700Schasinglulu 23*91f16700Schasinglulu /******************************************************************************* 24*91f16700Schasinglulu * Return a pointer to the 'entry_point_info' structure of the next image for 25*91f16700Schasinglulu * the security state specified. BL33 corresponds to the non-secure image type 26*91f16700Schasinglulu * while BL32 corresponds to the secure image type. A NULL pointer is returned 27*91f16700Schasinglulu * if the image does not exist. 28*91f16700Schasinglulu ******************************************************************************/ 29*91f16700Schasinglulu entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type) 30*91f16700Schasinglulu { 31*91f16700Schasinglulu entry_point_info_t *next_image_info; 32*91f16700Schasinglulu 33*91f16700Schasinglulu assert(type == NON_SECURE); 34*91f16700Schasinglulu 35*91f16700Schasinglulu next_image_info = &bl33_image_ep_info; 36*91f16700Schasinglulu 37*91f16700Schasinglulu /* None of the images can have 0x0 as the entrypoint. */ 38*91f16700Schasinglulu if (next_image_info->pc != 0U) { 39*91f16700Schasinglulu return next_image_info; 40*91f16700Schasinglulu } else { 41*91f16700Schasinglulu return NULL; 42*91f16700Schasinglulu } 43*91f16700Schasinglulu } 44*91f16700Schasinglulu 45*91f16700Schasinglulu /******************************************************************************* 46*91f16700Schasinglulu * Perform any BL31 early platform setup. Here is an opportunity to copy 47*91f16700Schasinglulu * parameters passed by the calling EL (S-EL1 in BL2 & S-EL3 in BL1) before 48*91f16700Schasinglulu * they are lost (potentially). This needs to be done before the MMU is 49*91f16700Schasinglulu * initialized so that the memory layout can be used while creating page 50*91f16700Schasinglulu * tables. BL2 has flushed this information to memory, so we are guaranteed 51*91f16700Schasinglulu * to pick up good data. 52*91f16700Schasinglulu ******************************************************************************/ 53*91f16700Schasinglulu struct gxbb_bl31_param { 54*91f16700Schasinglulu param_header_t h; 55*91f16700Schasinglulu image_info_t *bl31_image_info; 56*91f16700Schasinglulu entry_point_info_t *bl32_ep_info; 57*91f16700Schasinglulu image_info_t *bl32_image_info; 58*91f16700Schasinglulu entry_point_info_t *bl33_ep_info; 59*91f16700Schasinglulu image_info_t *bl33_image_info; 60*91f16700Schasinglulu }; 61*91f16700Schasinglulu 62*91f16700Schasinglulu void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, 63*91f16700Schasinglulu u_register_t arg2, u_register_t arg3) 64*91f16700Schasinglulu { 65*91f16700Schasinglulu struct gxbb_bl31_param *from_bl2; 66*91f16700Schasinglulu 67*91f16700Schasinglulu /* Initialize the console to provide early debug support */ 68*91f16700Schasinglulu aml_console_init(); 69*91f16700Schasinglulu 70*91f16700Schasinglulu /* 71*91f16700Schasinglulu * In debug builds, we pass a special value in 'arg1' to verify platform 72*91f16700Schasinglulu * parameters from BL2 to BL31. In release builds it's not used. 73*91f16700Schasinglulu */ 74*91f16700Schasinglulu assert(arg1 == AML_BL31_PLAT_PARAM_VAL); 75*91f16700Schasinglulu 76*91f16700Schasinglulu /* Check that params passed from BL2 are not NULL. */ 77*91f16700Schasinglulu from_bl2 = (struct gxbb_bl31_param *) arg0; 78*91f16700Schasinglulu 79*91f16700Schasinglulu /* Check params passed from BL2 are not NULL. */ 80*91f16700Schasinglulu assert(from_bl2 != NULL); 81*91f16700Schasinglulu assert(from_bl2->h.type == PARAM_BL31); 82*91f16700Schasinglulu assert(from_bl2->h.version >= VERSION_1); 83*91f16700Schasinglulu 84*91f16700Schasinglulu /* 85*91f16700Schasinglulu * Copy BL33 entry point information. It is stored in Secure RAM, in 86*91f16700Schasinglulu * BL2's address space. 87*91f16700Schasinglulu */ 88*91f16700Schasinglulu bl33_image_ep_info = *from_bl2->bl33_ep_info; 89*91f16700Schasinglulu 90*91f16700Schasinglulu if (bl33_image_ep_info.pc == 0U) { 91*91f16700Schasinglulu ERROR("BL31: BL33 entrypoint not obtained from BL2\n"); 92*91f16700Schasinglulu panic(); 93*91f16700Schasinglulu } 94*91f16700Schasinglulu } 95*91f16700Schasinglulu 96*91f16700Schasinglulu void bl31_plat_arch_setup(void) 97*91f16700Schasinglulu { 98*91f16700Schasinglulu aml_setup_page_tables(); 99*91f16700Schasinglulu 100*91f16700Schasinglulu enable_mmu_el3(0); 101*91f16700Schasinglulu } 102*91f16700Schasinglulu 103*91f16700Schasinglulu /******************************************************************************* 104*91f16700Schasinglulu * GICv2 driver setup information 105*91f16700Schasinglulu ******************************************************************************/ 106*91f16700Schasinglulu static const interrupt_prop_t gxbb_interrupt_props[] = { 107*91f16700Schasinglulu INTR_PROP_DESC(IRQ_SEC_PHY_TIMER, GIC_HIGHEST_SEC_PRIORITY, 108*91f16700Schasinglulu GICV2_INTR_GROUP0, GIC_INTR_CFG_LEVEL), 109*91f16700Schasinglulu INTR_PROP_DESC(IRQ_SEC_SGI_0, GIC_HIGHEST_SEC_PRIORITY, 110*91f16700Schasinglulu GICV2_INTR_GROUP0, GIC_INTR_CFG_LEVEL), 111*91f16700Schasinglulu INTR_PROP_DESC(IRQ_SEC_SGI_1, GIC_HIGHEST_SEC_PRIORITY, 112*91f16700Schasinglulu GICV2_INTR_GROUP0, GIC_INTR_CFG_LEVEL), 113*91f16700Schasinglulu INTR_PROP_DESC(IRQ_SEC_SGI_2, GIC_HIGHEST_SEC_PRIORITY, 114*91f16700Schasinglulu GICV2_INTR_GROUP0, GIC_INTR_CFG_LEVEL), 115*91f16700Schasinglulu INTR_PROP_DESC(IRQ_SEC_SGI_3, GIC_HIGHEST_SEC_PRIORITY, 116*91f16700Schasinglulu GICV2_INTR_GROUP0, GIC_INTR_CFG_LEVEL), 117*91f16700Schasinglulu INTR_PROP_DESC(IRQ_SEC_SGI_4, GIC_HIGHEST_SEC_PRIORITY, 118*91f16700Schasinglulu GICV2_INTR_GROUP0, GIC_INTR_CFG_LEVEL), 119*91f16700Schasinglulu INTR_PROP_DESC(IRQ_SEC_SGI_5, GIC_HIGHEST_SEC_PRIORITY, 120*91f16700Schasinglulu GICV2_INTR_GROUP0, GIC_INTR_CFG_LEVEL), 121*91f16700Schasinglulu INTR_PROP_DESC(IRQ_SEC_SGI_6, GIC_HIGHEST_SEC_PRIORITY, 122*91f16700Schasinglulu GICV2_INTR_GROUP0, GIC_INTR_CFG_LEVEL), 123*91f16700Schasinglulu INTR_PROP_DESC(IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, 124*91f16700Schasinglulu GICV2_INTR_GROUP0, GIC_INTR_CFG_LEVEL), 125*91f16700Schasinglulu }; 126*91f16700Schasinglulu 127*91f16700Schasinglulu static const gicv2_driver_data_t gxbb_gic_data = { 128*91f16700Schasinglulu .gicd_base = AML_GICD_BASE, 129*91f16700Schasinglulu .gicc_base = AML_GICC_BASE, 130*91f16700Schasinglulu .interrupt_props = gxbb_interrupt_props, 131*91f16700Schasinglulu .interrupt_props_num = ARRAY_SIZE(gxbb_interrupt_props), 132*91f16700Schasinglulu }; 133*91f16700Schasinglulu 134*91f16700Schasinglulu void bl31_platform_setup(void) 135*91f16700Schasinglulu { 136*91f16700Schasinglulu aml_mhu_secure_init(); 137*91f16700Schasinglulu 138*91f16700Schasinglulu gicv2_driver_init(&gxbb_gic_data); 139*91f16700Schasinglulu gicv2_distif_init(); 140*91f16700Schasinglulu gicv2_pcpu_distif_init(); 141*91f16700Schasinglulu gicv2_cpuif_enable(); 142*91f16700Schasinglulu 143*91f16700Schasinglulu aml_thermal_unknown(); 144*91f16700Schasinglulu } 145