Software APIs
dt_sram_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_SRAM_CTRL_H_
8#define OPENTITAN_DT_SRAM_CTRL_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif // __cplusplus
13
14/**
15 * @file
16 * @brief Device Tables (DT) for IP sram_ctrl and top earlgrey.
17 *
18 * This file contains the type definitions and global functions of the sram_ctrl.
19 */
20
21#include "hw/top/dt/dt_api.h"
22#include <stdint.h>
23
24
25
26/**
27 * List of instances.
28 */
29typedef enum dt_sram_ctrl {
30 kDtSramCtrlRetAon = 0, /**< sram_ctrl_ret_aon */
31 kDtSramCtrlMain = 1, /**< sram_ctrl_main */
32 kDtSramCtrlFirst = 0, /**< \internal First instance */
33 kDtSramCtrlCount = 2, /**< \internal Number of instances */
35
36/**
37 * List of register blocks.
38 *
39 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
40 */
42 kDtSramCtrlRegBlockRegs = 0, /**< */
43 kDtSramCtrlRegBlockCount = 1, /**< \internal Number of register blocks */
45
46/** Primary register block (associated with the "primary" set of registers that control the IP). */
47static const dt_sram_ctrl_reg_block_t kDtSramCtrlRegBlockPrimary = kDtSramCtrlRegBlockRegs;
48
49/**
50 * List of memories.
51 *
52 * Memories are guaranteed to start at 0 and to be consecutively numbered.
53 */
54typedef enum dt_sram_ctrl_memory {
55 kDtSramCtrlMemoryRam = 0, /**< */
56 kDtSramCtrlMemoryCount = 1, /**< \internal Number of memories */
58
59/**
60 * List of Alerts.
61 *
62 * Alerts are guaranteed to be numbered consecutively from 0.
63 */
64typedef enum dt_sram_ctrl_alert {
65 kDtSramCtrlAlertFatalError = 0, /**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected,
66or if the initialization mechanism has reached an invalid state. */
67 kDtSramCtrlAlertCount = 1, /**< \internal Number of Alerts */
69
70/**
71 * List of clock ports.
72 *
73 * Clock ports are guaranteed to be numbered consecutively from 0.
74 */
75typedef enum dt_sram_ctrl_clock {
76 kDtSramCtrlClockClk = 0, /**< Clock port clk_i */
77 kDtSramCtrlClockOtp = 1, /**< Clock port clk_otp_i */
78 kDtSramCtrlClockCount = 2, /**< \internal Number of clock ports */
80
81/**
82 * List of reset ports.
83 *
84 * Reset ports are guaranteed to be numbered consecutively from 0.
85 */
86typedef enum dt_sram_ctrl_reset {
87 kDtSramCtrlResetRst = 0, /**< Reset port rst_ni */
88 kDtSramCtrlResetOtp = 1, /**< Reset port rst_otp_ni */
89 kDtSramCtrlResetCount = 2, /**< \internal Number of reset ports */
91
92/**
93 * List of supported hardware features.
94 */
95#define OPENTITAN_SRAM_CTRL_HAS_INTEGRITY 1
96#define OPENTITAN_SRAM_CTRL_HAS_SCRAMBLED 1
97#define OPENTITAN_SRAM_CTRL_HAS_LOCK_ON_ERROR 1
98#define OPENTITAN_SRAM_CTRL_HAS_MEMSET 1
99#define OPENTITAN_SRAM_CTRL_HAS_FETCH_ALLOW 1
100#define OPENTITAN_SRAM_CTRL_HAS_SUBWORD_ACCESS 1
101#define OPENTITAN_SRAM_CTRL_HAS_REGWEN 1
102
103
104
105/**
106 * Get the sram_ctrl instance from an instance ID
107 *
108 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
109 *
110 * @param inst_id Instance ID.
111 * @return A sram_ctrl instance.
112 *
113 * **Note:** This function only makes sense if the instance ID has device type sram_ctrl,
114 * otherwise the returned value is unspecified.
115 */
117
118/**
119 * Get the instance ID of an instance.
120 *
121 * @param dt Instance of sram_ctrl.
122 * @return The instance ID of that instance.
123 */
125
126/**
127 * Get the register base address of an instance.
128 *
129 * @param dt Instance of sram_ctrl.
130 * @param reg_block The register block requested.
131 * @return The register base address of the requested block.
132 */
135 dt_sram_ctrl_reg_block_t reg_block);
136
137/**
138 * Get the primary register base address of an instance.
139 *
140 * This is just a convenience function, equivalent to
141 * `dt_sram_ctrl_reg_block(dt, kDtSramCtrlRegBlockRegs)`
142 *
143 * @param dt Instance of sram_ctrl.
144 * @return The register base address of the primary register block.
145 */
146static inline uint32_t dt_sram_ctrl_primary_reg_block(
147 dt_sram_ctrl_t dt) {
148 return dt_sram_ctrl_reg_block(dt, kDtSramCtrlRegBlockRegs);
149}
150
151/**
152 * Get the base address of a memory.
153 *
154 * @param dt Instance of sram_ctrl.
155 * @param mem The memory requested.
156 * @return The base address of the requested memory.
157 */
161
162/**
163 * Get the size of a memory.
164 *
165 * @param dt Instance of sram_ctrl.
166 * @param mem The memory requested.
167 * @return The size of the requested memory.
168 */
172
173
174/**
175 * Get the alert ID of a sram_ctrl alert for a given instance.
176 *
177 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
178 * instances where the instance is not connected, the return value is unspecified.
179 *
180 * @param dt Instance of sram_ctrl.
181 * @param alert A sram_ctrl alert.
182 * @return The Alert Handler alert ID of the alert of this instance.
183 */
187
188/**
189 * Convert a global alert ID to a local sram_ctrl alert type.
190 *
191 * @param dt Instance of sram_ctrl.
192 * @param alert A global alert ID that belongs to this instance.
193 * @return The sram_ctrl alert, or `kDtSramCtrlAlertCount`.
194 *
195 * **Note:** This function assumes that the global alert ID belongs to the
196 * instance of sram_ctrl passed in parameter. In other words, it must be the case
197 * that `dt_sram_ctrl_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
198 * this function will return `kDtSramCtrlAlertCount`.
199 */
202 dt_alert_id_t alert);
203
204
205
206/**
207 * Get the clock signal connected to a clock port of an instance.
208 *
209 * @param dt Instance of sram_ctrl.
210 * @param clk Clock port.
211 * @return Clock signal.
212 */
216
217/**
218 * Get the reset signal connected to a reset port of an instance.
219 *
220 * @param dt Instance of sram_ctrl.
221 * @param rst Reset port.
222 * @return Reset signal.
223 */
227
228
229
230#ifdef __cplusplus
231} // extern "C"
232#endif // __cplusplus
233
234#endif // OPENTITAN_DT_SRAM_CTRL_H_