blob: df6267897086496f85478d1a19ad9eaf869f9d19 [file] [log] [blame]
Varun Wadekar0f3baa02015-07-16 11:36:33 +05301/*
Varun Wadekar84a775e2019-01-03 10:12:55 -08002 * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved.
Varun Wadekar0f3baa02015-07-16 11:36:33 +05303 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Varun Wadekar0f3baa02015-07-16 11:36:33 +05305 */
6
Varun Wadekarb7b45752015-12-28 14:55:41 -08007#include <arch_helpers.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008#include <common/bl_common.h>
Varun Wadekar9d15f7e2019-08-21 14:01:31 -07009#include <drivers/console.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010#include <lib/xlat_tables/xlat_tables_v2.h>
Ambroise Vincentffbf32a2019-03-28 09:01:18 +000011#include <plat/common/platform.h>
Varun Wadekar0f3baa02015-07-16 11:36:33 +053012#include <tegra_def.h>
Varun Wadekar9d15f7e2019-08-21 14:01:31 -070013#include <tegra_platform.h>
Varun Wadekarb7b45752015-12-28 14:55:41 -080014#include <tegra_private.h>
Varun Wadekar0f3baa02015-07-16 11:36:33 +053015
Varun Wadekar0f3baa02015-07-16 11:36:33 +053016/* sets of MMIO ranges setup */
17#define MMIO_RANGE_0_ADDR 0x50000000
18#define MMIO_RANGE_1_ADDR 0x60000000
19#define MMIO_RANGE_2_ADDR 0x70000000
20#define MMIO_RANGE_SIZE 0x200000
21
22/*
23 * Table of regions to map using the MMU.
24 */
25static const mmap_region_t tegra_mmap[] = {
26 MAP_REGION_FLAT(MMIO_RANGE_0_ADDR, MMIO_RANGE_SIZE,
27 MT_DEVICE | MT_RW | MT_SECURE),
28 MAP_REGION_FLAT(MMIO_RANGE_1_ADDR, MMIO_RANGE_SIZE,
29 MT_DEVICE | MT_RW | MT_SECURE),
30 MAP_REGION_FLAT(MMIO_RANGE_2_ADDR, MMIO_RANGE_SIZE,
31 MT_DEVICE | MT_RW | MT_SECURE),
32 {0}
33};
34
35/*******************************************************************************
36 * Set up the pagetables as per the platform memory map & initialize the MMU
37 ******************************************************************************/
38const mmap_region_t *plat_get_mmio_map(void)
39{
40 /* MMIO space */
41 return tegra_mmap;
42}
43
Varun Wadekare34bc3d2017-04-28 08:43:33 -070044/*******************************************************************************
45 * The Tegra power domain tree has a single system level power domain i.e. a
46 * single root node. The first entry in the power domain descriptor specifies
47 * the number of power domains at the highest power level.
48 *******************************************************************************
49 */
50const unsigned char tegra_power_domain_tree_desc[] = {
51 /* No of root nodes */
52 1,
53 /* No of clusters */
54 PLATFORM_CLUSTER_COUNT,
55 /* No of CPU cores */
56 PLATFORM_CORE_COUNT,
57};
58
59/*******************************************************************************
60 * This function returns the Tegra default topology tree information.
61 ******************************************************************************/
62const unsigned char *plat_get_power_domain_tree_desc(void)
63{
64 return tegra_power_domain_tree_desc;
65}
66
Antonio Nino Diaze82e29c2016-05-19 10:00:28 +010067unsigned int plat_get_syscnt_freq2(void)
Varun Wadekar0f3baa02015-07-16 11:36:33 +053068{
69 return 12000000;
70}
Varun Wadekard2014c62015-10-29 10:37:28 +053071
72/*******************************************************************************
73 * Maximum supported UART controllers
74 ******************************************************************************/
75#define TEGRA132_MAX_UART_PORTS 5
76
77/*******************************************************************************
78 * This variable holds the UART port base addresses
79 ******************************************************************************/
80static uint32_t tegra132_uart_addresses[TEGRA132_MAX_UART_PORTS + 1] = {
81 0, /* undefined - treated as an error case */
82 TEGRA_UARTA_BASE,
83 TEGRA_UARTB_BASE,
84 TEGRA_UARTC_BASE,
85 TEGRA_UARTD_BASE,
86 TEGRA_UARTE_BASE,
87};
88
89/*******************************************************************************
Varun Wadekar9d15f7e2019-08-21 14:01:31 -070090 * Enable console corresponding to the console ID
Varun Wadekard2014c62015-10-29 10:37:28 +053091 ******************************************************************************/
Varun Wadekar9d15f7e2019-08-21 14:01:31 -070092void plat_enable_console(int32_t id)
Varun Wadekard2014c62015-10-29 10:37:28 +053093{
Varun Wadekar9d15f7e2019-08-21 14:01:31 -070094 static console_16550_t uart_console;
95 uint32_t console_clock;
96
97 if ((id > 0) && (id < TEGRA132_MAX_UART_PORTS)) {
98 /*
99 * Reference clock used by the FPGAs is a lot slower.
100 */
101 if (tegra_platform_is_fpga()) {
102 console_clock = TEGRA_BOOT_UART_CLK_13_MHZ;
103 } else {
104 console_clock = TEGRA_BOOT_UART_CLK_408_MHZ;
105 }
Varun Wadekard2014c62015-10-29 10:37:28 +0530106
Varun Wadekar9d15f7e2019-08-21 14:01:31 -0700107 (void)console_16550_register(tegra132_uart_addresses[id],
108 console_clock,
109 TEGRA_CONSOLE_BAUDRATE,
110 &uart_console);
111 console_set_scope(&uart_console.console, CONSOLE_FLAG_BOOT |
112 CONSOLE_FLAG_RUNTIME | CONSOLE_FLAG_CRASH);
113 }
Varun Wadekard2014c62015-10-29 10:37:28 +0530114}
Varun Wadekarb7b45752015-12-28 14:55:41 -0800115
116/*******************************************************************************
117 * Initialize the GIC and SGIs
118 ******************************************************************************/
119void plat_gic_setup(void)
120{
121 tegra_gic_setup(NULL, 0);
Varun Wadekar84a775e2019-01-03 10:12:55 -0800122 tegra_gic_init();
Varun Wadekarb7b45752015-12-28 14:55:41 -0800123}