Varun Wadekar | 0f3baa0 | 2015-07-16 11:36:33 +0530 | [diff] [blame] | 1 | /* |
Varun Wadekar | 84a775e | 2019-01-03 10:12:55 -0800 | [diff] [blame] | 2 | * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved. |
Varun Wadekar | 7cf57d7 | 2018-05-17 09:36:38 -0700 | [diff] [blame] | 3 | * Copyright (c) 2020, NVIDIA Corporation. All rights reserved. |
Varun Wadekar | 0f3baa0 | 2015-07-16 11:36:33 +0530 | [diff] [blame] | 4 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 5 | * SPDX-License-Identifier: BSD-3-Clause |
Varun Wadekar | 0f3baa0 | 2015-07-16 11:36:33 +0530 | [diff] [blame] | 6 | */ |
| 7 | |
Varun Wadekar | b7b4575 | 2015-12-28 14:55:41 -0800 | [diff] [blame] | 8 | #include <arch_helpers.h> |
kalyanic | 0a2cc61 | 2019-09-13 14:49:39 -0700 | [diff] [blame^] | 9 | #include <assert.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | #include <common/bl_common.h> |
Varun Wadekar | 9d15f7e | 2019-08-21 14:01:31 -0700 | [diff] [blame] | 11 | #include <drivers/console.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 12 | #include <lib/xlat_tables/xlat_tables_v2.h> |
Ambroise Vincent | ffbf32a | 2019-03-28 09:01:18 +0000 | [diff] [blame] | 13 | #include <plat/common/platform.h> |
Varun Wadekar | 0f3baa0 | 2015-07-16 11:36:33 +0530 | [diff] [blame] | 14 | #include <tegra_def.h> |
Varun Wadekar | 9d15f7e | 2019-08-21 14:01:31 -0700 | [diff] [blame] | 15 | #include <tegra_platform.h> |
Varun Wadekar | b7b4575 | 2015-12-28 14:55:41 -0800 | [diff] [blame] | 16 | #include <tegra_private.h> |
Varun Wadekar | 0f3baa0 | 2015-07-16 11:36:33 +0530 | [diff] [blame] | 17 | |
Varun Wadekar | 0f3baa0 | 2015-07-16 11:36:33 +0530 | [diff] [blame] | 18 | /* 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 | */ |
| 27 | static const mmap_region_t tegra_mmap[] = { |
| 28 | MAP_REGION_FLAT(MMIO_RANGE_0_ADDR, MMIO_RANGE_SIZE, |
| 29 | MT_DEVICE | MT_RW | MT_SECURE), |
| 30 | MAP_REGION_FLAT(MMIO_RANGE_1_ADDR, MMIO_RANGE_SIZE, |
| 31 | MT_DEVICE | MT_RW | MT_SECURE), |
| 32 | MAP_REGION_FLAT(MMIO_RANGE_2_ADDR, MMIO_RANGE_SIZE, |
| 33 | MT_DEVICE | MT_RW | MT_SECURE), |
| 34 | {0} |
| 35 | }; |
| 36 | |
| 37 | /******************************************************************************* |
| 38 | * Set up the pagetables as per the platform memory map & initialize the MMU |
| 39 | ******************************************************************************/ |
| 40 | const mmap_region_t *plat_get_mmio_map(void) |
| 41 | { |
| 42 | /* MMIO space */ |
| 43 | return tegra_mmap; |
| 44 | } |
| 45 | |
Varun Wadekar | e34bc3d | 2017-04-28 08:43:33 -0700 | [diff] [blame] | 46 | /******************************************************************************* |
| 47 | * The Tegra power domain tree has a single system level power domain i.e. a |
| 48 | * single root node. The first entry in the power domain descriptor specifies |
| 49 | * the number of power domains at the highest power level. |
| 50 | ******************************************************************************* |
| 51 | */ |
| 52 | const unsigned char tegra_power_domain_tree_desc[] = { |
| 53 | /* No of root nodes */ |
| 54 | 1, |
| 55 | /* No of clusters */ |
| 56 | PLATFORM_CLUSTER_COUNT, |
| 57 | /* No of CPU cores */ |
| 58 | PLATFORM_CORE_COUNT, |
| 59 | }; |
| 60 | |
| 61 | /******************************************************************************* |
| 62 | * This function returns the Tegra default topology tree information. |
| 63 | ******************************************************************************/ |
| 64 | const unsigned char *plat_get_power_domain_tree_desc(void) |
| 65 | { |
| 66 | return tegra_power_domain_tree_desc; |
| 67 | } |
| 68 | |
Antonio Nino Diaz | e82e29c | 2016-05-19 10:00:28 +0100 | [diff] [blame] | 69 | unsigned int plat_get_syscnt_freq2(void) |
Varun Wadekar | 0f3baa0 | 2015-07-16 11:36:33 +0530 | [diff] [blame] | 70 | { |
| 71 | return 12000000; |
| 72 | } |
Varun Wadekar | d2014c6 | 2015-10-29 10:37:28 +0530 | [diff] [blame] | 73 | |
| 74 | /******************************************************************************* |
| 75 | * Maximum supported UART controllers |
| 76 | ******************************************************************************/ |
| 77 | #define TEGRA132_MAX_UART_PORTS 5 |
| 78 | |
| 79 | /******************************************************************************* |
| 80 | * This variable holds the UART port base addresses |
| 81 | ******************************************************************************/ |
| 82 | static uint32_t tegra132_uart_addresses[TEGRA132_MAX_UART_PORTS + 1] = { |
| 83 | 0, /* undefined - treated as an error case */ |
| 84 | TEGRA_UARTA_BASE, |
| 85 | TEGRA_UARTB_BASE, |
| 86 | TEGRA_UARTC_BASE, |
| 87 | TEGRA_UARTD_BASE, |
| 88 | TEGRA_UARTE_BASE, |
| 89 | }; |
| 90 | |
| 91 | /******************************************************************************* |
Varun Wadekar | 9d15f7e | 2019-08-21 14:01:31 -0700 | [diff] [blame] | 92 | * Enable console corresponding to the console ID |
Varun Wadekar | d2014c6 | 2015-10-29 10:37:28 +0530 | [diff] [blame] | 93 | ******************************************************************************/ |
Varun Wadekar | 9d15f7e | 2019-08-21 14:01:31 -0700 | [diff] [blame] | 94 | void plat_enable_console(int32_t id) |
Varun Wadekar | d2014c6 | 2015-10-29 10:37:28 +0530 | [diff] [blame] | 95 | { |
Andre Przywara | 98b5a11 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 96 | static console_t uart_console; |
Varun Wadekar | 9d15f7e | 2019-08-21 14:01:31 -0700 | [diff] [blame] | 97 | uint32_t console_clock; |
| 98 | |
| 99 | if ((id > 0) && (id < TEGRA132_MAX_UART_PORTS)) { |
| 100 | /* |
| 101 | * Reference clock used by the FPGAs is a lot slower. |
| 102 | */ |
| 103 | if (tegra_platform_is_fpga()) { |
| 104 | console_clock = TEGRA_BOOT_UART_CLK_13_MHZ; |
| 105 | } else { |
| 106 | console_clock = TEGRA_BOOT_UART_CLK_408_MHZ; |
| 107 | } |
Varun Wadekar | d2014c6 | 2015-10-29 10:37:28 +0530 | [diff] [blame] | 108 | |
Varun Wadekar | 9d15f7e | 2019-08-21 14:01:31 -0700 | [diff] [blame] | 109 | (void)console_16550_register(tegra132_uart_addresses[id], |
| 110 | console_clock, |
| 111 | TEGRA_CONSOLE_BAUDRATE, |
| 112 | &uart_console); |
Andre Przywara | 98b5a11 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 113 | console_set_scope(&uart_console, CONSOLE_FLAG_BOOT | |
Varun Wadekar | 9d15f7e | 2019-08-21 14:01:31 -0700 | [diff] [blame] | 114 | CONSOLE_FLAG_RUNTIME | CONSOLE_FLAG_CRASH); |
| 115 | } |
Varun Wadekar | d2014c6 | 2015-10-29 10:37:28 +0530 | [diff] [blame] | 116 | } |
Varun Wadekar | b7b4575 | 2015-12-28 14:55:41 -0800 | [diff] [blame] | 117 | |
| 118 | /******************************************************************************* |
| 119 | * Initialize the GIC and SGIs |
| 120 | ******************************************************************************/ |
| 121 | void plat_gic_setup(void) |
| 122 | { |
| 123 | tegra_gic_setup(NULL, 0); |
Varun Wadekar | 84a775e | 2019-01-03 10:12:55 -0800 | [diff] [blame] | 124 | tegra_gic_init(); |
Varun Wadekar | b7b4575 | 2015-12-28 14:55:41 -0800 | [diff] [blame] | 125 | } |
Varun Wadekar | 7cf57d7 | 2018-05-17 09:36:38 -0700 | [diff] [blame] | 126 | |
| 127 | /******************************************************************************* |
| 128 | * Return pointer to the BL31 params from previous bootloader |
| 129 | ******************************************************************************/ |
| 130 | struct tegra_bl31_params *plat_get_bl31_params(void) |
| 131 | { |
| 132 | return NULL; |
| 133 | } |
| 134 | |
| 135 | /******************************************************************************* |
| 136 | * Return pointer to the BL31 platform params from previous bootloader |
| 137 | ******************************************************************************/ |
| 138 | plat_params_from_bl2_t *plat_get_bl31_plat_params(void) |
| 139 | { |
| 140 | return NULL; |
| 141 | } |
| 142 | |
| 143 | /******************************************************************************* |
| 144 | * Handler for early platform setup |
| 145 | ******************************************************************************/ |
| 146 | void plat_early_platform_setup(void) |
| 147 | { |
kalyanic | 0a2cc61 | 2019-09-13 14:49:39 -0700 | [diff] [blame^] | 148 | /* Verify chip id is t132 */ |
| 149 | assert(tegra_chipid_is_t132()); |
Varun Wadekar | 7cf57d7 | 2018-05-17 09:36:38 -0700 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | /******************************************************************************* |
| 153 | * Handler for late platform setup |
| 154 | ******************************************************************************/ |
| 155 | void plat_late_platform_setup(void) |
| 156 | { |
| 157 | ; /* do nothing */ |
| 158 | } |
Varun Wadekar | 8d7a02b | 2018-06-26 16:07:50 -0700 | [diff] [blame] | 159 | |
| 160 | /******************************************************************************* |
| 161 | * Handler to indicate support for System Suspend |
| 162 | ******************************************************************************/ |
| 163 | bool plat_supports_system_suspend(void) |
| 164 | { |
| 165 | return true; |
| 166 | } |