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