Jorge Ramirez-Ortiz | a29d9a6 | 2017-06-28 10:11:31 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Jorge Ramirez-Ortiz | a29d9a6 | 2017-06-28 10:11:31 +0200 | [diff] [blame] | 7 | #include <assert.h> |
Jorge Ramirez-Ortiz | a29d9a6 | 2017-06-28 10:11:31 +0200 | [diff] [blame] | 8 | #include <errno.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 9 | |
| 10 | #include <arch_helpers.h> |
| 11 | #include <common/bl_common.h> |
| 12 | #include <common/debug.h> |
| 13 | #include <drivers/delay_timer.h> |
| 14 | #include <lib/mmio.h> |
| 15 | #include <lib/xlat_tables/xlat_tables.h> |
| 16 | #include <plat/common/platform.h> |
| 17 | |
Jorge Ramirez-Ortiz | a29d9a6 | 2017-06-28 10:11:31 +0200 | [diff] [blame] | 18 | #include "hi3798cv200.h" |
| 19 | #include "platform_def.h" |
| 20 | |
| 21 | #define MAP_DDR MAP_REGION_FLAT(DDR_BASE, \ |
| 22 | DDR_SIZE, \ |
| 23 | MT_MEMORY | MT_RW | MT_NS) |
| 24 | |
| 25 | #define MAP_DEVICE MAP_REGION_FLAT(DEVICE_BASE, \ |
| 26 | DEVICE_SIZE, \ |
| 27 | MT_DEVICE | MT_RW | MT_SECURE) |
| 28 | |
Victor Chong | 662556a | 2017-10-28 01:59:41 +0900 | [diff] [blame] | 29 | #define MAP_TSP_MEM MAP_REGION_FLAT(TSP_SEC_MEM_BASE, \ |
| 30 | TSP_SEC_MEM_SIZE, \ |
| 31 | MT_MEMORY | MT_RW | MT_SECURE) |
| 32 | |
Victor Chong | aa03347 | 2018-02-01 00:35:39 +0900 | [diff] [blame] | 33 | #ifdef SPD_opteed |
| 34 | #define MAP_OPTEE_PAGEABLE MAP_REGION_FLAT( \ |
| 35 | POPLAR_OPTEE_PAGEABLE_LOAD_BASE, \ |
| 36 | POPLAR_OPTEE_PAGEABLE_LOAD_SIZE, \ |
| 37 | MT_MEMORY | MT_RW | MT_SECURE) |
| 38 | #endif |
Victor Chong | aa03347 | 2018-02-01 00:35:39 +0900 | [diff] [blame] | 39 | |
Jorge Ramirez-Ortiz | a29d9a6 | 2017-06-28 10:11:31 +0200 | [diff] [blame] | 40 | static const mmap_region_t poplar_mmap[] = { |
| 41 | MAP_DDR, |
| 42 | MAP_DEVICE, |
Victor Chong | 662556a | 2017-10-28 01:59:41 +0900 | [diff] [blame] | 43 | MAP_TSP_MEM, |
Victor Chong | aa03347 | 2018-02-01 00:35:39 +0900 | [diff] [blame] | 44 | #ifdef SPD_opteed |
| 45 | MAP_OPTEE_PAGEABLE, |
| 46 | #endif |
Jorge Ramirez-Ortiz | a29d9a6 | 2017-06-28 10:11:31 +0200 | [diff] [blame] | 47 | {0} |
| 48 | }; |
| 49 | |
| 50 | #define DEFINE_CONFIGURE_MMU_EL(_el) \ |
| 51 | void plat_configure_mmu_el##_el(unsigned long total_base, \ |
| 52 | unsigned long total_size, \ |
| 53 | unsigned long ro_start, \ |
| 54 | unsigned long ro_limit, \ |
| 55 | unsigned long coh_start, \ |
| 56 | unsigned long coh_limit) \ |
| 57 | { \ |
| 58 | mmap_add_region(total_base, total_base, \ |
| 59 | total_size, \ |
| 60 | MT_MEMORY | MT_RW | MT_SECURE); \ |
| 61 | mmap_add_region(ro_start, ro_start, \ |
| 62 | ro_limit - ro_start, \ |
| 63 | MT_MEMORY | MT_RO | MT_SECURE); \ |
| 64 | mmap_add_region(coh_start, coh_start, \ |
| 65 | coh_limit - coh_start, \ |
| 66 | MT_DEVICE | MT_RW | MT_SECURE); \ |
| 67 | mmap_add(poplar_mmap); \ |
| 68 | init_xlat_tables(); \ |
| 69 | \ |
| 70 | enable_mmu_el##_el(0); \ |
| 71 | } |
| 72 | |
| 73 | DEFINE_CONFIGURE_MMU_EL(3) |
| 74 | DEFINE_CONFIGURE_MMU_EL(1) |
| 75 | |
| 76 | unsigned int plat_get_syscnt_freq2(void) |
| 77 | { |
| 78 | return SYS_COUNTER_FREQ_IN_TICKS; |
| 79 | } |