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/**
11 * @file
12 * @brief Device Tables (DT) for IP flash_ctrl and top earlgrey.
13 *
14 * This file contains the type definitions and global functions of the flash_ctrl.
15 */
16
17#include "dt_api.h"
18#include <stdint.h>
19
20
21
22/**
23 * List of instances.
24 */
25typedef enum dt_flash_ctrl {
26 kDtFlashCtrl = 0, /**< flash_ctrl */
27 kDtFlashCtrlFirst = 0, /**< \internal First instance */
28 kDtFlashCtrlCount = 1, /**< \internal Number of instances */
30
31/**
32 * List of register blocks.
33 *
34 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
35 */
37 kDtFlashCtrlRegBlockCore = 0, /**< */
38 kDtFlashCtrlRegBlockPrim = 1, /**< */
39 kDtFlashCtrlRegBlockMem = 2, /**< */
40 kDtFlashCtrlRegBlockCount = 3, /**< \internal Number of register blocks */
42
43/** Primary register block (associated with the "primary" set of registers that control the IP). */
44static const dt_flash_ctrl_reg_block_t kDtFlashCtrlRegBlockPrimary = kDtFlashCtrlRegBlockCore;
45
46/**
47 * List of IRQs.
48 *
49 * IRQs are guaranteed to be numbered consecutively from 0.
50 */
51typedef enum dt_flash_ctrl_irq {
52 kDtFlashCtrlIrqProgEmpty = 0, /**< Program FIFO empty */
53 kDtFlashCtrlIrqProgLvl = 1, /**< Program FIFO drained to level */
54 kDtFlashCtrlIrqRdFull = 2, /**< Read FIFO full */
55 kDtFlashCtrlIrqRdLvl = 3, /**< Read FIFO filled to level */
56 kDtFlashCtrlIrqOpDone = 4, /**< Operation complete */
57 kDtFlashCtrlIrqCorrErr = 5, /**< Correctable error encountered */
58 kDtFlashCtrlIrqCount = 6, /**< \internal Number of IRQs */
60
61/**
62 * List of Alerts.
63 *
64 * Alerts are guaranteed to be numbered consecutively from 0.
65 */
66typedef enum dt_flash_ctrl_alert {
67 kDtFlashCtrlAlertRecovErr = 0, /**< flash recoverable errors */
68 kDtFlashCtrlAlertFatalStdErr = 1, /**< flash standard fatal errors */
69 kDtFlashCtrlAlertFatalErr = 2, /**< Flash fatal errors including uncorrectable ECC errors.
70
71Note that this alert is not always fatal.
72The underlying error bits in the !!FAULT_STATUS register remain set until reset, meaning the alert keeps firing.
73This doesn't hold for !!FAULT_STATUS.PHY_RELBL_ERR and !!FAULT_STATUS.PHY_STORAGE_ERR.
74To enable firmware dealing with multi-bit ECC and ICV errors during firmware selection and verification, these error bits can be cleared.
75After passing this stage, it is recommended that firmware classifies the corresponding alert as fatal on the receiver end, i.e, inside the alert handler. */
76 kDtFlashCtrlAlertFatalPrimFlashAlert = 3, /**< Fatal alert triggered inside the flash primitive, including fatal TL-UL bus integrity faults of the test interface. */
77 kDtFlashCtrlAlertRecovPrimFlashAlert = 4, /**< Recoverable alert triggered inside the flash primitive. */
78 kDtFlashCtrlAlertCount = 5, /**< \internal Number of Alerts */
80
81/**
82 * List of clock ports.
83 *
84 * Clock ports are guaranteed to be numbered consecutively from 0.
85 */
86typedef enum dt_flash_ctrl_clock {
87 kDtFlashCtrlClockClk = 0, /**< Clock port clk_i */
88 kDtFlashCtrlClockOtp = 1, /**< Clock port clk_otp_i */
89 kDtFlashCtrlClockCount = 2, /**< \internal Number of clock ports */
91
92/**
93 * List of reset ports.
94 *
95 * Reset ports are guaranteed to be numbered consecutively from 0.
96 */
97typedef enum dt_flash_ctrl_reset {
98 kDtFlashCtrlResetRst = 0, /**< Reset port rst_ni */
99 kDtFlashCtrlResetOtp = 1, /**< Reset port rst_otp_ni */
100 kDtFlashCtrlResetCount = 2, /**< \internal Number of reset ports */
102
103/**
104 * List of peripheral I/O.
105 *
106 * Peripheral I/O are guaranteed to be numbered consecutively from 0.
107 */
109 kDtFlashCtrlPeriphIoTck = 0, /**< */
110 kDtFlashCtrlPeriphIoTms = 1, /**< */
111 kDtFlashCtrlPeriphIoTdi = 2, /**< */
112 kDtFlashCtrlPeriphIoTdo = 3, /**< */
113 kDtFlashCtrlPeriphIoCount = 4, /**< \internal Number of peripheral I/O */
115
116/**
117 * List of supported hardware features.
118 */
119#define OPENTITAN_FLASH_CTRL_HAS_ESCALATION 1
120#define OPENTITAN_FLASH_CTRL_HAS_FETCH_CODE 1
121#define OPENTITAN_FLASH_CTRL_HAS_INFO_CREATOR_PARTITION 1
122#define OPENTITAN_FLASH_CTRL_HAS_INFO_ISOLATED_PARTITION 1
123#define OPENTITAN_FLASH_CTRL_HAS_INFO_OWNER_PARTITION 1
124#define OPENTITAN_FLASH_CTRL_HAS_INIT_ROOT_SEEDS 1
125#define OPENTITAN_FLASH_CTRL_HAS_INIT_SCRAMBLING_KEYS 1
126#define OPENTITAN_FLASH_CTRL_HAS_MEM_PROTECTION 1
127#define OPENTITAN_FLASH_CTRL_HAS_OP_HOST_READ 1
128#define OPENTITAN_FLASH_CTRL_HAS_OP_PROTOCOL_CTRL 1
129#define OPENTITAN_FLASH_CTRL_HAS_RMA 1
130
131
132
133/**
134 * Get the flash_ctrl instance from an instance ID
135 *
136 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
137 *
138 * @param inst_id Instance ID.
139 * @return A flash_ctrl instance.
140 *
141 * **Note:** This function only makes sense if the instance ID has device type flash_ctrl,
142 * otherwise the returned value is unspecified.
143 */
145
146/**
147 * Get the instance ID of an instance.
148 *
149 * @param dt Instance of flash_ctrl.
150 * @return The instance ID of that instance.
151 */
153
154/**
155 * Get the register base address of an instance.
156 *
157 * @param dt Instance of flash_ctrl.
158 * @param reg_block The register block requested.
159 * @return The register base address of the requested block.
160 */
163 dt_flash_ctrl_reg_block_t reg_block);
164
165/**
166 * Get the primary register base address of an instance.
167 *
168 * This is just a convenience function, equivalent to
169 * `dt_flash_ctrl_reg_block(dt, kDtFlashCtrlRegBlockCore)`
170 *
171 * @param dt Instance of flash_ctrl.
172 * @return The register base address of the primary register block.
173 */
174static inline uint32_t dt_flash_ctrl_primary_reg_block(
175 dt_flash_ctrl_t dt) {
176 return dt_flash_ctrl_reg_block(dt, kDtFlashCtrlRegBlockCore);
177}
178
179/**
180 * Get the PLIC ID of a flash_ctrl IRQ for a given instance.
181 *
182 * If the instance is not connected to the PLIC, this function
183 * will return `kDtPlicIrqIdNone`.
184 *
185 * @param dt Instance of flash_ctrl.
186 * @param irq A flash_ctrl IRQ.
187 * @return The PLIC ID of the IRQ of this instance.
188 */
192
193/**
194 * Convert a global IRQ ID to a local flash_ctrl IRQ type.
195 *
196 * @param dt Instance of flash_ctrl.
197 * @param irq A PLIC ID that belongs to this instance.
198 * @return The flash_ctrl IRQ, or `kDtFlashCtrlIrqCount`.
199 *
200 * **Note:** This function assumes that the PLIC ID belongs to the instance
201 * of flash_ctrl passed in parameter. In other words, it must be the case that
202 * `dt_flash_ctrl_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
203 * will return `kDtFlashCtrlIrqCount`.
204 */
207 dt_plic_irq_id_t irq);
208
209
210/**
211 * Get the alert ID of a flash_ctrl alert for a given instance.
212 *
213 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
214 * instances where the instance is not connected, the return value is unspecified.
215 *
216 * @param dt Instance of flash_ctrl.
217 * @param alert A flash_ctrl alert.
218 * @return The Alert Handler alert ID of the alert of this instance.
219 */
223
224/**
225 * Convert a global alert ID to a local flash_ctrl alert type.
226 *
227 * @param dt Instance of flash_ctrl.
228 * @param alert A global alert ID that belongs to this instance.
229 * @return The flash_ctrl alert, or `kDtFlashCtrlAlertCount`.
230 *
231 * **Note:** This function assumes that the global alert ID belongs to the
232 * instance of flash_ctrl passed in parameter. In other words, it must be the case
233 * that `dt_flash_ctrl_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
234 * this function will return `kDtFlashCtrlAlertCount`.
235 */
238 dt_alert_id_t alert);
239
240
241/**
242 * Get the peripheral I/O description of an instance.
243 *
244 * @param dt Instance of flash_ctrl.
245 * @param sig Requested peripheral I/O.
246 * @return Description of the requested peripheral I/O for this instance.
247 */
251
252/**
253 * Get the clock signal connected to a clock port of an instance.
254 *
255 * @param dt Instance of flash_ctrl.
256 * @param clk Clock port.
257 * @return Clock signal.
258 */
262
263/**
264 * Get the reset signal connected to a reset port of an instance.
265 *
266 * @param dt Instance of flash_ctrl.
267 * @param rst Reset port.
268 * @return Reset signal.
269 */
273
274
275
276#endif // OPENTITAN_DT_FLASH_CTRL_H_