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
kDtPwrmgr
= 0,
/**< pwrmgr */
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_I3C0_RSTDET_WKUP_REQ_WAKEUP_ENABLE 1
132
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_I3C0_RSTDET_WKUP_REQ_WAKEUP_REQUEST 1
133
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_I3C1_RSTDET_WKUP_REQ_WAKEUP_ENABLE 1
134
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_I3C1_RSTDET_WKUP_REQ_WAKEUP_REQUEST 1
135
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_SYSRST_CTRL_WKUP_REQ_WAKEUP_ENABLE 1
136
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_SYSRST_CTRL_WKUP_REQ_WAKEUP_REQUEST 1
137
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_ADC_CTRL_WKUP_REQ_WAKEUP_ENABLE 1
138
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_ADC_CTRL_WKUP_REQ_WAKEUP_REQUEST 1
139
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_PINMUX_PIN_WKUP_REQ_WAKEUP_ENABLE 1
140
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_PINMUX_PIN_WKUP_REQ_WAKEUP_REQUEST 1
141
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_PINMUX_USB_WKUP_REQ_WAKEUP_ENABLE 1
142
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_PINMUX_USB_WKUP_REQ_WAKEUP_REQUEST 1
143
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_AON_TIMER_WKUP_REQ_WAKEUP_ENABLE 1
144
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_AON_TIMER_WKUP_REQ_WAKEUP_REQUEST 1
145
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_SENSOR_CTRL_WKUP_REQ_WAKEUP_ENABLE 1
146
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_SENSOR_CTRL_WKUP_REQ_WAKEUP_REQUEST 1
147
#define OPENTITAN_PWRMGR_HAS_LOW_POWER_WAKE_INFO 1
148
#define OPENTITAN_PWRMGR_HAS_RESET_CHECK_ROM_INTEGRITY 1
149
#define OPENTITAN_PWRMGR_HAS_RESET_SYSRST_CTRL_RST_REQ_ENABLE 1
150
#define OPENTITAN_PWRMGR_HAS_RESET_SYSRST_CTRL_RST_REQ_REQUEST 1
151
#define OPENTITAN_PWRMGR_HAS_RESET_AON_TIMER_AON_TIMER_RST_REQ_ENABLE 1
152
#define OPENTITAN_PWRMGR_HAS_RESET_AON_TIMER_AON_TIMER_RST_REQ_REQUEST 1
153
#define OPENTITAN_PWRMGR_HAS_RESET_ESCALATION_REQUEST 1
154
#define OPENTITAN_PWRMGR_HAS_RESET_ESCALATION_TIMEOUT 1
155
#define OPENTITAN_PWRMGR_HAS_RESET_SW_RST_REQUEST 1
156
#define OPENTITAN_PWRMGR_HAS_RESET_MAIN_POWER_GLITCH_RESET 1
157
#define OPENTITAN_PWRMGR_HAS_RESET_NDM_RESET_REQUEST 1
158
#define OPENTITAN_PWRMGR_HAS_RESET_POR_REQUEST 1
159
160
161
162
/**
163
* Get the pwrmgr instance from an instance ID
164
*
165
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
166
*
167
* @param inst_id Instance ID.
168
* @return A pwrmgr instance.
169
*
170
* **Note:** This function only makes sense if the instance ID has device type pwrmgr,
171
* otherwise the returned value is unspecified.
172
*/
173
dt_pwrmgr_t
dt_pwrmgr_from_instance_id
(
dt_instance_id_t
inst_id);
174
175
/**
176
* Get the instance ID of an instance.
177
*
178
* @param dt Instance of pwrmgr.
179
* @return The instance ID of that instance.
180
*/
181
dt_instance_id_t
dt_pwrmgr_instance_id
(
dt_pwrmgr_t
dt);
182
183
/**
184
* Get the register base address of an instance.
185
*
186
* @param dt Instance of pwrmgr.
187
* @param reg_block The register block requested.
188
* @return The register base address of the requested block.
189
*/
190
uint32_t
dt_pwrmgr_reg_block
(
191
dt_pwrmgr_t
dt,
192
dt_pwrmgr_reg_block_t
reg_block);
193
194
/**
195
* Get the primary register base address of an instance.
196
*
197
* This is just a convenience function, equivalent to
198
* `dt_pwrmgr_reg_block(dt, kDtPwrmgrRegBlockCore)`
199
*
200
* @param dt Instance of pwrmgr.
201
* @return The register base address of the primary register block.
202
*/
203
static
inline
uint32_t dt_pwrmgr_primary_reg_block(
204
dt_pwrmgr_t
dt) {
205
return
dt_pwrmgr_reg_block
(dt, kDtPwrmgrRegBlockCore);
206
}
207
208
/**
209
* Get the PLIC ID of a pwrmgr IRQ for a given instance.
210
*
211
* If the instance is not connected to the PLIC, this function
212
* will return `kDtPlicIrqIdNone`.
213
*
214
* @param dt Instance of pwrmgr.
215
* @param irq A pwrmgr IRQ.
216
* @return The PLIC ID of the IRQ of this instance.
217
*/
218
dt_plic_irq_id_t
dt_pwrmgr_irq_to_plic_id
(
219
dt_pwrmgr_t
dt,
220
dt_pwrmgr_irq_t
irq);
221
222
/**
223
* Convert a global IRQ ID to a local pwrmgr IRQ type.
224
*
225
* @param dt Instance of pwrmgr.
226
* @param irq A PLIC ID that belongs to this instance.
227
* @return The pwrmgr IRQ, or `kDtPwrmgrIrqCount`.
228
*
229
* **Note:** This function assumes that the PLIC ID belongs to the instance
230
* of pwrmgr passed in parameter. In other words, it must be the case that
231
* `dt_pwrmgr_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
232
* will return `kDtPwrmgrIrqCount`.
233
*/
234
dt_pwrmgr_irq_t
dt_pwrmgr_irq_from_plic_id
(
235
dt_pwrmgr_t
dt,
236
dt_plic_irq_id_t
irq);
237
238
239
/**
240
* Get the alert ID of a pwrmgr alert for a given instance.
241
*
242
* **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
243
* instances where the instance is not connected, the return value is unspecified.
244
*
245
* @param dt Instance of pwrmgr.
246
* @param alert A pwrmgr alert.
247
* @return The Alert Handler alert ID of the alert of this instance.
248
*/
249
dt_alert_id_t
dt_pwrmgr_alert_to_alert_id
(
250
dt_pwrmgr_t
dt,
251
dt_pwrmgr_alert_t
alert);
252
253
/**
254
* Convert a global alert ID to a local pwrmgr alert type.
255
*
256
* @param dt Instance of pwrmgr.
257
* @param alert A global alert ID that belongs to this instance.
258
* @return The pwrmgr alert, or `kDtPwrmgrAlertCount`.
259
*
260
* **Note:** This function assumes that the global alert ID belongs to the
261
* instance of pwrmgr passed in parameter. In other words, it must be the case
262
* that `dt_pwrmgr_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
263
* this function will return `kDtPwrmgrAlertCount`.
264
*/
265
dt_pwrmgr_alert_t
dt_pwrmgr_alert_from_alert_id
(
266
dt_pwrmgr_t
dt,
267
dt_alert_id_t
alert);
268
269
270
271
/**
272
* Get the clock signal connected to a clock port of an instance.
273
*
274
* @param dt Instance of pwrmgr.
275
* @param clk Clock port.
276
* @return Clock signal.
277
*/
278
dt_clock_t
dt_pwrmgr_clock
(
279
dt_pwrmgr_t
dt,
280
dt_pwrmgr_clock_t
clk);
281
282
/**
283
* Get the reset signal connected to a reset port of an instance.
284
*
285
* @param dt Instance of pwrmgr.
286
* @param rst Reset port.
287
* @return Reset signal.
288
*/
289
dt_reset_t
dt_pwrmgr_reset
(
290
dt_pwrmgr_t
dt,
291
dt_pwrmgr_reset_t
rst);
292
293
294
295
/**
296
* Description of a wakeup source.
297
*
298
* A wakeup source is always identified by the instance ID of the module where it comes from.
299
* Some instances can have several wakeup signals, e.g. the pinmux has two (`pin` and `usb`).
300
* For such IPs, it is not sufficient to know the instance, we also need to know which
301
* signal triggered the wakeup. The `wakeup` index can be used to distinguish between those.
302
* This value should be casted to the `dt_<ip>_wakeup_t` type of the corresponding IP.
303
* For example, if the `pwrmgr` has two `pinmux` wakeup sources as described above, it's
304
* two wakeup sources will be described as follows:
305
* ```c
306
* {.inst_id = kDtInstanceIdPinmux, .wakeup = kDtPinmuxWakeupPinWkupReq}, // for `pin`
307
* {.inst_id = kDtInstanceIdPinmux, .wakeup = kDtPinmuxWakeupUsbWkupReq}, // for `usb`
308
* ```
309
*/
310
typedef
struct
dt_pwrmgr_wakeup_src
{
311
dt_instance_id_t
inst_id
;
/**< Instance ID of the source of this wakeup. */
312
size_t
wakeup
;
/**< Index of the wakeup signal for that instance. */
313
}
dt_pwrmgr_wakeup_src_t
;
314
315
316
/**
317
* Get the number of wakeup sources.
318
*
319
* @param dt Instance of pwrmgr.
320
* @return Number of wakeup sources.
321
*/
322
size_t
dt_pwrmgr_wakeup_src_count
(
dt_pwrmgr_t
dt);
323
324
/**
325
* Get the description of a wakeup source.
326
*
327
* The wakeup sources are ordered as they appear in the registers.
328
*
329
* @param dt Instance of pwrmgr.
330
* @param idx Index of the wakeup source, between 0 and `dt_pwrmgr_wakeup_src_count(dt)-1`.
331
* @return Description of the source.
332
*/
333
dt_pwrmgr_wakeup_src_t
dt_pwrmgr_wakeup_src
(
dt_pwrmgr_t
dt,
size_t
idx);
334
335
/**
336
* Description of a reset request source.
337
*
338
* A reset request source is always identified by the instance ID of the module where it comes
339
* from. In principle, some instances could have several reset requests. If this is the case,
340
* the `rst_req` can be used to distinguish between those. It should be cast to the
341
* `dt_<ip>_reset_req_t` type of the corresponding IP.
342
*/
343
typedef
struct
dt_pwrmgr_reset_req_src
{
344
dt_instance_id_t
inst_id
;
/**< Instance ID of the source of this reset request. */
345
size_t
reset_req
;
/**< Index of the reset request signal for that instance. */
346
}
dt_pwrmgr_reset_req_src_t
;
347
348
349
/**
350
* Get the number of peripheral reset requests.
351
*
352
* @param dt Instance of pwrmgr.
353
* @return Number of reset requests.
354
*/
355
size_t
dt_pwrmgr_reset_request_src_count
(
dt_pwrmgr_t
dt);
356
357
/**
358
* Get the description of a reset request.
359
*
360
* The reset requests are ordered as they appear in the registers.
361
*
362
* @param dt Instance of pwrmgr.
363
* @param idx Index of the reset request source, between 0 and
364
* `dt_pwrmgr_reset_request_src_count(dt)-1`.
365
* @return Description of the reset.
366
*/
367
dt_pwrmgr_reset_req_src_t
dt_pwrmgr_reset_request_src
(
dt_pwrmgr_t
dt,
size_t
idx);
368
369
370
371
#ifdef __cplusplus
372
}
// extern "C"
373
#endif
// __cplusplus
374
375
#endif
// OPENTITAN_DT_PWRMGR_H_
(earlgrey)
hw
top
dt
pwrmgr.h
Return to
OpenTitan Documentation