Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Patrice Chotard | 1e1d02d | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 2 | /* |
Patrice Chotard | 789ee0e | 2017-10-23 09:53:58 +0200 | [diff] [blame] | 3 | * Copyright (C) 2017, STMicroelectronics - All Rights Reserved |
Patrice Chotard | 5d9950d | 2020-12-02 18:47:30 +0100 | [diff] [blame] | 4 | * Author(s): Patrice Chotard, <patrice.chotard@foss.st.com> for STMicroelectronics. |
Patrice Chotard | 1e1d02d | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 8 | #include <init.h> |
Patrice Chotard | 1e1d02d | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 9 | #include <asm/io.h> |
Lokesh Vutla | 076ee45 | 2018-04-26 18:21:30 +0530 | [diff] [blame] | 10 | #include <asm/armv7_mpu.h> |
Patrice Chotard | 1e1d02d | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 11 | |
Patrice Chotard | 1e1d02d | 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 | 574f457 | 2018-02-28 17:15:00 +0100 | [diff] [blame] | 18 | * Make SDRAM area cacheable & executable. |
Patrice Chotard | 1e1d02d | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 19 | */ |
Patrice Chotard | 574f457 | 2018-02-28 17:15:00 +0100 | [diff] [blame] | 20 | #if defined(CONFIG_STM32F4) |
Patrice Chotard | 1e1d02d | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 21 | { 0x00000000, REGION_0, XN_DIS, PRIV_RW_USR_RW, |
Patrice Chotard | 832f3ed | 2019-06-25 13:24:03 +0200 | [diff] [blame] | 22 | O_I_WB_RD_WR_ALLOC, REGION_512MB }, |
Patrice Chotard | 574f457 | 2018-02-28 17:15:00 +0100 | [diff] [blame] | 23 | #endif |
Patrice Chotard | 1e1d02d | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 24 | |
Patrice Chotard | bb1a550 | 2019-04-26 10:52:51 +0200 | [diff] [blame] | 25 | { 0x90000000, REGION_1, XN_DIS, PRIV_RW_USR_RW, |
| 26 | SHARED_WRITE_BUFFERED, REGION_256MB }, |
| 27 | |
Patrice Chotard | 6703074 | 2018-10-02 09:03:10 +0200 | [diff] [blame] | 28 | #if defined(CONFIG_STM32F7) || defined(CONFIG_STM32H7) |
Patrice Chotard | 574f457 | 2018-02-28 17:15:00 +0100 | [diff] [blame] | 29 | { 0xC0000000, REGION_0, XN_DIS, PRIV_RW_USR_RW, |
Patrice Chotard | 6703074 | 2018-10-02 09:03:10 +0200 | [diff] [blame] | 30 | O_I_WB_RD_WR_ALLOC, REGION_512MB }, |
Patrice Chotard | 0c6247c | 2017-11-16 08:59:21 +0100 | [diff] [blame] | 31 | #endif |
Patrice Chotard | 1e1d02d | 2017-09-13 18:00:12 +0200 | [diff] [blame] | 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 | } |