1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
/*
* mvf_edma.h - mvf eDMA driver header file.
*
* Copyright 2008-2012 Freescale Semiconductor, Inc. All Rights Reserved.
*
* Add support for mvf platform (Lanttor.Guo@freescale.com)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*/
#ifndef _MCF_EDMA_H
#define _MCF_EDMA_H
#include <linux/interrupt.h>
#include <asm/mvf_edma_regs.h>
#include <linux/scatterlist.h>
#define DMA_MODE_READ 0
#define DMA_MODE_WRITE 1
#define DMA_MODE_MASK 1
#define MCF_EDMA_INT0_CHANNEL_BASE (8)
#define MCF_EDMA_INT0_CONTROLLER_BASE (64)
#define MCF_EDMA_INT0_BASE (MCF_EDMA_INT0_CHANNEL_BASE + MCF_EDMA_INT0_CONTROLLER_BASE)
#define MCF_EDMA_INT0_NUM (16)
#define MCF_EDMA_INT0_END (MCF_EDMA_INT0_NUM)
#define MCF_EDMA_INT1_CHANNEL_BASE (8)
#define MCF_EDMA_INT1_CONTROLLER_BASE (128)
#define MCF_EDMA_INT1_BASE (MCF_EDMA_INT1_CHANNEL_BASE + MCF_EDMA_INT1_CONTROLLER_BASE)
#define MCF_EDMA_INT1_NUM (40)
#define MCF_EDMA_INT1_END (MCF_EDMA_INT0_END + MCF_EDMA_INT1_NUM)
#define MCF_EDMA_INT2_CHANNEL_BASE (0)
#define MCF_EDMA_INT2_CONTROLLER_BASE (192)
#define MCF_EDMA_INT2_BASE (MCF_EDMA_INT2_CHANNEL_BASE + MCF_EDMA_INT2_CONTROLLER_BASE)
#define MCF_EDMA_INT2_NUM (8)
#define MCF_EDMA_INT2_END (MCF_EDMA_INT1_END + MCF_EDMA_INT2_NUM)
#define MCF_EDMA_CHANNEL_ANY (0xFF)
#define MCF_EDMA_INT_ERR (16) /* edma error interrupt */
#define MCF_EDMA_TCD_PER_CHAN 256
#define MVF_EACH_DMA_CHANNEL 32
/* Setup transfer control descriptor (TCD)
* channel - descriptor number
* source - source address
* dest - destination address
* attr - attributes
* soff - source offset
* nbytes - number of bytes to be transfered in minor loop
* slast - last source address adjustment
* citer - major loop count
* biter - begining minor loop count
* doff - destination offset
* dlast_sga - last destination address adjustment
* major_int - generate interrupt after each major loop
* disable_req - disable DMA request after major loop
*/
#if 0
void mvf_edma_set_tcd_params(int channel, u32 source, u32 dest,
u32 attr, u32 soff, u32 nbytes, u32 slast,
u32 citer, u32 biter, u32 doff, u32 dlast_sga,
int major_int, int disable_req);
#endif
/* Setup transfer control descriptor (TCD) and enable halfway irq
* channel - descriptor number
* source - source address
* dest - destination address
* attr - attributes
* soff - source offset
* nbytes - number of bytes to be transfered in minor loop
* slast - last source address adjustment
* biter - major loop count
* doff - destination offset
* dlast_sga - last destination address adjustment
* disable_req - disable DMA request after major loop
*/
void mvf_edma_set_tcd_params_halfirq(int channel, u32 source, u32 dest,
u32 attr, u32 soff, u32 nbytes, u32 slast,
u32 biter, u32 doff, u32 dlast_sga,
int disable_req);
/* check if dma is done
* channel - descriptor number
* return 1 if done
*/
int mvf_edma_check_done(int channel);
#if 0
/* Starts eDMA transfer on specified channel
* channel - eDMA TCD number
*/
static inline void
mvf_edma_start_transfer(int channel)
{
MCF_EDMA_SERQ = channel;
MCF_EDMA_SSRT = channel;
}
/* Restart eDMA transfer from halfirq
* channel - eDMA TCD number
*/
static inline void
mvf_edma_confirm_halfirq(int channel)
{
/*MCF_EDMA_TCD_CSR(channel) = 7;*/
MCF_EDMA_SSRT = channel;
}
/* Starts eDMA transfer on specified channel based on peripheral request
* channel - eDMA TCD number
*/
static inline void mvf_edma_enable_transfer(int channel)
{
MCF_EDMA_SERQ = channel;
}
/* Stops eDMA transfer
* channel - eDMA TCD number
*/
static inline void
mvf_edma_stop_transfer(int channel)
{
MCF_EDMA_CINT = channel;
MCF_EDMA_CERQ = channel;
}
/* Confirm that interrupt has been handled
* channel - eDMA TCD number
*/
static inline void
mvf_edma_confirm_interrupt_handled(int channel)
{
MCF_EDMA_CINT = channel;
}
#endif
/**
* mvf_edma_request_channel - Request an eDMA channel
* @channel: channel number. In case it is equal to EDMA_CHANNEL_ANY
* it will be allocated a first free eDMA channel.
* @handler: dma handler
* @error_handler: dma error handler
* @irq_level: irq level for the dma handler
* @arg: argument to pass back
* @lock: optional spinlock to hold over interrupt
* @device_id: device id
*
* Returns allocatedd channel number if success or
* a negative value if failure.
*/
int mvf_edma_request_channel(int channel,
irqreturn_t(*handler) (int, void *),
void (*error_handler) (int, void *),
u8 irq_level,
void *arg,
spinlock_t *lock, const char *device_id);
/**
* Update the channel callback/arg
* @channel: channel number
* @handler: dma handler
* @error_handler: dma error handler
* @arg: argument to pass back
*
* Returns 0 if success or a negative value if failure
*/
int mvf_edma_set_callback(int channel,
irqreturn_t(*handler) (int, void *),
void (*error_handler) (int, void *), void *arg);
/**
* Free the edma channel
* @channel: channel number
* @arg: argument created with
*
* Returns 0 if success or a negative value if failure
*/
int mvf_edma_free_channel(int channel, void *arg);
void mvf_edma_dump_channel(int channel);
#endif /* _MCF_EDMA_H */
|