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