Software APIs
aon_timer.h
Go to the documentation of this file.
1
// Copyright lowRISC contributors (OpenTitan project).
2
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3
// SPDX-License-Identifier: Apache-2.0
4
//
5
// Device table API auto-generated by `dtgen`
6
7
#ifndef OPENTITAN_DT_AON_TIMER_H_
8
#define OPENTITAN_DT_AON_TIMER_H_
9
10
#ifdef __cplusplus
11
extern
"C"
{
12
#endif
// __cplusplus
13
14
/**
15
* @file
16
* @brief Device Tables (DT) for IP aon_timer and top earlgrey.
17
*
18
* This file contains the type definitions and global functions of the aon_timer.
19
*/
20
21
#include "hw/top/dt/api.h"
22
#include <stdint.h>
23
24
25
26
/**
27
* List of instances.
28
*/
29
typedef
enum
dt_aon_timer
{
30
kDtAonTimerFirst
= 0,
/**< First instance */
31
kDtAonTimerAon
= 0,
/**< aon_timer_aon */
32
}
dt_aon_timer_t
;
33
34
enum
{
35
kDtAonTimerCount
= 1,
/**< Number of instances */
36
};
37
38
39
/**
40
* List of register blocks.
41
*
42
* Register blocks are guaranteed to start at 0 and to be consecutively numbered.
43
*/
44
typedef
enum
dt_aon_timer_reg_block
{
45
kDtAonTimerRegBlockCore = 0,
/**< */
46
}
dt_aon_timer_reg_block_t
;
47
48
enum
{
49
kDtAonTimerRegBlockCount
= 1,
/**< Number of register blocks */
50
};
51
52
53
/** Primary register block (associated with the "primary" set of registers that control the IP). */
54
static
const
dt_aon_timer_reg_block_t
kDtAonTimerRegBlockPrimary = kDtAonTimerRegBlockCore;
55
56
/**
57
* List of IRQs.
58
*
59
* IRQs are guaranteed to be numbered consecutively from 0.
60
*/
61
typedef
enum
dt_aon_timer_irq
{
62
kDtAonTimerIrqWkupTimerExpired
= 0,
/**< Raised if the wakeup timer has hit the specified threshold. */
63
kDtAonTimerIrqWdogTimerBark
= 1,
/**< Raised if the watchdog timer has hit the bark threshold. */
64
}
dt_aon_timer_irq_t
;
65
66
enum
{
67
kDtAonTimerIrqCount
= 2,
/**< Number of IRQs */
68
};
69
70
71
/**
72
* List of Alerts.
73
*
74
* Alerts are guaranteed to be numbered consecutively from 0.
75
*/
76
typedef
enum
dt_aon_timer_alert
{
77
kDtAonTimerAlertFatalFault
= 0,
/**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
78
}
dt_aon_timer_alert_t
;
79
80
enum
{
81
kDtAonTimerAlertCount
= 1,
/**< Number of Alerts */
82
};
83
84
85
/**
86
* List of clock ports.
87
*
88
* Clock ports are guaranteed to be numbered consecutively from 0.
89
*/
90
typedef
enum
dt_aon_timer_clock
{
91
kDtAonTimerClockClk
= 0,
/**< Clock port clk_i */
92
kDtAonTimerClockAon
= 1,
/**< Clock port clk_aon_i */
93
}
dt_aon_timer_clock_t
;
94
95
enum
{
96
kDtAonTimerClockCount
= 2,
/**< Number of clock ports */
97
};
98
99
100
/**
101
* List of reset requests.
102
*
103
* Reset requests are guaranteed to be numbered consecutively from 0.
104
*/
105
typedef
enum
dt_aon_timer_reset_req
{
106
kDtAonTimerResetReqAonTimer
= 0,
/**< Watchdog reset request. */
107
}
dt_aon_timer_reset_req_t
;
108
109
enum
{
110
kDtAonTimerResetReqCount
= 1,
/**< Number of reset requests */
111
};
112
113
114
/**
115
* List of reset ports.
116
*
117
* Reset ports are guaranteed to be numbered consecutively from 0.
118
*/
119
typedef
enum
dt_aon_timer_reset
{
120
kDtAonTimerResetRst
= 0,
/**< Reset port rst_ni */
121
kDtAonTimerResetAon
= 1,
/**< Reset port rst_aon_ni */
122
}
dt_aon_timer_reset_t
;
123
124
enum
{
125
kDtAonTimerResetCount
= 2,
/**< Number of reset ports */
126
};
127
128
129
/**
130
* List of wakeups.
131
*
132
* Wakeups are guaranteed to be numbered consecutively from 0.
133
*/
134
typedef
enum
dt_aon_timer_wakeup
{
135
kDtAonTimerWakeupWkupReq
= 0,
/**< Raised if the wakeup or watchdog timer has hit the specified threshold. */
136
}
dt_aon_timer_wakeup_t
;
137
138
enum
{
139
kDtAonTimerWakeupCount
= 1,
/**< Number of wakeups */
140
};
141
142
143
/**
144
* List of supported hardware features.
145
*/
146
#define OPENTITAN_AON_TIMER_HAS_WAKEUP_WAKEUP_CONFIG 1
147
#define OPENTITAN_AON_TIMER_HAS_WAKEUP_WAKEUP_REQUEST 1
148
#define OPENTITAN_AON_TIMER_HAS_WAKEUP_INTERRUPT 1
149
#define OPENTITAN_AON_TIMER_HAS_WATCHDOG_BARK 1
150
#define OPENTITAN_AON_TIMER_HAS_WATCHDOG_BITE 1
151
#define OPENTITAN_AON_TIMER_HAS_WATCHDOG_PAUSE 1
152
#define OPENTITAN_AON_TIMER_HAS_WATCHDOG_DISABLE_BY_LC_CTRL 1
153
#define OPENTITAN_AON_TIMER_HAS_WATCHDOG_INTERRUPT 1
154
155
156
157
/**
158
* Get the aon_timer instance from an instance ID
159
*
160
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
161
*
162
* @param inst_id Instance ID.
163
* @return A aon_timer instance.
164
*
165
* **Note:** This function only makes sense if the instance ID has device type aon_timer,
166
* otherwise the returned value is unspecified.
167
*/
168
dt_aon_timer_t
dt_aon_timer_from_instance_id
(
dt_instance_id_t
inst_id);
169
170
/**
171
* Get the instance ID of an instance.
172
*
173
* @param dt Instance of aon_timer.
174
* @return The instance ID of that instance.
175
*/
176
dt_instance_id_t
dt_aon_timer_instance_id
(
dt_aon_timer_t
dt);
177
178
/**
179
* Get the register base address of an instance.
180
*
181
* @param dt Instance of aon_timer.
182
* @param reg_block The register block requested.
183
* @return The register base address of the requested block.
184
*/
185
uint32_t
dt_aon_timer_reg_block
(
186
dt_aon_timer_t
dt,
187
dt_aon_timer_reg_block_t
reg_block);
188
189
/**
190
* Get the primary register base address of an instance.
191
*
192
* This is just a convenience function, equivalent to
193
* `dt_aon_timer_reg_block(dt, kDtAonTimerRegBlockCore)`
194
*
195
* @param dt Instance of aon_timer.
196
* @return The register base address of the primary register block.
197
*/
198
static
inline
uint32_t dt_aon_timer_primary_reg_block(
199
dt_aon_timer_t
dt) {
200
return
dt_aon_timer_reg_block
(dt, kDtAonTimerRegBlockCore);
201
}
202
203
/**
204
* Get the PLIC ID of a aon_timer IRQ for a given instance.
205
*
206
* If the instance is not connected to the PLIC, this function
207
* will return `kDtPlicIrqIdNone`.
208
*
209
* @param dt Instance of aon_timer.
210
* @param irq A aon_timer IRQ.
211
* @return The PLIC ID of the IRQ of this instance.
212
*/
213
dt_plic_irq_id_t
dt_aon_timer_irq_to_plic_id
(
214
dt_aon_timer_t
dt,
215
dt_aon_timer_irq_t
irq);
216
217
/**
218
* Convert a global IRQ ID to a local aon_timer IRQ type.
219
*
220
* @param dt Instance of aon_timer.
221
* @param irq A PLIC ID that belongs to this instance.
222
* @return The aon_timer IRQ, or `kDtAonTimerIrqCount`.
223
*
224
* **Note:** This function assumes that the PLIC ID belongs to the instance
225
* of aon_timer passed in parameter. In other words, it must be the case that
226
* `dt_aon_timer_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
227
* will return `kDtAonTimerIrqCount`.
228
*/
229
dt_aon_timer_irq_t
dt_aon_timer_irq_from_plic_id
(
230
dt_aon_timer_t
dt,
231
dt_plic_irq_id_t
irq);
232
233
234
/**
235
* Get the alert ID of a aon_timer alert for a given instance.
236
*
237
* **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
238
* instances where the instance is not connected, the return value is unspecified.
239
*
240
* @param dt Instance of aon_timer.
241
* @param alert A aon_timer alert.
242
* @return The Alert Handler alert ID of the alert of this instance.
243
*/
244
dt_alert_id_t
dt_aon_timer_alert_to_alert_id
(
245
dt_aon_timer_t
dt,
246
dt_aon_timer_alert_t
alert);
247
248
/**
249
* Convert a global alert ID to a local aon_timer alert type.
250
*
251
* @param dt Instance of aon_timer.
252
* @param alert A global alert ID that belongs to this instance.
253
* @return The aon_timer alert, or `kDtAonTimerAlertCount`.
254
*
255
* **Note:** This function assumes that the global alert ID belongs to the
256
* instance of aon_timer passed in parameter. In other words, it must be the case
257
* that `dt_aon_timer_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
258
* this function will return `kDtAonTimerAlertCount`.
259
*/
260
dt_aon_timer_alert_t
dt_aon_timer_alert_from_alert_id
(
261
dt_aon_timer_t
dt,
262
dt_alert_id_t
alert);
263
264
265
266
/**
267
* Get the clock signal connected to a clock port of an instance.
268
*
269
* @param dt Instance of aon_timer.
270
* @param clk Clock port.
271
* @return Clock signal.
272
*/
273
dt_clock_t
dt_aon_timer_clock
(
274
dt_aon_timer_t
dt,
275
dt_aon_timer_clock_t
clk);
276
277
/**
278
* Get the reset signal connected to a reset port of an instance.
279
*
280
* @param dt Instance of aon_timer.
281
* @param rst Reset port.
282
* @return Reset signal.
283
*/
284
dt_reset_t
dt_aon_timer_reset
(
285
dt_aon_timer_t
dt,
286
dt_aon_timer_reset_t
rst);
287
288
289
290
#ifdef __cplusplus
291
}
// extern "C"
292
#endif
// __cplusplus
293
294
#endif
// OPENTITAN_DT_AON_TIMER_H_
(earlgrey)
hw
top
dt
aon_timer.h
Return to
OpenTitan Documentation