Software APIs
dt_edn.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_EDN_H_
8#define OPENTITAN_DT_EDN_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif // __cplusplus
13
14/**
15 * @file
16 * @brief Device Tables (DT) for IP edn and top earlgrey.
17 *
18 * This file contains the type definitions and global functions of the edn.
19 */
20
21#include "dt_api.h"
22#include <stdint.h>
23
24
25
26/**
27 * List of instances.
28 */
29typedef enum dt_edn {
30 kDtEdn0 = 0, /**< edn0 */
31 kDtEdn1 = 1, /**< edn1 */
32 kDtEdnFirst = 0, /**< \internal First instance */
33 kDtEdnCount = 2, /**< \internal Number of instances */
35
36/**
37 * List of register blocks.
38 *
39 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
40 */
41typedef enum dt_edn_reg_block {
42 kDtEdnRegBlockCore = 0, /**< */
43 kDtEdnRegBlockCount = 1, /**< \internal Number of register blocks */
45
46/** Primary register block (associated with the "primary" set of registers that control the IP). */
47static const dt_edn_reg_block_t kDtEdnRegBlockPrimary = kDtEdnRegBlockCore;
48
49/**
50 * List of IRQs.
51 *
52 * IRQs are guaranteed to be numbered consecutively from 0.
53 */
54typedef enum dt_edn_irq {
55 kDtEdnIrqEdnCmdReqDone = 0, /**< Asserted when a software CSRNG request has completed. */
56 kDtEdnIrqEdnFatalErr = 1, /**< Asserted when a FIFO error occurs. */
57 kDtEdnIrqCount = 2, /**< \internal Number of IRQs */
59
60/**
61 * List of Alerts.
62 *
63 * Alerts are guaranteed to be numbered consecutively from 0.
64 */
65typedef enum dt_edn_alert {
66 kDtEdnAlertRecovAlert = 0, /**< This alert is triggered when entropy bus data matches on consecutive clock cycles. */
67 kDtEdnAlertFatalAlert = 1, /**< This alert triggers (i) if an illegal state machine state is reached, or
68(ii) if a fatal integrity failure is detected on the TL-UL bus. */
69 kDtEdnAlertCount = 2, /**< \internal Number of Alerts */
71
72/**
73 * List of clock ports.
74 *
75 * Clock ports are guaranteed to be numbered consecutively from 0.
76 */
77typedef enum dt_edn_clock {
78 kDtEdnClockClk = 0, /**< Clock port clk_i */
79 kDtEdnClockCount = 1, /**< \internal Number of clock ports */
81
82/**
83 * List of reset ports.
84 *
85 * Reset ports are guaranteed to be numbered consecutively from 0.
86 */
87typedef enum dt_edn_reset {
88 kDtEdnResetRst = 0, /**< Reset port rst_ni */
89 kDtEdnResetCount = 1, /**< \internal Number of reset ports */
91
92/**
93 * List of supported hardware features.
94 */
95#define OPENTITAN_EDN_HAS_MODE_BOOT 1
96#define OPENTITAN_EDN_HAS_MODE_AUTO 1
97#define OPENTITAN_EDN_HAS_MODE_SW 1
98#define OPENTITAN_EDN_HAS_TRACK_SEED_COMPLIANCE 1
99#define OPENTITAN_EDN_HAS_BUS_CMP_ALERT 1
100
101
102
103/**
104 * Get the edn instance from an instance ID
105 *
106 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
107 *
108 * @param inst_id Instance ID.
109 * @return A edn instance.
110 *
111 * **Note:** This function only makes sense if the instance ID has device type edn,
112 * otherwise the returned value is unspecified.
113 */
115
116/**
117 * Get the instance ID of an instance.
118 *
119 * @param dt Instance of edn.
120 * @return The instance ID of that instance.
121 */
123
124/**
125 * Get the register base address of an instance.
126 *
127 * @param dt Instance of edn.
128 * @param reg_block The register block requested.
129 * @return The register base address of the requested block.
130 */
131uint32_t dt_edn_reg_block(
132 dt_edn_t dt,
133 dt_edn_reg_block_t reg_block);
134
135/**
136 * Get the primary register base address of an instance.
137 *
138 * This is just a convenience function, equivalent to
139 * `dt_edn_reg_block(dt, kDtEdnRegBlockCore)`
140 *
141 * @param dt Instance of edn.
142 * @return The register base address of the primary register block.
143 */
144static inline uint32_t dt_edn_primary_reg_block(
145 dt_edn_t dt) {
146 return dt_edn_reg_block(dt, kDtEdnRegBlockCore);
147}
148
149/**
150 * Get the PLIC ID of a edn IRQ for a given instance.
151 *
152 * If the instance is not connected to the PLIC, this function
153 * will return `kDtPlicIrqIdNone`.
154 *
155 * @param dt Instance of edn.
156 * @param irq A edn IRQ.
157 * @return The PLIC ID of the IRQ of this instance.
158 */
160 dt_edn_t dt,
161 dt_edn_irq_t irq);
162
163/**
164 * Convert a global IRQ ID to a local edn IRQ type.
165 *
166 * @param dt Instance of edn.
167 * @param irq A PLIC ID that belongs to this instance.
168 * @return The edn IRQ, or `kDtEdnIrqCount`.
169 *
170 * **Note:** This function assumes that the PLIC ID belongs to the instance
171 * of edn passed in parameter. In other words, it must be the case that
172 * `dt_edn_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
173 * will return `kDtEdnIrqCount`.
174 */
176 dt_edn_t dt,
177 dt_plic_irq_id_t irq);
178
179
180/**
181 * Get the alert ID of a edn alert for a given instance.
182 *
183 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
184 * instances where the instance is not connected, the return value is unspecified.
185 *
186 * @param dt Instance of edn.
187 * @param alert A edn alert.
188 * @return The Alert Handler alert ID of the alert of this instance.
189 */
191 dt_edn_t dt,
192 dt_edn_alert_t alert);
193
194/**
195 * Convert a global alert ID to a local edn alert type.
196 *
197 * @param dt Instance of edn.
198 * @param alert A global alert ID that belongs to this instance.
199 * @return The edn alert, or `kDtEdnAlertCount`.
200 *
201 * **Note:** This function assumes that the global alert ID belongs to the
202 * instance of edn passed in parameter. In other words, it must be the case
203 * that `dt_edn_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
204 * this function will return `kDtEdnAlertCount`.
205 */
207 dt_edn_t dt,
208 dt_alert_id_t alert);
209
210
211
212/**
213 * Get the clock signal connected to a clock port of an instance.
214 *
215 * @param dt Instance of edn.
216 * @param clk Clock port.
217 * @return Clock signal.
218 */
220 dt_edn_t dt,
221 dt_edn_clock_t clk);
222
223/**
224 * Get the reset signal connected to a reset port of an instance.
225 *
226 * @param dt Instance of edn.
227 * @param rst Reset port.
228 * @return Reset signal.
229 */
231 dt_edn_t dt,
232 dt_edn_reset_t rst);
233
234
235
236#ifdef __cplusplus
237} // extern "C"
238#endif // __cplusplus
239
240#endif // OPENTITAN_DT_EDN_H_