Software APIs
dt_otp_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_OTP_CTRL_H_
8#define OPENTITAN_DT_OTP_CTRL_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif // __cplusplus
13
14/**
15 * @file
16 * @brief Device Tables (DT) for IP otp_ctrl and top earlgrey.
17 *
18 * This file contains the type definitions and global functions of the otp_ctrl.
19 */
20
21#include "hw/top/dt/dt_api.h"
22#include <stdint.h>
23
24
25
26
27
28/**
29 * List of instances.
30 */
31typedef enum dt_otp_ctrl {
32 kDtOtpCtrl = 0, /**< otp_ctrl */
33 kDtOtpCtrlFirst = 0, /**< \internal First instance */
34 kDtOtpCtrlCount = 1, /**< \internal Number of instances */
36
37/**
38 * List of register blocks.
39 *
40 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
41 */
43 kDtOtpCtrlRegBlockCore = 0, /**< */
44 kDtOtpCtrlRegBlockCount = 1, /**< \internal Number of register blocks */
46
47/** Primary register block (associated with the "primary" set of registers that control the IP). */
48static const dt_otp_ctrl_reg_block_t kDtOtpCtrlRegBlockPrimary = kDtOtpCtrlRegBlockCore;
49
50/**
51 * List of memories.
52 *
53 * Memories are guaranteed to start at 0 and to be consecutively numbered.
54 */
55typedef enum dt_otp_ctrl_memory {
56 kDtOtpCtrlMemoryCount = 0, /**< \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_otp_ctrl_irq {
65 kDtOtpCtrlIrqOtpOperationDone = 0, /**< A direct access command or digest calculation operation has completed. */
66 kDtOtpCtrlIrqOtpError = 1, /**< An error has occurred in the OTP controller. Check the !!ERR_CODE register to get more information. */
67 kDtOtpCtrlIrqCount = 2, /**< \internal Number of IRQs */
69
70/**
71 * List of Alerts.
72 *
73 * Alerts are guaranteed to be numbered consecutively from 0.
74 */
75typedef enum dt_otp_ctrl_alert {
76 kDtOtpCtrlAlertFatalMacroError = 0, /**< This alert triggers if hardware detects an uncorrectable error during an OTP transaction, for example an uncorrectable ECC error in the OTP array. */
77 kDtOtpCtrlAlertFatalCheckError = 1, /**< This alert triggers if any of the background checks fails. This includes the digest checks and concurrent ECC checks in the buffer registers. */
78 kDtOtpCtrlAlertFatalBusIntegError = 2, /**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
79 kDtOtpCtrlAlertFatalPrimOtpAlert = 3, /**< Fatal alert triggered inside the OTP primitive, including fatal TL-UL bus integrity faults of the test interface. */
80 kDtOtpCtrlAlertRecovPrimOtpAlert = 4, /**< Recoverable alert triggered inside the OTP primitive. */
81 kDtOtpCtrlAlertCount = 5, /**< \internal Number of Alerts */
83
84/**
85 * List of clock ports.
86 *
87 * Clock ports are guaranteed to be numbered consecutively from 0.
88 */
89typedef enum dt_otp_ctrl_clock {
90 kDtOtpCtrlClockClk = 0, /**< Clock port clk_i */
91 kDtOtpCtrlClockEdn = 1, /**< Clock port clk_edn_i */
92 kDtOtpCtrlClockCount = 2, /**< \internal Number of clock ports */
94
95/**
96 * List of reset ports.
97 *
98 * Reset ports are guaranteed to be numbered consecutively from 0.
99 */
100typedef enum dt_otp_ctrl_reset {
101 kDtOtpCtrlResetRst = 0, /**< Reset port rst_ni */
102 kDtOtpCtrlResetEdn = 1, /**< Reset port rst_edn_ni */
103 kDtOtpCtrlResetCount = 2, /**< \internal Number of reset ports */
105
106/**
107 * List of supported hardware features.
108 */
109#define OPENTITAN_OTP_CTRL_HAS_PARTITION_VENDOR_TEST 1
110#define OPENTITAN_OTP_CTRL_HAS_PARTITION_CREATOR_SW_CFG 1
111#define OPENTITAN_OTP_CTRL_HAS_PARTITION_OWNER_SW_CFG 1
112#define OPENTITAN_OTP_CTRL_HAS_INIT 1
113#define OPENTITAN_OTP_CTRL_HAS_ENTROPY_READ 1
114#define OPENTITAN_OTP_CTRL_HAS_KEY_DERIVATION 1
115#define OPENTITAN_OTP_CTRL_HAS_PROGRAM 1
116#define OPENTITAN_OTP_CTRL_HAS_PARTITION_SECRET0 1
117#define OPENTITAN_OTP_CTRL_HAS_PARTITION_SECRET1 1
118#define OPENTITAN_OTP_CTRL_HAS_PARTITION_SECRET2 1
119#define OPENTITAN_OTP_CTRL_HAS_PARTITION_LIFE_CYCLE 1
120#define OPENTITAN_OTP_CTRL_HAS_PARTITIONS_FEATURE_READ_LOCK 1
121#define OPENTITAN_OTP_CTRL_HAS_PARTITIONS_FEATURE_WRITE_LOCK 1
122#define OPENTITAN_OTP_CTRL_HAS_ERROR_HANDLING_RECOVERABLE 1
123#define OPENTITAN_OTP_CTRL_HAS_ERROR_HANDLING_FATAL 1
124#define OPENTITAN_OTP_CTRL_HAS_BACKGROUND_CHECK_CHECK_TIMEOUT 1
125#define OPENTITAN_OTP_CTRL_HAS_BACKGROUND_CHECK_INTEGRITY_CHECK_PERIOD 1
126#define OPENTITAN_OTP_CTRL_HAS_BACKGROUND_CHECK_CONSISTENCY_CHECK_PERIOD 1
127
128
129
130/**
131 * Get the otp_ctrl instance from an instance ID
132 *
133 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
134 *
135 * @param inst_id Instance ID.
136 * @return A otp_ctrl instance.
137 *
138 * **Note:** This function only makes sense if the instance ID has device type otp_ctrl,
139 * otherwise the returned value is unspecified.
140 */
142
143/**
144 * Get the instance ID of an instance.
145 *
146 * @param dt Instance of otp_ctrl.
147 * @return The instance ID of that instance.
148 */
150
151/**
152 * Get the register base address of an instance.
153 *
154 * @param dt Instance of otp_ctrl.
155 * @param reg_block The register block requested.
156 * @return The register base address of the requested block.
157 */
158uint32_t dt_otp_ctrl_reg_block(
159 dt_otp_ctrl_t dt,
160 dt_otp_ctrl_reg_block_t reg_block);
161
162/**
163 * Get the primary register base address of an instance.
164 *
165 * This is just a convenience function, equivalent to
166 * `dt_otp_ctrl_reg_block(dt, kDtOtpCtrlRegBlockCore)`
167 *
168 * @param dt Instance of otp_ctrl.
169 * @return The register base address of the primary register block.
170 */
171static inline uint32_t dt_otp_ctrl_primary_reg_block(
172 dt_otp_ctrl_t dt) {
173 return dt_otp_ctrl_reg_block(dt, kDtOtpCtrlRegBlockCore);
174}
175
176/**
177 * Get the base address of a memory.
178 *
179 * @param dt Instance of otp_ctrl.
180 * @param mem The memory requested.
181 * @return The base address of the requested memory.
182 */
184 dt_otp_ctrl_t dt,
186
187/**
188 * Get the size of a memory.
189 *
190 * @param dt Instance of otp_ctrl.
191 * @param mem The memory requested.
192 * @return The size of the requested memory.
193 */
195 dt_otp_ctrl_t dt,
197
198/**
199 * Get the PLIC ID of a otp_ctrl IRQ for a given instance.
200 *
201 * If the instance is not connected to the PLIC, this function
202 * will return `kDtPlicIrqIdNone`.
203 *
204 * @param dt Instance of otp_ctrl.
205 * @param irq A otp_ctrl IRQ.
206 * @return The PLIC ID of the IRQ of this instance.
207 */
209 dt_otp_ctrl_t dt,
211
212/**
213 * Convert a global IRQ ID to a local otp_ctrl IRQ type.
214 *
215 * @param dt Instance of otp_ctrl.
216 * @param irq A PLIC ID that belongs to this instance.
217 * @return The otp_ctrl IRQ, or `kDtOtpCtrlIrqCount`.
218 *
219 * **Note:** This function assumes that the PLIC ID belongs to the instance
220 * of otp_ctrl passed in parameter. In other words, it must be the case that
221 * `dt_otp_ctrl_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
222 * will return `kDtOtpCtrlIrqCount`.
223 */
225 dt_otp_ctrl_t dt,
226 dt_plic_irq_id_t irq);
227
228
229/**
230 * Get the alert ID of a otp_ctrl alert for a given instance.
231 *
232 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
233 * instances where the instance is not connected, the return value is unspecified.
234 *
235 * @param dt Instance of otp_ctrl.
236 * @param alert A otp_ctrl alert.
237 * @return The Alert Handler alert ID of the alert of this instance.
238 */
240 dt_otp_ctrl_t dt,
241 dt_otp_ctrl_alert_t alert);
242
243/**
244 * Convert a global alert ID to a local otp_ctrl alert type.
245 *
246 * @param dt Instance of otp_ctrl.
247 * @param alert A global alert ID that belongs to this instance.
248 * @return The otp_ctrl alert, or `kDtOtpCtrlAlertCount`.
249 *
250 * **Note:** This function assumes that the global alert ID belongs to the
251 * instance of otp_ctrl passed in parameter. In other words, it must be the case
252 * that `dt_otp_ctrl_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
253 * this function will return `kDtOtpCtrlAlertCount`.
254 */
256 dt_otp_ctrl_t dt,
257 dt_alert_id_t alert);
258
259
260
261/**
262 * Get the clock signal connected to a clock port of an instance.
263 *
264 * @param dt Instance of otp_ctrl.
265 * @param clk Clock port.
266 * @return Clock signal.
267 */
269 dt_otp_ctrl_t dt,
271
272/**
273 * Get the reset signal connected to a reset port of an instance.
274 *
275 * @param dt Instance of otp_ctrl.
276 * @param rst Reset port.
277 * @return Reset signal.
278 */
280 dt_otp_ctrl_t dt,
282
283
284
285/**
286 * Description of an OTP partition.
287 *
288 */
289typedef struct dt_otp_partition_info {
290 uint32_t start_addr; /**< The absolute OTP address at which this partition starts */
291 size_t size; /**< Size (in bytes) of the partition, excluding the digest field */
292 uint32_t digest_addr; /**< The absolute OTP address at which this partition's digest starts */
293 uint32_t align_mask; /**< The alignment mask for this partition */
295
296
297/**
298 * SW readable OTP partition identifier.
299 */
300typedef enum otp_partition {
301 kOtpPartitionVendorTest = 0, /**< */
302 kOtpPartitionCreatorSwCfg = 1, /**< */
303 kOtpPartitionOwnerSwCfg = 2, /**< */
304 kOtpPartitionRotCreatorAuthCodesign = 3, /**< */
305 kOtpPartitionRotCreatorAuthState = 4, /**< */
306 kOtpPartitionHwCfg0 = 5, /**< */
307 kOtpPartitionHwCfg1 = 6, /**< */
308 kOtpPartitionCount = 7, /**< \internal */
310
311/**
312 * Get a SW readable OTP partition information.
313 *
314 * @param dt Instance of otp_ctrl.
315 * @param partition OTP partition identifier.
316 * @return OTP partition information.
317 */
320
321
322
323#ifdef __cplusplus
324} // extern "C"
325#endif // __cplusplus
326
327#endif // OPENTITAN_DT_OTP_CTRL_H_