|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 - L, y/ W! c* n8 R; y
- [code]EDMA sample test application
" f$ L0 L+ B( n' E - /*9 x4 s5 H7 j4 a/ p m
- * edma_test.c6 H$ }( q+ _- w
- *" m. H! z$ M. [+ \* F5 a$ c' _, E. l3 U6 `
- * brief EDMA3 Test Application% s$ F$ y6 Q% B; T
- *
, v9 x+ R y/ x+ i2 k - * This file contains EDMA3 Test code.. `& w# y4 a. Y' ^& [5 ?
- *8 J2 G+ y D' c9 m
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
5 m! @# \1 J6 d- }# z/ e& d* S - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 D7 _. D; ~1 r7 W/ Q% A
- * TO CHANGE.
* P8 ?8 n; ]. [. ^; y) H - *
2 m4 P0 u( T/ ~; K+ q2 s - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/' x1 P+ h. T4 `5 l1 M0 ?: w/ c4 L
- *
" u2 o! J) o7 d! ~# M/ Z' ^4 H - * This program is free software; you can redistribute it and/or
; F# T! w, j5 M - * modify it under the terms of the GNU General Public License as3 A$ e, A: \; n' [# E
- * published by the Free Software Foundation version 2.$ K7 J1 n& r: r2 k- s7 h# M
- *% Y: f# v: Z# Z' ?2 s% X4 f# O
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any; o2 O" X( ?( O, I: M
- * kind, whether express or implied; without even the implied warranty
8 L+ B6 Q. U) p% R5 q- r3 a8 R! w9 Q - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% {1 F1 b2 a$ ?3 D$ f ^3 i8 P - * GNU General Public License for more details.
: U, u0 `+ ]: l0 b* k2 v7 S - */, u: r" S4 i- W* _; ~
' N, ^. \" g- B# m- [! l) ]& Q- #include <linux/module.h>
* K" e0 K9 x6 M( K0 `+ c - #include <linux/init.h>
# \; L1 m% v( F; S# @* n, z - #include <linux/errno.h>* O- v8 q7 j% d- s3 ^" d9 }7 Y
- #include <linux/types.h>& h- G- S/ u: N% U+ R% L
- #include <linux/interrupt.h>5 `1 A6 t# b/ S8 B) f% Z4 e+ G" H9 P
- #include <asm/io.h>/ q) o$ n2 C! p6 v% K0 c1 p
- #include <linux/moduleparam.h>
6 U% I- E( j# P( @, K - #include <linux/sysctl.h>- }. I5 t, D* O) s
- #include <linux/mm.h>
1 T0 }6 ~% Q9 H/ d - #include <linux/dma-mapping.h>
, r# X' h8 W$ s! U, Z3 g5 v" s - ! ?0 [- E9 x, N9 m+ C
- #include <mach/memory.h>
( V9 f. |7 e$ K+ H5 u2 x' s; N, k - #include <mach/hardware.h>
y" \( Y( z* k" {1 m4 _2 _5 Z+ H - #include <mach/irqs.h>
( i* w; C5 Z$ Z* d% J* u5 n( ~ - #include <asm/hardware/edma.h>* L) ^" e6 I# Z6 ?/ B0 e# A
- " F, @) E% f6 \- R
- #undef EDMA3_DEBUG0 S0 b9 k& s& V; v) _1 g& ]1 \
- /*#define EDMA3_DEBUG*/, g2 o# E) n! m3 c4 a* h0 V
- ; q( E E) K. V2 \$ F% f) _
- #ifdef EDMA3_DEBUG. @5 Q( N7 K E- B3 z
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
, x" A4 Y, d2 N: p3 C - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 k0 J4 E$ ~+ v6 u+ ?! R8 f1 z - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
' ~0 k9 Y* l4 |" \4 {4 N - #else5 F( J& J) n5 J- P
- #define DMA_PRINTK( x... )
4 U9 T: E* z, I" O- b - #define DMA_FN_IN
& ]' K) ^$ m4 v6 O& i: C - #define DMA_FN_OUT
$ Y0 r6 h3 K. l7 X9 D5 B - #endif. o3 I* g: a7 ^% z5 f0 Z# L+ S3 F% e
- / H2 {* s% z; I; A/ ]0 F
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
0 ]' Q9 _) U& _' S) i9 p! M - #define STATIC_SHIFT 3
1 s# t* _0 o$ i8 _ - #define TCINTEN_SHIFT 20
: y' p- U2 y- R) } - #define ITCINTEN_SHIFT 212 z3 R% Y; f1 ^5 [
- #define TCCHEN_SHIFT 22' |! {; p. f j0 ~ H! O
- #define ITCCHEN_SHIFT 23+ M# P% T7 v) z5 [$ n) m
. b- t6 S, R4 x" g, L- static volatile int irqraised1 = 0;
) J5 y c8 Y7 i0 t. t - static volatile int irqraised2 = 0;" ~, ?( A7 L$ A
- . l) Z' a! ?( a/ U
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 Q& X1 C9 x, n# ^0 W
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( V! i( E/ I) Y/ x
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! T6 @5 F+ Z: ~! X
- 5 z6 c+ q: Y' j/ G% W* ]# A6 d4 m
- dma_addr_t dmaphyssrc1 = 0;
5 p8 ?% o" N6 X9 c6 G1 ? - dma_addr_t dmaphyssrc2 = 0;& G: L* M6 `7 i, ?3 a
- dma_addr_t dmaphysdest1 = 0;
6 E' ~' u( L8 w; ?- C - dma_addr_t dmaphysdest2 = 0;
& d: A5 z; z' a w$ Q0 s, d
: B8 M1 n0 ?, h# T- char *dmabufsrc1 = NULL;
1 S& @3 _1 q8 e) _3 G$ f9 \/ C/ h - char *dmabufsrc2 = NULL;
+ l r( Z: B# D% I1 R - char *dmabufdest1 = NULL;; f, F6 s8 T% x7 C
- char *dmabufdest2 = NULL;
& n9 [- b3 V; R0 T& L - 9 C" g3 r, K2 v6 I
- static int acnt = 512;$ z) L- A( [7 s5 p Z
- static int bcnt = 8;. l+ x/ J& U" w2 K F% T
- static int ccnt = 8;
; y) K: S3 i1 g8 B4 I1 r - - ]6 K3 j1 X0 M! G
- module_param(acnt, int, S_IRUGO);
; Z# N7 Z' {6 a4 ? - module_param(bcnt, int, S_IRUGO);9 k; O; E) w" S& Z
- module_param(ccnt, int, S_IRUGO);
复制代码 7 o) \9 }3 g# x% b* G; {
5 D ^* P# ^* ~ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ f, h! Q Z, X+ ~: ] J1 Sarm-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 @3 @, |% E7 Y' b8 F: E
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
) m* k- D- \) k
* f( Q0 c; F0 M+ H+ P
# J. g; S+ o* G& L; B; O |
|