Software APIs
dif_dma_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_DMA_AUTOGEN_H_
8#define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_DMA_AUTOGEN_H_
9
10// THIS FILE HAS BEEN GENERATED, DO NOT EDIT MANUALLY. COMMAND:
11// util/autogen_dif.py -i hw/ip/dma/data/dma.hjson -o
12// bazel-out/k8-fastbuild-ST-24cc6a2908d2/bin/sw/device/lib/dif/autogen
13
14
15/**
16 * @file
17 * @brief <a href="/book/hw/ip/dma/">DMA</a> Device Interface Functions
18 */
19
20#include <stdbool.h>
21#include <stdint.h>
22
26#include "dt/dt_dma.h" // Generated.
27
28#ifdef __cplusplus
29extern "C" {
30#endif // __cplusplus
31
32/**
33 * A handle to dma.
34 *
35 * This type should be treated as opaque by users.
36 */
37typedef struct dif_dma {
38 /**
39 * The base address for the dma hardware registers.
40 */
42 /**
43 * The instance, set to `kDtDmaCount` if not initialized
44 * through `dif_dma_init_from_dt`.
45 */
48
49/**
50 * Creates a new handle for a(n) dma peripheral.
51 *
52 * This function does not actuate the hardware.
53 *
54 * @param base_addr The MMIO base address of the dma peripheral.
55 * @param[out] dma 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_dma_t *dma);
65
66/**
67 * Creates a new handle for a(n) dma peripheral.
68 *
69 * This function does not actuate the hardware.
70 *
71 * @param dt The devicetable description of the device.
72 * @param[out] dma Out param for the initialized handle.
73 * @return The result of the operation.
74 */
77 dt_dma_t dt,
78 dif_dma_t *dma);
79
80/**
81 * Get the DT handle from this DIF.
82 *
83 * If this DIF was initialized by `dif_dma_init_from_dt(dt, ..)`
84 * then this function will return `dt`. Otherwise it will return an error.
85 *
86 * @param dma A dma handle.
87 * @param[out] dt DT handle.
88 * @return `kDifBadArg` if the DIF has no DT information, `kDifOk` otherwise.
89 */
92 const dif_dma_t *dma,
93 dt_dma_t *dt);
94
95 /**
96 * A dma alert type.
97 */
98 typedef enum dif_dma_alert {
99 /**
100 * This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected.
101 */
104
105 /**
106 * Forces a particular alert, causing it to be escalated as if the hardware
107 * had raised it.
108 *
109 * @param dma A dma handle.
110 * @param alert The alert to force.
111 * @return The result of the operation.
112 */
115 const dif_dma_t *dma,
116 dif_dma_alert_t alert);
117
118 // DEPRECATED This typedef exists solely for the transition to
119 // dt-based interrupt numbers and will be removed in the future.
120 typedef dt_dma_irq_t dif_dma_irq_t;
121
122 /**
123 * A dma interrupt request type.
124 *
125 * DEPRECATED Use `dt_dma_irq_t` instead.
126 * This enumeration exists solely for the transition to
127 * dt-based interrupt numbers and will be removed in the future.
128 *
129 * The following are defines to keep the types consistent with DT.
130 */
131 /**
132 * DMA operation has been completed.
133 */
134#define kDifDmaIrqDmaDone kDtDmaIrqDmaDone
135 /**
136 * Indicates the transfer of a single chunk has been completed.
137 */
138#define kDifDmaIrqDmaChunkDone kDtDmaIrqDmaChunkDone
139 /**
140 * DMA error has occurred. DMA_STATUS.error_code register shows the details.
141 */
142#define kDifDmaIrqDmaError kDtDmaIrqDmaError
143
144 /**
145 * A snapshot of the state of the interrupts for this IP.
146 *
147 * This is an opaque type, to be used with the `dif_dma_irq_get_state()`
148 * and `dif_dma_irq_acknowledge_state()` functions.
149 */
151
152 /**
153 * Returns the type of a given interrupt (i.e., event or status) for this IP.
154 *
155 * @param dma A dma handle.
156 * @param irq An interrupt request.
157 * @param[out] type Out-param for the interrupt type.
158 * @return The result of the operation.
159 */
162 const dif_dma_t *dma,
163 dif_dma_irq_t,
164 dif_irq_type_t *type);
165
166 /**
167 * Returns the state of all interrupts (i.e., pending or not) for this IP.
168 *
169 * @param dma A dma handle.
170 * @param[out] snapshot Out-param for interrupt state snapshot.
171 * @return The result of the operation.
172 */
175 const dif_dma_t *dma,
177
178 /**
179 * Returns whether a particular interrupt is currently pending.
180 *
181 * @param dma A dma handle.
182 * @param irq An interrupt request.
183 * @param[out] is_pending Out-param for whether the interrupt is pending.
184 * @return The result of the operation.
185 */
188 const dif_dma_t *dma,
189 dif_dma_irq_t,
190 bool *is_pending);
191
192 /**
193 * Acknowledges all interrupts that were pending at the time of the state
194 * snapshot.
195 *
196 * @param dma A dma handle.
197 * @param snapshot Interrupt state snapshot.
198 * @return The result of the operation.
199 */
202 const dif_dma_t *dma,
204
205 /**
206 * Acknowledges all interrupts, indicating to the hardware that all
207 * interrupts have been successfully serviced.
208 *
209 * @param dma A dma handle.
210 * @return The result of the operation.
211 */
214 const dif_dma_t *dma
215 );
216
217 /**
218 * Acknowledges a particular interrupt, indicating to the hardware that it has
219 * been successfully serviced.
220 *
221 * @param dma A dma handle.
222 * @param irq An interrupt request.
223 * @return The result of the operation.
224 */
227 const dif_dma_t *dma,
228 dif_dma_irq_t);
229
230 /**
231 * Forces a particular interrupt, causing it to be serviced as if hardware had
232 * asserted it.
233 *
234 * @param dma A dma handle.
235 * @param irq An interrupt request.
236 * @param val Value to be set.
237 * @return The result of the operation.
238 */
241 const dif_dma_t *dma,
242 dif_dma_irq_t,
243 const bool val);
244
245 /**
246 * A snapshot of the enablement state of the interrupts for this IP.
247 *
248 * This is an opaque type, to be used with the
249 * `dif_dma_irq_disable_all()` and `dif_dma_irq_restore_all()`
250 * functions.
251 */
253
254 /**
255 * Checks whether a particular interrupt is currently enabled or disabled.
256 *
257 * @param dma A dma handle.
258 * @param irq An interrupt request.
259 * @param[out] state Out-param toggle state of the interrupt.
260 * @return The result of the operation.
261 */
264 const dif_dma_t *dma,
265 dif_dma_irq_t,
266 dif_toggle_t *state);
267
268 /**
269 * Sets whether a particular interrupt is currently enabled or disabled.
270 *
271 * @param dma A dma handle.
272 * @param irq An interrupt request.
273 * @param state The new toggle state for the interrupt.
274 * @return The result of the operation.
275 */
278 const dif_dma_t *dma,
279 dif_dma_irq_t,
280 dif_toggle_t state);
281
282 /**
283 * Disables all interrupts, optionally snapshotting all enable states for later
284 * restoration.
285 *
286 * @param dma A dma handle.
287 * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
288 * @return The result of the operation.
289 */
292 const dif_dma_t *dma,
294
295 /**
296 * Restores interrupts from the given (enable) snapshot.
297 *
298 * @param dma A dma handle.
299 * @param snapshot A snapshot to restore from.
300 * @return The result of the operation.
301 */
304 const dif_dma_t *dma,
305 const dif_dma_irq_enable_snapshot_t *snapshot);
306
307
308#ifdef __cplusplus
309} // extern "C"
310#endif // __cplusplus
311
312#endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_DMA_AUTOGEN_H_