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