|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 G* ]& }8 p' s7 I6 o; L$ r0 f- [code]EDMA sample test application
& q: m" y- M8 b4 U: `* \' V - /*3 G1 X. t. d0 `( o
- * edma_test.c* o4 M G3 B( {9 g( z! R
- *$ G8 f5 D1 @4 a+ S6 Q
- * brief EDMA3 Test Application
/ e) w* K" V) D, Y$ B% p - *
) T0 B1 H! r1 B8 L6 j9 C - * This file contains EDMA3 Test code.
3 B+ W, r& m# }5 L! ^ - *
3 s. H/ ?+ Q4 X - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE0 ?- i) F" e6 K+ L; i9 N
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 Y. u2 F4 `" l. u: E4 k
- * TO CHANGE.
# U+ T: F k! ?* O9 U - *
& n" N9 o& P; m% i - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/3 ^: F6 [( V* Z; a! m+ ?
- *
4 A! @0 q$ A$ j( m- |) Z- e - * This program is free software; you can redistribute it and/or
! W+ B! R" w- r. b - * modify it under the terms of the GNU General Public License as
0 T# E$ N$ @$ z4 k0 `, q* H - * published by the Free Software Foundation version 2.- \& ^& e# ]6 p+ @+ w
- * \6 B, z0 R1 X% ]
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; O1 K1 ?, a$ O8 A( P. c) F - * kind, whether express or implied; without even the implied warranty8 i7 C# t- }- _2 _0 J% z
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
: t1 B/ ]3 M( H0 `3 g, z - * GNU General Public License for more details.
7 {( R2 g7 ^* Y - */
, W7 P, H9 z: |) y - # ]" y! D9 M l' {' t1 @% [: z7 R
- #include <linux/module.h>
4 p1 E( L8 G0 k3 A' o. u. y - #include <linux/init.h>7 e- O& t! E. ^* o
- #include <linux/errno.h>
) V# S- h# v) T9 w1 N - #include <linux/types.h>, `& X8 \4 C4 F! b2 p
- #include <linux/interrupt.h>+ _! y5 O, Y: a$ A3 c4 ^
- #include <asm/io.h>
, T( h: ~. P# \ - #include <linux/moduleparam.h>: e1 W! d: \# r1 q2 X9 }" H
- #include <linux/sysctl.h>, z/ g6 r& K$ }2 x" y1 L$ `7 K
- #include <linux/mm.h>9 Y5 D6 ^) N9 r, i, V( }3 o0 ]
- #include <linux/dma-mapping.h>
5 d8 v2 |- N9 l g- m# d& U# j - 2 j: D3 @8 R# u
- #include <mach/memory.h>
: s0 @- _9 S$ O8 R1 v5 {& h7 S7 g$ p - #include <mach/hardware.h>
' r* b8 d3 q. G5 G - #include <mach/irqs.h>
+ V( O# T4 F% Y/ G4 D - #include <asm/hardware/edma.h>- W: B! \4 P* S- K
- x& ^4 c1 H% `+ B% j V
- #undef EDMA3_DEBUG1 \7 n- S, v9 H- C2 H( r$ r
- /*#define EDMA3_DEBUG*/( [. H- j( t: e$ o( v
|- Q; m) `: _" J- #ifdef EDMA3_DEBUG
) l+ P4 b. C. k, }3 |" k$ D* k - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
% ]- p0 V0 i, o) e. H+ O5 p - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)0 @- }+ h' ~5 Q O) H6 v. W/ T9 E$ z
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)% _& O$ T q4 f$ {# n& Y* w+ `
- #else5 \( H1 s: u/ S) g- z6 K
- #define DMA_PRINTK( x... )
; N9 i( P' y8 f - #define DMA_FN_IN
1 {* H- J5 }4 X4 Y2 e - #define DMA_FN_OUT$ b; g, @4 A* q: d* S# P/ T
- #endif
3 C0 w* Y' p7 k4 ^
. Y$ c9 c) p% u2 h5 `0 @) j( l9 n- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
3 j0 O T& |) p( m - #define STATIC_SHIFT 3+ |4 h: Y8 \$ O; M8 _* K
- #define TCINTEN_SHIFT 207 o1 I3 y) X, l$ o/ w! r3 ?- f3 b
- #define ITCINTEN_SHIFT 21. b/ \& l7 [) H9 B
- #define TCCHEN_SHIFT 221 {& r" F6 _% c4 k0 f9 G
- #define ITCCHEN_SHIFT 23% P' ~2 G; g% L4 z0 n" z( |( C
1 C2 ~' k$ t7 v1 f& s- static volatile int irqraised1 = 0;
( _% S% a& L! B6 l, H' { - static volatile int irqraised2 = 0;. Z$ S0 R1 o$ |9 v' `: T
% b* R# ?2 A& x/ z L- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 l: t& [3 D# p% ~
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- P2 ?. @3 ?+ H: }/ K - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 ?7 p n9 ~" c' m: i7 W
# q2 R0 `( }8 e7 k- dma_addr_t dmaphyssrc1 = 0;
* [* X: b" E* Y& w - dma_addr_t dmaphyssrc2 = 0;0 ]" r1 Z: Q4 c9 ^# C4 ~- `
- dma_addr_t dmaphysdest1 = 0;
7 u5 V6 l9 u, w/ A4 V - dma_addr_t dmaphysdest2 = 0;
/ e+ T5 P+ p3 k5 v$ N - 6 l8 ?) H8 u* x8 q; o9 t+ [, g% E
- char *dmabufsrc1 = NULL;
' m' g1 v q2 L$ v8 w7 L - char *dmabufsrc2 = NULL;* `# ?$ n4 P) U' K% Q
- char *dmabufdest1 = NULL;
; P" a# ]# G3 z# U$ _, |. n2 M - char *dmabufdest2 = NULL;
5 I7 U( i$ e$ r0 k8 M# A - 0 L2 c6 ?6 A; y# e
- static int acnt = 512;$ h! n, {* O; {9 m
- static int bcnt = 8;8 r( v% P/ t2 F
- static int ccnt = 8;
: T6 u- f4 S" K- i4 p) H$ [- V - 1 s5 R. r& n; F2 @) D$ |! M
- module_param(acnt, int, S_IRUGO);
. J) ^0 }4 A% \" C' B/ D/ r - module_param(bcnt, int, S_IRUGO);- l1 A# F5 B; s- m, u$ P+ A7 d0 E
- module_param(ccnt, int, S_IRUGO);
复制代码 + Z$ u* w; W8 [) i6 {
7 H8 z; b1 \6 S# x 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ E0 A5 e: l: v2 l8 J2 e Parm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。2 ^7 f5 V, B- E$ W7 y# ]' }
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
& \4 k. o' n9 J: `; ]: [8 P) }2 S) T3 g+ u" d
5 w1 o1 }. S3 x0 l6 j' K+ ?" Z |
|