Software APIs
rom_ctrl.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_ROM_CTRL_H_
8#define OPENTITAN_DT_ROM_CTRL_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif // __cplusplus
13
14/**
15 * @file
16 * @brief Device Tables (DT) for IP rom_ctrl and top darjeeling.
17 *
18 * This file contains the type definitions and global functions of the rom_ctrl.
19 */
20
21#include "hw/top/dt/api.h"
22#include <stdint.h>
23
24
25
26/**
27 * List of instances.
28 */
29typedef enum dt_rom_ctrl {
30 kDtRomCtrlFirst = 0, /**< First instance */
31 kDtRomCtrl0 = 0, /**< rom_ctrl0 */
32 kDtRomCtrl1 = 1, /**< rom_ctrl1 */
34
35enum {
36 kDtRomCtrlCount = 2, /**< Number of instances */
37};
38
39
40/**
41 * List of register blocks.
42 *
43 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
44 */
46 kDtRomCtrlRegBlockRegs = 0, /**< */
48
49enum {
50 kDtRomCtrlRegBlockCount = 1, /**< Number of register blocks */
51};
52
53
54/** Primary register block (associated with the "primary" set of registers that control the IP). */
55static const dt_rom_ctrl_reg_block_t kDtRomCtrlRegBlockPrimary = kDtRomCtrlRegBlockRegs;
56
57/**
58 * List of memories.
59 *
60 * Memories are guaranteed to start at 0 and to be consecutively numbered.
61 */
62typedef enum dt_rom_ctrl_memory {
63 kDtRomCtrlMemoryRom = 0, /**< */
65
66enum {
67 kDtRomCtrlMemoryCount = 1, /**< Number of memories */
68};
69
70
71/**
72 * List of Alerts.
73 *
74 * Alerts are guaranteed to be numbered consecutively from 0.
75 */
76typedef enum dt_rom_ctrl_alert {
77 kDtRomCtrlAlertFatal = 0, /**< A fatal error. Fatal alerts are non-recoverable and will be asserted until a hard reset. */
79
80enum {
81 kDtRomCtrlAlertCount = 1, /**< Number of Alerts */
82};
83
84
85/**
86 * List of clock ports.
87 *
88 * Clock ports are guaranteed to be numbered consecutively from 0.
89 */
90typedef enum dt_rom_ctrl_clock {
91 kDtRomCtrlClockClk = 0, /**< Clock port clk_i */
93
94enum {
95 kDtRomCtrlClockCount = 1, /**< Number of clock ports */
96};
97
98
99/**
100 * List of reset ports.
101 *
102 * Reset ports are guaranteed to be numbered consecutively from 0.
103 */
104typedef enum dt_rom_ctrl_reset {
105 kDtRomCtrlResetRst = 0, /**< Reset port rst_ni */
107
108enum {
109 kDtRomCtrlResetCount = 1, /**< Number of reset ports */
110};
111
112
113/**
114 * List of supported hardware features.
115 */
116#define OPENTITAN_ROM_CTRL_HAS_SCRAMBLED 1
117#define OPENTITAN_ROM_CTRL_HAS_DIGESTS 1
118#define OPENTITAN_ROM_CTRL_HAS_EXP_DIGESTS 1
119
120
121
122/**
123 * Get the rom_ctrl instance from an instance ID
124 *
125 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
126 *
127 * @param inst_id Instance ID.
128 * @return A rom_ctrl instance.
129 *
130 * **Note:** This function only makes sense if the instance ID has device type rom_ctrl,
131 * otherwise the returned value is unspecified.
132 */
134
135/**
136 * Get the instance ID of an instance.
137 *
138 * @param dt Instance of rom_ctrl.
139 * @return The instance ID of that instance.
140 */
142
143/**
144 * Get the register base address of an instance.
145 *
146 * @param dt Instance of rom_ctrl.
147 * @param reg_block The register block requested.
148 * @return The register base address of the requested block.
149 */
150uint32_t dt_rom_ctrl_reg_block(
151 dt_rom_ctrl_t dt,
152 dt_rom_ctrl_reg_block_t reg_block);
153
154/**
155 * Get the primary register base address of an instance.
156 *
157 * This is just a convenience function, equivalent to
158 * `dt_rom_ctrl_reg_block(dt, kDtRomCtrlRegBlockRegs)`
159 *
160 * @param dt Instance of rom_ctrl.
161 * @return The register base address of the primary register block.
162 */
163static inline uint32_t dt_rom_ctrl_primary_reg_block(
164 dt_rom_ctrl_t dt) {
165 return dt_rom_ctrl_reg_block(dt, kDtRomCtrlRegBlockRegs);
166}
167
168/**
169 * Get the base address of a memory.
170 *
171 * @param dt Instance of rom_ctrl.
172 * @param mem The memory requested.
173 * @return The base address of the requested memory.
174 */
176 dt_rom_ctrl_t dt,
178
179/**
180 * Get the size of a memory.
181 *
182 * @param dt Instance of rom_ctrl.
183 * @param mem The memory requested.
184 * @return The size of the requested memory.
185 */
187 dt_rom_ctrl_t dt,
189
190
191/**
192 * Get the alert ID of a rom_ctrl alert for a given instance.
193 *
194 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
195 * instances where the instance is not connected, the return value is unspecified.
196 *
197 * @param dt Instance of rom_ctrl.
198 * @param alert A rom_ctrl alert.
199 * @return The Alert Handler alert ID of the alert of this instance.
200 */
202 dt_rom_ctrl_t dt,
203 dt_rom_ctrl_alert_t alert);
204
205/**
206 * Convert a global alert ID to a local rom_ctrl alert type.
207 *
208 * @param dt Instance of rom_ctrl.
209 * @param alert A global alert ID that belongs to this instance.
210 * @return The rom_ctrl alert, or `kDtRomCtrlAlertCount`.
211 *
212 * **Note:** This function assumes that the global alert ID belongs to the
213 * instance of rom_ctrl passed in parameter. In other words, it must be the case
214 * that `dt_rom_ctrl_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
215 * this function will return `kDtRomCtrlAlertCount`.
216 */
218 dt_rom_ctrl_t dt,
219 dt_alert_id_t alert);
220
221
222
223/**
224 * Get the clock signal connected to a clock port of an instance.
225 *
226 * @param dt Instance of rom_ctrl.
227 * @param clk Clock port.
228 * @return Clock signal.
229 */
231 dt_rom_ctrl_t dt,
233
234/**
235 * Get the reset signal connected to a reset port of an instance.
236 *
237 * @param dt Instance of rom_ctrl.
238 * @param rst Reset port.
239 * @return Reset signal.
240 */
242 dt_rom_ctrl_t dt,
244
245
246
247#ifdef __cplusplus
248} // extern "C"
249#endif // __cplusplus
250
251#endif // OPENTITAN_DT_ROM_CTRL_H_