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 darjeeling.
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 kDtRstmgrAon = 0, /**< rstmgr_aon */
33 kDtRstmgrFirst = 0, /**< \internal First instance */
34 kDtRstmgrCount = 1, /**< \internal Number of instances */
36
37/**
38 * List of register blocks.
39 *
40 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
41 */
42typedef enum dt_rstmgr_reg_block {
43 kDtRstmgrRegBlockCore = 0, /**< */
44 kDtRstmgrRegBlockCount = 1, /**< \internal Number of register blocks */
46
47/** Primary register block (associated with the "primary" set of registers that control the IP). */
48static const dt_rstmgr_reg_block_t kDtRstmgrRegBlockPrimary = kDtRstmgrRegBlockCore;
49
50/**
51 * List of Alerts.
52 *
53 * Alerts are guaranteed to be numbered consecutively from 0.
54 */
55typedef enum dt_rstmgr_alert {
56 kDtRstmgrAlertFatalFault = 0, /**< This fatal alert is triggered when a fatal structural fault is detected.
57Structural faults include errors such as sparse fsm errors and tlul integrity errors. */
58 kDtRstmgrAlertFatalCnstyFault = 1, /**< This fatal alert is triggered when a reset consistency fault is detected.
59It is separated from the category above for clearer error collection and debug. */
60 kDtRstmgrAlertCount = 2, /**< \internal Number of Alerts */
62
63/**
64 * List of clock ports.
65 *
66 * Clock ports are guaranteed to be numbered consecutively from 0.
67 */
68typedef enum dt_rstmgr_clock {
69 kDtRstmgrClockClk = 0, /**< Clock port clk_i */
70 kDtRstmgrClockAon = 1, /**< Clock port clk_aon_i */
71 kDtRstmgrClockIo = 2, /**< Clock port clk_io_i */
72 kDtRstmgrClockMain = 3, /**< Clock port clk_main_i */
73 kDtRstmgrClockPor = 4, /**< Clock port clk_por_i */
74 kDtRstmgrClockCount = 5, /**< \internal Number of clock ports */
76
77/**
78 * List of reset ports.
79 *
80 * Reset ports are guaranteed to be numbered consecutively from 0.
81 */
82typedef enum dt_rstmgr_reset {
83 kDtRstmgrResetRst = 0, /**< Reset port rst_ni */
84 kDtRstmgrResetPor = 1, /**< Reset port rst_por_ni */
85 kDtRstmgrResetCount = 2, /**< \internal Number of reset ports */
87
88/**
89 * List of supported hardware features.
90 */
91#define OPENTITAN_RSTMGR_HAS_SW_RST_CHIP_RESET 1
92#define OPENTITAN_RSTMGR_HAS_SW_RST_SPI_DEVICE_REQUEST 1
93#define OPENTITAN_RSTMGR_HAS_SW_RST_SPI_DEVICE_ENABLE 1
94#define OPENTITAN_RSTMGR_HAS_SW_RST_SPI_HOST0_REQUEST 1
95#define OPENTITAN_RSTMGR_HAS_SW_RST_SPI_HOST0_ENABLE 1
96#define OPENTITAN_RSTMGR_HAS_SW_RST_I2C0_REQUEST 1
97#define OPENTITAN_RSTMGR_HAS_SW_RST_I2C0_ENABLE 1
98#define OPENTITAN_RSTMGR_HAS_RESET_INFO_CAPTURE 1
99#define OPENTITAN_RSTMGR_HAS_RESET_INFO_CLEAR 1
100#define OPENTITAN_RSTMGR_HAS_ALERT_INFO_CAPTURE 1
101#define OPENTITAN_RSTMGR_HAS_ALERT_INFO_ENABLE 1
102#define OPENTITAN_RSTMGR_HAS_CPU_INFO_CAPTURE 1
103#define OPENTITAN_RSTMGR_HAS_CPU_INFO_ENABLE 1
104#define OPENTITAN_RSTMGR_HAS_ALERT_HANDLER_RESET_STATUS 1
105
106
107
108/**
109 * Get the rstmgr instance from an instance ID
110 *
111 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
112 *
113 * @param inst_id Instance ID.
114 * @return A rstmgr instance.
115 *
116 * **Note:** This function only makes sense if the instance ID has device type rstmgr,
117 * otherwise the returned value is unspecified.
118 */
120
121/**
122 * Get the instance ID of an instance.
123 *
124 * @param dt Instance of rstmgr.
125 * @return The instance ID of that instance.
126 */
128
129/**
130 * Get the register base address of an instance.
131 *
132 * @param dt Instance of rstmgr.
133 * @param reg_block The register block requested.
134 * @return The register base address of the requested block.
135 */
136uint32_t dt_rstmgr_reg_block(
137 dt_rstmgr_t dt,
138 dt_rstmgr_reg_block_t reg_block);
139
140/**
141 * Get the primary register base address of an instance.
142 *
143 * This is just a convenience function, equivalent to
144 * `dt_rstmgr_reg_block(dt, kDtRstmgrRegBlockCore)`
145 *
146 * @param dt Instance of rstmgr.
147 * @return The register base address of the primary register block.
148 */
149static inline uint32_t dt_rstmgr_primary_reg_block(
150 dt_rstmgr_t dt) {
151 return dt_rstmgr_reg_block(dt, kDtRstmgrRegBlockCore);
152}
153
154
155/**
156 * Get the alert ID of a rstmgr alert for a given instance.
157 *
158 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
159 * instances where the instance is not connected, the return value is unspecified.
160 *
161 * @param dt Instance of rstmgr.
162 * @param alert A rstmgr alert.
163 * @return The Alert Handler alert ID of the alert of this instance.
164 */
166 dt_rstmgr_t dt,
167 dt_rstmgr_alert_t alert);
168
169/**
170 * Convert a global alert ID to a local rstmgr alert type.
171 *
172 * @param dt Instance of rstmgr.
173 * @param alert A global alert ID that belongs to this instance.
174 * @return The rstmgr alert, or `kDtRstmgrAlertCount`.
175 *
176 * **Note:** This function assumes that the global alert ID belongs to the
177 * instance of rstmgr passed in parameter. In other words, it must be the case
178 * that `dt_rstmgr_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
179 * this function will return `kDtRstmgrAlertCount`.
180 */
182 dt_rstmgr_t dt,
183 dt_alert_id_t alert);
184
185
186
187/**
188 * Get the clock signal connected to a clock port of an instance.
189 *
190 * @param dt Instance of rstmgr.
191 * @param clk Clock port.
192 * @return Clock signal.
193 */
195 dt_rstmgr_t dt,
197
198/**
199 * Get the reset signal connected to a reset port of an instance.
200 *
201 * @param dt Instance of rstmgr.
202 * @param rst Reset port.
203 * @return Reset signal.
204 */
206 dt_rstmgr_t dt,
208
209
210
211/**
212 * Get the number of software resets.
213 *
214 * @param dt Instance of rstmgr.
215 * @return Number of software resets.
216 */
218
219/**
220 * Get the reset ID of a software reset.
221 *
222 * The resets are ordered in the same way as they appear in the registers.
223 *
224 * @param dt Instance of rstmgr.
225 * @param idx Index of the software reset, between 0 and `dt_rstmgr_sw_reset_count(dt)-1`.
226 * @return Reset ID, or `kDtResetUnknown` for invalid parameters.
227 */
229
230/**
231 * Description of a reset request source.
232 *
233 * A reset request source is always identified by the instance ID of the module where it comes
234 * from. In principle, some instances could have several reset requests. If this is the case,
235 * the `rst_req` can be used to distinguish between those. It should be cast to the
236 * `dt_<ip>_reset_req_t` type of the corresponding IP.
237 *
238 * WARNING At the moment, three hardcoded reset requests are treated specially and have their
239 * `reset_req` field set to `0` because there is no corresponding reset request declared by those
240 * IPs:
241 * - the main power glitch reset request, coming from the `pwrmgr`,
242 * - the escalation reset request, coming from the `alert_handler`,
243 * - the non-debug-module reset request, coming from the `rv_dm`.
244 */
245typedef struct dt_rstmgr_reset_req_src {
246 dt_instance_id_t inst_id; /**< Instance ID of the source of this reset request. */
247 size_t reset_req; /**< Index of the reset request signal for that instance. */
249
250
251/**
252 * Get the number of hardware reset requests.
253 *
254 * @param dt Instance of rstmgr.
255 * @return Number of reset requests.
256 */
258
259/**
260 * Get the description of a reset request.
261 *
262 * The reset requests are ordered as they appear in the registers.
263 *
264 * @param dt Instance of rstmgr.
265 * @param idx Index of the reset request source, between 0 and
266 * `dt_pwrmgr_hw_reset_req_src_count(dt)-1`.
267 * @return Description of the reset.
268 */
270
271
272
273#ifdef __cplusplus
274} // extern "C"
275#endif // __cplusplus
276
277#endif // OPENTITAN_DT_RSTMGR_H_