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