Patrice Chotard | 246771b | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 1 | /* |
Patrice Chotard | 3bc599c | 2017-10-23 09:53:58 +0200 | [diff] [blame] | 2 | * Copyright (C) 2017, STMicroelectronics - All Rights Reserved |
| 3 | * Author(s): Patrice Chotard, <patrice.chotard@st.com> for STMicroelectronics. |
Patrice Chotard | 246771b | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 4 | * |
| 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 Chotard | 246771b | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 12 | int arch_cpu_init(void) |
| 13 | { |
| 14 | int i; |
| 15 | |
| 16 | struct mpu_region_config stm32_region_config[] = { |
| 17 | /* |
Patrice Chotard | f5bd13e | 2018-02-28 17:15:00 +0100 | [diff] [blame] | 18 | * Make SDRAM area cacheable & executable. |
Patrice Chotard | 246771b | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 19 | */ |
Patrice Chotard | f5bd13e | 2018-02-28 17:15:00 +0100 | [diff] [blame] | 20 | #if defined(CONFIG_STM32F4) |
Patrice Chotard | 246771b | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 21 | { 0x00000000, REGION_0, XN_DIS, PRIV_RW_USR_RW, |
Patrice Chotard | f5bd13e | 2018-02-28 17:15:00 +0100 | [diff] [blame] | 22 | O_I_WB_RD_WR_ALLOC, REGION_16MB }, |
| 23 | #endif |
Patrice Chotard | 246771b | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 24 | |
Patrice Chotard | f5bd13e | 2018-02-28 17:15:00 +0100 | [diff] [blame] | 25 | #if defined(CONFIG_STM32F7) |
| 26 | { 0xC0000000, REGION_0, XN_DIS, PRIV_RW_USR_RW, |
| 27 | O_I_WB_RD_WR_ALLOC, REGION_16MB }, |
| 28 | #endif |
Patrice Chotard | 246771b | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 29 | |
Patrice Chotard | f5bd13e | 2018-02-28 17:15:00 +0100 | [diff] [blame] | 30 | #if defined(CONFIG_STM32H7) |
| 31 | { 0xD0000000, REGION_0, XN_DIS, PRIV_RW_USR_RW, |
| 32 | O_I_WB_RD_WR_ALLOC, REGION_32MB }, |
Patrice Chotard | c729fb2 | 2017-11-16 08:59:21 +0100 | [diff] [blame] | 33 | #endif |
Patrice Chotard | 246771b | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | disable_mpu(); |
| 37 | for (i = 0; i < ARRAY_SIZE(stm32_region_config); i++) |
| 38 | mpu_config(&stm32_region_config[i]); |
| 39 | enable_mpu(); |
| 40 | |
| 41 | return 0; |
| 42 | } |