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
101 */
103 /**
104 * RRAM standard fatal errors
105 */
107 /**
108 * RRAM fatal errors 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 error encountered
169 */
170#define kDifRramCtrlIrqCorrErr kDtRramCtrlIrqCorrErr
171
172 /**
173 * A snapshot of the state of the interrupts for this IP.
174 *
175 * This is an opaque type, to be used with the `dif_rram_ctrl_irq_get_state()`
176 * and `dif_rram_ctrl_irq_acknowledge_state()` functions.
177 */
179
180 /**
181 * Returns the type of a given interrupt (i.e., event or status) for this IP.
182 *
183 * @param rram_ctrl A rram_ctrl handle.
184 * @param irq An interrupt request.
185 * @param[out] type Out-param for the interrupt type.
186 * @return The result of the operation.
187 */
190 const dif_rram_ctrl_t *rram_ctrl,
191 dif_rram_ctrl_irq_t,
192 dif_irq_type_t *type);
193
194 /**
195 * Returns the state of all interrupts (i.e., pending or not) for this IP.
196 *
197 * @param rram_ctrl A rram_ctrl handle.
198 * @param[out] snapshot Out-param for interrupt state snapshot.
199 * @return The result of the operation.
200 */
203 const dif_rram_ctrl_t *rram_ctrl,
205
206 /**
207 * Returns whether a particular interrupt is currently pending.
208 *
209 * @param rram_ctrl A rram_ctrl handle.
210 * @param irq An interrupt request.
211 * @param[out] is_pending Out-param for whether the interrupt is pending.
212 * @return The result of the operation.
213 */
216 const dif_rram_ctrl_t *rram_ctrl,
217 dif_rram_ctrl_irq_t,
218 bool *is_pending);
219
220 /**
221 * Acknowledges all interrupts that were pending at the time of the state
222 * snapshot.
223 *
224 * @param rram_ctrl A rram_ctrl handle.
225 * @param snapshot Interrupt state snapshot.
226 * @return The result of the operation.
227 */
230 const dif_rram_ctrl_t *rram_ctrl,
232
233 /**
234 * Acknowledges all interrupts, indicating to the hardware that all
235 * interrupts have been successfully serviced.
236 *
237 * @param rram_ctrl A rram_ctrl handle.
238 * @return The result of the operation.
239 */
242 const dif_rram_ctrl_t *rram_ctrl
243 );
244
245 /**
246 * Acknowledges a particular interrupt, indicating to the hardware that it has
247 * been successfully serviced.
248 *
249 * @param rram_ctrl A rram_ctrl handle.
250 * @param irq An interrupt request.
251 * @return The result of the operation.
252 */
255 const dif_rram_ctrl_t *rram_ctrl,
256 dif_rram_ctrl_irq_t);
257
258 /**
259 * Forces a particular interrupt, causing it to be serviced as if hardware had
260 * asserted it.
261 *
262 * @param rram_ctrl A rram_ctrl handle.
263 * @param irq An interrupt request.
264 * @param val Value to be set.
265 * @return The result of the operation.
266 */
269 const dif_rram_ctrl_t *rram_ctrl,
270 dif_rram_ctrl_irq_t,
271 const bool val);
272
273 /**
274 * A snapshot of the enablement state of the interrupts for this IP.
275 *
276 * This is an opaque type, to be used with the
277 * `dif_rram_ctrl_irq_disable_all()` and `dif_rram_ctrl_irq_restore_all()`
278 * functions.
279 */
281
282 /**
283 * Checks whether a particular interrupt is currently enabled or disabled.
284 *
285 * @param rram_ctrl A rram_ctrl handle.
286 * @param irq An interrupt request.
287 * @param[out] state Out-param toggle state of the interrupt.
288 * @return The result of the operation.
289 */
292 const dif_rram_ctrl_t *rram_ctrl,
293 dif_rram_ctrl_irq_t,
294 dif_toggle_t *state);
295
296 /**
297 * Sets whether a particular interrupt is currently enabled or disabled.
298 *
299 * @param rram_ctrl A rram_ctrl handle.
300 * @param irq An interrupt request.
301 * @param state The new toggle state for the interrupt.
302 * @return The result of the operation.
303 */
306 const dif_rram_ctrl_t *rram_ctrl,
307 dif_rram_ctrl_irq_t,
308 dif_toggle_t state);
309
310 /**
311 * Disables all interrupts, optionally snapshotting all enable states for later
312 * restoration.
313 *
314 * @param rram_ctrl A rram_ctrl handle.
315 * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
316 * @return The result of the operation.
317 */
320 const dif_rram_ctrl_t *rram_ctrl,
322
323 /**
324 * Restores interrupts from the given (enable) snapshot.
325 *
326 * @param rram_ctrl A rram_ctrl handle.
327 * @param snapshot A snapshot to restore from.
328 * @return The result of the operation.
329 */
332 const dif_rram_ctrl_t *rram_ctrl,
334
335
336#ifdef __cplusplus
337} // extern "C"
338#endif // __cplusplus
339
340#endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_RRAM_CTRL_AUTOGEN_H_