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 englishbreakfast.
17
*
18
* This file contains the type definitions and global functions of the rv_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_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 memories.
50
*
51
* Memories are guaranteed to start at 0 and to be consecutively numbered.
52
*/
53
typedef
enum
dt_rv_timer_memory
{
54
kDtRvTimerMemoryCount = 0,
/**< \internal Number of memories */
55
}
dt_rv_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_rv_timer_irq
{
63
kDtRvTimerIrqTimerExpiredHart0Timer0
= 0,
/**< raised if hart0's timer0 expired (mtimecmp >= mtime) */
64
kDtRvTimerIrqCount = 1,
/**< \internal Number of IRQs */
65
}
dt_rv_timer_irq_t
;
66
67
/**
68
* List of clock ports.
69
*
70
* Clock ports are guaranteed to be numbered consecutively from 0.
71
*/
72
typedef
enum
dt_rv_timer_clock
{
73
kDtRvTimerClockClk
= 0,
/**< Clock port clk_i */
74
kDtRvTimerClockCount = 1,
/**< \internal Number of clock ports */
75
}
dt_rv_timer_clock_t
;
76
77
/**
78
* List of reset ports.
79
*
80
* Reset ports are guaranteed to be numbered consecutively from 0.
81
*/
82
typedef
enum
dt_rv_timer_reset
{
83
kDtRvTimerResetRst
= 0,
/**< Reset port rst_ni */
84
kDtRvTimerResetCount = 1,
/**< \internal Number of reset ports */
85
}
dt_rv_timer_reset_t
;
86
87
/**
88
* List of supported hardware features.
89
*/
90
#define OPENTITAN_RV_TIMER_HAS_RISCV_CSRS_INTEGRATION 1
91
#define OPENTITAN_RV_TIMER_HAS_ENABLE 1
92
#define OPENTITAN_RV_TIMER_HAS_DISABLE 1
93
#define OPENTITAN_RV_TIMER_HAS_INTERRUPT 1
94
#define OPENTITAN_RV_TIMER_HAS_CONFIG 1
95
#define OPENTITAN_RV_TIMER_HAS_COUNTER 1
96
#define OPENTITAN_RV_TIMER_HAS_COMPARE 1
97
98
99
100
/**
101
* Get the rv_timer instance from an instance ID
102
*
103
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
104
*
105
* @param inst_id Instance ID.
106
* @return A rv_timer instance.
107
*
108
* **Note:** This function only makes sense if the instance ID has device type rv_timer,
109
* otherwise the returned value is unspecified.
110
*/
111
dt_rv_timer_t
dt_rv_timer_from_instance_id
(
dt_instance_id_t
inst_id);
112
113
/**
114
* Get the instance ID of an instance.
115
*
116
* @param dt Instance of rv_timer.
117
* @return The instance ID of that instance.
118
*/
119
dt_instance_id_t
dt_rv_timer_instance_id
(
dt_rv_timer_t
dt);
120
121
/**
122
* Get the register base address of an instance.
123
*
124
* @param dt Instance of rv_timer.
125
* @param reg_block The register block requested.
126
* @return The register base address of the requested block.
127
*/
128
uint32_t
dt_rv_timer_reg_block
(
129
dt_rv_timer_t
dt,
130
dt_rv_timer_reg_block_t
reg_block);
131
132
/**
133
* Get the primary register base address of an instance.
134
*
135
* This is just a convenience function, equivalent to
136
* `dt_rv_timer_reg_block(dt, kDtRvTimerRegBlockCore)`
137
*
138
* @param dt Instance of rv_timer.
139
* @return The register base address of the primary register block.
140
*/
141
static
inline
uint32_t dt_rv_timer_primary_reg_block(
142
dt_rv_timer_t
dt) {
143
return
dt_rv_timer_reg_block
(dt, kDtRvTimerRegBlockCore);
144
}
145
146
/**
147
* Get the base address of a memory.
148
*
149
* @param dt Instance of rv_timer.
150
* @param mem The memory requested.
151
* @return The base address of the requested memory.
152
*/
153
uint32_t
dt_rv_timer_memory_base
(
154
dt_rv_timer_t
dt,
155
dt_rv_timer_memory_t
mem);
156
157
/**
158
* Get the size of a memory.
159
*
160
* @param dt Instance of rv_timer.
161
* @param mem The memory requested.
162
* @return The size of the requested memory.
163
*/
164
uint32_t
dt_rv_timer_memory_size
(
165
dt_rv_timer_t
dt,
166
dt_rv_timer_memory_t
mem);
167
168
/**
169
* Get the PLIC ID of a rv_timer IRQ for a given instance.
170
*
171
* If the instance is not connected to the PLIC, this function
172
* will return `kDtPlicIrqIdNone`.
173
*
174
* @param dt Instance of rv_timer.
175
* @param irq A rv_timer IRQ.
176
* @return The PLIC ID of the IRQ of this instance.
177
*/
178
dt_plic_irq_id_t
dt_rv_timer_irq_to_plic_id
(
179
dt_rv_timer_t
dt,
180
dt_rv_timer_irq_t
irq);
181
182
/**
183
* Convert a global IRQ ID to a local rv_timer IRQ type.
184
*
185
* @param dt Instance of rv_timer.
186
* @param irq A PLIC ID that belongs to this instance.
187
* @return The rv_timer IRQ, or `kDtRvTimerIrqCount`.
188
*
189
* **Note:** This function assumes that the PLIC ID belongs to the instance
190
* of rv_timer passed in parameter. In other words, it must be the case that
191
* `dt_rv_timer_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
192
* will return `kDtRvTimerIrqCount`.
193
*/
194
dt_rv_timer_irq_t
dt_rv_timer_irq_from_plic_id
(
195
dt_rv_timer_t
dt,
196
dt_plic_irq_id_t
irq);
197
198
199
200
201
/**
202
* Get the clock signal connected to a clock port of an instance.
203
*
204
* @param dt Instance of rv_timer.
205
* @param clk Clock port.
206
* @return Clock signal.
207
*/
208
dt_clock_t
dt_rv_timer_clock
(
209
dt_rv_timer_t
dt,
210
dt_rv_timer_clock_t
clk);
211
212
/**
213
* Get the reset signal connected to a reset port of an instance.
214
*
215
* @param dt Instance of rv_timer.
216
* @param rst Reset port.
217
* @return Reset signal.
218
*/
219
dt_reset_t
dt_rv_timer_reset
(
220
dt_rv_timer_t
dt,
221
dt_rv_timer_reset_t
rst);
222
223
224
225
#ifdef __cplusplus
226
}
// extern "C"
227
#endif
// __cplusplus
228
229
#endif
// OPENTITAN_DT_RV_TIMER_H_
(englishbreakfast)
hw
top
dt
dt_rv_timer.h
Return to
OpenTitan Documentation