Software APIs
dif_gpio_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_GPIO_AUTOGEN_H_
6 #define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_GPIO_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/gpio/">GPIO</a> Device Interface Functions
14  */
15 
16 #include <stdbool.h>
17 #include <stdint.h>
18 
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif // __cplusplus
26 
27 /**
28  * A handle to gpio.
29  *
30  * This type should be treated as opaque by users.
31  */
32 typedef struct dif_gpio {
33  /**
34  * The base address for the gpio hardware registers.
35  */
37 } dif_gpio_t;
38 
39 /**
40  * Creates a new handle for a(n) gpio peripheral.
41  *
42  * This function does not actuate the hardware.
43  *
44  * @param base_addr The MMIO base address of the gpio peripheral.
45  * @param[out] gpio Out param for the initialized handle.
46  * @return The result of the operation.
47  */
50 
51 /**
52  * A gpio alert type.
53  */
54 typedef enum dif_gpio_alert {
55  /**
56  * This fatal alert is triggered when a fatal TL-UL bus integrity fault is
57  * detected.
58  */
61 
62 /**
63  * Forces a particular alert, causing it to be escalated as if the hardware
64  * had raised it.
65  *
66  * @param gpio A gpio handle.
67  * @param alert The alert to force.
68  * @return The result of the operation.
69  */
72  dif_gpio_alert_t alert);
73 
74 /**
75  * A gpio interrupt request type.
76  */
77 typedef enum dif_gpio_irq {
78  /**
79  * Raised if any of GPIO pin detects configured interrupt mode
80  */
82  kDifGpioIrqGpio1 = 1,
83  kDifGpioIrqGpio2 = 2,
84  kDifGpioIrqGpio3 = 3,
85  kDifGpioIrqGpio4 = 4,
86  kDifGpioIrqGpio5 = 5,
87  kDifGpioIrqGpio6 = 6,
88  kDifGpioIrqGpio7 = 7,
89  kDifGpioIrqGpio8 = 8,
90  kDifGpioIrqGpio9 = 9,
91  kDifGpioIrqGpio10 = 10,
92  kDifGpioIrqGpio11 = 11,
93  kDifGpioIrqGpio12 = 12,
94  kDifGpioIrqGpio13 = 13,
95  kDifGpioIrqGpio14 = 14,
96  kDifGpioIrqGpio15 = 15,
97  kDifGpioIrqGpio16 = 16,
98  kDifGpioIrqGpio17 = 17,
99  kDifGpioIrqGpio18 = 18,
100  kDifGpioIrqGpio19 = 19,
101  kDifGpioIrqGpio20 = 20,
102  kDifGpioIrqGpio21 = 21,
103  kDifGpioIrqGpio22 = 22,
104  kDifGpioIrqGpio23 = 23,
105  kDifGpioIrqGpio24 = 24,
106  kDifGpioIrqGpio25 = 25,
107  kDifGpioIrqGpio26 = 26,
108  kDifGpioIrqGpio27 = 27,
109  kDifGpioIrqGpio28 = 28,
110  kDifGpioIrqGpio29 = 29,
111  kDifGpioIrqGpio30 = 30,
112  kDifGpioIrqGpio31 = 31,
114 
115 /**
116  * A snapshot of the state of the interrupts for this IP.
117  *
118  * This is an opaque type, to be used with the `dif_gpio_irq_get_state()`
119  * and `dif_gpio_irq_acknowledge_state()` functions.
120  */
122 
123 /**
124  * Returns the type of a given interrupt (i.e., event or status) for this IP.
125  *
126  * @param gpio A gpio handle.
127  * @param irq An interrupt request.
128  * @param[out] type Out-param for the interrupt type.
129  * @return The result of the operation.
130  */
133  dif_irq_type_t *type);
134 
135 /**
136  * Returns the state of all interrupts (i.e., pending or not) for this IP.
137  *
138  * @param gpio A gpio handle.
139  * @param[out] snapshot Out-param for interrupt state snapshot.
140  * @return The result of the operation.
141  */
145 
146 /**
147  * Returns whether a particular interrupt is currently pending.
148  *
149  * @param gpio A gpio handle.
150  * @param irq An interrupt request.
151  * @param[out] is_pending Out-param for whether the interrupt is pending.
152  * @return The result of the operation.
153  */
156  bool *is_pending);
157 
158 /**
159  * Acknowledges all interrupts that were pending at the time of the state
160  * snapshot.
161  *
162  * @param gpio A gpio handle.
163  * @param snapshot Interrupt state snapshot.
164  * @return The result of the operation.
165  */
168  const dif_gpio_t *gpio, dif_gpio_irq_state_snapshot_t snapshot);
169 
170 /**
171  * Acknowledges all interrupts, indicating to the hardware that all
172  * interrupts have been successfully serviced.
173  *
174  * @param gpio A gpio handle.
175  * @return The result of the operation.
176  */
179 
180 /**
181  * Acknowledges a particular interrupt, indicating to the hardware that it has
182  * been successfully serviced.
183  *
184  * @param gpio A gpio handle.
185  * @param irq An interrupt request.
186  * @return The result of the operation.
187  */
190  dif_gpio_irq_t irq);
191 
192 /**
193  * Forces a particular interrupt, causing it to be serviced as if hardware had
194  * asserted it.
195  *
196  * @param gpio A gpio handle.
197  * @param irq An interrupt request.
198  * @param val Value to be set.
199  * @return The result of the operation.
200  */
203  const bool val);
204 
205 /**
206  * A snapshot of the enablement state of the interrupts for this IP.
207  *
208  * This is an opaque type, to be used with the
209  * `dif_gpio_irq_disable_all()` and `dif_gpio_irq_restore_all()`
210  * functions.
211  */
213 
214 /**
215  * Checks whether a particular interrupt is currently enabled or disabled.
216  *
217  * @param gpio A gpio handle.
218  * @param irq An interrupt request.
219  * @param[out] state Out-param toggle state of the interrupt.
220  * @return The result of the operation.
221  */
224  dif_gpio_irq_t irq, dif_toggle_t *state);
225 
226 /**
227  * Sets whether a particular interrupt is currently enabled or disabled.
228  *
229  * @param gpio A gpio handle.
230  * @param irq An interrupt request.
231  * @param state The new toggle state for the interrupt.
232  * @return The result of the operation.
233  */
236  dif_gpio_irq_t irq, dif_toggle_t state);
237 
238 /**
239  * Disables all interrupts, optionally snapshotting all enable states for later
240  * restoration.
241  *
242  * @param gpio A gpio handle.
243  * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
244  * @return The result of the operation.
245  */
249 
250 /**
251  * Restores interrupts from the given (enable) snapshot.
252  *
253  * @param gpio A gpio handle.
254  * @param snapshot A snapshot to restore from.
255  * @return The result of the operation.
256  */
259  const dif_gpio_t *gpio, const dif_gpio_irq_enable_snapshot_t *snapshot);
260 
261 #ifdef __cplusplus
262 } // extern "C"
263 #endif // __cplusplus
264 
265 #endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_GPIO_AUTOGEN_H_