Software APIs
dt_otbn.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_OTBN_H_
8
#define OPENTITAN_DT_OTBN_H_
9
10
#ifdef __cplusplus
11
extern
"C"
{
12
#endif
// __cplusplus
13
14
/**
15
* @file
16
* @brief Device Tables (DT) for IP otbn and top earlgrey.
17
*
18
* This file contains the type definitions and global functions of the otbn.
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_otbn
{
30
kDtOtbn
= 0,
/**< otbn */
31
kDtOtbnFirst = 0,
/**< \internal First instance */
32
kDtOtbnCount = 1,
/**< \internal Number of instances */
33
}
dt_otbn_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_otbn_reg_block
{
41
kDtOtbnRegBlockCore = 0,
/**< */
42
kDtOtbnRegBlockCount = 1,
/**< \internal Number of register blocks */
43
}
dt_otbn_reg_block_t
;
44
45
/** Primary register block (associated with the "primary" set of registers that control the IP). */
46
static
const
dt_otbn_reg_block_t
kDtOtbnRegBlockPrimary = kDtOtbnRegBlockCore;
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_otbn_memory
{
54
kDtOtbnMemoryCount = 0,
/**< \internal Number of memories */
55
}
dt_otbn_memory_t
;
56
57
/**
58
* List of IRQs.
59
*
60
* IRQs are guaranteed to be numbered consecutively from 0.
61
*/
62
typedef
enum
dt_otbn_irq
{
63
kDtOtbnIrqDone
= 0,
/**< OTBN has completed the operation. */
64
kDtOtbnIrqCount = 1,
/**< \internal Number of IRQs */
65
}
dt_otbn_irq_t
;
66
67
/**
68
* List of Alerts.
69
*
70
* Alerts are guaranteed to be numbered consecutively from 0.
71
*/
72
typedef
enum
dt_otbn_alert
{
73
kDtOtbnAlertFatal
= 0,
/**< A fatal error. Fatal alerts are non-recoverable and will be asserted until a hard reset. */
74
kDtOtbnAlertRecov
= 1,
/**< A recoverable error. Just sent once (as the processor stops). */
75
kDtOtbnAlertCount = 2,
/**< \internal Number of Alerts */
76
}
dt_otbn_alert_t
;
77
78
/**
79
* List of clock ports.
80
*
81
* Clock ports are guaranteed to be numbered consecutively from 0.
82
*/
83
typedef
enum
dt_otbn_clock
{
84
kDtOtbnClockClk
= 0,
/**< Clock port clk_i */
85
kDtOtbnClockEdn
= 1,
/**< Clock port clk_edn_i */
86
kDtOtbnClockOtp
= 2,
/**< Clock port clk_otp_i */
87
kDtOtbnClockCount = 3,
/**< \internal Number of clock ports */
88
}
dt_otbn_clock_t
;
89
90
/**
91
* List of reset ports.
92
*
93
* Reset ports are guaranteed to be numbered consecutively from 0.
94
*/
95
typedef
enum
dt_otbn_reset
{
96
kDtOtbnResetRst
= 0,
/**< Reset port rst_ni */
97
kDtOtbnResetEdn
= 1,
/**< Reset port rst_edn_ni */
98
kDtOtbnResetOtp
= 2,
/**< Reset port rst_otp_ni */
99
kDtOtbnResetCount = 3,
/**< \internal Number of reset ports */
100
}
dt_otbn_reset_t
;
101
102
/**
103
* List of supported hardware features.
104
*/
105
#define OPENTITAN_OTBN_HAS_MEM_SCRAMBLE 1
106
107
108
109
/**
110
* Get the otbn instance from an instance ID
111
*
112
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
113
*
114
* @param inst_id Instance ID.
115
* @return A otbn instance.
116
*
117
* **Note:** This function only makes sense if the instance ID has device type otbn,
118
* otherwise the returned value is unspecified.
119
*/
120
dt_otbn_t
dt_otbn_from_instance_id
(
dt_instance_id_t
inst_id);
121
122
/**
123
* Get the instance ID of an instance.
124
*
125
* @param dt Instance of otbn.
126
* @return The instance ID of that instance.
127
*/
128
dt_instance_id_t
dt_otbn_instance_id
(
dt_otbn_t
dt);
129
130
/**
131
* Get the register base address of an instance.
132
*
133
* @param dt Instance of otbn.
134
* @param reg_block The register block requested.
135
* @return The register base address of the requested block.
136
*/
137
uint32_t
dt_otbn_reg_block
(
138
dt_otbn_t
dt,
139
dt_otbn_reg_block_t
reg_block);
140
141
/**
142
* Get the primary register base address of an instance.
143
*
144
* This is just a convenience function, equivalent to
145
* `dt_otbn_reg_block(dt, kDtOtbnRegBlockCore)`
146
*
147
* @param dt Instance of otbn.
148
* @return The register base address of the primary register block.
149
*/
150
static
inline
uint32_t dt_otbn_primary_reg_block(
151
dt_otbn_t
dt) {
152
return
dt_otbn_reg_block
(dt, kDtOtbnRegBlockCore);
153
}
154
155
/**
156
* Get the base address of a memory.
157
*
158
* @param dt Instance of otbn.
159
* @param mem The memory requested.
160
* @return The base address of the requested memory.
161
*/
162
uint32_t
dt_otbn_memory_base
(
163
dt_otbn_t
dt,
164
dt_otbn_memory_t
mem);
165
166
/**
167
* Get the size of a memory.
168
*
169
* @param dt Instance of otbn.
170
* @param mem The memory requested.
171
* @return The size of the requested memory.
172
*/
173
uint32_t
dt_otbn_memory_size
(
174
dt_otbn_t
dt,
175
dt_otbn_memory_t
mem);
176
177
/**
178
* Get the PLIC ID of a otbn IRQ for a given instance.
179
*
180
* If the instance is not connected to the PLIC, this function
181
* will return `kDtPlicIrqIdNone`.
182
*
183
* @param dt Instance of otbn.
184
* @param irq A otbn IRQ.
185
* @return The PLIC ID of the IRQ of this instance.
186
*/
187
dt_plic_irq_id_t
dt_otbn_irq_to_plic_id
(
188
dt_otbn_t
dt,
189
dt_otbn_irq_t
irq);
190
191
/**
192
* Convert a global IRQ ID to a local otbn IRQ type.
193
*
194
* @param dt Instance of otbn.
195
* @param irq A PLIC ID that belongs to this instance.
196
* @return The otbn IRQ, or `kDtOtbnIrqCount`.
197
*
198
* **Note:** This function assumes that the PLIC ID belongs to the instance
199
* of otbn passed in parameter. In other words, it must be the case that
200
* `dt_otbn_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
201
* will return `kDtOtbnIrqCount`.
202
*/
203
dt_otbn_irq_t
dt_otbn_irq_from_plic_id
(
204
dt_otbn_t
dt,
205
dt_plic_irq_id_t
irq);
206
207
208
/**
209
* Get the alert ID of a otbn alert for a given instance.
210
*
211
* **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
212
* instances where the instance is not connected, the return value is unspecified.
213
*
214
* @param dt Instance of otbn.
215
* @param alert A otbn alert.
216
* @return The Alert Handler alert ID of the alert of this instance.
217
*/
218
dt_alert_id_t
dt_otbn_alert_to_alert_id
(
219
dt_otbn_t
dt,
220
dt_otbn_alert_t
alert);
221
222
/**
223
* Convert a global alert ID to a local otbn alert type.
224
*
225
* @param dt Instance of otbn.
226
* @param alert A global alert ID that belongs to this instance.
227
* @return The otbn alert, or `kDtOtbnAlertCount`.
228
*
229
* **Note:** This function assumes that the global alert ID belongs to the
230
* instance of otbn passed in parameter. In other words, it must be the case
231
* that `dt_otbn_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
232
* this function will return `kDtOtbnAlertCount`.
233
*/
234
dt_otbn_alert_t
dt_otbn_alert_from_alert_id
(
235
dt_otbn_t
dt,
236
dt_alert_id_t
alert);
237
238
239
240
/**
241
* Get the clock signal connected to a clock port of an instance.
242
*
243
* @param dt Instance of otbn.
244
* @param clk Clock port.
245
* @return Clock signal.
246
*/
247
dt_clock_t
dt_otbn_clock
(
248
dt_otbn_t
dt,
249
dt_otbn_clock_t
clk);
250
251
/**
252
* Get the reset signal connected to a reset port of an instance.
253
*
254
* @param dt Instance of otbn.
255
* @param rst Reset port.
256
* @return Reset signal.
257
*/
258
dt_reset_t
dt_otbn_reset
(
259
dt_otbn_t
dt,
260
dt_otbn_reset_t
rst);
261
262
263
264
#ifdef __cplusplus
265
}
// extern "C"
266
#endif
// __cplusplus
267
268
#endif
// OPENTITAN_DT_OTBN_H_
(earlgrey)
hw
top
dt
dt_otbn.h
Return to
OpenTitan Documentation