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