|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
1 r* P* v0 y q- [code]EDMA sample test application
* B9 H/ x e) W5 R. o0 m i9 x7 l - /*2 o- w. T* K: t; M& u. N- C
- * edma_test.c
: F1 L2 e, N. K& x' } - *
: Q [/ H- i9 Q - * brief EDMA3 Test Application
: r9 u0 s2 N% {0 j - *
6 Y2 _/ Y" B1 _ - * This file contains EDMA3 Test code.
# o# f3 s0 a0 G% K9 a! b) S - *: [! |+ b5 P4 L
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
3 G: y' F- _. G - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
$ q9 K5 n4 v7 o* B( M3 ` - * TO CHANGE." D6 h. E p! y, A
- *# Z0 U! v9 B2 Z4 X' m5 d
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 p: D, `, g4 c$ w) P8 o+ @ - * e8 |. o. S+ x; {1 c
- * This program is free software; you can redistribute it and/or
6 F t. \6 s% v9 u& e2 ~# Y+ J - * modify it under the terms of the GNU General Public License as
9 {) {- i' P. X/ p2 x1 h- r - * published by the Free Software Foundation version 2.
( |: r0 l/ w( L - *
! v* Y' [$ y5 d" z - * This program is distributed "as is" WITHOUT ANY WARRANTY of any& X; c4 P4 n% m- Y5 D# h$ ^
- * kind, whether express or implied; without even the implied warranty& z2 S v0 U6 c2 a& A: p
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4 m9 G+ Q1 f5 L h7 x7 B - * GNU General Public License for more details.
; y, v7 B! d1 Y+ w/ |4 v. y - */; H& x( U( ?- R
- . [- @; R, F+ U
- #include <linux/module.h>
3 E% \( N4 H4 x3 o - #include <linux/init.h>
( w8 }% ~: ]1 [# K3 V6 C/ g6 ] - #include <linux/errno.h>1 c, H7 R8 T1 u( ~! g' ^
- #include <linux/types.h>
4 Z+ e5 E4 `1 o+ L: X - #include <linux/interrupt.h>
# ^ f1 C8 z% q" @4 _1 X - #include <asm/io.h>/ p5 n" [' w2 T/ h9 r! k4 H
- #include <linux/moduleparam.h>, _# H2 _: f5 S, i/ r
- #include <linux/sysctl.h>
8 l& ]3 f6 M/ v$ B) E' g/ [ - #include <linux/mm.h>
+ }, F( I5 Q5 l, R+ v) N) u" |) _; d - #include <linux/dma-mapping.h>6 H" p- B% a4 s
- & m% A- D5 Q- U- u, o
- #include <mach/memory.h>( R- o4 X3 V% H$ r9 v
- #include <mach/hardware.h>
& S6 `0 y2 E |1 ~ - #include <mach/irqs.h>
+ f9 g9 j5 G6 t9 p1 Q - #include <asm/hardware/edma.h>' F7 s7 X1 @( b% c
- ! D' S2 ^5 D! m5 `0 c/ @
- #undef EDMA3_DEBUG( u0 c% `+ D9 ~
- /*#define EDMA3_DEBUG*/
5 a* ?2 C0 _0 N2 `+ k" I5 q
1 ? z3 W8 K' R7 i0 d2 a9 z, _8 ^$ b& M- #ifdef EDMA3_DEBUG* Q6 z& }* T/ K! G3 M
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
" e4 `1 p+ @! q& O) J: O* ? - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
6 u! S/ U: A+ _& ]+ t' g* H - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): j* A& P0 P2 \7 m6 L
- #else
" w0 _5 {8 m) S' F. G- { - #define DMA_PRINTK( x... )
6 X) r9 ]6 ~" E f - #define DMA_FN_IN5 \- F2 r5 A0 t R$ a) X
- #define DMA_FN_OUT
6 N: E; r! s* S( i& l$ o - #endif
8 j; O$ c. t! [- k - . L/ S: s }9 h* w( p( L5 v5 x7 V
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
* P& @" B% W" u0 K - #define STATIC_SHIFT 31 U9 K% B$ k( E% I# ?
- #define TCINTEN_SHIFT 20
% E. t+ y) e1 x1 s* @7 G2 R/ x. | - #define ITCINTEN_SHIFT 21
8 q, g1 q& e5 x& i* y) ` - #define TCCHEN_SHIFT 22. E; o1 Y" t) t
- #define ITCCHEN_SHIFT 23( Y) E0 Y" X+ y9 F) m( L
+ Q5 i+ z C; r& d& h- static volatile int irqraised1 = 0;. H$ i$ r5 X0 [0 r7 O# Z- q
- static volatile int irqraised2 = 0;) Q% ^: W. I! x7 @; R
- / [6 C4 Z0 O. [2 m% [3 ~
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& \! F5 m' d9 _6 _) ] - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# @# H/ f2 z9 U" @# T+ H9 V* q - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 y/ {- e- \' i2 { W f( O/ m P
- $ F& X6 Y- X5 L# C* i
- dma_addr_t dmaphyssrc1 = 0;
* |1 o+ w/ u6 f9 |5 g - dma_addr_t dmaphyssrc2 = 0;; ^2 d1 T. ~+ D* w% N
- dma_addr_t dmaphysdest1 = 0;& S* ~/ G3 A1 |6 Q& K
- dma_addr_t dmaphysdest2 = 0;0 @" _+ \1 ]- L4 c4 y
/ U5 Q/ ?' {* H5 q" d- char *dmabufsrc1 = NULL;
& f9 D3 ~$ I, p0 Z - char *dmabufsrc2 = NULL;
4 r* p: U% \# ^1 X. M - char *dmabufdest1 = NULL;
* A, |6 i n+ d' Y - char *dmabufdest2 = NULL;% n, H. b* J) P, ~, b5 Z
- ' z) r% F+ f- t% J9 H
- static int acnt = 512;
2 F+ r! T0 U" U6 V( t5 L+ T - static int bcnt = 8;
& j3 d- x1 s/ p1 d, O! F+ U - static int ccnt = 8;
+ P) J$ ~+ r5 m# k: Z3 C$ @6 \ - 9 P8 n: t+ k. u d% h
- module_param(acnt, int, S_IRUGO);5 i3 K& w% T- p. f( K6 N
- module_param(bcnt, int, S_IRUGO);* n" Z6 ^3 S6 {6 G' O: O
- module_param(ccnt, int, S_IRUGO);
复制代码 * ]3 K3 \* h! L, S7 D5 \$ u& o* {
7 _+ n7 U- W: Y& B 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 k: x9 p: _) |. t) _- O% [) ^4 parm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
& O5 `& C2 H) ~. \ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。; y |! E) u( T- b. u. f
% x7 S' g8 h7 {/ }
2 ^3 \- s. |; a2 }' e, w( f6 N
|
|