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 <asm/io.h>
9 #include <asm/armv7_mpu.h>
10
arch_cpu_init(void)11 int arch_cpu_init(void)
12 {
13 int i;
14
15 struct mpu_region_config stm32_region_config[] = {
16 /*
17 * Make SDRAM area cacheable & executable.
18 */
19 #if defined(CONFIG_STM32F4)
20 { 0x00000000, REGION_0, XN_DIS, PRIV_RW_USR_RW,
21 O_I_WB_RD_WR_ALLOC, REGION_512MB },
22 #endif
23
24 { 0x90000000, REGION_1, XN_DIS, PRIV_RW_USR_RW,
25 SHARED_WRITE_BUFFERED, REGION_256MB },
26
27 #if defined(CONFIG_STM32F7) || defined(CONFIG_STM32H7)
28 { 0xC0000000, REGION_0, XN_DIS, PRIV_RW_USR_RW,
29 O_I_WB_RD_WR_ALLOC, REGION_512MB },
30 #endif
31 };
32
33 disable_mpu();
34 for (i = 0; i < ARRAY_SIZE(stm32_region_config); i++)
35 mpu_config(&stm32_region_config[i]);
36 enable_mpu();
37
38 return 0;
39 }
40