Software APIs
dif_rram_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_RRAM_CTRL_AUTOGEN_H_
8#define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_RRAM_CTRL_AUTOGEN_H_
9
10// THIS FILE HAS BEEN GENERATED, DO NOT EDIT MANUALLY. COMMAND:
11// util/autogen_dif.py -i hw/ip/rram_ctrl/data/rram_ctrl.hjson -o
12// bazel-out/k8-fastbuild/bin/sw/device/lib/dif/autogen
13
14
15/**
16 * @file
17 * @brief <a href="/book/hw/ip/rram_ctrl/">RRAM_CTRL</a> Device Interface Functions
18 */
19
20#include <stdbool.h>
21#include <stdint.h>
22
26#include "hw/top/dt/rram_ctrl.h" // Generated.
27
28#ifdef __cplusplus
29extern "C" {
30#endif // __cplusplus
31
32/**
33 * A handle to rram_ctrl.
34 *
35 * This type should be treated as opaque by users.
36 */
37typedef struct dif_rram_ctrl {
38 /**
39 * The base address for the rram_ctrl hardware registers.
40 */
42 /**
43 * The instance, set to `kDtRramCtrlCount` if not initialized
44 * through `dif_rram_ctrl_init_from_dt`.
45 */
48
49/**
50 * Creates a new handle for a(n) rram_ctrl peripheral.
51 *
52 * This function does not actuate the hardware.
53 *
54 * @param base_addr The MMIO base address of the rram_ctrl peripheral.
55 * @param[out] rram_ctrl Out param for the initialized handle.
56 * @return The result of the operation.
57 *
58 * DEPRECATED This function exists solely for the transition to
59 * dt-based DIFs and will be removed in the future.
60 */
63 mmio_region_t base_addr,
64 dif_rram_ctrl_t *rram_ctrl);
65
66/**
67 * Creates a new handle for a(n) rram_ctrl peripheral.
68 *
69 * This function does not actuate the hardware.
70 *
71 * @param dt The devicetable description of the device.
72 * @param[out] rram_ctrl Out param for the initialized handle.
73 * @return The result of the operation.
74 */
78 dif_rram_ctrl_t *rram_ctrl);
79
80/**
81 * Get the DT handle from this DIF.
82 *
83 * If this DIF was initialized by `dif_rram_ctrl_init_from_dt(dt, ..)`
84 * then this function will return `dt`. Otherwise it will return an error.
85 *
86 * @param rram_ctrl A rram_ctrl handle.
87 * @param[out] dt DT handle.
88 * @return `kDifBadArg` if the DIF has no DT information, `kDifOk` otherwise.
89 */
92 const dif_rram_ctrl_t *rram_ctrl,
93 dt_rram_ctrl_t *dt);
94
95 /**
96 * A rram_ctrl alert type.
97 */
98 typedef enum dif_rram_ctrl_alert {
99 /**
100 * RRAM recoverable errors. Fired whenever a software initiated controller operation completes with any bit set in !!ERR_CODE.
101 */
103 /**
104 * RRAM standard fatal errors. Fired whenever any bit in !!STD_FAULT_STATUS is set.
105 */
107 /**
108 * RRAM fatal errors. Fired whenever any bit in !!FAULT_STATUS is set, including uncorrectable ECC errors. Note that this alert is not always fatal. The underlying error bits in the !!FAULT_STATUS register remain set until reset, meaning the alert keeps firing. This doesn't hold for !!FAULT_STATUS.PHY_RELBL_ERR. To enable firmware dealing with multi-bit ECC errors during firmware selection and verification, these error bits can be cleared. After passing this stage, it is recommended that firmware classifies the corresponding alert as fatal on the receiver end, i.e, inside the alert handler.
109 */
111 /**
112 * Fatal errors triggered inside the RRAM macro, including fatal TL-UL bus integrity faults of the test interface.
113 */
115 /**
116 * Recoverable errors triggered inside the RRAM macro.
117 */
120
121 /**
122 * Forces a particular alert, causing it to be escalated as if the hardware
123 * had raised it.
124 *
125 * @param rram_ctrl A rram_ctrl handle.
126 * @param alert The alert to force.
127 * @return The result of the operation.
128 */
131 const dif_rram_ctrl_t *rram_ctrl,
133
134 // DEPRECATED This typedef exists solely for the transition to
135 // dt-based interrupt numbers and will be removed in the future.
136 typedef dt_rram_ctrl_irq_t dif_rram_ctrl_irq_t;
137
138 /**
139 * A rram_ctrl interrupt request type.
140 *
141 * DEPRECATED Use `dt_rram_ctrl_irq_t` instead.
142 * This enumeration exists solely for the transition to
143 * dt-based interrupt numbers and will be removed in the future.
144 *
145 * The following are defines to keep the types consistent with DT.
146 */
147 /**
148 * Write FIFO empty
149 */
150#define kDifRramCtrlIrqWrEmpty kDtRramCtrlIrqWrEmpty
151 /**
152 * Write FIFO drained to level
153 */
154#define kDifRramCtrlIrqWrLvl kDtRramCtrlIrqWrLvl
155 /**
156 * Read FIFO full
157 */
158#define kDifRramCtrlIrqRdFull kDtRramCtrlIrqRdFull
159 /**
160 * Read FIFO filled to level
161 */
162#define kDifRramCtrlIrqRdLvl kDtRramCtrlIrqRdLvl
163 /**
164 * Operation complete
165 */
166#define kDifRramCtrlIrqOpDone kDtRramCtrlIrqOpDone
167 /**
168 * Correctable single-bit error encountered
169 */
170#define kDifRramCtrlIrqCorr1Err kDtRramCtrlIrqCorr1Err
171 /**
172 * Correctable double-bit error encountered
173 */
174#define kDifRramCtrlIrqCorr2Err kDtRramCtrlIrqCorr2Err
175
176 /**
177 * A snapshot of the state of the interrupts for this IP.
178 *
179 * This is an opaque type, to be used with the `dif_rram_ctrl_irq_get_state()`
180 * and `dif_rram_ctrl_irq_acknowledge_state()` functions.
181 */
183
184 /**
185 * Returns the type of a given interrupt (i.e., event or status) for this IP.
186 *
187 * @param rram_ctrl A rram_ctrl handle.
188 * @param irq An interrupt request.
189 * @param[out] type Out-param for the interrupt type.
190 * @return The result of the operation.
191 */
194 const dif_rram_ctrl_t *rram_ctrl,
195 dif_rram_ctrl_irq_t,
196 dif_irq_type_t *type);
197
198 /**
199 * Returns the state of all interrupts (i.e., pending or not) for this IP.
200 *
201 * @param rram_ctrl A rram_ctrl handle.
202 * @param[out] snapshot Out-param for interrupt state snapshot.
203 * @return The result of the operation.
204 */
207 const dif_rram_ctrl_t *rram_ctrl,
209
210 /**
211 * Returns whether a particular interrupt is currently pending.
212 *
213 * @param rram_ctrl A rram_ctrl handle.
214 * @param irq An interrupt request.
215 * @param[out] is_pending Out-param for whether the interrupt is pending.
216 * @return The result of the operation.
217 */
220 const dif_rram_ctrl_t *rram_ctrl,
221 dif_rram_ctrl_irq_t,
222 bool *is_pending);
223
224 /**
225 * Acknowledges all interrupts that were pending at the time of the state
226 * snapshot.
227 *
228 * @param rram_ctrl A rram_ctrl handle.
229 * @param snapshot Interrupt state snapshot.
230 * @return The result of the operation.
231 */
234 const dif_rram_ctrl_t *rram_ctrl,
236
237 /**
238 * Acknowledges all interrupts, indicating to the hardware that all
239 * interrupts have been successfully serviced.
240 *
241 * @param rram_ctrl A rram_ctrl handle.
242 * @return The result of the operation.
243 */
246 const dif_rram_ctrl_t *rram_ctrl
247 );
248
249 /**
250 * Acknowledges a particular interrupt, indicating to the hardware that it has
251 * been successfully serviced.
252 *
253 * @param rram_ctrl A rram_ctrl handle.
254 * @param irq An interrupt request.
255 * @return The result of the operation.
256 */
259 const dif_rram_ctrl_t *rram_ctrl,
260 dif_rram_ctrl_irq_t);
261
262 /**
263 * Forces a particular interrupt, causing it to be serviced as if hardware had
264 * asserted it.
265 *
266 * @param rram_ctrl A rram_ctrl handle.
267 * @param irq An interrupt request.
268 * @param val Value to be set.
269 * @return The result of the operation.
270 */
273 const dif_rram_ctrl_t *rram_ctrl,
274 dif_rram_ctrl_irq_t,
275 const bool val);
276
277 /**
278 * A snapshot of the enablement state of the interrupts for this IP.
279 *
280 * This is an opaque type, to be used with the
281 * `dif_rram_ctrl_irq_disable_all()` and `dif_rram_ctrl_irq_restore_all()`
282 * functions.
283 */
285
286 /**
287 * Checks whether a particular interrupt is currently enabled or disabled.
288 *
289 * @param rram_ctrl A rram_ctrl handle.
290 * @param irq An interrupt request.
291 * @param[out] state Out-param toggle state of the interrupt.
292 * @return The result of the operation.
293 */
296 const dif_rram_ctrl_t *rram_ctrl,
297 dif_rram_ctrl_irq_t,
298 dif_toggle_t *state);
299
300 /**
301 * Sets whether a particular interrupt is currently enabled or disabled.
302 *
303 * @param rram_ctrl A rram_ctrl handle.
304 * @param irq An interrupt request.
305 * @param state The new toggle state for the interrupt.
306 * @return The result of the operation.
307 */
310 const dif_rram_ctrl_t *rram_ctrl,
311 dif_rram_ctrl_irq_t,
312 dif_toggle_t state);
313
314 /**
315 * Disables all interrupts, optionally snapshotting all enable states for later
316 * restoration.
317 *
318 * @param rram_ctrl A rram_ctrl handle.
319 * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
320 * @return The result of the operation.
321 */
324 const dif_rram_ctrl_t *rram_ctrl,
326
327 /**
328 * Restores interrupts from the given (enable) snapshot.
329 *
330 * @param rram_ctrl A rram_ctrl handle.
331 * @param snapshot A snapshot to restore from.
332 * @return The result of the operation.
333 */
336 const dif_rram_ctrl_t *rram_ctrl,
338
339
340#ifdef __cplusplus
341} // extern "C"
342#endif // __cplusplus
343
344#endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_RRAM_CTRL_AUTOGEN_H_