Software APIs
adc_ctrl.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
// Device table API auto-generated by `dtgen`
6
7
#ifndef OPENTITAN_DT_ADC_CTRL_H_
8
#define OPENTITAN_DT_ADC_CTRL_H_
9
10
#ifdef __cplusplus
11
extern
"C"
{
12
#endif
// __cplusplus
13
14
/**
15
* @file
16
* @brief Device Tables (DT) for IP adc_ctrl and top earlgrey.
17
*
18
* This file contains the type definitions and global functions of the adc_ctrl.
19
*/
20
21
#include "hw/top/dt/api.h"
22
#include <stdint.h>
23
24
25
26
/**
27
* List of instances.
28
*/
29
typedef
enum
dt_adc_ctrl
{
30
kDtAdcCtrlFirst
= 0,
/**< First instance */
31
kDtAdcCtrlAon
= 0,
/**< adc_ctrl_aon */
32
}
dt_adc_ctrl_t
;
33
34
enum
{
35
kDtAdcCtrlCount
= 1,
/**< Number of instances */
36
};
37
38
39
/**
40
* List of register blocks.
41
*
42
* Register blocks are guaranteed to start at 0 and to be consecutively numbered.
43
*/
44
typedef
enum
dt_adc_ctrl_reg_block
{
45
kDtAdcCtrlRegBlockCore = 0,
/**< */
46
}
dt_adc_ctrl_reg_block_t
;
47
48
enum
{
49
kDtAdcCtrlRegBlockCount
= 1,
/**< Number of register blocks */
50
};
51
52
53
/** Primary register block (associated with the "primary" set of registers that control the IP). */
54
static
const
dt_adc_ctrl_reg_block_t
kDtAdcCtrlRegBlockPrimary = kDtAdcCtrlRegBlockCore;
55
56
/**
57
* List of IRQs.
58
*
59
* IRQs are guaranteed to be numbered consecutively from 0.
60
*/
61
typedef
enum
dt_adc_ctrl_irq
{
62
kDtAdcCtrlIrqMatchPending
= 0,
/**< ADC match or measurement event has occurred */
63
}
dt_adc_ctrl_irq_t
;
64
65
enum
{
66
kDtAdcCtrlIrqCount
= 1,
/**< Number of IRQs */
67
};
68
69
70
/**
71
* List of Alerts.
72
*
73
* Alerts are guaranteed to be numbered consecutively from 0.
74
*/
75
typedef
enum
dt_adc_ctrl_alert
{
76
kDtAdcCtrlAlertFatalFault
= 0,
/**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
77
}
dt_adc_ctrl_alert_t
;
78
79
enum
{
80
kDtAdcCtrlAlertCount
= 1,
/**< Number of Alerts */
81
};
82
83
84
/**
85
* List of clock ports.
86
*
87
* Clock ports are guaranteed to be numbered consecutively from 0.
88
*/
89
typedef
enum
dt_adc_ctrl_clock
{
90
kDtAdcCtrlClockClk
= 0,
/**< Clock port clk_i */
91
kDtAdcCtrlClockAon
= 1,
/**< Clock port clk_aon_i */
92
}
dt_adc_ctrl_clock_t
;
93
94
enum
{
95
kDtAdcCtrlClockCount
= 2,
/**< Number of clock ports */
96
};
97
98
99
/**
100
* List of reset ports.
101
*
102
* Reset ports are guaranteed to be numbered consecutively from 0.
103
*/
104
typedef
enum
dt_adc_ctrl_reset
{
105
kDtAdcCtrlResetRst
= 0,
/**< Reset port rst_ni */
106
kDtAdcCtrlResetAon
= 1,
/**< Reset port rst_aon_ni */
107
}
dt_adc_ctrl_reset_t
;
108
109
enum
{
110
kDtAdcCtrlResetCount
= 2,
/**< Number of reset ports */
111
};
112
113
114
/**
115
* List of wakeups.
116
*
117
* Wakeups are guaranteed to be numbered consecutively from 0.
118
*/
119
typedef
enum
dt_adc_ctrl_wakeup
{
120
kDtAdcCtrlWakeupWkupReq
= 0,
/**< ADC wakeup request */
121
}
dt_adc_ctrl_wakeup_t
;
122
123
enum
{
124
kDtAdcCtrlWakeupCount
= 1,
/**< Number of wakeups */
125
};
126
127
128
/**
129
* List of supported hardware features.
130
*/
131
#define OPENTITAN_ADC_CTRL_HAS_MODE_NORMAL 1
132
#define OPENTITAN_ADC_CTRL_HAS_MODE_LOW_POWER 1
133
#define OPENTITAN_ADC_CTRL_HAS_ONESHOT 1
134
135
136
137
/**
138
* Get the adc_ctrl instance from an instance ID
139
*
140
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
141
*
142
* @param inst_id Instance ID.
143
* @return A adc_ctrl instance.
144
*
145
* **Note:** This function only makes sense if the instance ID has device type adc_ctrl,
146
* otherwise the returned value is unspecified.
147
*/
148
dt_adc_ctrl_t
dt_adc_ctrl_from_instance_id
(
dt_instance_id_t
inst_id);
149
150
/**
151
* Get the instance ID of an instance.
152
*
153
* @param dt Instance of adc_ctrl.
154
* @return The instance ID of that instance.
155
*/
156
dt_instance_id_t
dt_adc_ctrl_instance_id
(
dt_adc_ctrl_t
dt);
157
158
/**
159
* Get the register base address of an instance.
160
*
161
* @param dt Instance of adc_ctrl.
162
* @param reg_block The register block requested.
163
* @return The register base address of the requested block.
164
*/
165
uint32_t
dt_adc_ctrl_reg_block
(
166
dt_adc_ctrl_t
dt,
167
dt_adc_ctrl_reg_block_t
reg_block);
168
169
/**
170
* Get the primary register base address of an instance.
171
*
172
* This is just a convenience function, equivalent to
173
* `dt_adc_ctrl_reg_block(dt, kDtAdcCtrlRegBlockCore)`
174
*
175
* @param dt Instance of adc_ctrl.
176
* @return The register base address of the primary register block.
177
*/
178
static
inline
uint32_t dt_adc_ctrl_primary_reg_block(
179
dt_adc_ctrl_t
dt) {
180
return
dt_adc_ctrl_reg_block
(dt, kDtAdcCtrlRegBlockCore);
181
}
182
183
/**
184
* Get the PLIC ID of a adc_ctrl IRQ for a given instance.
185
*
186
* If the instance is not connected to the PLIC, this function
187
* will return `kDtPlicIrqIdNone`.
188
*
189
* @param dt Instance of adc_ctrl.
190
* @param irq A adc_ctrl IRQ.
191
* @return The PLIC ID of the IRQ of this instance.
192
*/
193
dt_plic_irq_id_t
dt_adc_ctrl_irq_to_plic_id
(
194
dt_adc_ctrl_t
dt,
195
dt_adc_ctrl_irq_t
irq);
196
197
/**
198
* Convert a global IRQ ID to a local adc_ctrl IRQ type.
199
*
200
* @param dt Instance of adc_ctrl.
201
* @param irq A PLIC ID that belongs to this instance.
202
* @return The adc_ctrl IRQ, or `kDtAdcCtrlIrqCount`.
203
*
204
* **Note:** This function assumes that the PLIC ID belongs to the instance
205
* of adc_ctrl passed in parameter. In other words, it must be the case that
206
* `dt_adc_ctrl_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
207
* will return `kDtAdcCtrlIrqCount`.
208
*/
209
dt_adc_ctrl_irq_t
dt_adc_ctrl_irq_from_plic_id
(
210
dt_adc_ctrl_t
dt,
211
dt_plic_irq_id_t
irq);
212
213
214
/**
215
* Get the alert ID of a adc_ctrl alert for a given instance.
216
*
217
* **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
218
* instances where the instance is not connected, the return value is unspecified.
219
*
220
* @param dt Instance of adc_ctrl.
221
* @param alert A adc_ctrl alert.
222
* @return The Alert Handler alert ID of the alert of this instance.
223
*/
224
dt_alert_id_t
dt_adc_ctrl_alert_to_alert_id
(
225
dt_adc_ctrl_t
dt,
226
dt_adc_ctrl_alert_t
alert);
227
228
/**
229
* Convert a global alert ID to a local adc_ctrl alert type.
230
*
231
* @param dt Instance of adc_ctrl.
232
* @param alert A global alert ID that belongs to this instance.
233
* @return The adc_ctrl alert, or `kDtAdcCtrlAlertCount`.
234
*
235
* **Note:** This function assumes that the global alert ID belongs to the
236
* instance of adc_ctrl passed in parameter. In other words, it must be the case
237
* that `dt_adc_ctrl_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
238
* this function will return `kDtAdcCtrlAlertCount`.
239
*/
240
dt_adc_ctrl_alert_t
dt_adc_ctrl_alert_from_alert_id
(
241
dt_adc_ctrl_t
dt,
242
dt_alert_id_t
alert);
243
244
245
246
/**
247
* Get the clock signal connected to a clock port of an instance.
248
*
249
* @param dt Instance of adc_ctrl.
250
* @param clk Clock port.
251
* @return Clock signal.
252
*/
253
dt_clock_t
dt_adc_ctrl_clock
(
254
dt_adc_ctrl_t
dt,
255
dt_adc_ctrl_clock_t
clk);
256
257
/**
258
* Get the reset signal connected to a reset port of an instance.
259
*
260
* @param dt Instance of adc_ctrl.
261
* @param rst Reset port.
262
* @return Reset signal.
263
*/
264
dt_reset_t
dt_adc_ctrl_reset
(
265
dt_adc_ctrl_t
dt,
266
dt_adc_ctrl_reset_t
rst);
267
268
269
270
#ifdef __cplusplus
271
}
// extern "C"
272
#endif
// __cplusplus
273
274
#endif
// OPENTITAN_DT_ADC_CTRL_H_
(earlgrey)
hw
top
dt
adc_ctrl.h
Return to
OpenTitan Documentation