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
/**
11
* @file
12
* @brief Device Tables (DT) for IP rv_timer and top englishbreakfast.
13
*
14
* This file contains the type definitions and global functions of the rv_timer.
15
*/
16
17
#include "
dt_api.h
"
18
#include <stdint.h>
19
20
21
22
/**
23
* List of instances.
24
*/
25
typedef
enum
dt_rv_timer
{
26
kDtRvTimer
= 0,
/**< rv_timer */
27
kDtRvTimerFirst = 0,
/**< \internal First instance */
28
kDtRvTimerCount = 1,
/**< \internal Number of instances */
29
}
dt_rv_timer_t
;
30
31
/**
32
* List of register blocks.
33
*
34
* Register blocks are guaranteed to start at 0 and to be consecutively numbered.
35
*/
36
typedef
enum
dt_rv_timer_reg_block
{
37
kDtRvTimerRegBlockCore = 0,
/**< */
38
kDtRvTimerRegBlockCount = 1,
/**< \internal Number of register blocks */
39
}
dt_rv_timer_reg_block_t
;
40
41
/** Primary register block (associated with the "primary" set of registers that control the IP). */
42
static
const
dt_rv_timer_reg_block_t
kDtRvTimerRegBlockPrimary = kDtRvTimerRegBlockCore;
43
44
/**
45
* List of IRQs.
46
*
47
* IRQs are guaranteed to be numbered consecutively from 0.
48
*/
49
typedef
enum
dt_rv_timer_irq
{
50
kDtRvTimerIrqTimerExpiredHart0Timer0
= 0,
/**< raised if hart0's timer0 expired (mtimecmp >= mtime) */
51
kDtRvTimerIrqCount = 1,
/**< \internal Number of IRQs */
52
}
dt_rv_timer_irq_t
;
53
54
/**
55
* List of clock ports.
56
*
57
* Clock ports are guaranteed to be numbered consecutively from 0.
58
*/
59
typedef
enum
dt_rv_timer_clock
{
60
kDtRvTimerClockClk
= 0,
/**< Clock port clk_i */
61
kDtRvTimerClockCount = 1,
/**< \internal Number of clock ports */
62
}
dt_rv_timer_clock_t
;
63
64
/**
65
* List of reset ports.
66
*
67
* Reset ports are guaranteed to be numbered consecutively from 0.
68
*/
69
typedef
enum
dt_rv_timer_reset
{
70
kDtRvTimerResetRst
= 0,
/**< Reset port rst_ni */
71
kDtRvTimerResetCount = 1,
/**< \internal Number of reset ports */
72
}
dt_rv_timer_reset_t
;
73
74
/**
75
* List of supported hardware features.
76
*/
77
#define OPENTITAN_RV_TIMER_HAS_RISCV_CSRS_INTEGRATION 1
78
#define OPENTITAN_RV_TIMER_HAS_ENABLE 1
79
#define OPENTITAN_RV_TIMER_HAS_DISABLE 1
80
#define OPENTITAN_RV_TIMER_HAS_INTERRUPT 1
81
#define OPENTITAN_RV_TIMER_HAS_CONFIG 1
82
#define OPENTITAN_RV_TIMER_HAS_COUNTER 1
83
#define OPENTITAN_RV_TIMER_HAS_COMPARE 1
84
85
86
87
/**
88
* Get the rv_timer instance from an instance ID
89
*
90
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
91
*
92
* @param inst_id Instance ID.
93
* @return A rv_timer instance.
94
*
95
* **Note:** This function only makes sense if the instance ID has device type rv_timer,
96
* otherwise the returned value is unspecified.
97
*/
98
dt_rv_timer_t
dt_rv_timer_from_instance_id
(
dt_instance_id_t
inst_id);
99
100
/**
101
* Get the instance ID of an instance.
102
*
103
* @param dt Instance of rv_timer.
104
* @return The instance ID of that instance.
105
*/
106
dt_instance_id_t
dt_rv_timer_instance_id
(
dt_rv_timer_t
dt);
107
108
/**
109
* Get the register base address of an instance.
110
*
111
* @param dt Instance of rv_timer.
112
* @param reg_block The register block requested.
113
* @return The register base address of the requested block.
114
*/
115
uint32_t
dt_rv_timer_reg_block
(
116
dt_rv_timer_t
dt,
117
dt_rv_timer_reg_block_t
reg_block);
118
119
/**
120
* Get the primary register base address of an instance.
121
*
122
* This is just a convenience function, equivalent to
123
* `dt_rv_timer_reg_block(dt, kDtRvTimerRegBlockCore)`
124
*
125
* @param dt Instance of rv_timer.
126
* @return The register base address of the primary register block.
127
*/
128
static
inline
uint32_t dt_rv_timer_primary_reg_block(
129
dt_rv_timer_t
dt) {
130
return
dt_rv_timer_reg_block
(dt, kDtRvTimerRegBlockCore);
131
}
132
133
/**
134
* Get the PLIC ID of a rv_timer IRQ for a given instance.
135
*
136
* If the instance is not connected to the PLIC, this function
137
* will return `kDtPlicIrqIdNone`.
138
*
139
* @param dt Instance of rv_timer.
140
* @param irq A rv_timer IRQ.
141
* @return The PLIC ID of the IRQ of this instance.
142
*/
143
dt_plic_irq_id_t
dt_rv_timer_irq_to_plic_id
(
144
dt_rv_timer_t
dt,
145
dt_rv_timer_irq_t
irq);
146
147
/**
148
* Convert a global IRQ ID to a local rv_timer IRQ type.
149
*
150
* @param dt Instance of rv_timer.
151
* @param irq A PLIC ID that belongs to this instance.
152
* @return The rv_timer IRQ, or `kDtRvTimerIrqCount`.
153
*
154
* **Note:** This function assumes that the PLIC ID belongs to the instance
155
* of rv_timer passed in parameter. In other words, it must be the case that
156
* `dt_rv_timer_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
157
* will return `kDtRvTimerIrqCount`.
158
*/
159
dt_rv_timer_irq_t
dt_rv_timer_irq_from_plic_id
(
160
dt_rv_timer_t
dt,
161
dt_plic_irq_id_t
irq);
162
163
164
165
166
/**
167
* Get the clock signal connected to a clock port of an instance.
168
*
169
* @param dt Instance of rv_timer.
170
* @param clk Clock port.
171
* @return Clock signal.
172
*/
173
dt_clock_t
dt_rv_timer_clock
(
174
dt_rv_timer_t
dt,
175
dt_rv_timer_clock_t
clk);
176
177
/**
178
* Get the reset signal connected to a reset port of an instance.
179
*
180
* @param dt Instance of rv_timer.
181
* @param rst Reset port.
182
* @return Reset signal.
183
*/
184
dt_reset_t
dt_rv_timer_reset
(
185
dt_rv_timer_t
dt,
186
dt_rv_timer_reset_t
rst);
187
188
189
190
#endif
// OPENTITAN_DT_RV_TIMER_H_
(englishbreakfast)
hw
top
dt
dt_rv_timer.h
Return to
OpenTitan Documentation