Yann Gautier | ee8f542 | 2019-02-14 11:13:25 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Yann Gautier | e3bf913 | 2019-05-07 18:52:17 +0200 | [diff] [blame] | 7 | #include <assert.h> |
| 8 | |
Yann Gautier | ee8f542 | 2019-02-14 11:13:25 +0100 | [diff] [blame] | 9 | #include <platform_def.h> |
| 10 | |
| 11 | #include <lib/xlat_tables/xlat_tables_v2.h> |
| 12 | |
Yann Gautier | a2e2a30 | 2019-02-14 11:13:39 +0100 | [diff] [blame] | 13 | #define MAP_SRAM MAP_REGION_FLAT(STM32MP_SYSRAM_BASE, \ |
| 14 | STM32MP_SYSRAM_SIZE, \ |
Yann Gautier | ee8f542 | 2019-02-14 11:13:25 +0100 | [diff] [blame] | 15 | MT_MEMORY | \ |
| 16 | MT_RW | \ |
| 17 | MT_SECURE | \ |
| 18 | MT_EXECUTE_NEVER) |
| 19 | |
| 20 | #define MAP_DEVICE1 MAP_REGION_FLAT(STM32MP1_DEVICE1_BASE, \ |
| 21 | STM32MP1_DEVICE1_SIZE, \ |
| 22 | MT_DEVICE | \ |
| 23 | MT_RW | \ |
| 24 | MT_SECURE | \ |
| 25 | MT_EXECUTE_NEVER) |
| 26 | |
| 27 | #define MAP_DEVICE2 MAP_REGION_FLAT(STM32MP1_DEVICE2_BASE, \ |
| 28 | STM32MP1_DEVICE2_SIZE, \ |
| 29 | MT_DEVICE | \ |
| 30 | MT_RW | \ |
| 31 | MT_SECURE | \ |
| 32 | MT_EXECUTE_NEVER) |
| 33 | |
| 34 | #if defined(IMAGE_BL2) |
| 35 | static const mmap_region_t stm32mp1_mmap[] = { |
| 36 | MAP_SRAM, |
| 37 | MAP_DEVICE1, |
| 38 | MAP_DEVICE2, |
| 39 | {0} |
| 40 | }; |
| 41 | #endif |
| 42 | #if defined(IMAGE_BL32) |
| 43 | static const mmap_region_t stm32mp1_mmap[] = { |
| 44 | MAP_SRAM, |
| 45 | MAP_DEVICE1, |
| 46 | MAP_DEVICE2, |
| 47 | {0} |
| 48 | }; |
| 49 | #endif |
| 50 | |
| 51 | void configure_mmu(void) |
| 52 | { |
| 53 | mmap_add(stm32mp1_mmap); |
| 54 | init_xlat_tables(); |
| 55 | |
| 56 | enable_mmu_svc_mon(0); |
| 57 | } |
Yann Gautier | e3bf913 | 2019-05-07 18:52:17 +0200 | [diff] [blame] | 58 | |
| 59 | unsigned long stm32_get_gpio_bank_clock(unsigned int bank) |
| 60 | { |
| 61 | if (bank == GPIO_BANK_Z) { |
| 62 | return GPIOZ; |
| 63 | } |
| 64 | |
| 65 | assert(GPIO_BANK_A == 0 && bank <= GPIO_BANK_K); |
| 66 | |
| 67 | return GPIOA + (bank - GPIO_BANK_A); |
| 68 | } |