Software APIs
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
6
7#ifndef OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_OTP_CTRL_AUTOGEN_H_
8#define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_OTP_CTRL_AUTOGEN_H_
9
10// THIS FILE HAS BEEN GENERATED, DO NOT EDIT MANUALLY. COMMAND:
11// util/autogen_dif.py -i
12// hw/top_earlgrey/ip_autogen/otp_ctrl/data/otp_ctrl.hjson -o
13// bazel-out/k8-fastbuild/bin/sw/device/lib/dif/autogen
14
15
16/**
17 * @file
18 * @brief <a href="/book/hw/ip/otp_ctrl/">OTP_CTRL</a> Device Interface Functions
19 */
20
21#include <stdbool.h>
22#include <stdint.h>
23
27#include "hw/top/dt/otp_ctrl.h" // Generated.
28
29#ifdef __cplusplus
30extern "C" {
31#endif // __cplusplus
32
33/**
34 * A handle to otp_ctrl.
35 *
36 * This type should be treated as opaque by users.
37 */
38typedef struct dif_otp_ctrl {
39 /**
40 * The base address for the otp_ctrl hardware registers.
41 */
43 /**
44 * The instance, set to `kDtOtpCtrlCount` if not initialized
45 * through `dif_otp_ctrl_init_from_dt`.
46 */
49
50/**
51 * Creates a new handle for a(n) otp_ctrl peripheral.
52 *
53 * This function does not actuate the hardware.
54 *
55 * @param base_addr The MMIO base address of the otp_ctrl peripheral.
56 * @param[out] otp_ctrl Out param for the initialized handle.
57 * @return The result of the operation.
58 *
59 * DEPRECATED This function exists solely for the transition to
60 * dt-based DIFs and will be removed in the future.
61 */
64 mmio_region_t base_addr,
65 dif_otp_ctrl_t *otp_ctrl);
66
67/**
68 * Creates a new handle for a(n) otp_ctrl peripheral.
69 *
70 * This function does not actuate the hardware.
71 *
72 * @param dt The devicetable description of the device.
73 * @param[out] otp_ctrl Out param for the initialized handle.
74 * @return The result of the operation.
75 */
79 dif_otp_ctrl_t *otp_ctrl);
80
81/**
82 * Get the DT handle from this DIF.
83 *
84 * If this DIF was initialized by `dif_otp_ctrl_init_from_dt(dt, ..)`
85 * then this function will return `dt`. Otherwise it will return an error.
86 *
87 * @param otp_ctrl A otp_ctrl handle.
88 * @param[out] dt DT handle.
89 * @return `kDifBadArg` if the DIF has no DT information, `kDifOk` otherwise.
90 */
93 const dif_otp_ctrl_t *otp_ctrl,
94 dt_otp_ctrl_t *dt);
95
96 /**
97 * A otp_ctrl alert type.
98 */
99 typedef enum dif_otp_ctrl_alert {
100 /**
101 * This alert triggers if hardware detects an uncorrectable error during an OTP transaction, for example an uncorrectable ECC error in the OTP array.
102 */
104 /**
105 * This alert triggers if any of the background checks fails. This includes the digest checks and concurrent ECC checks in the buffer registers.
106 */
108 /**
109 * This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected.
110 */
112 /**
113 * Fatal alert triggered inside the OTP primitive, including fatal TL-UL bus integrity faults of the test interface.
114 */
116 /**
117 * Recoverable alert triggered inside the OTP primitive.
118 */
121
122 /**
123 * Forces a particular alert, causing it to be escalated as if the hardware
124 * had raised it.
125 *
126 * @param otp_ctrl A otp_ctrl handle.
127 * @param alert The alert to force.
128 * @return The result of the operation.
129 */
132 const dif_otp_ctrl_t *otp_ctrl,
134
135 // DEPRECATED This typedef exists solely for the transition to
136 // dt-based interrupt numbers and will be removed in the future.
137 typedef dt_otp_ctrl_irq_t dif_otp_ctrl_irq_t;
138
139 /**
140 * A otp_ctrl interrupt request type.
141 *
142 * DEPRECATED Use `dt_otp_ctrl_irq_t` instead.
143 * This enumeration exists solely for the transition to
144 * dt-based interrupt numbers and will be removed in the future.
145 *
146 * The following are defines to keep the types consistent with DT.
147 */
148 /**
149 * A direct access command or digest calculation operation has completed.
150 */
151#define kDifOtpCtrlIrqOtpOperationDone kDtOtpCtrlIrqOtpOperationDone
152 /**
153 * An error has occurred in the OTP controller. Check the !!ERR_CODE register to get more information.
154 */
155#define kDifOtpCtrlIrqOtpError kDtOtpCtrlIrqOtpError
156
157 /**
158 * A snapshot of the state of the interrupts for this IP.
159 *
160 * This is an opaque type, to be used with the `dif_otp_ctrl_irq_get_state()`
161 * and `dif_otp_ctrl_irq_acknowledge_state()` functions.
162 */
164
165 /**
166 * Returns the type of a given interrupt (i.e., event or status) for this IP.
167 *
168 * @param otp_ctrl A otp_ctrl handle.
169 * @param irq An interrupt request.
170 * @param[out] type Out-param for the interrupt type.
171 * @return The result of the operation.
172 */
175 const dif_otp_ctrl_t *otp_ctrl,
176 dif_otp_ctrl_irq_t,
177 dif_irq_type_t *type);
178
179 /**
180 * Returns the state of all interrupts (i.e., pending or not) for this IP.
181 *
182 * @param otp_ctrl A otp_ctrl handle.
183 * @param[out] snapshot Out-param for interrupt state snapshot.
184 * @return The result of the operation.
185 */
188 const dif_otp_ctrl_t *otp_ctrl,
190
191 /**
192 * Returns whether a particular interrupt is currently pending.
193 *
194 * @param otp_ctrl A otp_ctrl handle.
195 * @param irq An interrupt request.
196 * @param[out] is_pending Out-param for whether the interrupt is pending.
197 * @return The result of the operation.
198 */
201 const dif_otp_ctrl_t *otp_ctrl,
202 dif_otp_ctrl_irq_t,
203 bool *is_pending);
204
205 /**
206 * Acknowledges all interrupts that were pending at the time of the state
207 * snapshot.
208 *
209 * @param otp_ctrl A otp_ctrl handle.
210 * @param snapshot Interrupt state snapshot.
211 * @return The result of the operation.
212 */
215 const dif_otp_ctrl_t *otp_ctrl,
217
218 /**
219 * Acknowledges all interrupts, indicating to the hardware that all
220 * interrupts have been successfully serviced.
221 *
222 * @param otp_ctrl A otp_ctrl handle.
223 * @return The result of the operation.
224 */
227 const dif_otp_ctrl_t *otp_ctrl
228 );
229
230 /**
231 * Acknowledges a particular interrupt, indicating to the hardware that it has
232 * been successfully serviced.
233 *
234 * @param otp_ctrl A otp_ctrl handle.
235 * @param irq An interrupt request.
236 * @return The result of the operation.
237 */
240 const dif_otp_ctrl_t *otp_ctrl,
241 dif_otp_ctrl_irq_t);
242
243 /**
244 * Forces a particular interrupt, causing it to be serviced as if hardware had
245 * asserted it.
246 *
247 * @param otp_ctrl A otp_ctrl handle.
248 * @param irq An interrupt request.
249 * @param val Value to be set.
250 * @return The result of the operation.
251 */
254 const dif_otp_ctrl_t *otp_ctrl,
255 dif_otp_ctrl_irq_t,
256 const bool val);
257
258 /**
259 * A snapshot of the enablement state of the interrupts for this IP.
260 *
261 * This is an opaque type, to be used with the
262 * `dif_otp_ctrl_irq_disable_all()` and `dif_otp_ctrl_irq_restore_all()`
263 * functions.
264 */
266
267 /**
268 * Checks whether a particular interrupt is currently enabled or disabled.
269 *
270 * @param otp_ctrl A otp_ctrl handle.
271 * @param irq An interrupt request.
272 * @param[out] state Out-param toggle state of the interrupt.
273 * @return The result of the operation.
274 */
277 const dif_otp_ctrl_t *otp_ctrl,
278 dif_otp_ctrl_irq_t,
279 dif_toggle_t *state);
280
281 /**
282 * Sets whether a particular interrupt is currently enabled or disabled.
283 *
284 * @param otp_ctrl A otp_ctrl handle.
285 * @param irq An interrupt request.
286 * @param state The new toggle state for the interrupt.
287 * @return The result of the operation.
288 */
291 const dif_otp_ctrl_t *otp_ctrl,
292 dif_otp_ctrl_irq_t,
293 dif_toggle_t state);
294
295 /**
296 * Disables all interrupts, optionally snapshotting all enable states for later
297 * restoration.
298 *
299 * @param otp_ctrl A otp_ctrl handle.
300 * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
301 * @return The result of the operation.
302 */
305 const dif_otp_ctrl_t *otp_ctrl,
307
308 /**
309 * Restores interrupts from the given (enable) snapshot.
310 *
311 * @param otp_ctrl A otp_ctrl handle.
312 * @param snapshot A snapshot to restore from.
313 * @return The result of the operation.
314 */
317 const dif_otp_ctrl_t *otp_ctrl,
318 const dif_otp_ctrl_irq_enable_snapshot_t *snapshot);
319
320
321#ifdef __cplusplus
322} // extern "C"
323#endif // __cplusplus
324
325#endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_OTP_CTRL_AUTOGEN_H_