xref: /optee_os/core/include/drivers/stm32_rtc.h (revision 678a558fd2617dd957b862f521ce3e8481636010)
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2018-2025, STMicroelectronics
4  */
5 
6 #ifndef __DRIVERS_STM32_RTC_H__
7 #define __DRIVERS_STM32_RTC_H__
8 
9 #include <drivers/rtc.h>
10 #include <stdbool.h>
11 #include <tee_api_types.h>
12 
13 #if defined(CFG_STM32_RTC)
14 /**
15  * stm32_rtc_set_tamper_timestamp() - Enable tamper and secure timestamp access
16  * in RTC
17  */
18 TEE_Result stm32_rtc_set_tamper_timestamp(void);
19 
20 /**
21  * stm32_rtc_is_timestamp_enabled() - Indicates if RTC timestamping is enabled
22  *
23  * @ret: [Out] True if and only if RTC timestamp is enabled
24  */
25 TEE_Result stm32_rtc_is_timestamp_enabled(bool *ret);
26 
27 /**
28  * stm32_rtc_get_timestamp() - Get RTC timestamp for current time. This function
29  * can be called from an interruption context
30  *
31  * @tm: [Out] RTC timestamp value
32  */
33 TEE_Result stm32_rtc_get_timestamp(struct optee_rtc_time *tm);
34 
35 /**
36  * stm32_rtc_driver_is_initialized() - Indicates if RTC driver is initialized
37  *
38  * Returns TEE_ERROR_DEFER_DRIVER_INIT if it's not the case, TEE_SUCCESS
39  * otherwise
40  */
41 TEE_Result stm32_rtc_driver_is_initialized(void);
42 #else /* CFG_STM32_RTC */
43 static inline TEE_Result stm32_rtc_set_tamper_timestamp(void)
44 {
45 	return TEE_ERROR_NOT_IMPLEMENTED;
46 }
47 
48 static inline TEE_Result stm32_rtc_is_timestamp_enabled(bool *ret __unused)
49 {
50 	return TEE_ERROR_NOT_IMPLEMENTED;
51 }
52 
53 static inline TEE_Result
54 stm32_rtc_get_timestamp(struct optee_rtc_time *tm __unused)
55 {
56 	return TEE_ERROR_NOT_IMPLEMENTED;
57 }
58 
59 static inline TEE_Result stm32_rtc_driver_is_initialized(void)
60 {
61 	return TEE_ERROR_NOT_IMPLEMENTED;
62 }
63 #endif /* CFG_STM32_RTC */
64 #endif /* __DRIVERS_STM32_RTC_H__ */
65