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