Software APIs
dif_spi_host_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_HOST_AUTOGEN_H_
6 #define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_SPI_HOST_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_host/">SPI_HOST</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_host.
30  *
31  * This type should be treated as opaque by users.
32  */
33 typedef struct dif_spi_host {
34  /**
35  * The base address for the spi_host hardware registers.
36  */
39 
40 /**
41  * Creates a new handle for a(n) spi_host peripheral.
42  *
43  * This function does not actuate the hardware.
44  *
45  * @param base_addr The MMIO base address of the spi_host peripheral.
46  * @param[out] spi_host Out param for the initialized handle.
47  * @return The result of the operation.
48  */
51  dif_spi_host_t *spi_host);
52 
53 /**
54  * A spi_host alert type.
55  */
56 typedef enum dif_spi_host_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_host A spi_host handle.
69  * @param alert The alert to force.
70  * @return The result of the operation.
71  */
74  dif_spi_host_alert_t alert);
75 
76 /**
77  * A spi_host interrupt request type.
78  */
79 typedef enum dif_spi_host_irq {
80  /**
81  * Error-related interrupts, see !!ERROR_ENABLE register for more information.
82  */
84  /**
85  * Event-related interrupts, see !!EVENT_ENABLE register for more information.
86  */
89 
90 /**
91  * A snapshot of the state of the interrupts for this IP.
92  *
93  * This is an opaque type, to be used with the `dif_spi_host_irq_get_state()`
94  * and `dif_spi_host_irq_acknowledge_state()` functions.
95  */
97 
98 /**
99  * Returns the type of a given interrupt (i.e., event or status) for this IP.
100  *
101  * @param spi_host A spi_host handle.
102  * @param irq An interrupt request.
103  * @param[out] type Out-param for the interrupt type.
104  * @return The result of the operation.
105  */
108  dif_spi_host_irq_t irq,
109  dif_irq_type_t *type);
110 
111 /**
112  * Returns the state of all interrupts (i.e., pending or not) for this IP.
113  *
114  * @param spi_host A spi_host handle.
115  * @param[out] snapshot Out-param for interrupt state snapshot.
116  * @return The result of the operation.
117  */
120  const dif_spi_host_t *spi_host,
122 
123 /**
124  * Returns whether a particular interrupt is currently pending.
125  *
126  * @param spi_host A spi_host handle.
127  * @param irq An interrupt request.
128  * @param[out] is_pending Out-param for whether the interrupt is pending.
129  * @return The result of the operation.
130  */
133  dif_spi_host_irq_t irq,
134  bool *is_pending);
135 
136 /**
137  * Acknowledges all interrupts that were pending at the time of the state
138  * snapshot.
139  *
140  * @param spi_host A spi_host handle.
141  * @param snapshot Interrupt state snapshot.
142  * @return The result of the operation.
143  */
146  const dif_spi_host_t *spi_host, dif_spi_host_irq_state_snapshot_t snapshot);
147 
148 /**
149  * Acknowledges all interrupts, indicating to the hardware that all
150  * interrupts have been successfully serviced.
151  *
152  * @param spi_host A spi_host handle.
153  * @return The result of the operation.
154  */
157 
158 /**
159  * Acknowledges a particular interrupt, indicating to the hardware that it has
160  * been successfully serviced.
161  *
162  * @param spi_host A spi_host handle.
163  * @param irq An interrupt request.
164  * @return The result of the operation.
165  */
168  dif_spi_host_irq_t irq);
169 
170 /**
171  * Forces a particular interrupt, causing it to be serviced as if hardware had
172  * asserted it.
173  *
174  * @param spi_host A spi_host handle.
175  * @param irq An interrupt request.
176  * @param val Value to be set.
177  * @return The result of the operation.
178  */
181  dif_spi_host_irq_t irq, const bool val);
182 
183 /**
184  * A snapshot of the enablement state of the interrupts for this IP.
185  *
186  * This is an opaque type, to be used with the
187  * `dif_spi_host_irq_disable_all()` and `dif_spi_host_irq_restore_all()`
188  * functions.
189  */
191 
192 /**
193  * Checks whether a particular interrupt is currently enabled or disabled.
194  *
195  * @param spi_host A spi_host handle.
196  * @param irq An interrupt request.
197  * @param[out] state Out-param toggle state of the interrupt.
198  * @return The result of the operation.
199  */
202  dif_spi_host_irq_t irq,
203  dif_toggle_t *state);
204 
205 /**
206  * Sets whether a particular interrupt is currently enabled or disabled.
207  *
208  * @param spi_host A spi_host handle.
209  * @param irq An interrupt request.
210  * @param state The new toggle state for the interrupt.
211  * @return The result of the operation.
212  */
215  dif_spi_host_irq_t irq,
216  dif_toggle_t state);
217 
218 /**
219  * Disables all interrupts, optionally snapshotting all enable states for later
220  * restoration.
221  *
222  * @param spi_host A spi_host handle.
223  * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
224  * @return The result of the operation.
225  */
228  const dif_spi_host_t *spi_host,
230 
231 /**
232  * Restores interrupts from the given (enable) snapshot.
233  *
234  * @param spi_host A spi_host handle.
235  * @param snapshot A snapshot to restore from.
236  * @return The result of the operation.
237  */
240  const dif_spi_host_t *spi_host,
241  const dif_spi_host_irq_enable_snapshot_t *snapshot);
242 
243 #ifdef __cplusplus
244 } // extern "C"
245 #endif // __cplusplus
246 
247 #endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_SPI_HOST_AUTOGEN_H_