Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch_helpers.h> |
| 8 | #include <assert.h> |
| 9 | #include <bl_common.h> |
| 10 | #include <debug.h> |
| 11 | #include <gicv2.h> |
| 12 | #include <mmio.h> |
| 13 | #include <platform_def.h> |
| 14 | #include <platform.h> |
| 15 | #include <stm32mp1_private.h> |
| 16 | #include <xlat_tables_v2.h> |
| 17 | |
| 18 | #define MAP_SRAM MAP_REGION_FLAT(STM32MP1_SRAM_BASE, \ |
| 19 | STM32MP1_SRAM_SIZE, \ |
| 20 | MT_MEMORY | \ |
| 21 | MT_RW | \ |
| 22 | MT_SECURE | \ |
| 23 | MT_EXECUTE_NEVER) |
| 24 | |
| 25 | #define MAP_DEVICE1 MAP_REGION_FLAT(STM32MP1_DEVICE1_BASE, \ |
| 26 | STM32MP1_DEVICE1_SIZE, \ |
| 27 | MT_DEVICE | \ |
| 28 | MT_RW | \ |
| 29 | MT_SECURE | \ |
| 30 | MT_EXECUTE_NEVER) |
| 31 | |
| 32 | #define MAP_DEVICE2 MAP_REGION_FLAT(STM32MP1_DEVICE2_BASE, \ |
| 33 | STM32MP1_DEVICE2_SIZE, \ |
| 34 | MT_DEVICE | \ |
| 35 | MT_RW | \ |
| 36 | MT_SECURE | \ |
| 37 | MT_EXECUTE_NEVER) |
| 38 | |
Yann Gautier | caf575b | 2018-07-24 17:18:19 +0200 | [diff] [blame] | 39 | #define MAP_DDR MAP_REGION_FLAT(STM32MP1_DDR_BASE, \ |
| 40 | STM32MP1_DDR_MAX_SIZE, \ |
| 41 | MT_MEMORY | \ |
| 42 | MT_RW | \ |
| 43 | MT_SECURE | \ |
| 44 | MT_EXECUTE_NEVER) |
| 45 | |
Yann Gautier | 9d135e4 | 2018-07-16 19:36:06 +0200 | [diff] [blame] | 46 | #define MAP_DDR_NS MAP_REGION_FLAT(STM32MP1_DDR_BASE, \ |
| 47 | STM32MP1_DDR_MAX_SIZE, \ |
| 48 | MT_MEMORY | \ |
| 49 | MT_RW | \ |
| 50 | MT_NS | \ |
| 51 | MT_EXECUTE_NEVER) |
| 52 | |
| 53 | #if defined(IMAGE_BL2) |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 54 | static const mmap_region_t stm32mp1_mmap[] = { |
| 55 | MAP_SRAM, |
| 56 | MAP_DEVICE1, |
| 57 | MAP_DEVICE2, |
Yann Gautier | caf575b | 2018-07-24 17:18:19 +0200 | [diff] [blame] | 58 | MAP_DDR, |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 59 | {0} |
| 60 | }; |
Yann Gautier | 9d135e4 | 2018-07-16 19:36:06 +0200 | [diff] [blame] | 61 | #endif |
| 62 | #if defined(IMAGE_BL32) |
| 63 | static const mmap_region_t stm32mp1_mmap[] = { |
| 64 | MAP_SRAM, |
| 65 | MAP_DEVICE1, |
| 66 | MAP_DEVICE2, |
| 67 | MAP_DDR_NS, |
| 68 | {0} |
| 69 | }; |
| 70 | #endif |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 71 | |
| 72 | void configure_mmu(void) |
| 73 | { |
| 74 | mmap_add(stm32mp1_mmap); |
| 75 | init_xlat_tables(); |
| 76 | |
Antonio Nino Diaz | 4bef6b0 | 2018-08-07 16:35:54 +0100 | [diff] [blame] | 77 | enable_mmu_svc_mon(0); |
Yann Gautier | 4b0c72a | 2018-07-16 10:54:09 +0200 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | uintptr_t plat_get_ns_image_entrypoint(void) |
| 81 | { |
| 82 | return BL33_BASE; |
| 83 | } |
| 84 | |
| 85 | unsigned int plat_get_syscnt_freq2(void) |
| 86 | { |
| 87 | return read_cntfrq_el0(); |
| 88 | } |
| 89 | |
| 90 | /* Functions to save and get boot context address given by ROM code */ |
| 91 | static uintptr_t boot_ctx_address; |
| 92 | |
| 93 | void stm32mp1_save_boot_ctx_address(uintptr_t address) |
| 94 | { |
| 95 | boot_ctx_address = address; |
| 96 | } |
| 97 | |
| 98 | uintptr_t stm32mp1_get_boot_ctx_address(void) |
| 99 | { |
| 100 | return boot_ctx_address; |
| 101 | } |