1 /*
2  * Copyright (c) 2018-2019, STMicroelectronics - All Rights Reserved
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef STM32MP_RESET_H
8 #define STM32MP_RESET_H
9 
10 #include <stdint.h>
11 
12 /*
13  * Assert target reset, if @to_us non null, wait until reset is asserted
14  *
15  * @reset_id: Reset controller ID
16  * @to_us: Timeout in microsecond, or 0 if not waiting
17  * Return 0 on success and -ETIMEDOUT if waiting and timeout expired
18  */
19 int stm32mp_reset_assert(uint32_t reset_id, unsigned int to_us);
20 
21 /*
22  * Enable reset control for target resource
23  *
24  * @reset_id: Reset controller ID
25  */
stm32mp_reset_set(uint32_t reset_id)26 static inline void stm32mp_reset_set(uint32_t reset_id)
27 {
28 	(void)stm32mp_reset_assert(reset_id, 0U);
29 }
30 
31 /*
32  * Deassert target reset, if @to_us non null, wait until reset is deasserted
33  *
34  * @reset_id: Reset controller ID
35  * @to_us: Timeout in microsecond, or 0 if not waiting
36  * Return 0 on success and -ETIMEDOUT if waiting and timeout expired
37  */
38 int stm32mp_reset_deassert(uint32_t reset_id, unsigned int to_us);
39 
40 /*
41  * Release reset control for target resource
42  *
43  * @reset_id: Reset controller ID
44  */
stm32mp_reset_release(uint32_t reset_id)45 static inline void stm32mp_reset_release(uint32_t reset_id)
46 {
47 	(void)stm32mp_reset_deassert(reset_id, 0U);
48 }
49 
50 #endif /* STM32MP_RESET_H */
51