blob: 25105ba13e3273e6648e2fe4a4d9147b089a4b20 [file] [log] [blame]
Varun Wadekarb316e242015-05-19 16:48:04 +05301/*
Varun Wadekar4538bfc2019-01-02 17:53:15 -08002 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
Varun Wadekarb316e242015-05-19 16:48:04 +05303 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Varun Wadekarb316e242015-05-19 16:48:04 +05305 */
6
Varun Wadekarb7b45752015-12-28 14:55:41 -08007#include <arch_helpers.h>
Sam Payne71ce6ed2017-05-08 12:42:49 -07008#include <cortex_a57.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00009#include <common/bl_common.h>
Varun Wadekar4538bfc2019-01-02 17:53:15 -080010#include <common/debug.h>
11#include <common/interrupt_props.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000012#include <drivers/console.h>
13#include <lib/xlat_tables/xlat_tables_v2.h>
Varun Wadekar4538bfc2019-01-02 17:53:15 -080014#include <drivers/arm/gic_common.h>
15#include <drivers/arm/gicv2.h>
16#include <bl31/interrupt_mgmt.h>
17
18#include <bpmp.h>
19#include <flowctrl.h>
Varun Wadekare34bc3d2017-04-28 08:43:33 -070020#include <platform.h>
Marvin Hsu21eea972017-04-11 11:00:48 +080021#include <security_engine.h>
Varun Wadekarb316e242015-05-19 16:48:04 +053022#include <tegra_def.h>
Marvin Hsu21eea972017-04-11 11:00:48 +080023#include <tegra_platform.h>
Varun Wadekarb7b45752015-12-28 14:55:41 -080024#include <tegra_private.h>
Varun Wadekarb316e242015-05-19 16:48:04 +053025
Varun Wadekarb316e242015-05-19 16:48:04 +053026/* sets of MMIO ranges setup */
27#define MMIO_RANGE_0_ADDR 0x50000000
28#define MMIO_RANGE_1_ADDR 0x60000000
29#define MMIO_RANGE_2_ADDR 0x70000000
30#define MMIO_RANGE_SIZE 0x200000
31
32/*
33 * Table of regions to map using the MMU.
34 */
35static const mmap_region_t tegra_mmap[] = {
Varun Wadekar08554a62017-06-12 16:47:16 -070036 MAP_REGION_FLAT(TEGRA_IRAM_BASE, 0x40000, /* 256KB */
Varun Wadekara6a357f2017-05-05 09:20:59 -070037 MT_DEVICE | MT_RW | MT_SECURE),
Varun Wadekarb316e242015-05-19 16:48:04 +053038 MAP_REGION_FLAT(MMIO_RANGE_0_ADDR, MMIO_RANGE_SIZE,
39 MT_DEVICE | MT_RW | MT_SECURE),
40 MAP_REGION_FLAT(MMIO_RANGE_1_ADDR, MMIO_RANGE_SIZE,
41 MT_DEVICE | MT_RW | MT_SECURE),
42 MAP_REGION_FLAT(MMIO_RANGE_2_ADDR, MMIO_RANGE_SIZE,
43 MT_DEVICE | MT_RW | MT_SECURE),
44 {0}
45};
46
47/*******************************************************************************
48 * Set up the pagetables as per the platform memory map & initialize the MMU
49 ******************************************************************************/
50const mmap_region_t *plat_get_mmio_map(void)
51{
Marvin Hsu21eea972017-04-11 11:00:48 +080052 /* Add the map region for security engine SE2 */
53 if (tegra_chipid_is_t210_b01()) {
54 mmap_add_region((uint64_t)TEGRA_SE2_BASE,
55 (uint64_t)TEGRA_SE2_BASE,
56 (uint64_t)TEGRA_SE2_RANGE_SIZE,
57 MT_DEVICE | MT_RW | MT_SECURE);
58 }
59
Varun Wadekarb316e242015-05-19 16:48:04 +053060 /* MMIO space */
61 return tegra_mmap;
62}
63
64/*******************************************************************************
Varun Wadekare34bc3d2017-04-28 08:43:33 -070065 * The Tegra power domain tree has a single system level power domain i.e. a
66 * single root node. The first entry in the power domain descriptor specifies
67 * the number of power domains at the highest power level.
68 *******************************************************************************
69 */
70const unsigned char tegra_power_domain_tree_desc[] = {
71 /* No of root nodes */
72 1,
73 /* No of clusters */
74 PLATFORM_CLUSTER_COUNT,
75 /* No of CPU cores - cluster0 */
76 PLATFORM_MAX_CPUS_PER_CLUSTER,
77 /* No of CPU cores - cluster1 */
78 PLATFORM_MAX_CPUS_PER_CLUSTER
79};
80
81/*******************************************************************************
82 * This function returns the Tegra default topology tree information.
83 ******************************************************************************/
84const unsigned char *plat_get_power_domain_tree_desc(void)
85{
86 return tegra_power_domain_tree_desc;
87}
88
89/*******************************************************************************
Varun Wadekarb316e242015-05-19 16:48:04 +053090 * Handler to get the System Counter Frequency
91 ******************************************************************************/
Antonio Nino Diaze82e29c2016-05-19 10:00:28 +010092unsigned int plat_get_syscnt_freq2(void)
Varun Wadekarb316e242015-05-19 16:48:04 +053093{
94 return 19200000;
95}
Varun Wadekard2014c62015-10-29 10:37:28 +053096
97/*******************************************************************************
98 * Maximum supported UART controllers
99 ******************************************************************************/
100#define TEGRA210_MAX_UART_PORTS 5
101
102/*******************************************************************************
103 * This variable holds the UART port base addresses
104 ******************************************************************************/
105static uint32_t tegra210_uart_addresses[TEGRA210_MAX_UART_PORTS + 1] = {
106 0, /* undefined - treated as an error case */
107 TEGRA_UARTA_BASE,
108 TEGRA_UARTB_BASE,
109 TEGRA_UARTC_BASE,
110 TEGRA_UARTD_BASE,
111 TEGRA_UARTE_BASE,
112};
113
114/*******************************************************************************
115 * Retrieve the UART controller base to be used as the console
116 ******************************************************************************/
117uint32_t plat_get_console_from_id(int id)
118{
119 if (id > TEGRA210_MAX_UART_PORTS)
120 return 0;
121
122 return tegra210_uart_addresses[id];
123}
Varun Wadekarb7b45752015-12-28 14:55:41 -0800124
125/*******************************************************************************
Marvin Hsu21eea972017-04-11 11:00:48 +0800126 * Handler for early platform setup
127 ******************************************************************************/
128void plat_early_platform_setup(void)
129{
Sam Payne71ce6ed2017-05-08 12:42:49 -0700130 const plat_params_from_bl2_t *plat_params = bl31_get_plat_params();
131 uint64_t val;
132
133 /* platform parameter passed by the previous bootloader */
134 if (plat_params->l2_ecc_parity_prot_dis != 1) {
135 /* Enable ECC Parity Protection for Cortex-A57 CPUs */
136 val = read_l2ctlr_el1();
137 val |= (uint64_t)CORTEX_A57_L2_ECC_PARITY_PROTECTION_BIT;
138 write_l2ctlr_el1(val);
139 }
140
Marvin Hsu21eea972017-04-11 11:00:48 +0800141 /* Initialize security engine driver */
142 if (tegra_chipid_is_t210_b01()) {
143 tegra_se_init();
144 }
145}
146
Varun Wadekar4538bfc2019-01-02 17:53:15 -0800147/* Secure IRQs for Tegra186 */
148static const interrupt_prop_t tegra210_interrupt_props[] = {
149 INTR_PROP_DESC(TEGRA210_WDT_CPU_LEGACY_FIQ, GIC_HIGHEST_SEC_PRIORITY,
150 GICV2_INTR_GROUP0, GIC_INTR_CFG_EDGE),
151};
152
Marvin Hsu21eea972017-04-11 11:00:48 +0800153/*******************************************************************************
Varun Wadekarb7b45752015-12-28 14:55:41 -0800154 * Initialize the GIC and SGIs
155 ******************************************************************************/
156void plat_gic_setup(void)
157{
Varun Wadekar4538bfc2019-01-02 17:53:15 -0800158 tegra_gic_setup(tegra210_interrupt_props, ARRAY_SIZE(tegra210_interrupt_props));
159
160 /* Enable handling for FIQs */
161 tegra_fiq_handler_setup();
162
163 /*
164 * Enable routing watchdog FIQs from the flow controller to
165 * the GICD.
166 */
167 tegra_fc_enable_fiq_to_ccplex_routing();
Varun Wadekarb7b45752015-12-28 14:55:41 -0800168}