Software APIs
flash_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_FLASH_CTRL_H_
8
#define OPENTITAN_DT_FLASH_CTRL_H_
9
10
#ifdef __cplusplus
11
extern
"C"
{
12
#endif
// __cplusplus
13
14
/**
15
* @file
16
* @brief Device Tables (DT) for IP flash_ctrl and top englishbreakfast.
17
*
18
* This file contains the type definitions and global functions of the flash_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_flash_ctrl
{
30
kDtFlashCtrlFirst
= 0,
/**< First instance */
31
kDtFlashCtrl
= 0,
/**< flash_ctrl */
32
}
dt_flash_ctrl_t
;
33
34
enum
{
35
kDtFlashCtrlCount
= 1,
/**< Number of instances */
36
};
37
38
39
/**
40
* List of register blocks.
41
*
42
* Register blocks are guaranteed to start at 0 and to be consecutively numbered.
43
*/
44
typedef
enum
dt_flash_ctrl_reg_block
{
45
kDtFlashCtrlRegBlockCore = 0,
/**< */
46
kDtFlashCtrlRegBlockPrim = 1,
/**< */
47
}
dt_flash_ctrl_reg_block_t
;
48
49
enum
{
50
kDtFlashCtrlRegBlockCount
= 2,
/**< 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_flash_ctrl_reg_block_t
kDtFlashCtrlRegBlockPrimary = kDtFlashCtrlRegBlockCore;
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_flash_ctrl_memory
{
63
kDtFlashCtrlMemoryMem = 0,
/**< */
64
}
dt_flash_ctrl_memory_t
;
65
66
enum
{
67
kDtFlashCtrlMemoryCount
= 1,
/**< Number of memories */
68
};
69
70
71
/**
72
* List of IRQs.
73
*
74
* IRQs are guaranteed to be numbered consecutively from 0.
75
*/
76
typedef
enum
dt_flash_ctrl_irq
{
77
kDtFlashCtrlIrqProgEmpty
= 0,
/**< Program FIFO empty */
78
kDtFlashCtrlIrqProgLvl
= 1,
/**< Program FIFO drained to level */
79
kDtFlashCtrlIrqRdFull
= 2,
/**< Read FIFO full */
80
kDtFlashCtrlIrqRdLvl
= 3,
/**< Read FIFO filled to level */
81
kDtFlashCtrlIrqOpDone
= 4,
/**< Operation complete */
82
kDtFlashCtrlIrqCorrErr
= 5,
/**< Correctable error encountered */
83
}
dt_flash_ctrl_irq_t
;
84
85
enum
{
86
kDtFlashCtrlIrqCount
= 6,
/**< Number of IRQs */
87
};
88
89
90
/**
91
* List of clock ports.
92
*
93
* Clock ports are guaranteed to be numbered consecutively from 0.
94
*/
95
typedef
enum
dt_flash_ctrl_clock
{
96
kDtFlashCtrlClockClk
= 0,
/**< Clock port clk_i */
97
kDtFlashCtrlClockOtp
= 1,
/**< Clock port clk_otp_i */
98
}
dt_flash_ctrl_clock_t
;
99
100
enum
{
101
kDtFlashCtrlClockCount
= 2,
/**< Number of clock ports */
102
};
103
104
105
/**
106
* List of reset ports.
107
*
108
* Reset ports are guaranteed to be numbered consecutively from 0.
109
*/
110
typedef
enum
dt_flash_ctrl_reset
{
111
kDtFlashCtrlResetRst
= 0,
/**< Reset port rst_ni */
112
kDtFlashCtrlResetOtp
= 1,
/**< Reset port rst_otp_ni */
113
}
dt_flash_ctrl_reset_t
;
114
115
enum
{
116
kDtFlashCtrlResetCount
= 2,
/**< Number of reset ports */
117
};
118
119
120
/**
121
* List of peripheral I/O.
122
*
123
* Peripheral I/O are guaranteed to be numbered consecutively from 0.
124
*/
125
typedef
enum
dt_flash_ctrl_periph_io
{
126
kDtFlashCtrlPeriphIoTck = 0,
/**< */
127
kDtFlashCtrlPeriphIoTms = 1,
/**< */
128
kDtFlashCtrlPeriphIoTdi = 2,
/**< */
129
kDtFlashCtrlPeriphIoTdo = 3,
/**< */
130
}
dt_flash_ctrl_periph_io_t
;
131
132
enum
{
133
kDtFlashCtrlPeriphIoCount
= 4,
/**< Number of peripheral I/O */
134
};
135
136
137
/**
138
* List of supported hardware features.
139
*/
140
#define OPENTITAN_FLASH_CTRL_HAS_ESCALATION 1
141
#define OPENTITAN_FLASH_CTRL_HAS_FETCH_CODE 1
142
#define OPENTITAN_FLASH_CTRL_HAS_INFO_CREATOR_PARTITION 1
143
#define OPENTITAN_FLASH_CTRL_HAS_INFO_ISOLATED_PARTITION 1
144
#define OPENTITAN_FLASH_CTRL_HAS_INFO_OWNER_PARTITION 1
145
#define OPENTITAN_FLASH_CTRL_HAS_INIT_ROOT_SEEDS 1
146
#define OPENTITAN_FLASH_CTRL_HAS_INIT_SCRAMBLING_KEYS 1
147
#define OPENTITAN_FLASH_CTRL_HAS_MEM_PROTECTION 1
148
#define OPENTITAN_FLASH_CTRL_HAS_OP_HOST_READ 1
149
#define OPENTITAN_FLASH_CTRL_HAS_OP_PROTOCOL_CTRL 1
150
#define OPENTITAN_FLASH_CTRL_HAS_RMA 1
151
152
153
154
/**
155
* Get the flash_ctrl instance from an instance ID
156
*
157
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
158
*
159
* @param inst_id Instance ID.
160
* @return A flash_ctrl instance.
161
*
162
* **Note:** This function only makes sense if the instance ID has device type flash_ctrl,
163
* otherwise the returned value is unspecified.
164
*/
165
dt_flash_ctrl_t
dt_flash_ctrl_from_instance_id
(
dt_instance_id_t
inst_id);
166
167
/**
168
* Get the instance ID of an instance.
169
*
170
* @param dt Instance of flash_ctrl.
171
* @return The instance ID of that instance.
172
*/
173
dt_instance_id_t
dt_flash_ctrl_instance_id
(
dt_flash_ctrl_t
dt);
174
175
/**
176
* Get the register base address of an instance.
177
*
178
* @param dt Instance of flash_ctrl.
179
* @param reg_block The register block requested.
180
* @return The register base address of the requested block.
181
*/
182
uint32_t
dt_flash_ctrl_reg_block
(
183
dt_flash_ctrl_t
dt,
184
dt_flash_ctrl_reg_block_t
reg_block);
185
186
/**
187
* Get the primary register base address of an instance.
188
*
189
* This is just a convenience function, equivalent to
190
* `dt_flash_ctrl_reg_block(dt, kDtFlashCtrlRegBlockCore)`
191
*
192
* @param dt Instance of flash_ctrl.
193
* @return The register base address of the primary register block.
194
*/
195
static
inline
uint32_t dt_flash_ctrl_primary_reg_block(
196
dt_flash_ctrl_t
dt) {
197
return
dt_flash_ctrl_reg_block
(dt, kDtFlashCtrlRegBlockCore);
198
}
199
200
/**
201
* Get the base address of a memory.
202
*
203
* @param dt Instance of flash_ctrl.
204
* @param mem The memory requested.
205
* @return The base address of the requested memory.
206
*/
207
uint32_t
dt_flash_ctrl_memory_base
(
208
dt_flash_ctrl_t
dt,
209
dt_flash_ctrl_memory_t
mem);
210
211
/**
212
* Get the size of a memory.
213
*
214
* @param dt Instance of flash_ctrl.
215
* @param mem The memory requested.
216
* @return The size of the requested memory.
217
*/
218
uint32_t
dt_flash_ctrl_memory_size
(
219
dt_flash_ctrl_t
dt,
220
dt_flash_ctrl_memory_t
mem);
221
222
/**
223
* Get the PLIC ID of a flash_ctrl IRQ for a given instance.
224
*
225
* If the instance is not connected to the PLIC, this function
226
* will return `kDtPlicIrqIdNone`.
227
*
228
* @param dt Instance of flash_ctrl.
229
* @param irq A flash_ctrl IRQ.
230
* @return The PLIC ID of the IRQ of this instance.
231
*/
232
dt_plic_irq_id_t
dt_flash_ctrl_irq_to_plic_id
(
233
dt_flash_ctrl_t
dt,
234
dt_flash_ctrl_irq_t
irq);
235
236
/**
237
* Convert a global IRQ ID to a local flash_ctrl IRQ type.
238
*
239
* @param dt Instance of flash_ctrl.
240
* @param irq A PLIC ID that belongs to this instance.
241
* @return The flash_ctrl IRQ, or `kDtFlashCtrlIrqCount`.
242
*
243
* **Note:** This function assumes that the PLIC ID belongs to the instance
244
* of flash_ctrl passed in parameter. In other words, it must be the case that
245
* `dt_flash_ctrl_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
246
* will return `kDtFlashCtrlIrqCount`.
247
*/
248
dt_flash_ctrl_irq_t
dt_flash_ctrl_irq_from_plic_id
(
249
dt_flash_ctrl_t
dt,
250
dt_plic_irq_id_t
irq);
251
252
253
254
/**
255
* Get the peripheral I/O description of an instance.
256
*
257
* @param dt Instance of flash_ctrl.
258
* @param sig Requested peripheral I/O.
259
* @return Description of the requested peripheral I/O for this instance.
260
*/
261
dt_periph_io_t
dt_flash_ctrl_periph_io
(
262
dt_flash_ctrl_t
dt,
263
dt_flash_ctrl_periph_io_t
sig);
264
265
/**
266
* Get the clock signal connected to a clock port of an instance.
267
*
268
* @param dt Instance of flash_ctrl.
269
* @param clk Clock port.
270
* @return Clock signal.
271
*/
272
dt_clock_t
dt_flash_ctrl_clock
(
273
dt_flash_ctrl_t
dt,
274
dt_flash_ctrl_clock_t
clk);
275
276
/**
277
* Get the reset signal connected to a reset port of an instance.
278
*
279
* @param dt Instance of flash_ctrl.
280
* @param rst Reset port.
281
* @return Reset signal.
282
*/
283
dt_reset_t
dt_flash_ctrl_reset
(
284
dt_flash_ctrl_t
dt,
285
dt_flash_ctrl_reset_t
rst);
286
287
288
289
#ifdef __cplusplus
290
}
// extern "C"
291
#endif
// __cplusplus
292
293
#endif
// OPENTITAN_DT_FLASH_CTRL_H_
(englishbreakfast)
hw
top
dt
flash_ctrl.h
Return to
OpenTitan Documentation