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