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