|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 - f) w! T. z/ [) N7 }5 n. K* X
- [code]EDMA sample test application
) h( L1 P3 P: Y* L: v7 [* Q" x - /*0 R+ ?" K! u* r; g r
- * edma_test.c
8 i G& j* J0 Q! F- G% c( K8 z$ t - *
* _4 V0 ^) \: E2 o5 @+ J/ u - * brief EDMA3 Test Application
0 N8 p& V2 b; N7 _% [4 o$ p% @6 W - *
6 d* c% ^ ~$ K% K- n/ F$ N - * This file contains EDMA3 Test code./ ^3 w5 k+ K7 r3 a, C# ^& q
- *
/ y5 m% ^9 w7 T1 V+ `2 [( }6 U/ K - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
: C: {0 Y. U+ y - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT9 K5 O8 }$ r0 P" P: |9 ?0 L
- * TO CHANGE.
( P* e& g; M. g$ i# i8 A - *! [4 \! G& E6 F2 Q' h
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
6 j: i t3 T T4 _. O - *
1 Q, u; O. g, Z3 e( m2 N; w - * This program is free software; you can redistribute it and/or7 |4 y5 Q" E* q+ f
- * modify it under the terms of the GNU General Public License as
9 e! Q! a C/ ~7 T4 |: k) t - * published by the Free Software Foundation version 2.! i, i0 N5 c4 l) J0 |5 t
- *
7 [; H" m4 X6 d. q* b F. P - * This program is distributed "as is" WITHOUT ANY WARRANTY of any- L( Q( L! S! W/ G; ~! b
- * kind, whether express or implied; without even the implied warranty+ m; R* v- G/ A0 E) e) ^6 [
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the2 H: G1 n1 }1 l! g
- * GNU General Public License for more details.
, D' a$ P( A1 e% i$ ]3 M/ D; c - */9 n+ B5 a7 h+ m @
! M! S7 n X. | G- #include <linux/module.h>( C( j0 s5 m; K. M# p& |
- #include <linux/init.h>) Q4 I4 T3 o, ?& ]
- #include <linux/errno.h>+ S/ D5 z5 k* i+ B
- #include <linux/types.h>
g7 ?4 a, O, _ - #include <linux/interrupt.h>6 G4 t% ^. k* C" u* a6 Y l
- #include <asm/io.h>( X) b0 [/ r% W) N* d' h2 N
- #include <linux/moduleparam.h>
: ?5 y' u% t8 C) @) j8 b - #include <linux/sysctl.h>
0 G3 m8 \4 \8 u; G4 ] - #include <linux/mm.h>( O/ s p, ^. @& n0 h6 d" r
- #include <linux/dma-mapping.h>
0 B6 |- F& U$ p
2 t( E- L2 D* ^- #include <mach/memory.h>
5 L7 [% S8 A9 K$ x0 r( G3 D `+ u - #include <mach/hardware.h>
( l. o8 ~% J4 @. j% |' d' O0 k - #include <mach/irqs.h>
0 F0 ]. u+ q3 L8 |6 P9 P" ~, Z3 J - #include <asm/hardware/edma.h>! S$ l7 U2 }- \3 r
- ; }, ^9 Y8 W2 d7 M
- #undef EDMA3_DEBUG8 ?3 _: n8 o5 I* M0 L$ j
- /*#define EDMA3_DEBUG*/% u' o7 Y. r" ?& B
- 6 Q g# m/ J) a% O9 n: e
- #ifdef EDMA3_DEBUG+ J3 k B1 V$ ] i7 M0 S4 \
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)8 ^ A( U) B4 b5 _9 X
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
& N+ \0 c" I; P: `8 F; N - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
& V/ T' w% g" p5 P( | V. p - #else% C/ {( {$ p2 J! Q% @" W: ?5 a
- #define DMA_PRINTK( x... )2 g% h+ q2 W2 E* b; F- l
- #define DMA_FN_IN
3 J' A/ }$ ]- k - #define DMA_FN_OUT
2 w; _" p3 O0 L, y0 m# x. H/ u - #endif
5 \" Y; h. T, u3 d$ b6 X0 S. q - : u) W( T8 Q3 u; ^1 ~ |9 M. Q
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)* ~3 B; C7 Y' d8 r* w; O/ x/ q$ N- h0 Y% @
- #define STATIC_SHIFT 3. L r, g" X- b5 H
- #define TCINTEN_SHIFT 20
9 p0 Z. M( R1 ~1 D: X - #define ITCINTEN_SHIFT 21
+ r7 L7 q/ b% X4 |! G3 w - #define TCCHEN_SHIFT 22
9 ~+ ^' E: _, X7 E5 m. X K+ Z - #define ITCCHEN_SHIFT 232 y7 g5 c3 O k: t+ L
- / r$ g9 |; M: ~# }
- static volatile int irqraised1 = 0;
2 R6 j. U/ N/ z6 {( s1 f - static volatile int irqraised2 = 0;
. x9 z& {' [! D" h& x, ? - ) n" u( I7 P/ [2 b M3 \
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. U9 J+ f: E" z* N0 ?4 x - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( I) Z$ q5 l+ }0 b" ?: w" f - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 ~& a$ F0 E8 z( _: ?
- 1 @% V) G/ i5 { n, F
- dma_addr_t dmaphyssrc1 = 0;
& X: ^9 x5 `3 i, J - dma_addr_t dmaphyssrc2 = 0;
. n3 @, W) F1 U2 _/ F% I2 s1 }& } - dma_addr_t dmaphysdest1 = 0;
& A1 j: z5 m p' X3 I5 j4 ~: \ - dma_addr_t dmaphysdest2 = 0;
+ z$ ~: y: X* t9 B+ [" s4 O# h1 M/ w; l - * p! p: \0 @& S) ?0 V
- char *dmabufsrc1 = NULL;
- i6 d% e3 F% H9 _ - char *dmabufsrc2 = NULL;/ }0 N* W1 b3 Y
- char *dmabufdest1 = NULL;
- z( }. B! m ^& e. ^8 N4 o2 p r - char *dmabufdest2 = NULL;
; U- u' T0 j- R5 J; l) k, ?
6 v. ?9 S& [& {2 V, r* m- static int acnt = 512;) a+ X! w2 \, b. [3 O+ x+ \. J
- static int bcnt = 8;
v. I: E& j& C - static int ccnt = 8;
0 d2 }0 X( S% P# Q) f* p
! m0 V% z8 W# q6 P6 Z- module_param(acnt, int, S_IRUGO);
8 s4 c2 N( J6 ~0 o9 ` - module_param(bcnt, int, S_IRUGO);
) v S/ s) t2 j6 a9 E2 }# w8 u - module_param(ccnt, int, S_IRUGO);
复制代码 5 G0 H4 w" E0 y9 Y9 L
9 y$ D5 ~9 U; J 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
" o$ H6 c/ @; V P$ y+ T! \# uarm-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 L/ R4 b' O( B; |0 z
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。) w* T% o: M" q
# v- Z5 W& U: R8 e1 E, k- ^* U% \# L6 ]: K' n/ ?( v3 q
|
|