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