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