Pavona Software APIs
dif_adc_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_ADC_CTRL_AUTOGEN_H_
8
#define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_ADC_CTRL_AUTOGEN_H_
9
10
// THIS FILE HAS BEEN GENERATED, DO NOT EDIT MANUALLY. COMMAND:
11
// util/autogen_dif.py -i hw/ip/adc_ctrl/data/adc_ctrl.hjson -o
12
// bazel-out/k8-fastbuild/bin/sw/device/lib/dif/autogen
13
14
15
/**
16
* @file
17
* @brief <a href="/book/hw/ip/adc_ctrl/">ADC_CTRL</a> Device Interface Functions
18
*/
19
20
#include <stdbool.h>
21
#include <stdint.h>
22
23
#include "
sw/device/lib/base/macros.h
"
24
#include "
sw/device/lib/base/mmio.h
"
25
#include "
sw/device/lib/dif/dif_base.h
"
26
#include "
hw/top/dt/adc_ctrl.h
"
// Generated.
27
28
#ifdef __cplusplus
29
extern
"C"
{
30
#endif
// __cplusplus
31
32
/**
33
* A handle to adc_ctrl.
34
*
35
* This type should be treated as opaque by users.
36
*/
37
typedef
struct
dif_adc_ctrl
{
38
/**
39
* The base address for the adc_ctrl hardware registers.
40
*/
41
mmio_region_t
base_addr
;
42
/**
43
* The instance, set to `kDtAdcCtrlCount` if not initialized
44
* through `dif_adc_ctrl_init_from_dt`.
45
*/
46
dt_adc_ctrl_t
dt
;
47
}
dif_adc_ctrl_t
;
48
49
/**
50
* Creates a new handle for a(n) adc_ctrl peripheral.
51
*
52
* This function does not actuate the hardware.
53
*
54
* @param base_addr The MMIO base address of the adc_ctrl peripheral.
55
* @param[out] adc_ctrl Out param for the initialized handle.
56
* @return The result of the operation.
57
*
58
* DEPRECATED This function exists solely for the transition to
59
* dt-based DIFs and will be removed in the future.
60
*/
61
OT_WARN_UNUSED_RESULT
62
dif_result_t
dif_adc_ctrl_init
(
63
mmio_region_t
base_addr,
64
dif_adc_ctrl_t
*adc_ctrl);
65
66
/**
67
* Creates a new handle for a(n) adc_ctrl peripheral.
68
*
69
* This function does not actuate the hardware.
70
*
71
* @param dt The devicetable description of the device.
72
* @param[out] adc_ctrl Out param for the initialized handle.
73
* @return The result of the operation.
74
*/
75
OT_WARN_UNUSED_RESULT
76
dif_result_t
dif_adc_ctrl_init_from_dt
(
77
dt_adc_ctrl_t
dt,
78
dif_adc_ctrl_t
*adc_ctrl);
79
80
/**
81
* Get the DT handle from this DIF.
82
*
83
* If this DIF was initialized by `dif_adc_ctrl_init_from_dt(dt, ..)`
84
* then this function will return `dt`. Otherwise it will return an error.
85
*
86
* @param adc_ctrl A adc_ctrl handle.
87
* @param[out] dt DT handle.
88
* @return `kDifBadArg` if the DIF has no DT information, `kDifOk` otherwise.
89
*/
90
OT_WARN_UNUSED_RESULT
91
dif_result_t
dif_adc_ctrl_get_dt
(
92
const
dif_adc_ctrl_t
*adc_ctrl,
93
dt_adc_ctrl_t
*dt);
94
95
/**
96
* A adc_ctrl alert type.
97
*/
98
typedef
enum
dif_adc_ctrl_alert
{
99
/**
100
* This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected.
101
*/
102
kDifAdcCtrlAlertFatalFault
= 0,
103
}
dif_adc_ctrl_alert_t
;
104
105
/**
106
* Forces a particular alert, causing it to be escalated as if the hardware
107
* had raised it.
108
*
109
* @param adc_ctrl A adc_ctrl handle.
110
* @param alert The alert to force.
111
* @return The result of the operation.
112
*/
113
OT_WARN_UNUSED_RESULT
114
dif_result_t
dif_adc_ctrl_alert_force
(
115
const
dif_adc_ctrl_t
*adc_ctrl,
116
dif_adc_ctrl_alert_t
alert);
117
118
// DEPRECATED This typedef exists solely for the transition to
119
// dt-based interrupt numbers and will be removed in the future.
120
typedef
dt_adc_ctrl_irq_t
dif_adc_ctrl_irq_t;
121
122
/**
123
* A adc_ctrl interrupt request type.
124
*
125
* DEPRECATED Use `dt_adc_ctrl_irq_t` instead.
126
* This enumeration exists solely for the transition to
127
* dt-based interrupt numbers and will be removed in the future.
128
*
129
* The following are defines to keep the types consistent with DT.
130
*/
131
/**
132
* ADC match or measurement event has occurred.
133
*/
134
#define kDifAdcCtrlIrqMatchPending kDtAdcCtrlIrqMatchPending
135
136
/**
137
* A snapshot of the state of the interrupts for this IP.
138
*
139
* This is an opaque type, to be used with the `dif_adc_ctrl_irq_get_state()`
140
* and `dif_adc_ctrl_irq_acknowledge_state()` functions.
141
*/
142
typedef
uint32_t
dif_adc_ctrl_irq_state_snapshot_t
;
143
144
/**
145
* Returns the type of a given interrupt (i.e., event or status) for this IP.
146
*
147
* @param adc_ctrl A adc_ctrl handle.
148
* @param irq An interrupt request.
149
* @param[out] type Out-param for the interrupt type.
150
* @return The result of the operation.
151
*/
152
OT_WARN_UNUSED_RESULT
153
dif_result_t
dif_adc_ctrl_irq_get_type
(
154
const
dif_adc_ctrl_t
*adc_ctrl,
155
dif_adc_ctrl_irq_t,
156
dif_irq_type_t
*type);
157
158
/**
159
* Returns the state of all interrupts (i.e., pending or not) for this IP.
160
*
161
* @param adc_ctrl A adc_ctrl handle.
162
* @param[out] snapshot Out-param for interrupt state snapshot.
163
* @return The result of the operation.
164
*/
165
OT_WARN_UNUSED_RESULT
166
dif_result_t
dif_adc_ctrl_irq_get_state
(
167
const
dif_adc_ctrl_t
*adc_ctrl,
168
dif_adc_ctrl_irq_state_snapshot_t
*snapshot);
169
170
/**
171
* Returns whether a particular interrupt is currently pending.
172
*
173
* @param adc_ctrl A adc_ctrl handle.
174
* @param irq An interrupt request.
175
* @param[out] is_pending Out-param for whether the interrupt is pending.
176
* @return The result of the operation.
177
*/
178
OT_WARN_UNUSED_RESULT
179
dif_result_t
dif_adc_ctrl_irq_is_pending
(
180
const
dif_adc_ctrl_t
*adc_ctrl,
181
dif_adc_ctrl_irq_t,
182
bool
*is_pending);
183
184
/**
185
* Acknowledges all interrupts that were pending at the time of the state
186
* snapshot.
187
*
188
* @param adc_ctrl A adc_ctrl handle.
189
* @param snapshot Interrupt state snapshot.
190
* @return The result of the operation.
191
*/
192
OT_WARN_UNUSED_RESULT
193
dif_result_t
dif_adc_ctrl_irq_acknowledge_state
(
194
const
dif_adc_ctrl_t
*adc_ctrl,
195
dif_adc_ctrl_irq_state_snapshot_t
snapshot);
196
197
/**
198
* Acknowledges all interrupts, indicating to the hardware that all
199
* interrupts have been successfully serviced.
200
*
201
* @param adc_ctrl A adc_ctrl handle.
202
* @return The result of the operation.
203
*/
204
OT_WARN_UNUSED_RESULT
205
dif_result_t
dif_adc_ctrl_irq_acknowledge_all
(
206
const
dif_adc_ctrl_t
*adc_ctrl
207
);
208
209
/**
210
* Acknowledges a particular interrupt, indicating to the hardware that it has
211
* been successfully serviced.
212
*
213
* @param adc_ctrl A adc_ctrl handle.
214
* @param irq An interrupt request.
215
* @return The result of the operation.
216
*/
217
OT_WARN_UNUSED_RESULT
218
dif_result_t
dif_adc_ctrl_irq_acknowledge
(
219
const
dif_adc_ctrl_t
*adc_ctrl,
220
dif_adc_ctrl_irq_t);
221
222
/**
223
* Forces a particular interrupt, causing it to be serviced as if hardware had
224
* asserted it.
225
*
226
* @param adc_ctrl A adc_ctrl handle.
227
* @param irq An interrupt request.
228
* @param val Value to be set.
229
* @return The result of the operation.
230
*/
231
OT_WARN_UNUSED_RESULT
232
dif_result_t
dif_adc_ctrl_irq_force
(
233
const
dif_adc_ctrl_t
*adc_ctrl,
234
dif_adc_ctrl_irq_t,
235
const
bool
val);
236
237
/**
238
* A snapshot of the enablement state of the interrupts for this IP.
239
*
240
* This is an opaque type, to be used with the
241
* `dif_adc_ctrl_irq_disable_all()` and `dif_adc_ctrl_irq_restore_all()`
242
* functions.
243
*/
244
typedef
uint32_t
dif_adc_ctrl_irq_enable_snapshot_t
;
245
246
/**
247
* Checks whether a particular interrupt is currently enabled or disabled.
248
*
249
* @param adc_ctrl A adc_ctrl handle.
250
* @param irq An interrupt request.
251
* @param[out] state Out-param toggle state of the interrupt.
252
* @return The result of the operation.
253
*/
254
OT_WARN_UNUSED_RESULT
255
dif_result_t
dif_adc_ctrl_irq_get_enabled
(
256
const
dif_adc_ctrl_t
*adc_ctrl,
257
dif_adc_ctrl_irq_t,
258
dif_toggle_t
*state);
259
260
/**
261
* Sets whether a particular interrupt is currently enabled or disabled.
262
*
263
* @param adc_ctrl A adc_ctrl handle.
264
* @param irq An interrupt request.
265
* @param state The new toggle state for the interrupt.
266
* @return The result of the operation.
267
*/
268
OT_WARN_UNUSED_RESULT
269
dif_result_t
dif_adc_ctrl_irq_set_enabled
(
270
const
dif_adc_ctrl_t
*adc_ctrl,
271
dif_adc_ctrl_irq_t,
272
dif_toggle_t
state);
273
274
/**
275
* Disables all interrupts, optionally snapshotting all enable states for later
276
* restoration.
277
*
278
* @param adc_ctrl A adc_ctrl handle.
279
* @param[out] snapshot Out-param for the snapshot; may be `NULL`.
280
* @return The result of the operation.
281
*/
282
OT_WARN_UNUSED_RESULT
283
dif_result_t
dif_adc_ctrl_irq_disable_all
(
284
const
dif_adc_ctrl_t
*adc_ctrl,
285
dif_adc_ctrl_irq_enable_snapshot_t
*snapshot);
286
287
/**
288
* Restores interrupts from the given (enable) snapshot.
289
*
290
* @param adc_ctrl A adc_ctrl handle.
291
* @param snapshot A snapshot to restore from.
292
* @return The result of the operation.
293
*/
294
OT_WARN_UNUSED_RESULT
295
dif_result_t
dif_adc_ctrl_irq_restore_all
(
296
const
dif_adc_ctrl_t
*adc_ctrl,
297
const
dif_adc_ctrl_irq_enable_snapshot_t
*snapshot);
298
299
300
#ifdef __cplusplus
301
}
// extern "C"
302
#endif
// __cplusplus
303
304
#endif
// OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_ADC_CTRL_AUTOGEN_H_
(egret)
sw
device
lib
dif
autogen
dif_adc_ctrl_autogen.h
Generated by
1.13.2