Commit 5813e6ed authored by Yann Gautier's avatar Yann Gautier
Browse files

stm32mp1: use stm32mp_get_ddr_ns_size() function



Instead of using dt_get_ddr_size() and withdrawing the secure and shared
memory areas, use stm32mp_get_ddr_ns_size() function.

Change-Id: I5608fd7873589ea0e1262ba7d2ee3e52b53d9a7d
Signed-off-by: default avatarYann Gautier <yann.gautier@st.com>
parent 9c52e69f
...@@ -353,8 +353,7 @@ int bl2_plat_handle_post_image_load(unsigned int image_id) ...@@ -353,8 +353,7 @@ int bl2_plat_handle_post_image_load(unsigned int image_id)
paged_mem_params = get_bl_mem_params_node(BL32_EXTRA2_IMAGE_ID); paged_mem_params = get_bl_mem_params_node(BL32_EXTRA2_IMAGE_ID);
assert(paged_mem_params != NULL); assert(paged_mem_params != NULL);
paged_mem_params->image_info.image_base = STM32MP_DDR_BASE + paged_mem_params->image_info.image_base = STM32MP_DDR_BASE +
(dt_get_ddr_size() - STM32MP_DDR_S_SIZE - stm32mp_get_ddr_ns_size();
STM32MP_DDR_SHMEM_SIZE);
paged_mem_params->image_info.image_max_size = paged_mem_params->image_info.image_max_size =
STM32MP_DDR_S_SIZE; STM32MP_DDR_S_SIZE;
......
/* /*
* Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -35,29 +35,30 @@ static void init_tzc400(void) ...@@ -35,29 +35,30 @@ static void init_tzc400(void)
{ {
unsigned long long region_base, region_top; unsigned long long region_base, region_top;
unsigned long long ddr_base = STM32MP_DDR_BASE; unsigned long long ddr_base = STM32MP_DDR_BASE;
unsigned long long ddr_size = (unsigned long long)dt_get_ddr_size(); unsigned long long ddr_ns_size =
unsigned long long ddr_top = ddr_base + (ddr_size - 1U); (unsigned long long)stm32mp_get_ddr_ns_size();
unsigned long long ddr_ns_top = ddr_base + (ddr_ns_size - 1U);
tzc400_init(STM32MP1_TZC_BASE); tzc400_init(STM32MP1_TZC_BASE);
tzc400_disable_filters(); tzc400_disable_filters();
#ifdef AARCH32_SP_OPTEE
/* /*
* Region 1 set to cover all non-secure DRAM at 0xC000_0000. Apply the * Region 1 set to cover all non-secure DRAM at 0xC000_0000. Apply the
* same configuration to all filters in the TZC. * same configuration to all filters in the TZC.
*/ */
region_base = ddr_base; region_base = ddr_base;
region_top = ddr_top - STM32MP_DDR_S_SIZE - STM32MP_DDR_SHMEM_SIZE; region_top = ddr_ns_top;
tzc400_configure_region(STM32MP1_FILTER_BIT_ALL, 1, tzc400_configure_region(STM32MP1_FILTER_BIT_ALL, 1,
region_base, region_base,
region_top, region_top,
TZC_REGION_S_NONE, TZC_REGION_S_NONE,
TZC_REGION_NSEC_ALL_ACCESS_RDWR); TZC_REGION_NSEC_ALL_ACCESS_RDWR);
#ifdef AARCH32_SP_OPTEE
/* Region 2 set to cover all secure DRAM. */ /* Region 2 set to cover all secure DRAM. */
region_base = region_top + 1U; region_base = region_top + 1U;
region_top = ddr_top - STM32MP_DDR_SHMEM_SIZE; region_top += STM32MP_DDR_S_SIZE;
tzc400_configure_region(STM32MP1_FILTER_BIT_ALL, 2, tzc400_configure_region(STM32MP1_FILTER_BIT_ALL, 2,
region_base, region_base,
region_top, region_top,
...@@ -66,24 +67,12 @@ static void init_tzc400(void) ...@@ -66,24 +67,12 @@ static void init_tzc400(void)
/* Region 3 set to cover non-secure shared memory DRAM. */ /* Region 3 set to cover non-secure shared memory DRAM. */
region_base = region_top + 1U; region_base = region_top + 1U;
region_top = ddr_top; region_top += STM32MP_DDR_SHMEM_SIZE;
tzc400_configure_region(STM32MP1_FILTER_BIT_ALL, 3, tzc400_configure_region(STM32MP1_FILTER_BIT_ALL, 3,
region_base, region_base,
region_top, region_top,
TZC_REGION_S_NONE, TZC_REGION_S_NONE,
TZC_REGION_NSEC_ALL_ACCESS_RDWR); TZC_REGION_NSEC_ALL_ACCESS_RDWR);
#else
/*
* Region 1 set to cover all DRAM at 0xC000_0000. Apply the
* same configuration to all filters in the TZC.
*/
region_base = ddr_base;
region_top = ddr_top;
tzc400_configure_region(STM32MP1_FILTER_BIT_ALL, 1,
region_base,
region_top,
TZC_REGION_S_NONE,
TZC_REGION_NSEC_ALL_ACCESS_RDWR);
#endif #endif
/* Raise an exception if a NS device tries to access secure memory */ /* Raise an exception if a NS device tries to access secure memory */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment