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