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