|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 \2 K% Y( @+ U9 h; N
- [code]EDMA sample test application
9 Q5 E5 t9 x- s1 o, u& h Q) \ - /*
2 s( p+ G: n* F. [) `" L - * edma_test.c/ m# z$ T$ y, k4 u, u
- *
- V2 a) Z& c3 _ - * brief EDMA3 Test Application) b. p: a) ?+ ^3 k( b% H; L
- *
2 h5 ]2 B% J2 V; \" t5 f1 Z - * This file contains EDMA3 Test code.8 }' p/ W: S" X9 ~$ o
- *
7 l0 p' i: ]( V) Z' U v2 u; e - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE) N6 @0 d& _- Z* V# f, \
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 l# I% p& l: U6 U% j, C - * TO CHANGE.* _) N) X, I. Y) G$ W" Q( x
- *
1 {: U# x5 A$ s M" }+ b" ~! | - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
3 r+ G; i6 [0 Q3 N - *
3 x f. g1 \ v7 K$ f - * This program is free software; you can redistribute it and/or
7 ]! z* q+ S- O+ g - * modify it under the terms of the GNU General Public License as
/ W- Q: w% M/ y5 Q - * published by the Free Software Foundation version 2.
; _3 y4 e/ l9 |7 Q( a - *. f" s* l. w, z+ n# ?4 I% z
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any+ k8 m' m4 {9 Z) @
- * kind, whether express or implied; without even the implied warranty5 \( I" `" L' V, ?& b# y
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% |5 e$ ]: N% t/ G2 {; J
- * GNU General Public License for more details.
5 M' I0 K/ N$ h4 {" _" J, ?1 Y* E - */9 ^4 k+ Y) ]8 p/ |! k: i
- + m* W% U( G) f* m# z0 ]+ D
- #include <linux/module.h>
3 U h3 w2 W; T W - #include <linux/init.h>1 G6 @$ Z: a! v
- #include <linux/errno.h>
" ~3 s0 r( D' ^ - #include <linux/types.h>
C0 g. v7 k j - #include <linux/interrupt.h>
" j! ?: P9 n* ~: F, E4 A M - #include <asm/io.h>
1 ?. s6 ]: e0 O0 q: e0 z# q - #include <linux/moduleparam.h>! f# S. q5 n; U0 s1 R& ?
- #include <linux/sysctl.h>
: l6 n+ P& X4 M) a! z - #include <linux/mm.h>
& U8 q+ k( s$ o" I) B - #include <linux/dma-mapping.h>
. p" t) L$ k; G( H4 f8 M" u0 g
/ t6 x8 Z5 u) E- #include <mach/memory.h>
7 t2 [. t8 S3 o* n8 r - #include <mach/hardware.h>
) L- w! z7 S) K. B9 | - #include <mach/irqs.h>
9 M' G/ u8 n( L4 d - #include <asm/hardware/edma.h>
, D( D, ?3 v; r5 k1 [ - 5 J8 u/ a, u4 B% p* E8 V
- #undef EDMA3_DEBUG0 k) K& S/ z6 Y# ^3 m# l W# e+ R/ I
- /*#define EDMA3_DEBUG*/ h& _/ ^# X' }5 X0 ]1 ]
- 7 q: v( b3 l: [, E% `5 |/ S
- #ifdef EDMA3_DEBUG2 ^' f6 T( b6 K$ _+ q* I
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)% i- z0 q# \8 g, k
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)! }. R% V2 k1 n5 r0 |
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)6 E- ]$ q4 y. V# ?
- #else
# [ A, N" ~* q1 T. d0 L1 _ - #define DMA_PRINTK( x... )+ V, K4 D+ H, O7 _
- #define DMA_FN_IN- U9 K! G3 C' w# _- ?
- #define DMA_FN_OUT
" w W1 O1 z2 h9 d - #endif, c& J2 \3 Y9 M% q( `5 o! U+ a
* g# c! q7 I; Y8 B8 ?- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
6 }0 `5 d5 [* o% ^ - #define STATIC_SHIFT 3+ B8 _' q+ |5 c5 e F2 g
- #define TCINTEN_SHIFT 204 V7 X" A/ H9 d$ R- |' P
- #define ITCINTEN_SHIFT 214 Z% J& a; }5 y
- #define TCCHEN_SHIFT 222 N5 D5 ?/ V c3 d3 F5 R* G* E8 n
- #define ITCCHEN_SHIFT 23
0 m* I$ [' ^* {+ Q
+ k6 N2 \1 |& X# `4 z' D) I2 v- static volatile int irqraised1 = 0;
$ P7 @* G4 d5 b$ G! A, v, c* ] - static volatile int irqraised2 = 0;
3 j7 p& x, k( A( _
& G0 `( F. T) Q- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# R# D. _' s7 `9 ?- j
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, \- [6 p8 |" ]/ j4 | - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. A, V. \6 e, _/ T/ X
1 |9 k& w M+ @4 P- dma_addr_t dmaphyssrc1 = 0;
5 S& E: }$ H: B# r7 U - dma_addr_t dmaphyssrc2 = 0;, ]" D% k/ `! q1 c, s
- dma_addr_t dmaphysdest1 = 0;( D2 p' a% q, a9 r7 Y
- dma_addr_t dmaphysdest2 = 0;, m) d. y6 q% @$ ~4 U
$ I2 W& ~0 }/ F* h4 v/ W- char *dmabufsrc1 = NULL;0 w) x# O5 l' d; g7 l
- char *dmabufsrc2 = NULL;9 P& s4 _8 C0 |4 d) F
- char *dmabufdest1 = NULL;
) o- k( {1 \2 v b8 j3 ] - char *dmabufdest2 = NULL;
6 D6 @; U2 @) Z, x2 y
5 C. x% v+ x5 [9 [0 D g0 m! K4 t- static int acnt = 512;
) H3 @ `8 M- t4 x - static int bcnt = 8;: F* Q3 C7 R9 O( L: Q7 O* |5 K
- static int ccnt = 8;
% K: {5 N; J' b6 y9 T - , Q7 P5 u$ r4 W: f2 f/ i
- module_param(acnt, int, S_IRUGO);
- W ?9 \3 b6 X' B - module_param(bcnt, int, S_IRUGO);
7 x8 o: j6 _# k' s" t" R- c# d - module_param(ccnt, int, S_IRUGO);
复制代码 1 m* ^5 V& k2 X5 @6 }
- _& m* d" z3 y0 }9 q) K( ?
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
0 w2 t: w6 `- P0 @, larm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" g* N5 N( @4 ~
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' ^" o6 D% ^7 F# T$ o3 s- W0 ^ F
; G( y, v, k2 t( P/ n
|
|