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 "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 IRQs.
50 *
51 * IRQs are guaranteed to be numbered consecutively from 0.
52 */
53typedef enum dt_entropy_src_irq {
54 kDtEntropySrcIrqEsEntropyValid = 0, /**< Asserted when entropy source bits are available for firmware for consumption via !!ENTROPY_DATA register. */
55 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. */
56 kDtEntropySrcIrqEsObserveFifoReady = 2, /**< Asserted when the observe FIFO has filled to the configured threshold level (see !!OBSERVE_FIFO_THRESH). */
57 kDtEntropySrcIrqEsFatalErr = 3, /**< Asserted when an fatal error condition is met, e.g., upon FIFO errors, or if an illegal state machine state is reached. */
58 kDtEntropySrcIrqCount = 4, /**< \internal Number of IRQs */
60
61/**
62 * List of Alerts.
63 *
64 * Alerts are guaranteed to be numbered consecutively from 0.
65 */
67 kDtEntropySrcAlertRecovAlert = 0, /**< This alert is triggered upon the alert health test threshold criteria not met. */
68 kDtEntropySrcAlertFatalAlert = 1, /**< This alert triggers for any condition detected in the !!ERR_CODE register,
69which includes FIFO errors, COUNTER errors, FSM state errors,
70and also when integrity failures are detected on the TL-UL bus. */
71 kDtEntropySrcAlertCount = 2, /**< \internal Number of Alerts */
73
74/**
75 * List of clock ports.
76 *
77 * Clock ports are guaranteed to be numbered consecutively from 0.
78 */
80 kDtEntropySrcClockClk = 0, /**< Clock port clk_i */
81 kDtEntropySrcClockCount = 1, /**< \internal Number of clock ports */
83
84/**
85 * List of reset ports.
86 *
87 * Reset ports are guaranteed to be numbered consecutively from 0.
88 */
90 kDtEntropySrcResetRst = 0, /**< Reset port rst_ni */
91 kDtEntropySrcResetCount = 1, /**< \internal Number of reset ports */
93
94/**
95 * List of supported hardware features.
96 */
97#define OPENTITAN_ENTROPY_SRC_HAS_MODE_BYPASS 1
98#define OPENTITAN_ENTROPY_SRC_HAS_MODE_FIPS 1
99#define OPENTITAN_ENTROPY_SRC_HAS_HEALTH_TESTS 1
100#define OPENTITAN_ENTROPY_SRC_HAS_HEALTH_TESTS_EXT 1
101#define OPENTITAN_ENTROPY_SRC_HAS_RNG_BIT_ENABLE 1
102#define OPENTITAN_ENTROPY_SRC_HAS_ROUTE_TO_FIRMWARE 1
103#define OPENTITAN_ENTROPY_SRC_HAS_FW_OV_OBSERVE 1
104#define OPENTITAN_ENTROPY_SRC_HAS_FW_OV_EXTRACT_AND_INSERT 1
105
106
107
108/**
109 * Get the entropy_src instance from an instance ID
110 *
111 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
112 *
113 * @param inst_id Instance ID.
114 * @return A entropy_src instance.
115 *
116 * **Note:** This function only makes sense if the instance ID has device type entropy_src,
117 * otherwise the returned value is unspecified.
118 */
120
121/**
122 * Get the instance ID of an instance.
123 *
124 * @param dt Instance of entropy_src.
125 * @return The instance ID of that instance.
126 */
128
129/**
130 * Get the register base address of an instance.
131 *
132 * @param dt Instance of entropy_src.
133 * @param reg_block The register block requested.
134 * @return The register base address of the requested block.
135 */
139
140/**
141 * Get the primary register base address of an instance.
142 *
143 * This is just a convenience function, equivalent to
144 * `dt_entropy_src_reg_block(dt, kDtEntropySrcRegBlockCore)`
145 *
146 * @param dt Instance of entropy_src.
147 * @return The register base address of the primary register block.
148 */
149static inline uint32_t dt_entropy_src_primary_reg_block(
150 dt_entropy_src_t dt) {
151 return dt_entropy_src_reg_block(dt, kDtEntropySrcRegBlockCore);
152}
153
154/**
155 * Get the PLIC ID of a entropy_src IRQ for a given instance.
156 *
157 * If the instance is not connected to the PLIC, this function
158 * will return `kDtPlicIrqIdNone`.
159 *
160 * @param dt Instance of entropy_src.
161 * @param irq A entropy_src IRQ.
162 * @return The PLIC ID of the IRQ of this instance.
163 */
167
168/**
169 * Convert a global IRQ ID to a local entropy_src IRQ type.
170 *
171 * @param dt Instance of entropy_src.
172 * @param irq A PLIC ID that belongs to this instance.
173 * @return The entropy_src IRQ, or `kDtEntropySrcIrqCount`.
174 *
175 * **Note:** This function assumes that the PLIC ID belongs to the instance
176 * of entropy_src passed in parameter. In other words, it must be the case that
177 * `dt_entropy_src_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
178 * will return `kDtEntropySrcIrqCount`.
179 */
182 dt_plic_irq_id_t irq);
183
184
185/**
186 * Get the alert ID of a entropy_src alert for a given instance.
187 *
188 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
189 * instances where the instance is not connected, the return value is unspecified.
190 *
191 * @param dt Instance of entropy_src.
192 * @param alert A entropy_src alert.
193 * @return The Alert Handler alert ID of the alert of this instance.
194 */
198
199/**
200 * Convert a global alert ID to a local entropy_src alert type.
201 *
202 * @param dt Instance of entropy_src.
203 * @param alert A global alert ID that belongs to this instance.
204 * @return The entropy_src alert, or `kDtEntropySrcAlertCount`.
205 *
206 * **Note:** This function assumes that the global alert ID belongs to the
207 * instance of entropy_src passed in parameter. In other words, it must be the case
208 * that `dt_entropy_src_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
209 * this function will return `kDtEntropySrcAlertCount`.
210 */
213 dt_alert_id_t alert);
214
215
216
217/**
218 * Get the clock signal connected to a clock port of an instance.
219 *
220 * @param dt Instance of entropy_src.
221 * @param clk Clock port.
222 * @return Clock signal.
223 */
227
228/**
229 * Get the reset signal connected to a reset port of an instance.
230 *
231 * @param dt Instance of entropy_src.
232 * @param rst Reset port.
233 * @return Reset signal.
234 */
238
239
240
241#ifdef __cplusplus
242} // extern "C"
243#endif // __cplusplus
244
245#endif // OPENTITAN_DT_ENTROPY_SRC_H_