1 /* 2 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <arch_helpers.h> 8 #include <arm_gic.h> 9 #include <assert.h> 10 #include <bl_common.h> 11 #include <cci.h> 12 #include <console.h> 13 #include <debug.h> 14 #include <errno.h> 15 #include <generic_delay_timer.h> 16 #include <gicv2.h> 17 #include <hi3660.h> 18 #include <hisi_ipc.h> 19 #include <platform_def.h> 20 21 #include "hikey960_def.h" 22 #include "hikey960_private.h" 23 24 /* 25 * The next 2 constants identify the extents of the code & RO data region. 26 * These addresses are used by the MMU setup code and therefore they must be 27 * page-aligned. It is the responsibility of the linker script to ensure that 28 * __RO_START__ and __RO_END__ linker symbols refer to page-aligned addresses. 29 */ 30 #define BL31_RO_BASE (unsigned long)(&__RO_START__) 31 #define BL31_RO_LIMIT (unsigned long)(&__RO_END__) 32 33 /* 34 * The next 2 constants identify the extents of the coherent memory region. 35 * These addresses are used by the MMU setup code and therefore they must be 36 * page-aligned. It is the responsibility of the linker script to ensure that 37 * __COHERENT_RAM_START__ and __COHERENT_RAM_END__ linker symbols refer to 38 * page-aligned addresses. 39 */ 40 #define BL31_COHERENT_RAM_BASE (unsigned long)(&__COHERENT_RAM_START__) 41 #define BL31_COHERENT_RAM_LIMIT (unsigned long)(&__COHERENT_RAM_END__) 42 43 static entry_point_info_t bl32_ep_info; 44 static entry_point_info_t bl33_ep_info; 45 46 /****************************************************************************** 47 * On a GICv2 system, the Group 1 secure interrupts are treated as Group 0 48 * interrupts. 49 *****************************************************************************/ 50 const unsigned int g0_interrupt_array[] = { 51 IRQ_SEC_PHY_TIMER, 52 IRQ_SEC_SGI_0 53 }; 54 55 const gicv2_driver_data_t hikey960_gic_data = { 56 .gicd_base = GICD_REG_BASE, 57 .gicc_base = GICC_REG_BASE, 58 .g0_interrupt_num = ARRAY_SIZE(g0_interrupt_array), 59 .g0_interrupt_array = g0_interrupt_array, 60 }; 61 62 static const int cci_map[] = { 63 CCI400_SL_IFACE3_CLUSTER_IX, 64 CCI400_SL_IFACE4_CLUSTER_IX 65 }; 66 67 entry_point_info_t *bl31_plat_get_next_image_ep_info(unsigned int type) 68 { 69 entry_point_info_t *next_image_info; 70 71 next_image_info = (type == NON_SECURE) ? &bl33_ep_info : &bl32_ep_info; 72 73 /* None of the images on this platform can have 0x0 as the entrypoint */ 74 if (next_image_info->pc) 75 return next_image_info; 76 return NULL; 77 } 78 79 void bl31_early_platform_setup(bl31_params_t *from_bl2, 80 void *plat_params_from_bl2) 81 { 82 unsigned int id, uart_base; 83 84 generic_delay_timer_init(); 85 hikey960_read_boardid(&id); 86 if (id == 5300) 87 uart_base = PL011_UART5_BASE; 88 else 89 uart_base = PL011_UART6_BASE; 90 91 /* Initialize the console to provide early debug support */ 92 console_init(uart_base, PL011_UART_CLK_IN_HZ, PL011_BAUDRATE); 93 94 /* Initialize CCI driver */ 95 cci_init(CCI400_REG_BASE, cci_map, ARRAY_SIZE(cci_map)); 96 cci_enable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr_el1())); 97 98 /* 99 * Copy BL3-2 and BL3-3 entry point information. 100 * They are stored in Secure RAM, in BL2's address space. 101 */ 102 bl32_ep_info = *from_bl2->bl32_ep_info; 103 bl33_ep_info = *from_bl2->bl33_ep_info; 104 } 105 106 void bl31_plat_arch_setup(void) 107 { 108 hikey960_init_mmu_el3(BL31_BASE, 109 BL31_LIMIT - BL31_BASE, 110 BL31_RO_BASE, 111 BL31_RO_LIMIT, 112 BL31_COHERENT_RAM_BASE, 113 BL31_COHERENT_RAM_LIMIT); 114 } 115 116 void bl31_platform_setup(void) 117 { 118 /* Initialize the GIC driver, cpu and distributor interfaces */ 119 gicv2_driver_init(&hikey960_gic_data); 120 gicv2_distif_init(); 121 gicv2_pcpu_distif_init(); 122 gicv2_cpuif_enable(); 123 124 hisi_ipc_init(); 125 } 126 127 void bl31_plat_runtime_setup(void) 128 { 129 } 130