Software APIs
sensor_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_SENSOR_CTRL_H_
8#define OPENTITAN_DT_SENSOR_CTRL_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif // __cplusplus
13
14/**
15 * @file
16 * @brief Device Tables (DT) for IP sensor_ctrl and top earlgrey.
17 *
18 * This file contains the type definitions and global functions of the sensor_ctrl.
19 */
20
21#include "hw/top/dt/api.h"
22#include <stdint.h>
23
24
25
26/**
27 * List of instances.
28 */
29typedef enum dt_sensor_ctrl {
30 kDtSensorCtrlFirst = 0, /**< First instance */
31 kDtSensorCtrlAon = 0, /**< sensor_ctrl_aon */
33
34enum {
35 kDtSensorCtrlCount = 1, /**< Number of instances */
36};
37
38
39/**
40 * List of register blocks.
41 *
42 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
43 */
45 kDtSensorCtrlRegBlockCore = 0, /**< */
47
48enum {
49 kDtSensorCtrlRegBlockCount = 1, /**< Number of register blocks */
50};
51
52
53/** Primary register block (associated with the "primary" set of registers that control the IP). */
54static const dt_sensor_ctrl_reg_block_t kDtSensorCtrlRegBlockPrimary = kDtSensorCtrlRegBlockCore;
55
56/**
57 * List of IRQs.
58 *
59 * IRQs are guaranteed to be numbered consecutively from 0.
60 */
61typedef enum dt_sensor_ctrl_irq {
62 kDtSensorCtrlIrqIoStatusChange = 0, /**< io power status has changed */
63 kDtSensorCtrlIrqInitStatusChange = 1, /**< ast init status has changed */
65
66enum {
67 kDtSensorCtrlIrqCount = 2, /**< Number of IRQs */
68};
69
70
71/**
72 * List of Alerts.
73 *
74 * Alerts are guaranteed to be numbered consecutively from 0.
75 */
77 kDtSensorCtrlAlertRecovAlert = 0, /**< recoverable sensor_ctrl alerts */
78 kDtSensorCtrlAlertFatalAlert = 1, /**< fatal sensor_ctrl alerts */
80
81enum {
82 kDtSensorCtrlAlertCount = 2, /**< Number of Alerts */
83};
84
85
86/**
87 * List of clock ports.
88 *
89 * Clock ports are guaranteed to be numbered consecutively from 0.
90 */
92 kDtSensorCtrlClockClk = 0, /**< Clock port clk_i */
93 kDtSensorCtrlClockAon = 1, /**< Clock port clk_aon_i */
95
96enum {
97 kDtSensorCtrlClockCount = 2, /**< Number of clock ports */
98};
99
100
101/**
102 * List of reset ports.
103 *
104 * Reset ports are guaranteed to be numbered consecutively from 0.
105 */
107 kDtSensorCtrlResetRst = 0, /**< Reset port rst_ni */
108 kDtSensorCtrlResetAon = 1, /**< Reset port rst_aon_ni */
110
111enum {
112 kDtSensorCtrlResetCount = 2, /**< Number of reset ports */
113};
114
115
116/**
117 * List of peripheral I/O.
118 *
119 * Peripheral I/O are guaranteed to be numbered consecutively from 0.
120 */
122 kDtSensorCtrlPeriphIoAstDebugOut0 = 0, /**< */
123 kDtSensorCtrlPeriphIoAstDebugOut1 = 1, /**< */
124 kDtSensorCtrlPeriphIoAstDebugOut2 = 2, /**< */
125 kDtSensorCtrlPeriphIoAstDebugOut3 = 3, /**< */
126 kDtSensorCtrlPeriphIoAstDebugOut4 = 4, /**< */
127 kDtSensorCtrlPeriphIoAstDebugOut5 = 5, /**< */
128 kDtSensorCtrlPeriphIoAstDebugOut6 = 6, /**< */
129 kDtSensorCtrlPeriphIoAstDebugOut7 = 7, /**< */
130 kDtSensorCtrlPeriphIoAstDebugOut8 = 8, /**< */
132
133enum {
134 kDtSensorCtrlPeriphIoCount = 9, /**< Number of peripheral I/O */
135};
136
137
138/**
139 * List of wakeups.
140 *
141 * Wakeups are guaranteed to be numbered consecutively from 0.
142 */
144 kDtSensorCtrlWakeupWkupReq = 0, /**< Raised if an alert event is seen during low power */
146
147enum {
148 kDtSensorCtrlWakeupCount = 1, /**< Number of wakeups */
149};
150
151
152
153/**
154 * Get the sensor_ctrl instance from an instance ID
155 *
156 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
157 *
158 * @param inst_id Instance ID.
159 * @return A sensor_ctrl instance.
160 *
161 * **Note:** This function only makes sense if the instance ID has device type sensor_ctrl,
162 * otherwise the returned value is unspecified.
163 */
165
166/**
167 * Get the instance ID of an instance.
168 *
169 * @param dt Instance of sensor_ctrl.
170 * @return The instance ID of that instance.
171 */
173
174/**
175 * Get the register base address of an instance.
176 *
177 * @param dt Instance of sensor_ctrl.
178 * @param reg_block The register block requested.
179 * @return The register base address of the requested block.
180 */
184
185/**
186 * Get the primary register base address of an instance.
187 *
188 * This is just a convenience function, equivalent to
189 * `dt_sensor_ctrl_reg_block(dt, kDtSensorCtrlRegBlockCore)`
190 *
191 * @param dt Instance of sensor_ctrl.
192 * @return The register base address of the primary register block.
193 */
194static inline uint32_t dt_sensor_ctrl_primary_reg_block(
195 dt_sensor_ctrl_t dt) {
196 return dt_sensor_ctrl_reg_block(dt, kDtSensorCtrlRegBlockCore);
197}
198
199/**
200 * Get the PLIC ID of a sensor_ctrl IRQ for a given instance.
201 *
202 * If the instance is not connected to the PLIC, this function
203 * will return `kDtPlicIrqIdNone`.
204 *
205 * @param dt Instance of sensor_ctrl.
206 * @param irq A sensor_ctrl IRQ.
207 * @return The PLIC ID of the IRQ of this instance.
208 */
212
213/**
214 * Convert a global IRQ ID to a local sensor_ctrl IRQ type.
215 *
216 * @param dt Instance of sensor_ctrl.
217 * @param irq A PLIC ID that belongs to this instance.
218 * @return The sensor_ctrl IRQ, or `kDtSensorCtrlIrqCount`.
219 *
220 * **Note:** This function assumes that the PLIC ID belongs to the instance
221 * of sensor_ctrl passed in parameter. In other words, it must be the case that
222 * `dt_sensor_ctrl_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
223 * will return `kDtSensorCtrlIrqCount`.
224 */
227 dt_plic_irq_id_t irq);
228
229
230/**
231 * Get the alert ID of a sensor_ctrl alert for a given instance.
232 *
233 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
234 * instances where the instance is not connected, the return value is unspecified.
235 *
236 * @param dt Instance of sensor_ctrl.
237 * @param alert A sensor_ctrl alert.
238 * @return The Alert Handler alert ID of the alert of this instance.
239 */
243
244/**
245 * Convert a global alert ID to a local sensor_ctrl alert type.
246 *
247 * @param dt Instance of sensor_ctrl.
248 * @param alert A global alert ID that belongs to this instance.
249 * @return The sensor_ctrl alert, or `kDtSensorCtrlAlertCount`.
250 *
251 * **Note:** This function assumes that the global alert ID belongs to the
252 * instance of sensor_ctrl passed in parameter. In other words, it must be the case
253 * that `dt_sensor_ctrl_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
254 * this function will return `kDtSensorCtrlAlertCount`.
255 */
258 dt_alert_id_t alert);
259
260
261/**
262 * Get the peripheral I/O description of an instance.
263 *
264 * @param dt Instance of sensor_ctrl.
265 * @param sig Requested peripheral I/O.
266 * @return Description of the requested peripheral I/O for this instance.
267 */
271
272/**
273 * Get the clock signal connected to a clock port of an instance.
274 *
275 * @param dt Instance of sensor_ctrl.
276 * @param clk Clock port.
277 * @return Clock signal.
278 */
282
283/**
284 * Get the reset signal connected to a reset port of an instance.
285 *
286 * @param dt Instance of sensor_ctrl.
287 * @param rst Reset port.
288 * @return Reset signal.
289 */
293
294
295
296#ifdef __cplusplus
297} // extern "C"
298#endif // __cplusplus
299
300#endif // OPENTITAN_DT_SENSOR_CTRL_H_