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/**
11 * @file
12 * @brief Device Tables (DT) for IP otp_ctrl and top earlgrey.
13 *
14 * This file contains the type definitions and global functions of the otp_ctrl.
15 */
16
17#include "dt_api.h"
18#include <stdint.h>
19
20/**
21 * List of instances.
22 */
23typedef enum dt_otp_ctrl {
24 kDtOtpCtrl = 0, /**< otp_ctrl */
25 kDtOtpCtrlFirst = 0, /**< \internal First instance */
26 kDtOtpCtrlCount = 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 kDtOtpCtrlRegBlockCore = 0, /**< */
36 kDtOtpCtrlRegBlockCount = 1, /**< \internal Number of register blocks */
38
39/** Primary register block (associated with the "primary" set of registers that control the IP). */
40static const dt_otp_ctrl_reg_block_t kDtOtpCtrlRegBlockPrimary = kDtOtpCtrlRegBlockCore;
41
42/**
43 * List of IRQs.
44 *
45 * IRQs are guaranteed to be numbered consecutively from 0.
46 */
47typedef enum dt_otp_ctrl_irq {
48 kDtOtpCtrlIrqOtpOperationDone = 0, /**< A direct access command or digest calculation operation has completed. */
49 kDtOtpCtrlIrqOtpError = 1, /**< An error has occurred in the OTP controller. Check the !!ERR_CODE register to get more information. */
50 kDtOtpCtrlIrqCount = 2, /**< \internal Number of IRQs */
52
53/**
54 * List of Alerts.
55 *
56 * Alerts are guaranteed to be numbered consecutively from 0.
57 */
58typedef enum dt_otp_ctrl_alert {
59 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. */
60 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. */
61 kDtOtpCtrlAlertFatalBusIntegError = 2, /**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
62 kDtOtpCtrlAlertFatalPrimOtpAlert = 3, /**< Fatal alert triggered inside the OTP primitive, including fatal TL-UL bus integrity faults of the test interface. */
63 kDtOtpCtrlAlertRecovPrimOtpAlert = 4, /**< Recoverable alert triggered inside the OTP primitive. */
64 kDtOtpCtrlAlertCount = 5, /**< \internal Number of Alerts */
66
67/**
68 * List of clock ports.
69 *
70 * Clock ports are guaranteed to be numbered consecutively from 0.
71 */
72typedef enum dt_otp_ctrl_clock {
73 kDtOtpCtrlClockClk = 0, /**< Clock port clk_i */
74 kDtOtpCtrlClockEdn = 1, /**< Clock port clk_edn_i */
75 kDtOtpCtrlClockCount = 2, /**< \internal Number of clock ports */
77
78/**
79 * List of reset ports.
80 *
81 * Reset ports are guaranteed to be numbered consecutively from 0.
82 */
83typedef enum dt_otp_ctrl_reset {
84 kDtOtpCtrlResetRst = 0, /**< Reset port rst_ni */
85 kDtOtpCtrlResetEdn = 1, /**< Reset port rst_edn_ni */
86 kDtOtpCtrlResetCount = 2, /**< \internal Number of reset ports */
88
89/**
90 * List of supported hardware features.
91 */
92#define OPENTITAN_OTP_CTRL_HAS_PARTITION_VENDOR_TEST 1
93#define OPENTITAN_OTP_CTRL_HAS_PARTITION_CREATOR_SW_CFG 1
94#define OPENTITAN_OTP_CTRL_HAS_PARTITION_OWNER_SW_CFG 1
95#define OPENTITAN_OTP_CTRL_HAS_INIT 1
96#define OPENTITAN_OTP_CTRL_HAS_ENTROPY_READ 1
97#define OPENTITAN_OTP_CTRL_HAS_KEY_DERIVATION 1
98#define OPENTITAN_OTP_CTRL_HAS_PROGRAM 1
99#define OPENTITAN_OTP_CTRL_HAS_PARTITION_SECRET0 1
100#define OPENTITAN_OTP_CTRL_HAS_PARTITION_SECRET1 1
101#define OPENTITAN_OTP_CTRL_HAS_PARTITION_SECRET2 1
102#define OPENTITAN_OTP_CTRL_HAS_PARTITION_LIFE_CYCLE 1
103#define OPENTITAN_OTP_CTRL_HAS_PARTITIONS_FEATURE_READ_LOCK 1
104#define OPENTITAN_OTP_CTRL_HAS_PARTITIONS_FEATURE_WRITE_LOCK 1
105#define OPENTITAN_OTP_CTRL_HAS_ERROR_HANDLING_RECOVERABLE 1
106#define OPENTITAN_OTP_CTRL_HAS_ERROR_HANDLING_FATAL 1
107#define OPENTITAN_OTP_CTRL_HAS_BACKGROUND_CHECK_CHECK_TIMEOUT 1
108#define OPENTITAN_OTP_CTRL_HAS_BACKGROUND_CHECK_INTEGRITY_CHECK_PERIOD 1
109#define OPENTITAN_OTP_CTRL_HAS_BACKGROUND_CHECK_CONSISTENCY_CHECK_PERIOD 1
110
111
112
113/**
114 * Get the otp_ctrl instance from an instance ID
115 *
116 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
117 *
118 * @param inst_id Instance ID.
119 * @return A otp_ctrl instance.
120 *
121 * **Note:** This function only makes sense if the instance ID has device type otp_ctrl,
122 * otherwise the returned value is unspecified.
123 */
125
126/**
127 * Get the instance ID of an instance.
128 *
129 * @param dt Instance of otp_ctrl.
130 * @return The instance ID of that instance.
131 */
133
134/**
135 * Get the register base address of an instance.
136 *
137 * @param dt Instance of otp_ctrl.
138 * @param reg_block The register block requested.
139 * @return The register base address of the requested block.
140 */
141uint32_t dt_otp_ctrl_reg_block(
142 dt_otp_ctrl_t dt,
143 dt_otp_ctrl_reg_block_t reg_block);
144
145/**
146 * Get the primary register base address of an instance.
147 *
148 * This is just a convenience function, equivalent to
149 * `dt_otp_ctrl_reg_block(dt, kDtOtpCtrlRegBlockCore)`
150 *
151 * @param dt Instance of otp_ctrl.
152 * @return The register base address of the primary register block.
153 */
154static inline uint32_t dt_otp_ctrl_primary_reg_block(
155 dt_otp_ctrl_t dt) {
156 return dt_otp_ctrl_reg_block(dt, kDtOtpCtrlRegBlockCore);
157}
158
159/**
160 * Get the PLIC ID of a otp_ctrl IRQ for a given instance.
161 *
162 * If the instance is not connected to the PLIC, this function
163 * will return `kDtPlicIrqIdNone`.
164 *
165 * @param dt Instance of otp_ctrl.
166 * @param irq A otp_ctrl IRQ.
167 * @return The PLIC ID of the IRQ of this instance.
168 */
170 dt_otp_ctrl_t dt,
172
173/**
174 * Convert a global IRQ ID to a local otp_ctrl IRQ type.
175 *
176 * @param dt Instance of otp_ctrl.
177 * @param irq A PLIC ID that belongs to this instance.
178 * @return The otp_ctrl IRQ, or `kDtOtpCtrlIrqCount`.
179 *
180 * **Note:** This function assumes that the PLIC ID belongs to the instance
181 * of otp_ctrl passed in parameter. In other words, it must be the case that
182 * `dt_otp_ctrl_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
183 * will return `kDtOtpCtrlIrqCount`.
184 */
186 dt_otp_ctrl_t dt,
187 dt_plic_irq_id_t irq);
188
189
190/**
191 * Get the alert ID of a otp_ctrl alert for a given instance.
192 *
193 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
194 * instances where the instance is not connected, the return value is unspecified.
195 *
196 * @param dt Instance of otp_ctrl.
197 * @param alert A otp_ctrl alert.
198 * @return The Alert Handler alert ID of the alert of this instance.
199 */
201 dt_otp_ctrl_t dt,
202 dt_otp_ctrl_alert_t alert);
203
204/**
205 * Convert a global alert ID to a local otp_ctrl alert type.
206 *
207 * @param dt Instance of otp_ctrl.
208 * @param alert A global alert ID that belongs to this instance.
209 * @return The otp_ctrl alert, or `kDtOtpCtrlAlertCount`.
210 *
211 * **Note:** This function assumes that the global alert ID belongs to the
212 * instance of otp_ctrl passed in parameter. In other words, it must be the case
213 * that `dt_otp_ctrl_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
214 * this function will return `kDtOtpCtrlAlertCount`.
215 */
217 dt_otp_ctrl_t dt,
218 dt_alert_id_t alert);
219
220
221
222/**
223 * Get the clock signal connected to a clock port of an instance.
224 *
225 * @param dt Instance of otp_ctrl.
226 * @param clk Clock port.
227 * @return Clock signal.
228 */
230 dt_otp_ctrl_t dt,
232
233/**
234 * Get the reset signal connected to a reset port of an instance.
235 *
236 * @param dt Instance of otp_ctrl.
237 * @param rst Reset port.
238 * @return Reset signal.
239 */
241 dt_otp_ctrl_t dt,
243
244
245
246#endif // OPENTITAN_DT_OTP_CTRL_H_