Software APIs
dt_entropy_src.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_ENTROPY_SRC_H_
8#define OPENTITAN_DT_ENTROPY_SRC_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif // __cplusplus
13
14/**
15 * @file
16 * @brief Device Tables (DT) for IP entropy_src and top darjeeling.
17 *
18 * This file contains the type definitions and global functions of the entropy_src.
19 */
20
21#include "hw/top/dt/dt_api.h"
22#include <stdint.h>
23
24
25
26/**
27 * List of instances.
28 */
29typedef enum dt_entropy_src {
30 kDtEntropySrc = 0, /**< entropy_src */
31 kDtEntropySrcFirst = 0, /**< \internal First instance */
32 kDtEntropySrcCount = 1, /**< \internal Number of instances */
34
35/**
36 * List of register blocks.
37 *
38 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
39 */
41 kDtEntropySrcRegBlockCore = 0, /**< */
42 kDtEntropySrcRegBlockCount = 1, /**< \internal Number of register blocks */
44
45/** Primary register block (associated with the "primary" set of registers that control the IP). */
46static const dt_entropy_src_reg_block_t kDtEntropySrcRegBlockPrimary = kDtEntropySrcRegBlockCore;
47
48/**
49 * List of memories.
50 *
51 * Memories are guaranteed to start at 0 and to be consecutively numbered.
52 */
54 kDtEntropySrcMemoryCount = 0, /**< \internal Number of memories */
56
57/**
58 * List of IRQs.
59 *
60 * IRQs are guaranteed to be numbered consecutively from 0.
61 */
62typedef enum dt_entropy_src_irq {
63 kDtEntropySrcIrqEsEntropyValid = 0, /**< Asserted when entropy source bits are available for firmware for consumption via !!ENTROPY_DATA register. */
64 kDtEntropySrcIrqEsHealthTestFailed = 1, /**< Asserted whenever the main state machine is in the alert state, e.g., due to health tests failing and reaching the threshold value configured in !!ALERT_THRESHOLD. */
65 kDtEntropySrcIrqEsObserveFifoReady = 2, /**< Asserted when the observe FIFO has filled to the configured threshold level (see !!OBSERVE_FIFO_THRESH). */
66 kDtEntropySrcIrqEsFatalErr = 3, /**< Asserted when an fatal error condition is met, e.g., upon FIFO errors, or if an illegal state machine state is reached. */
67 kDtEntropySrcIrqCount = 4, /**< \internal Number of IRQs */
69
70/**
71 * List of Alerts.
72 *
73 * Alerts are guaranteed to be numbered consecutively from 0.
74 */
76 kDtEntropySrcAlertRecovAlert = 0, /**< This alert is triggered upon the alert health test threshold criteria not met. */
77 kDtEntropySrcAlertFatalAlert = 1, /**< This alert triggers for any condition detected in the !!ERR_CODE register,
78which includes FIFO errors, COUNTER errors, FSM state errors,
79and also when integrity failures are detected on the TL-UL bus. */
80 kDtEntropySrcAlertCount = 2, /**< \internal Number of Alerts */
82
83/**
84 * List of clock ports.
85 *
86 * Clock ports are guaranteed to be numbered consecutively from 0.
87 */
89 kDtEntropySrcClockClk = 0, /**< Clock port clk_i */
90 kDtEntropySrcClockCount = 1, /**< \internal Number of clock ports */
92
93/**
94 * List of reset ports.
95 *
96 * Reset ports are guaranteed to be numbered consecutively from 0.
97 */
99 kDtEntropySrcResetRst = 0, /**< Reset port rst_ni */
100 kDtEntropySrcResetCount = 1, /**< \internal Number of reset ports */
102
103/**
104 * List of supported hardware features.
105 */
106#define OPENTITAN_ENTROPY_SRC_HAS_MODE_BYPASS 1
107#define OPENTITAN_ENTROPY_SRC_HAS_MODE_FIPS 1
108#define OPENTITAN_ENTROPY_SRC_HAS_HEALTH_TESTS 1
109#define OPENTITAN_ENTROPY_SRC_HAS_HEALTH_TESTS_EXT 1
110#define OPENTITAN_ENTROPY_SRC_HAS_RNG_BIT_ENABLE 1
111#define OPENTITAN_ENTROPY_SRC_HAS_ROUTE_TO_FIRMWARE 1
112#define OPENTITAN_ENTROPY_SRC_HAS_FW_OV_OBSERVE 1
113#define OPENTITAN_ENTROPY_SRC_HAS_FW_OV_EXTRACT_AND_INSERT 1
114
115
116
117/**
118 * Get the entropy_src instance from an instance ID
119 *
120 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
121 *
122 * @param inst_id Instance ID.
123 * @return A entropy_src instance.
124 *
125 * **Note:** This function only makes sense if the instance ID has device type entropy_src,
126 * otherwise the returned value is unspecified.
127 */
129
130/**
131 * Get the instance ID of an instance.
132 *
133 * @param dt Instance of entropy_src.
134 * @return The instance ID of that instance.
135 */
137
138/**
139 * Get the register base address of an instance.
140 *
141 * @param dt Instance of entropy_src.
142 * @param reg_block The register block requested.
143 * @return The register base address of the requested block.
144 */
148
149/**
150 * Get the primary register base address of an instance.
151 *
152 * This is just a convenience function, equivalent to
153 * `dt_entropy_src_reg_block(dt, kDtEntropySrcRegBlockCore)`
154 *
155 * @param dt Instance of entropy_src.
156 * @return The register base address of the primary register block.
157 */
158static inline uint32_t dt_entropy_src_primary_reg_block(
159 dt_entropy_src_t dt) {
160 return dt_entropy_src_reg_block(dt, kDtEntropySrcRegBlockCore);
161}
162
163/**
164 * Get the base address of a memory.
165 *
166 * @param dt Instance of entropy_src.
167 * @param mem The memory requested.
168 * @return The base address of the requested memory.
169 */
173
174/**
175 * Get the size of a memory.
176 *
177 * @param dt Instance of entropy_src.
178 * @param mem The memory requested.
179 * @return The size of the requested memory.
180 */
184
185/**
186 * Get the PLIC ID of a entropy_src IRQ for a given instance.
187 *
188 * If the instance is not connected to the PLIC, this function
189 * will return `kDtPlicIrqIdNone`.
190 *
191 * @param dt Instance of entropy_src.
192 * @param irq A entropy_src IRQ.
193 * @return The PLIC ID of the IRQ of this instance.
194 */
198
199/**
200 * Convert a global IRQ ID to a local entropy_src IRQ type.
201 *
202 * @param dt Instance of entropy_src.
203 * @param irq A PLIC ID that belongs to this instance.
204 * @return The entropy_src IRQ, or `kDtEntropySrcIrqCount`.
205 *
206 * **Note:** This function assumes that the PLIC ID belongs to the instance
207 * of entropy_src passed in parameter. In other words, it must be the case that
208 * `dt_entropy_src_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
209 * will return `kDtEntropySrcIrqCount`.
210 */
213 dt_plic_irq_id_t irq);
214
215
216/**
217 * Get the alert ID of a entropy_src alert for a given instance.
218 *
219 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
220 * instances where the instance is not connected, the return value is unspecified.
221 *
222 * @param dt Instance of entropy_src.
223 * @param alert A entropy_src alert.
224 * @return The Alert Handler alert ID of the alert of this instance.
225 */
229
230/**
231 * Convert a global alert ID to a local entropy_src alert type.
232 *
233 * @param dt Instance of entropy_src.
234 * @param alert A global alert ID that belongs to this instance.
235 * @return The entropy_src alert, or `kDtEntropySrcAlertCount`.
236 *
237 * **Note:** This function assumes that the global alert ID belongs to the
238 * instance of entropy_src passed in parameter. In other words, it must be the case
239 * that `dt_entropy_src_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
240 * this function will return `kDtEntropySrcAlertCount`.
241 */
244 dt_alert_id_t alert);
245
246
247
248/**
249 * Get the clock signal connected to a clock port of an instance.
250 *
251 * @param dt Instance of entropy_src.
252 * @param clk Clock port.
253 * @return Clock signal.
254 */
258
259/**
260 * Get the reset signal connected to a reset port of an instance.
261 *
262 * @param dt Instance of entropy_src.
263 * @param rst Reset port.
264 * @return Reset signal.
265 */
269
270
271
272#ifdef __cplusplus
273} // extern "C"
274#endif // __cplusplus
275
276#endif // OPENTITAN_DT_ENTROPY_SRC_H_