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