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