|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 + m1 Y& m. V. K8 ~$ x" s
- [code]EDMA sample test application
% G' |1 y9 Z. z: z - /*! M( _5 [( P& M% p
- * edma_test.c) `5 | M, `- y, K" F: R
- *8 w9 G; ?, Q0 i0 G& Q
- * brief EDMA3 Test Application
& N6 r$ f, |! E' u) X - *
& l$ M: U( x& i8 U* Z. W4 H - * This file contains EDMA3 Test code.
* M4 f# R5 d8 f9 e* `/ y. v6 U: t/ m - *
; t/ W5 Y% m( B9 ]6 m/ E* n - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
! o$ N8 `3 b- `& ]0 s' ]# ^ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
' F! R) h0 W1 @) y9 m" T' L3 W - * TO CHANGE.1 z$ l0 G- y4 l: o9 _
- * U0 {% u& W2 ~: k$ k! a
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
( c" ]' v( ~2 O2 G3 G$ h' b - *& N, Y( p& C) T) H- }
- * This program is free software; you can redistribute it and/or) Y! p/ S( x0 ]/ ~- [
- * modify it under the terms of the GNU General Public License as
7 T5 h7 o$ C; K3 d4 ? - * published by the Free Software Foundation version 2.9 I; ]- w8 g1 u4 ?* J
- *, H! n; M2 f8 X4 h# J
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 q5 V" W- P* v* ~9 L
- * kind, whether express or implied; without even the implied warranty
a( I- a5 r# r& g- {" D - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! l& F4 ]8 G9 n3 l" ~1 b' j1 r2 f5 u - * GNU General Public License for more details., X# [: Z0 p- d# f1 B5 z
- */
3 |- I5 ^6 r% W0 M8 q
5 x& S5 _. {7 r' ~- #include <linux/module.h>8 k7 {1 } L8 `# Z& q ?
- #include <linux/init.h>8 |. j: F6 @+ w" P N
- #include <linux/errno.h>
M: }6 d+ G# M5 W - #include <linux/types.h>5 ], L" i. s; C) J7 ^3 I, I
- #include <linux/interrupt.h>: R& g- Q" w" u( L) T
- #include <asm/io.h>
/ J7 a) r0 g4 R1 K - #include <linux/moduleparam.h>9 @& m+ f! v$ S
- #include <linux/sysctl.h>: V, L+ }1 {% F1 h( N
- #include <linux/mm.h> a! o7 Z3 }4 W7 H6 R$ d+ N
- #include <linux/dma-mapping.h>& \1 K% ]3 h) m
- 6 E4 f1 Z+ N$ Y% M/ z+ b
- #include <mach/memory.h>. ^! C6 @/ S! E# ^+ |' n
- #include <mach/hardware.h>
7 e4 o4 u7 l& ?! [# k - #include <mach/irqs.h>
. }) [1 D- N5 A& [5 u c& l" W0 x - #include <asm/hardware/edma.h>( M0 T3 l \% u; S
- 2 ^4 i* f* r, q3 K. j' u
- #undef EDMA3_DEBUG3 }. k% Z u& S2 M c0 S: g. i+ I9 c( i
- /*#define EDMA3_DEBUG*/. L; ]; K3 M2 o
/ D8 ?- _) r( F4 E- #ifdef EDMA3_DEBUG( `4 t3 R5 [3 b2 h2 f2 `, o$ j
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; m. H, a5 o% U4 ~" E - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
# Q3 n, n$ k/ y7 W2 v - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
+ S0 @/ p9 J, S: h2 e. j% g - #else
2 W6 G8 R2 c, v - #define DMA_PRINTK( x... )- U6 B: w! x1 K& g2 c- E
- #define DMA_FN_IN% {: B, s9 c) O, ?
- #define DMA_FN_OUT
/ p& f* D& Z4 G( {+ A x1 N - #endif3 C3 e8 {! f3 R2 ~5 B, M$ M
' U% Y* O; n- z8 Z% h( z$ w- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, X" X: J8 E: b0 e8 ^5 i4 h - #define STATIC_SHIFT 3/ w3 c1 O. I: |( s
- #define TCINTEN_SHIFT 20
" ~# V, R4 Q+ V v0 \ - #define ITCINTEN_SHIFT 21
' `# Z+ i# C! \" o! }+ n, m' x - #define TCCHEN_SHIFT 221 ^# s; p+ U$ H( k. k
- #define ITCCHEN_SHIFT 23
! H( E6 w+ R* J& K& y4 T$ M- | - 8 G @, R3 T. I1 R8 N6 n7 U! t
- static volatile int irqraised1 = 0;0 J; d! D% _4 _' ^& G1 I) V
- static volatile int irqraised2 = 0;
8 S5 P# A7 l0 s" x( ~2 n, Y - . {! C" s# X7 w& E4 r
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: U! @2 X6 Y% f
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 R5 [4 s1 {. }+ L8 H: }3 E - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ q( ]7 z7 b8 P+ H2 J# K0 _
7 m) F0 `- z5 A- j, y0 U- dma_addr_t dmaphyssrc1 = 0;
# R0 ^. n6 m4 @ - dma_addr_t dmaphyssrc2 = 0;
f6 l. B" J8 |/ x - dma_addr_t dmaphysdest1 = 0;! r! g: ~2 ?# A- L& Y+ C9 }
- dma_addr_t dmaphysdest2 = 0;" c& |* e/ l: v5 t5 w" L
. e& B& @" v9 z% a6 V& z- char *dmabufsrc1 = NULL;" ]6 f9 c- h4 H+ \4 I0 n8 }5 ^
- char *dmabufsrc2 = NULL;
# h9 S/ S7 N# z - char *dmabufdest1 = NULL;
" a1 L" z0 x, c1 a) j; B# |, ?4 ? - char *dmabufdest2 = NULL;
k$ w" W d1 Y - , _( `) t/ W0 W/ \8 o- R4 K+ ^
- static int acnt = 512;+ a1 J/ a u" n, r5 S
- static int bcnt = 8;' q- D) s# l0 g. W) B
- static int ccnt = 8;" p0 `+ C; E1 o; s1 J3 V& R p/ E
8 ~9 l3 L0 ]/ Y( u# Y2 ]. N- module_param(acnt, int, S_IRUGO);9 P; m2 }4 a8 H6 t2 W
- module_param(bcnt, int, S_IRUGO);
! w& V4 W, `6 y5 J9 E - module_param(ccnt, int, S_IRUGO);
复制代码
$ p! E, S7 @; c& D# I1 @1 i+ \; H0 d, i" I; m) J0 W3 k H
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用7 T6 G" M9 w1 `) x
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。) H v0 v m: s9 O2 _* I" a1 W" Q$ b
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。" k; b& r- d. d1 _+ g+ U
, u9 `0 A0 p8 Y( r! w/ l
% e! Z/ r1 z& k6 v* ? |
|