File: pta_rtc.h

package info (click to toggle)
optee-os 4.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 31,960 kB
  • sloc: ansic: 444,388; asm: 12,922; python: 3,719; makefile: 1,681; sh: 238
file content (201 lines) | stat: -rw-r--r-- 5,189 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
/* SPDX-License-Identifier: BSD-2-Clause */
/*
 * Copyright (C) 2022, Microchip
 */
#ifndef __PTA_RTC_H
#define __PTA_RTC_H

#include <tee_api_types.h>

#define PTA_RTC_UUID { 0xf389f8c8, 0x845f, 0x496c, \
		{ 0x8b, 0xbe, 0xd6, 0x4b, 0xd2, 0x4c, 0x92, 0xfd } }

#define PTA_RTC_INFO_VERSION		0x1

/*
 * RTC provides set/get offset and thus command PTA_CMD_RTC_GET_OFFSET and
 * PTA_CMD_RTC_SET_OFFSET might be called
 */
#define PTA_RTC_FEATURE_CORRECTION	BIT(0)

/*
 * RTC provides set/read/enable/wait alarm and thus
 * commands:
 * PTA_CMD_RTC_SET_ALARM, PTA_CMD_RTC_READ_ALARM,
 * PTA_CMD_RTC_WAIT_ALARM, PTA_CMD_RTC_ENABLE_ALARM
 * might be called
 */
#define PTA_RTC_FEATURE_ALARM		BIT(1)

/*
 * Command PTA_CMD_RTC_SET_WAKE_ALARM_STATUS can be used to enable/disable the
 * alarm wake-up capability.
 */
#define PTA_RTC_FEATURE_WAKEUP_ALARM	BIT(2)

struct pta_rtc_time {
	uint32_t tm_sec;
	uint32_t tm_min;
	uint32_t tm_hour;
	uint32_t tm_mday;
	uint32_t tm_mon;
	uint32_t tm_year;
	uint32_t tm_wday;
};

/*
 * struct pta_rtc_alarm - State of an RTC alarm
 * @enabled - 1 if alarm is enabled, 0 if disabled
 * @pending - 1 if alarm event is pending, 0 if not
 * @time: Alarm elapsure time
 */
struct pta_rtc_alarm {
	uint8_t enabled;
	uint8_t pending;
	struct pta_rtc_time time;
};

/*
 * struct pta_rtc_info - RTC service information
 * @version - 1st 64bit cell, version of the structure: PTA_RTC_INFO_VERSION
 * @features - 64bit flag mask related to PTA_RTC_FEATURE_*
 * @range_min - Minima time reference the RTC can be programmed to
 * @range_max - Maxima time reference the RTC can reach
 */
struct pta_rtc_info {
	uint64_t version;
	uint64_t features;
	struct pta_rtc_time range_min;
	struct pta_rtc_time range_max;
};

/*
 * PTA_CMD_RTC_GET_INFO - Get RTC information
 *
 * [out]        memref[0]  RTC buffer memory reference containing a struct
 *			   pta_rtc_info
 *
 * Return codes:
 * TEE_SUCCESS - Invoke command success
 * TEE_ERROR_BAD_PARAMETERS - Incorrect input param
 */
#define PTA_CMD_RTC_GET_INFO			0x0

/*
 * PTA_CMD_RTC_GET_TIME - Get time from RTC
 *
 * [out]    memref[0]  RTC buffer memory reference containing a struct
 *		       pta_rtc_time
 *
 * Return codes:
 * TEE_SUCCESS - Invoke command success
 * TEE_ERROR_BAD_PARAMETERS - Incorrect input param
 */
#define PTA_CMD_RTC_GET_TIME			0x1

/*
 * PTA_CMD_RTC_SET_TIME - Set time from RTC
 *
 * [in]     memref[0]  RTC buffer memory reference containing a struct
 *                     pta_rtc_time to be used as RTC time
 *
 * Return codes:
 * TEE_SUCCESS - Invoke command success
 * TEE_ERROR_BAD_PARAMETERS - Incorrect input param
 */
#define PTA_CMD_RTC_SET_TIME			0x2

/*
 * PTA_CMD_RTC_GET_OFFSET - Get RTC offset
 *
 * [out]    value[0].a  RTC offset (signed 32bit value)
 *
 * Return codes:
 * TEE_SUCCESS - Invoke command success
 * TEE_ERROR_BAD_PARAMETERS - Incorrect input param
 */
#define PTA_CMD_RTC_GET_OFFSET			0x3

/*
 * PTA_CMD_RTC_SET_OFFSET - Set RTC offset
 *
 * [in]     value[0].a  RTC offset to be set (signed 32bit value)
 *
 * Return codes:
 * TEE_SUCCESS - Invoke command success
 * TEE_ERROR_BAD_PARAMETERS - Incorrect input param
 */
#define PTA_CMD_RTC_SET_OFFSET			0x4

/*
 * PTA_CMD_RTC_READ_ALARM - Read RTC alarm
 *
 * [out]     memref[0]  RTC buffer memory reference containing a struct
 *                      pta_rtc_alarm
 *
 * Return codes:
 * TEE_SUCCESS - Invoke command success
 * TEE_ERROR_BAD_PARAMETERS - Incorrect input param
 */
#define PTA_CMD_RTC_READ_ALARM			0x5

/*
 * PTA_CMD_RTC_SET_ALARM - Set RTC alarm
 *
 * [in]     memref[0]  RTC buffer memory reference containing a struct
 *                     pta_rtc_alarm to be used as RTC alarm
 *
 * Return codes:
 * TEE_SUCCESS - Invoke command success
 * TEE_ERROR_BAD_PARAMETERS - Incorrect input param
 */
#define PTA_CMD_RTC_SET_ALARM			0x6

/*
 * PTA_CMD_RTC_ENABLE_ALARM - Enable Alarm
 *
 * [in]     value[0].a  RTC IRQ flag (uint32_t), 0 to disable the alarm, 1 to
 *                      enable
 *
 * Return codes:
 * TEE_SUCCESS - Invoke command success
 * TEE_ERROR_BAD_PARAMETERS - Incorrect input param
 */
#define PTA_CMD_RTC_ENABLE_ALARM		0x7

/*
 * PTA_CMD_RTC_WAIT_ALARM - Get alarm event
 *
 * [out]     value[0].a  RTC wait alarm return status (uint32_t):
 *                       - 0: No alarm event
 *                       - 1: Alarm event occurred
 *                       - 2: Alarm event canceled
 *
 * Return codes:
 * TEE_SUCCESS - Invoke command success
 * TEE_ERROR_BAD_PARAMETERS - Incorrect input param
 */
#define PTA_CMD_RTC_WAIT_ALARM			0x8

/*
 * PTA_CMD_RTC_CANCEL_WAIT_ALARM - Cancel wait for alarm event
 *
 * Return codes:
 * TEE_SUCCESS - Invoke command success
 * TEE_ERROR_BAD_PARAMETERS - Incorrect input param
 */
#define PTA_CMD_RTC_CANCEL_WAIT_ALARM		0x9

/*
 * PTA_CMD_RTC_SET_WAKE_ALARM_STATUS - Set RTC wake alarm status flag
 *
 * [in]     value[0].a RTC IRQ wake alarm flag (uint32_t), 0 to disable the wake
 *                     up capability, 1 to enable.
 *
 * Return codes:
 * TEE_SUCCESS - Invoke command success
 * TEE_ERROR_BAD_PARAMETERS - Incorrect input param
 */
#define PTA_CMD_RTC_SET_WAKE_ALARM_STATUS	0xA

#endif /* __PTA_RTC_H */