Software APIs
dt_clkmgr.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_CLKMGR_H_
8
#define OPENTITAN_DT_CLKMGR_H_
9
10
#ifdef __cplusplus
11
extern
"C"
{
12
#endif
// __cplusplus
13
14
/**
15
* @file
16
* @brief Device Tables (DT) for IP clkmgr and top earlgrey.
17
*
18
* This file contains the type definitions and global functions of the clkmgr.
19
*/
20
21
#include "hw/top/dt/dt_api.h"
22
#include <stdint.h>
23
24
25
#include "
sw/device/lib/base/bitfield.h
"
26
27
28
/**
29
* List of instances.
30
*/
31
typedef
enum
dt_clkmgr
{
32
kDtClkmgrAon
= 0,
/**< clkmgr_aon */
33
kDtClkmgrFirst = 0,
/**< \internal First instance */
34
kDtClkmgrCount = 1,
/**< \internal Number of instances */
35
}
dt_clkmgr_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_clkmgr_reg_block
{
43
kDtClkmgrRegBlockCore = 0,
/**< */
44
kDtClkmgrRegBlockCount = 1,
/**< \internal Number of register blocks */
45
}
dt_clkmgr_reg_block_t
;
46
47
/** Primary register block (associated with the "primary" set of registers that control the IP). */
48
static
const
dt_clkmgr_reg_block_t
kDtClkmgrRegBlockPrimary = kDtClkmgrRegBlockCore;
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_clkmgr_memory
{
56
kDtClkmgrMemoryCount = 0,
/**< \internal Number of memories */
57
}
dt_clkmgr_memory_t
;
58
59
/**
60
* List of Alerts.
61
*
62
* Alerts are guaranteed to be numbered consecutively from 0.
63
*/
64
typedef
enum
dt_clkmgr_alert
{
65
kDtClkmgrAlertRecovFault
= 0,
/**< This recoverable alert is triggered when there are measurement errors. */
66
kDtClkmgrAlertFatalFault
= 1,
/**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
67
kDtClkmgrAlertCount = 2,
/**< \internal Number of Alerts */
68
}
dt_clkmgr_alert_t
;
69
70
/**
71
* List of clock ports.
72
*
73
* Clock ports are guaranteed to be numbered consecutively from 0.
74
*/
75
typedef
enum
dt_clkmgr_clock
{
76
kDtClkmgrClockClk
= 0,
/**< Clock port clk_i */
77
kDtClkmgrClockMain
= 1,
/**< Clock port clk_main_i */
78
kDtClkmgrClockIo
= 2,
/**< Clock port clk_io_i */
79
kDtClkmgrClockUsb
= 3,
/**< Clock port clk_usb_i */
80
kDtClkmgrClockAon
= 4,
/**< Clock port clk_aon_i */
81
kDtClkmgrClockCount = 5,
/**< \internal Number of clock ports */
82
}
dt_clkmgr_clock_t
;
83
84
/**
85
* List of reset ports.
86
*
87
* Reset ports are guaranteed to be numbered consecutively from 0.
88
*/
89
typedef
enum
dt_clkmgr_reset
{
90
kDtClkmgrResetRst
= 0,
/**< Reset port rst_ni */
91
kDtClkmgrResetRoot
= 1,
/**< Reset port rst_root_ni */
92
kDtClkmgrResetMain
= 2,
/**< Reset port rst_main_ni */
93
kDtClkmgrResetIo
= 3,
/**< Reset port rst_io_ni */
94
kDtClkmgrResetUsb
= 4,
/**< Reset port rst_usb_ni */
95
kDtClkmgrResetAon
= 5,
/**< Reset port rst_aon_ni */
96
kDtClkmgrResetIoDiv2
= 6,
/**< Reset port rst_io_div2_ni */
97
kDtClkmgrResetIoDiv4
= 7,
/**< Reset port rst_io_div4_ni */
98
kDtClkmgrResetRootMain
= 8,
/**< Reset port rst_root_main_ni */
99
kDtClkmgrResetRootIo
= 9,
/**< Reset port rst_root_io_ni */
100
kDtClkmgrResetRootIoDiv2
= 10,
/**< Reset port rst_root_io_div2_ni */
101
kDtClkmgrResetRootIoDiv4
= 11,
/**< Reset port rst_root_io_div4_ni */
102
kDtClkmgrResetRootUsb
= 12,
/**< Reset port rst_root_usb_ni */
103
kDtClkmgrResetCount = 13,
/**< \internal Number of reset ports */
104
}
dt_clkmgr_reset_t
;
105
106
/**
107
* List of supported hardware features.
108
*/
109
#define OPENTITAN_CLKMGR_HAS_ENABLE_IO_DIV4 1
110
#define OPENTITAN_CLKMGR_HAS_ENABLE_IO_DIV2 1
111
#define OPENTITAN_CLKMGR_HAS_ENABLE_IO 1
112
#define OPENTITAN_CLKMGR_HAS_ENABLE_USB 1
113
#define OPENTITAN_CLKMGR_HAS_HINT_AES 1
114
#define OPENTITAN_CLKMGR_HAS_HINT_HMAC 1
115
#define OPENTITAN_CLKMGR_HAS_HINT_KMAC 1
116
#define OPENTITAN_CLKMGR_HAS_HINT_OTBN 1
117
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_REGWEN 1
118
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO 1
119
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO_DIV2 1
120
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO_DIV4 1
121
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_MAIN 1
122
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_USB 1
123
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_RECOV_ERR 1
124
#define OPENTITAN_CLKMGR_HAS_LC_EXTCLK_SPEED 1
125
#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_REGWEN 1
126
#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_HIGH_SPEED 1
127
#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_LOW_SPEED 1
128
#define OPENTITAN_CLKMGR_HAS_JITTER_REGWEN 1
129
#define OPENTITAN_CLKMGR_HAS_JITTER_ENABLE 1
130
#define OPENTITAN_CLKMGR_HAS_ALERT_HANDLER_CLOCK_STATUS 1
131
132
133
134
/**
135
* Get the clkmgr instance from an instance ID
136
*
137
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
138
*
139
* @param inst_id Instance ID.
140
* @return A clkmgr instance.
141
*
142
* **Note:** This function only makes sense if the instance ID has device type clkmgr,
143
* otherwise the returned value is unspecified.
144
*/
145
dt_clkmgr_t
dt_clkmgr_from_instance_id
(
dt_instance_id_t
inst_id);
146
147
/**
148
* Get the instance ID of an instance.
149
*
150
* @param dt Instance of clkmgr.
151
* @return The instance ID of that instance.
152
*/
153
dt_instance_id_t
dt_clkmgr_instance_id
(
dt_clkmgr_t
dt);
154
155
/**
156
* Get the register base address of an instance.
157
*
158
* @param dt Instance of clkmgr.
159
* @param reg_block The register block requested.
160
* @return The register base address of the requested block.
161
*/
162
uint32_t
dt_clkmgr_reg_block
(
163
dt_clkmgr_t
dt,
164
dt_clkmgr_reg_block_t
reg_block);
165
166
/**
167
* Get the primary register base address of an instance.
168
*
169
* This is just a convenience function, equivalent to
170
* `dt_clkmgr_reg_block(dt, kDtClkmgrRegBlockCore)`
171
*
172
* @param dt Instance of clkmgr.
173
* @return The register base address of the primary register block.
174
*/
175
static
inline
uint32_t dt_clkmgr_primary_reg_block(
176
dt_clkmgr_t
dt) {
177
return
dt_clkmgr_reg_block
(dt, kDtClkmgrRegBlockCore);
178
}
179
180
/**
181
* Get the base address of a memory.
182
*
183
* @param dt Instance of clkmgr.
184
* @param mem The memory requested.
185
* @return The base address of the requested memory.
186
*/
187
uint32_t
dt_clkmgr_memory_base
(
188
dt_clkmgr_t
dt,
189
dt_clkmgr_memory_t
mem);
190
191
/**
192
* Get the size of a memory.
193
*
194
* @param dt Instance of clkmgr.
195
* @param mem The memory requested.
196
* @return The size of the requested memory.
197
*/
198
uint32_t
dt_clkmgr_memory_size
(
199
dt_clkmgr_t
dt,
200
dt_clkmgr_memory_t
mem);
201
202
203
/**
204
* Get the alert ID of a clkmgr alert for a given instance.
205
*
206
* **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
207
* instances where the instance is not connected, the return value is unspecified.
208
*
209
* @param dt Instance of clkmgr.
210
* @param alert A clkmgr alert.
211
* @return The Alert Handler alert ID of the alert of this instance.
212
*/
213
dt_alert_id_t
dt_clkmgr_alert_to_alert_id
(
214
dt_clkmgr_t
dt,
215
dt_clkmgr_alert_t
alert);
216
217
/**
218
* Convert a global alert ID to a local clkmgr alert type.
219
*
220
* @param dt Instance of clkmgr.
221
* @param alert A global alert ID that belongs to this instance.
222
* @return The clkmgr alert, or `kDtClkmgrAlertCount`.
223
*
224
* **Note:** This function assumes that the global alert ID belongs to the
225
* instance of clkmgr passed in parameter. In other words, it must be the case
226
* that `dt_clkmgr_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
227
* this function will return `kDtClkmgrAlertCount`.
228
*/
229
dt_clkmgr_alert_t
dt_clkmgr_alert_from_alert_id
(
230
dt_clkmgr_t
dt,
231
dt_alert_id_t
alert);
232
233
234
235
/**
236
* Get the clock signal connected to a clock port of an instance.
237
*
238
* @param dt Instance of clkmgr.
239
* @param clk Clock port.
240
* @return Clock signal.
241
*/
242
dt_clock_t
dt_clkmgr_clock
(
243
dt_clkmgr_t
dt,
244
dt_clkmgr_clock_t
clk);
245
246
/**
247
* Get the reset signal connected to a reset port of an instance.
248
*
249
* @param dt Instance of clkmgr.
250
* @param rst Reset port.
251
* @return Reset signal.
252
*/
253
dt_reset_t
dt_clkmgr_reset
(
254
dt_clkmgr_t
dt,
255
dt_clkmgr_reset_t
rst);
256
257
258
259
/**
260
* Get the number of software gateable clocks.
261
*
262
* @param dt Instance of clkmgr.
263
* @return Number of gateable clocks.
264
*/
265
size_t
dt_clkmgr_gateable_clock_count
(
dt_clkmgr_t
dt);
266
267
/**
268
* Get the instance ID of a gateable clock.
269
*
270
* The clocks are ordered as they appear in the registers.
271
*
272
* @param dt Instance of clkmgr.
273
* @param idx Index of the gateable clock, between 0 and `dt_clkmgr_sw_clock_count(dt)-1`.
274
* @return Instance ID of the device whose clock is gateable.
275
*/
276
dt_instance_id_t
dt_clkmgr_gateable_clock
(
dt_clkmgr_t
dt,
size_t
idx);
277
278
/**
279
* Get the number of software hintable clocks.
280
*
281
* @param dt Instance of clkmgr.
282
* @return Number of hintable clocks.
283
*/
284
size_t
dt_clkmgr_hintable_clock_count
(
dt_clkmgr_t
dt);
285
286
/**
287
* Get the instance ID of a hintable clock.
288
*
289
* The clocks sources are ordered as they appear in the registers.
290
*
291
* @param dt Instance of clkmgr.
292
* @param idx Index of the hintable clock, between 0 and `dt_clkmgr_hint_clock_count(dt)-1`.
293
* @return Instance ID of the device whose clock is hintable.
294
*/
295
dt_instance_id_t
dt_clkmgr_hintable_clock
(
dt_clkmgr_t
dt,
size_t
idx);
296
297
/**
298
* Description of a measurable clock.
299
*
300
*/
301
typedef
struct
dt_clkmgr_measurable_clk
{
302
dt_clock_t
clock
;
/**< Clock */
303
uint32_t
meas_ctrl_en_off
;
/**< MEAS_CTRL_EN register offset */
304
bitfield_field32_t
meas_ctrl_en_en_field
;
/**< MEAS_CTRL_EN_EN bitfield */
305
uint32_t
meas_ctrl_shadowed_off
;
/**< CTRL_SHADOWED register offset */
306
bitfield_field32_t
meas_ctrl_shadowed_lo_field
;
/**< CTRL_SHADOWED_LO bitfield */
307
bitfield_field32_t
meas_ctrl_shadowed_hi_field
;
/**< CTRL_SHADOWED_HI bitfield */
308
}
dt_clkmgr_measurable_clk_t
;
309
310
311
/**
312
* Get the number of measurable clocks.
313
*
314
* @param dt Instance of clkmgr.
315
* @return Number of measurable clocks.
316
*/
317
size_t
dt_clkmgr_measurable_clock_count
(
dt_clkmgr_t
dt);
318
319
/**
320
* Get the description of a measurable clock.
321
*
322
* @param dt Instance of clkmgr.
323
* @param idx Index of the measurable clock, between 0 and
324
* `dt_clkmgr_measurable_clock_count(dt)-1`.
325
* @return Description of the measurable clock.
326
*/
327
dt_clkmgr_measurable_clk_t
dt_clkmgr_measurable_clock
(
dt_clkmgr_t
dt,
size_t
idx);
328
329
330
331
#ifdef __cplusplus
332
}
// extern "C"
333
#endif
// __cplusplus
334
335
#endif
// OPENTITAN_DT_CLKMGR_H_
(earlgrey)
hw
top
dt
dt_clkmgr.h
Return to
OpenTitan Documentation