Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 1 | /* |
Varun Wadekar | e34bc3d | 2017-04-28 08:43:33 -0700 | [diff] [blame] | 2 | * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 5 | */ |
| 6 | |
Varun Wadekar | b7b4575 | 2015-12-28 14:55:41 -0800 | [diff] [blame] | 7 | #include <arch_helpers.h> |
Varun Wadekar | a6a357f | 2017-05-05 09:20:59 -0700 | [diff] [blame] | 8 | #include <bpmp.h> |
Sam Payne | 71ce6ed | 2017-05-08 12:42:49 -0700 | [diff] [blame] | 9 | #include <cortex_a57.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | #include <common/bl_common.h> |
| 11 | #include <drivers/console.h> |
| 12 | #include <lib/xlat_tables/xlat_tables_v2.h> |
Varun Wadekar | e34bc3d | 2017-04-28 08:43:33 -0700 | [diff] [blame] | 13 | #include <platform.h> |
Marvin Hsu | 21eea97 | 2017-04-11 11:00:48 +0800 | [diff] [blame] | 14 | #include <security_engine.h> |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 15 | #include <tegra_def.h> |
Marvin Hsu | 21eea97 | 2017-04-11 11:00:48 +0800 | [diff] [blame] | 16 | #include <tegra_platform.h> |
Varun Wadekar | b7b4575 | 2015-12-28 14:55:41 -0800 | [diff] [blame] | 17 | #include <tegra_private.h> |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 18 | |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 19 | /* sets of MMIO ranges setup */ |
| 20 | #define MMIO_RANGE_0_ADDR 0x50000000 |
| 21 | #define MMIO_RANGE_1_ADDR 0x60000000 |
| 22 | #define MMIO_RANGE_2_ADDR 0x70000000 |
| 23 | #define MMIO_RANGE_SIZE 0x200000 |
| 24 | |
| 25 | /* |
| 26 | * Table of regions to map using the MMU. |
| 27 | */ |
| 28 | static const mmap_region_t tegra_mmap[] = { |
Varun Wadekar | 08554a6 | 2017-06-12 16:47:16 -0700 | [diff] [blame] | 29 | MAP_REGION_FLAT(TEGRA_IRAM_BASE, 0x40000, /* 256KB */ |
Varun Wadekar | a6a357f | 2017-05-05 09:20:59 -0700 | [diff] [blame] | 30 | MT_DEVICE | MT_RW | MT_SECURE), |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 31 | MAP_REGION_FLAT(MMIO_RANGE_0_ADDR, MMIO_RANGE_SIZE, |
| 32 | MT_DEVICE | MT_RW | MT_SECURE), |
| 33 | MAP_REGION_FLAT(MMIO_RANGE_1_ADDR, MMIO_RANGE_SIZE, |
| 34 | MT_DEVICE | MT_RW | MT_SECURE), |
| 35 | MAP_REGION_FLAT(MMIO_RANGE_2_ADDR, MMIO_RANGE_SIZE, |
| 36 | MT_DEVICE | MT_RW | MT_SECURE), |
| 37 | {0} |
| 38 | }; |
| 39 | |
| 40 | /******************************************************************************* |
| 41 | * Set up the pagetables as per the platform memory map & initialize the MMU |
| 42 | ******************************************************************************/ |
| 43 | const mmap_region_t *plat_get_mmio_map(void) |
| 44 | { |
Marvin Hsu | 21eea97 | 2017-04-11 11:00:48 +0800 | [diff] [blame] | 45 | /* Add the map region for security engine SE2 */ |
| 46 | if (tegra_chipid_is_t210_b01()) { |
| 47 | mmap_add_region((uint64_t)TEGRA_SE2_BASE, |
| 48 | (uint64_t)TEGRA_SE2_BASE, |
| 49 | (uint64_t)TEGRA_SE2_RANGE_SIZE, |
| 50 | MT_DEVICE | MT_RW | MT_SECURE); |
| 51 | } |
| 52 | |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 53 | /* MMIO space */ |
| 54 | return tegra_mmap; |
| 55 | } |
| 56 | |
| 57 | /******************************************************************************* |
Varun Wadekar | e34bc3d | 2017-04-28 08:43:33 -0700 | [diff] [blame] | 58 | * The Tegra power domain tree has a single system level power domain i.e. a |
| 59 | * single root node. The first entry in the power domain descriptor specifies |
| 60 | * the number of power domains at the highest power level. |
| 61 | ******************************************************************************* |
| 62 | */ |
| 63 | const unsigned char tegra_power_domain_tree_desc[] = { |
| 64 | /* No of root nodes */ |
| 65 | 1, |
| 66 | /* No of clusters */ |
| 67 | PLATFORM_CLUSTER_COUNT, |
| 68 | /* No of CPU cores - cluster0 */ |
| 69 | PLATFORM_MAX_CPUS_PER_CLUSTER, |
| 70 | /* No of CPU cores - cluster1 */ |
| 71 | PLATFORM_MAX_CPUS_PER_CLUSTER |
| 72 | }; |
| 73 | |
| 74 | /******************************************************************************* |
| 75 | * This function returns the Tegra default topology tree information. |
| 76 | ******************************************************************************/ |
| 77 | const unsigned char *plat_get_power_domain_tree_desc(void) |
| 78 | { |
| 79 | return tegra_power_domain_tree_desc; |
| 80 | } |
| 81 | |
| 82 | /******************************************************************************* |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 83 | * Handler to get the System Counter Frequency |
| 84 | ******************************************************************************/ |
Antonio Nino Diaz | e82e29c | 2016-05-19 10:00:28 +0100 | [diff] [blame] | 85 | unsigned int plat_get_syscnt_freq2(void) |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 86 | { |
| 87 | return 19200000; |
| 88 | } |
Varun Wadekar | d2014c6 | 2015-10-29 10:37:28 +0530 | [diff] [blame] | 89 | |
| 90 | /******************************************************************************* |
| 91 | * Maximum supported UART controllers |
| 92 | ******************************************************************************/ |
| 93 | #define TEGRA210_MAX_UART_PORTS 5 |
| 94 | |
| 95 | /******************************************************************************* |
| 96 | * This variable holds the UART port base addresses |
| 97 | ******************************************************************************/ |
| 98 | static uint32_t tegra210_uart_addresses[TEGRA210_MAX_UART_PORTS + 1] = { |
| 99 | 0, /* undefined - treated as an error case */ |
| 100 | TEGRA_UARTA_BASE, |
| 101 | TEGRA_UARTB_BASE, |
| 102 | TEGRA_UARTC_BASE, |
| 103 | TEGRA_UARTD_BASE, |
| 104 | TEGRA_UARTE_BASE, |
| 105 | }; |
| 106 | |
| 107 | /******************************************************************************* |
| 108 | * Retrieve the UART controller base to be used as the console |
| 109 | ******************************************************************************/ |
| 110 | uint32_t plat_get_console_from_id(int id) |
| 111 | { |
| 112 | if (id > TEGRA210_MAX_UART_PORTS) |
| 113 | return 0; |
| 114 | |
| 115 | return tegra210_uart_addresses[id]; |
| 116 | } |
Varun Wadekar | b7b4575 | 2015-12-28 14:55:41 -0800 | [diff] [blame] | 117 | |
| 118 | /******************************************************************************* |
Marvin Hsu | 21eea97 | 2017-04-11 11:00:48 +0800 | [diff] [blame] | 119 | * Handler for early platform setup |
| 120 | ******************************************************************************/ |
| 121 | void plat_early_platform_setup(void) |
| 122 | { |
Sam Payne | 71ce6ed | 2017-05-08 12:42:49 -0700 | [diff] [blame] | 123 | const plat_params_from_bl2_t *plat_params = bl31_get_plat_params(); |
| 124 | uint64_t val; |
| 125 | |
| 126 | /* platform parameter passed by the previous bootloader */ |
| 127 | if (plat_params->l2_ecc_parity_prot_dis != 1) { |
| 128 | /* Enable ECC Parity Protection for Cortex-A57 CPUs */ |
| 129 | val = read_l2ctlr_el1(); |
| 130 | val |= (uint64_t)CORTEX_A57_L2_ECC_PARITY_PROTECTION_BIT; |
| 131 | write_l2ctlr_el1(val); |
| 132 | } |
| 133 | |
Marvin Hsu | 21eea97 | 2017-04-11 11:00:48 +0800 | [diff] [blame] | 134 | /* Initialize security engine driver */ |
| 135 | if (tegra_chipid_is_t210_b01()) { |
| 136 | tegra_se_init(); |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | /******************************************************************************* |
Varun Wadekar | b7b4575 | 2015-12-28 14:55:41 -0800 | [diff] [blame] | 141 | * Initialize the GIC and SGIs |
| 142 | ******************************************************************************/ |
| 143 | void plat_gic_setup(void) |
| 144 | { |
| 145 | tegra_gic_setup(NULL, 0); |
| 146 | } |