xref: /optee_os/core/include/drivers/atmel_rstc.h (revision 5aa44b2b9b8be5ad8bab1fb0b446fe1115bead2b)
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 <drivers/rstctrl.h>
10 #include <stdbool.h>
11 #include <util.h>
12 
13 #define RESET_ID_MASK		GENMASK_32(8, 5)
14 #define RESET_ID_SHIFT		U(5)
15 #define RESET_BIT_POS_MASK	GENMASK_32(4, 0)
16 #define RESET_OFFSET(id)	(((id) & RESET_ID_MASK) >> RESET_ID_SHIFT)
17 #define RESET_BIT_POS(id)	((id) & RESET_BIT_POS_MASK)
18 
19 #if defined(CFG_ATMEL_RSTC)
20 bool atmel_rstc_available(void);
21 
22 void __noreturn atmel_rstc_reset(void);
23 void sam_rstc_usb_por(unsigned char id, bool enable);
24 struct rstctrl *sam_get_rstctrl(unsigned int reset_id);
25 #else
atmel_rstc_available(void)26 static inline bool atmel_rstc_available(void)
27 {
28 	return false;
29 }
30 
atmel_rstc_reset(void)31 static inline void atmel_rstc_reset(void) {}
sam_rstc_usb_por(unsigned char id __unused,bool enable __unused)32 static inline void sam_rstc_usb_por(unsigned char id __unused,
33 				    bool enable __unused) {}
sam_get_rstctrl(unsigned int reset_id __unused)34 static inline struct rstctrl *sam_get_rstctrl(unsigned int reset_id __unused)
35 {
36 	return NULL;
37 }
38 #endif
39 
40 #endif /* __DRIVERS_ATMEL_RSTC_H */
41