Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / arch / arm / mach-stm32 / soc.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2017, STMicroelectronics - All Rights Reserved
4  * Author(s): Patrice Chotard, <patrice.chotard@st.com> for STMicroelectronics.
5  */
6
7 #include <common.h>
8 #include <init.h>
9 #include <asm/io.h>
10 #include <asm/armv7_mpu.h>
11
12 int arch_cpu_init(void)
13 {
14         int i;
15
16         struct mpu_region_config stm32_region_config[] = {
17                 /*
18                  * Make SDRAM area cacheable & executable.
19                  */
20 #if defined(CONFIG_STM32F4)
21                 { 0x00000000, REGION_0, XN_DIS, PRIV_RW_USR_RW,
22                 O_I_WB_RD_WR_ALLOC, REGION_512MB },
23 #endif
24
25                 { 0x90000000, REGION_1, XN_DIS, PRIV_RW_USR_RW,
26                 SHARED_WRITE_BUFFERED, REGION_256MB },
27
28 #if defined(CONFIG_STM32F7) || defined(CONFIG_STM32H7)
29                 { 0xC0000000, REGION_0, XN_DIS, PRIV_RW_USR_RW,
30                 O_I_WB_RD_WR_ALLOC, REGION_512MB },
31 #endif
32         };
33
34         disable_mpu();
35         for (i = 0; i < ARRAY_SIZE(stm32_region_config); i++)
36                 mpu_config(&stm32_region_config[i]);
37         enable_mpu();
38
39         return 0;
40 }