Jiafei Pan | 46367ad | 2018-03-02 07:23:30 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Antonio Nino Diaz | de97ff3 | 2019-01-25 13:28:38 +0000 | [diff] [blame] | 7 | #include <common/bl_common.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | #include <common/debug.h> |
| 9 | #include <common/interrupt_props.h> |
| 10 | #include <drivers/arm/gicv2.h> |
Antonio Nino Diaz | 53dec73 | 2018-09-25 14:54:23 +0100 | [diff] [blame] | 11 | |
Jiafei Pan | 46367ad | 2018-03-02 07:23:30 +0000 | [diff] [blame] | 12 | #include "ls_16550.h" |
| 13 | #include "plat_ls.h" |
| 14 | #include "soc.h" |
| 15 | |
Antonio Nino Diaz | 53dec73 | 2018-09-25 14:54:23 +0100 | [diff] [blame] | 16 | static const interrupt_prop_t g0_interrupt_props[] = { |
| 17 | INTR_PROP_DESC(9, GIC_HIGHEST_SEC_PRIORITY, |
| 18 | GICV2_INTR_GROUP0, GIC_INTR_CFG_LEVEL), |
Jiafei Pan | 46367ad | 2018-03-02 07:23:30 +0000 | [diff] [blame] | 19 | }; |
| 20 | |
| 21 | gicv2_driver_data_t ls_gic_data = { |
| 22 | .gicd_base = GICD_BASE, |
| 23 | .gicc_base = GICC_BASE, |
Antonio Nino Diaz | 53dec73 | 2018-09-25 14:54:23 +0100 | [diff] [blame] | 24 | .interrupt_props = g0_interrupt_props, |
| 25 | .interrupt_props_num = ARRAY_SIZE(g0_interrupt_props), |
Jiafei Pan | 46367ad | 2018-03-02 07:23:30 +0000 | [diff] [blame] | 26 | }; |
| 27 | |
| 28 | /******************************************************************************* |
| 29 | * Initialize the UART |
| 30 | ******************************************************************************/ |
| 31 | void ls_tsp_early_platform_setup(void) |
| 32 | { |
Andre Przywara | 15069ea | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 33 | static console_t console; |
Jiafei Pan | 46367ad | 2018-03-02 07:23:30 +0000 | [diff] [blame] | 34 | /* |
| 35 | * Initialize a different console than already in use to display |
| 36 | * messages from TSP |
| 37 | */ |
| 38 | console_ls_16550_register(PLAT_LS1043_UART2_BASE, PLAT_LS1043_UART_CLOCK, |
| 39 | PLAT_LS1043_UART_BAUDRATE, &console); |
| 40 | NOTICE(FIRMWARE_WELCOME_STR_LS1043_BL32); |
| 41 | } |
| 42 | |
| 43 | /******************************************************************************* |
| 44 | * Perform platform specific setup placeholder |
| 45 | ******************************************************************************/ |
| 46 | void tsp_platform_setup(void) |
| 47 | { |
| 48 | uint32_t gicc_base, gicd_base; |
| 49 | |
| 50 | /* Initialize the GIC driver, cpu and distributor interfaces */ |
| 51 | get_gic_offset(&gicc_base, &gicd_base); |
| 52 | ls_gic_data.gicd_base = (uintptr_t)gicd_base; |
| 53 | ls_gic_data.gicc_base = (uintptr_t)gicc_base; |
| 54 | gicv2_driver_init(&ls_gic_data); |
| 55 | gicv2_distif_init(); |
| 56 | gicv2_pcpu_distif_init(); |
| 57 | gicv2_cpuif_enable(); |
| 58 | } |
| 59 | |
| 60 | /******************************************************************************* |
| 61 | * Perform the very early platform specific architectural setup here. At the |
| 62 | * moment this is only intializes the MMU |
| 63 | ******************************************************************************/ |
| 64 | void tsp_plat_arch_setup(void) |
| 65 | { |
| 66 | ls_setup_page_tables(BL32_BASE, |
| 67 | (BL32_END - BL32_BASE), |
| 68 | BL_CODE_BASE, |
| 69 | BL_CODE_END, |
| 70 | BL_RO_DATA_BASE, |
| 71 | BL_RO_DATA_END |
| 72 | #if USE_COHERENT_MEM |
| 73 | , BL_COHERENT_RAM_BASE, |
| 74 | BL_COHERENT_RAM_END |
| 75 | #endif |
| 76 | ); |
| 77 | enable_mmu_el1(0); |
| 78 | } |