|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
: U! m% B1 Y7 I, x Y- p" p1 i- [code]EDMA sample test application
+ P2 o8 V8 {5 K% O - /*8 H% U& k) E9 Q6 Z
- * edma_test.c, f X/ g5 q2 h0 B ~8 c
- *& P( b% O5 O2 D+ i3 [1 s
- * brief EDMA3 Test Application" W& N- \& l* A" p- H4 f
- *$ `% R7 w) ~2 j
- * This file contains EDMA3 Test code.
/ f" T7 ?9 K4 P. N" N - *4 Q6 a7 T) w7 V& P6 W
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
/ [0 F+ F2 y7 N8 [6 _$ ^7 [ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT4 h7 L* ]0 `, d
- * TO CHANGE.! p. P2 l; ^) Q6 h' E
- *6 }5 y. { F, u2 B' Y# T2 ?1 X
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
/ S; f! V. [& m+ E6 a% g# X - *! ?/ Z; k r( y) X. X+ U2 U$ d
- * This program is free software; you can redistribute it and/or
# d& I/ y5 n5 c2 b$ a - * modify it under the terms of the GNU General Public License as a# N, Z/ r# B, l$ `
- * published by the Free Software Foundation version 2.2 J# N5 I, z2 z$ E5 c
- *! b) H1 {9 s- f
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
6 m4 i5 z5 p' g f2 f6 o - * kind, whether express or implied; without even the implied warranty ?8 l$ _- v- Q p: D& ^
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the h$ M. C7 {2 h. h% B3 q
- * GNU General Public License for more details.
1 b( B5 j# g5 b" a, i4 x) ^2 x - */
$ G i2 C+ E* A2 p! J. U
P; ` ~& S9 m. a- #include <linux/module.h>
& g0 d4 X7 m2 A* P0 `+ z - #include <linux/init.h>
$ D4 a1 k4 s& z - #include <linux/errno.h>8 \0 D/ }. q6 T/ e/ a
- #include <linux/types.h>5 u' u7 @! D H% k* O( `! j
- #include <linux/interrupt.h>
( t8 u1 q) ]- r - #include <asm/io.h>
* O9 ]7 m m4 j - #include <linux/moduleparam.h>4 W" p+ g: S9 e9 O& ~* U* L5 Y
- #include <linux/sysctl.h>- f6 ?8 @5 R$ w( A4 y
- #include <linux/mm.h>
( C5 `3 M. [6 C/ k: @; j! ^ - #include <linux/dma-mapping.h>
, K: q9 u- o# J7 g o& V
4 r( v1 G, {' `9 e- #include <mach/memory.h>
2 @% h9 p7 |' M5 k% r$ G: s# I - #include <mach/hardware.h>
/ ^9 ?2 }: f7 ~% X% O/ Q; S$ B - #include <mach/irqs.h>, O$ m9 x0 R( U3 a; [7 C. {" X
- #include <asm/hardware/edma.h>
3 b% S- u/ _( e - % e' s7 q+ ], D) p
- #undef EDMA3_DEBUG
5 B) S0 C- w2 c- c- V" Y( L$ ` - /*#define EDMA3_DEBUG*/
) S# |) p! c7 V# a$ u$ `6 z - ! I! w, v0 l3 ^! h
- #ifdef EDMA3_DEBUG; `7 @8 a' G- ^/ {% [9 m+ b! }
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)& \7 Q9 u2 `7 F4 t8 v! y) W
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)$ {6 x* ^6 B5 I/ B) a$ [+ t) Z' r
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)0 `2 |, J! \( K0 g. E# F& A
- #else0 l, h9 Z& \1 `1 a
- #define DMA_PRINTK( x... )
, h1 ~& o$ a! S0 v* K5 p1 z$ h - #define DMA_FN_IN
3 [- _; v, C3 U) ]4 i) f - #define DMA_FN_OUT2 L: ]4 G0 G+ c- a! G+ b6 H: S7 W0 i$ F
- #endif
+ q( { W" Q' Q. w - $ J( P" \! f& O: e T9 X2 R
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
* ?. Y3 ?& F3 l- \4 @. s1 s - #define STATIC_SHIFT 39 g. X; M/ T) y+ \
- #define TCINTEN_SHIFT 20
& g' C( _+ V: t$ h" L2 {% ^ - #define ITCINTEN_SHIFT 21' J& e/ y! a, C; k a& P) @
- #define TCCHEN_SHIFT 22
, r6 y9 U2 D4 l7 ~" d - #define ITCCHEN_SHIFT 230 V- {' L7 v. o/ m* q
- 0 p* C7 Q% ~& P- V3 m6 {
- static volatile int irqraised1 = 0;
; r+ r) P1 ^& J& p* f: Y f - static volatile int irqraised2 = 0;. e- p/ D/ l" {/ B; b8 m
- : u/ I) s t( Z
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 x3 C% v* I I- K( t4 P# k! i
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! R5 `' ^/ T7 P. u! V% c+ L2 a1 S - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 Q: \! P0 ~- W6 W3 W3 y* {8 Z
: e. t1 y1 p0 [; E- dma_addr_t dmaphyssrc1 = 0;; t5 w M; G# Z2 D+ W
- dma_addr_t dmaphyssrc2 = 0;
: W& ^! S0 Y3 ^% h6 }) @) J2 ` - dma_addr_t dmaphysdest1 = 0;; K# z4 y, `* E0 {6 ?$ z; [" h
- dma_addr_t dmaphysdest2 = 0;
( p" _2 S |0 Q - $ Q7 ^5 ?( k( H+ P, J' E: ?. c4 h' P
- char *dmabufsrc1 = NULL;, S0 b) P7 T1 |3 x3 [3 D% D# l
- char *dmabufsrc2 = NULL;- V& x- e- T3 V% k) `
- char *dmabufdest1 = NULL;* R6 J: A+ x0 L$ Z( K% d
- char *dmabufdest2 = NULL;
( O$ C$ x) L- {+ a2 I8 _ - . [5 n* u- Y1 E
- static int acnt = 512;3 M7 b* C& m& v/ G9 H4 o
- static int bcnt = 8;3 g% J5 I$ ]6 P8 J) `
- static int ccnt = 8;3 x- R; h C P* U
- 9 w$ q) X; }" j8 Y9 S
- module_param(acnt, int, S_IRUGO);
* g8 \" ?2 U( g, n$ A7 @' t - module_param(bcnt, int, S_IRUGO);9 i6 t2 |* Y7 s! x
- module_param(ccnt, int, S_IRUGO);
复制代码 * ]" G3 z; o4 J5 f) M- o L
% ]" E5 J, s% ^# V
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用( e0 q j! D; w
arm-none-linux-gnueabi-gcc -I /home/tl/omapl138/linux-3.3/arch/arm/include -I /home/tl/omapl138/linux-3.3/include EDMA3test.cpp -o EDMA3这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
7 i: `5 U' u* C' S 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。7 H1 i- v" M/ P3 e
7 H1 C$ k7 h# O! x |
2 B# E5 w$ e* V( W0 t
|
|