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