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 "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 IRQs.
50 *
51 * IRQs are guaranteed to be numbered consecutively from 0.
52 */
53typedef enum dt_adc_ctrl_irq {
54 kDtAdcCtrlIrqMatchPending = 0, /**< ADC match or measurement event has occurred */
55 kDtAdcCtrlIrqCount = 1, /**< \internal Number of IRQs */
57
58/**
59 * List of Alerts.
60 *
61 * Alerts are guaranteed to be numbered consecutively from 0.
62 */
63typedef 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 */
67
68/**
69 * List of clock ports.
70 *
71 * Clock ports are guaranteed to be numbered consecutively from 0.
72 */
73typedef 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 */
78
79/**
80 * List of reset ports.
81 *
82 * Reset ports are guaranteed to be numbered consecutively from 0.
83 */
84typedef 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 */
89
90/**
91 * List of wakeups.
92 *
93 * Wakeups are guaranteed to be numbered consecutively from 0.
94 */
95typedef enum dt_adc_ctrl_wakeup {
96 kDtAdcCtrlWakeupWkupReq = 0, /**< ADC wakeup request */
97 kDtAdcCtrlWakeupCount = 1, /**< \internal Number of wakeups */
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 */
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 */
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 */
137uint32_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 */
150static 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 */
166 dt_adc_ctrl_t dt,
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 */
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 */
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 */
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 */
226 dt_adc_ctrl_t dt,
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 */
237 dt_adc_ctrl_t dt,
239
240
241
242#ifdef __cplusplus
243} // extern "C"
244#endif // __cplusplus
245
246#endif // OPENTITAN_DT_ADC_CTRL_H_