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