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/**
11 * @file
12 * @brief Device Tables (DT) for IP entropy_src and top earlgrey.
13 *
14 * This file contains the type definitions and global functions of the entropy_src.
15 */
16
17#include "dt_api.h"
18#include <stdint.h>
19
20
21
22/**
23 * List of instances.
24 */
25typedef enum dt_entropy_src {
26 kDtEntropySrc = 0, /**< entropy_src */
27 kDtEntropySrcFirst = 0, /**< \internal First instance */
28 kDtEntropySrcCount = 1, /**< \internal Number of instances */
30
31/**
32 * List of register blocks.
33 *
34 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
35 */
37 kDtEntropySrcRegBlockCore = 0, /**< */
38 kDtEntropySrcRegBlockCount = 1, /**< \internal Number of register blocks */
40
41/** Primary register block (associated with the "primary" set of registers that control the IP). */
42static const dt_entropy_src_reg_block_t kDtEntropySrcRegBlockPrimary = kDtEntropySrcRegBlockCore;
43
44/**
45 * List of IRQs.
46 *
47 * IRQs are guaranteed to be numbered consecutively from 0.
48 */
49typedef enum dt_entropy_src_irq {
50 kDtEntropySrcIrqEsEntropyValid = 0, /**< Asserted when entropy source bits are available for firmware for consumption via !!ENTROPY_DATA register. */
51 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. */
52 kDtEntropySrcIrqEsObserveFifoReady = 2, /**< Asserted when the observe FIFO has filled to the configured threshold level (see !!OBSERVE_FIFO_THRESH). */
53 kDtEntropySrcIrqEsFatalErr = 3, /**< Asserted when an fatal error condition is met, e.g., upon FIFO errors, or if an illegal state machine state is reached. */
54 kDtEntropySrcIrqCount = 4, /**< \internal Number of IRQs */
56
57/**
58 * List of Alerts.
59 *
60 * Alerts are guaranteed to be numbered consecutively from 0.
61 */
63 kDtEntropySrcAlertRecovAlert = 0, /**< This alert is triggered upon the alert health test threshold criteria not met. */
64 kDtEntropySrcAlertFatalAlert = 1, /**< This alert triggers for any condition detected in the !!ERR_CODE register,
65which includes FIFO errors, COUNTER errors, FSM state errors,
66and also when integrity failures are detected on the TL-UL bus. */
67 kDtEntropySrcAlertCount = 2, /**< \internal Number of Alerts */
69
70/**
71 * List of clock ports.
72 *
73 * Clock ports are guaranteed to be numbered consecutively from 0.
74 */
76 kDtEntropySrcClockClk = 0, /**< Clock port clk_i */
77 kDtEntropySrcClockCount = 1, /**< \internal Number of clock ports */
79
80/**
81 * List of reset ports.
82 *
83 * Reset ports are guaranteed to be numbered consecutively from 0.
84 */
86 kDtEntropySrcResetRst = 0, /**< Reset port rst_ni */
87 kDtEntropySrcResetCount = 1, /**< \internal Number of reset ports */
89
90/**
91 * List of supported hardware features.
92 */
93#define OPENTITAN_ENTROPY_SRC_HAS_MODE_BYPASS 1
94#define OPENTITAN_ENTROPY_SRC_HAS_MODE_FIPS 1
95#define OPENTITAN_ENTROPY_SRC_HAS_HEALTH_TESTS 1
96#define OPENTITAN_ENTROPY_SRC_HAS_HEALTH_TESTS_EXT 1
97#define OPENTITAN_ENTROPY_SRC_HAS_RNG_BIT_ENABLE 1
98#define OPENTITAN_ENTROPY_SRC_HAS_ROUTE_TO_FIRMWARE 1
99#define OPENTITAN_ENTROPY_SRC_HAS_FW_OV_OBSERVE 1
100#define OPENTITAN_ENTROPY_SRC_HAS_FW_OV_EXTRACT_AND_INSERT 1
101
102
103
104/**
105 * Get the entropy_src instance from an instance ID
106 *
107 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
108 *
109 * @param inst_id Instance ID.
110 * @return A entropy_src instance.
111 *
112 * **Note:** This function only makes sense if the instance ID has device type entropy_src,
113 * otherwise the returned value is unspecified.
114 */
116
117/**
118 * Get the instance ID of an instance.
119 *
120 * @param dt Instance of entropy_src.
121 * @return The instance ID of that instance.
122 */
124
125/**
126 * Get the register base address of an instance.
127 *
128 * @param dt Instance of entropy_src.
129 * @param reg_block The register block requested.
130 * @return The register base address of the requested block.
131 */
135
136/**
137 * Get the primary register base address of an instance.
138 *
139 * This is just a convenience function, equivalent to
140 * `dt_entropy_src_reg_block(dt, kDtEntropySrcRegBlockCore)`
141 *
142 * @param dt Instance of entropy_src.
143 * @return The register base address of the primary register block.
144 */
145static inline uint32_t dt_entropy_src_primary_reg_block(
146 dt_entropy_src_t dt) {
147 return dt_entropy_src_reg_block(dt, kDtEntropySrcRegBlockCore);
148}
149
150/**
151 * Get the PLIC ID of a entropy_src IRQ for a given instance.
152 *
153 * If the instance is not connected to the PLIC, this function
154 * will return `kDtPlicIrqIdNone`.
155 *
156 * @param dt Instance of entropy_src.
157 * @param irq A entropy_src IRQ.
158 * @return The PLIC ID of the IRQ of this instance.
159 */
163
164/**
165 * Convert a global IRQ ID to a local entropy_src IRQ type.
166 *
167 * @param dt Instance of entropy_src.
168 * @param irq A PLIC ID that belongs to this instance.
169 * @return The entropy_src IRQ, or `kDtEntropySrcIrqCount`.
170 *
171 * **Note:** This function assumes that the PLIC ID belongs to the instance
172 * of entropy_src passed in parameter. In other words, it must be the case that
173 * `dt_entropy_src_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
174 * will return `kDtEntropySrcIrqCount`.
175 */
178 dt_plic_irq_id_t irq);
179
180
181/**
182 * Get the alert ID of a entropy_src alert for a given instance.
183 *
184 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
185 * instances where the instance is not connected, the return value is unspecified.
186 *
187 * @param dt Instance of entropy_src.
188 * @param alert A entropy_src alert.
189 * @return The Alert Handler alert ID of the alert of this instance.
190 */
194
195/**
196 * Convert a global alert ID to a local entropy_src alert type.
197 *
198 * @param dt Instance of entropy_src.
199 * @param alert A global alert ID that belongs to this instance.
200 * @return The entropy_src alert, or `kDtEntropySrcAlertCount`.
201 *
202 * **Note:** This function assumes that the global alert ID belongs to the
203 * instance of entropy_src passed in parameter. In other words, it must be the case
204 * that `dt_entropy_src_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
205 * this function will return `kDtEntropySrcAlertCount`.
206 */
209 dt_alert_id_t alert);
210
211
212
213/**
214 * Get the clock signal connected to a clock port of an instance.
215 *
216 * @param dt Instance of entropy_src.
217 * @param clk Clock port.
218 * @return Clock signal.
219 */
223
224/**
225 * Get the reset signal connected to a reset port of an instance.
226 *
227 * @param dt Instance of entropy_src.
228 * @param rst Reset port.
229 * @return Reset signal.
230 */
234
235
236
237#endif // OPENTITAN_DT_ENTROPY_SRC_H_