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