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
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/dt_api.h"
22
#include <stdint.h>
23
24
25
26
/**
27
* List of instances.
28
*/
29
typedef
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 */
34
}
dt_sram_ctrl_t
;
35
36
/**
37
* List of register blocks.
38
*
39
* Register blocks are guaranteed to start at 0 and to be consecutively numbered.
40
*/
41
typedef
enum
dt_sram_ctrl_reg_block
{
42
kDtSramCtrlRegBlockRegs = 0,
/**< */
43
kDtSramCtrlRegBlockCount = 1,
/**< \internal Number of register blocks */
44
}
dt_sram_ctrl_reg_block_t
;
45
46
/** Primary register block (associated with the "primary" set of registers that control the IP). */
47
static
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
*/
54
typedef
enum
dt_sram_ctrl_memory
{
55
kDtSramCtrlMemoryRam = 0,
/**< */
56
kDtSramCtrlMemoryCount = 1,
/**< \internal Number of memories */
57
}
dt_sram_ctrl_memory_t
;
58
59
/**
60
* List of Alerts.
61
*
62
* Alerts are guaranteed to be numbered consecutively from 0.
63
*/
64
typedef
enum
dt_sram_ctrl_alert
{
65
kDtSramCtrlAlertFatalError
= 0,
/**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected,
66
or if the initialization mechanism has reached an invalid state. */
67
kDtSramCtrlAlertCount = 1,
/**< \internal Number of Alerts */
68
}
dt_sram_ctrl_alert_t
;
69
70
/**
71
* List of clock ports.
72
*
73
* Clock ports are guaranteed to be numbered consecutively from 0.
74
*/
75
typedef
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 */
79
}
dt_sram_ctrl_clock_t
;
80
81
/**
82
* List of reset ports.
83
*
84
* Reset ports are guaranteed to be numbered consecutively from 0.
85
*/
86
typedef
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 */
90
}
dt_sram_ctrl_reset_t
;
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
*/
116
dt_sram_ctrl_t
dt_sram_ctrl_from_instance_id
(
dt_instance_id_t
inst_id);
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
*/
124
dt_instance_id_t
dt_sram_ctrl_instance_id
(
dt_sram_ctrl_t
dt);
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
*/
133
uint32_t
dt_sram_ctrl_reg_block
(
134
dt_sram_ctrl_t
dt,
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
*/
146
static
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
*/
158
uint32_t
dt_sram_ctrl_memory_base
(
159
dt_sram_ctrl_t
dt,
160
dt_sram_ctrl_memory_t
mem);
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
*/
169
uint32_t
dt_sram_ctrl_memory_size
(
170
dt_sram_ctrl_t
dt,
171
dt_sram_ctrl_memory_t
mem);
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
*/
184
dt_alert_id_t
dt_sram_ctrl_alert_to_alert_id
(
185
dt_sram_ctrl_t
dt,
186
dt_sram_ctrl_alert_t
alert);
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
*/
200
dt_sram_ctrl_alert_t
dt_sram_ctrl_alert_from_alert_id
(
201
dt_sram_ctrl_t
dt,
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
*/
213
dt_clock_t
dt_sram_ctrl_clock
(
214
dt_sram_ctrl_t
dt,
215
dt_sram_ctrl_clock_t
clk);
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
*/
224
dt_reset_t
dt_sram_ctrl_reset
(
225
dt_sram_ctrl_t
dt,
226
dt_sram_ctrl_reset_t
rst);
227
228
229
230
#ifdef __cplusplus
231
}
// extern "C"
232
#endif
// __cplusplus
233
234
#endif
// OPENTITAN_DT_SRAM_CTRL_H_
(earlgrey)
hw
top
dt
dt_sram_ctrl.h
Return to
OpenTitan Documentation