Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
awilliam
GitHub Repository: awilliam/linux-vfio
Path: blob/master/arch/arm/mach-ep93xx/include/mach/dma.h
15157 views
1
/**
2
* DOC: EP93xx DMA M2P memory to peripheral and peripheral to memory engine
3
*
4
* The EP93xx DMA M2P subsystem handles DMA transfers between memory and
5
* peripherals. DMA M2P channels are available for audio, UARTs and IrDA.
6
* See chapter 10 of the EP93xx users guide for full details on the DMA M2P
7
* engine.
8
*
9
* See sound/soc/ep93xx/ep93xx-pcm.c for an example use of the DMA M2P code.
10
*
11
*/
12
13
#ifndef __ASM_ARCH_DMA_H
14
#define __ASM_ARCH_DMA_H
15
16
#include <linux/list.h>
17
#include <linux/types.h>
18
19
/**
20
* struct ep93xx_dma_buffer - Information about a buffer to be transferred
21
* using the DMA M2P engine
22
*
23
* @list: Entry in DMA buffer list
24
* @bus_addr: Physical address of the buffer
25
* @size: Size of the buffer in bytes
26
*/
27
struct ep93xx_dma_buffer {
28
struct list_head list;
29
u32 bus_addr;
30
u16 size;
31
};
32
33
/**
34
* struct ep93xx_dma_m2p_client - Information about a DMA M2P client
35
*
36
* @name: Unique name for this client
37
* @flags: Client flags
38
* @cookie: User data to pass to callback functions
39
* @buffer_started: Non NULL function to call when a transfer is started.
40
* The arguments are the user data cookie and the DMA
41
* buffer which is starting.
42
* @buffer_finished: Non NULL function to call when a transfer is completed.
43
* The arguments are the user data cookie, the DMA buffer
44
* which has completed, and a boolean flag indicating if
45
* the transfer had an error.
46
*/
47
struct ep93xx_dma_m2p_client {
48
char *name;
49
u8 flags;
50
void *cookie;
51
void (*buffer_started)(void *cookie,
52
struct ep93xx_dma_buffer *buf);
53
void (*buffer_finished)(void *cookie,
54
struct ep93xx_dma_buffer *buf,
55
int bytes, int error);
56
57
/* private: Internal use only */
58
void *channel;
59
};
60
61
/* DMA M2P ports */
62
#define EP93XX_DMA_M2P_PORT_I2S1 0x00
63
#define EP93XX_DMA_M2P_PORT_I2S2 0x01
64
#define EP93XX_DMA_M2P_PORT_AAC1 0x02
65
#define EP93XX_DMA_M2P_PORT_AAC2 0x03
66
#define EP93XX_DMA_M2P_PORT_AAC3 0x04
67
#define EP93XX_DMA_M2P_PORT_I2S3 0x05
68
#define EP93XX_DMA_M2P_PORT_UART1 0x06
69
#define EP93XX_DMA_M2P_PORT_UART2 0x07
70
#define EP93XX_DMA_M2P_PORT_UART3 0x08
71
#define EP93XX_DMA_M2P_PORT_IRDA 0x09
72
#define EP93XX_DMA_M2P_PORT_MASK 0x0f
73
74
/* DMA M2P client flags */
75
#define EP93XX_DMA_M2P_TX 0x00 /* Memory to peripheral */
76
#define EP93XX_DMA_M2P_RX 0x10 /* Peripheral to memory */
77
78
/*
79
* DMA M2P client error handling flags. See the EP93xx users guide
80
* documentation on the DMA M2P CONTROL register for more details
81
*/
82
#define EP93XX_DMA_M2P_ABORT_ON_ERROR 0x20 /* Abort on peripheral error */
83
#define EP93XX_DMA_M2P_IGNORE_ERROR 0x40 /* Ignore peripheral errors */
84
#define EP93XX_DMA_M2P_ERROR_MASK 0x60 /* Mask of error bits */
85
86
/**
87
* ep93xx_dma_m2p_client_register - Register a client with the DMA M2P
88
* subsystem
89
*
90
* @m2p: Client information to register
91
* returns 0 on success
92
*
93
* The DMA M2P subsystem allocates a channel and an interrupt line for the DMA
94
* client
95
*/
96
int ep93xx_dma_m2p_client_register(struct ep93xx_dma_m2p_client *m2p);
97
98
/**
99
* ep93xx_dma_m2p_client_unregister - Unregister a client from the DMA M2P
100
* subsystem
101
*
102
* @m2p: Client to unregister
103
*
104
* Any transfers currently in progress will be completed in hardware, but
105
* ignored in software.
106
*/
107
void ep93xx_dma_m2p_client_unregister(struct ep93xx_dma_m2p_client *m2p);
108
109
/**
110
* ep93xx_dma_m2p_submit - Submit a DMA M2P transfer
111
*
112
* @m2p: DMA Client to submit the transfer on
113
* @buf: DMA Buffer to submit
114
*
115
* If the current or next transfer positions are free on the M2P client then
116
* the transfer is started immediately. If not, the transfer is added to the
117
* list of pending transfers. This function must not be called from the
118
* buffer_finished callback for an M2P channel.
119
*
120
*/
121
void ep93xx_dma_m2p_submit(struct ep93xx_dma_m2p_client *m2p,
122
struct ep93xx_dma_buffer *buf);
123
124
/**
125
* ep93xx_dma_m2p_submit_recursive - Put a DMA transfer on the pending list
126
* for an M2P channel
127
*
128
* @m2p: DMA Client to submit the transfer on
129
* @buf: DMA Buffer to submit
130
*
131
* This function must only be called from the buffer_finished callback for an
132
* M2P channel. It is commonly used to add the next transfer in a chained list
133
* of DMA transfers.
134
*/
135
void ep93xx_dma_m2p_submit_recursive(struct ep93xx_dma_m2p_client *m2p,
136
struct ep93xx_dma_buffer *buf);
137
138
/**
139
* ep93xx_dma_m2p_flush - Flush all pending transfers on a DMA M2P client
140
*
141
* @m2p: DMA client to flush transfers on
142
*
143
* Any transfers currently in progress will be completed in hardware, but
144
* ignored in software.
145
*
146
*/
147
void ep93xx_dma_m2p_flush(struct ep93xx_dma_m2p_client *m2p);
148
149
#endif /* __ASM_ARCH_DMA_H */
150
151