Software APIs
lc_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_LC_CTRL_H_
8#define OPENTITAN_DT_LC_CTRL_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif // __cplusplus
13
14/**
15 * @file
16 * @brief Device Tables (DT) for IP lc_ctrl and top darjeeling.
17 *
18 * This file contains the type definitions and global functions of the lc_ctrl.
19 */
20
21#include "hw/top/dt/api.h"
22#include <stdint.h>
23
24
25
26/**
27 * List of instances.
28 */
29typedef enum dt_lc_ctrl {
30 kDtLcCtrlFirst = 0, /**< First instance */
31 kDtLcCtrl = 0, /**< lc_ctrl */
33
34enum {
35 kDtLcCtrlCount = 1, /**< Number of instances */
36};
37
38
39/**
40 * List of register blocks.
41 *
42 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
43 */
45 kDtLcCtrlRegBlockRegs = 0, /**< */
46 kDtLcCtrlRegBlockDmi = 1, /**< */
48
49enum {
50 kDtLcCtrlRegBlockCount = 2, /**< Number of register blocks */
51};
52
53
54/** Primary register block (associated with the "primary" set of registers that control the IP). */
55static const dt_lc_ctrl_reg_block_t kDtLcCtrlRegBlockPrimary = kDtLcCtrlRegBlockRegs;
56
57/**
58 * List of Alerts.
59 *
60 * Alerts are guaranteed to be numbered consecutively from 0.
61 */
62typedef enum dt_lc_ctrl_alert {
63 kDtLcCtrlAlertFatalProgError = 0, /**< This alert triggers if an error occurred during an OTP programming operation. */
64 kDtLcCtrlAlertFatalStateError = 1, /**< This alert triggers if an error in the life cycle state or life cycle controller FSM is detected. */
65 kDtLcCtrlAlertFatalBusIntegError = 2, /**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
67
68enum {
69 kDtLcCtrlAlertCount = 3, /**< Number of Alerts */
70};
71
72
73/**
74 * List of clock ports.
75 *
76 * Clock ports are guaranteed to be numbered consecutively from 0.
77 */
78typedef enum dt_lc_ctrl_clock {
79 kDtLcCtrlClockClk = 0, /**< Clock port clk_i */
80 kDtLcCtrlClockKmac = 1, /**< Clock port clk_kmac_i */
82
83enum {
84 kDtLcCtrlClockCount = 2, /**< Number of clock ports */
85};
86
87
88/**
89 * List of reset ports.
90 *
91 * Reset ports are guaranteed to be numbered consecutively from 0.
92 */
93typedef enum dt_lc_ctrl_reset {
94 kDtLcCtrlResetRst = 0, /**< Reset port rst_ni */
95 kDtLcCtrlResetKmac = 1, /**< Reset port rst_kmac_ni */
97
98enum {
99 kDtLcCtrlResetCount = 2, /**< Number of reset ports */
100};
101
102
103/**
104 * List of supported hardware features.
105 */
106#define OPENTITAN_LC_CTRL_HAS_STATE_RAW 1
107#define OPENTITAN_LC_CTRL_HAS_STATE_TEST_UNLOCKED 1
108#define OPENTITAN_LC_CTRL_HAS_STATE_TEST_LOCKED 1
109#define OPENTITAN_LC_CTRL_HAS_STATE_DEV 1
110#define OPENTITAN_LC_CTRL_HAS_STATE_PROD 1
111#define OPENTITAN_LC_CTRL_HAS_STATE_PROD_END 1
112#define OPENTITAN_LC_CTRL_HAS_STATE_RMA 1
113#define OPENTITAN_LC_CTRL_HAS_STATE_SCRAP 1
114#define OPENTITAN_LC_CTRL_HAS_ACCESS_JTAG 1
115#define OPENTITAN_LC_CTRL_HAS_ACCESS_EXT_CLK 1
116#define OPENTITAN_LC_CTRL_HAS_AUTHENTICATED_TRANSITIONS 1
117#define OPENTITAN_LC_CTRL_HAS_LOGICAL_SCRAP 1
118
119
120
121/**
122 * Get the lc_ctrl instance from an instance ID
123 *
124 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
125 *
126 * @param inst_id Instance ID.
127 * @return A lc_ctrl instance.
128 *
129 * **Note:** This function only makes sense if the instance ID has device type lc_ctrl,
130 * otherwise the returned value is unspecified.
131 */
133
134/**
135 * Get the instance ID of an instance.
136 *
137 * @param dt Instance of lc_ctrl.
138 * @return The instance ID of that instance.
139 */
141
142/**
143 * Get the register base address of an instance.
144 *
145 * @param dt Instance of lc_ctrl.
146 * @param reg_block The register block requested.
147 * @return The register base address of the requested block.
148 */
149uint32_t dt_lc_ctrl_reg_block(
150 dt_lc_ctrl_t dt,
151 dt_lc_ctrl_reg_block_t reg_block);
152
153/**
154 * Get the primary register base address of an instance.
155 *
156 * This is just a convenience function, equivalent to
157 * `dt_lc_ctrl_reg_block(dt, kDtLcCtrlRegBlockRegs)`
158 *
159 * @param dt Instance of lc_ctrl.
160 * @return The register base address of the primary register block.
161 */
162static inline uint32_t dt_lc_ctrl_primary_reg_block(
163 dt_lc_ctrl_t dt) {
164 return dt_lc_ctrl_reg_block(dt, kDtLcCtrlRegBlockRegs);
165}
166
167
168/**
169 * Get the alert ID of a lc_ctrl alert for a given instance.
170 *
171 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
172 * instances where the instance is not connected, the return value is unspecified.
173 *
174 * @param dt Instance of lc_ctrl.
175 * @param alert A lc_ctrl alert.
176 * @return The Alert Handler alert ID of the alert of this instance.
177 */
179 dt_lc_ctrl_t dt,
180 dt_lc_ctrl_alert_t alert);
181
182/**
183 * Convert a global alert ID to a local lc_ctrl alert type.
184 *
185 * @param dt Instance of lc_ctrl.
186 * @param alert A global alert ID that belongs to this instance.
187 * @return The lc_ctrl alert, or `kDtLcCtrlAlertCount`.
188 *
189 * **Note:** This function assumes that the global alert ID belongs to the
190 * instance of lc_ctrl passed in parameter. In other words, it must be the case
191 * that `dt_lc_ctrl_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
192 * this function will return `kDtLcCtrlAlertCount`.
193 */
195 dt_lc_ctrl_t dt,
196 dt_alert_id_t alert);
197
198
199
200/**
201 * Get the clock signal connected to a clock port of an instance.
202 *
203 * @param dt Instance of lc_ctrl.
204 * @param clk Clock port.
205 * @return Clock signal.
206 */
208 dt_lc_ctrl_t dt,
210
211/**
212 * Get the reset signal connected to a reset port of an instance.
213 *
214 * @param dt Instance of lc_ctrl.
215 * @param rst Reset port.
216 * @return Reset signal.
217 */
219 dt_lc_ctrl_t dt,
221
222
223
224#ifdef __cplusplus
225} // extern "C"
226#endif // __cplusplus
227
228#endif // OPENTITAN_DT_LC_CTRL_H_