Software APIs
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 darjeeling.
17 *
18 * This file contains the type definitions and global functions of the sram_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_sram_ctrl {
30 kDtSramCtrlFirst = 0, /**< First instance */
31 kDtSramCtrlRetAon = 0, /**< sram_ctrl_ret_aon */
32 kDtSramCtrlMain = 1, /**< sram_ctrl_main */
33 kDtSramCtrlMbox = 2, /**< sram_ctrl_mbox */
35
36enum {
37 kDtSramCtrlCount = 3, /**< Number of instances */
38};
39
40
41/**
42 * List of register blocks.
43 *
44 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
45 */
47 kDtSramCtrlRegBlockRegs = 0, /**< */
49
50enum {
51 kDtSramCtrlRegBlockCount = 1, /**< Number of register blocks */
52};
53
54
55/** Primary register block (associated with the "primary" set of registers that control the IP). */
56static const dt_sram_ctrl_reg_block_t kDtSramCtrlRegBlockPrimary = kDtSramCtrlRegBlockRegs;
57
58/**
59 * List of memories.
60 *
61 * Memories are guaranteed to start at 0 and to be consecutively numbered.
62 */
63typedef enum dt_sram_ctrl_memory {
64 kDtSramCtrlMemoryRam = 0, /**< */
66
67enum {
68 kDtSramCtrlMemoryCount = 1, /**< Number of memories */
69};
70
71
72/**
73 * List of Alerts.
74 *
75 * Alerts are guaranteed to be numbered consecutively from 0.
76 */
77typedef enum dt_sram_ctrl_alert {
78 kDtSramCtrlAlertFatalError = 0, /**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected,
79 or if the initialization mechanism has reached an invalid state. */
81
82enum {
83 kDtSramCtrlAlertCount = 1, /**< Number of Alerts */
84};
85
86
87/**
88 * List of clock ports.
89 *
90 * Clock ports are guaranteed to be numbered consecutively from 0.
91 */
92typedef enum dt_sram_ctrl_clock {
93 kDtSramCtrlClockClk = 0, /**< Clock port clk_i */
94 kDtSramCtrlClockOtp = 1, /**< Clock port clk_otp_i */
96
97enum {
98 kDtSramCtrlClockCount = 2, /**< Number of clock ports */
99};
100
101
102/**
103 * List of reset ports.
104 *
105 * Reset ports are guaranteed to be numbered consecutively from 0.
106 */
107typedef enum dt_sram_ctrl_reset {
108 kDtSramCtrlResetRst = 0, /**< Reset port rst_ni */
109 kDtSramCtrlResetOtp = 1, /**< Reset port rst_otp_ni */
111
112enum {
113 kDtSramCtrlResetCount = 2, /**< Number of reset ports */
114};
115
116
117/**
118 * List of supported hardware features.
119 */
120#define OPENTITAN_SRAM_CTRL_HAS_INTEGRITY 1
121#define OPENTITAN_SRAM_CTRL_HAS_SCRAMBLED 1
122#define OPENTITAN_SRAM_CTRL_HAS_LOCK_ON_ERROR 1
123#define OPENTITAN_SRAM_CTRL_HAS_MEMSET 1
124#define OPENTITAN_SRAM_CTRL_HAS_FETCH_ALLOW 1
125#define OPENTITAN_SRAM_CTRL_HAS_SUBWORD_ACCESS 1
126#define OPENTITAN_SRAM_CTRL_HAS_REGWEN 1
127
128
129
130/**
131 * Get the sram_ctrl instance from an instance ID
132 *
133 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
134 *
135 * @param inst_id Instance ID.
136 * @return A sram_ctrl instance.
137 *
138 * **Note:** This function only makes sense if the instance ID has device type sram_ctrl,
139 * otherwise the returned value is unspecified.
140 */
142
143/**
144 * Get the instance ID of an instance.
145 *
146 * @param dt Instance of sram_ctrl.
147 * @return The instance ID of that instance.
148 */
150
151/**
152 * Get the register base address of an instance.
153 *
154 * @param dt Instance of sram_ctrl.
155 * @param reg_block The register block requested.
156 * @return The register base address of the requested block.
157 */
160 dt_sram_ctrl_reg_block_t reg_block);
161
162/**
163 * Get the primary register base address of an instance.
164 *
165 * This is just a convenience function, equivalent to
166 * `dt_sram_ctrl_reg_block(dt, kDtSramCtrlRegBlockRegs)`
167 *
168 * @param dt Instance of sram_ctrl.
169 * @return The register base address of the primary register block.
170 */
171static inline uint32_t dt_sram_ctrl_primary_reg_block(
172 dt_sram_ctrl_t dt) {
173 return dt_sram_ctrl_reg_block(dt, kDtSramCtrlRegBlockRegs);
174}
175
176/**
177 * Get the base address of a memory.
178 *
179 * @param dt Instance of sram_ctrl.
180 * @param mem The memory requested.
181 * @return The base address of the requested memory.
182 */
186
187/**
188 * Get the size of a memory.
189 *
190 * @param dt Instance of sram_ctrl.
191 * @param mem The memory requested.
192 * @return The size of the requested memory.
193 */
197
198
199/**
200 * Get the alert ID of a sram_ctrl alert for a given instance.
201 *
202 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
203 * instances where the instance is not connected, the return value is unspecified.
204 *
205 * @param dt Instance of sram_ctrl.
206 * @param alert A sram_ctrl alert.
207 * @return The Alert Handler alert ID of the alert of this instance.
208 */
212
213/**
214 * Convert a global alert ID to a local sram_ctrl alert type.
215 *
216 * @param dt Instance of sram_ctrl.
217 * @param alert A global alert ID that belongs to this instance.
218 * @return The sram_ctrl alert, or `kDtSramCtrlAlertCount`.
219 *
220 * **Note:** This function assumes that the global alert ID belongs to the
221 * instance of sram_ctrl passed in parameter. In other words, it must be the case
222 * that `dt_sram_ctrl_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
223 * this function will return `kDtSramCtrlAlertCount`.
224 */
227 dt_alert_id_t alert);
228
229
230
231/**
232 * Get the clock signal connected to a clock port of an instance.
233 *
234 * @param dt Instance of sram_ctrl.
235 * @param clk Clock port.
236 * @return Clock signal.
237 */
241
242/**
243 * Get the reset signal connected to a reset port of an instance.
244 *
245 * @param dt Instance of sram_ctrl.
246 * @param rst Reset port.
247 * @return Reset signal.
248 */
252
253
254
255#ifdef __cplusplus
256} // extern "C"
257#endif // __cplusplus
258
259#endif // OPENTITAN_DT_SRAM_CTRL_H_