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