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
11extern "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 */
29typedef enum dt_adc_ctrl {
30 kDtAdcCtrlAon = 0, /**< adc_ctrl_aon */
31 kDtAdcCtrlFirst = 0, /**< \internal First instance */
32 kDtAdcCtrlCount = 1, /**< \internal Number of instances */
34
35/**
36 * List of register blocks.
37 *
38 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
39 */
41 kDtAdcCtrlRegBlockCore = 0, /**< */
42 kDtAdcCtrlRegBlockCount = 1, /**< \internal Number of register blocks */
44
45/** Primary register block (associated with the "primary" set of registers that control the IP). */
46static 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 */
53typedef enum dt_adc_ctrl_memory {
54 kDtAdcCtrlMemoryCount = 0, /**< \internal Number of memories */
56
57/**
58 * List of IRQs.
59 *
60 * IRQs are guaranteed to be numbered consecutively from 0.
61 */
62typedef enum dt_adc_ctrl_irq {
63 kDtAdcCtrlIrqMatchPending = 0, /**< ADC match or measurement event has occurred */
64 kDtAdcCtrlIrqCount = 1, /**< \internal Number of IRQs */
66
67/**
68 * List of Alerts.
69 *
70 * Alerts are guaranteed to be numbered consecutively from 0.
71 */
72typedef 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 */
76
77/**
78 * List of clock ports.
79 *
80 * Clock ports are guaranteed to be numbered consecutively from 0.
81 */
82typedef 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 */
87
88/**
89 * List of reset ports.
90 *
91 * Reset ports are guaranteed to be numbered consecutively from 0.
92 */
93typedef 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 */
98
99/**
100 * List of wakeups.
101 *
102 * Wakeups are guaranteed to be numbered consecutively from 0.
103 */
104typedef enum dt_adc_ctrl_wakeup {
105 kDtAdcCtrlWakeupWkupReq = 0, /**< ADC wakeup request */
106 kDtAdcCtrlWakeupCount = 1, /**< \internal Number of wakeups */
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 */
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 */
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 */
146uint32_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 */
159static 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 */
172 dt_adc_ctrl_t dt,
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 */
183 dt_adc_ctrl_t dt,
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 */
197 dt_adc_ctrl_t dt,
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 */
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 */
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 */
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 */
257 dt_adc_ctrl_t dt,
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 */
268 dt_adc_ctrl_t dt,
270
271
272
273#ifdef __cplusplus
274} // extern "C"
275#endif // __cplusplus
276
277#endif // OPENTITAN_DT_ADC_CTRL_H_