blob: d6b8bc3f8b8c88ded92165d416a66bc2c07d1a0b [file] [log] [blame]
Varun Wadekar921b9062015-08-25 17:03:14 +05301/*
Varun Wadekarb8776152016-03-03 13:52:52 -08002 * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
Varun Wadekar921b9062015-08-25 17:03:14 +05303 *
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
Varun Wadekarcad7b082015-12-28 18:12:59 -080031#include <arch_helpers.h>
32#include <assert.h>
33#include <bl_common.h>
Varun Wadekar921b9062015-08-25 17:03:14 +053034#include <console.h>
Varun Wadekarcad7b082015-12-28 18:12:59 -080035#include <context.h>
36#include <context_mgmt.h>
37#include <debug.h>
38#include <denver.h>
39#include <interrupt_mgmt.h>
40#include <platform.h>
Varun Wadekar921b9062015-08-25 17:03:14 +053041#include <tegra_def.h>
Varun Wadekarcad7b082015-12-28 18:12:59 -080042#include <tegra_private.h>
Varun Wadekar921b9062015-08-25 17:03:14 +053043#include <xlat_tables.h>
44
Varun Wadekarc2c3a2a2016-01-08 17:38:51 -080045/*******************************************************************************
46 * The Tegra power domain tree has a single system level power domain i.e. a
47 * single root node. The first entry in the power domain descriptor specifies
48 * the number of power domains at the highest power level.
49 *******************************************************************************
50 */
51const unsigned char tegra_power_domain_tree_desc[] = {
52 /* No of root nodes */
53 1,
54 /* No of clusters */
55 PLATFORM_CLUSTER_COUNT,
56 /* No of CPU cores - cluster0 */
57 PLATFORM_MAX_CPUS_PER_CLUSTER,
58 /* No of CPU cores - cluster1 */
59 PLATFORM_MAX_CPUS_PER_CLUSTER
60};
61
Varun Wadekar921b9062015-08-25 17:03:14 +053062/*
63 * Table of regions to map using the MMU.
64 */
65static const mmap_region_t tegra_mmap[] = {
66 MAP_REGION_FLAT(TEGRA_MISC_BASE, 0x10000, /* 64KB */
67 MT_DEVICE | MT_RW | MT_SECURE),
68 MAP_REGION_FLAT(TEGRA_MC_STREAMID_BASE, 0x10000, /* 64KB */
69 MT_DEVICE | MT_RW | MT_SECURE),
70 MAP_REGION_FLAT(TEGRA_MC_BASE, 0x10000, /* 64KB */
71 MT_DEVICE | MT_RW | MT_SECURE),
72 MAP_REGION_FLAT(TEGRA_UARTA_BASE, 0x20000, /* 128KB */
73 MT_DEVICE | MT_RW | MT_SECURE),
74 MAP_REGION_FLAT(TEGRA_GICD_BASE, 0x20000, /* 128KB */
75 MT_DEVICE | MT_RW | MT_SECURE),
Varun Wadekarb8776152016-03-03 13:52:52 -080076 MAP_REGION_FLAT(TEGRA_SE0_BASE, 0x10000, /* 64KB */
77 MT_DEVICE | MT_RW | MT_SECURE),
78 MAP_REGION_FLAT(TEGRA_PKA1_BASE, 0x10000, /* 64KB */
79 MT_DEVICE | MT_RW | MT_SECURE),
80 MAP_REGION_FLAT(TEGRA_RNG1_BASE, 0x10000, /* 64KB */
81 MT_DEVICE | MT_RW | MT_SECURE),
Varun Wadekare60f1bf2016-02-17 10:10:50 -080082 MAP_REGION_FLAT(TEGRA_CAR_RESET_BASE, 0x10000, /* 64KB */
83 MT_DEVICE | MT_RW | MT_SECURE),
Varun Wadekar921b9062015-08-25 17:03:14 +053084 MAP_REGION_FLAT(TEGRA_PMC_BASE, 0x40000, /* 256KB */
85 MT_DEVICE | MT_RW | MT_SECURE),
Varun Wadekarb8776152016-03-03 13:52:52 -080086 MAP_REGION_FLAT(TEGRA_SCRATCH_BASE, 0x10000, /* 64KB */
87 MT_DEVICE | MT_RW | MT_SECURE),
Varun Wadekar921b9062015-08-25 17:03:14 +053088 MAP_REGION_FLAT(TEGRA_MMCRAB_BASE, 0x60000, /* 384KB */
89 MT_DEVICE | MT_RW | MT_SECURE),
Varun Wadekarb8776152016-03-03 13:52:52 -080090 MAP_REGION_FLAT(TEGRA_SMMU_BASE, 0x1000000, /* 64KB */
Varun Wadekar921b9062015-08-25 17:03:14 +053091 MT_DEVICE | MT_RW | MT_SECURE),
92 {0}
93};
94
95/*******************************************************************************
96 * Set up the pagetables as per the platform memory map & initialize the MMU
97 ******************************************************************************/
98const mmap_region_t *plat_get_mmio_map(void)
99{
100 /* MMIO space */
101 return tegra_mmap;
102}
103
104/*******************************************************************************
105 * Handler to get the System Counter Frequency
106 ******************************************************************************/
107unsigned int plat_get_syscnt_freq2(void)
108{
Varun Wadekar20c94292016-01-04 10:57:45 -0800109 return 31250000;
Varun Wadekar921b9062015-08-25 17:03:14 +0530110}
111
112/*******************************************************************************
113 * Maximum supported UART controllers
114 ******************************************************************************/
115#define TEGRA186_MAX_UART_PORTS 7
116
117/*******************************************************************************
118 * This variable holds the UART port base addresses
119 ******************************************************************************/
120static uint32_t tegra186_uart_addresses[TEGRA186_MAX_UART_PORTS + 1] = {
121 0, /* undefined - treated as an error case */
122 TEGRA_UARTA_BASE,
123 TEGRA_UARTB_BASE,
124 TEGRA_UARTC_BASE,
125 TEGRA_UARTD_BASE,
126 TEGRA_UARTE_BASE,
127 TEGRA_UARTF_BASE,
128 TEGRA_UARTG_BASE,
129};
130
131/*******************************************************************************
132 * Retrieve the UART controller base to be used as the console
133 ******************************************************************************/
134uint32_t plat_get_console_from_id(int id)
135{
136 if (id > TEGRA186_MAX_UART_PORTS)
137 return 0;
138
139 return tegra186_uart_addresses[id];
140}
Varun Wadekarcad7b082015-12-28 18:12:59 -0800141
142/* Secure IRQs for Tegra186 */
143static const irq_sec_cfg_t tegra186_sec_irqs[] = {
144 {
145 TEGRA186_TOP_WDT_IRQ,
146 TEGRA186_SEC_IRQ_TARGET_MASK,
147 INTR_TYPE_EL3,
148 },
149 {
150 TEGRA186_AON_WDT_IRQ,
151 TEGRA186_SEC_IRQ_TARGET_MASK,
152 INTR_TYPE_EL3,
153 },
154};
155
156/*******************************************************************************
157 * Initialize the GIC and SGIs
158 ******************************************************************************/
159void plat_gic_setup(void)
160{
161 tegra_gic_setup(tegra186_sec_irqs,
162 sizeof(tegra186_sec_irqs) / sizeof(tegra186_sec_irqs[0]));
163
164 /*
165 * Initialize the FIQ handler only if the platform supports any
166 * FIQ interrupt sources.
167 */
168 if (sizeof(tegra186_sec_irqs) > 0)
169 tegra_fiq_handler_setup();
170}