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 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
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 clock ports.
61 *
62 * Clock ports are guaranteed to be numbered consecutively from 0.
63 */
64typedef 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 */
72
73/**
74 * List of reset ports.
75 *
76 * Reset ports are guaranteed to be numbered consecutively from 0.
77 */
78typedef 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 */
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 */
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 */
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 */
147uint32_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 */
160static 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 */
172uint32_t dt_clkmgr_memory_base(
173 dt_clkmgr_t dt,
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 */
183uint32_t dt_clkmgr_memory_size(
184 dt_clkmgr_t dt,
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 */
198 dt_clkmgr_t dt,
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 */
209 dt_clkmgr_t dt,
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 */
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 */
232
233/**
234 * Get the number of software hintable clocks.
235 *
236 * @param dt Instance of clkmgr.
237 * @return Number of hintable clocks.
238 */
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 */
251
252/**
253 * Description of a measurable clock.
254 *
255 */
256typedef 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 */
264
265
266/**
267 * Get the number of measurable clocks.
268 *
269 * @param dt Instance of clkmgr.
270 * @return Number of measurable clocks.
271 */
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 */
283
284
285
286#ifdef __cplusplus
287} // extern "C"
288#endif // __cplusplus
289
290#endif // OPENTITAN_DT_CLKMGR_H_