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