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