|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; b6 l0 y! G3 m- [code]EDMA sample test application
0 A1 i" o' N" Y# T: v. s - /*
0 p# D$ m& \. g. r - * edma_test.c9 \* |5 |! K P" e! g8 A
- *; Y6 w* m7 R) _1 g( q
- * brief EDMA3 Test Application
L5 h7 v+ B6 E+ b. @3 u - *
1 `" E% Z) e6 G Q, X9 N - * This file contains EDMA3 Test code.
: `1 z+ ^ P7 I0 E - *
3 j% P8 h' [ y, x3 m/ V - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 M3 [3 k* e0 r. u3 E1 S
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
; u( X# J2 x6 ? - * TO CHANGE.
4 q: P6 ]" n @; N - *
: T n3 T6 Q- ` - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; `+ K) g5 o5 t) e
- *1 [0 R+ v( H" \/ U% u. P
- * This program is free software; you can redistribute it and/or
2 Y7 N' I- B4 L% h* A - * modify it under the terms of the GNU General Public License as$ z s- L, B4 ~
- * published by the Free Software Foundation version 2.6 S8 E j! A v: i8 l* G
- *5 k# e: b8 T. c: ^/ z& L
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any z$ S' Y4 Y- r. H/ |9 e
- * kind, whether express or implied; without even the implied warranty
- q/ @4 i/ V2 D5 I1 O: D - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 D' z0 \3 D6 O: f* k9 q - * GNU General Public License for more details.
, Q+ H! B: B! ^& s. }! g% v- a( B - */
]9 k% U8 i% p - * ]8 P/ Z4 x) u. [: [
- #include <linux/module.h>
' z9 t9 w: g/ `6 t1 Z - #include <linux/init.h>
4 [) w$ G8 v# d$ p; J - #include <linux/errno.h>5 g: F" ^7 r- d/ Q# T i
- #include <linux/types.h>
0 b' v% k& @+ C, D. u+ e7 {. {, e - #include <linux/interrupt.h>
" v1 N9 ?- ~& o8 N! e1 U - #include <asm/io.h>+ g) N( ~, L$ b4 w9 P$ X& D4 F. k$ ?
- #include <linux/moduleparam.h>: l* n2 w, a9 K x) h2 T$ `7 N
- #include <linux/sysctl.h>6 R, T& p! k$ n7 D2 h6 @
- #include <linux/mm.h>
7 i1 _1 R0 q6 B% ], _6 u* L$ A - #include <linux/dma-mapping.h>
$ A$ C( m9 D3 E. C - 3 w! d2 }- ~) z: l, ]. x
- #include <mach/memory.h>
4 ^ C h- X8 F }" [ - #include <mach/hardware.h>: y, _6 b7 r2 L* R
- #include <mach/irqs.h>
; {) o! E0 W8 Q2 U1 p0 m: t* S - #include <asm/hardware/edma.h>- x3 c: ~/ m# C1 p) C" v9 ^
& o X7 L6 M& r" W- #undef EDMA3_DEBUG
) }) C. N; g$ T/ E# p; N9 j, c - /*#define EDMA3_DEBUG*/
$ t# m% j9 s! V4 |% ^6 n
" X/ N+ B: y& ]3 Q- #ifdef EDMA3_DEBUG
6 L5 m; |& c* z# O! w! n - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
$ j U2 T. u% O& B$ Z - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
" q8 o( f% \. G& [, H - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
" z) U% m. u D8 u8 R - #else
* G/ u& V% J, J/ z6 v5 ~3 n - #define DMA_PRINTK( x... )
: A6 ]! P" |6 C' f% i - #define DMA_FN_IN
9 X3 j0 L H+ r8 K/ } - #define DMA_FN_OUT
) u6 @! S7 X3 h- m) E. d - #endif' y3 V! ~3 S I, X q
8 W$ ^! P3 q1 p8 x- F- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 A/ Z9 O( S- j u, H - #define STATIC_SHIFT 3
: X( U2 _& u9 t+ y2 [/ R+ G4 c - #define TCINTEN_SHIFT 20
4 e$ l8 g! s* G8 W$ n. V - #define ITCINTEN_SHIFT 21
" \# E2 F& I, b0 `* f9 O - #define TCCHEN_SHIFT 22
- a7 U( ], X: R* P3 q' Z0 l7 Y - #define ITCCHEN_SHIFT 23
/ y0 \0 r0 }$ i% [+ q. G' P# ^- {, d7 r
@0 u( j! O' e3 L- static volatile int irqraised1 = 0;+ v. \0 A8 W3 \' ~
- static volatile int irqraised2 = 0;
, P9 n* Y7 X! v# k s# C+ X1 o s - . t# `5 N: B$ a" {3 a2 w, W
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: B+ Z O8 G; E# j+ u
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* u9 v" G" @! r) V - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 x* M8 {6 V; D - - l P. j" T- w3 M- P
- dma_addr_t dmaphyssrc1 = 0;7 J% D+ ^2 p1 d- w$ {* }& b
- dma_addr_t dmaphyssrc2 = 0;6 |2 p. | P% W3 h# c7 Z
- dma_addr_t dmaphysdest1 = 0;
8 r* u1 f: v5 N* v7 a% ` - dma_addr_t dmaphysdest2 = 0;
8 i; D, g. }+ E% F5 X9 \ - ' A/ r9 \9 {, \ N6 J( \) a$ b
- char *dmabufsrc1 = NULL;
# \2 K# e/ I3 D" d - char *dmabufsrc2 = NULL;
* s$ }+ V- W$ {5 H L& F - char *dmabufdest1 = NULL;, q3 V" [, C: S4 K; n# j8 ^% e( n
- char *dmabufdest2 = NULL;
' D+ k. G; [# h& H' t
/ ?9 v7 q6 D/ R o2 a. B: a; w- static int acnt = 512;2 ^0 B4 V- l4 O# s0 ~# l
- static int bcnt = 8;
" N) y6 A# f9 [( U+ O8 K - static int ccnt = 8;$ N+ e. ^9 x& K& ?( B
- 3 q$ \& s& q6 v
- module_param(acnt, int, S_IRUGO);; W6 w3 o# j0 U9 U q- J4 {1 f
- module_param(bcnt, int, S_IRUGO);
/ t1 X+ z& R( T$ H$ B c( W - module_param(ccnt, int, S_IRUGO);
复制代码
- H+ o. o, ~2 L) W; _7 l+ \( w q+ b# f t& f0 [# r N" e ]
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用+ U3 e0 q/ j" a" _) E
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。( h4 c" B* q+ p1 }6 {
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. t9 O6 W" D( |* R' j, V# \# Y% N- n# f3 b
) v/ B5 F0 T2 n( ]
9 W4 O7 t' p2 c7 T, ^& P* i7 u- b
|
|