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 kDtClkmgr = 0, /**< clkmgr */
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 kDtClkmgrResetIoDiv4 = 6, /**< Reset port rst_io_div4_ni */
89 kDtClkmgrResetRootMain = 7, /**< Reset port rst_root_main_ni */
90 kDtClkmgrResetRootIo = 8, /**< Reset port rst_root_io_ni */
91 kDtClkmgrResetRootIoDiv4 = 9, /**< Reset port rst_root_io_div4_ni */
92 kDtClkmgrResetRootUsb = 10, /**< Reset port rst_root_usb_ni */
94
95enum {
96 kDtClkmgrResetCount = 11, /**< Number of reset ports */
97};
98
99
100/**
101 * List of supported hardware features.
102 */
103#define OPENTITAN_CLKMGR_HAS_ENABLE_IO_DIV4 1
104#define OPENTITAN_CLKMGR_HAS_ENABLE_IO 1
105#define OPENTITAN_CLKMGR_HAS_ENABLE_USB 1
106#define OPENTITAN_CLKMGR_HAS_HINT_AES 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_IO_DIV4 1
110#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_MAIN 1
111#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_USB 1
112#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_RECOV_ERR 1
113#define OPENTITAN_CLKMGR_HAS_LC_EXTCLK_SPEED 1
114#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_REGWEN 1
115#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_HIGH_SPEED 1
116#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_LOW_SPEED 1
117#define OPENTITAN_CLKMGR_HAS_JITTER_REGWEN 1
118#define OPENTITAN_CLKMGR_HAS_JITTER_ENABLE 1
119#define OPENTITAN_CLKMGR_HAS_ALERT_HANDLER_CLOCK_STATUS 1
120
121
122
123/**
124 * Get the clkmgr instance from an instance ID
125 *
126 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
127 *
128 * @param inst_id Instance ID.
129 * @return A clkmgr instance.
130 *
131 * **Note:** This function only makes sense if the instance ID has device type clkmgr,
132 * otherwise the returned value is unspecified.
133 */
135
136/**
137 * Get the instance ID of an instance.
138 *
139 * @param dt Instance of clkmgr.
140 * @return The instance ID of that instance.
141 */
143
144/**
145 * Get the register base address of an instance.
146 *
147 * @param dt Instance of clkmgr.
148 * @param reg_block The register block requested.
149 * @return The register base address of the requested block.
150 */
151uint32_t dt_clkmgr_reg_block(
152 dt_clkmgr_t dt,
153 dt_clkmgr_reg_block_t reg_block);
154
155/**
156 * Get the primary register base address of an instance.
157 *
158 * This is just a convenience function, equivalent to
159 * `dt_clkmgr_reg_block(dt, kDtClkmgrRegBlockCore)`
160 *
161 * @param dt Instance of clkmgr.
162 * @return The register base address of the primary register block.
163 */
164static inline uint32_t dt_clkmgr_primary_reg_block(
165 dt_clkmgr_t dt) {
166 return dt_clkmgr_reg_block(dt, kDtClkmgrRegBlockCore);
167}
168
169
170
171
172/**
173 * Get the clock signal connected to a clock port of an instance.
174 *
175 * @param dt Instance of clkmgr.
176 * @param clk Clock port.
177 * @return Clock signal.
178 */
180 dt_clkmgr_t dt,
182
183/**
184 * Get the reset signal connected to a reset port of an instance.
185 *
186 * @param dt Instance of clkmgr.
187 * @param rst Reset port.
188 * @return Reset signal.
189 */
191 dt_clkmgr_t dt,
193
194
195
196/**
197 * Get the number of software gateable clocks.
198 *
199 * @param dt Instance of clkmgr.
200 * @return Number of gateable clocks.
201 */
203
204/**
205 * Get the instance ID of a gateable clock.
206 *
207 * The clocks are ordered as they appear in the registers.
208 *
209 * @param dt Instance of clkmgr.
210 * @param idx Index of the gateable clock, between 0 and `dt_clkmgr_sw_clock_count(dt)-1`.
211 * @return Instance ID of the device whose clock is gateable.
212 */
214
215/**
216 * Get the number of software hintable clocks.
217 *
218 * @param dt Instance of clkmgr.
219 * @return Number of hintable clocks.
220 */
222
223/**
224 * Get the instance ID of a hintable clock.
225 *
226 * The clocks sources are ordered as they appear in the registers.
227 *
228 * @param dt Instance of clkmgr.
229 * @param idx Index of the hintable clock, between 0 and `dt_clkmgr_hint_clock_count(dt)-1`.
230 * @return Instance ID of the device whose clock is hintable.
231 */
233
234/**
235 * Description of a measurable clock.
236 *
237 */
238typedef struct dt_clkmgr_measurable_clk {
239 dt_clock_t clock; /**< Clock */
240 uint32_t meas_ctrl_en_off; /**< MEAS_CTRL_EN register offset */
241 bitfield_field32_t meas_ctrl_en_en_field; /**< MEAS_CTRL_EN_EN bitfield */
242 uint32_t meas_ctrl_shadowed_off; /**< CTRL_SHADOWED register offset */
243 bitfield_field32_t meas_ctrl_shadowed_lo_field; /**< CTRL_SHADOWED_LO bitfield */
244 bitfield_field32_t meas_ctrl_shadowed_hi_field; /**< CTRL_SHADOWED_HI bitfield */
246
247
248/**
249 * Get the number of measurable clocks.
250 *
251 * @param dt Instance of clkmgr.
252 * @return Number of measurable clocks.
253 */
255
256/**
257 * Get the description of a measurable clock.
258 *
259 * @param dt Instance of clkmgr.
260 * @param idx Index of the measurable clock, between 0 and
261 * `dt_clkmgr_measurable_clock_count(dt)-1`.
262 * @return Description of the measurable clock.
263 */
265
266
267
268#ifdef __cplusplus
269} // extern "C"
270#endif // __cplusplus
271
272#endif // OPENTITAN_DT_CLKMGR_H_