Software APIs
sw
device
lib
dif
autogen
dif_otp_ctrl_autogen.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
#ifndef OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_OTP_CTRL_AUTOGEN_H_
6
#define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_OTP_CTRL_AUTOGEN_H_
7
8
// THIS FILE HAS BEEN GENERATED, DO NOT EDIT MANUALLY. COMMAND:
9
// util/make_new_dif.py --mode=regen --only=autogen
10
11
/**
12
* @file
13
* @brief <a href="/book/hw/ip/otp_ctrl/">OTP_CTRL</a> Device Interface
14
* Functions
15
*/
16
17
#include <
stdbool.h
>
18
#include <
stdint.h
>
19
20
#include "
sw/device/lib/base/macros.h
"
21
#include "
sw/device/lib/base/mmio.h
"
22
#include "
sw/device/lib/dif/dif_base.h
"
23
24
#ifdef __cplusplus
25
extern
"C"
{
26
#endif
// __cplusplus
27
28
/**
29
* A handle to otp_ctrl.
30
*
31
* This type should be treated as opaque by users.
32
*/
33
typedef
struct
dif_otp_ctrl
{
34
/**
35
* The base address for the otp_ctrl hardware registers.
36
*/
37
mmio_region_t
base_addr
;
38
}
dif_otp_ctrl_t
;
39
40
/**
41
* Creates a new handle for a(n) otp_ctrl peripheral.
42
*
43
* This function does not actuate the hardware.
44
*
45
* @param base_addr The MMIO base address of the otp_ctrl peripheral.
46
* @param[out] otp_ctrl Out param for the initialized handle.
47
* @return The result of the operation.
48
*/
49
OT_WARN_UNUSED_RESULT
50
dif_result_t
dif_otp_ctrl_init
(
mmio_region_t
base_addr,
51
dif_otp_ctrl_t
*otp_ctrl);
52
53
/**
54
* A otp_ctrl alert type.
55
*/
56
typedef
enum
dif_otp_ctrl_alert
{
57
/**
58
* This alert triggers if hardware detects an uncorrectable error during an
59
* OTP transaction, for example an uncorrectable ECC error in the OTP array.
60
*/
61
kDifOtpCtrlAlertFatalMacroError
= 0,
62
/**
63
* This alert triggers if any of the background checks fails. This includes
64
* the digest checks and concurrent ECC checks in the buffer registers.
65
*/
66
kDifOtpCtrlAlertFatalCheckError
= 1,
67
/**
68
* This fatal alert is triggered when a fatal TL-UL bus integrity fault is
69
* detected.
70
*/
71
kDifOtpCtrlAlertFatalBusIntegError
= 2,
72
/**
73
* Fatal alert triggered inside the OTP primitive, including fatal TL-UL bus
74
* integrity faults of the test interface.
75
*/
76
kDifOtpCtrlAlertFatalPrimOtpAlert
= 3,
77
/**
78
* Recoverable alert triggered inside the OTP primitive.
79
*/
80
kDifOtpCtrlAlertRecovPrimOtpAlert
= 4,
81
}
dif_otp_ctrl_alert_t
;
82
83
/**
84
* Forces a particular alert, causing it to be escalated as if the hardware
85
* had raised it.
86
*
87
* @param otp_ctrl A otp_ctrl handle.
88
* @param alert The alert to force.
89
* @return The result of the operation.
90
*/
91
OT_WARN_UNUSED_RESULT
92
dif_result_t
dif_otp_ctrl_alert_force
(
const
dif_otp_ctrl_t
*otp_ctrl,
93
dif_otp_ctrl_alert_t
alert);
94
95
/**
96
* A otp_ctrl interrupt request type.
97
*/
98
typedef
enum
dif_otp_ctrl_irq
{
99
/**
100
* A direct access command or digest calculation operation has completed.
101
*/
102
kDifOtpCtrlIrqOtpOperationDone
= 0,
103
/**
104
* An error has occurred in the OTP controller. Check the !!ERR_CODE register
105
* to get more information.
106
*/
107
kDifOtpCtrlIrqOtpError
= 1,
108
}
dif_otp_ctrl_irq_t
;
109
110
/**
111
* A snapshot of the state of the interrupts for this IP.
112
*
113
* This is an opaque type, to be used with the `dif_otp_ctrl_irq_get_state()`
114
* and `dif_otp_ctrl_irq_acknowledge_state()` functions.
115
*/
116
typedef
uint32_t
dif_otp_ctrl_irq_state_snapshot_t
;
117
118
/**
119
* Returns the type of a given interrupt (i.e., event or status) for this IP.
120
*
121
* @param otp_ctrl A otp_ctrl handle.
122
* @param irq An interrupt request.
123
* @param[out] type Out-param for the interrupt type.
124
* @return The result of the operation.
125
*/
126
OT_WARN_UNUSED_RESULT
127
dif_result_t
dif_otp_ctrl_irq_get_type
(
const
dif_otp_ctrl_t
*otp_ctrl,
128
dif_otp_ctrl_irq_t
irq,
129
dif_irq_type_t
*type);
130
131
/**
132
* Returns the state of all interrupts (i.e., pending or not) for this IP.
133
*
134
* @param otp_ctrl A otp_ctrl handle.
135
* @param[out] snapshot Out-param for interrupt state snapshot.
136
* @return The result of the operation.
137
*/
138
OT_WARN_UNUSED_RESULT
139
dif_result_t
dif_otp_ctrl_irq_get_state
(
140
const
dif_otp_ctrl_t
*otp_ctrl,
141
dif_otp_ctrl_irq_state_snapshot_t
*snapshot);
142
143
/**
144
* Returns whether a particular interrupt is currently pending.
145
*
146
* @param otp_ctrl A otp_ctrl handle.
147
* @param irq An interrupt request.
148
* @param[out] is_pending Out-param for whether the interrupt is pending.
149
* @return The result of the operation.
150
*/
151
OT_WARN_UNUSED_RESULT
152
dif_result_t
dif_otp_ctrl_irq_is_pending
(
const
dif_otp_ctrl_t
*otp_ctrl,
153
dif_otp_ctrl_irq_t
irq,
154
bool
*is_pending);
155
156
/**
157
* Acknowledges all interrupts that were pending at the time of the state
158
* snapshot.
159
*
160
* @param otp_ctrl A otp_ctrl handle.
161
* @param snapshot Interrupt state snapshot.
162
* @return The result of the operation.
163
*/
164
OT_WARN_UNUSED_RESULT
165
dif_result_t
dif_otp_ctrl_irq_acknowledge_state
(
166
const
dif_otp_ctrl_t
*otp_ctrl,
dif_otp_ctrl_irq_state_snapshot_t
snapshot);
167
168
/**
169
* Acknowledges all interrupts, indicating to the hardware that all
170
* interrupts have been successfully serviced.
171
*
172
* @param otp_ctrl A otp_ctrl handle.
173
* @return The result of the operation.
174
*/
175
OT_WARN_UNUSED_RESULT
176
dif_result_t
dif_otp_ctrl_irq_acknowledge_all
(
const
dif_otp_ctrl_t
*otp_ctrl);
177
178
/**
179
* Acknowledges a particular interrupt, indicating to the hardware that it has
180
* been successfully serviced.
181
*
182
* @param otp_ctrl A otp_ctrl handle.
183
* @param irq An interrupt request.
184
* @return The result of the operation.
185
*/
186
OT_WARN_UNUSED_RESULT
187
dif_result_t
dif_otp_ctrl_irq_acknowledge
(
const
dif_otp_ctrl_t
*otp_ctrl,
188
dif_otp_ctrl_irq_t
irq);
189
190
/**
191
* Forces a particular interrupt, causing it to be serviced as if hardware had
192
* asserted it.
193
*
194
* @param otp_ctrl A otp_ctrl handle.
195
* @param irq An interrupt request.
196
* @param val Value to be set.
197
* @return The result of the operation.
198
*/
199
OT_WARN_UNUSED_RESULT
200
dif_result_t
dif_otp_ctrl_irq_force
(
const
dif_otp_ctrl_t
*otp_ctrl,
201
dif_otp_ctrl_irq_t
irq,
const
bool
val);
202
203
/**
204
* A snapshot of the enablement state of the interrupts for this IP.
205
*
206
* This is an opaque type, to be used with the
207
* `dif_otp_ctrl_irq_disable_all()` and `dif_otp_ctrl_irq_restore_all()`
208
* functions.
209
*/
210
typedef
uint32_t
dif_otp_ctrl_irq_enable_snapshot_t
;
211
212
/**
213
* Checks whether a particular interrupt is currently enabled or disabled.
214
*
215
* @param otp_ctrl A otp_ctrl handle.
216
* @param irq An interrupt request.
217
* @param[out] state Out-param toggle state of the interrupt.
218
* @return The result of the operation.
219
*/
220
OT_WARN_UNUSED_RESULT
221
dif_result_t
dif_otp_ctrl_irq_get_enabled
(
const
dif_otp_ctrl_t
*otp_ctrl,
222
dif_otp_ctrl_irq_t
irq,
223
dif_toggle_t
*state);
224
225
/**
226
* Sets whether a particular interrupt is currently enabled or disabled.
227
*
228
* @param otp_ctrl A otp_ctrl handle.
229
* @param irq An interrupt request.
230
* @param state The new toggle state for the interrupt.
231
* @return The result of the operation.
232
*/
233
OT_WARN_UNUSED_RESULT
234
dif_result_t
dif_otp_ctrl_irq_set_enabled
(
const
dif_otp_ctrl_t
*otp_ctrl,
235
dif_otp_ctrl_irq_t
irq,
236
dif_toggle_t
state);
237
238
/**
239
* Disables all interrupts, optionally snapshotting all enable states for later
240
* restoration.
241
*
242
* @param otp_ctrl A otp_ctrl handle.
243
* @param[out] snapshot Out-param for the snapshot; may be `NULL`.
244
* @return The result of the operation.
245
*/
246
OT_WARN_UNUSED_RESULT
247
dif_result_t
dif_otp_ctrl_irq_disable_all
(
248
const
dif_otp_ctrl_t
*otp_ctrl,
249
dif_otp_ctrl_irq_enable_snapshot_t
*snapshot);
250
251
/**
252
* Restores interrupts from the given (enable) snapshot.
253
*
254
* @param otp_ctrl A otp_ctrl handle.
255
* @param snapshot A snapshot to restore from.
256
* @return The result of the operation.
257
*/
258
OT_WARN_UNUSED_RESULT
259
dif_result_t
dif_otp_ctrl_irq_restore_all
(
260
const
dif_otp_ctrl_t
*otp_ctrl,
261
const
dif_otp_ctrl_irq_enable_snapshot_t
*snapshot);
262
263
#ifdef __cplusplus
264
}
// extern "C"
265
#endif
// __cplusplus
266
267
#endif
// OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_OTP_CTRL_AUTOGEN_H_
Return to
OpenTitan Documentation