Software APIs
dt_sysrst_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_SYSRST_CTRL_H_
8#define OPENTITAN_DT_SYSRST_CTRL_H_
9
10/**
11 * @file
12 * @brief Device Tables (DT) for IP sysrst_ctrl and top earlgrey.
13 *
14 * This file contains the type definitions and global functions of the sysrst_ctrl.
15 */
16
17#include "dt_api.h"
18#include <stdint.h>
19
20/**
21 * List of instances.
22 */
23typedef enum dt_sysrst_ctrl {
24 kDtSysrstCtrlAon = 0, /**< sysrst_ctrl_aon */
25 kDtSysrstCtrlFirst = 0, /**< \internal First instance */
26 kDtSysrstCtrlCount = 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 kDtSysrstCtrlRegBlockCore = 0, /**< */
36 kDtSysrstCtrlRegBlockCount = 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_sysrst_ctrl_reg_block_t kDtSysrstCtrlRegBlockPrimary = kDtSysrstCtrlRegBlockCore;
41
42/**
43 * List of IRQs.
44 *
45 * IRQs are guaranteed to be numbered consecutively from 0.
46 */
47typedef enum dt_sysrst_ctrl_irq {
48 kDtSysrstCtrlIrqEventDetected = 0, /**< Common interrupt triggered by combo or keyboard events. */
49 kDtSysrstCtrlIrqCount = 1, /**< \internal Number of IRQs */
51
52/**
53 * List of Alerts.
54 *
55 * Alerts are guaranteed to be numbered consecutively from 0.
56 */
58 kDtSysrstCtrlAlertFatalFault = 0, /**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
59 kDtSysrstCtrlAlertCount = 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 */
68 kDtSysrstCtrlClockClk = 0, /**< Clock port clk_i */
69 kDtSysrstCtrlClockAon = 1, /**< Clock port clk_aon_i */
70 kDtSysrstCtrlClockCount = 2, /**< \internal Number of clock ports */
72
73/**
74 * List of reset requests.
75 *
76 * Reset requests are guaranteed to be numbered consecutively from 0.
77 */
79 kDtSysrstCtrlResetReqRstReq = 0, /**< OpenTitan reset request to `rstmgr` (running on AON clock). */
80 kDtSysrstCtrlResetReqCount = 1, /**< \internal Number of reset requests */
82
83/**
84 * List of reset ports.
85 *
86 * Reset ports are guaranteed to be numbered consecutively from 0.
87 */
89 kDtSysrstCtrlResetRst = 0, /**< Reset port rst_ni */
90 kDtSysrstCtrlResetAon = 1, /**< Reset port rst_aon_ni */
91 kDtSysrstCtrlResetCount = 2, /**< \internal Number of reset ports */
93
94/**
95 * List of peripheral I/O.
96 *
97 * Peripheral I/O are guaranteed to be numbered consecutively from 0.
98 */
100 kDtSysrstCtrlPeriphIoAcPresent = 0, /**< */
101 kDtSysrstCtrlPeriphIoKey0In = 1, /**< */
102 kDtSysrstCtrlPeriphIoKey1In = 2, /**< */
103 kDtSysrstCtrlPeriphIoKey2In = 3, /**< */
104 kDtSysrstCtrlPeriphIoPwrbIn = 4, /**< */
105 kDtSysrstCtrlPeriphIoLidOpen = 5, /**< */
106 kDtSysrstCtrlPeriphIoBatDisable = 6, /**< */
107 kDtSysrstCtrlPeriphIoKey0Out = 7, /**< */
108 kDtSysrstCtrlPeriphIoKey1Out = 8, /**< */
109 kDtSysrstCtrlPeriphIoKey2Out = 9, /**< */
110 kDtSysrstCtrlPeriphIoPwrbOut = 10, /**< */
111 kDtSysrstCtrlPeriphIoZ3Wakeup = 11, /**< */
112 kDtSysrstCtrlPeriphIoEcRstL = 12, /**< */
113 kDtSysrstCtrlPeriphIoFlashWpL = 13, /**< */
114 kDtSysrstCtrlPeriphIoCount = 14, /**< \internal Number of peripheral I/O */
116
117/**
118 * List of wakeups.
119 *
120 * Wakeups are guaranteed to be numbered consecutively from 0.
121 */
123 kDtSysrstCtrlWakeupWkupReq = 0, /**< OpenTitan wake request signal to `pwrmgr` (running on AON clock). */
124 kDtSysrstCtrlWakeupCount = 1, /**< \internal Number of wakeups */
126
127/**
128 * List of supported hardware features.
129 */
130#define OPENTITAN_SYSRST_CTRL_HAS_COMBO_DETECT 1
131#define OPENTITAN_SYSRST_CTRL_HAS_AUTO_BLOCK_KEY_OUTPUT 1
132#define OPENTITAN_SYSRST_CTRL_HAS_INPUT_TRIGGERED_INTERRUPT 1
133#define OPENTITAN_SYSRST_CTRL_HAS_ULTRA_LOW_POWER_WAKEUP 1
134#define OPENTITAN_SYSRST_CTRL_HAS_PINOUT_KEY_INVERSION_CONTROL 1
135#define OPENTITAN_SYSRST_CTRL_HAS_HARDWARE_RESET_STRETCH 1
136#define OPENTITAN_SYSRST_CTRL_HAS_FLASH_WRITE_PROTECT 1
137#define OPENTITAN_SYSRST_CTRL_HAS_PIN_INPUT_VALUE_ACCESS 1
138
139
140
141/**
142 * Get the sysrst_ctrl instance from an instance ID
143 *
144 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
145 *
146 * @param inst_id Instance ID.
147 * @return A sysrst_ctrl instance.
148 *
149 * **Note:** This function only makes sense if the instance ID has device type sysrst_ctrl,
150 * otherwise the returned value is unspecified.
151 */
153
154/**
155 * Get the instance ID of an instance.
156 *
157 * @param dt Instance of sysrst_ctrl.
158 * @return The instance ID of that instance.
159 */
161
162/**
163 * Get the register base address of an instance.
164 *
165 * @param dt Instance of sysrst_ctrl.
166 * @param reg_block The register block requested.
167 * @return The register base address of the requested block.
168 */
172
173/**
174 * Get the primary register base address of an instance.
175 *
176 * This is just a convenience function, equivalent to
177 * `dt_sysrst_ctrl_reg_block(dt, kDtSysrstCtrlRegBlockCore)`
178 *
179 * @param dt Instance of sysrst_ctrl.
180 * @return The register base address of the primary register block.
181 */
182static inline uint32_t dt_sysrst_ctrl_primary_reg_block(
183 dt_sysrst_ctrl_t dt) {
184 return dt_sysrst_ctrl_reg_block(dt, kDtSysrstCtrlRegBlockCore);
185}
186
187/**
188 * Get the PLIC ID of a sysrst_ctrl IRQ for a given instance.
189 *
190 * If the instance is not connected to the PLIC, this function
191 * will return `kDtPlicIrqIdNone`.
192 *
193 * @param dt Instance of sysrst_ctrl.
194 * @param irq A sysrst_ctrl IRQ.
195 * @return The PLIC ID of the IRQ of this instance.
196 */
200
201/**
202 * Convert a global IRQ ID to a local sysrst_ctrl IRQ type.
203 *
204 * @param dt Instance of sysrst_ctrl.
205 * @param irq A PLIC ID that belongs to this instance.
206 * @return The sysrst_ctrl IRQ, or `kDtSysrstCtrlIrqCount`.
207 *
208 * **Note:** This function assumes that the PLIC ID belongs to the instance
209 * of sysrst_ctrl passed in parameter. In other words, it must be the case that
210 * `dt_sysrst_ctrl_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
211 * will return `kDtSysrstCtrlIrqCount`.
212 */
215 dt_plic_irq_id_t irq);
216
217
218/**
219 * Get the alert ID of a sysrst_ctrl alert for a given instance.
220 *
221 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
222 * instances where the instance is not connected, the return value is unspecified.
223 *
224 * @param dt Instance of sysrst_ctrl.
225 * @param alert A sysrst_ctrl alert.
226 * @return The Alert Handler alert ID of the alert of this instance.
227 */
231
232/**
233 * Convert a global alert ID to a local sysrst_ctrl alert type.
234 *
235 * @param dt Instance of sysrst_ctrl.
236 * @param alert A global alert ID that belongs to this instance.
237 * @return The sysrst_ctrl alert, or `kDtSysrstCtrlAlertCount`.
238 *
239 * **Note:** This function assumes that the global alert ID belongs to the
240 * instance of sysrst_ctrl passed in parameter. In other words, it must be the case
241 * that `dt_sysrst_ctrl_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
242 * this function will return `kDtSysrstCtrlAlertCount`.
243 */
246 dt_alert_id_t alert);
247
248
249/**
250 * Get the peripheral I/O description of an instance.
251 *
252 * @param dt Instance of sysrst_ctrl.
253 * @param sig Requested peripheral I/O.
254 * @return Description of the requested peripheral I/O for this instance.
255 */
259
260/**
261 * Get the clock signal connected to a clock port of an instance.
262 *
263 * @param dt Instance of sysrst_ctrl.
264 * @param clk Clock port.
265 * @return Clock signal.
266 */
270
271/**
272 * Get the reset signal connected to a reset port of an instance.
273 *
274 * @param dt Instance of sysrst_ctrl.
275 * @param rst Reset port.
276 * @return Reset signal.
277 */
281
282
283
284#endif // OPENTITAN_DT_SYSRST_CTRL_H_