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