|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ' x3 _- k9 g; j& W4 R! k
- [code]EDMA sample test application! X( v+ V' D3 ~7 T0 r
- /*
# A6 j" Q+ N, A3 v - * edma_test.c; r s+ Z5 M6 O! z
- *
6 ^1 v* w' V7 h% L# v0 |9 v) s, f - * brief EDMA3 Test Application+ q) I6 u: P6 u9 A. f
- */ n5 m" F! |4 P% t- x/ k* U0 p
- * This file contains EDMA3 Test code.; v8 S/ w) N, }: i% {6 o% Q4 `
- *
, ]. d' |+ L7 q" A6 } - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE$ N, S0 \, v& }: }2 s. D. T
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT9 u% a5 [8 p7 A5 T8 c- l
- * TO CHANGE.7 C& Y6 c. p: u: e( ]; T5 A! Z
- * U/ K2 \% M/ b% b+ h, o
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/0 `4 `5 }! A" u7 }5 V
- *
& \0 D3 v- O' p - * This program is free software; you can redistribute it and/or( ]( \/ n9 p( E' |2 g, l: E" t6 F W8 ~
- * modify it under the terms of the GNU General Public License as5 T! O. x/ H* A" h7 r
- * published by the Free Software Foundation version 2.
7 h$ L" z* p2 G - *1 A9 W+ l3 ^/ M/ ~+ @& L% |7 F
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any6 q4 Y0 X! Q( T1 @ c
- * kind, whether express or implied; without even the implied warranty- [' a5 n9 Z2 C$ A* C$ X
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the. Y3 F: G; c- q* S8 l$ m
- * GNU General Public License for more details./ U0 b" Q; a! v
- */0 e, p' `; n+ X3 [
: S% R- u8 Z8 _1 b$ r8 q- #include <linux/module.h>
; o+ S1 j' \5 q( h - #include <linux/init.h># ~( ?0 o, F( t h) m
- #include <linux/errno.h>+ x" ?( C& f3 E4 t; S& x/ z. u
- #include <linux/types.h>
/ p( ], E! p N5 X; P/ \- h# q$ V - #include <linux/interrupt.h>4 \" \" T4 i, H& R
- #include <asm/io.h>, q8 Q/ F, { [2 _9 ?, B x
- #include <linux/moduleparam.h>: o- }+ r: o$ u( e3 [+ L
- #include <linux/sysctl.h>. ]# R, S% T/ m8 t7 w0 E4 d9 F; B, p
- #include <linux/mm.h> s; s& J' u, C. _0 b. ?* a" w$ ^
- #include <linux/dma-mapping.h>6 T( Y/ }1 [+ d7 j2 N
5 U( Q. c9 A( p: k( u1 r1 K- #include <mach/memory.h>
2 j; v' L I3 H" O0 }$ a - #include <mach/hardware.h>
% } j& `# a: F: f - #include <mach/irqs.h>) j% q/ U, B* R: D. u2 v8 q" Y9 f
- #include <asm/hardware/edma.h>
7 d. i* A) E8 m' c& E - ! O e, k6 L* S, ]8 b. r
- #undef EDMA3_DEBUG
2 L5 T( w9 s0 r; {2 U7 `$ \4 ^0 M( @ - /*#define EDMA3_DEBUG*/. B4 q& f. T) n) F) H a4 G; j
- , p$ j3 h' D/ P. K6 d
- #ifdef EDMA3_DEBUG4 q9 \! \( B/ p" l2 H3 A
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
0 ^: a7 M5 e$ H! ?3 S6 b6 O& o - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)# ~# J% P0 v1 M& P1 O6 m- S8 M) _8 I
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
+ g% N: x! n) @( c: f - #else/ ^ y6 A7 N& @* C4 V
- #define DMA_PRINTK( x... )8 p X1 w5 L9 e
- #define DMA_FN_IN8 o, x( F [) c( ^# Q# j) z$ Y
- #define DMA_FN_OUT
/ _) H9 b6 Q; f2 J - #endif
4 m: v: e' j+ R. v' q( G. Q- ] - - o, _; y+ ?8 A. Q# O
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: [* r" D4 M7 G) A - #define STATIC_SHIFT 3: S. w+ g) q! w. r
- #define TCINTEN_SHIFT 205 m! X, a+ j$ X7 q9 ?8 Z
- #define ITCINTEN_SHIFT 219 |" D$ g! X# V0 W
- #define TCCHEN_SHIFT 22
+ X0 t( `; ~5 p7 @- s" x& |: J - #define ITCCHEN_SHIFT 23; T- F2 H) w; ^
- 5 v0 f% N: F! ?, r$ E
- static volatile int irqraised1 = 0;
: f2 R" B3 Z% W- e - static volatile int irqraised2 = 0;9 x/ m$ n7 P0 t6 r$ I) `8 l$ d; I0 l n
/ S( l4 [& v, H6 i5 O- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 ]9 L) X( ~- o, n$ F( X - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( ]* g) s6 {$ V0 K0 L - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# s5 ]! R, T( u) F" H |
& P! j3 h0 u" V0 c/ V8 [- dma_addr_t dmaphyssrc1 = 0;
o7 ]4 Q6 {/ |, \% ` - dma_addr_t dmaphyssrc2 = 0;
* q* ]+ i. s, J0 E" Y/ ? \ - dma_addr_t dmaphysdest1 = 0;
: |& r7 N+ R' [: e G - dma_addr_t dmaphysdest2 = 0;# U% V2 l* v4 V0 Y& D- _' V# C
- ! Z( Z9 X2 ~* G
- char *dmabufsrc1 = NULL;
t3 w* B7 r2 N4 ?! c - char *dmabufsrc2 = NULL;
! ^, W' T" C6 Z - char *dmabufdest1 = NULL;
/ r# i$ { N$ y+ _ - char *dmabufdest2 = NULL;3 n) q: X! C( L( n" Q) j
- ) k- C+ ]+ o! u0 P
- static int acnt = 512;' O/ S' E4 S3 w' b9 [6 G. H
- static int bcnt = 8;- q; Y1 f: F9 T
- static int ccnt = 8;
5 O) V# Z/ f8 F E! X - 3 A- {2 M& p4 M& G9 G0 g
- module_param(acnt, int, S_IRUGO);
. {, s( Z" V$ i. {, f% m/ n/ z% r - module_param(bcnt, int, S_IRUGO);
6 @& r0 {0 o5 k5 U - module_param(ccnt, int, S_IRUGO);
复制代码
, z- K3 p( U/ \ C3 S9 ]' _* U. f- H
. B& B4 _6 s( J2 u 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用$ N& c! h1 q* L' T
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
& I" m3 |+ {- _9 | 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
1 p2 g) J$ o8 W- R: e' [* R- Y( X3 Q3 b1 S
* z/ G1 o1 Z5 L' r* r |
|