stm32mp1_reset.c 942 Bytes
Newer Older
1
/*
2
 * Copyright (c) 2018-2019, STMicroelectronics - All Rights Reserved
3
4
5
6
7
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <limits.h>
8

9
#include <platform_def.h>
10
11
12

#include <common/bl_common.h>
#include <common/debug.h>
13
#include <drivers/st/stm32mp_reset.h>
14
15
16
#include <drivers/st/stm32mp1_rcc.h>
#include <lib/mmio.h>
#include <lib/utils_def.h>
17
18
19

#define RST_CLR_OFFSET	4U

20
void stm32mp_reset_assert(uint32_t id)
21
22
23
24
25
26
27
28
29
30
{
	uint32_t offset = (id / (uint32_t)__LONG_BIT) * sizeof(uintptr_t);
	uint32_t bit = id % (uint32_t)__LONG_BIT;

	mmio_write_32(RCC_BASE + offset, BIT(bit));
	while ((mmio_read_32(RCC_BASE + offset) & BIT(bit)) == 0U) {
		;
	}
}

31
void stm32mp_reset_deassert(uint32_t id)
32
33
34
35
36
37
38
39
40
41
{
	uint32_t offset = ((id / (uint32_t)__LONG_BIT) * sizeof(uintptr_t)) +
			  RST_CLR_OFFSET;
	uint32_t bit = id % (uint32_t)__LONG_BIT;

	mmio_write_32(RCC_BASE + offset, BIT(bit));
	while ((mmio_read_32(RCC_BASE + offset) & BIT(bit)) != 0U) {
		;
	}
}