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