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
*/
23
typedef
enum
dt_pattgen
{
24
kDtPattgen
= 0,
/**< pattgen */
25
kDtPattgenFirst = 0,
/**< \internal First instance */
26
kDtPattgenCount = 1,
/**< \internal Number of instances */
27
}
dt_pattgen_t
;
28
29
/**
30
* List of register blocks.
31
*
32
* Register blocks are guaranteed to start at 0 and to be consecutively numbered.
33
*/
34
typedef
enum
dt_pattgen_reg_block
{
35
kDtPattgenRegBlockCore = 0,
/**< */
36
kDtPattgenRegBlockCount = 1,
/**< \internal Number of register blocks */
37
}
dt_pattgen_reg_block_t
;
38
39
/** Primary register block (associated with the "primary" set of registers that control the IP). */
40
static
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
*/
47
typedef
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 */
51
}
dt_pattgen_irq_t
;
52
53
/**
54
* List of Alerts.
55
*
56
* Alerts are guaranteed to be numbered consecutively from 0.
57
*/
58
typedef
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 */
61
}
dt_pattgen_alert_t
;
62
63
/**
64
* List of clock ports.
65
*
66
* Clock ports are guaranteed to be numbered consecutively from 0.
67
*/
68
typedef
enum
dt_pattgen_clock
{
69
kDtPattgenClockClk
= 0,
/**< Clock port clk_i */
70
kDtPattgenClockCount = 1,
/**< \internal Number of clock ports */
71
}
dt_pattgen_clock_t
;
72
73
/**
74
* List of reset ports.
75
*
76
* Reset ports are guaranteed to be numbered consecutively from 0.
77
*/
78
typedef
enum
dt_pattgen_reset
{
79
kDtPattgenResetRst
= 0,
/**< Reset port rst_ni */
80
kDtPattgenResetCount = 1,
/**< \internal Number of reset ports */
81
}
dt_pattgen_reset_t
;
82
83
/**
84
* List of peripheral I/O.
85
*
86
* Peripheral I/O are guaranteed to be numbered consecutively from 0.
87
*/
88
typedef
enum
dt_pattgen_periph_io
{
89
kDtPattgenPeriphIoPda0Tx = 0,
/**< */
90
kDtPattgenPeriphIoPcl0Tx = 1,
/**< */
91
kDtPattgenPeriphIoPda1Tx = 2,
/**< */
92
kDtPattgenPeriphIoPcl1Tx = 3,
/**< */
93
kDtPattgenPeriphIoCount = 4,
/**< \internal Number of peripheral I/O */
94
}
dt_pattgen_periph_io_t
;
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
*/
121
dt_pattgen_t
dt_pattgen_from_instance_id
(
dt_instance_id_t
inst_id);
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
*/
129
dt_instance_id_t
dt_pattgen_instance_id
(
dt_pattgen_t
dt);
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
*/
138
uint32_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
*/
151
static
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
*/
166
dt_plic_irq_id_t
dt_pattgen_irq_to_plic_id
(
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
*/
182
dt_pattgen_irq_t
dt_pattgen_irq_from_plic_id
(
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
*/
197
dt_alert_id_t
dt_pattgen_alert_to_alert_id
(
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
*/
213
dt_pattgen_alert_t
dt_pattgen_alert_from_alert_id
(
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
*/
225
dt_periph_io_t
dt_pattgen_periph_io
(
226
dt_pattgen_t
dt,
227
dt_pattgen_periph_io_t
sig);
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
*/
236
dt_clock_t
dt_pattgen_clock
(
237
dt_pattgen_t
dt,
238
dt_pattgen_clock_t
clk);
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
*/
247
dt_reset_t
dt_pattgen_reset
(
248
dt_pattgen_t
dt,
249
dt_pattgen_reset_t
rst);
250
251
252
253
#endif
// OPENTITAN_DT_PATTGEN_H_
(earlgrey)
hw
top
dt
dt_pattgen.h
Return to
OpenTitan Documentation