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 earlgrey.
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 Alerts.
92 *
93 * Alerts are guaranteed to be numbered consecutively from 0.
94 */
95typedef enum dt_flash_ctrl_alert {
96 kDtFlashCtrlAlertRecovErr = 0, /**< flash recoverable errors */
97 kDtFlashCtrlAlertFatalStdErr = 1, /**< flash standard fatal errors */
98 kDtFlashCtrlAlertFatalErr = 2, /**< Flash fatal errors including uncorrectable ECC errors.
99
100 Note that this alert is not always fatal.
101 The underlying error bits in the !!FAULT_STATUS register remain set until reset, meaning the alert keeps firing.
102 This doesn't hold for !!FAULT_STATUS.PHY_RELBL_ERR and !!FAULT_STATUS.PHY_STORAGE_ERR.
103 To enable firmware dealing with multi-bit ECC and ICV errors during firmware selection and verification, these error bits can be cleared.
104 After passing this stage, it is recommended that firmware classifies the corresponding alert as fatal on the receiver end, i.e, inside the alert handler. */
105 kDtFlashCtrlAlertFatalPrimFlashAlert = 3, /**< Fatal alert triggered inside the flash primitive, including fatal TL-UL bus integrity faults of the test interface. */
106 kDtFlashCtrlAlertRecovPrimFlashAlert = 4, /**< Recoverable alert triggered inside the flash primitive. */
108
109enum {
110 kDtFlashCtrlAlertCount = 5, /**< Number of Alerts */
111};
112
113
114/**
115 * List of clock ports.
116 *
117 * Clock ports are guaranteed to be numbered consecutively from 0.
118 */
120 kDtFlashCtrlClockClk = 0, /**< Clock port clk_i */
121 kDtFlashCtrlClockOtp = 1, /**< Clock port clk_otp_i */
123
124enum {
125 kDtFlashCtrlClockCount = 2, /**< Number of clock ports */
126};
127
128
129/**
130 * List of reset ports.
131 *
132 * Reset ports are guaranteed to be numbered consecutively from 0.
133 */
135 kDtFlashCtrlResetRst = 0, /**< Reset port rst_ni */
136 kDtFlashCtrlResetOtp = 1, /**< Reset port rst_otp_ni */
138
139enum {
140 kDtFlashCtrlResetCount = 2, /**< Number of reset ports */
141};
142
143
144/**
145 * List of peripheral I/O.
146 *
147 * Peripheral I/O are guaranteed to be numbered consecutively from 0.
148 */
150 kDtFlashCtrlPeriphIoTck = 0, /**< */
151 kDtFlashCtrlPeriphIoTms = 1, /**< */
152 kDtFlashCtrlPeriphIoTdi = 2, /**< */
153 kDtFlashCtrlPeriphIoTdo = 3, /**< */
155
156enum {
157 kDtFlashCtrlPeriphIoCount = 4, /**< Number of peripheral I/O */
158};
159
160
161/**
162 * List of supported hardware features.
163 */
164#define OPENTITAN_FLASH_CTRL_HAS_ESCALATION 1
165#define OPENTITAN_FLASH_CTRL_HAS_FETCH_CODE 1
166#define OPENTITAN_FLASH_CTRL_HAS_INFO_CREATOR_PARTITION 1
167#define OPENTITAN_FLASH_CTRL_HAS_INFO_ISOLATED_PARTITION 1
168#define OPENTITAN_FLASH_CTRL_HAS_INFO_OWNER_PARTITION 1
169#define OPENTITAN_FLASH_CTRL_HAS_INIT_ROOT_SEEDS 1
170#define OPENTITAN_FLASH_CTRL_HAS_INIT_SCRAMBLING_KEYS 1
171#define OPENTITAN_FLASH_CTRL_HAS_MEM_PROTECTION 1
172#define OPENTITAN_FLASH_CTRL_HAS_OP_HOST_READ 1
173#define OPENTITAN_FLASH_CTRL_HAS_OP_PROTOCOL_CTRL 1
174#define OPENTITAN_FLASH_CTRL_HAS_RMA 1
175
176
177
178/**
179 * Get the flash_ctrl instance from an instance ID
180 *
181 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
182 *
183 * @param inst_id Instance ID.
184 * @return A flash_ctrl instance.
185 *
186 * **Note:** This function only makes sense if the instance ID has device type flash_ctrl,
187 * otherwise the returned value is unspecified.
188 */
190
191/**
192 * Get the instance ID of an instance.
193 *
194 * @param dt Instance of flash_ctrl.
195 * @return The instance ID of that instance.
196 */
198
199/**
200 * Get the register base address of an instance.
201 *
202 * @param dt Instance of flash_ctrl.
203 * @param reg_block The register block requested.
204 * @return The register base address of the requested block.
205 */
208 dt_flash_ctrl_reg_block_t reg_block);
209
210/**
211 * Get the primary register base address of an instance.
212 *
213 * This is just a convenience function, equivalent to
214 * `dt_flash_ctrl_reg_block(dt, kDtFlashCtrlRegBlockCore)`
215 *
216 * @param dt Instance of flash_ctrl.
217 * @return The register base address of the primary register block.
218 */
219static inline uint32_t dt_flash_ctrl_primary_reg_block(
220 dt_flash_ctrl_t dt) {
221 return dt_flash_ctrl_reg_block(dt, kDtFlashCtrlRegBlockCore);
222}
223
224/**
225 * Get the base address of a memory.
226 *
227 * @param dt Instance of flash_ctrl.
228 * @param mem The memory requested.
229 * @return The base address of the requested memory.
230 */
234
235/**
236 * Get the size of a memory.
237 *
238 * @param dt Instance of flash_ctrl.
239 * @param mem The memory requested.
240 * @return The size of the requested memory.
241 */
245
246/**
247 * Get the PLIC ID of a flash_ctrl IRQ for a given instance.
248 *
249 * If the instance is not connected to the PLIC, this function
250 * will return `kDtPlicIrqIdNone`.
251 *
252 * @param dt Instance of flash_ctrl.
253 * @param irq A flash_ctrl IRQ.
254 * @return The PLIC ID of the IRQ of this instance.
255 */
259
260/**
261 * Convert a global IRQ ID to a local flash_ctrl IRQ type.
262 *
263 * @param dt Instance of flash_ctrl.
264 * @param irq A PLIC ID that belongs to this instance.
265 * @return The flash_ctrl IRQ, or `kDtFlashCtrlIrqCount`.
266 *
267 * **Note:** This function assumes that the PLIC ID belongs to the instance
268 * of flash_ctrl passed in parameter. In other words, it must be the case that
269 * `dt_flash_ctrl_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
270 * will return `kDtFlashCtrlIrqCount`.
271 */
274 dt_plic_irq_id_t irq);
275
276
277/**
278 * Get the alert ID of a flash_ctrl alert for a given instance.
279 *
280 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
281 * instances where the instance is not connected, the return value is unspecified.
282 *
283 * @param dt Instance of flash_ctrl.
284 * @param alert A flash_ctrl alert.
285 * @return The Alert Handler alert ID of the alert of this instance.
286 */
290
291/**
292 * Convert a global alert ID to a local flash_ctrl alert type.
293 *
294 * @param dt Instance of flash_ctrl.
295 * @param alert A global alert ID that belongs to this instance.
296 * @return The flash_ctrl alert, or `kDtFlashCtrlAlertCount`.
297 *
298 * **Note:** This function assumes that the global alert ID belongs to the
299 * instance of flash_ctrl passed in parameter. In other words, it must be the case
300 * that `dt_flash_ctrl_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
301 * this function will return `kDtFlashCtrlAlertCount`.
302 */
305 dt_alert_id_t alert);
306
307
308/**
309 * Get the peripheral I/O description of an instance.
310 *
311 * @param dt Instance of flash_ctrl.
312 * @param sig Requested peripheral I/O.
313 * @return Description of the requested peripheral I/O for this instance.
314 */
318
319/**
320 * Get the clock signal connected to a clock port of an instance.
321 *
322 * @param dt Instance of flash_ctrl.
323 * @param clk Clock port.
324 * @return Clock signal.
325 */
329
330/**
331 * Get the reset signal connected to a reset port of an instance.
332 *
333 * @param dt Instance of flash_ctrl.
334 * @param rst Reset port.
335 * @return Reset signal.
336 */
340
341
342
343#ifdef __cplusplus
344} // extern "C"
345#endif // __cplusplus
346
347#endif // OPENTITAN_DT_FLASH_CTRL_H_