blob: df20d547c5008361413c647ec8a54efe7488706e [file] [log] [blame]
Patrice Chotard246771b2017-09-13 18:00:12 +02001/*
Patrice Chotard3bc599c2017-10-23 09:53:58 +02002 * Copyright (C) 2017, STMicroelectronics - All Rights Reserved
3 * Author(s): Patrice Chotard, <patrice.chotard@st.com> for STMicroelectronics.
Patrice Chotard246771b2017-09-13 18:00:12 +02004 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#include <common.h>
9#include <asm/io.h>
10#include <asm/armv7m_mpu.h>
11
Patrice Chotard246771b2017-09-13 18:00:12 +020012int arch_cpu_init(void)
13{
14 int i;
15
16 struct mpu_region_config stm32_region_config[] = {
17 /*
18 * Make all 4GB cacheable & executable. We are overriding it
19 * with next region for any requirement. e.g. below region1,
20 * 2 etc.
21 * In other words, the area not coming in following
22 * regions configuration is the one configured here in region_0
23 * (cacheable & executable).
24 */
25 { 0x00000000, REGION_0, XN_DIS, PRIV_RW_USR_RW,
26 O_I_WB_RD_WR_ALLOC, REGION_4GB },
27
Patrice Chotardc729fb22017-11-16 08:59:21 +010028 /* armv7m code area */
29 { 0x00000000, REGION_1, XN_DIS, PRIV_RW_USR_RW,
30 STRONG_ORDER, REGION_512MB },
Patrice Chotard246771b2017-09-13 18:00:12 +020031
Patrice Chotardc729fb22017-11-16 08:59:21 +010032 /* Device area : Not executable */
Patrice Chotard246771b2017-09-13 18:00:12 +020033 { 0x40000000, REGION_2, XN_EN, PRIV_RW_USR_RW,
34 DEVICE_NON_SHARED, REGION_512MB },
35
36 /*
37 * Armv7m fixed configuration: strongly ordered & not
38 * executable, not cacheable
39 */
Patrice Chotardc729fb22017-11-16 08:59:21 +010040 { 0xE0000000, REGION_3, XN_EN, PRIV_RW_USR_RW,
Patrice Chotard246771b2017-09-13 18:00:12 +020041 STRONG_ORDER, REGION_512MB },
Patrice Chotardc729fb22017-11-16 08:59:21 +010042
43#if !defined(CONFIG_STM32H7)
44 /* Device area : Not executable */
45 { 0xA0000000, REGION_4, XN_EN, PRIV_RW_USR_RW,
46 DEVICE_NON_SHARED, REGION_512MB },
47#endif
Patrice Chotard246771b2017-09-13 18:00:12 +020048 };
49
50 disable_mpu();
51 for (i = 0; i < ARRAY_SIZE(stm32_region_config); i++)
52 mpu_config(&stm32_region_config[i]);
53 enable_mpu();
54
55 return 0;
56}