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