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