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