Konstantin Porotchkin | f69ec58 | 2018-06-07 18:31:14 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 Marvell International Ltd. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * https://spdx.org/licenses |
| 6 | */ |
| 7 | |
| 8 | #include <bl1.h> |
| 9 | #include <bl1/bl1_private.h> |
| 10 | #include <bl_common.h> |
| 11 | #include <console.h> |
| 12 | #include <debug.h> |
| 13 | #include <platform.h> |
| 14 | #include <platform_def.h> |
| 15 | #include <plat_marvell.h> |
| 16 | #include <sp805.h> |
| 17 | |
| 18 | /* Weak definitions may be overridden in specific Marvell standard platform */ |
| 19 | #pragma weak bl1_early_platform_setup |
| 20 | #pragma weak bl1_plat_arch_setup |
| 21 | #pragma weak bl1_platform_setup |
| 22 | #pragma weak bl1_plat_sec_mem_layout |
| 23 | |
| 24 | |
| 25 | /* Data structure which holds the extents of the RAM for BL1*/ |
| 26 | static meminfo_t bl1_ram_layout; |
| 27 | |
| 28 | meminfo_t *bl1_plat_sec_mem_layout(void) |
| 29 | { |
| 30 | return &bl1_ram_layout; |
| 31 | } |
| 32 | |
| 33 | /* |
| 34 | * BL1 specific platform actions shared between Marvell standard platforms. |
| 35 | */ |
| 36 | void marvell_bl1_early_platform_setup(void) |
| 37 | { |
| 38 | const size_t bl1_size = BL1_RAM_LIMIT - BL1_RAM_BASE; |
| 39 | |
| 40 | /* Initialize the console to provide early debug support */ |
| 41 | console_init(PLAT_MARVELL_BOOT_UART_BASE, |
| 42 | PLAT_MARVELL_BOOT_UART_CLK_IN_HZ, |
| 43 | MARVELL_CONSOLE_BAUDRATE); |
| 44 | |
| 45 | /* Allow BL1 to see the whole Trusted RAM */ |
| 46 | bl1_ram_layout.total_base = MARVELL_BL_RAM_BASE; |
| 47 | bl1_ram_layout.total_size = MARVELL_BL_RAM_SIZE; |
| 48 | |
| 49 | /* Calculate how much RAM BL1 is using and how much remains free */ |
| 50 | bl1_ram_layout.free_base = MARVELL_BL_RAM_BASE; |
| 51 | bl1_ram_layout.free_size = MARVELL_BL_RAM_SIZE; |
| 52 | reserve_mem(&bl1_ram_layout.free_base, |
| 53 | &bl1_ram_layout.free_size, |
| 54 | BL1_RAM_BASE, |
| 55 | bl1_size); |
| 56 | } |
| 57 | |
| 58 | void bl1_early_platform_setup(void) |
| 59 | { |
| 60 | marvell_bl1_early_platform_setup(); |
| 61 | } |
| 62 | |
| 63 | /* |
| 64 | * Perform the very early platform specific architecture setup shared between |
| 65 | * MARVELL standard platforms. This only does basic initialization. Later |
| 66 | * architectural setup (bl1_arch_setup()) does not do anything platform |
| 67 | * specific. |
| 68 | */ |
| 69 | void marvell_bl1_plat_arch_setup(void) |
| 70 | { |
| 71 | marvell_setup_page_tables(bl1_ram_layout.total_base, |
| 72 | bl1_ram_layout.total_size, |
| 73 | BL1_RO_BASE, |
| 74 | BL1_RO_LIMIT, |
| 75 | BL1_RO_DATA_BASE, |
| 76 | BL1_RO_DATA_END |
| 77 | #if USE_COHERENT_MEM |
| 78 | , BL_COHERENT_RAM_BASE, |
| 79 | BL_COHERENT_RAM_END |
| 80 | #endif |
| 81 | ); |
| 82 | enable_mmu_el3(0); |
| 83 | } |
| 84 | |
| 85 | void bl1_plat_arch_setup(void) |
| 86 | { |
| 87 | marvell_bl1_plat_arch_setup(); |
| 88 | } |
| 89 | |
| 90 | /* |
| 91 | * Perform the platform specific architecture setup shared between |
| 92 | * MARVELL standard platforms. |
| 93 | */ |
| 94 | void marvell_bl1_platform_setup(void) |
| 95 | { |
| 96 | /* Initialise the IO layer and register platform IO devices */ |
| 97 | plat_marvell_io_setup(); |
| 98 | } |
| 99 | |
| 100 | void bl1_platform_setup(void) |
| 101 | { |
| 102 | marvell_bl1_platform_setup(); |
| 103 | } |
| 104 | |
| 105 | void bl1_plat_prepare_exit(entry_point_info_t *ep_info) |
| 106 | { |
| 107 | #ifdef EL3_PAYLOAD_BASE |
| 108 | /* |
| 109 | * Program the EL3 payload's entry point address into the CPUs mailbox |
| 110 | * in order to release secondary CPUs from their holding pen and make |
| 111 | * them jump there. |
| 112 | */ |
| 113 | marvell_program_trusted_mailbox(ep_info->pc); |
| 114 | dsbsy(); |
| 115 | sev(); |
| 116 | #endif |
| 117 | } |