xref: /optee_os/core/include/drivers/atmel_rstc.h (revision 9e86f0a2065ab429a5b05e148b3f39c62f86c108)
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2021, Microchip
4  */
5 #ifndef __DRIVERS_ATMEL_RSTC_H
6 #define __DRIVERS_ATMEL_RSTC_H
7 
8 #include <compiler.h>
9 #include <stdbool.h>
10 #include <util.h>
11 
12 #define RESET_ID_MASK		GENMASK_32(8, 5)
13 #define RESET_ID_SHIFT		U(5)
14 #define RESET_BIT_POS_MASK	GENMASK_32(4, 0)
15 #define RESET_OFFSET(id)	(((id) & RESET_ID_MASK) >> RESET_ID_SHIFT)
16 #define RESET_BIT_POS(id)	((id) & RESET_BIT_POS_MASK)
17 
18 #if defined(CFG_ATMEL_RSTC)
19 bool atmel_rstc_available(void);
20 
21 void __noreturn atmel_rstc_reset(void);
22 void sam_rstc_usb_por(unsigned char id, bool enable);
23 #else
24 static inline bool atmel_rstc_available(void)
25 {
26 	return false;
27 }
28 
29 static inline void atmel_rstc_reset(void) {}
30 static inline void sam_rstc_usb_por(unsigned char id __unused,
31 				    bool enable __unused) {}
32 #endif
33 
34 #endif /* __DRIVERS_ATMEL_RSTC_H */
35