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