Software APIs
dt_pwrmgr.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_PWRMGR_H_
8
#define OPENTITAN_DT_PWRMGR_H_
9
10
/**
11
* @file
12
* @brief Device Tables (DT) for IP pwrmgr and top englishbreakfast.
13
*
14
* This file contains the type definitions and global functions of the pwrmgr.
15
*/
16
17
#include "
dt_api.h
"
18
#include <stdint.h>
19
20
/**
21
* List of instances.
22
*/
23
typedef
enum
dt_pwrmgr
{
24
kDtPwrmgrAon
= 0,
/**< pwrmgr_aon */
25
kDtPwrmgrFirst = 0,
/**< \internal First instance */
26
kDtPwrmgrCount = 1,
/**< \internal Number of instances */
27
}
dt_pwrmgr_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_pwrmgr_reg_block
{
35
kDtPwrmgrRegBlockCore = 0,
/**< */
36
kDtPwrmgrRegBlockCount = 1,
/**< \internal Number of register blocks */
37
}
dt_pwrmgr_reg_block_t
;
38
39
/** Primary register block (associated with the "primary" set of registers that control the IP). */
40
static
const
dt_pwrmgr_reg_block_t
kDtPwrmgrRegBlockPrimary = kDtPwrmgrRegBlockCore;
41
42
/**
43
* List of IRQs.
44
*
45
* IRQs are guaranteed to be numbered consecutively from 0.
46
*/
47
typedef
enum
dt_pwrmgr_irq
{
48
kDtPwrmgrIrqWakeup
= 0,
/**< Wake from low power state. See wake info for more details */
49
kDtPwrmgrIrqCount = 1,
/**< \internal Number of IRQs */
50
}
dt_pwrmgr_irq_t
;
51
52
/**
53
* List of clock ports.
54
*
55
* Clock ports are guaranteed to be numbered consecutively from 0.
56
*/
57
typedef
enum
dt_pwrmgr_clock
{
58
kDtPwrmgrClockClk
= 0,
/**< Clock port clk_i */
59
kDtPwrmgrClockSlow
= 1,
/**< Clock port clk_slow_i */
60
kDtPwrmgrClockLc
= 2,
/**< Clock port clk_lc_i */
61
kDtPwrmgrClockEsc
= 3,
/**< Clock port clk_esc_i */
62
kDtPwrmgrClockCount = 4,
/**< \internal Number of clock ports */
63
}
dt_pwrmgr_clock_t
;
64
65
/**
66
* List of reset ports.
67
*
68
* Reset ports are guaranteed to be numbered consecutively from 0.
69
*/
70
typedef
enum
dt_pwrmgr_reset
{
71
kDtPwrmgrResetRst
= 0,
/**< Reset port rst_ni */
72
kDtPwrmgrResetMain
= 1,
/**< Reset port rst_main_ni */
73
kDtPwrmgrResetSlow
= 2,
/**< Reset port rst_slow_ni */
74
kDtPwrmgrResetLc
= 3,
/**< Reset port rst_lc_ni */
75
kDtPwrmgrResetEsc
= 4,
/**< Reset port rst_esc_ni */
76
kDtPwrmgrResetCount = 5,
/**< \internal Number of reset ports */
77
}
dt_pwrmgr_reset_t
;
78
79
/**
80
* List of supported hardware features.
81
*/
82
#define OPENTITAN_PWRMGR_HAS_STARTUP_LIFE_CYCLE_INITIALIZATION 1
83
#define OPENTITAN_PWRMGR_HAS_CLOCK_CONTROL_IO_IN_LOW_POWER 1
84
#define OPENTITAN_PWRMGR_HAS_CLOCK_CONTROL_MAIN_IN_LOW_POWER 1
85
#define OPENTITAN_PWRMGR_HAS_CLOCK_CONTROL_USB_IN_LOW_POWER 1
86
#define OPENTITAN_PWRMGR_HAS_CLOCK_CONTROL_USB_WHEN_ACTIVE 1
87
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_ENTRY 1
88
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_DISABLE_POWER 1
89
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_PINMUX_AON_PIN_WKUP_REQ_WAKEUP_ENABLE 1
90
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_PINMUX_AON_PIN_WKUP_REQ_WAKEUP_REQUEST 1
91
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_PINMUX_AON_USB_WKUP_REQ_WAKEUP_ENABLE 1
92
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_PINMUX_AON_USB_WKUP_REQ_WAKEUP_REQUEST 1
93
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_AON_TIMER_AON_WKUP_REQ_WAKEUP_ENABLE 1
94
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_AON_TIMER_AON_WKUP_REQ_WAKEUP_REQUEST 1
95
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_WAKE_INFO 1
96
#define OPENTITAN_PWRMGR_HAS_RESET_CHECK_ROM_INTEGRITY 1
97
#define OPENTITAN_PWRMGR_HAS_RESET_AON_TIMER_AON_AON_TIMER_RST_REQ_ENABLE 1
98
#define OPENTITAN_PWRMGR_HAS_RESET_AON_TIMER_AON_AON_TIMER_RST_REQ_REQUEST 1
99
#define OPENTITAN_PWRMGR_HAS_RESET_ESCALATION_REQUEST 1
100
#define OPENTITAN_PWRMGR_HAS_RESET_ESCALATION_TIMEOUT 1
101
#define OPENTITAN_PWRMGR_HAS_RESET_SW_RST_REQUEST 1
102
#define OPENTITAN_PWRMGR_HAS_RESET_MAIN_POWER_GLITCH_RESET 1
103
#define OPENTITAN_PWRMGR_HAS_RESET_NDM_RESET_REQUEST 1
104
#define OPENTITAN_PWRMGR_HAS_RESET_POR_REQUEST 1
105
106
107
108
/**
109
* Get the pwrmgr instance from an instance ID
110
*
111
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
112
*
113
* @param inst_id Instance ID.
114
* @return A pwrmgr instance.
115
*
116
* **Note:** This function only makes sense if the instance ID has device type pwrmgr,
117
* otherwise the returned value is unspecified.
118
*/
119
dt_pwrmgr_t
dt_pwrmgr_from_instance_id
(
dt_instance_id_t
inst_id);
120
121
/**
122
* Get the instance ID of an instance.
123
*
124
* @param dt Instance of pwrmgr.
125
* @return The instance ID of that instance.
126
*/
127
dt_instance_id_t
dt_pwrmgr_instance_id
(
dt_pwrmgr_t
dt);
128
129
/**
130
* Get the register base address of an instance.
131
*
132
* @param dt Instance of pwrmgr.
133
* @param reg_block The register block requested.
134
* @return The register base address of the requested block.
135
*/
136
uint32_t
dt_pwrmgr_reg_block
(
137
dt_pwrmgr_t
dt,
138
dt_pwrmgr_reg_block_t
reg_block);
139
140
/**
141
* Get the primary register base address of an instance.
142
*
143
* This is just a convenience function, equivalent to
144
* `dt_pwrmgr_reg_block(dt, kDtPwrmgrRegBlockCore)`
145
*
146
* @param dt Instance of pwrmgr.
147
* @return The register base address of the primary register block.
148
*/
149
static
inline
uint32_t dt_pwrmgr_primary_reg_block(
150
dt_pwrmgr_t
dt) {
151
return
dt_pwrmgr_reg_block
(dt, kDtPwrmgrRegBlockCore);
152
}
153
154
/**
155
* Get the PLIC ID of a pwrmgr IRQ for a given instance.
156
*
157
* If the instance is not connected to the PLIC, this function
158
* will return `kDtPlicIrqIdNone`.
159
*
160
* @param dt Instance of pwrmgr.
161
* @param irq A pwrmgr IRQ.
162
* @return The PLIC ID of the IRQ of this instance.
163
*/
164
dt_plic_irq_id_t
dt_pwrmgr_irq_to_plic_id
(
165
dt_pwrmgr_t
dt,
166
dt_pwrmgr_irq_t
irq);
167
168
/**
169
* Convert a global IRQ ID to a local pwrmgr IRQ type.
170
*
171
* @param dt Instance of pwrmgr.
172
* @param irq A PLIC ID that belongs to this instance.
173
* @return The pwrmgr IRQ, or `kDtPwrmgrIrqCount`.
174
*
175
* **Note:** This function assumes that the PLIC ID belongs to the instance
176
* of pwrmgr passed in parameter. In other words, it must be the case that
177
* `dt_pwrmgr_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
178
* will return `kDtPwrmgrIrqCount`.
179
*/
180
dt_pwrmgr_irq_t
dt_pwrmgr_irq_from_plic_id
(
181
dt_pwrmgr_t
dt,
182
dt_plic_irq_id_t
irq);
183
184
185
186
187
/**
188
* Get the clock signal connected to a clock port of an instance.
189
*
190
* @param dt Instance of pwrmgr.
191
* @param clk Clock port.
192
* @return Clock signal.
193
*/
194
dt_clock_t
dt_pwrmgr_clock
(
195
dt_pwrmgr_t
dt,
196
dt_pwrmgr_clock_t
clk);
197
198
/**
199
* Get the reset signal connected to a reset port of an instance.
200
*
201
* @param dt Instance of pwrmgr.
202
* @param rst Reset port.
203
* @return Reset signal.
204
*/
205
dt_reset_t
dt_pwrmgr_reset
(
206
dt_pwrmgr_t
dt,
207
dt_pwrmgr_reset_t
rst);
208
209
210
/**
211
* Description of a wakeup source.
212
*
213
* A wakeup source is always identified by the instance ID of the module where it comes from.
214
* Some instances can have several wakeup signals, e.g. the pinmux has two (`pin` and `usb`).
215
* For such IPs, it is not sufficient to know the instance, we also need to know which
216
* signal triggered the wakeup. The `wakeup` index can be used to distinguish between those.
217
* This value should be casted to the `dt_<ip>_wakeup_t` type of the corresponding IP.
218
* For example, if the `pwrmgr` has two `pinmux` wakeup sources as described above, it's
219
* two wakeup sources will be described as follows:
220
* ```c
221
* {.inst_id = kDtInstanceIdPinmux, .wakeup = kDtPinmuxWakeupPinWkupReq}, // for `pin`
222
* {.inst_id = kDtInstanceIdPinmux, .wakeup = kDtPinmuxWakeupUsbWkupReq}, // for `usb`
223
* ```
224
*/
225
typedef
struct
dt_pwrmgr_wakeup_src
{
226
dt_instance_id_t
inst_id
;
/**< Instance ID of the source of this wakeup. */
227
size_t
wakeup
;
/**< Index of the wakeup signal for that instance. */
228
}
dt_pwrmgr_wakeup_src_t
;
229
230
231
/**
232
* Get the number of wakeup sources.
233
*
234
* @param dt Instance of pwrmgr.
235
* @return Number of wakeup sources.
236
*/
237
size_t
dt_pwrmgr_wakeup_src_count
(
dt_pwrmgr_t
dt);
238
239
/**
240
* Get the description of a wakeup source.
241
*
242
* The wakeup sources are ordered as they appear in the registers.
243
*
244
* @param dt Instance of pwrmgr.
245
* @param idx Index of the wakeup source, between 0 and `dt_pwrmgr_wakeup_src_count(dt)-1`.
246
* @return Description of the source.
247
*/
248
dt_pwrmgr_wakeup_src_t
dt_pwrmgr_wakeup_src
(
dt_pwrmgr_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
typedef
struct
dt_pwrmgr_reset_req_src
{
259
dt_instance_id_t
inst_id
;
/**< Instance ID of the source of this reset request. */
260
size_t
reset_req
;
/**< Index of the reset request signal for that instance. */
261
}
dt_pwrmgr_reset_req_src_t
;
262
263
264
/**
265
* Get the number of peripheral reset requests.
266
*
267
* @param dt Instance of pwrmgr.
268
* @return Number of reset requests.
269
*/
270
size_t
dt_pwrmgr_reset_request_src_count
(
dt_pwrmgr_t
dt);
271
272
/**
273
* Get the description of a reset request.
274
*
275
* The reset requests are ordered as they appear in the registers.
276
*
277
* @param dt Instance of pwrmgr.
278
* @param idx Index of the reset request source, between 0 and
279
* `dt_pwrmgr_reset_request_src_count(dt)-1`.
280
* @return Description of the reset.
281
*/
282
dt_pwrmgr_reset_req_src_t
dt_pwrmgr_reset_request_src
(
dt_pwrmgr_t
dt,
size_t
idx);
283
284
285
#endif
// OPENTITAN_DT_PWRMGR_H_
(englishbreakfast)
hw
top
dt
dt_pwrmgr.h
Return to
OpenTitan Documentation