17d116dccSCC Ma /* 2ed81f3ebSSandrine Bailleux * Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved. 37d116dccSCC Ma * 4*82cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 57d116dccSCC Ma */ 67d116dccSCC Ma #include <arch_helpers.h> 77d116dccSCC Ma #include <arm_gic.h> 87d116dccSCC Ma #include <bl_common.h> 97d116dccSCC Ma #include <cci.h> 107d116dccSCC Ma #include <debug.h> 117d116dccSCC Ma #include <mt8173_def.h> 127d116dccSCC Ma #include <platform_def.h> 13ed81f3ebSSandrine Bailleux #include <utils.h> 147d116dccSCC Ma #include <xlat_tables.h> 157d116dccSCC Ma 167d116dccSCC Ma static const int cci_map[] = { 177d116dccSCC Ma PLAT_MT_CCI_CLUSTER0_SL_IFACE_IX, 187d116dccSCC Ma PLAT_MT_CCI_CLUSTER1_SL_IFACE_IX 197d116dccSCC Ma }; 207d116dccSCC Ma 217d116dccSCC Ma /* Table of regions to map using the MMU. */ 227d116dccSCC Ma const mmap_region_t plat_mmap[] = { 237d116dccSCC Ma /* for TF text, RO, RW */ 24e2a65959SJimmy Huang MAP_REGION_FLAT(TZRAM_BASE, TZRAM_SIZE, 257d116dccSCC Ma MT_MEMORY | MT_RW | MT_SECURE), 267d116dccSCC Ma MAP_REGION_FLAT(MTK_DEV_RNG0_BASE, MTK_DEV_RNG0_SIZE, 277d116dccSCC Ma MT_DEVICE | MT_RW | MT_SECURE), 287d116dccSCC Ma MAP_REGION_FLAT(MTK_DEV_RNG1_BASE, MTK_DEV_RNG1_SIZE, 297d116dccSCC Ma MT_DEVICE | MT_RW | MT_SECURE), 307d116dccSCC Ma { 0 } 317d116dccSCC Ma 327d116dccSCC Ma }; 337d116dccSCC Ma 347d116dccSCC Ma /******************************************************************************* 357d116dccSCC Ma * Macro generating the code for the function setting up the pagetables as per 367d116dccSCC Ma * the platform memory map & initialize the mmu, for the given exception level 377d116dccSCC Ma ******************************************************************************/ 387d116dccSCC Ma #define DEFINE_CONFIGURE_MMU_EL(_el) \ 397d116dccSCC Ma void plat_configure_mmu_el ## _el(unsigned long total_base, \ 407d116dccSCC Ma unsigned long total_size, \ 417d116dccSCC Ma unsigned long ro_start, \ 427d116dccSCC Ma unsigned long ro_limit, \ 437d116dccSCC Ma unsigned long coh_start, \ 447d116dccSCC Ma unsigned long coh_limit) \ 457d116dccSCC Ma { \ 467d116dccSCC Ma mmap_add_region(total_base, total_base, \ 477d116dccSCC Ma total_size, \ 487d116dccSCC Ma MT_MEMORY | MT_RW | MT_SECURE); \ 497d116dccSCC Ma mmap_add_region(ro_start, ro_start, \ 507d116dccSCC Ma ro_limit - ro_start, \ 517d116dccSCC Ma MT_MEMORY | MT_RO | MT_SECURE); \ 527d116dccSCC Ma mmap_add_region(coh_start, coh_start, \ 537d116dccSCC Ma coh_limit - coh_start, \ 547d116dccSCC Ma MT_DEVICE | MT_RW | MT_SECURE); \ 557d116dccSCC Ma mmap_add(plat_mmap); \ 567d116dccSCC Ma init_xlat_tables(); \ 577d116dccSCC Ma \ 587d116dccSCC Ma enable_mmu_el ## _el(0); \ 597d116dccSCC Ma } 607d116dccSCC Ma 617d116dccSCC Ma /* Define EL3 variants of the function initialising the MMU */ 627d116dccSCC Ma DEFINE_CONFIGURE_MMU_EL(3) 637d116dccSCC Ma 64f3d3b316SAntonio Nino Diaz unsigned int plat_get_syscnt_freq2(void) 657d116dccSCC Ma { 667d116dccSCC Ma return SYS_COUNTER_FREQ_IN_TICKS; 677d116dccSCC Ma } 687d116dccSCC Ma 697d116dccSCC Ma void plat_cci_init(void) 707d116dccSCC Ma { 717d116dccSCC Ma /* Initialize CCI driver */ 727d116dccSCC Ma cci_init(PLAT_MT_CCI_BASE, cci_map, ARRAY_SIZE(cci_map)); 737d116dccSCC Ma } 747d116dccSCC Ma 757d116dccSCC Ma void plat_cci_enable(void) 767d116dccSCC Ma { 777d116dccSCC Ma /* 787d116dccSCC Ma * Enable CCI coherency for this cluster. 797d116dccSCC Ma * No need for locks as no other cpu is active at the moment. 807d116dccSCC Ma */ 817d116dccSCC Ma cci_enable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr())); 827d116dccSCC Ma } 837d116dccSCC Ma 847d116dccSCC Ma void plat_cci_disable(void) 857d116dccSCC Ma { 867d116dccSCC Ma cci_disable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr())); 877d116dccSCC Ma } 88