|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
1 j* Z3 K. H, X9 F- [code]EDMA sample test application- i- U, A3 y k2 w) {0 J+ c
- /*& q& f* P+ d- a( q) M( w
- * edma_test.c
* |; [( t& D6 m) o; E" Y8 ?% k; j8 @ - *) t% e# G: L- r
- * brief EDMA3 Test Application) `3 A' h8 h5 Y1 u0 s; x
- *% H8 L* A$ Q9 [9 j+ Q
- * This file contains EDMA3 Test code.
+ b0 D3 t7 ?% h" ]/ O% j c - *9 ?% N+ e* x# b. M
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
) q; I- M( }7 Y/ w- I8 u; i - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 _5 F' Q# v* b# Q9 u' b- l - * TO CHANGE.' l* V F+ A% c
- *
% V& i+ [0 @/ m/ k0 L - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
7 c% q! D. b0 A8 }& ~( S) t% F - *
2 t( X" F2 e2 ]8 q6 F - * This program is free software; you can redistribute it and/or
+ y& k( Q. @! a1 I$ g - * modify it under the terms of the GNU General Public License as
# a F; |9 F+ h" U) W1 {3 F - * published by the Free Software Foundation version 2./ R( s- o( y" S' M" ?3 n1 M
- *
1 }& E4 [( w T+ f5 C& D' w/ n5 q - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
$ x7 v5 Q0 ?! f3 ]2 f - * kind, whether express or implied; without even the implied warranty: j# L/ H9 x! `; g/ O
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1 V8 ]4 L( d* l# N: C: i - * GNU General Public License for more details.
9 S- Y7 ^: D9 R$ r' v - */
- o$ H; F# A% e, O. d - & |+ t7 i" ?0 r; G1 t( X
- #include <linux/module.h>
t) z8 \; t+ z4 P& d - #include <linux/init.h>
6 W/ _) G: Y0 I! ] - #include <linux/errno.h>' b. m- W5 u7 S( J+ v6 M [
- #include <linux/types.h>8 q( k3 `2 l5 {" N$ v6 f; E
- #include <linux/interrupt.h>9 Y1 b; s: E2 c1 |, R0 \
- #include <asm/io.h>
0 e4 Z7 ]$ Y& ?& h/ m5 B3 K - #include <linux/moduleparam.h>- g9 U0 O: P! [ z+ n7 R
- #include <linux/sysctl.h>
) Q8 k `, |# v! F/ l; {/ i8 R1 d - #include <linux/mm.h>
) K! o- W* M/ v! u. Y- P& c$ ] - #include <linux/dma-mapping.h>1 s/ ?$ |. w' O: E; [
- ) d) s* c! `: e7 q4 p) e: {
- #include <mach/memory.h>
0 D6 M5 X7 O+ q6 ]: F - #include <mach/hardware.h>
0 F3 J* ]% x0 Z" `& f6 Q - #include <mach/irqs.h> h6 d0 l6 Z" F5 {9 X, y! I
- #include <asm/hardware/edma.h>; w/ t; r& _( p7 R# V' H
- 5 J1 ]. e; h; s4 B. k7 x$ G5 D
- #undef EDMA3_DEBUG& z8 h7 }) O4 b9 h" V. p4 {+ ?
- /*#define EDMA3_DEBUG*/2 m6 C3 g% d6 b) s0 w. Y
- , J) L4 O- ~; p
- #ifdef EDMA3_DEBUG9 n; M6 R# _! e1 i& |
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
8 Q. E, c; p2 A& p0 f8 T - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
) {9 B! g& f+ ] - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
8 R* A: t7 M/ N5 |; r- { \6 W - #else9 Z# k }" p9 ^: g- `. P! T
- #define DMA_PRINTK( x... )
/ i, O! z) t6 p* ? - #define DMA_FN_IN% K+ [ d9 c2 Z8 H
- #define DMA_FN_OUT; e& i2 J7 V8 M. r
- #endif3 t( G% U. j/ J0 _; k! U8 o
% l. b8 O# f% M/ h, U- #define MAX_DMA_TRANSFER_IN_BYTES (32768)5 e" }8 W- Y9 K
- #define STATIC_SHIFT 3' B* C: Q+ f$ Q) ?. t" b
- #define TCINTEN_SHIFT 200 A- J# e/ o1 B, M
- #define ITCINTEN_SHIFT 21
5 p; G. k3 T o/ g5 S/ A2 M! z _, D# M - #define TCCHEN_SHIFT 229 E' G% b( x( B& c+ R4 O* o x
- #define ITCCHEN_SHIFT 23
0 c: }6 q) O+ W. U8 B! e - 4 b2 {* |( B7 C' K# n& \
- static volatile int irqraised1 = 0;2 \. x4 @) i5 r7 \
- static volatile int irqraised2 = 0;' m9 @) x. b; y x# a3 s
- ; I/ z# Q1 T: A
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); P" K7 L0 Y- R9 J) v3 F
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 s3 H( ?# ^1 l% n5 a
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 E1 Q" j$ I2 |9 S2 `9 I
. r% }8 _8 k o# {$ i9 \$ A- dma_addr_t dmaphyssrc1 = 0;
7 u* [: }5 J7 R- c% [& o* N - dma_addr_t dmaphyssrc2 = 0;. k3 x; {& a& ~# O u0 `: g
- dma_addr_t dmaphysdest1 = 0;$ i) d; o& I# S
- dma_addr_t dmaphysdest2 = 0;
# ?, _5 S4 Y2 g
" u' d! X, [8 Z4 M9 `0 f2 I- char *dmabufsrc1 = NULL;5 e" k! O& O+ z5 g
- char *dmabufsrc2 = NULL;
" M( d' f6 c% l. B' T# V - char *dmabufdest1 = NULL;$ b2 O4 t- I& g. ?: s1 {( p
- char *dmabufdest2 = NULL;# P9 T' \) V! E. ~6 l1 s Z
3 e* g B' N" N- static int acnt = 512;
* u5 Y. a8 C4 M$ G1 ?) ^ - static int bcnt = 8;
3 f0 K: A& u% A- ?- s3 b - static int ccnt = 8;
9 I! O$ G- A. W# a+ p) I - ) z: i- m/ g$ Z+ G
- module_param(acnt, int, S_IRUGO);
/ _1 R0 ~) {/ i) }* y; x' N - module_param(bcnt, int, S_IRUGO);5 Q b, K* i+ i" R' t: }
- module_param(ccnt, int, S_IRUGO);
复制代码 - |& Z; ?4 w& l z0 L
0 z ^6 r2 T) N$ A) q
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
" ^" R1 Q& ]$ \2 k$ f( U8 ~& Q, ?6 N; f! d7 Tarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。( f; r0 ?# I3 d
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 X H: Y/ g# f! G- T1 b' o _1 Z
$ n' C+ w9 |$ k# l+ e
5 v, A* [7 r& @$ {% d. J, A |
|