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/**
11 * @file
12 * @brief Device Tables (DT) for IP sram_ctrl and top earlgrey.
13 *
14 * This file contains the type definitions and global functions of the sram_ctrl.
15 */
16
17#include "dt_api.h"
18#include <stdint.h>
19
20/**
21 * List of instances.
22 */
23typedef enum dt_sram_ctrl {
24 kDtSramCtrlRetAon = 0, /**< sram_ctrl_ret_aon */
25 kDtSramCtrlMain = 1, /**< sram_ctrl_main */
26 kDtSramCtrlFirst = 0, /**< \internal First instance */
27 kDtSramCtrlCount = 2, /**< \internal Number of instances */
29
30/**
31 * List of register blocks.
32 *
33 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
34 */
36 kDtSramCtrlRegBlockRegs = 0, /**< */
37 kDtSramCtrlRegBlockRam = 1, /**< */
38 kDtSramCtrlRegBlockCount = 2, /**< \internal Number of register blocks */
40
41/** Primary register block (associated with the "primary" set of registers that control the IP). */
42static const dt_sram_ctrl_reg_block_t kDtSramCtrlRegBlockPrimary = kDtSramCtrlRegBlockRegs;
43
44/**
45 * List of Alerts.
46 *
47 * Alerts are guaranteed to be numbered consecutively from 0.
48 */
49typedef enum dt_sram_ctrl_alert {
50 kDtSramCtrlAlertFatalError = 0, /**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected,
51or if the initialization mechanism has reached an invalid state. */
52 kDtSramCtrlAlertCount = 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_sram_ctrl_clock {
61 kDtSramCtrlClockClk = 0, /**< Clock port clk_i */
62 kDtSramCtrlClockOtp = 1, /**< Clock port clk_otp_i */
63 kDtSramCtrlClockCount = 2, /**< \internal Number of clock ports */
65
66/**
67 * List of reset ports.
68 *
69 * Reset ports are guaranteed to be numbered consecutively from 0.
70 */
71typedef enum dt_sram_ctrl_reset {
72 kDtSramCtrlResetRst = 0, /**< Reset port rst_ni */
73 kDtSramCtrlResetOtp = 1, /**< Reset port rst_otp_ni */
74 kDtSramCtrlResetCount = 2, /**< \internal Number of reset ports */
76
77/**
78 * List of supported hardware features.
79 */
80#define OPENTITAN_SRAM_CTRL_HAS_INTEGRITY 1
81#define OPENTITAN_SRAM_CTRL_HAS_SCRAMBLED 1
82#define OPENTITAN_SRAM_CTRL_HAS_LOCK_ON_ERROR 1
83#define OPENTITAN_SRAM_CTRL_HAS_MEMSET 1
84#define OPENTITAN_SRAM_CTRL_HAS_FETCH_ALLOW 1
85#define OPENTITAN_SRAM_CTRL_HAS_SUBWORD_ACCESS 1
86#define OPENTITAN_SRAM_CTRL_HAS_REGWEN 1
87
88
89
90/**
91 * Get the sram_ctrl instance from an instance ID
92 *
93 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
94 *
95 * @param inst_id Instance ID.
96 * @return A sram_ctrl instance.
97 *
98 * **Note:** This function only makes sense if the instance ID has device type sram_ctrl,
99 * otherwise the returned value is unspecified.
100 */
102
103/**
104 * Get the instance ID of an instance.
105 *
106 * @param dt Instance of sram_ctrl.
107 * @return The instance ID of that instance.
108 */
110
111/**
112 * Get the register base address of an instance.
113 *
114 * @param dt Instance of sram_ctrl.
115 * @param reg_block The register block requested.
116 * @return The register base address of the requested block.
117 */
120 dt_sram_ctrl_reg_block_t reg_block);
121
122/**
123 * Get the primary register base address of an instance.
124 *
125 * This is just a convenience function, equivalent to
126 * `dt_sram_ctrl_reg_block(dt, kDtSramCtrlRegBlockRegs)`
127 *
128 * @param dt Instance of sram_ctrl.
129 * @return The register base address of the primary register block.
130 */
131static inline uint32_t dt_sram_ctrl_primary_reg_block(
132 dt_sram_ctrl_t dt) {
133 return dt_sram_ctrl_reg_block(dt, kDtSramCtrlRegBlockRegs);
134}
135
136
137/**
138 * Get the alert ID of a sram_ctrl alert for a given instance.
139 *
140 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
141 * instances where the instance is not connected, the return value is unspecified.
142 *
143 * @param dt Instance of sram_ctrl.
144 * @param alert A sram_ctrl alert.
145 * @return The Alert Handler alert ID of the alert of this instance.
146 */
150
151/**
152 * Convert a global alert ID to a local sram_ctrl alert type.
153 *
154 * @param dt Instance of sram_ctrl.
155 * @param alert A global alert ID that belongs to this instance.
156 * @return The sram_ctrl alert, or `kDtSramCtrlAlertCount`.
157 *
158 * **Note:** This function assumes that the global alert ID belongs to the
159 * instance of sram_ctrl passed in parameter. In other words, it must be the case
160 * that `dt_sram_ctrl_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
161 * this function will return `kDtSramCtrlAlertCount`.
162 */
165 dt_alert_id_t alert);
166
167
168
169/**
170 * Get the clock signal connected to a clock port of an instance.
171 *
172 * @param dt Instance of sram_ctrl.
173 * @param clk Clock port.
174 * @return Clock signal.
175 */
179
180/**
181 * Get the reset signal connected to a reset port of an instance.
182 *
183 * @param dt Instance of sram_ctrl.
184 * @param rst Reset port.
185 * @return Reset signal.
186 */
190
191
192
193#endif // OPENTITAN_DT_SRAM_CTRL_H_