blob: aefe1aa797493c017d8f3abb75548c4ff6ad042a [file] [log] [blame]
Varun Wadekarb316e242015-05-19 16:48:04 +05301/*
Varun Wadekare34bc3d2017-04-28 08:43:33 -07002 * Copyright (c) 2015-2017, 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>
Varun Wadekara6a357f2017-05-05 09:20:59 -07008#include <bpmp.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00009#include <common/bl_common.h>
10#include <drivers/console.h>
11#include <lib/xlat_tables/xlat_tables_v2.h>
Varun Wadekare34bc3d2017-04-28 08:43:33 -070012#include <platform.h>
Marvin Hsu21eea972017-04-11 11:00:48 +080013#include <security_engine.h>
Varun Wadekarb316e242015-05-19 16:48:04 +053014#include <tegra_def.h>
Marvin Hsu21eea972017-04-11 11:00:48 +080015#include <tegra_platform.h>
Varun Wadekarb7b45752015-12-28 14:55:41 -080016#include <tegra_private.h>
Varun Wadekarb316e242015-05-19 16:48:04 +053017
Varun Wadekarb316e242015-05-19 16:48:04 +053018/* sets of MMIO ranges setup */
19#define MMIO_RANGE_0_ADDR 0x50000000
20#define MMIO_RANGE_1_ADDR 0x60000000
21#define MMIO_RANGE_2_ADDR 0x70000000
22#define MMIO_RANGE_SIZE 0x200000
23
24/*
25 * Table of regions to map using the MMU.
26 */
27static const mmap_region_t tegra_mmap[] = {
Varun Wadekar08554a62017-06-12 16:47:16 -070028 MAP_REGION_FLAT(TEGRA_IRAM_BASE, 0x40000, /* 256KB */
Varun Wadekara6a357f2017-05-05 09:20:59 -070029 MT_DEVICE | MT_RW | MT_SECURE),
Varun Wadekarb316e242015-05-19 16:48:04 +053030 MAP_REGION_FLAT(MMIO_RANGE_0_ADDR, MMIO_RANGE_SIZE,
31 MT_DEVICE | MT_RW | MT_SECURE),
32 MAP_REGION_FLAT(MMIO_RANGE_1_ADDR, MMIO_RANGE_SIZE,
33 MT_DEVICE | MT_RW | MT_SECURE),
34 MAP_REGION_FLAT(MMIO_RANGE_2_ADDR, MMIO_RANGE_SIZE,
35 MT_DEVICE | MT_RW | MT_SECURE),
36 {0}
37};
38
39/*******************************************************************************
40 * Set up the pagetables as per the platform memory map & initialize the MMU
41 ******************************************************************************/
42const mmap_region_t *plat_get_mmio_map(void)
43{
Marvin Hsu21eea972017-04-11 11:00:48 +080044 /* Add the map region for security engine SE2 */
45 if (tegra_chipid_is_t210_b01()) {
46 mmap_add_region((uint64_t)TEGRA_SE2_BASE,
47 (uint64_t)TEGRA_SE2_BASE,
48 (uint64_t)TEGRA_SE2_RANGE_SIZE,
49 MT_DEVICE | MT_RW | MT_SECURE);
50 }
51
Varun Wadekarb316e242015-05-19 16:48:04 +053052 /* MMIO space */
53 return tegra_mmap;
54}
55
56/*******************************************************************************
Varun Wadekare34bc3d2017-04-28 08:43:33 -070057 * The Tegra power domain tree has a single system level power domain i.e. a
58 * single root node. The first entry in the power domain descriptor specifies
59 * the number of power domains at the highest power level.
60 *******************************************************************************
61 */
62const unsigned char tegra_power_domain_tree_desc[] = {
63 /* No of root nodes */
64 1,
65 /* No of clusters */
66 PLATFORM_CLUSTER_COUNT,
67 /* No of CPU cores - cluster0 */
68 PLATFORM_MAX_CPUS_PER_CLUSTER,
69 /* No of CPU cores - cluster1 */
70 PLATFORM_MAX_CPUS_PER_CLUSTER
71};
72
73/*******************************************************************************
74 * This function returns the Tegra default topology tree information.
75 ******************************************************************************/
76const unsigned char *plat_get_power_domain_tree_desc(void)
77{
78 return tegra_power_domain_tree_desc;
79}
80
81/*******************************************************************************
Varun Wadekarb316e242015-05-19 16:48:04 +053082 * Handler to get the System Counter Frequency
83 ******************************************************************************/
Antonio Nino Diaze82e29c2016-05-19 10:00:28 +010084unsigned int plat_get_syscnt_freq2(void)
Varun Wadekarb316e242015-05-19 16:48:04 +053085{
86 return 19200000;
87}
Varun Wadekard2014c62015-10-29 10:37:28 +053088
89/*******************************************************************************
90 * Maximum supported UART controllers
91 ******************************************************************************/
92#define TEGRA210_MAX_UART_PORTS 5
93
94/*******************************************************************************
95 * This variable holds the UART port base addresses
96 ******************************************************************************/
97static uint32_t tegra210_uart_addresses[TEGRA210_MAX_UART_PORTS + 1] = {
98 0, /* undefined - treated as an error case */
99 TEGRA_UARTA_BASE,
100 TEGRA_UARTB_BASE,
101 TEGRA_UARTC_BASE,
102 TEGRA_UARTD_BASE,
103 TEGRA_UARTE_BASE,
104};
105
106/*******************************************************************************
107 * Retrieve the UART controller base to be used as the console
108 ******************************************************************************/
109uint32_t plat_get_console_from_id(int id)
110{
111 if (id > TEGRA210_MAX_UART_PORTS)
112 return 0;
113
114 return tegra210_uart_addresses[id];
115}
Varun Wadekarb7b45752015-12-28 14:55:41 -0800116
117/*******************************************************************************
Marvin Hsu21eea972017-04-11 11:00:48 +0800118 * Handler for early platform setup
119 ******************************************************************************/
120void plat_early_platform_setup(void)
121{
122 /* Initialize security engine driver */
123 if (tegra_chipid_is_t210_b01()) {
124 tegra_se_init();
125 }
126}
127
128/*******************************************************************************
Varun Wadekarb7b45752015-12-28 14:55:41 -0800129 * Initialize the GIC and SGIs
130 ******************************************************************************/
131void plat_gic_setup(void)
132{
133 tegra_gic_setup(NULL, 0);
134}