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