1f3f9432fSClément Léger /* SPDX-License-Identifier: BSD-2-Clause */
2f3f9432fSClément Léger /*
3f3f9432fSClément Léger * Copyright 2022 Microchip.
4f3f9432fSClément Léger */
5f3f9432fSClément Léger
6d50fee03SEtienne Carriere #ifndef __DRIVERS_RTC_H
7d50fee03SEtienne Carriere #define __DRIVERS_RTC_H
8f3f9432fSClément Léger
926899ca2SClément Le Goffic #include <kernel/panic.h>
10f3f9432fSClément Léger #include <tee_api_types.h>
11f3f9432fSClément Léger #include <util.h>
12f3f9432fSClément Léger
13f3f9432fSClément Léger /* The RTC allows to set/get offset for correction */
14f3f9432fSClément Léger #define RTC_CORRECTION_FEATURE BIT(0)
15*143e9dceSClément Le Goffic /* The RTC allows to set/read an alarm */
16*143e9dceSClément Le Goffic #define RTC_ALARM_FEATURE BIT(1)
17*143e9dceSClément Le Goffic /* The RTC can wake-up the platform through alarm */
18*143e9dceSClément Le Goffic #define RTC_WAKEUP_ALARM BIT(2)
19f3f9432fSClément Léger
2026899ca2SClément Le Goffic #define MS_PER_SEC 1000
2126899ca2SClément Le Goffic #define MS_PER_MIN (60 * MS_PER_SEC)
2226899ca2SClément Le Goffic #define MS_PER_HOUR (60 * MS_PER_MIN)
2326899ca2SClément Le Goffic #define MS_PER_DAY (24 * MS_PER_HOUR)
2426899ca2SClément Le Goffic
25a83e616eSGatien Chevallier #define RTC_TIME(year, mon, mday, wday, hour, min, sec, ms) \
26a83e616eSGatien Chevallier { \
27a83e616eSGatien Chevallier .tm_year = (year), \
28a83e616eSGatien Chevallier .tm_mon = (mon), \
29a83e616eSGatien Chevallier .tm_mday = (mday), \
30a83e616eSGatien Chevallier .tm_wday = (wday), \
31a83e616eSGatien Chevallier .tm_hour = (hour), \
32a83e616eSGatien Chevallier .tm_min = (min), \
33a83e616eSGatien Chevallier .tm_sec = (sec), \
34a83e616eSGatien Chevallier .tm_ms = (ms), \
35a83e616eSGatien Chevallier }
36a83e616eSGatien Chevallier
3726899ca2SClément Le Goffic /*
3826899ca2SClément Le Goffic * struct optee_rtc_time - Time in Gregorian calendar
3926899ca2SClément Le Goffic *
4026899ca2SClément Le Goffic * @tm_year: Absolute year
4126899ca2SClément Le Goffic * @tm_mon: Month: 0=January, 1=February, ..., 11=December
4226899ca2SClément Le Goffic * @tm_mday: Month day start from 1
4326899ca2SClément Le Goffic * @tm_wday: Week day: 0=Sunday, 1=Monday, ..., 6=Saturday
4426899ca2SClément Le Goffic * @tm_hour: Hour in range [0 23]
4526899ca2SClément Le Goffic * @tm_min: Minute in range [0 59]
4626899ca2SClément Le Goffic * @tm_sec: Second in range [0 59]
4726899ca2SClément Le Goffic * @tm_ms: Millisecond in range [0 999] or 0 if no applicable
4826899ca2SClément Le Goffic */
49f3f9432fSClément Léger struct optee_rtc_time {
50f3f9432fSClément Léger uint32_t tm_year;
51f3f9432fSClément Léger uint32_t tm_mon;
52f3f9432fSClément Léger uint32_t tm_mday;
5326899ca2SClément Le Goffic uint32_t tm_wday;
54f3f9432fSClément Léger uint32_t tm_hour;
55f3f9432fSClément Léger uint32_t tm_min;
56f3f9432fSClément Léger uint32_t tm_sec;
5726899ca2SClément Le Goffic uint32_t tm_ms;
58f3f9432fSClément Léger };
59f3f9432fSClément Léger
60f3f9432fSClément Léger struct rtc {
61f3f9432fSClément Léger const struct rtc_ops *ops;
62f3f9432fSClément Léger struct optee_rtc_time range_min;
63f3f9432fSClément Léger struct optee_rtc_time range_max;
64*143e9dceSClément Le Goffic bool is_wakeup_source;
65*143e9dceSClément Le Goffic };
66*143e9dceSClément Le Goffic
67*143e9dceSClément Le Goffic /*
68*143e9dceSClément Le Goffic * struct optee_rtc_alarm - The RTC alarm
69*143e9dceSClément Le Goffic * @enabled: 1 if the alarm is enabled, 0 otherwise
70*143e9dceSClément Le Goffic * @pending: 1 if the alarm is pending, 0 otherwise
71*143e9dceSClément Le Goffic * @time: The alarm time
72*143e9dceSClément Le Goffic */
73*143e9dceSClément Le Goffic struct optee_rtc_alarm {
74*143e9dceSClément Le Goffic bool enabled;
75*143e9dceSClément Le Goffic bool pending;
76*143e9dceSClément Le Goffic struct optee_rtc_time time;
77*143e9dceSClément Le Goffic };
78*143e9dceSClément Le Goffic
79*143e9dceSClément Le Goffic /*
80*143e9dceSClément Le Goffic * enum rtc_wait_alarm_status - Return status wait_alarm ops
81*143e9dceSClément Le Goffic * @RTC_WAIT_ALARM_RESET: Reset the wait for the RTC alarm
82*143e9dceSClément Le Goffic * @RTC_WAIT_ALARM_ALARM_OCCURRED: The RTC alarm occurred
83*143e9dceSClément Le Goffic * @RTC_WAIT_ALARM_CANCELED: The wait for the RTC alarm was canceled
84*143e9dceSClément Le Goffic */
85*143e9dceSClément Le Goffic enum rtc_wait_alarm_status {
86*143e9dceSClément Le Goffic RTC_WAIT_ALARM_RESET,
87*143e9dceSClément Le Goffic RTC_WAIT_ALARM_ALARM_OCCURRED,
88*143e9dceSClément Le Goffic RTC_WAIT_ALARM_CANCELED,
89f3f9432fSClément Léger };
90f3f9432fSClément Léger
91f3f9432fSClément Léger /*
92f3f9432fSClément Léger * struct rtc_ops - The RTC device operations
93f3f9432fSClément Léger *
94f3f9432fSClément Léger * @get_time: Get the RTC time.
95f3f9432fSClément Léger * @set_time: Set the RTC time.
96f3f9432fSClément Léger * @get_offset: Get the RTC offset.
97f3f9432fSClément Léger * @set_offset: Set the RTC offset
98*143e9dceSClément Le Goffic * @read_alarm: Read the RTC alarm
99*143e9dceSClément Le Goffic * @set_alarm: Set the RTC alarm
100*143e9dceSClément Le Goffic * @enable_alarm: Enable the RTC alarm
101*143e9dceSClément Le Goffic * @wait_alarm: Wait for the RTC alarm
102*143e9dceSClément Le Goffic * @cancel_wait: Cancel the wait for the RTC alarm
103*143e9dceSClément Le Goffic * @set_alarm_wakeup_status: Set the wakeup capability of the alarm
104f3f9432fSClément Léger */
105f3f9432fSClément Léger struct rtc_ops {
106f3f9432fSClément Léger TEE_Result (*get_time)(struct rtc *rtc, struct optee_rtc_time *tm);
107f3f9432fSClément Léger TEE_Result (*set_time)(struct rtc *rtc, struct optee_rtc_time *tm);
108f3f9432fSClément Léger TEE_Result (*get_offset)(struct rtc *rtc, long *offset);
109f3f9432fSClément Léger TEE_Result (*set_offset)(struct rtc *rtc, long offset);
110*143e9dceSClément Le Goffic TEE_Result (*read_alarm)(struct rtc *rtc, struct optee_rtc_alarm *alrm);
111*143e9dceSClément Le Goffic TEE_Result (*set_alarm)(struct rtc *rtc, struct optee_rtc_alarm *alrm);
112*143e9dceSClément Le Goffic TEE_Result (*enable_alarm)(struct rtc *rtc, bool enable);
113*143e9dceSClément Le Goffic TEE_Result (*wait_alarm)(struct rtc *rtc,
114*143e9dceSClément Le Goffic enum rtc_wait_alarm_status *status);
115*143e9dceSClément Le Goffic TEE_Result (*cancel_wait)(struct rtc *rtc);
116*143e9dceSClément Le Goffic TEE_Result (*set_alarm_wakeup_status)(struct rtc *rtc, bool status);
117f3f9432fSClément Léger };
118f3f9432fSClément Léger
119f3f9432fSClément Léger #ifdef CFG_DRIVERS_RTC
120f3f9432fSClément Léger extern struct rtc *rtc_device;
121f3f9432fSClément Léger
122f3f9432fSClément Léger /* Register a RTC device as the system RTC */
123f3f9432fSClément Léger void rtc_register(struct rtc *rtc);
124f3f9432fSClément Léger
12526899ca2SClément Le Goffic /**
12626899ca2SClément Le Goffic * rtc_is_a_leap_year() - Check if a year is a leap year
12726899ca2SClément Le Goffic * @year: The year to check
12826899ca2SClément Le Goffic *
12926899ca2SClément Le Goffic * Return: true if the year is a leap year, false otherwise
13026899ca2SClément Le Goffic */
13126899ca2SClément Le Goffic bool rtc_is_a_leap_year(uint32_t year);
13226899ca2SClément Le Goffic
13326899ca2SClément Le Goffic /**
13426899ca2SClément Le Goffic * rtc_get_month_days() - Get the number of days in a month
13526899ca2SClément Le Goffic * @month: The month to know the number of days
13626899ca2SClément Le Goffic * @year: The year of the month
13726899ca2SClément Le Goffic *
13826899ca2SClément Le Goffic * Return: Number of days in the month
13926899ca2SClément Le Goffic */
14026899ca2SClément Le Goffic uint8_t rtc_get_month_days(uint32_t month, uint32_t year);
14126899ca2SClément Le Goffic
14226899ca2SClément Le Goffic /**
14326899ca2SClément Le Goffic * rtc_timecmp() - Compare two RTC time structures
14426899ca2SClément Le Goffic * @a: First RTC time
14526899ca2SClément Le Goffic * @b: Second RTC time
14626899ca2SClément Le Goffic *
14726899ca2SClément Le Goffic * Return a negative value if @a < @b
14826899ca2SClément Le Goffic * Return 0 if @a == @b
14926899ca2SClément Le Goffic * Return a positive value if @a > @b
15026899ca2SClément Le Goffic */
15126899ca2SClément Le Goffic int rtc_timecmp(struct optee_rtc_time *a, struct optee_rtc_time *b);
15226899ca2SClément Le Goffic
15326899ca2SClément Le Goffic /**
15426899ca2SClément Le Goffic * rtc_diff_calendar_ms() - Return the difference in milliseconds between
15526899ca2SClément Le Goffic * two times captures.
15626899ca2SClément Le Goffic * @ref1: First time capture
15726899ca2SClément Le Goffic * @ref2: Second time capture
15826899ca2SClément Le Goffic *
15926899ca2SClément Le Goffic * Return @ref1 - @ref2 in milliseconds or LLONG_MAX in case of overflow
16026899ca2SClément Le Goffic */
16126899ca2SClément Le Goffic signed long long rtc_diff_calendar_ms(struct optee_rtc_time *ref1,
16226899ca2SClément Le Goffic struct optee_rtc_time *ref2);
16326899ca2SClément Le Goffic
16426899ca2SClément Le Goffic /**
16526899ca2SClément Le Goffic * rtc_diff_calendar_tick() - Return the difference in number of ticks between
16626899ca2SClément Le Goffic * two times captures.
16726899ca2SClément Le Goffic * @ref1: First time capture
16826899ca2SClément Le Goffic * @ref2: Second time capture
16926899ca2SClément Le Goffic * @tick_rate: Tick rate
17026899ca2SClément Le Goffic *
17126899ca2SClément Le Goffic * Return @ref1 - @ref2 in number of ticks. In case of tick computation
17226899ca2SClément Le Goffic * overflow, return LLONG_MAX
17326899ca2SClément Le Goffic */
17426899ca2SClément Le Goffic signed long long rtc_diff_calendar_tick(struct optee_rtc_time *ref1,
17526899ca2SClément Le Goffic struct optee_rtc_time *ref2,
17626899ca2SClément Le Goffic unsigned long long tick_rate);
17726899ca2SClément Le Goffic
rtc_get_info(uint64_t * features,struct optee_rtc_time * range_min,struct optee_rtc_time * range_max)178f3f9432fSClément Léger static inline TEE_Result rtc_get_info(uint64_t *features,
179f3f9432fSClément Léger struct optee_rtc_time *range_min,
180f3f9432fSClément Léger struct optee_rtc_time *range_max)
181f3f9432fSClément Léger {
182f3f9432fSClément Léger if (!rtc_device)
183f3f9432fSClément Léger return TEE_ERROR_NOT_SUPPORTED;
184f3f9432fSClément Léger
185f3f9432fSClément Léger if (rtc_device->ops->set_offset)
186f3f9432fSClément Léger *features = RTC_CORRECTION_FEATURE;
187f3f9432fSClément Léger *range_min = rtc_device->range_min;
188f3f9432fSClément Léger *range_max = rtc_device->range_max;
189f3f9432fSClément Léger
190*143e9dceSClément Le Goffic if (rtc_device->ops->set_alarm)
191*143e9dceSClément Le Goffic *features |= RTC_ALARM_FEATURE;
192*143e9dceSClément Le Goffic
193*143e9dceSClément Le Goffic if (rtc_device->is_wakeup_source)
194*143e9dceSClément Le Goffic *features |= RTC_WAKEUP_ALARM;
195*143e9dceSClément Le Goffic
196f3f9432fSClément Léger return TEE_SUCCESS;
197f3f9432fSClément Léger }
198f3f9432fSClément Léger
rtc_get_time(struct optee_rtc_time * tm)199f3f9432fSClément Léger static inline TEE_Result rtc_get_time(struct optee_rtc_time *tm)
200f3f9432fSClément Léger {
201f3f9432fSClément Léger if (!rtc_device)
202f3f9432fSClément Léger return TEE_ERROR_NOT_SUPPORTED;
203f3f9432fSClément Léger
204f3f9432fSClément Léger return rtc_device->ops->get_time(rtc_device, tm);
205f3f9432fSClément Léger }
206f3f9432fSClément Léger
rtc_set_time(struct optee_rtc_time * tm)207f3f9432fSClément Léger static inline TEE_Result rtc_set_time(struct optee_rtc_time *tm)
208f3f9432fSClément Léger {
209f3f9432fSClément Léger if (!rtc_device || !rtc_device->ops->set_time)
210f3f9432fSClément Léger return TEE_ERROR_NOT_SUPPORTED;
211f3f9432fSClément Léger
21273aafcc9SGatien Chevallier if (tm->tm_mon >= 12 ||
21373aafcc9SGatien Chevallier tm->tm_mday > rtc_get_month_days(tm->tm_mon, tm->tm_year) ||
21473aafcc9SGatien Chevallier tm->tm_wday >= 7 || tm->tm_hour >= 24 || tm->tm_min >= 60 ||
21573aafcc9SGatien Chevallier tm->tm_sec >= 60 || tm->tm_ms >= 1000 ||
21673aafcc9SGatien Chevallier rtc_timecmp(tm, &rtc_device->range_min) < 0 ||
21773aafcc9SGatien Chevallier rtc_timecmp(tm, &rtc_device->range_max) > 0)
21873aafcc9SGatien Chevallier return TEE_ERROR_BAD_PARAMETERS;
21973aafcc9SGatien Chevallier
220f3f9432fSClément Léger return rtc_device->ops->set_time(rtc_device, tm);
221f3f9432fSClément Léger }
222f3f9432fSClément Léger
rtc_get_offset(long * offset)223f3f9432fSClément Léger static inline TEE_Result rtc_get_offset(long *offset)
224f3f9432fSClément Léger {
225f3f9432fSClément Léger if (!rtc_device || !rtc_device->ops->get_offset)
226f3f9432fSClément Léger return TEE_ERROR_NOT_SUPPORTED;
227f3f9432fSClément Léger
228f3f9432fSClément Léger return rtc_device->ops->get_offset(rtc_device, offset);
229f3f9432fSClément Léger }
230f3f9432fSClément Léger
rtc_set_offset(long offset)231f3f9432fSClément Léger static inline TEE_Result rtc_set_offset(long offset)
232f3f9432fSClément Léger {
233f3f9432fSClément Léger if (!rtc_device || !rtc_device->ops->set_offset)
234f3f9432fSClément Léger return TEE_ERROR_NOT_SUPPORTED;
235f3f9432fSClément Léger
236f3f9432fSClément Léger return rtc_device->ops->set_offset(rtc_device, offset);
237f3f9432fSClément Léger }
238f3f9432fSClément Léger
rtc_read_alarm(struct optee_rtc_alarm * alarm)239*143e9dceSClément Le Goffic static inline TEE_Result rtc_read_alarm(struct optee_rtc_alarm *alarm)
240*143e9dceSClément Le Goffic {
241*143e9dceSClément Le Goffic if (!rtc_device || !rtc_device->ops->read_alarm)
242*143e9dceSClément Le Goffic return TEE_ERROR_NOT_SUPPORTED;
243*143e9dceSClément Le Goffic
244*143e9dceSClément Le Goffic return rtc_device->ops->read_alarm(rtc_device, alarm);
245*143e9dceSClément Le Goffic }
246*143e9dceSClément Le Goffic
rtc_set_alarm(struct optee_rtc_alarm * alarm)247*143e9dceSClément Le Goffic static inline TEE_Result rtc_set_alarm(struct optee_rtc_alarm *alarm)
248*143e9dceSClément Le Goffic {
249*143e9dceSClément Le Goffic if (!rtc_device || !rtc_device->ops->set_alarm)
250*143e9dceSClément Le Goffic return TEE_ERROR_NOT_SUPPORTED;
251*143e9dceSClément Le Goffic
252*143e9dceSClément Le Goffic return rtc_device->ops->set_alarm(rtc_device, alarm);
253*143e9dceSClément Le Goffic }
254*143e9dceSClément Le Goffic
rtc_enable_alarm(bool enable)255*143e9dceSClément Le Goffic static inline TEE_Result rtc_enable_alarm(bool enable)
256*143e9dceSClément Le Goffic {
257*143e9dceSClément Le Goffic if (!rtc_device || !rtc_device->ops->enable_alarm)
258*143e9dceSClément Le Goffic return TEE_ERROR_NOT_SUPPORTED;
259*143e9dceSClément Le Goffic
260*143e9dceSClément Le Goffic return rtc_device->ops->enable_alarm(rtc_device, enable);
261*143e9dceSClément Le Goffic }
262*143e9dceSClément Le Goffic
rtc_wait_alarm(enum rtc_wait_alarm_status * status)263*143e9dceSClément Le Goffic static inline TEE_Result rtc_wait_alarm(enum rtc_wait_alarm_status *status)
264*143e9dceSClément Le Goffic {
265*143e9dceSClément Le Goffic if (!rtc_device || !rtc_device->ops->wait_alarm)
266*143e9dceSClément Le Goffic return TEE_ERROR_NOT_SUPPORTED;
267*143e9dceSClément Le Goffic
268*143e9dceSClément Le Goffic return rtc_device->ops->wait_alarm(rtc_device, status);
269*143e9dceSClément Le Goffic }
270*143e9dceSClément Le Goffic
rtc_cancel_wait_alarm(void)271*143e9dceSClément Le Goffic static inline TEE_Result rtc_cancel_wait_alarm(void)
272*143e9dceSClément Le Goffic {
273*143e9dceSClément Le Goffic if (!rtc_device || !rtc_device->ops->cancel_wait)
274*143e9dceSClément Le Goffic return TEE_ERROR_NOT_SUPPORTED;
275*143e9dceSClément Le Goffic
276*143e9dceSClément Le Goffic return rtc_device->ops->cancel_wait(rtc_device);
277*143e9dceSClément Le Goffic }
278*143e9dceSClément Le Goffic
rtc_set_alarm_wakeup_status(bool status)279*143e9dceSClément Le Goffic static inline TEE_Result rtc_set_alarm_wakeup_status(bool status)
280*143e9dceSClément Le Goffic {
281*143e9dceSClément Le Goffic if (!rtc_device || !rtc_device->ops->set_alarm_wakeup_status)
282*143e9dceSClément Le Goffic return TEE_ERROR_NOT_SUPPORTED;
283*143e9dceSClément Le Goffic
284*143e9dceSClément Le Goffic return rtc_device->ops->set_alarm_wakeup_status(rtc_device, status);
285*143e9dceSClément Le Goffic }
286f3f9432fSClément Léger #else
287f3f9432fSClément Léger
rtc_register(struct rtc * rtc __unused)288f3f9432fSClément Léger static inline void rtc_register(struct rtc *rtc __unused) {}
289f3f9432fSClément Léger
rtc_is_a_leap_year(uint32_t year __unused)29026899ca2SClément Le Goffic static inline bool __noreturn rtc_is_a_leap_year(uint32_t year __unused)
29126899ca2SClément Le Goffic {
29226899ca2SClément Le Goffic panic();
29326899ca2SClément Le Goffic }
29426899ca2SClément Le Goffic
rtc_get_month_days(uint32_t month __unused,uint32_t year __unused)29526899ca2SClément Le Goffic static inline uint8_t __noreturn rtc_get_month_days(uint32_t month __unused,
29626899ca2SClément Le Goffic uint32_t year __unused)
29726899ca2SClément Le Goffic {
29826899ca2SClément Le Goffic panic();
29926899ca2SClément Le Goffic }
30026899ca2SClément Le Goffic
rtc_timecmp(struct optee_rtc_time * a __unused,struct optee_rtc_time * b __unused)30126899ca2SClément Le Goffic static inline int __noreturn rtc_timecmp(struct optee_rtc_time *a __unused,
30226899ca2SClément Le Goffic struct optee_rtc_time *b __unused)
30326899ca2SClément Le Goffic {
30426899ca2SClément Le Goffic panic();
30526899ca2SClément Le Goffic }
30626899ca2SClément Le Goffic
rtc_get_info(uint64_t * features __unused,struct optee_rtc_time * range_min __unused,struct optee_rtc_time * range_max __unused)307f3f9432fSClément Léger static inline TEE_Result rtc_get_info(uint64_t *features __unused,
308f3f9432fSClément Léger struct optee_rtc_time *range_min __unused,
309f3f9432fSClément Léger struct optee_rtc_time *range_max __unused)
310f3f9432fSClément Léger {
311f3f9432fSClément Léger return TEE_ERROR_NOT_SUPPORTED;
312f3f9432fSClément Léger }
313f3f9432fSClément Léger
rtc_get_time(struct optee_rtc_time * tm __unused)314f3f9432fSClément Léger static inline TEE_Result rtc_get_time(struct optee_rtc_time *tm __unused)
315f3f9432fSClément Léger {
316f3f9432fSClément Léger return TEE_ERROR_NOT_SUPPORTED;
317f3f9432fSClément Léger }
318f3f9432fSClément Léger
rtc_set_time(struct optee_rtc_time * tm __unused)319f3f9432fSClément Léger static inline TEE_Result rtc_set_time(struct optee_rtc_time *tm __unused)
320f3f9432fSClément Léger {
321f3f9432fSClément Léger return TEE_ERROR_NOT_SUPPORTED;
322f3f9432fSClément Léger }
323f3f9432fSClément Léger
rtc_get_offset(long * offset __unused)324f3f9432fSClément Léger static inline TEE_Result rtc_get_offset(long *offset __unused)
325f3f9432fSClément Léger {
326f3f9432fSClément Léger return TEE_ERROR_NOT_SUPPORTED;
327f3f9432fSClément Léger }
328f3f9432fSClément Léger
rtc_set_offset(long offset __unused)329f3f9432fSClément Léger static inline TEE_Result rtc_set_offset(long offset __unused)
330f3f9432fSClément Léger {
331f3f9432fSClément Léger return TEE_ERROR_NOT_SUPPORTED;
332f3f9432fSClément Léger }
33326899ca2SClément Le Goffic
33426899ca2SClément Le Goffic static inline signed long long
rtc_diff_calendar_ms(struct optee_rtc_time * ref1 __unused,struct optee_rtc_time * ref2 __unused)33526899ca2SClément Le Goffic rtc_diff_calendar_ms(struct optee_rtc_time *ref1 __unused,
33626899ca2SClément Le Goffic struct optee_rtc_time *ref2 __unused)
33726899ca2SClément Le Goffic {
33826899ca2SClément Le Goffic return LLONG_MAX;
33926899ca2SClément Le Goffic }
34026899ca2SClément Le Goffic
34126899ca2SClément Le Goffic static inline signed long long
rtc_diff_calendar_tick(struct optee_rtc_time * ref1 __unused,struct optee_rtc_time * ref2 __unused,unsigned long long tick_rate __unused)34226899ca2SClément Le Goffic rtc_diff_calendar_tick(struct optee_rtc_time *ref1 __unused,
34326899ca2SClément Le Goffic struct optee_rtc_time *ref2 __unused,
34426899ca2SClément Le Goffic unsigned long long tick_rate __unused)
34526899ca2SClément Le Goffic {
34626899ca2SClément Le Goffic return LLONG_MAX;
34726899ca2SClément Le Goffic }
348*143e9dceSClément Le Goffic
rtc_read_alarm(struct optee_rtc_alarm * alarm __unused)349*143e9dceSClément Le Goffic static inline TEE_Result rtc_read_alarm(struct optee_rtc_alarm *alarm __unused)
350*143e9dceSClément Le Goffic {
351*143e9dceSClément Le Goffic return TEE_ERROR_NOT_SUPPORTED;
352*143e9dceSClément Le Goffic }
353*143e9dceSClément Le Goffic
rtc_set_alarm(struct optee_rtc_alarm * alarm __unused)354*143e9dceSClément Le Goffic static inline TEE_Result rtc_set_alarm(struct optee_rtc_alarm *alarm __unused)
355*143e9dceSClément Le Goffic {
356*143e9dceSClément Le Goffic return TEE_ERROR_NOT_SUPPORTED;
357*143e9dceSClément Le Goffic }
358*143e9dceSClément Le Goffic
rtc_enable_alarm(bool enable __unused)359*143e9dceSClément Le Goffic static inline TEE_Result rtc_enable_alarm(bool enable __unused)
360*143e9dceSClément Le Goffic {
361*143e9dceSClément Le Goffic return TEE_ERROR_NOT_SUPPORTED;
362*143e9dceSClément Le Goffic }
363*143e9dceSClément Le Goffic
364*143e9dceSClément Le Goffic static inline TEE_Result
rtc_wait_alarm(enum rtc_wait_alarm_status * status __unused)365*143e9dceSClément Le Goffic rtc_wait_alarm(enum rtc_wait_alarm_status *status __unused)
366*143e9dceSClément Le Goffic {
367*143e9dceSClément Le Goffic return TEE_ERROR_NOT_SUPPORTED;
368*143e9dceSClément Le Goffic }
369*143e9dceSClément Le Goffic
rtc_cancel_wait_alarm(void)370*143e9dceSClément Le Goffic static inline TEE_Result rtc_cancel_wait_alarm(void)
371*143e9dceSClément Le Goffic {
372*143e9dceSClément Le Goffic return TEE_ERROR_NOT_SUPPORTED;
373*143e9dceSClément Le Goffic }
374*143e9dceSClément Le Goffic
rtc_set_alarm_wakeup_status(bool status __unused)375*143e9dceSClément Le Goffic static inline TEE_Result rtc_set_alarm_wakeup_status(bool status __unused)
376*143e9dceSClément Le Goffic {
377*143e9dceSClément Le Goffic return TEE_ERROR_NOT_SUPPORTED;
378*143e9dceSClément Le Goffic }
379f3f9432fSClément Léger #endif
380d50fee03SEtienne Carriere #endif /* __DRIVERS_RTC_H */
381