Software APIs
dt_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/dt_api.h"
22#include <stdint.h>
23
24
25
26/**
27 * List of instances.
28 */
29typedef enum dt_sensor_ctrl {
30 kDtSensorCtrlAon = 0, /**< sensor_ctrl_aon */
31 kDtSensorCtrlFirst = 0, /**< \internal First instance */
32 kDtSensorCtrlCount = 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 kDtSensorCtrlRegBlockCore = 0, /**< */
42 kDtSensorCtrlRegBlockCount = 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_sensor_ctrl_reg_block_t kDtSensorCtrlRegBlockPrimary = kDtSensorCtrlRegBlockCore;
47
48/**
49 * List of memories.
50 *
51 * Memories are guaranteed to start at 0 and to be consecutively numbered.
52 */
54 kDtSensorCtrlMemoryCount = 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_sensor_ctrl_irq {
63 kDtSensorCtrlIrqIoStatusChange = 0, /**< io power status has changed */
64 kDtSensorCtrlIrqInitStatusChange = 1, /**< ast init status has changed */
65 kDtSensorCtrlIrqCount = 2, /**< \internal Number of IRQs */
67
68/**
69 * List of Alerts.
70 *
71 * Alerts are guaranteed to be numbered consecutively from 0.
72 */
74 kDtSensorCtrlAlertRecovAlert = 0, /**< recoverable sensor_ctrl alerts */
75 kDtSensorCtrlAlertFatalAlert = 1, /**< fatal sensor_ctrl alerts */
76 kDtSensorCtrlAlertCount = 2, /**< \internal Number of Alerts */
78
79/**
80 * List of clock ports.
81 *
82 * Clock ports are guaranteed to be numbered consecutively from 0.
83 */
85 kDtSensorCtrlClockClk = 0, /**< Clock port clk_i */
86 kDtSensorCtrlClockAon = 1, /**< Clock port clk_aon_i */
87 kDtSensorCtrlClockCount = 2, /**< \internal Number of clock ports */
89
90/**
91 * List of reset ports.
92 *
93 * Reset ports are guaranteed to be numbered consecutively from 0.
94 */
96 kDtSensorCtrlResetRst = 0, /**< Reset port rst_ni */
97 kDtSensorCtrlResetAon = 1, /**< Reset port rst_aon_ni */
98 kDtSensorCtrlResetCount = 2, /**< \internal Number of reset ports */
100
101/**
102 * List of peripheral I/O.
103 *
104 * Peripheral I/O are guaranteed to be numbered consecutively from 0.
105 */
107 kDtSensorCtrlPeriphIoAstDebugOut0 = 0, /**< */
108 kDtSensorCtrlPeriphIoAstDebugOut1 = 1, /**< */
109 kDtSensorCtrlPeriphIoAstDebugOut2 = 2, /**< */
110 kDtSensorCtrlPeriphIoAstDebugOut3 = 3, /**< */
111 kDtSensorCtrlPeriphIoAstDebugOut4 = 4, /**< */
112 kDtSensorCtrlPeriphIoAstDebugOut5 = 5, /**< */
113 kDtSensorCtrlPeriphIoAstDebugOut6 = 6, /**< */
114 kDtSensorCtrlPeriphIoAstDebugOut7 = 7, /**< */
115 kDtSensorCtrlPeriphIoAstDebugOut8 = 8, /**< */
116 kDtSensorCtrlPeriphIoCount = 9, /**< \internal Number of peripheral I/O */
118
119/**
120 * List of wakeups.
121 *
122 * Wakeups are guaranteed to be numbered consecutively from 0.
123 */
125 kDtSensorCtrlWakeupWkupReq = 0, /**< Raised if an alert event is seen during low power */
126 kDtSensorCtrlWakeupCount = 1, /**< \internal Number of wakeups */
128
129
130/**
131 * Get the sensor_ctrl instance from an instance ID
132 *
133 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
134 *
135 * @param inst_id Instance ID.
136 * @return A sensor_ctrl instance.
137 *
138 * **Note:** This function only makes sense if the instance ID has device type sensor_ctrl,
139 * otherwise the returned value is unspecified.
140 */
142
143/**
144 * Get the instance ID of an instance.
145 *
146 * @param dt Instance of sensor_ctrl.
147 * @return The instance ID of that instance.
148 */
150
151/**
152 * Get the register base address of an instance.
153 *
154 * @param dt Instance of sensor_ctrl.
155 * @param reg_block The register block requested.
156 * @return The register base address of the requested block.
157 */
161
162/**
163 * Get the primary register base address of an instance.
164 *
165 * This is just a convenience function, equivalent to
166 * `dt_sensor_ctrl_reg_block(dt, kDtSensorCtrlRegBlockCore)`
167 *
168 * @param dt Instance of sensor_ctrl.
169 * @return The register base address of the primary register block.
170 */
171static inline uint32_t dt_sensor_ctrl_primary_reg_block(
172 dt_sensor_ctrl_t dt) {
173 return dt_sensor_ctrl_reg_block(dt, kDtSensorCtrlRegBlockCore);
174}
175
176/**
177 * Get the base address of a memory.
178 *
179 * @param dt Instance of sensor_ctrl.
180 * @param mem The memory requested.
181 * @return The base address of the requested memory.
182 */
186
187/**
188 * Get the size of a memory.
189 *
190 * @param dt Instance of sensor_ctrl.
191 * @param mem The memory requested.
192 * @return The size of the requested memory.
193 */
197
198/**
199 * Get the PLIC ID of a sensor_ctrl IRQ for a given instance.
200 *
201 * If the instance is not connected to the PLIC, this function
202 * will return `kDtPlicIrqIdNone`.
203 *
204 * @param dt Instance of sensor_ctrl.
205 * @param irq A sensor_ctrl IRQ.
206 * @return The PLIC ID of the IRQ of this instance.
207 */
211
212/**
213 * Convert a global IRQ ID to a local sensor_ctrl IRQ type.
214 *
215 * @param dt Instance of sensor_ctrl.
216 * @param irq A PLIC ID that belongs to this instance.
217 * @return The sensor_ctrl IRQ, or `kDtSensorCtrlIrqCount`.
218 *
219 * **Note:** This function assumes that the PLIC ID belongs to the instance
220 * of sensor_ctrl passed in parameter. In other words, it must be the case that
221 * `dt_sensor_ctrl_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
222 * will return `kDtSensorCtrlIrqCount`.
223 */
226 dt_plic_irq_id_t irq);
227
228
229/**
230 * Get the alert ID of a sensor_ctrl alert for a given instance.
231 *
232 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
233 * instances where the instance is not connected, the return value is unspecified.
234 *
235 * @param dt Instance of sensor_ctrl.
236 * @param alert A sensor_ctrl alert.
237 * @return The Alert Handler alert ID of the alert of this instance.
238 */
242
243/**
244 * Convert a global alert ID to a local sensor_ctrl alert type.
245 *
246 * @param dt Instance of sensor_ctrl.
247 * @param alert A global alert ID that belongs to this instance.
248 * @return The sensor_ctrl alert, or `kDtSensorCtrlAlertCount`.
249 *
250 * **Note:** This function assumes that the global alert ID belongs to the
251 * instance of sensor_ctrl passed in parameter. In other words, it must be the case
252 * that `dt_sensor_ctrl_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
253 * this function will return `kDtSensorCtrlAlertCount`.
254 */
257 dt_alert_id_t alert);
258
259
260/**
261 * Get the peripheral I/O description of an instance.
262 *
263 * @param dt Instance of sensor_ctrl.
264 * @param sig Requested peripheral I/O.
265 * @return Description of the requested peripheral I/O for this instance.
266 */
270
271/**
272 * Get the clock signal connected to a clock port of an instance.
273 *
274 * @param dt Instance of sensor_ctrl.
275 * @param clk Clock port.
276 * @return Clock signal.
277 */
281
282/**
283 * Get the reset signal connected to a reset port of an instance.
284 *
285 * @param dt Instance of sensor_ctrl.
286 * @param rst Reset port.
287 * @return Reset signal.
288 */
292
293
294
295#ifdef __cplusplus
296} // extern "C"
297#endif // __cplusplus
298
299#endif // OPENTITAN_DT_SENSOR_CTRL_H_