Software APIs
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/api.h"
22#include <stdint.h>
23
24
25
26/**
27 * List of instances.
28 */
29typedef enum dt_entropy_src {
30 kDtEntropySrcFirst = 0, /**< First instance */
31 kDtEntropySrc = 0, /**< entropy_src */
33
34enum {
35 kDtEntropySrcCount = 1, /**< Number of instances */
36};
37
38
39/**
40 * List of register blocks.
41 *
42 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
43 */
45 kDtEntropySrcRegBlockCore = 0, /**< */
47
48enum {
49 kDtEntropySrcRegBlockCount = 1, /**< Number of register blocks */
50};
51
52
53/** Primary register block (associated with the "primary" set of registers that control the IP). */
54static const dt_entropy_src_reg_block_t kDtEntropySrcRegBlockPrimary = kDtEntropySrcRegBlockCore;
55
56/**
57 * List of IRQs.
58 *
59 * IRQs are guaranteed to be numbered consecutively from 0.
60 */
61typedef enum dt_entropy_src_irq {
62 kDtEntropySrcIrqEsEntropyValid = 0, /**< Asserted when entropy source bits are available for firmware for consumption via !!ENTROPY_DATA register. */
63 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. */
64 kDtEntropySrcIrqEsObserveFifoReady = 2, /**< Asserted when the observe FIFO has filled to the configured threshold level (see !!OBSERVE_FIFO_THRESH). */
65 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
68enum {
69 kDtEntropySrcIrqCount = 4, /**< Number of IRQs */
70};
71
72
73/**
74 * List of Alerts.
75 *
76 * Alerts are guaranteed to be numbered consecutively from 0.
77 */
79 kDtEntropySrcAlertRecovAlert = 0, /**< This alert is triggered upon the alert health test threshold criteria not met. */
80 kDtEntropySrcAlertFatalAlert = 1, /**< This alert triggers for any condition detected in the !!ERR_CODE register,
81 which includes FIFO errors, COUNTER errors, FSM state errors,
82 and also when integrity failures are detected on the TL-UL bus. */
84
85enum {
86 kDtEntropySrcAlertCount = 2, /**< Number of Alerts */
87};
88
89
90/**
91 * List of clock ports.
92 *
93 * Clock ports are guaranteed to be numbered consecutively from 0.
94 */
96 kDtEntropySrcClockClk = 0, /**< Clock port clk_i */
98
99enum {
100 kDtEntropySrcClockCount = 1, /**< Number of clock ports */
101};
102
103
104/**
105 * List of reset ports.
106 *
107 * Reset ports are guaranteed to be numbered consecutively from 0.
108 */
110 kDtEntropySrcResetRst = 0, /**< Reset port rst_ni */
112
113enum {
114 kDtEntropySrcResetCount = 1, /**< Number of reset ports */
115};
116
117
118/**
119 * List of supported hardware features.
120 */
121#define OPENTITAN_ENTROPY_SRC_HAS_MODE_BYPASS 1
122#define OPENTITAN_ENTROPY_SRC_HAS_MODE_FIPS 1
123#define OPENTITAN_ENTROPY_SRC_HAS_HEALTH_TESTS 1
124#define OPENTITAN_ENTROPY_SRC_HAS_HEALTH_TESTS_EXT 1
125#define OPENTITAN_ENTROPY_SRC_HAS_RNG_BIT_ENABLE 1
126#define OPENTITAN_ENTROPY_SRC_HAS_ROUTE_TO_FIRMWARE 1
127#define OPENTITAN_ENTROPY_SRC_HAS_FW_OV_OBSERVE 1
128#define OPENTITAN_ENTROPY_SRC_HAS_FW_OV_EXTRACT_AND_INSERT 1
129
130
131
132/**
133 * Get the entropy_src instance from an instance ID
134 *
135 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
136 *
137 * @param inst_id Instance ID.
138 * @return A entropy_src instance.
139 *
140 * **Note:** This function only makes sense if the instance ID has device type entropy_src,
141 * otherwise the returned value is unspecified.
142 */
144
145/**
146 * Get the instance ID of an instance.
147 *
148 * @param dt Instance of entropy_src.
149 * @return The instance ID of that instance.
150 */
152
153/**
154 * Get the register base address of an instance.
155 *
156 * @param dt Instance of entropy_src.
157 * @param reg_block The register block requested.
158 * @return The register base address of the requested block.
159 */
163
164/**
165 * Get the primary register base address of an instance.
166 *
167 * This is just a convenience function, equivalent to
168 * `dt_entropy_src_reg_block(dt, kDtEntropySrcRegBlockCore)`
169 *
170 * @param dt Instance of entropy_src.
171 * @return The register base address of the primary register block.
172 */
173static inline uint32_t dt_entropy_src_primary_reg_block(
174 dt_entropy_src_t dt) {
175 return dt_entropy_src_reg_block(dt, kDtEntropySrcRegBlockCore);
176}
177
178/**
179 * Get the PLIC ID of a entropy_src IRQ for a given instance.
180 *
181 * If the instance is not connected to the PLIC, this function
182 * will return `kDtPlicIrqIdNone`.
183 *
184 * @param dt Instance of entropy_src.
185 * @param irq A entropy_src IRQ.
186 * @return The PLIC ID of the IRQ of this instance.
187 */
191
192/**
193 * Convert a global IRQ ID to a local entropy_src IRQ type.
194 *
195 * @param dt Instance of entropy_src.
196 * @param irq A PLIC ID that belongs to this instance.
197 * @return The entropy_src IRQ, or `kDtEntropySrcIrqCount`.
198 *
199 * **Note:** This function assumes that the PLIC ID belongs to the instance
200 * of entropy_src passed in parameter. In other words, it must be the case that
201 * `dt_entropy_src_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
202 * will return `kDtEntropySrcIrqCount`.
203 */
206 dt_plic_irq_id_t irq);
207
208
209/**
210 * Get the alert ID of a entropy_src alert for a given instance.
211 *
212 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
213 * instances where the instance is not connected, the return value is unspecified.
214 *
215 * @param dt Instance of entropy_src.
216 * @param alert A entropy_src alert.
217 * @return The Alert Handler alert ID of the alert of this instance.
218 */
222
223/**
224 * Convert a global alert ID to a local entropy_src alert type.
225 *
226 * @param dt Instance of entropy_src.
227 * @param alert A global alert ID that belongs to this instance.
228 * @return The entropy_src alert, or `kDtEntropySrcAlertCount`.
229 *
230 * **Note:** This function assumes that the global alert ID belongs to the
231 * instance of entropy_src passed in parameter. In other words, it must be the case
232 * that `dt_entropy_src_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
233 * this function will return `kDtEntropySrcAlertCount`.
234 */
237 dt_alert_id_t alert);
238
239
240
241/**
242 * Get the clock signal connected to a clock port of an instance.
243 *
244 * @param dt Instance of entropy_src.
245 * @param clk Clock port.
246 * @return Clock signal.
247 */
251
252/**
253 * Get the reset signal connected to a reset port of an instance.
254 *
255 * @param dt Instance of entropy_src.
256 * @param rst Reset port.
257 * @return Reset signal.
258 */
262
263
264
265#ifdef __cplusplus
266} // extern "C"
267#endif // __cplusplus
268
269#endif // OPENTITAN_DT_ENTROPY_SRC_H_