developer | 65014b8 | 2015-04-13 14:47:57 +0800 | [diff] [blame] | 1 | /* |
Sandrine Bailleux | 7659a26 | 2016-07-05 09:55:03 +0100 | [diff] [blame] | 2 | * Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved. |
developer | 65014b8 | 2015-04-13 14:47:57 +0800 | [diff] [blame] | 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are met: |
| 6 | * |
| 7 | * Redistributions of source code must retain the above copyright notice, this |
| 8 | * list of conditions and the following disclaimer. |
| 9 | * |
| 10 | * Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * |
| 14 | * Neither the name of ARM nor the names of its contributors may be used |
| 15 | * to endorse or promote products derived from this software without specific |
| 16 | * prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 22 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 28 | * POSSIBILITY OF SUCH DAMAGE. |
| 29 | */ |
| 30 | #include <arch_helpers.h> |
| 31 | #include <arm_gic.h> |
| 32 | #include <bl_common.h> |
| 33 | #include <cci.h> |
| 34 | #include <debug.h> |
| 35 | #include <mt8173_def.h> |
| 36 | #include <platform_def.h> |
Sandrine Bailleux | 7659a26 | 2016-07-05 09:55:03 +0100 | [diff] [blame] | 37 | #include <utils.h> |
developer | 65014b8 | 2015-04-13 14:47:57 +0800 | [diff] [blame] | 38 | #include <xlat_tables.h> |
| 39 | |
| 40 | static const int cci_map[] = { |
| 41 | PLAT_MT_CCI_CLUSTER0_SL_IFACE_IX, |
| 42 | PLAT_MT_CCI_CLUSTER1_SL_IFACE_IX |
| 43 | }; |
| 44 | |
| 45 | /* Table of regions to map using the MMU. */ |
| 46 | const mmap_region_t plat_mmap[] = { |
| 47 | /* for TF text, RO, RW */ |
developer | 4419325 | 2016-03-04 20:18:58 +0800 | [diff] [blame] | 48 | MAP_REGION_FLAT(TZRAM_BASE, TZRAM_SIZE, |
developer | 65014b8 | 2015-04-13 14:47:57 +0800 | [diff] [blame] | 49 | MT_MEMORY | MT_RW | MT_SECURE), |
| 50 | MAP_REGION_FLAT(MTK_DEV_RNG0_BASE, MTK_DEV_RNG0_SIZE, |
| 51 | MT_DEVICE | MT_RW | MT_SECURE), |
| 52 | MAP_REGION_FLAT(MTK_DEV_RNG1_BASE, MTK_DEV_RNG1_SIZE, |
| 53 | MT_DEVICE | MT_RW | MT_SECURE), |
| 54 | { 0 } |
| 55 | |
| 56 | }; |
| 57 | |
| 58 | /******************************************************************************* |
| 59 | * Macro generating the code for the function setting up the pagetables as per |
| 60 | * the platform memory map & initialize the mmu, for the given exception level |
| 61 | ******************************************************************************/ |
| 62 | #define DEFINE_CONFIGURE_MMU_EL(_el) \ |
| 63 | void plat_configure_mmu_el ## _el(unsigned long total_base, \ |
| 64 | unsigned long total_size, \ |
| 65 | unsigned long ro_start, \ |
| 66 | unsigned long ro_limit, \ |
| 67 | unsigned long coh_start, \ |
| 68 | unsigned long coh_limit) \ |
| 69 | { \ |
| 70 | mmap_add_region(total_base, total_base, \ |
| 71 | total_size, \ |
| 72 | MT_MEMORY | MT_RW | MT_SECURE); \ |
| 73 | mmap_add_region(ro_start, ro_start, \ |
| 74 | ro_limit - ro_start, \ |
| 75 | MT_MEMORY | MT_RO | MT_SECURE); \ |
| 76 | mmap_add_region(coh_start, coh_start, \ |
| 77 | coh_limit - coh_start, \ |
| 78 | MT_DEVICE | MT_RW | MT_SECURE); \ |
| 79 | mmap_add(plat_mmap); \ |
| 80 | init_xlat_tables(); \ |
| 81 | \ |
| 82 | enable_mmu_el ## _el(0); \ |
| 83 | } |
| 84 | |
| 85 | /* Define EL3 variants of the function initialising the MMU */ |
| 86 | DEFINE_CONFIGURE_MMU_EL(3) |
| 87 | |
Antonio Nino Diaz | e82e29c | 2016-05-19 10:00:28 +0100 | [diff] [blame] | 88 | unsigned int plat_get_syscnt_freq2(void) |
developer | 65014b8 | 2015-04-13 14:47:57 +0800 | [diff] [blame] | 89 | { |
| 90 | return SYS_COUNTER_FREQ_IN_TICKS; |
| 91 | } |
| 92 | |
| 93 | void plat_cci_init(void) |
| 94 | { |
| 95 | /* Initialize CCI driver */ |
| 96 | cci_init(PLAT_MT_CCI_BASE, cci_map, ARRAY_SIZE(cci_map)); |
| 97 | } |
| 98 | |
| 99 | void plat_cci_enable(void) |
| 100 | { |
| 101 | /* |
| 102 | * Enable CCI coherency for this cluster. |
| 103 | * No need for locks as no other cpu is active at the moment. |
| 104 | */ |
| 105 | cci_enable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr())); |
| 106 | } |
| 107 | |
| 108 | void plat_cci_disable(void) |
| 109 | { |
| 110 | cci_disable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr())); |
| 111 | } |