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 englishbreakfast.
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 clock ports.
60 *
61 * Clock ports are guaranteed to be numbered consecutively from 0.
62 */
63typedef enum dt_clkmgr_clock {
64 kDtClkmgrClockClk = 0, /**< Clock port clk_i */
65 kDtClkmgrClockMain = 1, /**< Clock port clk_main_i */
66 kDtClkmgrClockIo = 2, /**< Clock port clk_io_i */
67 kDtClkmgrClockUsb = 3, /**< Clock port clk_usb_i */
68 kDtClkmgrClockAon = 4, /**< Clock port clk_aon_i */
70
71enum {
72 kDtClkmgrClockCount = 5, /**< Number of clock ports */
73};
74
75
76/**
77 * List of reset ports.
78 *
79 * Reset ports are guaranteed to be numbered consecutively from 0.
80 */
81typedef enum dt_clkmgr_reset {
82 kDtClkmgrResetRst = 0, /**< Reset port rst_ni */
83 kDtClkmgrResetRoot = 1, /**< Reset port rst_root_ni */
84 kDtClkmgrResetMain = 2, /**< Reset port rst_main_ni */
85 kDtClkmgrResetIo = 3, /**< Reset port rst_io_ni */
86 kDtClkmgrResetUsb = 4, /**< Reset port rst_usb_ni */
87 kDtClkmgrResetAon = 5, /**< Reset port rst_aon_ni */
88 kDtClkmgrResetIoDiv2 = 6, /**< Reset port rst_io_div2_ni */
89 kDtClkmgrResetIoDiv4 = 7, /**< Reset port rst_io_div4_ni */
90 kDtClkmgrResetRootMain = 8, /**< Reset port rst_root_main_ni */
91 kDtClkmgrResetRootIo = 9, /**< Reset port rst_root_io_ni */
92 kDtClkmgrResetRootIoDiv2 = 10, /**< Reset port rst_root_io_div2_ni */
93 kDtClkmgrResetRootIoDiv4 = 11, /**< Reset port rst_root_io_div4_ni */
94 kDtClkmgrResetRootUsb = 12, /**< Reset port rst_root_usb_ni */
96
97enum {
98 kDtClkmgrResetCount = 13, /**< Number of reset ports */
99};
100
101
102/**
103 * List of supported hardware features.
104 */
105#define OPENTITAN_CLKMGR_HAS_ENABLE_IO_DIV4 1
106#define OPENTITAN_CLKMGR_HAS_ENABLE_IO_DIV2 1
107#define OPENTITAN_CLKMGR_HAS_ENABLE_IO 1
108#define OPENTITAN_CLKMGR_HAS_ENABLE_USB 1
109#define OPENTITAN_CLKMGR_HAS_HINT_AES 1
110#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_REGWEN 1
111#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO 1
112#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO_DIV4 1
113#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_MAIN 1
114#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_USB 1
115#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_RECOV_ERR 1
116#define OPENTITAN_CLKMGR_HAS_LC_EXTCLK_SPEED 1
117#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_REGWEN 1
118#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_HIGH_SPEED 1
119#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_LOW_SPEED 1
120#define OPENTITAN_CLKMGR_HAS_JITTER_REGWEN 1
121#define OPENTITAN_CLKMGR_HAS_JITTER_ENABLE 1
122#define OPENTITAN_CLKMGR_HAS_ALERT_HANDLER_CLOCK_STATUS 1
123
124
125
126/**
127 * Get the clkmgr instance from an instance ID
128 *
129 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
130 *
131 * @param inst_id Instance ID.
132 * @return A clkmgr instance.
133 *
134 * **Note:** This function only makes sense if the instance ID has device type clkmgr,
135 * otherwise the returned value is unspecified.
136 */
138
139/**
140 * Get the instance ID of an instance.
141 *
142 * @param dt Instance of clkmgr.
143 * @return The instance ID of that instance.
144 */
146
147/**
148 * Get the register base address of an instance.
149 *
150 * @param dt Instance of clkmgr.
151 * @param reg_block The register block requested.
152 * @return The register base address of the requested block.
153 */
154uint32_t dt_clkmgr_reg_block(
155 dt_clkmgr_t dt,
156 dt_clkmgr_reg_block_t reg_block);
157
158/**
159 * Get the primary register base address of an instance.
160 *
161 * This is just a convenience function, equivalent to
162 * `dt_clkmgr_reg_block(dt, kDtClkmgrRegBlockCore)`
163 *
164 * @param dt Instance of clkmgr.
165 * @return The register base address of the primary register block.
166 */
167static inline uint32_t dt_clkmgr_primary_reg_block(
168 dt_clkmgr_t dt) {
169 return dt_clkmgr_reg_block(dt, kDtClkmgrRegBlockCore);
170}
171
172
173
174
175/**
176 * Get the clock signal connected to a clock port of an instance.
177 *
178 * @param dt Instance of clkmgr.
179 * @param clk Clock port.
180 * @return Clock signal.
181 */
183 dt_clkmgr_t dt,
185
186/**
187 * Get the reset signal connected to a reset port of an instance.
188 *
189 * @param dt Instance of clkmgr.
190 * @param rst Reset port.
191 * @return Reset signal.
192 */
194 dt_clkmgr_t dt,
196
197
198
199/**
200 * Get the number of software gateable clocks.
201 *
202 * @param dt Instance of clkmgr.
203 * @return Number of gateable clocks.
204 */
206
207/**
208 * Get the instance ID of a gateable clock.
209 *
210 * The clocks are ordered as they appear in the registers.
211 *
212 * @param dt Instance of clkmgr.
213 * @param idx Index of the gateable clock, between 0 and `dt_clkmgr_sw_clock_count(dt)-1`.
214 * @return Instance ID of the device whose clock is gateable.
215 */
217
218/**
219 * Get the number of software hintable clocks.
220 *
221 * @param dt Instance of clkmgr.
222 * @return Number of hintable clocks.
223 */
225
226/**
227 * Get the instance ID of a hintable clock.
228 *
229 * The clocks sources are ordered as they appear in the registers.
230 *
231 * @param dt Instance of clkmgr.
232 * @param idx Index of the hintable clock, between 0 and `dt_clkmgr_hint_clock_count(dt)-1`.
233 * @return Instance ID of the device whose clock is hintable.
234 */
236
237/**
238 * Description of a measurable clock.
239 *
240 */
241typedef struct dt_clkmgr_measurable_clk {
242 dt_clock_t clock; /**< Clock */
243 uint32_t meas_ctrl_en_off; /**< MEAS_CTRL_EN register offset */
244 bitfield_field32_t meas_ctrl_en_en_field; /**< MEAS_CTRL_EN_EN bitfield */
245 uint32_t meas_ctrl_shadowed_off; /**< CTRL_SHADOWED register offset */
246 bitfield_field32_t meas_ctrl_shadowed_lo_field; /**< CTRL_SHADOWED_LO bitfield */
247 bitfield_field32_t meas_ctrl_shadowed_hi_field; /**< CTRL_SHADOWED_HI bitfield */
249
250
251/**
252 * Get the number of measurable clocks.
253 *
254 * @param dt Instance of clkmgr.
255 * @return Number of measurable clocks.
256 */
258
259/**
260 * Get the description of a measurable clock.
261 *
262 * @param dt Instance of clkmgr.
263 * @param idx Index of the measurable clock, between 0 and
264 * `dt_clkmgr_measurable_clock_count(dt)-1`.
265 * @return Description of the measurable clock.
266 */
268
269
270
271#ifdef __cplusplus
272} // extern "C"
273#endif // __cplusplus
274
275#endif // OPENTITAN_DT_CLKMGR_H_