|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 6 v* z |0 E6 o7 Q
- [code]EDMA sample test application0 [6 }7 `0 H9 Q. Q& \$ L9 f3 g) U5 V
- /*. j8 t, j' C' F& i# }0 F
- * edma_test.c
% [1 }2 k1 f# E- p3 y @ - *' ~ r# I: J0 u% @
- * brief EDMA3 Test Application( p, Q& k J9 D9 F
- *1 g' [$ T. S* N
- * This file contains EDMA3 Test code.
- U/ f: M6 I+ F! s) X - *
$ J. Y/ ~7 u4 [1 n N% }$ ~1 K - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE# p& K* A3 ?. Y: a' h* \
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
! F' L" D* q- A - * TO CHANGE.
% o! S2 J' w ~ - *
' r/ H U4 D' s - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/0 C' |' g) x* S4 J4 d3 {: m
- ** M: L# g9 {1 Y3 `* b5 Q- R
- * This program is free software; you can redistribute it and/or1 |/ U( Q y# a! k& @+ P, d* p3 L; k
- * modify it under the terms of the GNU General Public License as w- Z0 x. S: n& B
- * published by the Free Software Foundation version 2.. B, K* _6 U) V0 v/ R: K
- *
+ x% d7 ?9 ], S" `. ~+ [/ N. y4 F0 t. h - * This program is distributed "as is" WITHOUT ANY WARRANTY of any9 x$ @' R3 o6 S, e( w0 M
- * kind, whether express or implied; without even the implied warranty& A6 w, O2 P: H6 i& u
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* ` i0 \( b2 @' m - * GNU General Public License for more details.
0 A2 u( G+ ~+ w- Y0 \3 f' J - */, T6 b6 z4 H- q6 h* o+ A0 m) j: V
0 m' I! n- T0 y/ X- #include <linux/module.h>, f4 F% a: L2 d/ H3 M& g2 M; Q
- #include <linux/init.h>9 J9 M3 T7 r! v3 w6 ?6 h
- #include <linux/errno.h>& r E3 i3 V1 H% X/ {
- #include <linux/types.h>
6 }7 v& f5 J7 P - #include <linux/interrupt.h> G1 @8 z- O! L2 T# @* A+ ~
- #include <asm/io.h>5 K% T" }* U8 T; R. h6 j. Z3 T2 H3 J
- #include <linux/moduleparam.h>+ a4 B/ F. {5 [: L7 s7 N4 u K1 m
- #include <linux/sysctl.h>" Y; d3 A9 W, C7 s _& `' ^
- #include <linux/mm.h>+ n' x5 H' v5 p% [
- #include <linux/dma-mapping.h>7 v! p8 T6 L' Q9 k+ S* t5 v8 Y- c
- 1 M# E- p* `/ ]. o/ w" _
- #include <mach/memory.h>) K4 r* B0 b8 l# n8 T( ~% m$ R% t
- #include <mach/hardware.h>
7 N! V M1 E' {" V& f - #include <mach/irqs.h>
8 H1 _- g% M. O% i& [5 f: n - #include <asm/hardware/edma.h>9 L! B. r [" r. a$ n
7 m2 V) l& v$ E) r" v* e+ z- #undef EDMA3_DEBUG
/ i) Y0 ^ a. V, f - /*#define EDMA3_DEBUG*/
+ d. y% \ o: L3 f& b0 l+ V5 X$ \' J
9 z+ k5 x* C z- #ifdef EDMA3_DEBUG9 w+ [( H X" a+ s+ W
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)+ C( o5 Y+ C/ v
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): e6 A. {+ b$ o
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! l# Y4 h1 `. o! I8 _7 y7 j5 G
- #else
; B1 ]2 z* R: z; ?" p& r; ? - #define DMA_PRINTK( x... )9 N6 U/ x% P5 @, n7 d" [* {; j
- #define DMA_FN_IN
6 ]: _* R& Q# X2 e* T' \ - #define DMA_FN_OUT
' j5 b+ h7 } W2 O2 A! ~ - #endif
q6 m; u H0 O5 V) i2 n
a2 r& `! C- V% j* C5 M7 r4 R; I% s- #define MAX_DMA_TRANSFER_IN_BYTES (32768)6 X+ k& ?, R( U& f
- #define STATIC_SHIFT 3
+ m6 D1 x; K! |, S - #define TCINTEN_SHIFT 20
w7 p, l( S- x% p; p - #define ITCINTEN_SHIFT 21
Z; i& F; @' p' |9 ^* [- q0 { - #define TCCHEN_SHIFT 22
$ K8 }7 Q; }% R @% S; t" V - #define ITCCHEN_SHIFT 237 l! {# w# A* D8 p" ]: S1 j
1 ?* h" Y1 Y$ W% V, P1 {% e+ F- static volatile int irqraised1 = 0;
2 D+ `( y! L9 M. k7 R# B& m9 O - static volatile int irqraised2 = 0;% i" R3 q! O3 D1 C# G( a% A! O
- 1 x+ R' r- b* x( W
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 G* i( X9 `$ Y5 ^9 {8 V
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. j3 V- y. R$ x/ k4 H$ O
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% u. V! C, N ^* q4 T# o
3 d& A3 r7 \- a0 X- dma_addr_t dmaphyssrc1 = 0;. O* M2 }6 j; ]0 Z5 i7 i
- dma_addr_t dmaphyssrc2 = 0;9 e8 I/ |: f0 Q Z/ Q8 s
- dma_addr_t dmaphysdest1 = 0;2 W5 a$ G l6 [# o# h( a
- dma_addr_t dmaphysdest2 = 0;) C8 n( I8 w) P7 ?) D
- " u& l- O. o$ p
- char *dmabufsrc1 = NULL;) w+ |8 A' ?9 m8 Z
- char *dmabufsrc2 = NULL;
& X$ ]# _) E& d4 P. x. f- Y - char *dmabufdest1 = NULL;' v; |+ g# w9 r2 N1 f* ~
- char *dmabufdest2 = NULL;
/ F' T7 f5 T3 Z/ r
$ x6 z# i' n+ _* g5 ` V- static int acnt = 512;
) I: H6 w6 [9 k) {1 R' e& D - static int bcnt = 8;+ \* r* ]& [: ?% c5 R$ f; `1 ?1 C
- static int ccnt = 8;! `+ Y+ ~% E3 b* H
- . y, K# u; F* b, [5 A; ^% _5 M3 H
- module_param(acnt, int, S_IRUGO);- i, T! @' F9 _- n# Z
- module_param(bcnt, int, S_IRUGO);6 Z" Z& u% Q) c* L
- module_param(ccnt, int, S_IRUGO);
复制代码
# W, M* y$ t; {6 U! l: \7 {6 z
' r$ i; E7 P4 h" k7 J 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用* t2 V; z2 r/ }& w4 u( ?" U- `
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
' l9 T) E- }3 k: Y& w" @; I* D 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
0 M x7 j3 T$ W& _; i! ^5 a
) O8 a8 U/ }+ z6 c$ i9 [* n1 N
& G# U; p( V: `% G2 J$ w: G% h2 J/ b |
|