Software APIs
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 darjeeling.
17
*
18
* This file contains the type definitions and global functions of the clkmgr.
19
*/
20
21
#include "hw/top/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 Alerts.
52
*
53
* Alerts are guaranteed to be numbered consecutively from 0.
54
*/
55
typedef
enum
dt_clkmgr_alert
{
56
kDtClkmgrAlertRecovFault
= 0,
/**< This recoverable alert is triggered when there are measurement errors. */
57
kDtClkmgrAlertFatalFault
= 1,
/**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
58
kDtClkmgrAlertCount = 2,
/**< \internal Number of Alerts */
59
}
dt_clkmgr_alert_t
;
60
61
/**
62
* List of clock ports.
63
*
64
* Clock ports are guaranteed to be numbered consecutively from 0.
65
*/
66
typedef
enum
dt_clkmgr_clock
{
67
kDtClkmgrClockClk
= 0,
/**< Clock port clk_i */
68
kDtClkmgrClockMain
= 1,
/**< Clock port clk_main_i */
69
kDtClkmgrClockIo
= 2,
/**< Clock port clk_io_i */
70
kDtClkmgrClockAon
= 3,
/**< Clock port clk_aon_i */
71
kDtClkmgrClockCount = 4,
/**< \internal Number of clock ports */
72
}
dt_clkmgr_clock_t
;
73
74
/**
75
* List of reset ports.
76
*
77
* Reset ports are guaranteed to be numbered consecutively from 0.
78
*/
79
typedef
enum
dt_clkmgr_reset
{
80
kDtClkmgrResetRst
= 0,
/**< Reset port rst_ni */
81
kDtClkmgrResetRoot
= 1,
/**< Reset port rst_root_ni */
82
kDtClkmgrResetMain
= 2,
/**< Reset port rst_main_ni */
83
kDtClkmgrResetIo
= 3,
/**< Reset port rst_io_ni */
84
kDtClkmgrResetAon
= 4,
/**< Reset port rst_aon_ni */
85
kDtClkmgrResetRootMain
= 5,
/**< Reset port rst_root_main_ni */
86
kDtClkmgrResetRootIo
= 6,
/**< Reset port rst_root_io_ni */
87
kDtClkmgrResetCount = 7,
/**< \internal Number of reset ports */
88
}
dt_clkmgr_reset_t
;
89
90
/**
91
* List of supported hardware features.
92
*/
93
#define OPENTITAN_CLKMGR_HAS_ENABLE_IO 1
94
#define OPENTITAN_CLKMGR_HAS_HINT_AES 1
95
#define OPENTITAN_CLKMGR_HAS_HINT_HMAC 1
96
#define OPENTITAN_CLKMGR_HAS_HINT_KMAC 1
97
#define OPENTITAN_CLKMGR_HAS_HINT_OTBN 1
98
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_REGWEN 1
99
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO 1
100
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_MAIN 1
101
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_RECOV_ERR 1
102
#define OPENTITAN_CLKMGR_HAS_JITTER_REGWEN 1
103
#define OPENTITAN_CLKMGR_HAS_JITTER_ENABLE 1
104
#define OPENTITAN_CLKMGR_HAS_ALERT_HANDLER_CLOCK_STATUS 1
105
106
107
108
/**
109
* Get the clkmgr instance from an instance ID
110
*
111
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
112
*
113
* @param inst_id Instance ID.
114
* @return A clkmgr instance.
115
*
116
* **Note:** This function only makes sense if the instance ID has device type clkmgr,
117
* otherwise the returned value is unspecified.
118
*/
119
dt_clkmgr_t
dt_clkmgr_from_instance_id
(
dt_instance_id_t
inst_id);
120
121
/**
122
* Get the instance ID of an instance.
123
*
124
* @param dt Instance of clkmgr.
125
* @return The instance ID of that instance.
126
*/
127
dt_instance_id_t
dt_clkmgr_instance_id
(
dt_clkmgr_t
dt);
128
129
/**
130
* Get the register base address of an instance.
131
*
132
* @param dt Instance of clkmgr.
133
* @param reg_block The register block requested.
134
* @return The register base address of the requested block.
135
*/
136
uint32_t
dt_clkmgr_reg_block
(
137
dt_clkmgr_t
dt,
138
dt_clkmgr_reg_block_t
reg_block);
139
140
/**
141
* Get the primary register base address of an instance.
142
*
143
* This is just a convenience function, equivalent to
144
* `dt_clkmgr_reg_block(dt, kDtClkmgrRegBlockCore)`
145
*
146
* @param dt Instance of clkmgr.
147
* @return The register base address of the primary register block.
148
*/
149
static
inline
uint32_t dt_clkmgr_primary_reg_block(
150
dt_clkmgr_t
dt) {
151
return
dt_clkmgr_reg_block
(dt, kDtClkmgrRegBlockCore);
152
}
153
154
155
/**
156
* Get the alert ID of a clkmgr alert for a given instance.
157
*
158
* **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
159
* instances where the instance is not connected, the return value is unspecified.
160
*
161
* @param dt Instance of clkmgr.
162
* @param alert A clkmgr alert.
163
* @return The Alert Handler alert ID of the alert of this instance.
164
*/
165
dt_alert_id_t
dt_clkmgr_alert_to_alert_id
(
166
dt_clkmgr_t
dt,
167
dt_clkmgr_alert_t
alert);
168
169
/**
170
* Convert a global alert ID to a local clkmgr alert type.
171
*
172
* @param dt Instance of clkmgr.
173
* @param alert A global alert ID that belongs to this instance.
174
* @return The clkmgr alert, or `kDtClkmgrAlertCount`.
175
*
176
* **Note:** This function assumes that the global alert ID belongs to the
177
* instance of clkmgr passed in parameter. In other words, it must be the case
178
* that `dt_clkmgr_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
179
* this function will return `kDtClkmgrAlertCount`.
180
*/
181
dt_clkmgr_alert_t
dt_clkmgr_alert_from_alert_id
(
182
dt_clkmgr_t
dt,
183
dt_alert_id_t
alert);
184
185
186
187
/**
188
* Get the clock signal connected to a clock port of an instance.
189
*
190
* @param dt Instance of clkmgr.
191
* @param clk Clock port.
192
* @return Clock signal.
193
*/
194
dt_clock_t
dt_clkmgr_clock
(
195
dt_clkmgr_t
dt,
196
dt_clkmgr_clock_t
clk);
197
198
/**
199
* Get the reset signal connected to a reset port of an instance.
200
*
201
* @param dt Instance of clkmgr.
202
* @param rst Reset port.
203
* @return Reset signal.
204
*/
205
dt_reset_t
dt_clkmgr_reset
(
206
dt_clkmgr_t
dt,
207
dt_clkmgr_reset_t
rst);
208
209
210
211
/**
212
* Get the number of software gateable clocks.
213
*
214
* @param dt Instance of clkmgr.
215
* @return Number of gateable clocks.
216
*/
217
size_t
dt_clkmgr_gateable_clock_count
(
dt_clkmgr_t
dt);
218
219
/**
220
* Get the instance ID of a gateable clock.
221
*
222
* The clocks are ordered as they appear in the registers.
223
*
224
* @param dt Instance of clkmgr.
225
* @param idx Index of the gateable clock, between 0 and `dt_clkmgr_sw_clock_count(dt)-1`.
226
* @return Instance ID of the device whose clock is gateable.
227
*/
228
dt_instance_id_t
dt_clkmgr_gateable_clock
(
dt_clkmgr_t
dt,
size_t
idx);
229
230
/**
231
* Get the number of software hintable clocks.
232
*
233
* @param dt Instance of clkmgr.
234
* @return Number of hintable clocks.
235
*/
236
size_t
dt_clkmgr_hintable_clock_count
(
dt_clkmgr_t
dt);
237
238
/**
239
* Get the instance ID of a hintable clock.
240
*
241
* The clocks sources are ordered as they appear in the registers.
242
*
243
* @param dt Instance of clkmgr.
244
* @param idx Index of the hintable clock, between 0 and `dt_clkmgr_hint_clock_count(dt)-1`.
245
* @return Instance ID of the device whose clock is hintable.
246
*/
247
dt_instance_id_t
dt_clkmgr_hintable_clock
(
dt_clkmgr_t
dt,
size_t
idx);
248
249
/**
250
* Description of a measurable clock.
251
*
252
*/
253
typedef
struct
dt_clkmgr_measurable_clk
{
254
dt_clock_t
clock
;
/**< Clock */
255
uint32_t
meas_ctrl_en_off
;
/**< MEAS_CTRL_EN register offset */
256
bitfield_field32_t
meas_ctrl_en_en_field
;
/**< MEAS_CTRL_EN_EN bitfield */
257
uint32_t
meas_ctrl_shadowed_off
;
/**< CTRL_SHADOWED register offset */
258
bitfield_field32_t
meas_ctrl_shadowed_lo_field
;
/**< CTRL_SHADOWED_LO bitfield */
259
bitfield_field32_t
meas_ctrl_shadowed_hi_field
;
/**< CTRL_SHADOWED_HI bitfield */
260
}
dt_clkmgr_measurable_clk_t
;
261
262
263
/**
264
* Get the number of measurable clocks.
265
*
266
* @param dt Instance of clkmgr.
267
* @return Number of measurable clocks.
268
*/
269
size_t
dt_clkmgr_measurable_clock_count
(
dt_clkmgr_t
dt);
270
271
/**
272
* Get the description of a measurable clock.
273
*
274
* @param dt Instance of clkmgr.
275
* @param idx Index of the measurable clock, between 0 and
276
* `dt_clkmgr_measurable_clock_count(dt)-1`.
277
* @return Description of the measurable clock.
278
*/
279
dt_clkmgr_measurable_clk_t
dt_clkmgr_measurable_clock
(
dt_clkmgr_t
dt,
size_t
idx);
280
281
282
283
#ifdef __cplusplus
284
}
// extern "C"
285
#endif
// __cplusplus
286
287
#endif
// OPENTITAN_DT_CLKMGR_H_
(darjeeling)
hw
top
dt
clkmgr.h
Return to
OpenTitan Documentation