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
11extern "C" {
12#endif // __cplusplus
13
14/**
15 * @file
16 * @brief Device Tables (DT) for IP flash_ctrl and top earlgrey.
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 */
29typedef enum dt_flash_ctrl {
30 kDtFlashCtrl = 0, /**< flash_ctrl */
31 kDtFlashCtrlFirst = 0, /**< \internal First instance */
32 kDtFlashCtrlCount = 1, /**< \internal Number of instances */
34
35/**
36 * List of register blocks.
37 *
38 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
39 */
41 kDtFlashCtrlRegBlockCore = 0, /**< */
42 kDtFlashCtrlRegBlockPrim = 1, /**< */
43 kDtFlashCtrlRegBlockCount = 2, /**< \internal Number of register blocks */
45
46/** Primary register block (associated with the "primary" set of registers that control the IP). */
47static 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 */
55 kDtFlashCtrlMemoryMem = 0, /**< */
56 kDtFlashCtrlMemoryCount = 1, /**< \internal Number of memories */
58
59/**
60 * List of IRQs.
61 *
62 * IRQs are guaranteed to be numbered consecutively from 0.
63 */
64typedef 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 */
73
74/**
75 * List of Alerts.
76 *
77 * Alerts are guaranteed to be numbered consecutively from 0.
78 */
79typedef enum dt_flash_ctrl_alert {
80 kDtFlashCtrlAlertRecovErr = 0, /**< flash recoverable errors */
81 kDtFlashCtrlAlertFatalStdErr = 1, /**< flash standard fatal errors */
82 kDtFlashCtrlAlertFatalErr = 2, /**< Flash fatal errors including uncorrectable ECC errors.
83
84Note that this alert is not always fatal.
85The underlying error bits in the !!FAULT_STATUS register remain set until reset, meaning the alert keeps firing.
86This doesn't hold for !!FAULT_STATUS.PHY_RELBL_ERR and !!FAULT_STATUS.PHY_STORAGE_ERR.
87To enable firmware dealing with multi-bit ECC and ICV errors during firmware selection and verification, these error bits can be cleared.
88After passing this stage, it is recommended that firmware classifies the corresponding alert as fatal on the receiver end, i.e, inside the alert handler. */
89 kDtFlashCtrlAlertFatalPrimFlashAlert = 3, /**< Fatal alert triggered inside the flash primitive, including fatal TL-UL bus integrity faults of the test interface. */
90 kDtFlashCtrlAlertRecovPrimFlashAlert = 4, /**< Recoverable alert triggered inside the flash primitive. */
91 kDtFlashCtrlAlertCount = 5, /**< \internal Number of Alerts */
93
94/**
95 * List of clock ports.
96 *
97 * Clock ports are guaranteed to be numbered consecutively from 0.
98 */
99typedef enum dt_flash_ctrl_clock {
100 kDtFlashCtrlClockClk = 0, /**< Clock port clk_i */
101 kDtFlashCtrlClockOtp = 1, /**< Clock port clk_otp_i */
102 kDtFlashCtrlClockCount = 2, /**< \internal Number of clock ports */
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 */
113 kDtFlashCtrlResetCount = 2, /**< \internal Number of reset ports */
115
116/**
117 * List of peripheral I/O.
118 *
119 * Peripheral I/O are guaranteed to be numbered consecutively from 0.
120 */
122 kDtFlashCtrlPeriphIoTck = 0, /**< */
123 kDtFlashCtrlPeriphIoTms = 1, /**< */
124 kDtFlashCtrlPeriphIoTdi = 2, /**< */
125 kDtFlashCtrlPeriphIoTdo = 3, /**< */
126 kDtFlashCtrlPeriphIoCount = 4, /**< \internal Number of peripheral I/O */
128
129/**
130 * List of supported hardware features.
131 */
132#define OPENTITAN_FLASH_CTRL_HAS_ESCALATION 1
133#define OPENTITAN_FLASH_CTRL_HAS_FETCH_CODE 1
134#define OPENTITAN_FLASH_CTRL_HAS_INFO_CREATOR_PARTITION 1
135#define OPENTITAN_FLASH_CTRL_HAS_INFO_ISOLATED_PARTITION 1
136#define OPENTITAN_FLASH_CTRL_HAS_INFO_OWNER_PARTITION 1
137#define OPENTITAN_FLASH_CTRL_HAS_INIT_ROOT_SEEDS 1
138#define OPENTITAN_FLASH_CTRL_HAS_INIT_SCRAMBLING_KEYS 1
139#define OPENTITAN_FLASH_CTRL_HAS_MEM_PROTECTION 1
140#define OPENTITAN_FLASH_CTRL_HAS_OP_HOST_READ 1
141#define OPENTITAN_FLASH_CTRL_HAS_OP_PROTOCOL_CTRL 1
142#define OPENTITAN_FLASH_CTRL_HAS_RMA 1
143
144
145
146/**
147 * Get the flash_ctrl instance from an instance ID
148 *
149 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
150 *
151 * @param inst_id Instance ID.
152 * @return A flash_ctrl instance.
153 *
154 * **Note:** This function only makes sense if the instance ID has device type flash_ctrl,
155 * otherwise the returned value is unspecified.
156 */
158
159/**
160 * Get the instance ID of an instance.
161 *
162 * @param dt Instance of flash_ctrl.
163 * @return The instance ID of that instance.
164 */
166
167/**
168 * Get the register base address of an instance.
169 *
170 * @param dt Instance of flash_ctrl.
171 * @param reg_block The register block requested.
172 * @return The register base address of the requested block.
173 */
176 dt_flash_ctrl_reg_block_t reg_block);
177
178/**
179 * Get the primary register base address of an instance.
180 *
181 * This is just a convenience function, equivalent to
182 * `dt_flash_ctrl_reg_block(dt, kDtFlashCtrlRegBlockCore)`
183 *
184 * @param dt Instance of flash_ctrl.
185 * @return The register base address of the primary register block.
186 */
187static inline uint32_t dt_flash_ctrl_primary_reg_block(
188 dt_flash_ctrl_t dt) {
189 return dt_flash_ctrl_reg_block(dt, kDtFlashCtrlRegBlockCore);
190}
191
192/**
193 * Get the base address of a memory.
194 *
195 * @param dt Instance of flash_ctrl.
196 * @param mem The memory requested.
197 * @return The base address of the requested memory.
198 */
202
203/**
204 * Get the size of a memory.
205 *
206 * @param dt Instance of flash_ctrl.
207 * @param mem The memory requested.
208 * @return The size of the requested memory.
209 */
213
214/**
215 * Get the PLIC ID of a flash_ctrl IRQ for a given instance.
216 *
217 * If the instance is not connected to the PLIC, this function
218 * will return `kDtPlicIrqIdNone`.
219 *
220 * @param dt Instance of flash_ctrl.
221 * @param irq A flash_ctrl IRQ.
222 * @return The PLIC ID of the IRQ of this instance.
223 */
227
228/**
229 * Convert a global IRQ ID to a local flash_ctrl IRQ type.
230 *
231 * @param dt Instance of flash_ctrl.
232 * @param irq A PLIC ID that belongs to this instance.
233 * @return The flash_ctrl IRQ, or `kDtFlashCtrlIrqCount`.
234 *
235 * **Note:** This function assumes that the PLIC ID belongs to the instance
236 * of flash_ctrl passed in parameter. In other words, it must be the case that
237 * `dt_flash_ctrl_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
238 * will return `kDtFlashCtrlIrqCount`.
239 */
242 dt_plic_irq_id_t irq);
243
244
245/**
246 * Get the alert ID of a flash_ctrl alert for a given instance.
247 *
248 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
249 * instances where the instance is not connected, the return value is unspecified.
250 *
251 * @param dt Instance of flash_ctrl.
252 * @param alert A flash_ctrl alert.
253 * @return The Alert Handler alert ID of the alert of this instance.
254 */
258
259/**
260 * Convert a global alert ID to a local flash_ctrl alert type.
261 *
262 * @param dt Instance of flash_ctrl.
263 * @param alert A global alert ID that belongs to this instance.
264 * @return The flash_ctrl alert, or `kDtFlashCtrlAlertCount`.
265 *
266 * **Note:** This function assumes that the global alert ID belongs to the
267 * instance of flash_ctrl passed in parameter. In other words, it must be the case
268 * that `dt_flash_ctrl_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
269 * this function will return `kDtFlashCtrlAlertCount`.
270 */
273 dt_alert_id_t alert);
274
275
276/**
277 * Get the peripheral I/O description of an instance.
278 *
279 * @param dt Instance of flash_ctrl.
280 * @param sig Requested peripheral I/O.
281 * @return Description of the requested peripheral I/O for this instance.
282 */
286
287/**
288 * Get the clock signal connected to a clock port of an instance.
289 *
290 * @param dt Instance of flash_ctrl.
291 * @param clk Clock port.
292 * @return Clock signal.
293 */
297
298/**
299 * Get the reset signal connected to a reset port of an instance.
300 *
301 * @param dt Instance of flash_ctrl.
302 * @param rst Reset port.
303 * @return Reset signal.
304 */
308
309
310
311#ifdef __cplusplus
312} // extern "C"
313#endif // __cplusplus
314
315#endif // OPENTITAN_DT_FLASH_CTRL_H_