|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 * U) h( W' s3 D- A
- [code]EDMA sample test application& V9 }3 w% K- L& D$ [
- /*3 H& k+ g+ s8 e8 U) v6 f" m
- * edma_test.c# z3 B. K* d' r2 y+ }1 j8 D
- *" A! e" p; P, c1 }
- * brief EDMA3 Test Application6 c& D4 N2 }* B! _2 t
- *( K9 h7 ~& P2 c7 c4 {6 K
- * This file contains EDMA3 Test code.# u- k% }3 v `5 j! |: W
- *
. C" n( F2 q. P. d0 z* P; O4 Y - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
5 }. |9 x) _7 h5 p1 J - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
. H4 H* V% ^% F3 q# C- M - * TO CHANGE.
1 m% X9 l) ]2 N, N+ ?1 W - *
7 r! S- G- ?( K/ F m+ R - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
0 C; K4 m9 P8 A0 ^( W$ { - *( I& I& R+ [1 U0 p: `
- * This program is free software; you can redistribute it and/or
e# s# }0 C3 y - * modify it under the terms of the GNU General Public License as. j! m4 i7 S/ b% L# p% X. b
- * published by the Free Software Foundation version 2.
; y% E$ N o5 E- b! o# L+ k+ Z - *' l9 R3 w" d: ]- s& p8 W
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any6 m0 C4 R4 _6 Y* \: N
- * kind, whether express or implied; without even the implied warranty
, r/ x u# M9 E - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4 T& P" w% w% S - * GNU General Public License for more details.4 o7 o0 k# L% r* c7 @
- */
& R# e# [" ?+ H
" A$ v& h/ Z. q4 c- #include <linux/module.h>1 u: t2 w1 G" X! u
- #include <linux/init.h>$ G( R$ x! S/ R3 M1 x& n% `7 f
- #include <linux/errno.h>
5 w2 F6 F S9 P$ L3 f - #include <linux/types.h>2 M( d+ L# Y2 a1 `
- #include <linux/interrupt.h>
) ~" r8 ~! Q* w1 O& e! | - #include <asm/io.h>
' ]2 s$ P3 }2 n6 j- r5 R/ N - #include <linux/moduleparam.h>9 @% f( @ T4 x) J, k
- #include <linux/sysctl.h>
# h9 w/ m4 S5 w# {- E& A) k# V1 { - #include <linux/mm.h>
% h( P: f. W7 a - #include <linux/dma-mapping.h>
2 c& e6 f$ j) u/ G - , o% h8 X1 a3 a/ L
- #include <mach/memory.h>
, R9 D. a; ]: B0 Z& d& p" T5 U - #include <mach/hardware.h>
8 [5 ^/ @7 G& F2 `, k8 W - #include <mach/irqs.h>. l$ R5 C# J9 C2 g, `; k1 B, c
- #include <asm/hardware/edma.h>% ?0 U2 v( m8 n
- 5 D) Y% F9 \* b5 k9 T
- #undef EDMA3_DEBUG* y' s G7 h+ t, \7 b0 N w
- /*#define EDMA3_DEBUG*/& w! G0 m- Z5 d) L# t
- c5 R% v8 @1 V! T
- #ifdef EDMA3_DEBUG
, g+ x. Y; j6 ]. u$ O3 v - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" M9 `- j8 }+ Z+ O: d# e! h! i: c
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. X1 ?* R9 Y0 j$ H* F+ x - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__); o, i7 R% N" {- [; Y
- #else6 Q! }5 n! v. k5 e
- #define DMA_PRINTK( x... )
+ }- [ c& c% @4 W o - #define DMA_FN_IN
5 } U8 D& |, ^ - #define DMA_FN_OUT
3 K3 Z0 M2 S$ u$ S3 K" O/ h+ i" h& z Z - #endif
1 ]+ o6 n5 c1 G - 3 w. p; ?' O; b% V; r9 T5 i
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
_# H2 H" i) S2 _4 I& Q - #define STATIC_SHIFT 36 s5 k: P# j/ `' E+ K+ v
- #define TCINTEN_SHIFT 20
* K0 I0 X1 l) ~; y4 o/ Z - #define ITCINTEN_SHIFT 21
8 ~% t4 i! _% A& X L+ E/ q - #define TCCHEN_SHIFT 22
( |# ^! V+ l2 t5 ? V R/ @ - #define ITCCHEN_SHIFT 23
1 i4 J& L+ b [* R - # G$ q+ C% L& W( {, Y+ Q
- static volatile int irqraised1 = 0;
+ H+ i) c7 {- x+ @+ w - static volatile int irqraised2 = 0;
0 a$ F0 n9 y/ A) j: Z0 g& T - , T, J# O j0 X) |' b
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- _' `: i; k: G& y: A - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& V. f$ a, v3 q! S
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 {0 X r4 H; Z# m7 C
- ( F( l5 ~/ R: y4 X1 m' ^1 R
- dma_addr_t dmaphyssrc1 = 0;9 M- }3 w+ j/ Q5 @4 M
- dma_addr_t dmaphyssrc2 = 0;& l) u' \# ?% t) P8 H$ E
- dma_addr_t dmaphysdest1 = 0;4 V) d7 `# N; {( L
- dma_addr_t dmaphysdest2 = 0;
0 p, a. \2 \3 a q4 @3 Z! n8 b! B
# Y+ @' u. B i- char *dmabufsrc1 = NULL;0 @& V3 V- h3 ]
- char *dmabufsrc2 = NULL;" x! `* F4 r" u$ c5 I7 Y K& q
- char *dmabufdest1 = NULL;
# v1 U( s6 a; Q% i7 c, I2 }0 i. @# s - char *dmabufdest2 = NULL;6 }% ]2 h _9 E. i' _- f" n2 p
- / I. `! I# E& g0 U8 G0 {* \7 |
- static int acnt = 512;# a3 ~6 {0 x8 J. s
- static int bcnt = 8;
$ m/ t& W$ { o; M3 y - static int ccnt = 8;
7 B( A' T3 M6 Y& F - h% X ]" H0 {3 L; M1 o& w
- module_param(acnt, int, S_IRUGO);
; {. G4 A3 Y. V3 L - module_param(bcnt, int, S_IRUGO);% h- O y N0 K g7 T" V% t4 a- s
- module_param(ccnt, int, S_IRUGO);
复制代码
4 ^) v; ]8 y" m; X$ I$ p
# G; D3 M0 {5 I" P" @; Y: R 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
; x' Q+ j# W( harm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# V+ {/ @2 A4 t- x% \( X* F. l
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。0 |7 d3 O D! t- D# w I& [5 R
) }8 U" I5 u: y. n! F5 V: C7 S( ?& \ R# X1 [; N
|
|