|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
0 A8 |: \& O. [* |$ ]3 ?4 j0 h( z- [code]EDMA sample test application* S0 `% l$ s4 z. M0 N
- /** x3 B2 [5 Z2 q7 T8 k) x0 L9 ?! _
- * edma_test.c; ~: y2 I$ T0 N9 b
- *
- E% K: u3 p' q C9 j7 |' } - * brief EDMA3 Test Application
0 ?0 p' z; _& A+ Z - ** y$ X" U& d- h$ e. J* S6 ]
- * This file contains EDMA3 Test code.- g1 K3 Q" e& L
- *4 z3 J5 ^# m* v
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
2 Z# i6 e3 W% g' R - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% O1 ?: B- G& C: ~
- * TO CHANGE.0 k5 _* F- W/ |* U2 X
- *
[: H1 d; ^$ |% L" r) i* w% _ y- N) ~ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
" `5 q0 r5 L6 n: W0 {) g - *' |2 S" ~! n( V% P2 y0 J- \
- * This program is free software; you can redistribute it and/or2 e2 g: `' A0 x6 g0 |# i! i" N& g
- * modify it under the terms of the GNU General Public License as1 k, F8 L+ }2 u1 S" [
- * published by the Free Software Foundation version 2.! t; r+ u# ?% ]6 D
- *6 c& b, Y7 U3 G* E: J0 j/ E
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any+ Z& S0 k+ t" k$ e2 d& v+ ?
- * kind, whether express or implied; without even the implied warranty. E; y' p& B& @5 f
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 X. s& v+ {3 Z
- * GNU General Public License for more details.% z# V4 v6 r0 ^. c
- */- h+ y: ^0 C+ i6 t( d8 C
- " F+ A4 P4 O& I* R8 \2 _! i
- #include <linux/module.h>; _' K9 i0 {' o, d2 U# O
- #include <linux/init.h>, L) C0 D U6 R) b( I
- #include <linux/errno.h>
; \6 Y4 B7 U# _9 l7 h - #include <linux/types.h>
6 b4 q8 ^1 ~* M( j4 o \8 E - #include <linux/interrupt.h>: p& n; B# o: h2 H! q
- #include <asm/io.h>+ s# k2 s8 F0 Z& c# k8 C
- #include <linux/moduleparam.h>2 @; |5 [8 @" U. w" `) c9 \- c
- #include <linux/sysctl.h>3 M7 q' I, P4 d6 X: `
- #include <linux/mm.h>+ X, D0 k: l& m( p9 _% `
- #include <linux/dma-mapping.h>
% R7 u5 C5 C) f0 g8 P* M! ?% R
7 b1 ~# {! e) F6 {1 @- #include <mach/memory.h>
$ h K! {& g2 r/ i% N$ A O - #include <mach/hardware.h>
8 Y% I1 W8 L$ a; m& Z - #include <mach/irqs.h>
( ], P1 b; @& r, z: N u - #include <asm/hardware/edma.h>8 f; N9 x7 G/ \( m& A, }# N
+ O2 x: {; q j- #undef EDMA3_DEBUG6 t: E& p, A/ u! E
- /*#define EDMA3_DEBUG*/$ h' W- |: }- s
8 o" A6 C" j! } G j$ ?) m- #ifdef EDMA3_DEBUG- p6 Q% p& u" n- Y7 m. i+ o
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
" I: z/ D( F. E" T; G - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)2 Z/ K: B& j# t* s( f: R
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
. S2 R4 i0 V( c/ |8 j; F; e - #else/ S2 ^$ i! m- O" W
- #define DMA_PRINTK( x... )
- a. ~$ w' C# p+ b$ V, V& t - #define DMA_FN_IN
( M/ g4 J8 k5 m+ S- E - #define DMA_FN_OUT
3 G0 r" f% e' T0 m* u - #endif
' e5 `; K+ m8 Q; t! M1 F, z; @9 y
- Y& W; b9 y* u3 _- #define MAX_DMA_TRANSFER_IN_BYTES (32768)( \9 G+ w- V) Z
- #define STATIC_SHIFT 3
9 M: G6 w, v1 H) D+ i" ^0 o - #define TCINTEN_SHIFT 20
- S) P7 K- `* ]* X3 X - #define ITCINTEN_SHIFT 21' | B, s) R3 P; D: z! i1 v2 q& k
- #define TCCHEN_SHIFT 22
" S. `( ~; ]/ W) x k- e - #define ITCCHEN_SHIFT 23# n! u6 h5 d, C& o
- , @+ j1 Y- j' m3 J+ D4 e# I
- static volatile int irqraised1 = 0;% [* I3 t! ~& V7 v
- static volatile int irqraised2 = 0;3 Z; ?8 ]; J2 A* O. V3 F' B" T$ |6 q
- 7 B4 V) J/ \# Z" }9 c
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! H& x' x/ O' [" ?6 G f& ^, E/ H, j
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" A5 h# m) x( ]' H$ P - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ J" C- h& V# m
R3 v6 |5 A: }# |! P- dma_addr_t dmaphyssrc1 = 0;8 ]2 s3 V6 E$ }
- dma_addr_t dmaphyssrc2 = 0;0 V% r4 o& O) M) y2 l
- dma_addr_t dmaphysdest1 = 0;& O( `7 O7 }3 Q8 s
- dma_addr_t dmaphysdest2 = 0;& Z+ i" A/ r4 _
- * d& T+ E9 c$ y7 I g, O
- char *dmabufsrc1 = NULL;
3 I8 \$ r5 w' E9 ~ - char *dmabufsrc2 = NULL;$ T6 ~# z/ Q4 x9 }( S9 `' [
- char *dmabufdest1 = NULL;
- x2 E$ P* A( b" S - char *dmabufdest2 = NULL;
& N% \) ?6 m5 f k# }4 ^3 S+ L: V
% ?/ |- \4 o" _0 k7 P" @0 A1 {- static int acnt = 512;
4 n, A. c( T) z8 F/ r4 P - static int bcnt = 8;
/ c. Y' z9 Z; t. H# z8 Y - static int ccnt = 8;
& v5 L! {# g* U" i, U `7 W- _7 F1 r - ' }& T/ z. P$ Z$ ?
- module_param(acnt, int, S_IRUGO);
) P4 j3 ~8 `9 V, D/ H7 z9 s - module_param(bcnt, int, S_IRUGO);5 @+ \$ B7 |( B, `
- module_param(ccnt, int, S_IRUGO);
复制代码 & d3 p" }( k% _8 \' m( _
( D$ I: C7 p3 | 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
' Z5 A, W% d+ ~/ F, W) P& M; X" Sarm-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* G4 Y& l* L4 C' c 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。) m, O# [; }% R5 i
h6 M5 O$ q8 O' q3 j1 |! x- P! ?
, w/ s M3 ]7 \1 @6 H9 ^" r |
|