Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 2 | * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <arm_def.h> |
| 8 | #include <bl_common.h> |
| 9 | #include <console.h> |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 10 | #include <debug.h> |
| 11 | #include <pl011.h> |
Isla Mitchell | d254879 | 2017-07-14 10:48:25 +0100 | [diff] [blame] | 12 | #include <plat_arm.h> |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 13 | #include <platform_def.h> |
| 14 | #include <platform_tsp.h> |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 15 | |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 16 | #define BL32_END (unsigned long)(&__BL32_END__) |
| 17 | |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 18 | /* Weak definitions may be overridden in specific ARM standard platform */ |
| 19 | #pragma weak tsp_early_platform_setup |
| 20 | #pragma weak tsp_platform_setup |
| 21 | #pragma weak tsp_plat_arch_setup |
| 22 | |
| 23 | |
| 24 | /******************************************************************************* |
| 25 | * Initialize the UART |
| 26 | ******************************************************************************/ |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 27 | #if MULTI_CONSOLE_API |
| 28 | static console_pl011_t arm_tsp_runtime_console; |
| 29 | #endif |
| 30 | |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 31 | void arm_tsp_early_platform_setup(void) |
| 32 | { |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 33 | #if MULTI_CONSOLE_API |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 34 | /* |
| 35 | * Initialize a different console than already in use to display |
| 36 | * messages from TSP |
| 37 | */ |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 38 | int rc = console_pl011_register(PLAT_ARM_TSP_UART_BASE, |
| 39 | PLAT_ARM_TSP_UART_CLK_IN_HZ, |
| 40 | ARM_CONSOLE_BAUDRATE, |
| 41 | &arm_tsp_runtime_console); |
| 42 | if (rc == 0) |
| 43 | panic(); |
| 44 | |
| 45 | console_set_scope(&arm_tsp_runtime_console.console, |
| 46 | CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME); |
| 47 | #else |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 48 | console_init(PLAT_ARM_TSP_UART_BASE, PLAT_ARM_TSP_UART_CLK_IN_HZ, |
| 49 | ARM_CONSOLE_BAUDRATE); |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 50 | #endif /* MULTI_CONSOLE_API */ |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | void tsp_early_platform_setup(void) |
| 54 | { |
| 55 | arm_tsp_early_platform_setup(); |
| 56 | } |
| 57 | |
| 58 | /******************************************************************************* |
| 59 | * Perform platform specific setup placeholder |
| 60 | ******************************************************************************/ |
| 61 | void tsp_platform_setup(void) |
| 62 | { |
Achin Gupta | 1fa7eb6 | 2015-11-03 14:18:34 +0000 | [diff] [blame] | 63 | plat_arm_gic_driver_init(); |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | /******************************************************************************* |
| 67 | * Perform the very early platform specific architectural setup here. At the |
| 68 | * moment this is only intializes the MMU |
| 69 | ******************************************************************************/ |
| 70 | void tsp_plat_arch_setup(void) |
| 71 | { |
Sandrine Bailleux | ecdc4d3 | 2016-07-08 14:38:16 +0100 | [diff] [blame] | 72 | arm_setup_page_tables(BL32_BASE, |
| 73 | (BL32_END - BL32_BASE), |
| 74 | BL_CODE_BASE, |
Masahiro Yamada | 51bef61 | 2017-01-18 02:10:08 +0900 | [diff] [blame] | 75 | BL_CODE_END, |
Sandrine Bailleux | ecdc4d3 | 2016-07-08 14:38:16 +0100 | [diff] [blame] | 76 | BL_RO_DATA_BASE, |
Masahiro Yamada | 51bef61 | 2017-01-18 02:10:08 +0900 | [diff] [blame] | 77 | BL_RO_DATA_END |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 78 | #if USE_COHERENT_MEM |
Masahiro Yamada | 0fac5af | 2016-12-28 16:11:41 +0900 | [diff] [blame] | 79 | , BL_COHERENT_RAM_BASE, |
| 80 | BL_COHERENT_RAM_END |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 81 | #endif |
| 82 | ); |
Sandrine Bailleux | 4a1267a | 2016-05-18 16:11:47 +0100 | [diff] [blame] | 83 | enable_mmu_el1(0); |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 84 | } |