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
#ifdef __cplusplus
11
extern
"C"
{
12
#endif
// __cplusplus
13
14
/**
15
* @file
16
* @brief Device Tables (DT) for IP pattgen and top earlgrey.
17
*
18
* This file contains the type definitions and global functions of the pattgen.
19
*/
20
21
#include "hw/top/dt/dt_api.h"
22
#include <stdint.h>
23
24
25
26
/**
27
* List of instances.
28
*/
29
typedef
enum
dt_pattgen
{
30
kDtPattgen
= 0,
/**< pattgen */
31
kDtPattgenFirst = 0,
/**< \internal First instance */
32
kDtPattgenCount = 1,
/**< \internal Number of instances */
33
}
dt_pattgen_t
;
34
35
/**
36
* List of register blocks.
37
*
38
* Register blocks are guaranteed to start at 0 and to be consecutively numbered.
39
*/
40
typedef
enum
dt_pattgen_reg_block
{
41
kDtPattgenRegBlockCore = 0,
/**< */
42
kDtPattgenRegBlockCount = 1,
/**< \internal Number of register blocks */
43
}
dt_pattgen_reg_block_t
;
44
45
/** Primary register block (associated with the "primary" set of registers that control the IP). */
46
static
const
dt_pattgen_reg_block_t
kDtPattgenRegBlockPrimary = kDtPattgenRegBlockCore;
47
48
/**
49
* List of memories.
50
*
51
* Memories are guaranteed to start at 0 and to be consecutively numbered.
52
*/
53
typedef
enum
dt_pattgen_memory
{
54
kDtPattgenMemoryCount = 0,
/**< \internal Number of memories */
55
}
dt_pattgen_memory_t
;
56
57
/**
58
* List of IRQs.
59
*
60
* IRQs are guaranteed to be numbered consecutively from 0.
61
*/
62
typedef
enum
dt_pattgen_irq
{
63
kDtPattgenIrqDoneCh0
= 0,
/**< raise if pattern generation on Channel 0 is complete */
64
kDtPattgenIrqDoneCh1
= 1,
/**< raise if pattern generation on Channel 1 is complete */
65
kDtPattgenIrqCount = 2,
/**< \internal Number of IRQs */
66
}
dt_pattgen_irq_t
;
67
68
/**
69
* List of Alerts.
70
*
71
* Alerts are guaranteed to be numbered consecutively from 0.
72
*/
73
typedef
enum
dt_pattgen_alert
{
74
kDtPattgenAlertFatalFault
= 0,
/**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
75
kDtPattgenAlertCount = 1,
/**< \internal Number of Alerts */
76
}
dt_pattgen_alert_t
;
77
78
/**
79
* List of clock ports.
80
*
81
* Clock ports are guaranteed to be numbered consecutively from 0.
82
*/
83
typedef
enum
dt_pattgen_clock
{
84
kDtPattgenClockClk
= 0,
/**< Clock port clk_i */
85
kDtPattgenClockCount = 1,
/**< \internal Number of clock ports */
86
}
dt_pattgen_clock_t
;
87
88
/**
89
* List of reset ports.
90
*
91
* Reset ports are guaranteed to be numbered consecutively from 0.
92
*/
93
typedef
enum
dt_pattgen_reset
{
94
kDtPattgenResetRst
= 0,
/**< Reset port rst_ni */
95
kDtPattgenResetCount = 1,
/**< \internal Number of reset ports */
96
}
dt_pattgen_reset_t
;
97
98
/**
99
* List of peripheral I/O.
100
*
101
* Peripheral I/O are guaranteed to be numbered consecutively from 0.
102
*/
103
typedef
enum
dt_pattgen_periph_io
{
104
kDtPattgenPeriphIoPda0Tx = 0,
/**< */
105
kDtPattgenPeriphIoPcl0Tx = 1,
/**< */
106
kDtPattgenPeriphIoPda1Tx = 2,
/**< */
107
kDtPattgenPeriphIoPcl1Tx = 3,
/**< */
108
kDtPattgenPeriphIoCount = 4,
/**< \internal Number of peripheral I/O */
109
}
dt_pattgen_periph_io_t
;
110
111
/**
112
* List of supported hardware features.
113
*/
114
#define OPENTITAN_PATTGEN_HAS_CHANNEL_ONE 1
115
#define OPENTITAN_PATTGEN_HAS_CHANNEL_TWO 1
116
#define OPENTITAN_PATTGEN_HAS_CONFIG_PATTERN 1
117
#define OPENTITAN_PATTGEN_HAS_CONFIG_DIVIDER 1
118
#define OPENTITAN_PATTGEN_HAS_CONFIG_REPEAT 1
119
#define OPENTITAN_PATTGEN_HAS_CONFIG_POLARITY 1
120
#define OPENTITAN_PATTGEN_HAS_CONFIG_INACTIVE_LEVEL 1
121
#define OPENTITAN_PATTGEN_HAS_COMPLETE 1
122
123
124
125
/**
126
* Get the pattgen instance from an instance ID
127
*
128
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
129
*
130
* @param inst_id Instance ID.
131
* @return A pattgen instance.
132
*
133
* **Note:** This function only makes sense if the instance ID has device type pattgen,
134
* otherwise the returned value is unspecified.
135
*/
136
dt_pattgen_t
dt_pattgen_from_instance_id
(
dt_instance_id_t
inst_id);
137
138
/**
139
* Get the instance ID of an instance.
140
*
141
* @param dt Instance of pattgen.
142
* @return The instance ID of that instance.
143
*/
144
dt_instance_id_t
dt_pattgen_instance_id
(
dt_pattgen_t
dt);
145
146
/**
147
* Get the register base address of an instance.
148
*
149
* @param dt Instance of pattgen.
150
* @param reg_block The register block requested.
151
* @return The register base address of the requested block.
152
*/
153
uint32_t
dt_pattgen_reg_block
(
154
dt_pattgen_t
dt,
155
dt_pattgen_reg_block_t
reg_block);
156
157
/**
158
* Get the primary register base address of an instance.
159
*
160
* This is just a convenience function, equivalent to
161
* `dt_pattgen_reg_block(dt, kDtPattgenRegBlockCore)`
162
*
163
* @param dt Instance of pattgen.
164
* @return The register base address of the primary register block.
165
*/
166
static
inline
uint32_t dt_pattgen_primary_reg_block(
167
dt_pattgen_t
dt) {
168
return
dt_pattgen_reg_block
(dt, kDtPattgenRegBlockCore);
169
}
170
171
/**
172
* Get the base address of a memory.
173
*
174
* @param dt Instance of pattgen.
175
* @param mem The memory requested.
176
* @return The base address of the requested memory.
177
*/
178
uint32_t
dt_pattgen_memory_base
(
179
dt_pattgen_t
dt,
180
dt_pattgen_memory_t
mem);
181
182
/**
183
* Get the size of a memory.
184
*
185
* @param dt Instance of pattgen.
186
* @param mem The memory requested.
187
* @return The size of the requested memory.
188
*/
189
uint32_t
dt_pattgen_memory_size
(
190
dt_pattgen_t
dt,
191
dt_pattgen_memory_t
mem);
192
193
/**
194
* Get the PLIC ID of a pattgen IRQ for a given instance.
195
*
196
* If the instance is not connected to the PLIC, this function
197
* will return `kDtPlicIrqIdNone`.
198
*
199
* @param dt Instance of pattgen.
200
* @param irq A pattgen IRQ.
201
* @return The PLIC ID of the IRQ of this instance.
202
*/
203
dt_plic_irq_id_t
dt_pattgen_irq_to_plic_id
(
204
dt_pattgen_t
dt,
205
dt_pattgen_irq_t
irq);
206
207
/**
208
* Convert a global IRQ ID to a local pattgen IRQ type.
209
*
210
* @param dt Instance of pattgen.
211
* @param irq A PLIC ID that belongs to this instance.
212
* @return The pattgen IRQ, or `kDtPattgenIrqCount`.
213
*
214
* **Note:** This function assumes that the PLIC ID belongs to the instance
215
* of pattgen passed in parameter. In other words, it must be the case that
216
* `dt_pattgen_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
217
* will return `kDtPattgenIrqCount`.
218
*/
219
dt_pattgen_irq_t
dt_pattgen_irq_from_plic_id
(
220
dt_pattgen_t
dt,
221
dt_plic_irq_id_t
irq);
222
223
224
/**
225
* Get the alert ID of a pattgen alert for a given instance.
226
*
227
* **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
228
* instances where the instance is not connected, the return value is unspecified.
229
*
230
* @param dt Instance of pattgen.
231
* @param alert A pattgen alert.
232
* @return The Alert Handler alert ID of the alert of this instance.
233
*/
234
dt_alert_id_t
dt_pattgen_alert_to_alert_id
(
235
dt_pattgen_t
dt,
236
dt_pattgen_alert_t
alert);
237
238
/**
239
* Convert a global alert ID to a local pattgen alert type.
240
*
241
* @param dt Instance of pattgen.
242
* @param alert A global alert ID that belongs to this instance.
243
* @return The pattgen alert, or `kDtPattgenAlertCount`.
244
*
245
* **Note:** This function assumes that the global alert ID belongs to the
246
* instance of pattgen passed in parameter. In other words, it must be the case
247
* that `dt_pattgen_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
248
* this function will return `kDtPattgenAlertCount`.
249
*/
250
dt_pattgen_alert_t
dt_pattgen_alert_from_alert_id
(
251
dt_pattgen_t
dt,
252
dt_alert_id_t
alert);
253
254
255
/**
256
* Get the peripheral I/O description of an instance.
257
*
258
* @param dt Instance of pattgen.
259
* @param sig Requested peripheral I/O.
260
* @return Description of the requested peripheral I/O for this instance.
261
*/
262
dt_periph_io_t
dt_pattgen_periph_io
(
263
dt_pattgen_t
dt,
264
dt_pattgen_periph_io_t
sig);
265
266
/**
267
* Get the clock signal connected to a clock port of an instance.
268
*
269
* @param dt Instance of pattgen.
270
* @param clk Clock port.
271
* @return Clock signal.
272
*/
273
dt_clock_t
dt_pattgen_clock
(
274
dt_pattgen_t
dt,
275
dt_pattgen_clock_t
clk);
276
277
/**
278
* Get the reset signal connected to a reset port of an instance.
279
*
280
* @param dt Instance of pattgen.
281
* @param rst Reset port.
282
* @return Reset signal.
283
*/
284
dt_reset_t
dt_pattgen_reset
(
285
dt_pattgen_t
dt,
286
dt_pattgen_reset_t
rst);
287
288
289
290
#ifdef __cplusplus
291
}
// extern "C"
292
#endif
// __cplusplus
293
294
#endif
// OPENTITAN_DT_PATTGEN_H_
(earlgrey)
hw
top
dt
dt_pattgen.h
Return to
OpenTitan Documentation