blob: de8cc78ccbeb297407530f0a54202cbecbb17fb6 [file] [log] [blame]
Yann Gautier4b0c72a2018-07-16 10:54:09 +02001/*
Yann Gautierf9d40d52019-01-17 14:41:46 +01002 * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved.
Yann Gautier4b0c72a2018-07-16 10:54:09 +02003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Yann Gautier4b0c72a2018-07-16 10:54:09 +02007#include <assert.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
Yann Gautier4b0c72a2018-07-16 10:54:09 +02009#include <platform_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010
11#include <arch_helpers.h>
12#include <common/bl_common.h>
13#include <common/debug.h>
14#include <drivers/arm/gicv2.h>
15#include <lib/mmio.h>
16#include <lib/xlat_tables/xlat_tables_v2.h>
17#include <plat/common/platform.h>
18
Yann Gautier4b0c72a2018-07-16 10:54:09 +020019#include <stm32mp1_private.h>
Yann Gautier4b0c72a2018-07-16 10:54:09 +020020
21#define MAP_SRAM MAP_REGION_FLAT(STM32MP1_SRAM_BASE, \
22 STM32MP1_SRAM_SIZE, \
23 MT_MEMORY | \
24 MT_RW | \
25 MT_SECURE | \
26 MT_EXECUTE_NEVER)
27
28#define MAP_DEVICE1 MAP_REGION_FLAT(STM32MP1_DEVICE1_BASE, \
29 STM32MP1_DEVICE1_SIZE, \
30 MT_DEVICE | \
31 MT_RW | \
32 MT_SECURE | \
33 MT_EXECUTE_NEVER)
34
35#define MAP_DEVICE2 MAP_REGION_FLAT(STM32MP1_DEVICE2_BASE, \
36 STM32MP1_DEVICE2_SIZE, \
37 MT_DEVICE | \
38 MT_RW | \
39 MT_SECURE | \
40 MT_EXECUTE_NEVER)
41
Yann Gautier9d135e42018-07-16 19:36:06 +020042#if defined(IMAGE_BL2)
Yann Gautier4b0c72a2018-07-16 10:54:09 +020043static const mmap_region_t stm32mp1_mmap[] = {
44 MAP_SRAM,
45 MAP_DEVICE1,
46 MAP_DEVICE2,
Yann Gautier4b0c72a2018-07-16 10:54:09 +020047 {0}
48};
Yann Gautier9d135e42018-07-16 19:36:06 +020049#endif
50#if defined(IMAGE_BL32)
51static const mmap_region_t stm32mp1_mmap[] = {
52 MAP_SRAM,
53 MAP_DEVICE1,
54 MAP_DEVICE2,
Yann Gautier9d135e42018-07-16 19:36:06 +020055 {0}
56};
57#endif
Yann Gautier4b0c72a2018-07-16 10:54:09 +020058
59void configure_mmu(void)
60{
61 mmap_add(stm32mp1_mmap);
62 init_xlat_tables();
63
Antonio Nino Diaz4bef6b02018-08-07 16:35:54 +010064 enable_mmu_svc_mon(0);
Yann Gautier4b0c72a2018-07-16 10:54:09 +020065}
66
67uintptr_t plat_get_ns_image_entrypoint(void)
68{
69 return BL33_BASE;
70}
71
72unsigned int plat_get_syscnt_freq2(void)
73{
74 return read_cntfrq_el0();
75}
76
77/* Functions to save and get boot context address given by ROM code */
78static uintptr_t boot_ctx_address;
79
80void stm32mp1_save_boot_ctx_address(uintptr_t address)
81{
82 boot_ctx_address = address;
83}
84
85uintptr_t stm32mp1_get_boot_ctx_address(void)
86{
87 return boot_ctx_address;
88}