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