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 englishbreakfast.
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 clock ports.
44 *
45 * Clock ports are guaranteed to be numbered consecutively from 0.
46 */
47typedef enum dt_clkmgr_clock {
48 kDtClkmgrClockClk = 0, /**< Clock port clk_i */
49 kDtClkmgrClockMain = 1, /**< Clock port clk_main_i */
50 kDtClkmgrClockIo = 2, /**< Clock port clk_io_i */
51 kDtClkmgrClockUsb = 3, /**< Clock port clk_usb_i */
52 kDtClkmgrClockAon = 4, /**< Clock port clk_aon_i */
53 kDtClkmgrClockCount = 5, /**< \internal Number of clock ports */
55
56/**
57 * List of reset ports.
58 *
59 * Reset ports are guaranteed to be numbered consecutively from 0.
60 */
61typedef enum dt_clkmgr_reset {
62 kDtClkmgrResetRst = 0, /**< Reset port rst_ni */
63 kDtClkmgrResetRoot = 1, /**< Reset port rst_root_ni */
64 kDtClkmgrResetMain = 2, /**< Reset port rst_main_ni */
65 kDtClkmgrResetIo = 3, /**< Reset port rst_io_ni */
66 kDtClkmgrResetUsb = 4, /**< Reset port rst_usb_ni */
67 kDtClkmgrResetAon = 5, /**< Reset port rst_aon_ni */
68 kDtClkmgrResetIoDiv2 = 6, /**< Reset port rst_io_div2_ni */
69 kDtClkmgrResetIoDiv4 = 7, /**< Reset port rst_io_div4_ni */
70 kDtClkmgrResetRootMain = 8, /**< Reset port rst_root_main_ni */
71 kDtClkmgrResetRootIo = 9, /**< Reset port rst_root_io_ni */
72 kDtClkmgrResetRootIoDiv2 = 10, /**< Reset port rst_root_io_div2_ni */
73 kDtClkmgrResetRootIoDiv4 = 11, /**< Reset port rst_root_io_div4_ni */
74 kDtClkmgrResetRootUsb = 12, /**< Reset port rst_root_usb_ni */
75 kDtClkmgrResetCount = 13, /**< \internal Number of reset ports */
77
78/**
79 * List of supported hardware features.
80 */
81#define OPENTITAN_CLKMGR_HAS_ENABLE_IO_DIV4 1
82#define OPENTITAN_CLKMGR_HAS_ENABLE_IO_DIV2 1
83#define OPENTITAN_CLKMGR_HAS_ENABLE_IO 1
84#define OPENTITAN_CLKMGR_HAS_ENABLE_USB 1
85#define OPENTITAN_CLKMGR_HAS_HINT_AES 1
86#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_REGWEN 1
87#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO 1
88#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO_DIV4 1
89#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_MAIN 1
90#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_USB 1
91#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_RECOV_ERR 1
92#define OPENTITAN_CLKMGR_HAS_LC_EXTCLK_SPEED 1
93#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_REGWEN 1
94#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_HIGH_SPEED 1
95#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_LOW_SPEED 1
96#define OPENTITAN_CLKMGR_HAS_JITTER_REGWEN 1
97#define OPENTITAN_CLKMGR_HAS_JITTER_ENABLE 1
98#define OPENTITAN_CLKMGR_HAS_ALERT_HANDLER_CLOCK_STATUS 1
99
100
101
102/**
103 * Get the clkmgr instance from an instance ID
104 *
105 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
106 *
107 * @param inst_id Instance ID.
108 * @return A clkmgr instance.
109 *
110 * **Note:** This function only makes sense if the instance ID has device type clkmgr,
111 * otherwise the returned value is unspecified.
112 */
114
115/**
116 * Get the instance ID of an instance.
117 *
118 * @param dt Instance of clkmgr.
119 * @return The instance ID of that instance.
120 */
122
123/**
124 * Get the register base address of an instance.
125 *
126 * @param dt Instance of clkmgr.
127 * @param reg_block The register block requested.
128 * @return The register base address of the requested block.
129 */
130uint32_t dt_clkmgr_reg_block(
131 dt_clkmgr_t dt,
132 dt_clkmgr_reg_block_t reg_block);
133
134/**
135 * Get the primary register base address of an instance.
136 *
137 * This is just a convenience function, equivalent to
138 * `dt_clkmgr_reg_block(dt, kDtClkmgrRegBlockCore)`
139 *
140 * @param dt Instance of clkmgr.
141 * @return The register base address of the primary register block.
142 */
143static inline uint32_t dt_clkmgr_primary_reg_block(
144 dt_clkmgr_t dt) {
145 return dt_clkmgr_reg_block(dt, kDtClkmgrRegBlockCore);
146}
147
148
149
150
151/**
152 * Get the clock signal connected to a clock port of an instance.
153 *
154 * @param dt Instance of clkmgr.
155 * @param clk Clock port.
156 * @return Clock signal.
157 */
159 dt_clkmgr_t dt,
161
162/**
163 * Get the reset signal connected to a reset port of an instance.
164 *
165 * @param dt Instance of clkmgr.
166 * @param rst Reset port.
167 * @return Reset signal.
168 */
170 dt_clkmgr_t dt,
172
173
174/**
175 * Get the number of software gateable clocks.
176 *
177 * @param dt Instance of clkmgr.
178 * @return Number of gateable clocks.
179 */
181
182/**
183 * Get the instance ID of a gateable clock.
184 *
185 * The clocks are ordered as they appear in the registers.
186 *
187 * @param dt Instance of clkmgr.
188 * @param idx Index of the gateable clock, between 0 and `dt_clkmgr_sw_clock_count(dt)-1`.
189 * @return Instance ID of the device whose clock is gateable.
190 */
192
193/**
194 * Get the number of software hintable clocks.
195 *
196 * @param dt Instance of clkmgr.
197 * @return Number of hintable clocks.
198 */
200
201/**
202 * Get the instance ID of a hintable clock.
203 *
204 * The clocks sources are ordered as they appear in the registers.
205 *
206 * @param dt Instance of clkmgr.
207 * @param idx Index of the hintable clock, between 0 and `dt_clkmgr_hint_clock_count(dt)-1`.
208 * @return Instance ID of the device whose clock is hintable.
209 */
211
212
213#endif // OPENTITAN_DT_CLKMGR_H_