Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Patrice Chotard | 246771b | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 2 | /* |
Patrice Chotard | 3bc599c | 2017-10-23 09:53:58 +0200 | [diff] [blame] | 3 | * Copyright (C) 2017, STMicroelectronics - All Rights Reserved |
| 4 | * Author(s): Patrice Chotard, <patrice.chotard@st.com> for STMicroelectronics. |
Patrice Chotard | 246771b | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <asm/io.h> |
Lokesh Vutla | f2ef204 | 2018-04-26 18:21:30 +0530 | [diff] [blame] | 9 | #include <asm/armv7_mpu.h> |
Patrice Chotard | 246771b | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 10 | |
Patrice Chotard | 246771b | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 11 | int arch_cpu_init(void) |
| 12 | { |
| 13 | int i; |
| 14 | |
| 15 | struct mpu_region_config stm32_region_config[] = { |
| 16 | /* |
Patrice Chotard | f5bd13e | 2018-02-28 17:15:00 +0100 | [diff] [blame] | 17 | * Make SDRAM area cacheable & executable. |
Patrice Chotard | 246771b | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 18 | */ |
Patrice Chotard | f5bd13e | 2018-02-28 17:15:00 +0100 | [diff] [blame] | 19 | #if defined(CONFIG_STM32F4) |
Patrice Chotard | 246771b | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 20 | { 0x00000000, REGION_0, XN_DIS, PRIV_RW_USR_RW, |
Patrice Chotard | f5bd13e | 2018-02-28 17:15:00 +0100 | [diff] [blame] | 21 | O_I_WB_RD_WR_ALLOC, REGION_16MB }, |
| 22 | #endif |
Patrice Chotard | 246771b | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 23 | |
Patrice Chotard | 362612d | 2018-10-02 09:03:10 +0200 | [diff] [blame] | 24 | #if defined(CONFIG_STM32F7) || defined(CONFIG_STM32H7) |
Patrice Chotard | f5bd13e | 2018-02-28 17:15:00 +0100 | [diff] [blame] | 25 | { 0xC0000000, REGION_0, XN_DIS, PRIV_RW_USR_RW, |
Patrice Chotard | 362612d | 2018-10-02 09:03:10 +0200 | [diff] [blame] | 26 | O_I_WB_RD_WR_ALLOC, REGION_512MB }, |
Patrice Chotard | c729fb2 | 2017-11-16 08:59:21 +0100 | [diff] [blame] | 27 | #endif |
Patrice Chotard | 246771b | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 28 | }; |
| 29 | |
| 30 | disable_mpu(); |
| 31 | for (i = 0; i < ARRAY_SIZE(stm32_region_config); i++) |
| 32 | mpu_config(&stm32_region_config[i]); |
| 33 | enable_mpu(); |
| 34 | |
| 35 | return 0; |
| 36 | } |