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 englishbreakfast.
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 clock ports.
60
*
61
* Clock ports are guaranteed to be numbered consecutively from 0.
62
*/
63
typedef
enum
dt_rstmgr_clock
{
64
kDtRstmgrClockClk
= 0,
/**< Clock port clk_i */
65
kDtRstmgrClockAon
= 1,
/**< Clock port clk_aon_i */
66
kDtRstmgrClockIoDiv4
= 2,
/**< Clock port clk_io_div4_i */
67
kDtRstmgrClockMain
= 3,
/**< Clock port clk_main_i */
68
kDtRstmgrClockIo
= 4,
/**< Clock port clk_io_i */
69
kDtRstmgrClockIoDiv2
= 5,
/**< Clock port clk_io_div2_i */
70
kDtRstmgrClockUsb
= 6,
/**< Clock port clk_usb_i */
71
kDtRstmgrClockPor
= 7,
/**< Clock port clk_por_i */
72
}
dt_rstmgr_clock_t
;
73
74
enum
{
75
kDtRstmgrClockCount
= 8,
/**< Number of clock ports */
76
};
77
78
79
/**
80
* List of reset ports.
81
*
82
* Reset ports are guaranteed to be numbered consecutively from 0.
83
*/
84
typedef
enum
dt_rstmgr_reset
{
85
kDtRstmgrResetRst
= 0,
/**< Reset port rst_ni */
86
kDtRstmgrResetPor
= 1,
/**< Reset port rst_por_ni */
87
}
dt_rstmgr_reset_t
;
88
89
enum
{
90
kDtRstmgrResetCount
= 2,
/**< Number of reset ports */
91
};
92
93
94
/**
95
* List of supported hardware features.
96
*/
97
#define OPENTITAN_RSTMGR_HAS_SW_RST_CHIP_RESET 1
98
#define OPENTITAN_RSTMGR_HAS_SW_RST_SPI_DEVICE_REQUEST 1
99
#define OPENTITAN_RSTMGR_HAS_SW_RST_SPI_DEVICE_ENABLE 1
100
#define OPENTITAN_RSTMGR_HAS_SW_RST_SPI_HOST0_REQUEST 1
101
#define OPENTITAN_RSTMGR_HAS_SW_RST_SPI_HOST0_ENABLE 1
102
#define OPENTITAN_RSTMGR_HAS_SW_RST_USB_REQUEST 1
103
#define OPENTITAN_RSTMGR_HAS_SW_RST_USB_ENABLE 1
104
#define OPENTITAN_RSTMGR_HAS_RESET_INFO_CAPTURE 1
105
#define OPENTITAN_RSTMGR_HAS_RESET_INFO_CLEAR 1
106
#define OPENTITAN_RSTMGR_HAS_ALERT_INFO_CAPTURE 1
107
#define OPENTITAN_RSTMGR_HAS_ALERT_INFO_ENABLE 1
108
#define OPENTITAN_RSTMGR_HAS_CPU_INFO_CAPTURE 1
109
#define OPENTITAN_RSTMGR_HAS_CPU_INFO_ENABLE 1
110
#define OPENTITAN_RSTMGR_HAS_ALERT_HANDLER_RESET_STATUS 1
111
112
113
114
/**
115
* Get the rstmgr instance from an instance ID
116
*
117
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
118
*
119
* @param inst_id Instance ID.
120
* @return A rstmgr instance.
121
*
122
* **Note:** This function only makes sense if the instance ID has device type rstmgr,
123
* otherwise the returned value is unspecified.
124
*/
125
dt_rstmgr_t
dt_rstmgr_from_instance_id
(
dt_instance_id_t
inst_id);
126
127
/**
128
* Get the instance ID of an instance.
129
*
130
* @param dt Instance of rstmgr.
131
* @return The instance ID of that instance.
132
*/
133
dt_instance_id_t
dt_rstmgr_instance_id
(
dt_rstmgr_t
dt);
134
135
/**
136
* Get the register base address of an instance.
137
*
138
* @param dt Instance of rstmgr.
139
* @param reg_block The register block requested.
140
* @return The register base address of the requested block.
141
*/
142
uint32_t
dt_rstmgr_reg_block
(
143
dt_rstmgr_t
dt,
144
dt_rstmgr_reg_block_t
reg_block);
145
146
/**
147
* Get the primary register base address of an instance.
148
*
149
* This is just a convenience function, equivalent to
150
* `dt_rstmgr_reg_block(dt, kDtRstmgrRegBlockCore)`
151
*
152
* @param dt Instance of rstmgr.
153
* @return The register base address of the primary register block.
154
*/
155
static
inline
uint32_t dt_rstmgr_primary_reg_block(
156
dt_rstmgr_t
dt) {
157
return
dt_rstmgr_reg_block
(dt, kDtRstmgrRegBlockCore);
158
}
159
160
161
162
163
/**
164
* Get the clock signal connected to a clock port of an instance.
165
*
166
* @param dt Instance of rstmgr.
167
* @param clk Clock port.
168
* @return Clock signal.
169
*/
170
dt_clock_t
dt_rstmgr_clock
(
171
dt_rstmgr_t
dt,
172
dt_rstmgr_clock_t
clk);
173
174
/**
175
* Get the reset signal connected to a reset port of an instance.
176
*
177
* @param dt Instance of rstmgr.
178
* @param rst Reset port.
179
* @return Reset signal.
180
*/
181
dt_reset_t
dt_rstmgr_reset
(
182
dt_rstmgr_t
dt,
183
dt_rstmgr_reset_t
rst);
184
185
186
187
/**
188
* Get the number of software resets.
189
*
190
* @param dt Instance of rstmgr.
191
* @return Number of software resets.
192
*/
193
size_t
dt_rstmgr_sw_reset_count
(
dt_rstmgr_t
dt);
194
195
/**
196
* Get the reset ID of a software reset.
197
*
198
* The resets are ordered in the same way as they appear in the registers.
199
*
200
* @param dt Instance of rstmgr.
201
* @param idx Index of the software reset, between 0 and `dt_rstmgr_sw_reset_count(dt)-1`.
202
* @return Reset ID, or `kDtResetUnknown` for invalid parameters.
203
*/
204
dt_reset_t
dt_rstmgr_sw_reset
(
dt_rstmgr_t
dt,
size_t
idx);
205
206
/**
207
* Description of a reset request source.
208
*
209
* A reset request source is always identified by the instance ID of the module where it comes
210
* from. In principle, some instances could have several reset requests. If this is the case,
211
* the `rst_req` can be used to distinguish between those. It should be cast to the
212
* `dt_<ip>_reset_req_t` type of the corresponding IP.
213
*
214
* WARNING At the moment, three hardcoded reset requests are treated specially and have their
215
* `reset_req` field set to `0` because there is no corresponding reset request declared by those
216
* IPs:
217
* - the main power glitch reset request, coming from the `pwrmgr`,
218
* - the escalation reset request, coming from the `alert_handler`,
219
* - the non-debug-module reset request, coming from the `rv_dm`.
220
*/
221
typedef
struct
dt_rstmgr_reset_req_src
{
222
dt_instance_id_t
inst_id
;
/**< Instance ID of the source of this reset request. */
223
size_t
reset_req
;
/**< Index of the reset request signal for that instance. */
224
}
dt_rstmgr_reset_req_src_t
;
225
226
227
/**
228
* Get the number of hardware reset requests.
229
*
230
* @param dt Instance of rstmgr.
231
* @return Number of reset requests.
232
*/
233
size_t
dt_rstmgr_hw_reset_req_src_count
(
dt_rstmgr_t
dt);
234
235
/**
236
* Get the description of a reset request.
237
*
238
* The reset requests are ordered as they appear in the registers.
239
*
240
* @param dt Instance of rstmgr.
241
* @param idx Index of the reset request source, between 0 and
242
* `dt_pwrmgr_hw_reset_req_src_count(dt)-1`.
243
* @return Description of the reset.
244
*/
245
dt_rstmgr_reset_req_src_t
dt_rstmgr_hw_reset_req_src
(
dt_rstmgr_t
dt,
size_t
idx);
246
247
248
249
#ifdef __cplusplus
250
}
// extern "C"
251
#endif
// __cplusplus
252
253
#endif
// OPENTITAN_DT_RSTMGR_H_
(englishbreakfast)
hw
top
dt
rstmgr.h
Return to
OpenTitan Documentation