blob: 451da13e6f3abbfa40359e62f0cd90eef898b1c3 [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 Wadekara6a357f2017-05-05 09:20:59 -070028 MAP_REGION_FLAT(TEGRA_IRAMA_BASE, 0x10000, /* 64KB */
29 MT_DEVICE | MT_RW | MT_SECURE),
30 MAP_REGION_FLAT(TEGRA_IRAMB_BASE, 0x10000, /* 64KB */
31 MT_DEVICE | MT_RW | MT_SECURE),
Varun Wadekarb316e242015-05-19 16:48:04 +053032 MAP_REGION_FLAT(MMIO_RANGE_0_ADDR, MMIO_RANGE_SIZE,
33 MT_DEVICE | MT_RW | MT_SECURE),
34 MAP_REGION_FLAT(MMIO_RANGE_1_ADDR, MMIO_RANGE_SIZE,
35 MT_DEVICE | MT_RW | MT_SECURE),
36 MAP_REGION_FLAT(MMIO_RANGE_2_ADDR, MMIO_RANGE_SIZE,
37 MT_DEVICE | MT_RW | MT_SECURE),
38 {0}
39};
40
41/*******************************************************************************
42 * Set up the pagetables as per the platform memory map & initialize the MMU
43 ******************************************************************************/
44const mmap_region_t *plat_get_mmio_map(void)
45{
Marvin Hsu21eea972017-04-11 11:00:48 +080046 /* Add the map region for security engine SE2 */
47 if (tegra_chipid_is_t210_b01()) {
48 mmap_add_region((uint64_t)TEGRA_SE2_BASE,
49 (uint64_t)TEGRA_SE2_BASE,
50 (uint64_t)TEGRA_SE2_RANGE_SIZE,
51 MT_DEVICE | MT_RW | MT_SECURE);
52 }
53
Varun Wadekarb316e242015-05-19 16:48:04 +053054 /* MMIO space */
55 return tegra_mmap;
56}
57
58/*******************************************************************************
Varun Wadekare34bc3d2017-04-28 08:43:33 -070059 * The Tegra power domain tree has a single system level power domain i.e. a
60 * single root node. The first entry in the power domain descriptor specifies
61 * the number of power domains at the highest power level.
62 *******************************************************************************
63 */
64const unsigned char tegra_power_domain_tree_desc[] = {
65 /* No of root nodes */
66 1,
67 /* No of clusters */
68 PLATFORM_CLUSTER_COUNT,
69 /* No of CPU cores - cluster0 */
70 PLATFORM_MAX_CPUS_PER_CLUSTER,
71 /* No of CPU cores - cluster1 */
72 PLATFORM_MAX_CPUS_PER_CLUSTER
73};
74
75/*******************************************************************************
76 * This function returns the Tegra default topology tree information.
77 ******************************************************************************/
78const unsigned char *plat_get_power_domain_tree_desc(void)
79{
80 return tegra_power_domain_tree_desc;
81}
82
83/*******************************************************************************
Varun Wadekarb316e242015-05-19 16:48:04 +053084 * Handler to get the System Counter Frequency
85 ******************************************************************************/
Antonio Nino Diaze82e29c2016-05-19 10:00:28 +010086unsigned int plat_get_syscnt_freq2(void)
Varun Wadekarb316e242015-05-19 16:48:04 +053087{
88 return 19200000;
89}
Varun Wadekard2014c62015-10-29 10:37:28 +053090
91/*******************************************************************************
92 * Maximum supported UART controllers
93 ******************************************************************************/
94#define TEGRA210_MAX_UART_PORTS 5
95
96/*******************************************************************************
97 * This variable holds the UART port base addresses
98 ******************************************************************************/
99static uint32_t tegra210_uart_addresses[TEGRA210_MAX_UART_PORTS + 1] = {
100 0, /* undefined - treated as an error case */
101 TEGRA_UARTA_BASE,
102 TEGRA_UARTB_BASE,
103 TEGRA_UARTC_BASE,
104 TEGRA_UARTD_BASE,
105 TEGRA_UARTE_BASE,
106};
107
108/*******************************************************************************
109 * Retrieve the UART controller base to be used as the console
110 ******************************************************************************/
111uint32_t plat_get_console_from_id(int id)
112{
113 if (id > TEGRA210_MAX_UART_PORTS)
114 return 0;
115
116 return tegra210_uart_addresses[id];
117}
Varun Wadekarb7b45752015-12-28 14:55:41 -0800118
119/*******************************************************************************
Marvin Hsu21eea972017-04-11 11:00:48 +0800120 * Handler for early platform setup
121 ******************************************************************************/
122void plat_early_platform_setup(void)
123{
124 /* Initialize security engine driver */
125 if (tegra_chipid_is_t210_b01()) {
126 tegra_se_init();
127 }
128}
129
130/*******************************************************************************
Varun Wadekarb7b45752015-12-28 14:55:41 -0800131 * Initialize the GIC and SGIs
132 ******************************************************************************/
133void plat_gic_setup(void)
134{
135 tegra_gic_setup(NULL, 0);
136}