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
11extern "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 */
29typedef enum dt_flash_ctrl {
30 kDtFlashCtrlFirst = 0, /**< First instance */
31 kDtFlashCtrl = 0, /**< flash_ctrl */
33
34enum {
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 */
45 kDtFlashCtrlRegBlockCore = 0, /**< */
46 kDtFlashCtrlRegBlockPrim = 1, /**< */
48
49enum {
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). */
55static 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 */
63 kDtFlashCtrlMemoryMem = 0, /**< */
65
66enum {
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 */
76typedef 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 */
84
85enum {
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 */
95typedef enum dt_flash_ctrl_clock {
96 kDtFlashCtrlClockClk = 0, /**< Clock port clk_i */
97 kDtFlashCtrlClockOtp = 1, /**< Clock port clk_otp_i */
99
100enum {
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 */
111 kDtFlashCtrlResetRst = 0, /**< Reset port rst_ni */
112 kDtFlashCtrlResetOtp = 1, /**< Reset port rst_otp_ni */
114
115enum {
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 */
126 kDtFlashCtrlPeriphIoTck = 0, /**< */
127 kDtFlashCtrlPeriphIoTms = 1, /**< */
128 kDtFlashCtrlPeriphIoTdi = 2, /**< */
129 kDtFlashCtrlPeriphIoTdo = 3, /**< */
131
132enum {
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 */
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 */
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 */
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 */
195static 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 */
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 */
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 */
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 */
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 */
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 */
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 */
286
287
288
289#ifdef __cplusplus
290} // extern "C"
291#endif // __cplusplus
292
293#endif // OPENTITAN_DT_FLASH_CTRL_H_