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
6
7#ifndef OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_PWRMGR_AUTOGEN_H_
8#define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_PWRMGR_AUTOGEN_H_
9
10// THIS FILE HAS BEEN GENERATED, DO NOT EDIT MANUALLY. COMMAND:
11// util/autogen_dif.py -i
12// hw/top_earlgrey/ip_autogen/pwrmgr/data/pwrmgr.hjson -o
13// bazel-out/k8-fastbuild/bin/sw/device/lib/dif/autogen
14
15
16/**
17 * @file
18 * @brief <a href="/book/hw/ip/pwrmgr/">PWRMGR</a> Device Interface Functions
19 */
20
21#include <stdbool.h>
22#include <stdint.h>
23
27#include "hw/top/dt/pwrmgr.h" // Generated.
28
29#ifdef __cplusplus
30extern "C" {
31#endif // __cplusplus
32
33/**
34 * A handle to pwrmgr.
35 *
36 * This type should be treated as opaque by users.
37 */
38typedef struct dif_pwrmgr {
39 /**
40 * The base address for the pwrmgr hardware registers.
41 */
43 /**
44 * The instance, set to `kDtPwrmgrCount` if not initialized
45 * through `dif_pwrmgr_init_from_dt`.
46 */
49
50/**
51 * Creates a new handle for a(n) pwrmgr peripheral.
52 *
53 * This function does not actuate the hardware.
54 *
55 * @param base_addr The MMIO base address of the pwrmgr peripheral.
56 * @param[out] pwrmgr Out param for the initialized handle.
57 * @return The result of the operation.
58 *
59 * DEPRECATED This function exists solely for the transition to
60 * dt-based DIFs and will be removed in the future.
61 */
64 mmio_region_t base_addr,
65 dif_pwrmgr_t *pwrmgr);
66
67/**
68 * Creates a new handle for a(n) pwrmgr peripheral.
69 *
70 * This function does not actuate the hardware.
71 *
72 * @param dt The devicetable description of the device.
73 * @param[out] pwrmgr Out param for the initialized handle.
74 * @return The result of the operation.
75 */
78 dt_pwrmgr_t dt,
79 dif_pwrmgr_t *pwrmgr);
80
81/**
82 * Get the DT handle from this DIF.
83 *
84 * If this DIF was initialized by `dif_pwrmgr_init_from_dt(dt, ..)`
85 * then this function will return `dt`. Otherwise it will return an error.
86 *
87 * @param pwrmgr A pwrmgr handle.
88 * @param[out] dt DT handle.
89 * @return `kDifBadArg` if the DIF has no DT information, `kDifOk` otherwise.
90 */
93 const dif_pwrmgr_t *pwrmgr,
94 dt_pwrmgr_t *dt);
95
96 /**
97 * A pwrmgr alert type.
98 */
99 typedef enum dif_pwrmgr_alert {
100 /**
101 * This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected.
102 */
105
106 /**
107 * Forces a particular alert, causing it to be escalated as if the hardware
108 * had raised it.
109 *
110 * @param pwrmgr A pwrmgr handle.
111 * @param alert The alert to force.
112 * @return The result of the operation.
113 */
116 const dif_pwrmgr_t *pwrmgr,
117 dif_pwrmgr_alert_t alert);
118
119 // DEPRECATED This typedef exists solely for the transition to
120 // dt-based interrupt numbers and will be removed in the future.
121 typedef dt_pwrmgr_irq_t dif_pwrmgr_irq_t;
122
123 /**
124 * A pwrmgr interrupt request type.
125 *
126 * DEPRECATED Use `dt_pwrmgr_irq_t` instead.
127 * This enumeration exists solely for the transition to
128 * dt-based interrupt numbers and will be removed in the future.
129 *
130 * The following are defines to keep the types consistent with DT.
131 */
132 /**
133 * Wake from low power state. See wake info for more details
134 */
135#define kDifPwrmgrIrqWakeup kDtPwrmgrIrqWakeup
136
137 /**
138 * A snapshot of the state of the interrupts for this IP.
139 *
140 * This is an opaque type, to be used with the `dif_pwrmgr_irq_get_state()`
141 * and `dif_pwrmgr_irq_acknowledge_state()` functions.
142 */
144
145 /**
146 * Returns the type of a given interrupt (i.e., event or status) for this IP.
147 *
148 * @param pwrmgr A pwrmgr handle.
149 * @param irq An interrupt request.
150 * @param[out] type Out-param for the interrupt type.
151 * @return The result of the operation.
152 */
155 const dif_pwrmgr_t *pwrmgr,
156 dif_pwrmgr_irq_t,
157 dif_irq_type_t *type);
158
159 /**
160 * Returns the state of all interrupts (i.e., pending or not) for this IP.
161 *
162 * @param pwrmgr A pwrmgr handle.
163 * @param[out] snapshot Out-param for interrupt state snapshot.
164 * @return The result of the operation.
165 */
168 const dif_pwrmgr_t *pwrmgr,
170
171 /**
172 * Returns whether a particular interrupt is currently pending.
173 *
174 * @param pwrmgr A pwrmgr handle.
175 * @param irq An interrupt request.
176 * @param[out] is_pending Out-param for whether the interrupt is pending.
177 * @return The result of the operation.
178 */
181 const dif_pwrmgr_t *pwrmgr,
182 dif_pwrmgr_irq_t,
183 bool *is_pending);
184
185 /**
186 * Acknowledges all interrupts that were pending at the time of the state
187 * snapshot.
188 *
189 * @param pwrmgr A pwrmgr handle.
190 * @param snapshot Interrupt state snapshot.
191 * @return The result of the operation.
192 */
195 const dif_pwrmgr_t *pwrmgr,
197
198 /**
199 * Acknowledges all interrupts, indicating to the hardware that all
200 * interrupts have been successfully serviced.
201 *
202 * @param pwrmgr A pwrmgr handle.
203 * @return The result of the operation.
204 */
207 const dif_pwrmgr_t *pwrmgr
208 );
209
210 /**
211 * Acknowledges a particular interrupt, indicating to the hardware that it has
212 * been successfully serviced.
213 *
214 * @param pwrmgr A pwrmgr handle.
215 * @param irq An interrupt request.
216 * @return The result of the operation.
217 */
220 const dif_pwrmgr_t *pwrmgr,
221 dif_pwrmgr_irq_t);
222
223 /**
224 * Forces a particular interrupt, causing it to be serviced as if hardware had
225 * asserted it.
226 *
227 * @param pwrmgr A pwrmgr handle.
228 * @param irq An interrupt request.
229 * @param val Value to be set.
230 * @return The result of the operation.
231 */
234 const dif_pwrmgr_t *pwrmgr,
235 dif_pwrmgr_irq_t,
236 const bool val);
237
238 /**
239 * A snapshot of the enablement state of the interrupts for this IP.
240 *
241 * This is an opaque type, to be used with the
242 * `dif_pwrmgr_irq_disable_all()` and `dif_pwrmgr_irq_restore_all()`
243 * functions.
244 */
246
247 /**
248 * Checks whether a particular interrupt is currently enabled or disabled.
249 *
250 * @param pwrmgr A pwrmgr handle.
251 * @param irq An interrupt request.
252 * @param[out] state Out-param toggle state of the interrupt.
253 * @return The result of the operation.
254 */
257 const dif_pwrmgr_t *pwrmgr,
258 dif_pwrmgr_irq_t,
259 dif_toggle_t *state);
260
261 /**
262 * Sets whether a particular interrupt is currently enabled or disabled.
263 *
264 * @param pwrmgr A pwrmgr handle.
265 * @param irq An interrupt request.
266 * @param state The new toggle state for the interrupt.
267 * @return The result of the operation.
268 */
271 const dif_pwrmgr_t *pwrmgr,
272 dif_pwrmgr_irq_t,
273 dif_toggle_t state);
274
275 /**
276 * Disables all interrupts, optionally snapshotting all enable states for later
277 * restoration.
278 *
279 * @param pwrmgr A pwrmgr handle.
280 * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
281 * @return The result of the operation.
282 */
285 const dif_pwrmgr_t *pwrmgr,
287
288 /**
289 * Restores interrupts from the given (enable) snapshot.
290 *
291 * @param pwrmgr A pwrmgr handle.
292 * @param snapshot A snapshot to restore from.
293 * @return The result of the operation.
294 */
297 const dif_pwrmgr_t *pwrmgr,
298 const dif_pwrmgr_irq_enable_snapshot_t *snapshot);
299
300
301#ifdef __cplusplus
302} // extern "C"
303#endif // __cplusplus
304
305#endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_PWRMGR_AUTOGEN_H_