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