Software APIs
dt_dma.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_DMA_H_
8
#define OPENTITAN_DT_DMA_H_
9
10
/**
11
* @file
12
* @brief Device Tables (DT) for IP dma and top darjeeling.
13
*
14
* This file contains the type definitions and global functions of the dma.
15
*/
16
17
#include "
dt_api.h
"
18
#include <stdint.h>
19
20
/**
21
* List of instances.
22
*/
23
typedef
enum
dt_dma
{
24
kDtDma
= 0,
/**< dma */
25
kDtDmaFirst = 0,
/**< \internal First instance */
26
kDtDmaCount = 1,
/**< \internal Number of instances */
27
}
dt_dma_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_dma_reg_block
{
35
kDtDmaRegBlockCore = 0,
/**< */
36
kDtDmaRegBlockCount = 1,
/**< \internal Number of register blocks */
37
}
dt_dma_reg_block_t
;
38
39
/** Primary register block (associated with the "primary" set of registers that control the IP). */
40
static
const
dt_dma_reg_block_t
kDtDmaRegBlockPrimary = kDtDmaRegBlockCore;
41
42
/**
43
* List of IRQs.
44
*
45
* IRQs are guaranteed to be numbered consecutively from 0.
46
*/
47
typedef
enum
dt_dma_irq
{
48
kDtDmaIrqDmaDone
= 0,
/**< DMA operation has been completed. */
49
kDtDmaIrqDmaChunkDone
= 1,
/**< Indicates the transfer of a single chunk has been completed. */
50
kDtDmaIrqDmaError
= 2,
/**< DMA error has occurred. DMA_STATUS.error_code register shows the details. */
51
kDtDmaIrqCount = 3,
/**< \internal Number of IRQs */
52
}
dt_dma_irq_t
;
53
54
/**
55
* List of Alerts.
56
*
57
* Alerts are guaranteed to be numbered consecutively from 0.
58
*/
59
typedef
enum
dt_dma_alert
{
60
kDtDmaAlertFatalFault
= 0,
/**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
61
kDtDmaAlertCount = 1,
/**< \internal Number of Alerts */
62
}
dt_dma_alert_t
;
63
64
/**
65
* List of clock ports.
66
*
67
* Clock ports are guaranteed to be numbered consecutively from 0.
68
*/
69
typedef
enum
dt_dma_clock
{
70
kDtDmaClockClk
= 0,
/**< Clock port clk_i */
71
kDtDmaClockCount = 1,
/**< \internal Number of clock ports */
72
}
dt_dma_clock_t
;
73
74
/**
75
* List of reset ports.
76
*
77
* Reset ports are guaranteed to be numbered consecutively from 0.
78
*/
79
typedef
enum
dt_dma_reset
{
80
kDtDmaResetRst
= 0,
/**< Reset port rst_ni */
81
kDtDmaResetCount = 1,
/**< \internal Number of reset ports */
82
}
dt_dma_reset_t
;
83
84
85
/**
86
* Get the dma instance from an instance ID
87
*
88
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
89
*
90
* @param inst_id Instance ID.
91
* @return A dma instance.
92
*
93
* **Note:** This function only makes sense if the instance ID has device type dma,
94
* otherwise the returned value is unspecified.
95
*/
96
dt_dma_t
dt_dma_from_instance_id
(
dt_instance_id_t
inst_id);
97
98
/**
99
* Get the instance ID of an instance.
100
*
101
* @param dt Instance of dma.
102
* @return The instance ID of that instance.
103
*/
104
dt_instance_id_t
dt_dma_instance_id
(
dt_dma_t
dt);
105
106
/**
107
* Get the register base address of an instance.
108
*
109
* @param dt Instance of dma.
110
* @param reg_block The register block requested.
111
* @return The register base address of the requested block.
112
*/
113
uint32_t
dt_dma_reg_block
(
114
dt_dma_t
dt,
115
dt_dma_reg_block_t
reg_block);
116
117
/**
118
* Get the primary register base address of an instance.
119
*
120
* This is just a convenience function, equivalent to
121
* `dt_dma_reg_block(dt, kDtDmaRegBlockCore)`
122
*
123
* @param dt Instance of dma.
124
* @return The register base address of the primary register block.
125
*/
126
static
inline
uint32_t dt_dma_primary_reg_block(
127
dt_dma_t
dt) {
128
return
dt_dma_reg_block
(dt, kDtDmaRegBlockCore);
129
}
130
131
/**
132
* Get the PLIC ID of a dma IRQ for a given instance.
133
*
134
* If the instance is not connected to the PLIC, this function
135
* will return `kDtPlicIrqIdNone`.
136
*
137
* @param dt Instance of dma.
138
* @param irq A dma IRQ.
139
* @return The PLIC ID of the IRQ of this instance.
140
*/
141
dt_plic_irq_id_t
dt_dma_irq_to_plic_id
(
142
dt_dma_t
dt,
143
dt_dma_irq_t
irq);
144
145
/**
146
* Convert a global IRQ ID to a local dma IRQ type.
147
*
148
* @param dt Instance of dma.
149
* @param irq A PLIC ID that belongs to this instance.
150
* @return The dma IRQ, or `kDtDmaIrqCount`.
151
*
152
* **Note:** This function assumes that the PLIC ID belongs to the instance
153
* of dma passed in parameter. In other words, it must be the case that
154
* `dt_dma_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
155
* will return `kDtDmaIrqCount`.
156
*/
157
dt_dma_irq_t
dt_dma_irq_from_plic_id
(
158
dt_dma_t
dt,
159
dt_plic_irq_id_t
irq);
160
161
162
/**
163
* Get the alert ID of a dma alert for a given instance.
164
*
165
* **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
166
* instances where the instance is not connected, the return value is unspecified.
167
*
168
* @param dt Instance of dma.
169
* @param alert A dma alert.
170
* @return The Alert Handler alert ID of the alert of this instance.
171
*/
172
dt_alert_id_t
dt_dma_alert_to_alert_id
(
173
dt_dma_t
dt,
174
dt_dma_alert_t
alert);
175
176
/**
177
* Convert a global alert ID to a local dma alert type.
178
*
179
* @param dt Instance of dma.
180
* @param alert A global alert ID that belongs to this instance.
181
* @return The dma alert, or `kDtDmaAlertCount`.
182
*
183
* **Note:** This function assumes that the global alert ID belongs to the
184
* instance of dma passed in parameter. In other words, it must be the case
185
* that `dt_dma_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
186
* this function will return `kDtDmaAlertCount`.
187
*/
188
dt_dma_alert_t
dt_dma_alert_from_alert_id
(
189
dt_dma_t
dt,
190
dt_alert_id_t
alert);
191
192
193
194
/**
195
* Get the clock signal connected to a clock port of an instance.
196
*
197
* @param dt Instance of dma.
198
* @param clk Clock port.
199
* @return Clock signal.
200
*/
201
dt_clock_t
dt_dma_clock
(
202
dt_dma_t
dt,
203
dt_dma_clock_t
clk);
204
205
/**
206
* Get the reset signal connected to a reset port of an instance.
207
*
208
* @param dt Instance of dma.
209
* @param rst Reset port.
210
* @return Reset signal.
211
*/
212
dt_reset_t
dt_dma_reset
(
213
dt_dma_t
dt,
214
dt_dma_reset_t
rst);
215
216
217
218
#endif
// OPENTITAN_DT_DMA_H_
(darjeeling)
hw
top
dt
dt_dma.h
Return to
OpenTitan Documentation