Software APIs
dt_rv_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_RV_TIMER_H_
8
#define OPENTITAN_DT_RV_TIMER_H_
9
10
#ifdef __cplusplus
11
extern
"C"
{
12
#endif
// __cplusplus
13
14
/**
15
* @file
16
* @brief Device Tables (DT) for IP rv_timer and top earlgrey.
17
*
18
* This file contains the type definitions and global functions of the rv_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_rv_timer
{
30
kDtRvTimer
= 0,
/**< rv_timer */
31
kDtRvTimerFirst = 0,
/**< \internal First instance */
32
kDtRvTimerCount = 1,
/**< \internal Number of instances */
33
}
dt_rv_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_rv_timer_reg_block
{
41
kDtRvTimerRegBlockCore = 0,
/**< */
42
kDtRvTimerRegBlockCount = 1,
/**< \internal Number of register blocks */
43
}
dt_rv_timer_reg_block_t
;
44
45
/** Primary register block (associated with the "primary" set of registers that control the IP). */
46
static
const
dt_rv_timer_reg_block_t
kDtRvTimerRegBlockPrimary = kDtRvTimerRegBlockCore;
47
48
/**
49
* List of IRQs.
50
*
51
* IRQs are guaranteed to be numbered consecutively from 0.
52
*/
53
typedef
enum
dt_rv_timer_irq
{
54
kDtRvTimerIrqTimerExpiredHart0Timer0
= 0,
/**< raised if hart0's timer0 expired (mtimecmp >= mtime) */
55
kDtRvTimerIrqCount = 1,
/**< \internal Number of IRQs */
56
}
dt_rv_timer_irq_t
;
57
58
/**
59
* List of Alerts.
60
*
61
* Alerts are guaranteed to be numbered consecutively from 0.
62
*/
63
typedef
enum
dt_rv_timer_alert
{
64
kDtRvTimerAlertFatalFault
= 0,
/**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected inside the RV_TIMER unit. */
65
kDtRvTimerAlertCount = 1,
/**< \internal Number of Alerts */
66
}
dt_rv_timer_alert_t
;
67
68
/**
69
* List of clock ports.
70
*
71
* Clock ports are guaranteed to be numbered consecutively from 0.
72
*/
73
typedef
enum
dt_rv_timer_clock
{
74
kDtRvTimerClockClk
= 0,
/**< Clock port clk_i */
75
kDtRvTimerClockCount = 1,
/**< \internal Number of clock ports */
76
}
dt_rv_timer_clock_t
;
77
78
/**
79
* List of reset ports.
80
*
81
* Reset ports are guaranteed to be numbered consecutively from 0.
82
*/
83
typedef
enum
dt_rv_timer_reset
{
84
kDtRvTimerResetRst
= 0,
/**< Reset port rst_ni */
85
kDtRvTimerResetCount = 1,
/**< \internal Number of reset ports */
86
}
dt_rv_timer_reset_t
;
87
88
/**
89
* List of supported hardware features.
90
*/
91
#define OPENTITAN_RV_TIMER_HAS_RISCV_CSRS_INTEGRATION 1
92
#define OPENTITAN_RV_TIMER_HAS_ENABLE 1
93
#define OPENTITAN_RV_TIMER_HAS_DISABLE 1
94
#define OPENTITAN_RV_TIMER_HAS_INTERRUPT 1
95
#define OPENTITAN_RV_TIMER_HAS_CONFIG 1
96
#define OPENTITAN_RV_TIMER_HAS_COUNTER 1
97
#define OPENTITAN_RV_TIMER_HAS_COMPARE 1
98
99
100
101
/**
102
* Get the rv_timer instance from an instance ID
103
*
104
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
105
*
106
* @param inst_id Instance ID.
107
* @return A rv_timer instance.
108
*
109
* **Note:** This function only makes sense if the instance ID has device type rv_timer,
110
* otherwise the returned value is unspecified.
111
*/
112
dt_rv_timer_t
dt_rv_timer_from_instance_id
(
dt_instance_id_t
inst_id);
113
114
/**
115
* Get the instance ID of an instance.
116
*
117
* @param dt Instance of rv_timer.
118
* @return The instance ID of that instance.
119
*/
120
dt_instance_id_t
dt_rv_timer_instance_id
(
dt_rv_timer_t
dt);
121
122
/**
123
* Get the register base address of an instance.
124
*
125
* @param dt Instance of rv_timer.
126
* @param reg_block The register block requested.
127
* @return The register base address of the requested block.
128
*/
129
uint32_t
dt_rv_timer_reg_block
(
130
dt_rv_timer_t
dt,
131
dt_rv_timer_reg_block_t
reg_block);
132
133
/**
134
* Get the primary register base address of an instance.
135
*
136
* This is just a convenience function, equivalent to
137
* `dt_rv_timer_reg_block(dt, kDtRvTimerRegBlockCore)`
138
*
139
* @param dt Instance of rv_timer.
140
* @return The register base address of the primary register block.
141
*/
142
static
inline
uint32_t dt_rv_timer_primary_reg_block(
143
dt_rv_timer_t
dt) {
144
return
dt_rv_timer_reg_block
(dt, kDtRvTimerRegBlockCore);
145
}
146
147
/**
148
* Get the PLIC ID of a rv_timer IRQ for a given instance.
149
*
150
* If the instance is not connected to the PLIC, this function
151
* will return `kDtPlicIrqIdNone`.
152
*
153
* @param dt Instance of rv_timer.
154
* @param irq A rv_timer IRQ.
155
* @return The PLIC ID of the IRQ of this instance.
156
*/
157
dt_plic_irq_id_t
dt_rv_timer_irq_to_plic_id
(
158
dt_rv_timer_t
dt,
159
dt_rv_timer_irq_t
irq);
160
161
/**
162
* Convert a global IRQ ID to a local rv_timer IRQ type.
163
*
164
* @param dt Instance of rv_timer.
165
* @param irq A PLIC ID that belongs to this instance.
166
* @return The rv_timer IRQ, or `kDtRvTimerIrqCount`.
167
*
168
* **Note:** This function assumes that the PLIC ID belongs to the instance
169
* of rv_timer passed in parameter. In other words, it must be the case that
170
* `dt_rv_timer_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
171
* will return `kDtRvTimerIrqCount`.
172
*/
173
dt_rv_timer_irq_t
dt_rv_timer_irq_from_plic_id
(
174
dt_rv_timer_t
dt,
175
dt_plic_irq_id_t
irq);
176
177
178
/**
179
* Get the alert ID of a rv_timer alert for a given instance.
180
*
181
* **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
182
* instances where the instance is not connected, the return value is unspecified.
183
*
184
* @param dt Instance of rv_timer.
185
* @param alert A rv_timer alert.
186
* @return The Alert Handler alert ID of the alert of this instance.
187
*/
188
dt_alert_id_t
dt_rv_timer_alert_to_alert_id
(
189
dt_rv_timer_t
dt,
190
dt_rv_timer_alert_t
alert);
191
192
/**
193
* Convert a global alert ID to a local rv_timer alert type.
194
*
195
* @param dt Instance of rv_timer.
196
* @param alert A global alert ID that belongs to this instance.
197
* @return The rv_timer alert, or `kDtRvTimerAlertCount`.
198
*
199
* **Note:** This function assumes that the global alert ID belongs to the
200
* instance of rv_timer passed in parameter. In other words, it must be the case
201
* that `dt_rv_timer_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
202
* this function will return `kDtRvTimerAlertCount`.
203
*/
204
dt_rv_timer_alert_t
dt_rv_timer_alert_from_alert_id
(
205
dt_rv_timer_t
dt,
206
dt_alert_id_t
alert);
207
208
209
210
/**
211
* Get the clock signal connected to a clock port of an instance.
212
*
213
* @param dt Instance of rv_timer.
214
* @param clk Clock port.
215
* @return Clock signal.
216
*/
217
dt_clock_t
dt_rv_timer_clock
(
218
dt_rv_timer_t
dt,
219
dt_rv_timer_clock_t
clk);
220
221
/**
222
* Get the reset signal connected to a reset port of an instance.
223
*
224
* @param dt Instance of rv_timer.
225
* @param rst Reset port.
226
* @return Reset signal.
227
*/
228
dt_reset_t
dt_rv_timer_reset
(
229
dt_rv_timer_t
dt,
230
dt_rv_timer_reset_t
rst);
231
232
233
234
#ifdef __cplusplus
235
}
// extern "C"
236
#endif
// __cplusplus
237
238
#endif
// OPENTITAN_DT_RV_TIMER_H_
(earlgrey)
hw
top
dt
dt_rv_timer.h
Return to
OpenTitan Documentation