Software APIs
dif_spi_device_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_SPI_DEVICE_AUTOGEN_H_
6 #define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_SPI_DEVICE_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/spi_device/">SPI_DEVICE</a> Device Interface
14  * Functions
15  */
16 
17 #include <stdbool.h>
18 #include <stdint.h>
19 
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif // __cplusplus
27 
28 /**
29  * A handle to spi_device.
30  *
31  * This type should be treated as opaque by users.
32  */
33 typedef struct dif_spi_device {
34  /**
35  * The base address for the spi_device hardware registers.
36  */
39 
40 /**
41  * Creates a new handle for a(n) spi_device peripheral.
42  *
43  * This function does not actuate the hardware.
44  *
45  * @param base_addr The MMIO base address of the spi_device peripheral.
46  * @param[out] spi_device Out param for the initialized handle.
47  * @return The result of the operation.
48  */
51  dif_spi_device_t *spi_device);
52 
53 /**
54  * A spi_device alert type.
55  */
56 typedef enum dif_spi_device_alert {
57  /**
58  * This fatal alert is triggered when a fatal TL-UL bus integrity fault is
59  * detected.
60  */
63 
64 /**
65  * Forces a particular alert, causing it to be escalated as if the hardware
66  * had raised it.
67  *
68  * @param spi_device A spi_device handle.
69  * @param alert The alert to force.
70  * @return The result of the operation.
71  */
75 
76 /**
77  * A spi_device interrupt request type.
78  */
79 typedef enum dif_spi_device_irq {
80  /**
81  * Upload Command FIFO is not empty
82  */
84  /**
85  * Upload payload is not empty. The event occurs after SPI transaction
86  * completed
87  */
89  /**
90  * Upload payload overflow event. When a SPI Host system issues a command
91  * with payload more than 256B, this event is reported. When it happens, SW
92  * should read the last written payload index CSR to figure out the starting
93  * address of the last 256B.
94  */
96  /**
97  * Read Buffer Threshold event. The host system accesses greater than or
98  * equal to the threshold of a buffer.
99  */
101  /**
102  * Read buffer flipped event. The host system accesses other side of buffer.
103  */
105  /**
106  * TPM Header(Command/Address) buffer available
107  */
109  /**
110  * TPM RdFIFO command ended. The TPM Read command targeting the RdFIFO ended.
111  * Check TPM_STATUS.rdfifo_aborted to see if the transaction completed.
112  */
114  /**
115  * TPM RdFIFO data dropped. Data was dropped from the RdFIFO. Data was
116  * written while a read command was not active, and it was not accepted. This
117  * can occur when the host aborts a read command.
118  */
121 
122 /**
123  * A snapshot of the state of the interrupts for this IP.
124  *
125  * This is an opaque type, to be used with the `dif_spi_device_irq_get_state()`
126  * and `dif_spi_device_irq_acknowledge_state()` functions.
127  */
129 
130 /**
131  * Returns the type of a given interrupt (i.e., event or status) for this IP.
132  *
133  * @param spi_device A spi_device handle.
134  * @param irq An interrupt request.
135  * @param[out] type Out-param for the interrupt type.
136  * @return The result of the operation.
137  */
141  dif_irq_type_t *type);
142 
143 /**
144  * Returns the state of all interrupts (i.e., pending or not) for this IP.
145  *
146  * @param spi_device A spi_device handle.
147  * @param[out] snapshot Out-param for interrupt state snapshot.
148  * @return The result of the operation.
149  */
152  const dif_spi_device_t *spi_device,
154 
155 /**
156  * Returns whether a particular interrupt is currently pending.
157  *
158  * @param spi_device A spi_device handle.
159  * @param irq An interrupt request.
160  * @param[out] is_pending Out-param for whether the interrupt is pending.
161  * @return The result of the operation.
162  */
166  bool *is_pending);
167 
168 /**
169  * Acknowledges all interrupts that were pending at the time of the state
170  * snapshot.
171  *
172  * @param spi_device A spi_device handle.
173  * @param snapshot Interrupt state snapshot.
174  * @return The result of the operation.
175  */
178  const dif_spi_device_t *spi_device,
180 
181 /**
182  * Acknowledges all interrupts, indicating to the hardware that all
183  * interrupts have been successfully serviced.
184  *
185  * @param spi_device A spi_device handle.
186  * @return The result of the operation.
187  */
190  const dif_spi_device_t *spi_device);
191 
192 /**
193  * Acknowledges a particular interrupt, indicating to the hardware that it has
194  * been successfully serviced.
195  *
196  * @param spi_device A spi_device handle.
197  * @param irq An interrupt request.
198  * @return The result of the operation.
199  */
203 
204 /**
205  * Forces a particular interrupt, causing it to be serviced as if hardware had
206  * asserted it.
207  *
208  * @param spi_device A spi_device handle.
209  * @param irq An interrupt request.
210  * @param val Value to be set.
211  * @return The result of the operation.
212  */
215  dif_spi_device_irq_t irq, const bool val);
216 
217 /**
218  * A snapshot of the enablement state of the interrupts for this IP.
219  *
220  * This is an opaque type, to be used with the
221  * `dif_spi_device_irq_disable_all()` and `dif_spi_device_irq_restore_all()`
222  * functions.
223  */
225 
226 /**
227  * Checks whether a particular interrupt is currently enabled or disabled.
228  *
229  * @param spi_device A spi_device handle.
230  * @param irq An interrupt request.
231  * @param[out] state Out-param toggle state of the interrupt.
232  * @return The result of the operation.
233  */
237  dif_toggle_t *state);
238 
239 /**
240  * Sets whether a particular interrupt is currently enabled or disabled.
241  *
242  * @param spi_device A spi_device handle.
243  * @param irq An interrupt request.
244  * @param state The new toggle state for the interrupt.
245  * @return The result of the operation.
246  */
250  dif_toggle_t state);
251 
252 /**
253  * Disables all interrupts, optionally snapshotting all enable states for later
254  * restoration.
255  *
256  * @param spi_device A spi_device handle.
257  * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
258  * @return The result of the operation.
259  */
262  const dif_spi_device_t *spi_device,
264 
265 /**
266  * Restores interrupts from the given (enable) snapshot.
267  *
268  * @param spi_device A spi_device handle.
269  * @param snapshot A snapshot to restore from.
270  * @return The result of the operation.
271  */
274  const dif_spi_device_t *spi_device,
275  const dif_spi_device_irq_enable_snapshot_t *snapshot);
276 
277 #ifdef __cplusplus
278 } // extern "C"
279 #endif // __cplusplus
280 
281 #endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_SPI_DEVICE_AUTOGEN_H_