|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, x6 f& U; }( z0 {$ V- [code]EDMA sample test application
+ [+ B) @( E/ o7 T+ U) v! Q - /*" [" [# }1 x. W0 @# ?( }
- * edma_test.c
/ h6 p. F8 e" f7 h/ C3 }3 V0 z: e - *
, _# \: a# c! u - * brief EDMA3 Test Application% F, l R' ~$ F' h6 v. c0 d
- *$ d& E. X) }% `$ t) S8 X
- * This file contains EDMA3 Test code.
4 ]: _, h" Y( v g( x - *
. T0 Y; D+ x0 |( y1 _ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( E) g4 [( z8 |- T, j6 I0 r
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
' S _ ~# S) B- l - * TO CHANGE.
% ^3 f$ I) [5 F; z& O6 d - *5 ]- B# J, e4 ]5 D; Y
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/" M; \% P0 i4 r, r/ a- ]
- *
6 I3 q! M3 x C" b7 w5 d G - * This program is free software; you can redistribute it and/or- f/ O) O5 y! I0 z O& U
- * modify it under the terms of the GNU General Public License as6 D! l' f2 }, I; P% o/ `# g1 J' D
- * published by the Free Software Foundation version 2.
& m6 X0 A4 x0 s; [7 e4 ] - *
$ D- V' a7 n3 u* @7 w3 G - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& B! ^$ f* u. t+ t0 x - * kind, whether express or implied; without even the implied warranty
7 w/ N+ G2 ~8 [; L( O6 W5 G' v' l - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
, F4 q4 G" \5 c4 T5 l - * GNU General Public License for more details./ c' Y. a7 s, Z6 ~* ^& O% m
- */: A* c. k7 d5 R0 {5 \0 e
- 3 G3 z; x- {9 ^" a/ h3 q. w8 {
- #include <linux/module.h>
* v8 E% v" w. g+ _ O1 h - #include <linux/init.h>
' C3 v' a% ~, @3 B - #include <linux/errno.h>
3 D/ R3 N* h4 P! S" S- e( r - #include <linux/types.h>, X/ U/ R: K: E
- #include <linux/interrupt.h>
$ o8 ?& s3 _6 K& v" W2 _1 ] y - #include <asm/io.h>
, k- @ D8 X( T4 Z0 r) T1 M - #include <linux/moduleparam.h>5 B, C: F1 ?9 i" d3 i" H I
- #include <linux/sysctl.h>7 s. h) B* Z( M+ h$ ^
- #include <linux/mm.h>
' w' ?, J0 P. g5 R. N8 |6 C - #include <linux/dma-mapping.h>
& A+ N) f/ N% |& L4 x5 P1 ^& m
g$ Y# f, [* G" W$ G: ?" H- #include <mach/memory.h>
w2 l' N0 z) L - #include <mach/hardware.h>) V& R6 E7 \% @* b8 s4 e
- #include <mach/irqs.h>+ ]( R( w7 G4 G4 q; T3 M5 _( M! f
- #include <asm/hardware/edma.h>- E4 V& T) f4 Q$ h' R$ z
! ^' F% Y6 ], s' e- #undef EDMA3_DEBUG
2 ~7 f0 l' @; c6 g# m5 V - /*#define EDMA3_DEBUG*/( K% _- |: N( {; T# t# R- d
- ^5 T5 U3 j& x- f
- #ifdef EDMA3_DEBUG
) W5 |- B0 A. N. \) J$ y( r - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
7 l9 n5 j% V+ w9 g' r- }+ x3 J - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
& F' X; l# C7 z: m5 I+ I - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* X6 n6 B5 o' ^& e
- #else
9 N+ U5 M' ^( S* z* Q' |/ f2 ] - #define DMA_PRINTK( x... )
2 C" [5 W8 o( b) M- n: w; r' h7 E - #define DMA_FN_IN
' g. e1 h& a# w4 k, @) x - #define DMA_FN_OUT
0 B6 G4 d& t& l+ I3 Y5 t0 e - #endif
/ x) Q: F( h& s+ ~* r
# Y4 F. B9 x x5 ?% h7 n9 Q- #define MAX_DMA_TRANSFER_IN_BYTES (32768)' Q: W k2 s ]8 Q- }8 w
- #define STATIC_SHIFT 3
1 p: h+ A7 {: l( j- s( T' Y) C9 F - #define TCINTEN_SHIFT 20
" C( m+ Z* O% | - #define ITCINTEN_SHIFT 21
0 B$ f5 j9 J% @4 y! K. O3 H: o: R - #define TCCHEN_SHIFT 22
8 l \7 g9 v' k& s - #define ITCCHEN_SHIFT 23. `+ d# ]* Q7 d4 u* Z
- 4 v: \! q. }8 G' @0 N
- static volatile int irqraised1 = 0;
1 [( `5 A: `+ h2 i( m! C - static volatile int irqraised2 = 0;
9 Z ]2 B7 u* P# g; l' ]
& k* a( r2 E; a7 `/ a- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 {; a; G9 n' n0 C4 _
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 ]5 N+ q1 F( I% Y. _
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 b& Y$ \3 p/ A( I) v/ N8 y
7 r3 n' u4 H5 P1 X D- dma_addr_t dmaphyssrc1 = 0;
& J$ K4 M# l5 j9 `7 L7 f4 \ - dma_addr_t dmaphyssrc2 = 0;
& W/ Z. ~# z6 d; M8 ` - dma_addr_t dmaphysdest1 = 0;! l6 Y c8 w: z: ] ]
- dma_addr_t dmaphysdest2 = 0;/ k4 q* J- l8 L( y3 U
! V$ O5 t3 `+ r- char *dmabufsrc1 = NULL;
7 x" v: h9 ? } - char *dmabufsrc2 = NULL;
( {/ X7 y+ W3 }2 ^* [ - char *dmabufdest1 = NULL;
+ r- J: [- w$ `1 \, N' m - char *dmabufdest2 = NULL;/ K- ~' C. J) i
- " w. N8 C) l& O$ N/ O! G4 ?% {
- static int acnt = 512;
2 e: S$ T6 V' I2 l' {% O; d9 P - static int bcnt = 8;
. Q8 ] Z: T3 h9 N1 n1 K7 M - static int ccnt = 8;8 J, J6 `. A5 S9 \' J+ ], x
: ?! @' W9 F# u: `- module_param(acnt, int, S_IRUGO);- z& \4 y# \/ ]
- module_param(bcnt, int, S_IRUGO);
+ h$ G/ v* l& A( e - module_param(ccnt, int, S_IRUGO);
复制代码
}, n/ e3 ?7 w+ P; d2 t. o$ e6 V0 j
2 Y& M, t) h0 T4 b3 a 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
* ]! B5 A* p" u3 ~ ~" x& narm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。/ m: |$ E% u/ t' m# g
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
) |9 f( Z& g7 r; l$ G) v$ X3 I7 m& ^ r. N+ k& V4 G5 Q( i. ?: o4 l; x& q
. d1 r) r ^, D6 x' f8 ]& F
|
|