Software APIs
dt_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 earlgrey.
17 *
18 * This file contains the type definitions and global functions of the rom_ctrl.
19 */
20
21#include "dt_api.h"
22#include <stdint.h>
23
24
25
26/**
27 * List of instances.
28 */
29typedef enum dt_rom_ctrl {
30 kDtRomCtrl = 0, /**< rom_ctrl */
31 kDtRomCtrlFirst = 0, /**< \internal First instance */
32 kDtRomCtrlCount = 1, /**< \internal Number of instances */
34
35/**
36 * List of register blocks.
37 *
38 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
39 */
41 kDtRomCtrlRegBlockRegs = 0, /**< */
42 kDtRomCtrlRegBlockRom = 1, /**< */
43 kDtRomCtrlRegBlockCount = 2, /**< \internal Number of register blocks */
45
46/** Primary register block (associated with the "primary" set of registers that control the IP). */
47static const dt_rom_ctrl_reg_block_t kDtRomCtrlRegBlockPrimary = kDtRomCtrlRegBlockRegs;
48
49/**
50 * List of Alerts.
51 *
52 * Alerts are guaranteed to be numbered consecutively from 0.
53 */
54typedef enum dt_rom_ctrl_alert {
55 kDtRomCtrlAlertFatal = 0, /**< A fatal error. Fatal alerts are non-recoverable and will be asserted until a hard reset. */
56 kDtRomCtrlAlertCount = 1, /**< \internal Number of Alerts */
58
59/**
60 * List of clock ports.
61 *
62 * Clock ports are guaranteed to be numbered consecutively from 0.
63 */
64typedef enum dt_rom_ctrl_clock {
65 kDtRomCtrlClockClk = 0, /**< Clock port clk_i */
66 kDtRomCtrlClockCount = 1, /**< \internal Number of clock ports */
68
69/**
70 * List of reset ports.
71 *
72 * Reset ports are guaranteed to be numbered consecutively from 0.
73 */
74typedef enum dt_rom_ctrl_reset {
75 kDtRomCtrlResetRst = 0, /**< Reset port rst_ni */
76 kDtRomCtrlResetCount = 1, /**< \internal Number of reset ports */
78
79/**
80 * List of supported hardware features.
81 */
82#define OPENTITAN_ROM_CTRL_HAS_SCRAMBLED 1
83#define OPENTITAN_ROM_CTRL_HAS_DIGESTS 1
84#define OPENTITAN_ROM_CTRL_HAS_EXP_DIGESTS 1
85
86
87
88/**
89 * Get the rom_ctrl instance from an instance ID
90 *
91 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
92 *
93 * @param inst_id Instance ID.
94 * @return A rom_ctrl instance.
95 *
96 * **Note:** This function only makes sense if the instance ID has device type rom_ctrl,
97 * otherwise the returned value is unspecified.
98 */
100
101/**
102 * Get the instance ID of an instance.
103 *
104 * @param dt Instance of rom_ctrl.
105 * @return The instance ID of that instance.
106 */
108
109/**
110 * Get the register base address of an instance.
111 *
112 * @param dt Instance of rom_ctrl.
113 * @param reg_block The register block requested.
114 * @return The register base address of the requested block.
115 */
116uint32_t dt_rom_ctrl_reg_block(
117 dt_rom_ctrl_t dt,
118 dt_rom_ctrl_reg_block_t reg_block);
119
120/**
121 * Get the primary register base address of an instance.
122 *
123 * This is just a convenience function, equivalent to
124 * `dt_rom_ctrl_reg_block(dt, kDtRomCtrlRegBlockRegs)`
125 *
126 * @param dt Instance of rom_ctrl.
127 * @return The register base address of the primary register block.
128 */
129static inline uint32_t dt_rom_ctrl_primary_reg_block(
130 dt_rom_ctrl_t dt) {
131 return dt_rom_ctrl_reg_block(dt, kDtRomCtrlRegBlockRegs);
132}
133
134
135/**
136 * Get the alert ID of a rom_ctrl alert for a given instance.
137 *
138 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
139 * instances where the instance is not connected, the return value is unspecified.
140 *
141 * @param dt Instance of rom_ctrl.
142 * @param alert A rom_ctrl alert.
143 * @return The Alert Handler alert ID of the alert of this instance.
144 */
146 dt_rom_ctrl_t dt,
147 dt_rom_ctrl_alert_t alert);
148
149/**
150 * Convert a global alert ID to a local rom_ctrl alert type.
151 *
152 * @param dt Instance of rom_ctrl.
153 * @param alert A global alert ID that belongs to this instance.
154 * @return The rom_ctrl alert, or `kDtRomCtrlAlertCount`.
155 *
156 * **Note:** This function assumes that the global alert ID belongs to the
157 * instance of rom_ctrl passed in parameter. In other words, it must be the case
158 * that `dt_rom_ctrl_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
159 * this function will return `kDtRomCtrlAlertCount`.
160 */
162 dt_rom_ctrl_t dt,
163 dt_alert_id_t alert);
164
165
166
167/**
168 * Get the clock signal connected to a clock port of an instance.
169 *
170 * @param dt Instance of rom_ctrl.
171 * @param clk Clock port.
172 * @return Clock signal.
173 */
175 dt_rom_ctrl_t dt,
177
178/**
179 * Get the reset signal connected to a reset port of an instance.
180 *
181 * @param dt Instance of rom_ctrl.
182 * @param rst Reset port.
183 * @return Reset signal.
184 */
186 dt_rom_ctrl_t dt,
188
189
190
191#ifdef __cplusplus
192} // extern "C"
193#endif // __cplusplus
194
195#endif // OPENTITAN_DT_ROM_CTRL_H_