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/**
11 * @file
12 * @brief Device Tables (DT) for IP sensor_ctrl and top earlgrey.
13 *
14 * This file contains the type definitions and global functions of the sensor_ctrl.
15 */
16
17#include "dt_api.h"
18#include <stdint.h>
19
20/**
21 * List of instances.
22 */
23typedef enum dt_sensor_ctrl {
24 kDtSensorCtrlAon = 0, /**< sensor_ctrl_aon */
25 kDtSensorCtrlFirst = 0, /**< \internal First instance */
26 kDtSensorCtrlCount = 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 kDtSensorCtrlRegBlockCore = 0, /**< */
36 kDtSensorCtrlRegBlockCount = 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_sensor_ctrl_reg_block_t kDtSensorCtrlRegBlockPrimary = kDtSensorCtrlRegBlockCore;
41
42/**
43 * List of IRQs.
44 *
45 * IRQs are guaranteed to be numbered consecutively from 0.
46 */
47typedef enum dt_sensor_ctrl_irq {
48 kDtSensorCtrlIrqIoStatusChange = 0, /**< io power status has changed */
49 kDtSensorCtrlIrqInitStatusChange = 1, /**< ast init status has changed */
50 kDtSensorCtrlIrqCount = 2, /**< \internal Number of IRQs */
52
53/**
54 * List of Alerts.
55 *
56 * Alerts are guaranteed to be numbered consecutively from 0.
57 */
59 kDtSensorCtrlAlertRecovAlert = 0, /**< recoverable sensor_ctrl alerts */
60 kDtSensorCtrlAlertFatalAlert = 1, /**< fatal sensor_ctrl alerts */
61 kDtSensorCtrlAlertCount = 2, /**< \internal Number of Alerts */
63
64/**
65 * List of clock ports.
66 *
67 * Clock ports are guaranteed to be numbered consecutively from 0.
68 */
70 kDtSensorCtrlClockClk = 0, /**< Clock port clk_i */
71 kDtSensorCtrlClockAon = 1, /**< Clock port clk_aon_i */
72 kDtSensorCtrlClockCount = 2, /**< \internal Number of clock ports */
74
75/**
76 * List of reset ports.
77 *
78 * Reset ports are guaranteed to be numbered consecutively from 0.
79 */
81 kDtSensorCtrlResetRst = 0, /**< Reset port rst_ni */
82 kDtSensorCtrlResetAon = 1, /**< Reset port rst_aon_ni */
83 kDtSensorCtrlResetCount = 2, /**< \internal Number of reset ports */
85
86/**
87 * List of peripheral I/O.
88 *
89 * Peripheral I/O are guaranteed to be numbered consecutively from 0.
90 */
92 kDtSensorCtrlPeriphIoAstDebugOut0 = 0, /**< */
93 kDtSensorCtrlPeriphIoAstDebugOut1 = 1, /**< */
94 kDtSensorCtrlPeriphIoAstDebugOut2 = 2, /**< */
95 kDtSensorCtrlPeriphIoAstDebugOut3 = 3, /**< */
96 kDtSensorCtrlPeriphIoAstDebugOut4 = 4, /**< */
97 kDtSensorCtrlPeriphIoAstDebugOut5 = 5, /**< */
98 kDtSensorCtrlPeriphIoAstDebugOut6 = 6, /**< */
99 kDtSensorCtrlPeriphIoAstDebugOut7 = 7, /**< */
100 kDtSensorCtrlPeriphIoAstDebugOut8 = 8, /**< */
101 kDtSensorCtrlPeriphIoCount = 9, /**< \internal Number of peripheral I/O */
103
104/**
105 * List of wakeups.
106 *
107 * Wakeups are guaranteed to be numbered consecutively from 0.
108 */
110 kDtSensorCtrlWakeupWkupReq = 0, /**< Raised if an alert event is seen during low power */
111 kDtSensorCtrlWakeupCount = 1, /**< \internal Number of wakeups */
113
114
115/**
116 * Get the sensor_ctrl instance from an instance ID
117 *
118 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
119 *
120 * @param inst_id Instance ID.
121 * @return A sensor_ctrl instance.
122 *
123 * **Note:** This function only makes sense if the instance ID has device type sensor_ctrl,
124 * otherwise the returned value is unspecified.
125 */
127
128/**
129 * Get the instance ID of an instance.
130 *
131 * @param dt Instance of sensor_ctrl.
132 * @return The instance ID of that instance.
133 */
135
136/**
137 * Get the register base address of an instance.
138 *
139 * @param dt Instance of sensor_ctrl.
140 * @param reg_block The register block requested.
141 * @return The register base address of the requested block.
142 */
146
147/**
148 * Get the primary register base address of an instance.
149 *
150 * This is just a convenience function, equivalent to
151 * `dt_sensor_ctrl_reg_block(dt, kDtSensorCtrlRegBlockCore)`
152 *
153 * @param dt Instance of sensor_ctrl.
154 * @return The register base address of the primary register block.
155 */
156static inline uint32_t dt_sensor_ctrl_primary_reg_block(
157 dt_sensor_ctrl_t dt) {
158 return dt_sensor_ctrl_reg_block(dt, kDtSensorCtrlRegBlockCore);
159}
160
161/**
162 * Get the PLIC ID of a sensor_ctrl IRQ for a given instance.
163 *
164 * If the instance is not connected to the PLIC, this function
165 * will return `kDtPlicIrqIdNone`.
166 *
167 * @param dt Instance of sensor_ctrl.
168 * @param irq A sensor_ctrl IRQ.
169 * @return The PLIC ID of the IRQ of this instance.
170 */
174
175/**
176 * Convert a global IRQ ID to a local sensor_ctrl IRQ type.
177 *
178 * @param dt Instance of sensor_ctrl.
179 * @param irq A PLIC ID that belongs to this instance.
180 * @return The sensor_ctrl IRQ, or `kDtSensorCtrlIrqCount`.
181 *
182 * **Note:** This function assumes that the PLIC ID belongs to the instance
183 * of sensor_ctrl passed in parameter. In other words, it must be the case that
184 * `dt_sensor_ctrl_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
185 * will return `kDtSensorCtrlIrqCount`.
186 */
189 dt_plic_irq_id_t irq);
190
191
192/**
193 * Get the alert ID of a sensor_ctrl alert for a given instance.
194 *
195 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
196 * instances where the instance is not connected, the return value is unspecified.
197 *
198 * @param dt Instance of sensor_ctrl.
199 * @param alert A sensor_ctrl alert.
200 * @return The Alert Handler alert ID of the alert of this instance.
201 */
205
206/**
207 * Convert a global alert ID to a local sensor_ctrl alert type.
208 *
209 * @param dt Instance of sensor_ctrl.
210 * @param alert A global alert ID that belongs to this instance.
211 * @return The sensor_ctrl alert, or `kDtSensorCtrlAlertCount`.
212 *
213 * **Note:** This function assumes that the global alert ID belongs to the
214 * instance of sensor_ctrl passed in parameter. In other words, it must be the case
215 * that `dt_sensor_ctrl_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
216 * this function will return `kDtSensorCtrlAlertCount`.
217 */
220 dt_alert_id_t alert);
221
222
223/**
224 * Get the peripheral I/O description of an instance.
225 *
226 * @param dt Instance of sensor_ctrl.
227 * @param sig Requested peripheral I/O.
228 * @return Description of the requested peripheral I/O for this instance.
229 */
233
234/**
235 * Get the clock signal connected to a clock port of an instance.
236 *
237 * @param dt Instance of sensor_ctrl.
238 * @param clk Clock port.
239 * @return Clock signal.
240 */
244
245/**
246 * Get the reset signal connected to a reset port of an instance.
247 *
248 * @param dt Instance of sensor_ctrl.
249 * @param rst Reset port.
250 * @return Reset signal.
251 */
255
256
257
258#endif // OPENTITAN_DT_SENSOR_CTRL_H_