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 "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 IRQs.
50 *
51 * IRQs are guaranteed to be numbered consecutively from 0.
52 */
53typedef enum dt_sensor_ctrl_irq {
54 kDtSensorCtrlIrqIoStatusChange = 0, /**< io power status has changed */
55 kDtSensorCtrlIrqInitStatusChange = 1, /**< ast init status has changed */
56 kDtSensorCtrlIrqCount = 2, /**< \internal Number of IRQs */
58
59/**
60 * List of Alerts.
61 *
62 * Alerts are guaranteed to be numbered consecutively from 0.
63 */
65 kDtSensorCtrlAlertRecovAlert = 0, /**< recoverable sensor_ctrl alerts */
66 kDtSensorCtrlAlertFatalAlert = 1, /**< fatal sensor_ctrl alerts */
67 kDtSensorCtrlAlertCount = 2, /**< \internal Number of Alerts */
69
70/**
71 * List of clock ports.
72 *
73 * Clock ports are guaranteed to be numbered consecutively from 0.
74 */
76 kDtSensorCtrlClockClk = 0, /**< Clock port clk_i */
77 kDtSensorCtrlClockAon = 1, /**< Clock port clk_aon_i */
78 kDtSensorCtrlClockCount = 2, /**< \internal Number of clock ports */
80
81/**
82 * List of reset ports.
83 *
84 * Reset ports are guaranteed to be numbered consecutively from 0.
85 */
87 kDtSensorCtrlResetRst = 0, /**< Reset port rst_ni */
88 kDtSensorCtrlResetAon = 1, /**< Reset port rst_aon_ni */
89 kDtSensorCtrlResetCount = 2, /**< \internal Number of reset ports */
91
92/**
93 * List of peripheral I/O.
94 *
95 * Peripheral I/O are guaranteed to be numbered consecutively from 0.
96 */
98 kDtSensorCtrlPeriphIoAstDebugOut0 = 0, /**< */
99 kDtSensorCtrlPeriphIoAstDebugOut1 = 1, /**< */
100 kDtSensorCtrlPeriphIoAstDebugOut2 = 2, /**< */
101 kDtSensorCtrlPeriphIoAstDebugOut3 = 3, /**< */
102 kDtSensorCtrlPeriphIoAstDebugOut4 = 4, /**< */
103 kDtSensorCtrlPeriphIoAstDebugOut5 = 5, /**< */
104 kDtSensorCtrlPeriphIoAstDebugOut6 = 6, /**< */
105 kDtSensorCtrlPeriphIoAstDebugOut7 = 7, /**< */
106 kDtSensorCtrlPeriphIoAstDebugOut8 = 8, /**< */
107 kDtSensorCtrlPeriphIoCount = 9, /**< \internal Number of peripheral I/O */
109
110/**
111 * List of wakeups.
112 *
113 * Wakeups are guaranteed to be numbered consecutively from 0.
114 */
116 kDtSensorCtrlWakeupWkupReq = 0, /**< Raised if an alert event is seen during low power */
117 kDtSensorCtrlWakeupCount = 1, /**< \internal Number of wakeups */
119
120
121/**
122 * Get the sensor_ctrl instance from an instance ID
123 *
124 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
125 *
126 * @param inst_id Instance ID.
127 * @return A sensor_ctrl instance.
128 *
129 * **Note:** This function only makes sense if the instance ID has device type sensor_ctrl,
130 * otherwise the returned value is unspecified.
131 */
133
134/**
135 * Get the instance ID of an instance.
136 *
137 * @param dt Instance of sensor_ctrl.
138 * @return The instance ID of that instance.
139 */
141
142/**
143 * Get the register base address of an instance.
144 *
145 * @param dt Instance of sensor_ctrl.
146 * @param reg_block The register block requested.
147 * @return The register base address of the requested block.
148 */
152
153/**
154 * Get the primary register base address of an instance.
155 *
156 * This is just a convenience function, equivalent to
157 * `dt_sensor_ctrl_reg_block(dt, kDtSensorCtrlRegBlockCore)`
158 *
159 * @param dt Instance of sensor_ctrl.
160 * @return The register base address of the primary register block.
161 */
162static inline uint32_t dt_sensor_ctrl_primary_reg_block(
163 dt_sensor_ctrl_t dt) {
164 return dt_sensor_ctrl_reg_block(dt, kDtSensorCtrlRegBlockCore);
165}
166
167/**
168 * Get the PLIC ID of a sensor_ctrl IRQ for a given instance.
169 *
170 * If the instance is not connected to the PLIC, this function
171 * will return `kDtPlicIrqIdNone`.
172 *
173 * @param dt Instance of sensor_ctrl.
174 * @param irq A sensor_ctrl IRQ.
175 * @return The PLIC ID of the IRQ of this instance.
176 */
180
181/**
182 * Convert a global IRQ ID to a local sensor_ctrl IRQ type.
183 *
184 * @param dt Instance of sensor_ctrl.
185 * @param irq A PLIC ID that belongs to this instance.
186 * @return The sensor_ctrl IRQ, or `kDtSensorCtrlIrqCount`.
187 *
188 * **Note:** This function assumes that the PLIC ID belongs to the instance
189 * of sensor_ctrl passed in parameter. In other words, it must be the case that
190 * `dt_sensor_ctrl_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
191 * will return `kDtSensorCtrlIrqCount`.
192 */
195 dt_plic_irq_id_t irq);
196
197
198/**
199 * Get the alert ID of a sensor_ctrl alert for a given instance.
200 *
201 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
202 * instances where the instance is not connected, the return value is unspecified.
203 *
204 * @param dt Instance of sensor_ctrl.
205 * @param alert A sensor_ctrl alert.
206 * @return The Alert Handler alert ID of the alert of this instance.
207 */
211
212/**
213 * Convert a global alert ID to a local sensor_ctrl alert type.
214 *
215 * @param dt Instance of sensor_ctrl.
216 * @param alert A global alert ID that belongs to this instance.
217 * @return The sensor_ctrl alert, or `kDtSensorCtrlAlertCount`.
218 *
219 * **Note:** This function assumes that the global alert ID belongs to the
220 * instance of sensor_ctrl passed in parameter. In other words, it must be the case
221 * that `dt_sensor_ctrl_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
222 * this function will return `kDtSensorCtrlAlertCount`.
223 */
226 dt_alert_id_t alert);
227
228
229/**
230 * Get the peripheral I/O description of an instance.
231 *
232 * @param dt Instance of sensor_ctrl.
233 * @param sig Requested peripheral I/O.
234 * @return Description of the requested peripheral I/O for this instance.
235 */
239
240/**
241 * Get the clock signal connected to a clock port of an instance.
242 *
243 * @param dt Instance of sensor_ctrl.
244 * @param clk Clock port.
245 * @return Clock signal.
246 */
250
251/**
252 * Get the reset signal connected to a reset port of an instance.
253 *
254 * @param dt Instance of sensor_ctrl.
255 * @param rst Reset port.
256 * @return Reset signal.
257 */
261
262
263
264#ifdef __cplusplus
265} // extern "C"
266#endif // __cplusplus
267
268#endif // OPENTITAN_DT_SENSOR_CTRL_H_