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 englishbreakfast.
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 clock ports.
61
*
62
* Clock ports are guaranteed to be numbered consecutively from 0.
63
*/
64
typedef
enum
dt_clkmgr_clock
{
65
kDtClkmgrClockClk
= 0,
/**< Clock port clk_i */
66
kDtClkmgrClockMain
= 1,
/**< Clock port clk_main_i */
67
kDtClkmgrClockIo
= 2,
/**< Clock port clk_io_i */
68
kDtClkmgrClockUsb
= 3,
/**< Clock port clk_usb_i */
69
kDtClkmgrClockAon
= 4,
/**< Clock port clk_aon_i */
70
kDtClkmgrClockCount = 5,
/**< \internal Number of clock ports */
71
}
dt_clkmgr_clock_t
;
72
73
/**
74
* List of reset ports.
75
*
76
* Reset ports are guaranteed to be numbered consecutively from 0.
77
*/
78
typedef
enum
dt_clkmgr_reset
{
79
kDtClkmgrResetRst
= 0,
/**< Reset port rst_ni */
80
kDtClkmgrResetRoot
= 1,
/**< Reset port rst_root_ni */
81
kDtClkmgrResetMain
= 2,
/**< Reset port rst_main_ni */
82
kDtClkmgrResetIo
= 3,
/**< Reset port rst_io_ni */
83
kDtClkmgrResetUsb
= 4,
/**< Reset port rst_usb_ni */
84
kDtClkmgrResetAon
= 5,
/**< Reset port rst_aon_ni */
85
kDtClkmgrResetIoDiv2
= 6,
/**< Reset port rst_io_div2_ni */
86
kDtClkmgrResetIoDiv4
= 7,
/**< Reset port rst_io_div4_ni */
87
kDtClkmgrResetRootMain
= 8,
/**< Reset port rst_root_main_ni */
88
kDtClkmgrResetRootIo
= 9,
/**< Reset port rst_root_io_ni */
89
kDtClkmgrResetRootIoDiv2
= 10,
/**< Reset port rst_root_io_div2_ni */
90
kDtClkmgrResetRootIoDiv4
= 11,
/**< Reset port rst_root_io_div4_ni */
91
kDtClkmgrResetRootUsb
= 12,
/**< Reset port rst_root_usb_ni */
92
kDtClkmgrResetCount = 13,
/**< \internal Number of reset ports */
93
}
dt_clkmgr_reset_t
;
94
95
/**
96
* List of supported hardware features.
97
*/
98
#define OPENTITAN_CLKMGR_HAS_ENABLE_IO_DIV4 1
99
#define OPENTITAN_CLKMGR_HAS_ENABLE_IO_DIV2 1
100
#define OPENTITAN_CLKMGR_HAS_ENABLE_IO 1
101
#define OPENTITAN_CLKMGR_HAS_ENABLE_USB 1
102
#define OPENTITAN_CLKMGR_HAS_HINT_AES 1
103
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_REGWEN 1
104
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO 1
105
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO_DIV4 1
106
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_MAIN 1
107
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_USB 1
108
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_RECOV_ERR 1
109
#define OPENTITAN_CLKMGR_HAS_LC_EXTCLK_SPEED 1
110
#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_REGWEN 1
111
#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_HIGH_SPEED 1
112
#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_LOW_SPEED 1
113
#define OPENTITAN_CLKMGR_HAS_JITTER_REGWEN 1
114
#define OPENTITAN_CLKMGR_HAS_JITTER_ENABLE 1
115
#define OPENTITAN_CLKMGR_HAS_ALERT_HANDLER_CLOCK_STATUS 1
116
117
118
119
/**
120
* Get the clkmgr instance from an instance ID
121
*
122
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
123
*
124
* @param inst_id Instance ID.
125
* @return A clkmgr instance.
126
*
127
* **Note:** This function only makes sense if the instance ID has device type clkmgr,
128
* otherwise the returned value is unspecified.
129
*/
130
dt_clkmgr_t
dt_clkmgr_from_instance_id
(
dt_instance_id_t
inst_id);
131
132
/**
133
* Get the instance ID of an instance.
134
*
135
* @param dt Instance of clkmgr.
136
* @return The instance ID of that instance.
137
*/
138
dt_instance_id_t
dt_clkmgr_instance_id
(
dt_clkmgr_t
dt);
139
140
/**
141
* Get the register base address of an instance.
142
*
143
* @param dt Instance of clkmgr.
144
* @param reg_block The register block requested.
145
* @return The register base address of the requested block.
146
*/
147
uint32_t
dt_clkmgr_reg_block
(
148
dt_clkmgr_t
dt,
149
dt_clkmgr_reg_block_t
reg_block);
150
151
/**
152
* Get the primary register base address of an instance.
153
*
154
* This is just a convenience function, equivalent to
155
* `dt_clkmgr_reg_block(dt, kDtClkmgrRegBlockCore)`
156
*
157
* @param dt Instance of clkmgr.
158
* @return The register base address of the primary register block.
159
*/
160
static
inline
uint32_t dt_clkmgr_primary_reg_block(
161
dt_clkmgr_t
dt) {
162
return
dt_clkmgr_reg_block
(dt, kDtClkmgrRegBlockCore);
163
}
164
165
/**
166
* Get the base address of a memory.
167
*
168
* @param dt Instance of clkmgr.
169
* @param mem The memory requested.
170
* @return The base address of the requested memory.
171
*/
172
uint32_t
dt_clkmgr_memory_base
(
173
dt_clkmgr_t
dt,
174
dt_clkmgr_memory_t
mem);
175
176
/**
177
* Get the size of a memory.
178
*
179
* @param dt Instance of clkmgr.
180
* @param mem The memory requested.
181
* @return The size of the requested memory.
182
*/
183
uint32_t
dt_clkmgr_memory_size
(
184
dt_clkmgr_t
dt,
185
dt_clkmgr_memory_t
mem);
186
187
188
189
190
/**
191
* Get the clock signal connected to a clock port of an instance.
192
*
193
* @param dt Instance of clkmgr.
194
* @param clk Clock port.
195
* @return Clock signal.
196
*/
197
dt_clock_t
dt_clkmgr_clock
(
198
dt_clkmgr_t
dt,
199
dt_clkmgr_clock_t
clk);
200
201
/**
202
* Get the reset signal connected to a reset port of an instance.
203
*
204
* @param dt Instance of clkmgr.
205
* @param rst Reset port.
206
* @return Reset signal.
207
*/
208
dt_reset_t
dt_clkmgr_reset
(
209
dt_clkmgr_t
dt,
210
dt_clkmgr_reset_t
rst);
211
212
213
214
/**
215
* Get the number of software gateable clocks.
216
*
217
* @param dt Instance of clkmgr.
218
* @return Number of gateable clocks.
219
*/
220
size_t
dt_clkmgr_gateable_clock_count
(
dt_clkmgr_t
dt);
221
222
/**
223
* Get the instance ID of a gateable clock.
224
*
225
* The clocks are ordered as they appear in the registers.
226
*
227
* @param dt Instance of clkmgr.
228
* @param idx Index of the gateable clock, between 0 and `dt_clkmgr_sw_clock_count(dt)-1`.
229
* @return Instance ID of the device whose clock is gateable.
230
*/
231
dt_instance_id_t
dt_clkmgr_gateable_clock
(
dt_clkmgr_t
dt,
size_t
idx);
232
233
/**
234
* Get the number of software hintable clocks.
235
*
236
* @param dt Instance of clkmgr.
237
* @return Number of hintable clocks.
238
*/
239
size_t
dt_clkmgr_hintable_clock_count
(
dt_clkmgr_t
dt);
240
241
/**
242
* Get the instance ID of a hintable clock.
243
*
244
* The clocks sources are ordered as they appear in the registers.
245
*
246
* @param dt Instance of clkmgr.
247
* @param idx Index of the hintable clock, between 0 and `dt_clkmgr_hint_clock_count(dt)-1`.
248
* @return Instance ID of the device whose clock is hintable.
249
*/
250
dt_instance_id_t
dt_clkmgr_hintable_clock
(
dt_clkmgr_t
dt,
size_t
idx);
251
252
/**
253
* Description of a measurable clock.
254
*
255
*/
256
typedef
struct
dt_clkmgr_measurable_clk
{
257
dt_clock_t
clock
;
/**< Clock */
258
uint32_t
meas_ctrl_en_off
;
/**< MEAS_CTRL_EN register offset */
259
bitfield_field32_t
meas_ctrl_en_en_field
;
/**< MEAS_CTRL_EN_EN bitfield */
260
uint32_t
meas_ctrl_shadowed_off
;
/**< CTRL_SHADOWED register offset */
261
bitfield_field32_t
meas_ctrl_shadowed_lo_field
;
/**< CTRL_SHADOWED_LO bitfield */
262
bitfield_field32_t
meas_ctrl_shadowed_hi_field
;
/**< CTRL_SHADOWED_HI bitfield */
263
}
dt_clkmgr_measurable_clk_t
;
264
265
266
/**
267
* Get the number of measurable clocks.
268
*
269
* @param dt Instance of clkmgr.
270
* @return Number of measurable clocks.
271
*/
272
size_t
dt_clkmgr_measurable_clock_count
(
dt_clkmgr_t
dt);
273
274
/**
275
* Get the description of a measurable clock.
276
*
277
* @param dt Instance of clkmgr.
278
* @param idx Index of the measurable clock, between 0 and
279
* `dt_clkmgr_measurable_clock_count(dt)-1`.
280
* @return Description of the measurable clock.
281
*/
282
dt_clkmgr_measurable_clk_t
dt_clkmgr_measurable_clock
(
dt_clkmgr_t
dt,
size_t
idx);
283
284
285
286
#ifdef __cplusplus
287
}
// extern "C"
288
#endif
// __cplusplus
289
290
#endif
// OPENTITAN_DT_CLKMGR_H_
(englishbreakfast)
hw
top
dt
dt_clkmgr.h
Return to
OpenTitan Documentation