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
11extern "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/dt_api.h"
22#include <stdint.h>
23
24
26
27
28/**
29 * List of instances.
30 */
31typedef enum dt_clkmgr {
32 kDtClkmgrAon = 0, /**< clkmgr_aon */
33 kDtClkmgrFirst = 0, /**< \internal First instance */
34 kDtClkmgrCount = 1, /**< \internal Number of instances */
36
37/**
38 * List of register blocks.
39 *
40 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
41 */
42typedef enum dt_clkmgr_reg_block {
43 kDtClkmgrRegBlockCore = 0, /**< */
44 kDtClkmgrRegBlockCount = 1, /**< \internal Number of register blocks */
46
47/** Primary register block (associated with the "primary" set of registers that control the IP). */
48static 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 */
55typedef enum dt_clkmgr_memory {
56 kDtClkmgrMemoryCount = 0, /**< \internal Number of memories */
58
59/**
60 * List of Alerts.
61 *
62 * Alerts are guaranteed to be numbered consecutively from 0.
63 */
64typedef 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 */
69
70/**
71 * List of clock ports.
72 *
73 * Clock ports are guaranteed to be numbered consecutively from 0.
74 */
75typedef 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 kDtClkmgrClockAon = 3, /**< Clock port clk_aon_i */
80 kDtClkmgrClockCount = 4, /**< \internal Number of clock ports */
82
83/**
84 * List of reset ports.
85 *
86 * Reset ports are guaranteed to be numbered consecutively from 0.
87 */
88typedef enum dt_clkmgr_reset {
89 kDtClkmgrResetRst = 0, /**< Reset port rst_ni */
90 kDtClkmgrResetRoot = 1, /**< Reset port rst_root_ni */
91 kDtClkmgrResetMain = 2, /**< Reset port rst_main_ni */
92 kDtClkmgrResetIo = 3, /**< Reset port rst_io_ni */
93 kDtClkmgrResetAon = 4, /**< Reset port rst_aon_ni */
94 kDtClkmgrResetRootMain = 5, /**< Reset port rst_root_main_ni */
95 kDtClkmgrResetRootIo = 6, /**< Reset port rst_root_io_ni */
96 kDtClkmgrResetCount = 7, /**< \internal Number of reset ports */
98
99/**
100 * List of supported hardware features.
101 */
102#define OPENTITAN_CLKMGR_HAS_ENABLE_IO 1
103#define OPENTITAN_CLKMGR_HAS_HINT_AES 1
104#define OPENTITAN_CLKMGR_HAS_HINT_HMAC 1
105#define OPENTITAN_CLKMGR_HAS_HINT_KMAC 1
106#define OPENTITAN_CLKMGR_HAS_HINT_OTBN 1
107#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_REGWEN 1
108#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO 1
109#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_MAIN 1
110#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_RECOV_ERR 1
111#define OPENTITAN_CLKMGR_HAS_JITTER_REGWEN 1
112#define OPENTITAN_CLKMGR_HAS_JITTER_ENABLE 1
113#define OPENTITAN_CLKMGR_HAS_ALERT_HANDLER_CLOCK_STATUS 1
114
115
116
117/**
118 * Get the clkmgr instance from an instance ID
119 *
120 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
121 *
122 * @param inst_id Instance ID.
123 * @return A clkmgr instance.
124 *
125 * **Note:** This function only makes sense if the instance ID has device type clkmgr,
126 * otherwise the returned value is unspecified.
127 */
129
130/**
131 * Get the instance ID of an instance.
132 *
133 * @param dt Instance of clkmgr.
134 * @return The instance ID of that instance.
135 */
137
138/**
139 * Get the register base address of an instance.
140 *
141 * @param dt Instance of clkmgr.
142 * @param reg_block The register block requested.
143 * @return The register base address of the requested block.
144 */
145uint32_t dt_clkmgr_reg_block(
146 dt_clkmgr_t dt,
147 dt_clkmgr_reg_block_t reg_block);
148
149/**
150 * Get the primary register base address of an instance.
151 *
152 * This is just a convenience function, equivalent to
153 * `dt_clkmgr_reg_block(dt, kDtClkmgrRegBlockCore)`
154 *
155 * @param dt Instance of clkmgr.
156 * @return The register base address of the primary register block.
157 */
158static inline uint32_t dt_clkmgr_primary_reg_block(
159 dt_clkmgr_t dt) {
160 return dt_clkmgr_reg_block(dt, kDtClkmgrRegBlockCore);
161}
162
163/**
164 * Get the base address of a memory.
165 *
166 * @param dt Instance of clkmgr.
167 * @param mem The memory requested.
168 * @return The base address of the requested memory.
169 */
170uint32_t dt_clkmgr_memory_base(
171 dt_clkmgr_t dt,
173
174/**
175 * Get the size of a memory.
176 *
177 * @param dt Instance of clkmgr.
178 * @param mem The memory requested.
179 * @return The size of the requested memory.
180 */
181uint32_t dt_clkmgr_memory_size(
182 dt_clkmgr_t dt,
184
185
186/**
187 * Get the alert ID of a clkmgr alert for a given instance.
188 *
189 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
190 * instances where the instance is not connected, the return value is unspecified.
191 *
192 * @param dt Instance of clkmgr.
193 * @param alert A clkmgr alert.
194 * @return The Alert Handler alert ID of the alert of this instance.
195 */
197 dt_clkmgr_t dt,
198 dt_clkmgr_alert_t alert);
199
200/**
201 * Convert a global alert ID to a local clkmgr alert type.
202 *
203 * @param dt Instance of clkmgr.
204 * @param alert A global alert ID that belongs to this instance.
205 * @return The clkmgr alert, or `kDtClkmgrAlertCount`.
206 *
207 * **Note:** This function assumes that the global alert ID belongs to the
208 * instance of clkmgr passed in parameter. In other words, it must be the case
209 * that `dt_clkmgr_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
210 * this function will return `kDtClkmgrAlertCount`.
211 */
213 dt_clkmgr_t dt,
214 dt_alert_id_t alert);
215
216
217
218/**
219 * Get the clock signal connected to a clock port of an instance.
220 *
221 * @param dt Instance of clkmgr.
222 * @param clk Clock port.
223 * @return Clock signal.
224 */
226 dt_clkmgr_t dt,
228
229/**
230 * Get the reset signal connected to a reset port of an instance.
231 *
232 * @param dt Instance of clkmgr.
233 * @param rst Reset port.
234 * @return Reset signal.
235 */
237 dt_clkmgr_t dt,
239
240
241
242/**
243 * Get the number of software gateable clocks.
244 *
245 * @param dt Instance of clkmgr.
246 * @return Number of gateable clocks.
247 */
249
250/**
251 * Get the instance ID of a gateable clock.
252 *
253 * The clocks are ordered as they appear in the registers.
254 *
255 * @param dt Instance of clkmgr.
256 * @param idx Index of the gateable clock, between 0 and `dt_clkmgr_sw_clock_count(dt)-1`.
257 * @return Instance ID of the device whose clock is gateable.
258 */
260
261/**
262 * Get the number of software hintable clocks.
263 *
264 * @param dt Instance of clkmgr.
265 * @return Number of hintable clocks.
266 */
268
269/**
270 * Get the instance ID of a hintable clock.
271 *
272 * The clocks sources are ordered as they appear in the registers.
273 *
274 * @param dt Instance of clkmgr.
275 * @param idx Index of the hintable clock, between 0 and `dt_clkmgr_hint_clock_count(dt)-1`.
276 * @return Instance ID of the device whose clock is hintable.
277 */
279
280/**
281 * Description of a measurable clock.
282 *
283 */
284typedef struct dt_clkmgr_measurable_clk {
285 dt_clock_t clock; /**< Clock */
286 uint32_t meas_ctrl_en_off; /**< MEAS_CTRL_EN register offset */
287 bitfield_field32_t meas_ctrl_en_en_field; /**< MEAS_CTRL_EN_EN bitfield */
288 uint32_t meas_ctrl_shadowed_off; /**< CTRL_SHADOWED register offset */
289 bitfield_field32_t meas_ctrl_shadowed_lo_field; /**< CTRL_SHADOWED_LO bitfield */
290 bitfield_field32_t meas_ctrl_shadowed_hi_field; /**< CTRL_SHADOWED_HI bitfield */
292
293
294/**
295 * Get the number of measurable clocks.
296 *
297 * @param dt Instance of clkmgr.
298 * @return Number of measurable clocks.
299 */
301
302/**
303 * Get the description of a measurable clock.
304 *
305 * @param dt Instance of clkmgr.
306 * @param idx Index of the measurable clock, between 0 and
307 * `dt_clkmgr_measurable_clock_count(dt)-1`.
308 * @return Description of the measurable clock.
309 */
311
312
313
314#ifdef __cplusplus
315} // extern "C"
316#endif // __cplusplus
317
318#endif // OPENTITAN_DT_CLKMGR_H_