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