blob: f58e10b27b2fe28ddb47524adf1bb09d69ba63fe [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
Yann Gautier9aea69e2018-07-24 17:13:36 +02007#include <limits.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
Yann Gautier9aea69e2018-07-24 17:13:36 +02009#include <platform_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010
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 Gautier9aea69e2018-07-24 17:13:36 +020017
18#define RST_CLR_OFFSET 4U
19
20void 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
31void 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}