17d116dccSCC Ma /* 27d116dccSCC Ma * Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved. 37d116dccSCC Ma * 47d116dccSCC Ma * Redistribution and use in source and binary forms, with or without 57d116dccSCC Ma * modification, are permitted provided that the following conditions are met: 67d116dccSCC Ma * 77d116dccSCC Ma * Redistributions of source code must retain the above copyright notice, this 87d116dccSCC Ma * list of conditions and the following disclaimer. 97d116dccSCC Ma * 107d116dccSCC Ma * Redistributions in binary form must reproduce the above copyright notice, 117d116dccSCC Ma * this list of conditions and the following disclaimer in the documentation 127d116dccSCC Ma * and/or other materials provided with the distribution. 137d116dccSCC Ma * 147d116dccSCC Ma * Neither the name of ARM nor the names of its contributors may be used 157d116dccSCC Ma * to endorse or promote products derived from this software without specific 167d116dccSCC Ma * prior written permission. 177d116dccSCC Ma * 187d116dccSCC Ma * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 197d116dccSCC Ma * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 207d116dccSCC Ma * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 217d116dccSCC Ma * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 227d116dccSCC Ma * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 237d116dccSCC Ma * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 247d116dccSCC Ma * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 257d116dccSCC Ma * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 267d116dccSCC Ma * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 277d116dccSCC Ma * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 287d116dccSCC Ma * POSSIBILITY OF SUCH DAMAGE. 297d116dccSCC Ma */ 307d116dccSCC Ma #include <arch_helpers.h> 317d116dccSCC Ma #include <arm_gic.h> 327d116dccSCC Ma #include <bl_common.h> 337d116dccSCC Ma #include <cci.h> 347d116dccSCC Ma #include <debug.h> 357d116dccSCC Ma #include <mt8173_def.h> 367d116dccSCC Ma #include <platform_def.h> 377d116dccSCC Ma #include <xlat_tables.h> 387d116dccSCC Ma 397d116dccSCC Ma static const int cci_map[] = { 407d116dccSCC Ma PLAT_MT_CCI_CLUSTER0_SL_IFACE_IX, 417d116dccSCC Ma PLAT_MT_CCI_CLUSTER1_SL_IFACE_IX 427d116dccSCC Ma }; 437d116dccSCC Ma 447d116dccSCC Ma /* Table of regions to map using the MMU. */ 457d116dccSCC Ma const mmap_region_t plat_mmap[] = { 467d116dccSCC Ma /* for TF text, RO, RW */ 47e2a65959SJimmy Huang MAP_REGION_FLAT(TZRAM_BASE, TZRAM_SIZE, 487d116dccSCC Ma MT_MEMORY | MT_RW | MT_SECURE), 497d116dccSCC Ma MAP_REGION_FLAT(MTK_DEV_RNG0_BASE, MTK_DEV_RNG0_SIZE, 507d116dccSCC Ma MT_DEVICE | MT_RW | MT_SECURE), 517d116dccSCC Ma MAP_REGION_FLAT(MTK_DEV_RNG1_BASE, MTK_DEV_RNG1_SIZE, 527d116dccSCC Ma MT_DEVICE | MT_RW | MT_SECURE), 537d116dccSCC Ma { 0 } 547d116dccSCC Ma 557d116dccSCC Ma }; 567d116dccSCC Ma 577d116dccSCC Ma /******************************************************************************* 587d116dccSCC Ma * Macro generating the code for the function setting up the pagetables as per 597d116dccSCC Ma * the platform memory map & initialize the mmu, for the given exception level 607d116dccSCC Ma ******************************************************************************/ 617d116dccSCC Ma #define DEFINE_CONFIGURE_MMU_EL(_el) \ 627d116dccSCC Ma void plat_configure_mmu_el ## _el(unsigned long total_base, \ 637d116dccSCC Ma unsigned long total_size, \ 647d116dccSCC Ma unsigned long ro_start, \ 657d116dccSCC Ma unsigned long ro_limit, \ 667d116dccSCC Ma unsigned long coh_start, \ 677d116dccSCC Ma unsigned long coh_limit) \ 687d116dccSCC Ma { \ 697d116dccSCC Ma mmap_add_region(total_base, total_base, \ 707d116dccSCC Ma total_size, \ 717d116dccSCC Ma MT_MEMORY | MT_RW | MT_SECURE); \ 727d116dccSCC Ma mmap_add_region(ro_start, ro_start, \ 737d116dccSCC Ma ro_limit - ro_start, \ 747d116dccSCC Ma MT_MEMORY | MT_RO | MT_SECURE); \ 757d116dccSCC Ma mmap_add_region(coh_start, coh_start, \ 767d116dccSCC Ma coh_limit - coh_start, \ 777d116dccSCC Ma MT_DEVICE | MT_RW | MT_SECURE); \ 787d116dccSCC Ma mmap_add(plat_mmap); \ 797d116dccSCC Ma init_xlat_tables(); \ 807d116dccSCC Ma \ 817d116dccSCC Ma enable_mmu_el ## _el(0); \ 827d116dccSCC Ma } 837d116dccSCC Ma 847d116dccSCC Ma /* Define EL3 variants of the function initialising the MMU */ 857d116dccSCC Ma DEFINE_CONFIGURE_MMU_EL(3) 867d116dccSCC Ma 87*f3d3b316SAntonio Nino Diaz unsigned int plat_get_syscnt_freq2(void) 887d116dccSCC Ma { 897d116dccSCC Ma return SYS_COUNTER_FREQ_IN_TICKS; 907d116dccSCC Ma } 917d116dccSCC Ma 927d116dccSCC Ma void plat_cci_init(void) 937d116dccSCC Ma { 947d116dccSCC Ma /* Initialize CCI driver */ 957d116dccSCC Ma cci_init(PLAT_MT_CCI_BASE, cci_map, ARRAY_SIZE(cci_map)); 967d116dccSCC Ma } 977d116dccSCC Ma 987d116dccSCC Ma void plat_cci_enable(void) 997d116dccSCC Ma { 1007d116dccSCC Ma /* 1017d116dccSCC Ma * Enable CCI coherency for this cluster. 1027d116dccSCC Ma * No need for locks as no other cpu is active at the moment. 1037d116dccSCC Ma */ 1047d116dccSCC Ma cci_enable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr())); 1057d116dccSCC Ma } 1067d116dccSCC Ma 1077d116dccSCC Ma void plat_cci_disable(void) 1087d116dccSCC Ma { 1097d116dccSCC Ma cci_disable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr())); 1107d116dccSCC Ma } 111