Yann Gautier | 9aea69e | 2018-07-24 17:13:36 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018, STMicroelectronics - All Rights Reserved |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Yann Gautier | 9aea69e | 2018-07-24 17:13:36 +0200 | [diff] [blame] | 7 | #include <limits.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | |
Yann Gautier | 9aea69e | 2018-07-24 17:13:36 +0200 | [diff] [blame] | 9 | #include <platform_def.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | |
| 11 | #include <common/bl_common.h> |
| 12 | #include <common/debug.h> |
| 13 | #include <drivers/st/stm32mp1_rcc.h> |
| 14 | #include <drivers/st/stm32mp1_reset.h> |
| 15 | #include <lib/mmio.h> |
| 16 | #include <lib/utils_def.h> |
Yann Gautier | 9aea69e | 2018-07-24 17:13:36 +0200 | [diff] [blame] | 17 | |
| 18 | #define RST_CLR_OFFSET 4U |
| 19 | |
| 20 | void stm32mp1_reset_assert(uint32_t id) |
| 21 | { |
| 22 | uint32_t offset = (id / (uint32_t)__LONG_BIT) * sizeof(uintptr_t); |
| 23 | uint32_t bit = id % (uint32_t)__LONG_BIT; |
| 24 | |
| 25 | mmio_write_32(RCC_BASE + offset, BIT(bit)); |
| 26 | while ((mmio_read_32(RCC_BASE + offset) & BIT(bit)) == 0U) { |
| 27 | ; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | void stm32mp1_reset_deassert(uint32_t id) |
| 32 | { |
| 33 | uint32_t offset = ((id / (uint32_t)__LONG_BIT) * sizeof(uintptr_t)) + |
| 34 | RST_CLR_OFFSET; |
| 35 | uint32_t bit = id % (uint32_t)__LONG_BIT; |
| 36 | |
| 37 | mmio_write_32(RCC_BASE + offset, BIT(bit)); |
| 38 | while ((mmio_read_32(RCC_BASE + offset) & BIT(bit)) != 0U) { |
| 39 | ; |
| 40 | } |
| 41 | } |