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
11
extern
"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
*/
31
typedef
enum
dt_rstmgr
{
32
kDtRstmgrFirst
= 0,
/**< First instance */
33
kDtRstmgrAon
= 0,
/**< rstmgr_aon */
34
}
dt_rstmgr_t
;
35
36
enum
{
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
*/
46
typedef
enum
dt_rstmgr_reg_block
{
47
kDtRstmgrRegBlockCore = 0,
/**< */
48
}
dt_rstmgr_reg_block_t
;
49
50
enum
{
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). */
56
static
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
*/
63
typedef
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. */
68
}
dt_rstmgr_alert_t
;
69
70
enum
{
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
*/
80
typedef
enum
dt_rstmgr_clock
{
81
kDtRstmgrClockClk
= 0,
/**< Clock port clk_i */
82
kDtRstmgrClockAon
= 1,
/**< Clock port clk_aon_i */
83
kDtRstmgrClockIo
= 2,
/**< Clock port clk_io_i */
84
kDtRstmgrClockMain
= 3,
/**< Clock port clk_main_i */
85
kDtRstmgrClockPor
= 4,
/**< Clock port clk_por_i */
86
}
dt_rstmgr_clock_t
;
87
88
enum
{
89
kDtRstmgrClockCount
= 5,
/**< Number of clock ports */
90
};
91
92
93
/**
94
* List of reset ports.
95
*
96
* Reset ports are guaranteed to be numbered consecutively from 0.
97
*/
98
typedef
enum
dt_rstmgr_reset
{
99
kDtRstmgrResetRst
= 0,
/**< Reset port rst_ni */
100
kDtRstmgrResetPor
= 1,
/**< Reset port rst_por_ni */
101
}
dt_rstmgr_reset_t
;
102
103
enum
{
104
kDtRstmgrResetCount
= 2,
/**< Number of reset ports */
105
};
106
107
108
/**
109
* List of supported hardware features.
110
*/
111
#define OPENTITAN_RSTMGR_HAS_SW_RST_CHIP_RESET 1
112
#define OPENTITAN_RSTMGR_HAS_SW_RST_SPI_DEVICE_REQUEST 1
113
#define OPENTITAN_RSTMGR_HAS_SW_RST_SPI_DEVICE_ENABLE 1
114
#define OPENTITAN_RSTMGR_HAS_SW_RST_SPI_HOST0_REQUEST 1
115
#define OPENTITAN_RSTMGR_HAS_SW_RST_SPI_HOST0_ENABLE 1
116
#define OPENTITAN_RSTMGR_HAS_SW_RST_I2C0_REQUEST 1
117
#define OPENTITAN_RSTMGR_HAS_SW_RST_I2C0_ENABLE 1
118
#define OPENTITAN_RSTMGR_HAS_RESET_INFO_CAPTURE 1
119
#define OPENTITAN_RSTMGR_HAS_RESET_INFO_CLEAR 1
120
#define OPENTITAN_RSTMGR_HAS_ALERT_INFO_CAPTURE 1
121
#define OPENTITAN_RSTMGR_HAS_ALERT_INFO_ENABLE 1
122
#define OPENTITAN_RSTMGR_HAS_CPU_INFO_CAPTURE 1
123
#define OPENTITAN_RSTMGR_HAS_CPU_INFO_ENABLE 1
124
#define OPENTITAN_RSTMGR_HAS_ALERT_HANDLER_RESET_STATUS 1
125
126
127
128
/**
129
* Get the rstmgr instance from an instance ID
130
*
131
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
132
*
133
* @param inst_id Instance ID.
134
* @return A rstmgr instance.
135
*
136
* **Note:** This function only makes sense if the instance ID has device type rstmgr,
137
* otherwise the returned value is unspecified.
138
*/
139
dt_rstmgr_t
dt_rstmgr_from_instance_id
(
dt_instance_id_t
inst_id);
140
141
/**
142
* Get the instance ID of an instance.
143
*
144
* @param dt Instance of rstmgr.
145
* @return The instance ID of that instance.
146
*/
147
dt_instance_id_t
dt_rstmgr_instance_id
(
dt_rstmgr_t
dt);
148
149
/**
150
* Get the register base address of an instance.
151
*
152
* @param dt Instance of rstmgr.
153
* @param reg_block The register block requested.
154
* @return The register base address of the requested block.
155
*/
156
uint32_t
dt_rstmgr_reg_block
(
157
dt_rstmgr_t
dt,
158
dt_rstmgr_reg_block_t
reg_block);
159
160
/**
161
* Get the primary register base address of an instance.
162
*
163
* This is just a convenience function, equivalent to
164
* `dt_rstmgr_reg_block(dt, kDtRstmgrRegBlockCore)`
165
*
166
* @param dt Instance of rstmgr.
167
* @return The register base address of the primary register block.
168
*/
169
static
inline
uint32_t dt_rstmgr_primary_reg_block(
170
dt_rstmgr_t
dt) {
171
return
dt_rstmgr_reg_block
(dt, kDtRstmgrRegBlockCore);
172
}
173
174
175
/**
176
* Get the alert ID of a rstmgr alert for a given instance.
177
*
178
* **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
179
* instances where the instance is not connected, the return value is unspecified.
180
*
181
* @param dt Instance of rstmgr.
182
* @param alert A rstmgr alert.
183
* @return The Alert Handler alert ID of the alert of this instance.
184
*/
185
dt_alert_id_t
dt_rstmgr_alert_to_alert_id
(
186
dt_rstmgr_t
dt,
187
dt_rstmgr_alert_t
alert);
188
189
/**
190
* Convert a global alert ID to a local rstmgr alert type.
191
*
192
* @param dt Instance of rstmgr.
193
* @param alert A global alert ID that belongs to this instance.
194
* @return The rstmgr alert, or `kDtRstmgrAlertCount`.
195
*
196
* **Note:** This function assumes that the global alert ID belongs to the
197
* instance of rstmgr passed in parameter. In other words, it must be the case
198
* that `dt_rstmgr_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
199
* this function will return `kDtRstmgrAlertCount`.
200
*/
201
dt_rstmgr_alert_t
dt_rstmgr_alert_from_alert_id
(
202
dt_rstmgr_t
dt,
203
dt_alert_id_t
alert);
204
205
206
207
/**
208
* Get the clock signal connected to a clock port of an instance.
209
*
210
* @param dt Instance of rstmgr.
211
* @param clk Clock port.
212
* @return Clock signal.
213
*/
214
dt_clock_t
dt_rstmgr_clock
(
215
dt_rstmgr_t
dt,
216
dt_rstmgr_clock_t
clk);
217
218
/**
219
* Get the reset signal connected to a reset port of an instance.
220
*
221
* @param dt Instance of rstmgr.
222
* @param rst Reset port.
223
* @return Reset signal.
224
*/
225
dt_reset_t
dt_rstmgr_reset
(
226
dt_rstmgr_t
dt,
227
dt_rstmgr_reset_t
rst);
228
229
230
231
/**
232
* Get the number of software resets.
233
*
234
* @param dt Instance of rstmgr.
235
* @return Number of software resets.
236
*/
237
size_t
dt_rstmgr_sw_reset_count
(
dt_rstmgr_t
dt);
238
239
/**
240
* Get the reset ID of a software reset.
241
*
242
* The resets are ordered in the same way as they appear in the registers.
243
*
244
* @param dt Instance of rstmgr.
245
* @param idx Index of the software reset, between 0 and `dt_rstmgr_sw_reset_count(dt)-1`.
246
* @return Reset ID, or `kDtResetUnknown` for invalid parameters.
247
*/
248
dt_reset_t
dt_rstmgr_sw_reset
(
dt_rstmgr_t
dt,
size_t
idx);
249
250
/**
251
* Description of a reset request source.
252
*
253
* A reset request source is always identified by the instance ID of the module where it comes
254
* from. In principle, some instances could have several reset requests. If this is the case,
255
* the `rst_req` can be used to distinguish between those. It should be cast to the
256
* `dt_<ip>_reset_req_t` type of the corresponding IP.
257
*
258
* WARNING At the moment, three hardcoded reset requests are treated specially and have their
259
* `reset_req` field set to `0` because there is no corresponding reset request declared by those
260
* IPs:
261
* - the main power glitch reset request, coming from the `pwrmgr`,
262
* - the escalation reset request, coming from the `alert_handler`,
263
* - the non-debug-module reset request, coming from the `rv_dm`.
264
*/
265
typedef
struct
dt_rstmgr_reset_req_src
{
266
dt_instance_id_t
inst_id
;
/**< Instance ID of the source of this reset request. */
267
size_t
reset_req
;
/**< Index of the reset request signal for that instance. */
268
}
dt_rstmgr_reset_req_src_t
;
269
270
271
/**
272
* Get the number of hardware reset requests.
273
*
274
* @param dt Instance of rstmgr.
275
* @return Number of reset requests.
276
*/
277
size_t
dt_rstmgr_hw_reset_req_src_count
(
dt_rstmgr_t
dt);
278
279
/**
280
* Get the description of a reset request.
281
*
282
* The reset requests are ordered as they appear in the registers.
283
*
284
* @param dt Instance of rstmgr.
285
* @param idx Index of the reset request source, between 0 and
286
* `dt_pwrmgr_hw_reset_req_src_count(dt)-1`.
287
* @return Description of the reset.
288
*/
289
dt_rstmgr_reset_req_src_t
dt_rstmgr_hw_reset_req_src
(
dt_rstmgr_t
dt,
size_t
idx);
290
291
292
293
#ifdef __cplusplus
294
}
// extern "C"
295
#endif
// __cplusplus
296
297
#endif
// OPENTITAN_DT_RSTMGR_H_
(darjeeling)
hw
top
dt
rstmgr.h
Return to
OpenTitan Documentation