|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( `$ m6 v" _- R8 D( b7 M- [code]EDMA sample test application/ A* K* h5 ^: v# W5 X
- /*, J$ P, [8 Y3 s4 ^! U2 @
- * edma_test.c' ?8 _5 p% q3 G7 y' N; R
- *, m0 ^. H8 n8 |: U" V0 I. Q3 ]: @
- * brief EDMA3 Test Application! w h) c. _6 G3 p$ O q: k& s& I
- *' ~% H& G% h/ F8 a, h2 I
- * This file contains EDMA3 Test code.
* g \1 G+ B- I; n - *0 x2 f2 z# W: m1 `& k# _; |
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" X) w3 S) s* D8 e8 x6 M
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
& K8 K8 J& W3 H! j4 Y/ D" x. ` - * TO CHANGE. n) I+ g# P v7 D
- *
7 M9 U) V% o" p l* F - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 y9 {" Q( Z% w( i, P - *
8 C) ?( T: u7 ~! Y" Y - * This program is free software; you can redistribute it and/or
2 b7 D8 ` E: D2 k. y T7 i" J - * modify it under the terms of the GNU General Public License as
z3 p# r' O1 }4 y+ [, P; F% Q - * published by the Free Software Foundation version 2.
2 ~, ^7 F- H" J4 m - *3 t; J2 ~& Y$ _8 n
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any3 [: Q7 g9 n; q- y. j0 s- F
- * kind, whether express or implied; without even the implied warranty
$ f, F5 R1 s8 B8 m2 u, w - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 g% J- X$ U3 @% \- K% J5 J6 y( S - * GNU General Public License for more details.
& L+ l0 G4 i! t0 s% z, d0 S. A - */4 `* R4 k, b. y: E) V# x/ b
8 _2 n( J( K1 R- #include <linux/module.h>
7 z" a# [- C j3 Y7 W - #include <linux/init.h>2 r9 t; I6 R* @8 \# t
- #include <linux/errno.h>* B% E' e6 n7 j( O
- #include <linux/types.h>
4 l- U9 T- N9 A z T& x - #include <linux/interrupt.h>
( V9 B, l% |; p/ ?4 X - #include <asm/io.h>
' A- @6 b& g2 Y - #include <linux/moduleparam.h>- t. n8 [2 w8 L6 U# s J
- #include <linux/sysctl.h>7 C" q0 y, O, e! M: R. Y
- #include <linux/mm.h>* _- P/ U0 t# i$ ^; [$ X% N
- #include <linux/dma-mapping.h>
; Z. V- a$ [3 P$ J - 2 J& X4 j0 m2 f' L
- #include <mach/memory.h>
& R* |3 A* ]7 W - #include <mach/hardware.h>* w. m7 V6 ?! p* J
- #include <mach/irqs.h>
& p; d& }; m5 b1 u6 z( _) V - #include <asm/hardware/edma.h>
3 i0 \, T/ H# @ - ; y P6 z4 s0 P" g
- #undef EDMA3_DEBUG
; k& I! u" S6 D& J2 A& c- e: ` - /*#define EDMA3_DEBUG*/
9 _! x, S4 W& G- v. x0 a - 6 F' w" c9 B8 O1 E/ a7 p5 b A
- #ifdef EDMA3_DEBUG
* x& B" Z% {( i- B& R$ r5 P$ v4 G% T% G - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)7 H3 E' O' w* p
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 p8 {! x% I4 Q M0 s - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
0 d9 p! p/ a+ H+ }; N - #else4 g* p, a9 F" p, R; \
- #define DMA_PRINTK( x... )
* e3 W% D+ {$ J: V( o* ] - #define DMA_FN_IN
5 W- Y5 k# b4 ?2 O5 X" h) q - #define DMA_FN_OUT
8 n5 P. R0 m5 k/ A: _% H7 l ` [ - #endif
0 M/ H! b( d0 L- j - 4 R, y V* j0 ~5 h# J; U
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, ^* a3 Y+ Q9 \7 o% ^ - #define STATIC_SHIFT 31 l0 I9 S6 d& K$ S/ N
- #define TCINTEN_SHIFT 20
* }, T, e4 e5 k) ~$ K9 Z2 M6 u' V' g - #define ITCINTEN_SHIFT 21
" C0 a5 r/ ~" n2 j) i0 Q2 }1 X1 [ - #define TCCHEN_SHIFT 22+ ~' ]! v" T8 C
- #define ITCCHEN_SHIFT 230 Z* Q/ g+ E# N/ o( @1 m* d
- 4 n" |7 B7 Z: _& P5 E+ \) k
- static volatile int irqraised1 = 0;
1 P1 _0 e' n j - static volatile int irqraised2 = 0;
& \) L* \; S/ P
2 N6 T6 J. c0 C- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 C/ x: R: B; |' @) H/ H
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- Y& |# f4 J( i
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! |) ]8 k! p2 k& c$ M - ( K( \. f w. u: c5 x! y7 q
- dma_addr_t dmaphyssrc1 = 0;& y4 P* i5 j! }; w# [( ]1 W8 C, Q, P5 e
- dma_addr_t dmaphyssrc2 = 0;
. @2 o% f, ?6 u - dma_addr_t dmaphysdest1 = 0;) P4 r1 Z( z* Z* x: |0 s
- dma_addr_t dmaphysdest2 = 0;! C/ n1 q% x: L0 q" m6 L. C
/ P- ~4 |! P6 h2 ]1 ^$ M- char *dmabufsrc1 = NULL;
2 n* M5 _5 ~# v% J - char *dmabufsrc2 = NULL;% B& ^6 q& L `3 [# M7 i
- char *dmabufdest1 = NULL;
$ H. N: A7 H, D+ ~) W - char *dmabufdest2 = NULL;3 {5 P$ k' w9 m6 @ ]/ B
- 5 M; J' }6 m& g/ D7 n
- static int acnt = 512;: s$ u+ W \ U- Z# b6 t
- static int bcnt = 8;! H+ i) O6 T8 O: w! W' O0 g
- static int ccnt = 8;
( _: E" ~& U5 ]& `* M
+ s8 p' a# i/ m( r1 V, Z8 k! d- module_param(acnt, int, S_IRUGO);% M# P3 V8 y7 ~6 U4 X- g- O
- module_param(bcnt, int, S_IRUGO);
. o" T. u9 f5 m' [: O( i - module_param(ccnt, int, S_IRUGO);
复制代码 2 H, q! [$ z$ {0 U9 ?( E
/ @7 V8 d2 y V; v
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用1 @! u' K% D, K- y6 _5 z/ x6 V
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" q d2 @! q" U1 ^0 J
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: T' D5 T1 o; E+ l& |+ Q
" K! Y9 K( x' Z1 \: Y
6 @7 Z4 p9 F i# b& n% Q |
|