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/**
11 * @file
12 * @brief Device Tables (DT) for IP clkmgr and top earlgrey.
13 *
14 * This file contains the type definitions and global functions of the clkmgr.
15 */
16
17#include "dt_api.h"
18#include <stdint.h>
19
20/**
21 * List of instances.
22 */
23typedef enum dt_clkmgr {
24 kDtClkmgrAon = 0, /**< clkmgr_aon */
25 kDtClkmgrFirst = 0, /**< \internal First instance */
26 kDtClkmgrCount = 1, /**< \internal Number of instances */
28
29/**
30 * List of register blocks.
31 *
32 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
33 */
34typedef enum dt_clkmgr_reg_block {
35 kDtClkmgrRegBlockCore = 0, /**< */
36 kDtClkmgrRegBlockCount = 1, /**< \internal Number of register blocks */
38
39/** Primary register block (associated with the "primary" set of registers that control the IP). */
40static const dt_clkmgr_reg_block_t kDtClkmgrRegBlockPrimary = kDtClkmgrRegBlockCore;
41
42/**
43 * List of Alerts.
44 *
45 * Alerts are guaranteed to be numbered consecutively from 0.
46 */
47typedef enum dt_clkmgr_alert {
48 kDtClkmgrAlertRecovFault = 0, /**< This recoverable alert is triggered when there are measurement errors. */
49 kDtClkmgrAlertFatalFault = 1, /**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
50 kDtClkmgrAlertCount = 2, /**< \internal Number of Alerts */
52
53/**
54 * List of clock ports.
55 *
56 * Clock ports are guaranteed to be numbered consecutively from 0.
57 */
58typedef enum dt_clkmgr_clock {
59 kDtClkmgrClockClk = 0, /**< Clock port clk_i */
60 kDtClkmgrClockMain = 1, /**< Clock port clk_main_i */
61 kDtClkmgrClockIo = 2, /**< Clock port clk_io_i */
62 kDtClkmgrClockUsb = 3, /**< Clock port clk_usb_i */
63 kDtClkmgrClockAon = 4, /**< Clock port clk_aon_i */
64 kDtClkmgrClockCount = 5, /**< \internal Number of clock ports */
66
67/**
68 * List of reset ports.
69 *
70 * Reset ports are guaranteed to be numbered consecutively from 0.
71 */
72typedef enum dt_clkmgr_reset {
73 kDtClkmgrResetRst = 0, /**< Reset port rst_ni */
74 kDtClkmgrResetRoot = 1, /**< Reset port rst_root_ni */
75 kDtClkmgrResetMain = 2, /**< Reset port rst_main_ni */
76 kDtClkmgrResetIo = 3, /**< Reset port rst_io_ni */
77 kDtClkmgrResetUsb = 4, /**< Reset port rst_usb_ni */
78 kDtClkmgrResetAon = 5, /**< Reset port rst_aon_ni */
79 kDtClkmgrResetIoDiv2 = 6, /**< Reset port rst_io_div2_ni */
80 kDtClkmgrResetIoDiv4 = 7, /**< Reset port rst_io_div4_ni */
81 kDtClkmgrResetRootMain = 8, /**< Reset port rst_root_main_ni */
82 kDtClkmgrResetRootIo = 9, /**< Reset port rst_root_io_ni */
83 kDtClkmgrResetRootIoDiv2 = 10, /**< Reset port rst_root_io_div2_ni */
84 kDtClkmgrResetRootIoDiv4 = 11, /**< Reset port rst_root_io_div4_ni */
85 kDtClkmgrResetRootUsb = 12, /**< Reset port rst_root_usb_ni */
86 kDtClkmgrResetCount = 13, /**< \internal Number of reset ports */
88
89/**
90 * List of supported hardware features.
91 */
92#define OPENTITAN_CLKMGR_HAS_ENABLE_IO_DIV4 1
93#define OPENTITAN_CLKMGR_HAS_ENABLE_IO_DIV2 1
94#define OPENTITAN_CLKMGR_HAS_ENABLE_IO 1
95#define OPENTITAN_CLKMGR_HAS_ENABLE_USB 1
96#define OPENTITAN_CLKMGR_HAS_HINT_AES 1
97#define OPENTITAN_CLKMGR_HAS_HINT_HMAC 1
98#define OPENTITAN_CLKMGR_HAS_HINT_KMAC 1
99#define OPENTITAN_CLKMGR_HAS_HINT_OTBN 1
100#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_REGWEN 1
101#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO 1
102#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO_DIV2 1
103#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO_DIV4 1
104#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_MAIN 1
105#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_USB 1
106#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_RECOV_ERR 1
107#define OPENTITAN_CLKMGR_HAS_LC_EXTCLK_SPEED 1
108#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_REGWEN 1
109#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_HIGH_SPEED 1
110#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_LOW_SPEED 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/**
165 * Get the alert ID of a clkmgr alert for a given instance.
166 *
167 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
168 * instances where the instance is not connected, the return value is unspecified.
169 *
170 * @param dt Instance of clkmgr.
171 * @param alert A clkmgr alert.
172 * @return The Alert Handler alert ID of the alert of this instance.
173 */
175 dt_clkmgr_t dt,
176 dt_clkmgr_alert_t alert);
177
178/**
179 * Convert a global alert ID to a local clkmgr alert type.
180 *
181 * @param dt Instance of clkmgr.
182 * @param alert A global alert ID that belongs to this instance.
183 * @return The clkmgr alert, or `kDtClkmgrAlertCount`.
184 *
185 * **Note:** This function assumes that the global alert ID belongs to the
186 * instance of clkmgr passed in parameter. In other words, it must be the case
187 * that `dt_clkmgr_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
188 * this function will return `kDtClkmgrAlertCount`.
189 */
191 dt_clkmgr_t dt,
192 dt_alert_id_t alert);
193
194
195
196/**
197 * Get the clock signal connected to a clock port of an instance.
198 *
199 * @param dt Instance of clkmgr.
200 * @param clk Clock port.
201 * @return Clock signal.
202 */
204 dt_clkmgr_t dt,
206
207/**
208 * Get the reset signal connected to a reset port of an instance.
209 *
210 * @param dt Instance of clkmgr.
211 * @param rst Reset port.
212 * @return Reset signal.
213 */
215 dt_clkmgr_t dt,
217
218
219/**
220 * Get the number of software gateable clocks.
221 *
222 * @param dt Instance of clkmgr.
223 * @return Number of gateable clocks.
224 */
226
227/**
228 * Get the instance ID of a gateable clock.
229 *
230 * The clocks are ordered as they appear in the registers.
231 *
232 * @param dt Instance of clkmgr.
233 * @param idx Index of the gateable clock, between 0 and `dt_clkmgr_sw_clock_count(dt)-1`.
234 * @return Instance ID of the device whose clock is gateable.
235 */
237
238/**
239 * Get the number of software hintable clocks.
240 *
241 * @param dt Instance of clkmgr.
242 * @return Number of hintable clocks.
243 */
245
246/**
247 * Get the instance ID of a hintable clock.
248 *
249 * The clocks sources are ordered as they appear in the registers.
250 *
251 * @param dt Instance of clkmgr.
252 * @param idx Index of the hintable clock, between 0 and `dt_clkmgr_hint_clock_count(dt)-1`.
253 * @return Instance ID of the device whose clock is hintable.
254 */
256
257
258#endif // OPENTITAN_DT_CLKMGR_H_