Software APIs
dt_edn.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_EDN_H_
8
#define OPENTITAN_DT_EDN_H_
9
10
#ifdef __cplusplus
11
extern
"C"
{
12
#endif
// __cplusplus
13
14
/**
15
* @file
16
* @brief Device Tables (DT) for IP edn and top earlgrey.
17
*
18
* This file contains the type definitions and global functions of the edn.
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_edn
{
30
kDtEdn0
= 0,
/**< edn0 */
31
kDtEdn1
= 1,
/**< edn1 */
32
kDtEdnFirst = 0,
/**< \internal First instance */
33
kDtEdnCount = 2,
/**< \internal Number of instances */
34
}
dt_edn_t
;
35
36
/**
37
* List of register blocks.
38
*
39
* Register blocks are guaranteed to start at 0 and to be consecutively numbered.
40
*/
41
typedef
enum
dt_edn_reg_block
{
42
kDtEdnRegBlockCore = 0,
/**< */
43
kDtEdnRegBlockCount = 1,
/**< \internal Number of register blocks */
44
}
dt_edn_reg_block_t
;
45
46
/** Primary register block (associated with the "primary" set of registers that control the IP). */
47
static
const
dt_edn_reg_block_t
kDtEdnRegBlockPrimary = kDtEdnRegBlockCore;
48
49
/**
50
* List of memories.
51
*
52
* Memories are guaranteed to start at 0 and to be consecutively numbered.
53
*/
54
typedef
enum
dt_edn_memory
{
55
kDtEdnMemoryCount = 0,
/**< \internal Number of memories */
56
}
dt_edn_memory_t
;
57
58
/**
59
* List of IRQs.
60
*
61
* IRQs are guaranteed to be numbered consecutively from 0.
62
*/
63
typedef
enum
dt_edn_irq
{
64
kDtEdnIrqEdnCmdReqDone
= 0,
/**< Asserted when a software CSRNG request has completed. */
65
kDtEdnIrqEdnFatalErr
= 1,
/**< Asserted when a FIFO error occurs. */
66
kDtEdnIrqCount = 2,
/**< \internal Number of IRQs */
67
}
dt_edn_irq_t
;
68
69
/**
70
* List of Alerts.
71
*
72
* Alerts are guaranteed to be numbered consecutively from 0.
73
*/
74
typedef
enum
dt_edn_alert
{
75
kDtEdnAlertRecovAlert
= 0,
/**< This alert is triggered when entropy bus data matches on consecutive clock cycles. */
76
kDtEdnAlertFatalAlert
= 1,
/**< This alert triggers (i) if an illegal state machine state is reached, or
77
(ii) if a fatal integrity failure is detected on the TL-UL bus. */
78
kDtEdnAlertCount = 2,
/**< \internal Number of Alerts */
79
}
dt_edn_alert_t
;
80
81
/**
82
* List of clock ports.
83
*
84
* Clock ports are guaranteed to be numbered consecutively from 0.
85
*/
86
typedef
enum
dt_edn_clock
{
87
kDtEdnClockClk
= 0,
/**< Clock port clk_i */
88
kDtEdnClockCount = 1,
/**< \internal Number of clock ports */
89
}
dt_edn_clock_t
;
90
91
/**
92
* List of reset ports.
93
*
94
* Reset ports are guaranteed to be numbered consecutively from 0.
95
*/
96
typedef
enum
dt_edn_reset
{
97
kDtEdnResetRst
= 0,
/**< Reset port rst_ni */
98
kDtEdnResetCount = 1,
/**< \internal Number of reset ports */
99
}
dt_edn_reset_t
;
100
101
/**
102
* List of supported hardware features.
103
*/
104
#define OPENTITAN_EDN_HAS_MODE_BOOT 1
105
#define OPENTITAN_EDN_HAS_MODE_AUTO 1
106
#define OPENTITAN_EDN_HAS_MODE_SW 1
107
#define OPENTITAN_EDN_HAS_TRACK_SEED_COMPLIANCE 1
108
#define OPENTITAN_EDN_HAS_BUS_CMP_ALERT 1
109
110
111
112
/**
113
* Get the edn instance from an instance ID
114
*
115
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
116
*
117
* @param inst_id Instance ID.
118
* @return A edn instance.
119
*
120
* **Note:** This function only makes sense if the instance ID has device type edn,
121
* otherwise the returned value is unspecified.
122
*/
123
dt_edn_t
dt_edn_from_instance_id
(
dt_instance_id_t
inst_id);
124
125
/**
126
* Get the instance ID of an instance.
127
*
128
* @param dt Instance of edn.
129
* @return The instance ID of that instance.
130
*/
131
dt_instance_id_t
dt_edn_instance_id
(
dt_edn_t
dt);
132
133
/**
134
* Get the register base address of an instance.
135
*
136
* @param dt Instance of edn.
137
* @param reg_block The register block requested.
138
* @return The register base address of the requested block.
139
*/
140
uint32_t
dt_edn_reg_block
(
141
dt_edn_t
dt,
142
dt_edn_reg_block_t
reg_block);
143
144
/**
145
* Get the primary register base address of an instance.
146
*
147
* This is just a convenience function, equivalent to
148
* `dt_edn_reg_block(dt, kDtEdnRegBlockCore)`
149
*
150
* @param dt Instance of edn.
151
* @return The register base address of the primary register block.
152
*/
153
static
inline
uint32_t dt_edn_primary_reg_block(
154
dt_edn_t
dt) {
155
return
dt_edn_reg_block
(dt, kDtEdnRegBlockCore);
156
}
157
158
/**
159
* Get the base address of a memory.
160
*
161
* @param dt Instance of edn.
162
* @param mem The memory requested.
163
* @return The base address of the requested memory.
164
*/
165
uint32_t
dt_edn_memory_base
(
166
dt_edn_t
dt,
167
dt_edn_memory_t
mem);
168
169
/**
170
* Get the size of a memory.
171
*
172
* @param dt Instance of edn.
173
* @param mem The memory requested.
174
* @return The size of the requested memory.
175
*/
176
uint32_t
dt_edn_memory_size
(
177
dt_edn_t
dt,
178
dt_edn_memory_t
mem);
179
180
/**
181
* Get the PLIC ID of a edn IRQ for a given instance.
182
*
183
* If the instance is not connected to the PLIC, this function
184
* will return `kDtPlicIrqIdNone`.
185
*
186
* @param dt Instance of edn.
187
* @param irq A edn IRQ.
188
* @return The PLIC ID of the IRQ of this instance.
189
*/
190
dt_plic_irq_id_t
dt_edn_irq_to_plic_id
(
191
dt_edn_t
dt,
192
dt_edn_irq_t
irq);
193
194
/**
195
* Convert a global IRQ ID to a local edn IRQ type.
196
*
197
* @param dt Instance of edn.
198
* @param irq A PLIC ID that belongs to this instance.
199
* @return The edn IRQ, or `kDtEdnIrqCount`.
200
*
201
* **Note:** This function assumes that the PLIC ID belongs to the instance
202
* of edn passed in parameter. In other words, it must be the case that
203
* `dt_edn_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
204
* will return `kDtEdnIrqCount`.
205
*/
206
dt_edn_irq_t
dt_edn_irq_from_plic_id
(
207
dt_edn_t
dt,
208
dt_plic_irq_id_t
irq);
209
210
211
/**
212
* Get the alert ID of a edn alert for a given instance.
213
*
214
* **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
215
* instances where the instance is not connected, the return value is unspecified.
216
*
217
* @param dt Instance of edn.
218
* @param alert A edn alert.
219
* @return The Alert Handler alert ID of the alert of this instance.
220
*/
221
dt_alert_id_t
dt_edn_alert_to_alert_id
(
222
dt_edn_t
dt,
223
dt_edn_alert_t
alert);
224
225
/**
226
* Convert a global alert ID to a local edn alert type.
227
*
228
* @param dt Instance of edn.
229
* @param alert A global alert ID that belongs to this instance.
230
* @return The edn alert, or `kDtEdnAlertCount`.
231
*
232
* **Note:** This function assumes that the global alert ID belongs to the
233
* instance of edn passed in parameter. In other words, it must be the case
234
* that `dt_edn_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
235
* this function will return `kDtEdnAlertCount`.
236
*/
237
dt_edn_alert_t
dt_edn_alert_from_alert_id
(
238
dt_edn_t
dt,
239
dt_alert_id_t
alert);
240
241
242
243
/**
244
* Get the clock signal connected to a clock port of an instance.
245
*
246
* @param dt Instance of edn.
247
* @param clk Clock port.
248
* @return Clock signal.
249
*/
250
dt_clock_t
dt_edn_clock
(
251
dt_edn_t
dt,
252
dt_edn_clock_t
clk);
253
254
/**
255
* Get the reset signal connected to a reset port of an instance.
256
*
257
* @param dt Instance of edn.
258
* @param rst Reset port.
259
* @return Reset signal.
260
*/
261
dt_reset_t
dt_edn_reset
(
262
dt_edn_t
dt,
263
dt_edn_reset_t
rst);
264
265
266
267
#ifdef __cplusplus
268
}
// extern "C"
269
#endif
// __cplusplus
270
271
#endif
// OPENTITAN_DT_EDN_H_
(earlgrey)
hw
top
dt
dt_edn.h
Return to
OpenTitan Documentation