Aaron Durbin | bc3019c | 2014-07-15 10:53:29 -0500 | [diff] [blame^] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2014 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #include <arch/io.h> |
| 21 | #include <arch/stages.h> |
| 22 | #include <soc/addressmap.h> |
| 23 | #include "mc.h" |
| 24 | |
| 25 | void arm64_soc_init(void) |
| 26 | { |
| 27 | struct tegra_mc_regs * const mc = (void *)(uintptr_t)TEGRA_MC_BASE; |
| 28 | const size_t tz_size_mib = CONFIG_TRUSTZONE_CARVEOUT_SIZE_MB; |
| 29 | uintptr_t base; |
| 30 | uintptr_t end; |
| 31 | |
| 32 | if (!tz_size_mib) |
| 33 | return; |
| 34 | |
| 35 | /* |
| 36 | * Ramstage is when the arm64 first gets running. It also is the |
| 37 | * only entity that the capabilities to program the Trust Zone region. |
| 38 | * Therefore configure the region early. Also, the TZ region can only |
| 39 | * live in 32-bit space. |
| 40 | */ |
| 41 | memory_range_by_bits(ADDRESS_SPACE_32_BIT, &base, &end); |
| 42 | |
| 43 | /* Place the TZ area just below current carveout regions. */ |
| 44 | end -= tz_size_mib; |
| 45 | write32(end << 20, &mc->security_cfg0); |
| 46 | write32(tz_size_mib, &mc->security_cfg1); |
| 47 | } |