xref: /optee_os/core/include/drivers/atmel_rstc.h (revision 5aa44b2b9b8be5ad8bab1fb0b446fe1115bead2b)
11dc7d0e9SClément Léger /* SPDX-License-Identifier: BSD-2-Clause */
21dc7d0e9SClément Léger /*
31dc7d0e9SClément Léger  * Copyright (c) 2021, Microchip
41dc7d0e9SClément Léger  */
51dc7d0e9SClément Léger #ifndef __DRIVERS_ATMEL_RSTC_H
61dc7d0e9SClément Léger #define __DRIVERS_ATMEL_RSTC_H
71dc7d0e9SClément Léger 
81dc7d0e9SClément Léger #include <compiler.h>
9*5aa44b2bSTony Han #include <drivers/rstctrl.h>
101dc7d0e9SClément Léger #include <stdbool.h>
119e86f0a2STony Han #include <util.h>
129e86f0a2STony Han 
139e86f0a2STony Han #define RESET_ID_MASK		GENMASK_32(8, 5)
149e86f0a2STony Han #define RESET_ID_SHIFT		U(5)
159e86f0a2STony Han #define RESET_BIT_POS_MASK	GENMASK_32(4, 0)
169e86f0a2STony Han #define RESET_OFFSET(id)	(((id) & RESET_ID_MASK) >> RESET_ID_SHIFT)
179e86f0a2STony Han #define RESET_BIT_POS(id)	((id) & RESET_BIT_POS_MASK)
181dc7d0e9SClément Léger 
191dc7d0e9SClément Léger #if defined(CFG_ATMEL_RSTC)
201dc7d0e9SClément Léger bool atmel_rstc_available(void);
211dc7d0e9SClément Léger 
221dc7d0e9SClément Léger void __noreturn atmel_rstc_reset(void);
23d557d174STony Han void sam_rstc_usb_por(unsigned char id, bool enable);
24*5aa44b2bSTony Han struct rstctrl *sam_get_rstctrl(unsigned int reset_id);
251dc7d0e9SClément Léger #else
atmel_rstc_available(void)261dc7d0e9SClément Léger static inline bool atmel_rstc_available(void)
271dc7d0e9SClément Léger {
281dc7d0e9SClément Léger 	return false;
291dc7d0e9SClément Léger }
301dc7d0e9SClément Léger 
atmel_rstc_reset(void)311dc7d0e9SClément Léger static inline void atmel_rstc_reset(void) {}
sam_rstc_usb_por(unsigned char id __unused,bool enable __unused)32d557d174STony Han static inline void sam_rstc_usb_por(unsigned char id __unused,
33d557d174STony Han 				    bool enable __unused) {}
sam_get_rstctrl(unsigned int reset_id __unused)34*5aa44b2bSTony Han static inline struct rstctrl *sam_get_rstctrl(unsigned int reset_id __unused)
35*5aa44b2bSTony Han {
36*5aa44b2bSTony Han 	return NULL;
37*5aa44b2bSTony Han }
381dc7d0e9SClément Léger #endif
391dc7d0e9SClément Léger 
401dc7d0e9SClément Léger #endif /* __DRIVERS_ATMEL_RSTC_H */
41