|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 $ a( C- L! y) o1 a/ V& P% y
- [code]EDMA sample test application0 [8 ?: }: A) Q. w0 ^0 ?
- /*
* r) S8 K3 C5 c; x1 E( I - * edma_test.c2 ^) R( w# T# v% e
- *! y" Y9 H( R4 H& a/ B
- * brief EDMA3 Test Application
! b+ J) y9 n" Z' } - *0 @6 J/ _% Z4 P+ k2 }
- * This file contains EDMA3 Test code.
+ f0 e/ k# q" z0 ] - *; W/ Z' A/ }" E# n" J/ c0 U2 B
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE. K' U M' A# j1 V6 [
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
. ]3 b" D# }% B+ ~ - * TO CHANGE.
. f6 T# L0 }( }9 M, s) m$ h. f+ S5 R P - *
! ^: ~- Z& Y9 x' V/ { - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/1 Z: w! u- {( H- ]8 B( b
- * @+ G! N% s6 m& z
- * This program is free software; you can redistribute it and/or
. x( b: N) t1 _& Z R; C - * modify it under the terms of the GNU General Public License as1 d5 @! O# E3 n& l0 G7 N7 N
- * published by the Free Software Foundation version 2.( u) A2 `% s, h% Y/ d2 h
- *
5 y3 Q) i" ?. o - * This program is distributed "as is" WITHOUT ANY WARRANTY of any: V v$ s' g# [/ b: Z
- * kind, whether express or implied; without even the implied warranty! A7 a3 ^! ]4 D( a+ g3 ?. Z9 @
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the3 d- W5 M# j, D# C" b' Y
- * GNU General Public License for more details.
# x& K. z9 A2 l2 F1 F6 k* w3 v+ \ - */- a) a4 r6 c; |
- $ q' y/ O6 a4 P
- #include <linux/module.h>
; V/ M$ \# W8 x P) K% b* j6 t$ } - #include <linux/init.h>
* C; ?4 t3 c- c - #include <linux/errno.h>* N r2 S& y, T, O" t
- #include <linux/types.h>6 {9 w2 j- I9 P3 y% |
- #include <linux/interrupt.h>
2 B0 r' Q4 ~. q - #include <asm/io.h>" Y' y. R ~; b6 Z- s$ x
- #include <linux/moduleparam.h>
" I6 ]7 d* V. [6 R3 S - #include <linux/sysctl.h>- n% T6 o5 T6 r6 o; t
- #include <linux/mm.h>0 J2 g$ P2 O- [6 h& d
- #include <linux/dma-mapping.h>
' o! N' f8 \- Q/ v$ V
* A; C1 m/ a7 Y9 @' G4 k4 g- #include <mach/memory.h># v1 M9 i. h3 p, w& F
- #include <mach/hardware.h>' S2 J. q4 a6 L3 u
- #include <mach/irqs.h>1 A' y, `/ h4 R( P
- #include <asm/hardware/edma.h>
8 |* O" v0 W& k
$ C: ^/ C0 X$ ]. v- #undef EDMA3_DEBUG
0 F5 I! f" ^- ]8 Y3 `1 L; P' ` - /*#define EDMA3_DEBUG*/
1 V# N& c- T$ i" N5 G: u5 R
- g! _0 \+ b A! Z, n6 j! Y- #ifdef EDMA3_DEBUG5 g+ }- y6 X# |0 F& [+ ^( f3 F
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" A. J8 v- p6 o' ~' N/ T
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__), ] ~% q9 `8 I; q
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* J9 ~8 s: I& D/ i" ?
- #else( K. q- K. E% J; u7 q& x, Q
- #define DMA_PRINTK( x... )5 s4 Q/ d. B8 ?* u
- #define DMA_FN_IN
1 Y' l$ e' E( @* Z& Z - #define DMA_FN_OUT$ A$ H2 ^, L# D2 U
- #endif
3 n( J- o0 ~: V" e. [) z; F - & w2 A6 ~, G$ _3 z, f" i4 U
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
) M' {- A* {- M, r! d W+ M: E5 k - #define STATIC_SHIFT 36 `1 s/ A+ f/ B
- #define TCINTEN_SHIFT 20
( L# P. Q! p) _! I. a8 k - #define ITCINTEN_SHIFT 21
+ L) V% N# C% l% b2 U4 N - #define TCCHEN_SHIFT 220 {5 [) I" A& N" M" n
- #define ITCCHEN_SHIFT 23; W8 D/ ~# r* G4 l9 J
- " T1 c8 M! f) U# h, l4 T7 ~! \3 w
- static volatile int irqraised1 = 0;
; o& m4 Q( l2 J5 w: C - static volatile int irqraised2 = 0;
+ s, d7 X6 \5 n% u+ o* T, b - $ ^! O" R( ~# n" ^+ ^$ ^
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) ^- a U4 m; D' t# W - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! ]9 e/ t: k* W" d: D - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! F+ f, L% p& t
: p/ m, [* C" H+ ~! q4 {) {+ r- dma_addr_t dmaphyssrc1 = 0;
3 j3 c1 d& }. J - dma_addr_t dmaphyssrc2 = 0;* X4 _: p) v- O" }3 G* r' y
- dma_addr_t dmaphysdest1 = 0;8 d. U; Q% g* G9 X6 M
- dma_addr_t dmaphysdest2 = 0;' D5 A. }9 [- C& H& k) k
- 0 T" S& S$ E: U) Z2 ^* f8 w0 s# i3 H
- char *dmabufsrc1 = NULL; p$ G s* ]9 q9 F
- char *dmabufsrc2 = NULL;
9 p. a- A) h# G - char *dmabufdest1 = NULL;1 V" c/ F5 u" F* y p4 _ h, q1 [
- char *dmabufdest2 = NULL;
7 }6 i/ _# Z; `" U2 D - : L/ o+ h9 @1 P
- static int acnt = 512;5 ~$ ?( v9 F1 ?; ?3 c& W5 q1 E$ U m
- static int bcnt = 8;
- ^) @1 _, b" w' B& E6 ? - static int ccnt = 8;
q, J$ C! s: y( O5 ^: p! a8 t - % d* X; S0 Q2 K3 v# q4 H
- module_param(acnt, int, S_IRUGO);
: }; G; P8 f& Z$ d4 W - module_param(bcnt, int, S_IRUGO);1 C( Y$ _' k) k+ h" e7 n- e+ o
- module_param(ccnt, int, S_IRUGO);
复制代码 / V: h8 ]$ V2 K0 A/ O$ S
# x7 h/ _+ C7 z P 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: N) N. T( E& t6 Darm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 N* ?' O- N. n. M2 v# M
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
8 J. u: X" t" u- A
7 E7 P3 F* t9 N8 s1 j$ X( K4 f7 E* d( o
|
|