Software APIs
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
#ifdef __cplusplus
11
extern
"C"
{
12
#endif
// __cplusplus
13
14
/**
15
* @file
16
* @brief Device Tables (DT) for IP pwrmgr and top earlgrey.
17
*
18
* This file contains the type definitions and global functions of the pwrmgr.
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_pwrmgr
{
32
kDtPwrmgrFirst
= 0,
/**< First instance */
33
kDtPwrmgrAon
= 0,
/**< pwrmgr_aon */
34
}
dt_pwrmgr_t
;
35
36
enum
{
37
kDtPwrmgrCount
= 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_pwrmgr_reg_block
{
47
kDtPwrmgrRegBlockCore = 0,
/**< */
48
}
dt_pwrmgr_reg_block_t
;
49
50
enum
{
51
kDtPwrmgrRegBlockCount
= 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_pwrmgr_reg_block_t
kDtPwrmgrRegBlockPrimary = kDtPwrmgrRegBlockCore;
57
58
/**
59
* List of IRQs.
60
*
61
* IRQs are guaranteed to be numbered consecutively from 0.
62
*/
63
typedef
enum
dt_pwrmgr_irq
{
64
kDtPwrmgrIrqWakeup
= 0,
/**< Wake from low power state. See wake info for more details */
65
}
dt_pwrmgr_irq_t
;
66
67
enum
{
68
kDtPwrmgrIrqCount
= 1,
/**< Number of IRQs */
69
};
70
71
72
/**
73
* List of Alerts.
74
*
75
* Alerts are guaranteed to be numbered consecutively from 0.
76
*/
77
typedef
enum
dt_pwrmgr_alert
{
78
kDtPwrmgrAlertFatalFault
= 0,
/**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
79
}
dt_pwrmgr_alert_t
;
80
81
enum
{
82
kDtPwrmgrAlertCount
= 1,
/**< Number of Alerts */
83
};
84
85
86
/**
87
* List of clock ports.
88
*
89
* Clock ports are guaranteed to be numbered consecutively from 0.
90
*/
91
typedef
enum
dt_pwrmgr_clock
{
92
kDtPwrmgrClockClk
= 0,
/**< Clock port clk_i */
93
kDtPwrmgrClockSlow
= 1,
/**< Clock port clk_slow_i */
94
kDtPwrmgrClockLc
= 2,
/**< Clock port clk_lc_i */
95
kDtPwrmgrClockEsc
= 3,
/**< Clock port clk_esc_i */
96
}
dt_pwrmgr_clock_t
;
97
98
enum
{
99
kDtPwrmgrClockCount
= 4,
/**< Number of clock ports */
100
};
101
102
103
/**
104
* List of reset ports.
105
*
106
* Reset ports are guaranteed to be numbered consecutively from 0.
107
*/
108
typedef
enum
dt_pwrmgr_reset
{
109
kDtPwrmgrResetRst
= 0,
/**< Reset port rst_ni */
110
kDtPwrmgrResetMain
= 1,
/**< Reset port rst_main_ni */
111
kDtPwrmgrResetSlow
= 2,
/**< Reset port rst_slow_ni */
112
kDtPwrmgrResetLc
= 3,
/**< Reset port rst_lc_ni */
113
kDtPwrmgrResetEsc
= 4,
/**< Reset port rst_esc_ni */
114
}
dt_pwrmgr_reset_t
;
115
116
enum
{
117
kDtPwrmgrResetCount
= 5,
/**< Number of reset ports */
118
};
119
120
121
/**
122
* List of supported hardware features.
123
*/
124
#define OPENTITAN_PWRMGR_HAS_STARTUP_LIFE_CYCLE_INITIALIZATION 1
125
#define OPENTITAN_PWRMGR_HAS_CLOCK_CONTROL_IO_IN_LOW_POWER 1
126
#define OPENTITAN_PWRMGR_HAS_CLOCK_CONTROL_MAIN_IN_LOW_POWER 1
127
#define OPENTITAN_PWRMGR_HAS_CLOCK_CONTROL_USB_IN_LOW_POWER 1
128
#define OPENTITAN_PWRMGR_HAS_CLOCK_CONTROL_USB_WHEN_ACTIVE 1
129
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_ENTRY 1
130
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_DISABLE_POWER 1
131
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_SYSRST_CTRL_AON_WKUP_REQ_WAKEUP_ENABLE 1
132
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_SYSRST_CTRL_AON_WKUP_REQ_WAKEUP_REQUEST 1
133
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_ADC_CTRL_AON_WKUP_REQ_WAKEUP_ENABLE 1
134
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_ADC_CTRL_AON_WKUP_REQ_WAKEUP_REQUEST 1
135
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_PINMUX_AON_PIN_WKUP_REQ_WAKEUP_ENABLE 1
136
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_PINMUX_AON_PIN_WKUP_REQ_WAKEUP_REQUEST 1
137
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_PINMUX_AON_USB_WKUP_REQ_WAKEUP_ENABLE 1
138
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_PINMUX_AON_USB_WKUP_REQ_WAKEUP_REQUEST 1
139
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_AON_TIMER_AON_WKUP_REQ_WAKEUP_ENABLE 1
140
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_AON_TIMER_AON_WKUP_REQ_WAKEUP_REQUEST 1
141
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_SENSOR_CTRL_AON_WKUP_REQ_WAKEUP_ENABLE 1
142
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_SENSOR_CTRL_AON_WKUP_REQ_WAKEUP_REQUEST 1
143
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_WAKE_INFO 1
144
#define OPENTITAN_PWRMGR_HAS_RESET_CHECK_ROM_INTEGRITY 1
145
#define OPENTITAN_PWRMGR_HAS_RESET_SYSRST_CTRL_AON_RST_REQ_ENABLE 1
146
#define OPENTITAN_PWRMGR_HAS_RESET_SYSRST_CTRL_AON_RST_REQ_REQUEST 1
147
#define OPENTITAN_PWRMGR_HAS_RESET_AON_TIMER_AON_AON_TIMER_RST_REQ_ENABLE 1
148
#define OPENTITAN_PWRMGR_HAS_RESET_AON_TIMER_AON_AON_TIMER_RST_REQ_REQUEST 1
149
#define OPENTITAN_PWRMGR_HAS_RESET_ESCALATION_REQUEST 1
150
#define OPENTITAN_PWRMGR_HAS_RESET_ESCALATION_TIMEOUT 1
151
#define OPENTITAN_PWRMGR_HAS_RESET_SW_RST_REQUEST 1
152
#define OPENTITAN_PWRMGR_HAS_RESET_MAIN_POWER_GLITCH_RESET 1
153
#define OPENTITAN_PWRMGR_HAS_RESET_NDM_RESET_REQUEST 1
154
#define OPENTITAN_PWRMGR_HAS_RESET_POR_REQUEST 1
155
156
157
158
/**
159
* Get the pwrmgr instance from an instance ID
160
*
161
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
162
*
163
* @param inst_id Instance ID.
164
* @return A pwrmgr instance.
165
*
166
* **Note:** This function only makes sense if the instance ID has device type pwrmgr,
167
* otherwise the returned value is unspecified.
168
*/
169
dt_pwrmgr_t
dt_pwrmgr_from_instance_id
(
dt_instance_id_t
inst_id);
170
171
/**
172
* Get the instance ID of an instance.
173
*
174
* @param dt Instance of pwrmgr.
175
* @return The instance ID of that instance.
176
*/
177
dt_instance_id_t
dt_pwrmgr_instance_id
(
dt_pwrmgr_t
dt);
178
179
/**
180
* Get the register base address of an instance.
181
*
182
* @param dt Instance of pwrmgr.
183
* @param reg_block The register block requested.
184
* @return The register base address of the requested block.
185
*/
186
uint32_t
dt_pwrmgr_reg_block
(
187
dt_pwrmgr_t
dt,
188
dt_pwrmgr_reg_block_t
reg_block);
189
190
/**
191
* Get the primary register base address of an instance.
192
*
193
* This is just a convenience function, equivalent to
194
* `dt_pwrmgr_reg_block(dt, kDtPwrmgrRegBlockCore)`
195
*
196
* @param dt Instance of pwrmgr.
197
* @return The register base address of the primary register block.
198
*/
199
static
inline
uint32_t dt_pwrmgr_primary_reg_block(
200
dt_pwrmgr_t
dt) {
201
return
dt_pwrmgr_reg_block
(dt, kDtPwrmgrRegBlockCore);
202
}
203
204
/**
205
* Get the PLIC ID of a pwrmgr IRQ for a given instance.
206
*
207
* If the instance is not connected to the PLIC, this function
208
* will return `kDtPlicIrqIdNone`.
209
*
210
* @param dt Instance of pwrmgr.
211
* @param irq A pwrmgr IRQ.
212
* @return The PLIC ID of the IRQ of this instance.
213
*/
214
dt_plic_irq_id_t
dt_pwrmgr_irq_to_plic_id
(
215
dt_pwrmgr_t
dt,
216
dt_pwrmgr_irq_t
irq);
217
218
/**
219
* Convert a global IRQ ID to a local pwrmgr IRQ type.
220
*
221
* @param dt Instance of pwrmgr.
222
* @param irq A PLIC ID that belongs to this instance.
223
* @return The pwrmgr IRQ, or `kDtPwrmgrIrqCount`.
224
*
225
* **Note:** This function assumes that the PLIC ID belongs to the instance
226
* of pwrmgr passed in parameter. In other words, it must be the case that
227
* `dt_pwrmgr_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
228
* will return `kDtPwrmgrIrqCount`.
229
*/
230
dt_pwrmgr_irq_t
dt_pwrmgr_irq_from_plic_id
(
231
dt_pwrmgr_t
dt,
232
dt_plic_irq_id_t
irq);
233
234
235
/**
236
* Get the alert ID of a pwrmgr alert for a given instance.
237
*
238
* **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
239
* instances where the instance is not connected, the return value is unspecified.
240
*
241
* @param dt Instance of pwrmgr.
242
* @param alert A pwrmgr alert.
243
* @return The Alert Handler alert ID of the alert of this instance.
244
*/
245
dt_alert_id_t
dt_pwrmgr_alert_to_alert_id
(
246
dt_pwrmgr_t
dt,
247
dt_pwrmgr_alert_t
alert);
248
249
/**
250
* Convert a global alert ID to a local pwrmgr alert type.
251
*
252
* @param dt Instance of pwrmgr.
253
* @param alert A global alert ID that belongs to this instance.
254
* @return The pwrmgr alert, or `kDtPwrmgrAlertCount`.
255
*
256
* **Note:** This function assumes that the global alert ID belongs to the
257
* instance of pwrmgr passed in parameter. In other words, it must be the case
258
* that `dt_pwrmgr_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
259
* this function will return `kDtPwrmgrAlertCount`.
260
*/
261
dt_pwrmgr_alert_t
dt_pwrmgr_alert_from_alert_id
(
262
dt_pwrmgr_t
dt,
263
dt_alert_id_t
alert);
264
265
266
267
/**
268
* Get the clock signal connected to a clock port of an instance.
269
*
270
* @param dt Instance of pwrmgr.
271
* @param clk Clock port.
272
* @return Clock signal.
273
*/
274
dt_clock_t
dt_pwrmgr_clock
(
275
dt_pwrmgr_t
dt,
276
dt_pwrmgr_clock_t
clk);
277
278
/**
279
* Get the reset signal connected to a reset port of an instance.
280
*
281
* @param dt Instance of pwrmgr.
282
* @param rst Reset port.
283
* @return Reset signal.
284
*/
285
dt_reset_t
dt_pwrmgr_reset
(
286
dt_pwrmgr_t
dt,
287
dt_pwrmgr_reset_t
rst);
288
289
290
291
/**
292
* Description of a wakeup source.
293
*
294
* A wakeup source is always identified by the instance ID of the module where it comes from.
295
* Some instances can have several wakeup signals, e.g. the pinmux has two (`pin` and `usb`).
296
* For such IPs, it is not sufficient to know the instance, we also need to know which
297
* signal triggered the wakeup. The `wakeup` index can be used to distinguish between those.
298
* This value should be casted to the `dt_<ip>_wakeup_t` type of the corresponding IP.
299
* For example, if the `pwrmgr` has two `pinmux` wakeup sources as described above, it's
300
* two wakeup sources will be described as follows:
301
* ```c
302
* {.inst_id = kDtInstanceIdPinmux, .wakeup = kDtPinmuxWakeupPinWkupReq}, // for `pin`
303
* {.inst_id = kDtInstanceIdPinmux, .wakeup = kDtPinmuxWakeupUsbWkupReq}, // for `usb`
304
* ```
305
*/
306
typedef
struct
dt_pwrmgr_wakeup_src
{
307
dt_instance_id_t
inst_id
;
/**< Instance ID of the source of this wakeup. */
308
size_t
wakeup
;
/**< Index of the wakeup signal for that instance. */
309
}
dt_pwrmgr_wakeup_src_t
;
310
311
312
/**
313
* Get the number of wakeup sources.
314
*
315
* @param dt Instance of pwrmgr.
316
* @return Number of wakeup sources.
317
*/
318
size_t
dt_pwrmgr_wakeup_src_count
(
dt_pwrmgr_t
dt);
319
320
/**
321
* Get the description of a wakeup source.
322
*
323
* The wakeup sources are ordered as they appear in the registers.
324
*
325
* @param dt Instance of pwrmgr.
326
* @param idx Index of the wakeup source, between 0 and `dt_pwrmgr_wakeup_src_count(dt)-1`.
327
* @return Description of the source.
328
*/
329
dt_pwrmgr_wakeup_src_t
dt_pwrmgr_wakeup_src
(
dt_pwrmgr_t
dt,
size_t
idx);
330
331
/**
332
* Description of a reset request source.
333
*
334
* A reset request source is always identified by the instance ID of the module where it comes
335
* from. In principle, some instances could have several reset requests. If this is the case,
336
* the `rst_req` can be used to distinguish between those. It should be cast to the
337
* `dt_<ip>_reset_req_t` type of the corresponding IP.
338
*/
339
typedef
struct
dt_pwrmgr_reset_req_src
{
340
dt_instance_id_t
inst_id
;
/**< Instance ID of the source of this reset request. */
341
size_t
reset_req
;
/**< Index of the reset request signal for that instance. */
342
}
dt_pwrmgr_reset_req_src_t
;
343
344
345
/**
346
* Get the number of peripheral reset requests.
347
*
348
* @param dt Instance of pwrmgr.
349
* @return Number of reset requests.
350
*/
351
size_t
dt_pwrmgr_reset_request_src_count
(
dt_pwrmgr_t
dt);
352
353
/**
354
* Get the description of a reset request.
355
*
356
* The reset requests are ordered as they appear in the registers.
357
*
358
* @param dt Instance of pwrmgr.
359
* @param idx Index of the reset request source, between 0 and
360
* `dt_pwrmgr_reset_request_src_count(dt)-1`.
361
* @return Description of the reset.
362
*/
363
dt_pwrmgr_reset_req_src_t
dt_pwrmgr_reset_request_src
(
dt_pwrmgr_t
dt,
size_t
idx);
364
365
366
367
#ifdef __cplusplus
368
}
// extern "C"
369
#endif
// __cplusplus
370
371
#endif
// OPENTITAN_DT_PWRMGR_H_
(earlgrey)
hw
top
dt
pwrmgr.h
Return to
OpenTitan Documentation