Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 1 | /* |
Masahiro Yamada | e30ec7f | 2020-01-17 13:46:38 +0900 | [diff] [blame] | 2 | * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved. |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Masahiro Yamada | 1a741d9 | 2020-02-03 19:46:15 +0900 | [diff] [blame] | 7 | #include <assert.h> |
| 8 | |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 9 | #include <platform_def.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | |
| 11 | #include <common/debug.h> |
| 12 | #include <lib/xlat_tables/xlat_tables_v2.h> |
Masahiro Yamada | 9c3da38 | 2020-03-26 13:18:48 +0900 | [diff] [blame] | 13 | #include <plat/common/platform.h> |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 14 | |
Masahiro Yamada | 1a741d9 | 2020-02-03 19:46:15 +0900 | [diff] [blame] | 15 | #include "uniphier.h" |
| 16 | |
| 17 | struct uniphier_reg_region { |
| 18 | uintptr_t base; |
| 19 | size_t size; |
| 20 | }; |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 21 | |
Masahiro Yamada | 1a741d9 | 2020-02-03 19:46:15 +0900 | [diff] [blame] | 22 | static const struct uniphier_reg_region uniphier_reg_region[] = { |
| 23 | [UNIPHIER_SOC_LD11] = { |
| 24 | .base = 0x50000000UL, |
| 25 | .size = 0x20000000UL, |
| 26 | }, |
| 27 | [UNIPHIER_SOC_LD20] = { |
| 28 | .base = 0x50000000UL, |
| 29 | .size = 0x20000000UL, |
| 30 | }, |
| 31 | [UNIPHIER_SOC_PXS3] = { |
| 32 | .base = 0x50000000UL, |
| 33 | .size = 0x20000000UL, |
| 34 | }, |
| 35 | }; |
| 36 | |
| 37 | void uniphier_mmap_setup(unsigned int soc) |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 38 | { |
| 39 | VERBOSE("Trusted RAM seen by this BL image: %p - %p\n", |
Masahiro Yamada | e30ec7f | 2020-01-17 13:46:38 +0900 | [diff] [blame] | 40 | (void *)BL_CODE_BASE, (void *)BL_END); |
| 41 | mmap_add_region(BL_CODE_BASE, BL_CODE_BASE, |
| 42 | round_up(BL_END, PAGE_SIZE) - BL_CODE_BASE, |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 43 | MT_MEMORY | MT_RW | MT_SECURE); |
| 44 | |
| 45 | /* remap the code section */ |
| 46 | VERBOSE("Code region: %p - %p\n", |
| 47 | (void *)BL_CODE_BASE, (void *)BL_CODE_END); |
| 48 | mmap_add_region(BL_CODE_BASE, BL_CODE_BASE, |
| 49 | round_up(BL_CODE_END, PAGE_SIZE) - BL_CODE_BASE, |
| 50 | MT_CODE | MT_SECURE); |
| 51 | |
| 52 | /* remap the coherent memory region */ |
| 53 | VERBOSE("Coherent region: %p - %p\n", |
| 54 | (void *)BL_COHERENT_RAM_BASE, (void *)BL_COHERENT_RAM_END); |
| 55 | mmap_add_region(BL_COHERENT_RAM_BASE, BL_COHERENT_RAM_BASE, |
| 56 | BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE, |
| 57 | MT_DEVICE | MT_RW | MT_SECURE); |
| 58 | |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 59 | /* register region */ |
Masahiro Yamada | 1a741d9 | 2020-02-03 19:46:15 +0900 | [diff] [blame] | 60 | assert(soc < ARRAY_SIZE(uniphier_reg_region)); |
| 61 | mmap_add_region(uniphier_reg_region[soc].base, |
| 62 | uniphier_reg_region[soc].base, |
| 63 | uniphier_reg_region[soc].size, |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 64 | MT_DEVICE | MT_RW | MT_SECURE); |
| 65 | |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 66 | init_xlat_tables(); |
Masahiro Yamada | c80bb43 | 2020-03-26 13:18:48 +0900 | [diff] [blame] | 67 | |
| 68 | enable_mmu(0); |
Masahiro Yamada | 9c3da38 | 2020-03-26 13:18:48 +0900 | [diff] [blame] | 69 | |
| 70 | #if PLAT_RO_XLAT_TABLES |
| 71 | { |
| 72 | int ret; |
| 73 | |
| 74 | ret = xlat_make_tables_readonly(); |
| 75 | if (ret) { |
| 76 | ERROR("Failed to make translation tables read-only."); |
| 77 | plat_error_handler(ret); |
| 78 | } |
| 79 | } |
| 80 | #endif |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 81 | } |