Software APIs
dif_pwrmgr_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_PWRMGR_AUTOGEN_H_
6 #define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_PWRMGR_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/pwrmgr/">PWRMGR</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 pwrmgr.
29  *
30  * This type should be treated as opaque by users.
31  */
32 typedef struct dif_pwrmgr {
33  /**
34  * The base address for the pwrmgr hardware registers.
35  */
37 } dif_pwrmgr_t;
38 
39 /**
40  * Creates a new handle for a(n) pwrmgr peripheral.
41  *
42  * This function does not actuate the hardware.
43  *
44  * @param base_addr The MMIO base address of the pwrmgr peripheral.
45  * @param[out] pwrmgr Out param for the initialized handle.
46  * @return The result of the operation.
47  */
50 
51 /**
52  * A pwrmgr alert type.
53  */
54 typedef enum dif_pwrmgr_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 pwrmgr A pwrmgr handle.
67  * @param alert The alert to force.
68  * @return The result of the operation.
69  */
72  dif_pwrmgr_alert_t alert);
73 
74 /**
75  * A pwrmgr interrupt request type.
76  */
77 typedef enum dif_pwrmgr_irq {
78  /**
79  * Wake from low power state. See wake info for more details
80  */
83 
84 /**
85  * A snapshot of the state of the interrupts for this IP.
86  *
87  * This is an opaque type, to be used with the `dif_pwrmgr_irq_get_state()`
88  * and `dif_pwrmgr_irq_acknowledge_state()` functions.
89  */
91 
92 /**
93  * Returns the type of a given interrupt (i.e., event or status) for this IP.
94  *
95  * @param pwrmgr A pwrmgr handle.
96  * @param irq An interrupt request.
97  * @param[out] type Out-param for the interrupt type.
98  * @return The result of the operation.
99  */
102  dif_pwrmgr_irq_t irq,
103  dif_irq_type_t *type);
104 
105 /**
106  * Returns the state of all interrupts (i.e., pending or not) for this IP.
107  *
108  * @param pwrmgr A pwrmgr handle.
109  * @param[out] snapshot Out-param for interrupt state snapshot.
110  * @return The result of the operation.
111  */
114  const dif_pwrmgr_t *pwrmgr, dif_pwrmgr_irq_state_snapshot_t *snapshot);
115 
116 /**
117  * Returns whether a particular interrupt is currently pending.
118  *
119  * @param pwrmgr A pwrmgr handle.
120  * @param irq An interrupt request.
121  * @param[out] is_pending Out-param for whether the interrupt is pending.
122  * @return The result of the operation.
123  */
126  dif_pwrmgr_irq_t irq, bool *is_pending);
127 
128 /**
129  * Acknowledges all interrupts that were pending at the time of the state
130  * snapshot.
131  *
132  * @param pwrmgr A pwrmgr handle.
133  * @param snapshot Interrupt state snapshot.
134  * @return The result of the operation.
135  */
138  const dif_pwrmgr_t *pwrmgr, dif_pwrmgr_irq_state_snapshot_t snapshot);
139 
140 /**
141  * Acknowledges all interrupts, indicating to the hardware that all
142  * interrupts have been successfully serviced.
143  *
144  * @param pwrmgr A pwrmgr handle.
145  * @return The result of the operation.
146  */
149 
150 /**
151  * Acknowledges a particular interrupt, indicating to the hardware that it has
152  * been successfully serviced.
153  *
154  * @param pwrmgr A pwrmgr handle.
155  * @param irq An interrupt request.
156  * @return The result of the operation.
157  */
160  dif_pwrmgr_irq_t irq);
161 
162 /**
163  * Forces a particular interrupt, causing it to be serviced as if hardware had
164  * asserted it.
165  *
166  * @param pwrmgr A pwrmgr handle.
167  * @param irq An interrupt request.
168  * @param val Value to be set.
169  * @return The result of the operation.
170  */
173  dif_pwrmgr_irq_t irq, const bool val);
174 
175 /**
176  * A snapshot of the enablement state of the interrupts for this IP.
177  *
178  * This is an opaque type, to be used with the
179  * `dif_pwrmgr_irq_disable_all()` and `dif_pwrmgr_irq_restore_all()`
180  * functions.
181  */
183 
184 /**
185  * Checks whether a particular interrupt is currently enabled or disabled.
186  *
187  * @param pwrmgr A pwrmgr handle.
188  * @param irq An interrupt request.
189  * @param[out] state Out-param toggle state of the interrupt.
190  * @return The result of the operation.
191  */
194  dif_pwrmgr_irq_t irq,
195  dif_toggle_t *state);
196 
197 /**
198  * Sets whether a particular interrupt is currently enabled or disabled.
199  *
200  * @param pwrmgr A pwrmgr handle.
201  * @param irq An interrupt request.
202  * @param state The new toggle state for the interrupt.
203  * @return The result of the operation.
204  */
207  dif_pwrmgr_irq_t irq,
208  dif_toggle_t state);
209 
210 /**
211  * Disables all interrupts, optionally snapshotting all enable states for later
212  * restoration.
213  *
214  * @param pwrmgr A pwrmgr handle.
215  * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
216  * @return The result of the operation.
217  */
220  const dif_pwrmgr_t *pwrmgr, dif_pwrmgr_irq_enable_snapshot_t *snapshot);
221 
222 /**
223  * Restores interrupts from the given (enable) snapshot.
224  *
225  * @param pwrmgr A pwrmgr handle.
226  * @param snapshot A snapshot to restore from.
227  * @return The result of the operation.
228  */
231  const dif_pwrmgr_t *pwrmgr,
232  const dif_pwrmgr_irq_enable_snapshot_t *snapshot);
233 
234 #ifdef __cplusplus
235 } // extern "C"
236 #endif // __cplusplus
237 
238 #endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_PWRMGR_AUTOGEN_H_