Software APIs
rstmgr.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_RSTMGR_H_
8#define OPENTITAN_DT_RSTMGR_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif // __cplusplus
13
14/**
15 * @file
16 * @brief Device Tables (DT) for IP rstmgr and top earlgrey.
17 *
18 * This file contains the type definitions and global functions of the rstmgr.
19 */
20
21#include "hw/top/dt/api.h"
22#include <stdint.h>
23
24
25
26
27
28/**
29 * List of instances.
30 */
31typedef enum dt_rstmgr {
32 kDtRstmgrFirst = 0, /**< First instance */
33 kDtRstmgr = 0, /**< rstmgr */
35
36enum {
37 kDtRstmgrCount = 1, /**< Number of instances */
38};
39
40
41/**
42 * List of register blocks.
43 *
44 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
45 */
46typedef enum dt_rstmgr_reg_block {
47 kDtRstmgrRegBlockCore = 0, /**< */
49
50enum {
51 kDtRstmgrRegBlockCount = 1, /**< Number of register blocks */
52};
53
54
55/** Primary register block (associated with the "primary" set of registers that control the IP). */
56static const dt_rstmgr_reg_block_t kDtRstmgrRegBlockPrimary = kDtRstmgrRegBlockCore;
57
58/**
59 * List of Alerts.
60 *
61 * Alerts are guaranteed to be numbered consecutively from 0.
62 */
63typedef enum dt_rstmgr_alert {
64 kDtRstmgrAlertFatalFault = 0, /**< This fatal alert is triggered when a fatal structural fault is detected.
65 Structural faults include errors such as sparse fsm errors and tlul integrity errors. */
66 kDtRstmgrAlertFatalCnstyFault = 1, /**< This fatal alert is triggered when a reset consistency fault is detected.
67 It is separated from the category above for clearer error collection and debug. */
69
70enum {
71 kDtRstmgrAlertCount = 2, /**< Number of Alerts */
72};
73
74
75/**
76 * List of clock ports.
77 *
78 * Clock ports are guaranteed to be numbered consecutively from 0.
79 */
80typedef enum dt_rstmgr_clock {
81 kDtRstmgrClockClk = 0, /**< Clock port clk_i */
82 kDtRstmgrClockAon = 1, /**< Clock port clk_aon_i */
83 kDtRstmgrClockIoDiv4 = 2, /**< Clock port clk_io_div4_i */
84 kDtRstmgrClockMain = 3, /**< Clock port clk_main_i */
85 kDtRstmgrClockIo = 4, /**< Clock port clk_io_i */
86 kDtRstmgrClockIoDiv2 = 5, /**< Clock port clk_io_div2_i */
87 kDtRstmgrClockUsb = 6, /**< Clock port clk_usb_i */
88 kDtRstmgrClockPor = 7, /**< Clock port clk_por_i */
90
91enum {
92 kDtRstmgrClockCount = 8, /**< Number of clock ports */
93};
94
95
96/**
97 * List of reset ports.
98 *
99 * Reset ports are guaranteed to be numbered consecutively from 0.
100 */
101typedef enum dt_rstmgr_reset {
102 kDtRstmgrResetRst = 0, /**< Reset port rst_ni */
103 kDtRstmgrResetPor = 1, /**< Reset port rst_por_ni */
105
106enum {
107 kDtRstmgrResetCount = 2, /**< Number of reset ports */
108};
109
110
111/**
112 * List of supported hardware features.
113 */
114#define OPENTITAN_RSTMGR_HAS_SW_RST_CHIP_RESET 1
115#define OPENTITAN_RSTMGR_HAS_SW_RST_SPI_DEVICE_REQUEST 1
116#define OPENTITAN_RSTMGR_HAS_SW_RST_SPI_DEVICE_ENABLE 1
117#define OPENTITAN_RSTMGR_HAS_SW_RST_SPI_HOST0_REQUEST 1
118#define OPENTITAN_RSTMGR_HAS_SW_RST_SPI_HOST0_ENABLE 1
119#define OPENTITAN_RSTMGR_HAS_SW_RST_SPI_HOST1_REQUEST 1
120#define OPENTITAN_RSTMGR_HAS_SW_RST_SPI_HOST1_ENABLE 1
121#define OPENTITAN_RSTMGR_HAS_SW_RST_USB_REQUEST 1
122#define OPENTITAN_RSTMGR_HAS_SW_RST_USB_ENABLE 1
123#define OPENTITAN_RSTMGR_HAS_SW_RST_USB_AON_REQUEST 1
124#define OPENTITAN_RSTMGR_HAS_SW_RST_USB_AON_ENABLE 1
125#define OPENTITAN_RSTMGR_HAS_SW_RST_I2C0_REQUEST 1
126#define OPENTITAN_RSTMGR_HAS_SW_RST_I2C0_ENABLE 1
127#define OPENTITAN_RSTMGR_HAS_SW_RST_I2C1_REQUEST 1
128#define OPENTITAN_RSTMGR_HAS_SW_RST_I2C1_ENABLE 1
129#define OPENTITAN_RSTMGR_HAS_SW_RST_I2C2_REQUEST 1
130#define OPENTITAN_RSTMGR_HAS_SW_RST_I2C2_ENABLE 1
131#define OPENTITAN_RSTMGR_HAS_SW_RST_I3C0_REQUEST 1
132#define OPENTITAN_RSTMGR_HAS_SW_RST_I3C0_ENABLE 1
133#define OPENTITAN_RSTMGR_HAS_SW_RST_I3C1_REQUEST 1
134#define OPENTITAN_RSTMGR_HAS_SW_RST_I3C1_ENABLE 1
135#define OPENTITAN_RSTMGR_HAS_RESET_INFO_CAPTURE 1
136#define OPENTITAN_RSTMGR_HAS_RESET_INFO_CLEAR 1
137#define OPENTITAN_RSTMGR_HAS_ALERT_INFO_CAPTURE 1
138#define OPENTITAN_RSTMGR_HAS_ALERT_INFO_ENABLE 1
139#define OPENTITAN_RSTMGR_HAS_CPU_INFO_CAPTURE 1
140#define OPENTITAN_RSTMGR_HAS_CPU_INFO_ENABLE 1
141#define OPENTITAN_RSTMGR_HAS_ALERT_HANDLER_RESET_STATUS 1
142
143
144
145/**
146 * Get the rstmgr instance from an instance ID
147 *
148 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
149 *
150 * @param inst_id Instance ID.
151 * @return A rstmgr instance.
152 *
153 * **Note:** This function only makes sense if the instance ID has device type rstmgr,
154 * otherwise the returned value is unspecified.
155 */
157
158/**
159 * Get the instance ID of an instance.
160 *
161 * @param dt Instance of rstmgr.
162 * @return The instance ID of that instance.
163 */
165
166/**
167 * Get the register base address of an instance.
168 *
169 * @param dt Instance of rstmgr.
170 * @param reg_block The register block requested.
171 * @return The register base address of the requested block.
172 */
173uint32_t dt_rstmgr_reg_block(
174 dt_rstmgr_t dt,
175 dt_rstmgr_reg_block_t reg_block);
176
177/**
178 * Get the primary register base address of an instance.
179 *
180 * This is just a convenience function, equivalent to
181 * `dt_rstmgr_reg_block(dt, kDtRstmgrRegBlockCore)`
182 *
183 * @param dt Instance of rstmgr.
184 * @return The register base address of the primary register block.
185 */
186static inline uint32_t dt_rstmgr_primary_reg_block(
187 dt_rstmgr_t dt) {
188 return dt_rstmgr_reg_block(dt, kDtRstmgrRegBlockCore);
189}
190
191
192/**
193 * Get the alert ID of a rstmgr 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 rstmgr.
199 * @param alert A rstmgr alert.
200 * @return The Alert Handler alert ID of the alert of this instance.
201 */
203 dt_rstmgr_t dt,
204 dt_rstmgr_alert_t alert);
205
206/**
207 * Convert a global alert ID to a local rstmgr alert type.
208 *
209 * @param dt Instance of rstmgr.
210 * @param alert A global alert ID that belongs to this instance.
211 * @return The rstmgr alert, or `kDtRstmgrAlertCount`.
212 *
213 * **Note:** This function assumes that the global alert ID belongs to the
214 * instance of rstmgr passed in parameter. In other words, it must be the case
215 * that `dt_rstmgr_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
216 * this function will return `kDtRstmgrAlertCount`.
217 */
219 dt_rstmgr_t dt,
220 dt_alert_id_t alert);
221
222
223
224/**
225 * Get the clock signal connected to a clock port of an instance.
226 *
227 * @param dt Instance of rstmgr.
228 * @param clk Clock port.
229 * @return Clock signal.
230 */
232 dt_rstmgr_t dt,
234
235/**
236 * Get the reset signal connected to a reset port of an instance.
237 *
238 * @param dt Instance of rstmgr.
239 * @param rst Reset port.
240 * @return Reset signal.
241 */
243 dt_rstmgr_t dt,
245
246
247
248/**
249 * Get the number of software resets.
250 *
251 * @param dt Instance of rstmgr.
252 * @return Number of software resets.
253 */
255
256/**
257 * Get the reset ID of a software reset.
258 *
259 * The resets are ordered in the same way as they appear in the registers.
260 *
261 * @param dt Instance of rstmgr.
262 * @param idx Index of the software reset, between 0 and `dt_rstmgr_sw_reset_count(dt)-1`.
263 * @return Reset ID, or `kDtResetUnknown` for invalid parameters.
264 */
266
267/**
268 * Description of a reset request source.
269 *
270 * A reset request source is always identified by the instance ID of the module where it comes
271 * from. In principle, some instances could have several reset requests. If this is the case,
272 * the `rst_req` can be used to distinguish between those. It should be cast to the
273 * `dt_<ip>_reset_req_t` type of the corresponding IP.
274 *
275 * WARNING At the moment, three hardcoded reset requests are treated specially and have their
276 * `reset_req` field set to `0` because there is no corresponding reset request declared by those
277 * IPs:
278 * - the main power glitch reset request, coming from the `pwrmgr`,
279 * - the escalation reset request, coming from the `alert_handler`,
280 * - the non-debug-module reset request, coming from the `rv_dm`.
281 */
283 dt_instance_id_t inst_id; /**< Instance ID of the source of this reset request. */
284 size_t reset_req; /**< Index of the reset request signal for that instance. */
286
287
288/**
289 * Get the number of hardware reset requests.
290 *
291 * @param dt Instance of rstmgr.
292 * @return Number of reset requests.
293 */
295
296/**
297 * Get the description of a reset request.
298 *
299 * The reset requests are ordered as they appear in the registers.
300 *
301 * @param dt Instance of rstmgr.
302 * @param idx Index of the reset request source, between 0 and
303 * `dt_pwrmgr_hw_reset_req_src_count(dt)-1`.
304 * @return Description of the reset.
305 */
307
308
309
310#ifdef __cplusplus
311} // extern "C"
312#endif // __cplusplus
313
314#endif // OPENTITAN_DT_RSTMGR_H_