Software APIs
dt_pattgen.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_PATTGEN_H_
8#define OPENTITAN_DT_PATTGEN_H_
9
10/**
11 * @file
12 * @brief Device Tables (DT) for IP pattgen and top earlgrey.
13 *
14 * This file contains the type definitions and global functions of the pattgen.
15 */
16
17#include "dt_api.h"
18#include <stdint.h>
19
20/**
21 * List of instances.
22 */
23typedef enum dt_pattgen {
24 kDtPattgen = 0, /**< pattgen */
25 kDtPattgenFirst = 0, /**< \internal First instance */
26 kDtPattgenCount = 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 kDtPattgenRegBlockCore = 0, /**< */
36 kDtPattgenRegBlockCount = 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_pattgen_reg_block_t kDtPattgenRegBlockPrimary = kDtPattgenRegBlockCore;
41
42/**
43 * List of IRQs.
44 *
45 * IRQs are guaranteed to be numbered consecutively from 0.
46 */
47typedef enum dt_pattgen_irq {
48 kDtPattgenIrqDoneCh0 = 0, /**< raise if pattern generation on Channel 0 is complete */
49 kDtPattgenIrqDoneCh1 = 1, /**< raise if pattern generation on Channel 1 is complete */
50 kDtPattgenIrqCount = 2, /**< \internal Number of IRQs */
52
53/**
54 * List of Alerts.
55 *
56 * Alerts are guaranteed to be numbered consecutively from 0.
57 */
58typedef enum dt_pattgen_alert {
59 kDtPattgenAlertFatalFault = 0, /**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
60 kDtPattgenAlertCount = 1, /**< \internal Number of Alerts */
62
63/**
64 * List of clock ports.
65 *
66 * Clock ports are guaranteed to be numbered consecutively from 0.
67 */
68typedef enum dt_pattgen_clock {
69 kDtPattgenClockClk = 0, /**< Clock port clk_i */
70 kDtPattgenClockCount = 1, /**< \internal Number of clock ports */
72
73/**
74 * List of reset ports.
75 *
76 * Reset ports are guaranteed to be numbered consecutively from 0.
77 */
78typedef enum dt_pattgen_reset {
79 kDtPattgenResetRst = 0, /**< Reset port rst_ni */
80 kDtPattgenResetCount = 1, /**< \internal Number of reset ports */
82
83/**
84 * List of peripheral I/O.
85 *
86 * Peripheral I/O are guaranteed to be numbered consecutively from 0.
87 */
89 kDtPattgenPeriphIoPda0Tx = 0, /**< */
90 kDtPattgenPeriphIoPcl0Tx = 1, /**< */
91 kDtPattgenPeriphIoPda1Tx = 2, /**< */
92 kDtPattgenPeriphIoPcl1Tx = 3, /**< */
93 kDtPattgenPeriphIoCount = 4, /**< \internal Number of peripheral I/O */
95
96/**
97 * List of supported hardware features.
98 */
99#define OPENTITAN_PATTGEN_HAS_CHANNEL_ONE 1
100#define OPENTITAN_PATTGEN_HAS_CHANNEL_TWO 1
101#define OPENTITAN_PATTGEN_HAS_CONFIG_PATTERN 1
102#define OPENTITAN_PATTGEN_HAS_CONFIG_DIVIDER 1
103#define OPENTITAN_PATTGEN_HAS_CONFIG_REPEAT 1
104#define OPENTITAN_PATTGEN_HAS_CONFIG_POLARITY 1
105#define OPENTITAN_PATTGEN_HAS_CONFIG_INACTIVE_LEVEL 1
106#define OPENTITAN_PATTGEN_HAS_COMPLETE 1
107
108
109
110/**
111 * Get the pattgen instance from an instance ID
112 *
113 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
114 *
115 * @param inst_id Instance ID.
116 * @return A pattgen instance.
117 *
118 * **Note:** This function only makes sense if the instance ID has device type pattgen,
119 * otherwise the returned value is unspecified.
120 */
122
123/**
124 * Get the instance ID of an instance.
125 *
126 * @param dt Instance of pattgen.
127 * @return The instance ID of that instance.
128 */
130
131/**
132 * Get the register base address of an instance.
133 *
134 * @param dt Instance of pattgen.
135 * @param reg_block The register block requested.
136 * @return The register base address of the requested block.
137 */
138uint32_t dt_pattgen_reg_block(
139 dt_pattgen_t dt,
140 dt_pattgen_reg_block_t reg_block);
141
142/**
143 * Get the primary register base address of an instance.
144 *
145 * This is just a convenience function, equivalent to
146 * `dt_pattgen_reg_block(dt, kDtPattgenRegBlockCore)`
147 *
148 * @param dt Instance of pattgen.
149 * @return The register base address of the primary register block.
150 */
151static inline uint32_t dt_pattgen_primary_reg_block(
152 dt_pattgen_t dt) {
153 return dt_pattgen_reg_block(dt, kDtPattgenRegBlockCore);
154}
155
156/**
157 * Get the PLIC ID of a pattgen IRQ for a given instance.
158 *
159 * If the instance is not connected to the PLIC, this function
160 * will return `kDtPlicIrqIdNone`.
161 *
162 * @param dt Instance of pattgen.
163 * @param irq A pattgen IRQ.
164 * @return The PLIC ID of the IRQ of this instance.
165 */
167 dt_pattgen_t dt,
168 dt_pattgen_irq_t irq);
169
170/**
171 * Convert a global IRQ ID to a local pattgen IRQ type.
172 *
173 * @param dt Instance of pattgen.
174 * @param irq A PLIC ID that belongs to this instance.
175 * @return The pattgen IRQ, or `kDtPattgenIrqCount`.
176 *
177 * **Note:** This function assumes that the PLIC ID belongs to the instance
178 * of pattgen passed in parameter. In other words, it must be the case that
179 * `dt_pattgen_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
180 * will return `kDtPattgenIrqCount`.
181 */
183 dt_pattgen_t dt,
184 dt_plic_irq_id_t irq);
185
186
187/**
188 * Get the alert ID of a pattgen alert for a given instance.
189 *
190 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
191 * instances where the instance is not connected, the return value is unspecified.
192 *
193 * @param dt Instance of pattgen.
194 * @param alert A pattgen alert.
195 * @return The Alert Handler alert ID of the alert of this instance.
196 */
198 dt_pattgen_t dt,
199 dt_pattgen_alert_t alert);
200
201/**
202 * Convert a global alert ID to a local pattgen alert type.
203 *
204 * @param dt Instance of pattgen.
205 * @param alert A global alert ID that belongs to this instance.
206 * @return The pattgen alert, or `kDtPattgenAlertCount`.
207 *
208 * **Note:** This function assumes that the global alert ID belongs to the
209 * instance of pattgen passed in parameter. In other words, it must be the case
210 * that `dt_pattgen_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
211 * this function will return `kDtPattgenAlertCount`.
212 */
214 dt_pattgen_t dt,
215 dt_alert_id_t alert);
216
217
218/**
219 * Get the peripheral I/O description of an instance.
220 *
221 * @param dt Instance of pattgen.
222 * @param sig Requested peripheral I/O.
223 * @return Description of the requested peripheral I/O for this instance.
224 */
226 dt_pattgen_t dt,
228
229/**
230 * Get the clock signal connected to a clock port of an instance.
231 *
232 * @param dt Instance of pattgen.
233 * @param clk Clock port.
234 * @return Clock signal.
235 */
237 dt_pattgen_t dt,
239
240/**
241 * Get the reset signal connected to a reset port of an instance.
242 *
243 * @param dt Instance of pattgen.
244 * @param rst Reset port.
245 * @return Reset signal.
246 */
248 dt_pattgen_t dt,
250
251
252
253#endif // OPENTITAN_DT_PATTGEN_H_