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