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