blob: 5ba38c116565d860f225c769bd2fa26c94d30fa5 [file] [log] [blame]
Sandrine Bailleux798140d2014-07-17 16:06:39 +01001/*
2 * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
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
31#include <arch_helpers.h>
32#include <assert.h>
33#include <bl_common.h>
34#include <debug.h>
35#include <mmio.h>
36#include <platform.h>
37#include <platform_def.h>
38#include <xlat_tables.h>
39#include "../juno_def.h"
40
41/*
42 * Table of regions to map using the MMU.
43 * This doesn't include Trusted RAM as the 'mem_layout' argument passed to
44 * configure_mmu_elx() will give the available subset of that,
45 */
46static const mmap_region_t juno_mmap[] = {
47 { TZROM_BASE, TZROM_BASE, TZROM_SIZE, MT_MEMORY | MT_RO | MT_SECURE },
48 { MHU_SECURE_BASE, MHU_SECURE_BASE, MHU_SECURE_SIZE, (MHU_PAYLOAD_CACHED ? MT_MEMORY : MT_DEVICE) | MT_RW | MT_SECURE },
49 { FLASH_BASE, FLASH_BASE, FLASH_SIZE, MT_MEMORY | MT_RO | MT_SECURE },
50 { EMMC_BASE, EMMC_BASE, EMMC_SIZE, MT_MEMORY | MT_RO | MT_SECURE },
51 { PSRAM_BASE, PSRAM_BASE, PSRAM_SIZE, MT_MEMORY | MT_RW | MT_SECURE }, /* Used for 'TZDRAM' */
52 { IOFPGA_BASE, IOFPGA_BASE, IOFPGA_SIZE, MT_DEVICE | MT_RW | MT_SECURE },
53 { DEVICE0_BASE, DEVICE0_BASE, DEVICE0_SIZE, MT_DEVICE | MT_RW | MT_SECURE },
54 { DEVICE1_BASE, DEVICE1_BASE, DEVICE1_SIZE, MT_DEVICE | MT_RW | MT_SECURE },
55 { DRAM_BASE, DRAM_BASE, DRAM_SIZE, MT_MEMORY | MT_RW | MT_NS },
56 {0}
57};
58
59/*******************************************************************************
60 * Macro generating the code for the function setting up the pagetables as per
61 * the platform memory map & initialize the mmu, for the given exception level
62 ******************************************************************************/
63#define DEFINE_CONFIGURE_MMU_EL(_el) \
64 void configure_mmu_el##_el(unsigned long total_base, \
65 unsigned long total_size, \
66 unsigned long ro_start, \
67 unsigned long ro_limit, \
68 unsigned long coh_start, \
69 unsigned long coh_limit) \
70 { \
71 mmap_add_region(total_base, total_base, \
72 total_size, \
73 MT_MEMORY | MT_RW | MT_SECURE); \
74 mmap_add_region(ro_start, ro_start, \
75 ro_limit - ro_start, \
76 MT_MEMORY | MT_RO | MT_SECURE); \
77 mmap_add_region(coh_start, coh_start, \
78 coh_limit - coh_start, \
79 MT_DEVICE | MT_RW | MT_SECURE); \
80 mmap_add(juno_mmap); \
81 init_xlat_tables(); \
82 \
83 enable_mmu_el##_el(0); \
84 }
85
86/* Define EL1 and EL3 variants of the function initialising the MMU */
87DEFINE_CONFIGURE_MMU_EL(1)
88DEFINE_CONFIGURE_MMU_EL(3)
89
90
91unsigned long plat_get_ns_image_entrypoint(void)
92{
93 return NS_IMAGE_OFFSET;
94}
95
96uint64_t plat_get_syscnt_freq(void)
97{
98 uint64_t counter_base_frequency;
99
100 /* Read the frequency from Frequency modes table */
101 counter_base_frequency = mmio_read_32(SYS_CNTCTL_BASE + CNTFID_OFF);
102
103 /* The first entry of the frequency modes table must not be 0 */
104 if (counter_base_frequency == 0)
105 panic();
106
107 return counter_base_frequency;
108}