Software APIs
dif_sensor_ctrl_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_SENSOR_CTRL_AUTOGEN_H_
8#define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_SENSOR_CTRL_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/sensor_ctrl/data/sensor_ctrl.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/sensor_ctrl/">SENSOR_CTRL</a> Device Interface Functions
19 */
20
21#include <stdbool.h>
22#include <stdint.h>
23
27#include "dt/dt_sensor_ctrl.h" // Generated.
28
29#ifdef __cplusplus
30extern "C" {
31#endif // __cplusplus
32
33/**
34 * A handle to sensor_ctrl.
35 *
36 * This type should be treated as opaque by users.
37 */
38typedef struct dif_sensor_ctrl {
39 /**
40 * The base address for the sensor_ctrl hardware registers.
41 */
43 /**
44 * The instance, set to `kDtSensorCtrlCount` if not initialized
45 * through `dif_sensor_ctrl_init_from_dt`.
46 */
49
50/**
51 * Creates a new handle for a(n) sensor_ctrl peripheral.
52 *
53 * This function does not actuate the hardware.
54 *
55 * @param base_addr The MMIO base address of the sensor_ctrl peripheral.
56 * @param[out] sensor_ctrl 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_sensor_ctrl_t *sensor_ctrl);
66
67/**
68 * Creates a new handle for a(n) sensor_ctrl peripheral.
69 *
70 * This function does not actuate the hardware.
71 *
72 * @param dt The devicetable description of the device.
73 * @param[out] sensor_ctrl Out param for the initialized handle.
74 * @return The result of the operation.
75 */
79 dif_sensor_ctrl_t *sensor_ctrl);
80
81/**
82 * Get the DT handle from this DIF.
83 *
84 * If this DIF was initialized by `dif_sensor_ctrl_init_from_dt(dt, ..)`
85 * then this function will return `dt`. Otherwise it will return an error.
86 *
87 * @param sensor_ctrl A sensor_ctrl handle.
88 * @param[out] dt DT handle.
89 * @return `kDifBadArg` if the DIF has no DT information, `kDifOk` otherwise.
90 */
93 const dif_sensor_ctrl_t *sensor_ctrl,
95
96 /**
97 * A sensor_ctrl alert type.
98 */
99 typedef enum dif_sensor_ctrl_alert {
100 /**
101 * Recoverable sensor_ctrl alerts
102 */
104 /**
105 * Fatal sensor_ctrl alerts
106 */
109
110 /**
111 * Forces a particular alert, causing it to be escalated as if the hardware
112 * had raised it.
113 *
114 * @param sensor_ctrl A sensor_ctrl handle.
115 * @param alert The alert to force.
116 * @return The result of the operation.
117 */
120 const dif_sensor_ctrl_t *sensor_ctrl,
122
123 // DEPRECATED This typedef exists solely for the transition to
124 // dt-based interrupt numbers and will be removed in the future.
125 typedef dt_sensor_ctrl_irq_t dif_sensor_ctrl_irq_t;
126
127 /**
128 * A sensor_ctrl interrupt request type.
129 *
130 * DEPRECATED Use `dt_sensor_ctrl_irq_t` instead.
131 * This enumeration exists solely for the transition to
132 * dt-based interrupt numbers and will be removed in the future.
133 *
134 * The following are defines to keep the types consistent with DT.
135 */
136 /**
137 * Io power status has changed
138 */
139#define kDifSensorCtrlIrqIoStatusChange kDtSensorCtrlIrqIoStatusChange
140 /**
141 * Ast init status has changed
142 */
143#define kDifSensorCtrlIrqInitStatusChange kDtSensorCtrlIrqInitStatusChange
144
145 /**
146 * A snapshot of the state of the interrupts for this IP.
147 *
148 * This is an opaque type, to be used with the `dif_sensor_ctrl_irq_get_state()`
149 * and `dif_sensor_ctrl_irq_acknowledge_state()` functions.
150 */
152
153 /**
154 * Returns the type of a given interrupt (i.e., event or status) for this IP.
155 *
156 * @param sensor_ctrl A sensor_ctrl handle.
157 * @param irq An interrupt request.
158 * @param[out] type Out-param for the interrupt type.
159 * @return The result of the operation.
160 */
163 const dif_sensor_ctrl_t *sensor_ctrl,
164 dif_sensor_ctrl_irq_t,
165 dif_irq_type_t *type);
166
167 /**
168 * Returns the state of all interrupts (i.e., pending or not) for this IP.
169 *
170 * @param sensor_ctrl A sensor_ctrl handle.
171 * @param[out] snapshot Out-param for interrupt state snapshot.
172 * @return The result of the operation.
173 */
176 const dif_sensor_ctrl_t *sensor_ctrl,
178
179 /**
180 * Returns whether a particular interrupt is currently pending.
181 *
182 * @param sensor_ctrl A sensor_ctrl handle.
183 * @param irq An interrupt request.
184 * @param[out] is_pending Out-param for whether the interrupt is pending.
185 * @return The result of the operation.
186 */
189 const dif_sensor_ctrl_t *sensor_ctrl,
190 dif_sensor_ctrl_irq_t,
191 bool *is_pending);
192
193 /**
194 * Acknowledges all interrupts that were pending at the time of the state
195 * snapshot.
196 *
197 * @param sensor_ctrl A sensor_ctrl handle.
198 * @param snapshot Interrupt state snapshot.
199 * @return The result of the operation.
200 */
203 const dif_sensor_ctrl_t *sensor_ctrl,
205
206 /**
207 * Acknowledges all interrupts, indicating to the hardware that all
208 * interrupts have been successfully serviced.
209 *
210 * @param sensor_ctrl A sensor_ctrl handle.
211 * @return The result of the operation.
212 */
215 const dif_sensor_ctrl_t *sensor_ctrl
216 );
217
218 /**
219 * Acknowledges a particular interrupt, indicating to the hardware that it has
220 * been successfully serviced.
221 *
222 * @param sensor_ctrl A sensor_ctrl handle.
223 * @param irq An interrupt request.
224 * @return The result of the operation.
225 */
228 const dif_sensor_ctrl_t *sensor_ctrl,
229 dif_sensor_ctrl_irq_t);
230
231 /**
232 * Forces a particular interrupt, causing it to be serviced as if hardware had
233 * asserted it.
234 *
235 * @param sensor_ctrl A sensor_ctrl handle.
236 * @param irq An interrupt request.
237 * @param val Value to be set.
238 * @return The result of the operation.
239 */
242 const dif_sensor_ctrl_t *sensor_ctrl,
243 dif_sensor_ctrl_irq_t,
244 const bool val);
245
246 /**
247 * A snapshot of the enablement state of the interrupts for this IP.
248 *
249 * This is an opaque type, to be used with the
250 * `dif_sensor_ctrl_irq_disable_all()` and `dif_sensor_ctrl_irq_restore_all()`
251 * functions.
252 */
254
255 /**
256 * Checks whether a particular interrupt is currently enabled or disabled.
257 *
258 * @param sensor_ctrl A sensor_ctrl handle.
259 * @param irq An interrupt request.
260 * @param[out] state Out-param toggle state of the interrupt.
261 * @return The result of the operation.
262 */
265 const dif_sensor_ctrl_t *sensor_ctrl,
266 dif_sensor_ctrl_irq_t,
267 dif_toggle_t *state);
268
269 /**
270 * Sets whether a particular interrupt is currently enabled or disabled.
271 *
272 * @param sensor_ctrl A sensor_ctrl handle.
273 * @param irq An interrupt request.
274 * @param state The new toggle state for the interrupt.
275 * @return The result of the operation.
276 */
279 const dif_sensor_ctrl_t *sensor_ctrl,
280 dif_sensor_ctrl_irq_t,
281 dif_toggle_t state);
282
283 /**
284 * Disables all interrupts, optionally snapshotting all enable states for later
285 * restoration.
286 *
287 * @param sensor_ctrl A sensor_ctrl handle.
288 * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
289 * @return The result of the operation.
290 */
293 const dif_sensor_ctrl_t *sensor_ctrl,
295
296 /**
297 * Restores interrupts from the given (enable) snapshot.
298 *
299 * @param sensor_ctrl A sensor_ctrl handle.
300 * @param snapshot A snapshot to restore from.
301 * @return The result of the operation.
302 */
305 const dif_sensor_ctrl_t *sensor_ctrl,
307
308
309#ifdef __cplusplus
310} // extern "C"
311#endif // __cplusplus
312
313#endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_SENSOR_CTRL_AUTOGEN_H_