|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ( o& l: p+ z" y/ |6 `
- [code]EDMA sample test application8 F1 E# ?* l7 h
- /*
( E) B y5 r- N. k: |8 u6 Q3 A" X0 O - * edma_test.c
) d8 A! Z: l+ V; J1 ~2 H$ q* _* d - *# H' I* M: o# @+ K' C: G
- * brief EDMA3 Test Application
7 D+ X1 B9 f' G2 ], Q; n+ H& @ - *
% _$ Y* c& X! L1 K: R - * This file contains EDMA3 Test code.' h$ P; a5 b7 |) r2 n# D% J* Z
- *
4 W' T; G& }0 B1 w - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
& _2 I9 R" G" w% H - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
$ p4 u" v) ?9 [- y( F - * TO CHANGE.
4 ]. Q' }1 i# ?& K) }2 O8 l: O - *" B+ t5 y+ Y# X
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/$ C2 N) \/ B! Y* x
- *
% \# w; @% e" H+ {' m% e - * This program is free software; you can redistribute it and/or9 N- l: B6 }7 m! A- D
- * modify it under the terms of the GNU General Public License as
- W2 G5 e' `2 y9 H. \- e - * published by the Free Software Foundation version 2.4 g. R. q p/ r9 g3 c
- *: |1 |% o5 r$ c
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any- o7 _6 _* C! g$ q
- * kind, whether express or implied; without even the implied warranty
4 K7 S: m# F2 p5 U; {' s0 V1 G - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- T5 C" U) Z/ ` - * GNU General Public License for more details.
9 S: I$ a( V! C9 y8 |6 m$ t- _) M - */) Z a# n3 }* d# j
Y# g2 `6 `. |2 l: X/ W6 P- #include <linux/module.h>+ s$ I0 ?7 s% K9 T
- #include <linux/init.h>
$ {& u0 \6 E. c6 ^1 J$ y' j - #include <linux/errno.h>7 L( p9 k. R2 v$ D
- #include <linux/types.h>
& u2 p6 m! M* P - #include <linux/interrupt.h>
2 r( B2 i; _0 P* r$ a+ ? - #include <asm/io.h>
! j% A0 t2 h$ K; q! O+ B" T, C - #include <linux/moduleparam.h>' }1 f/ m- }# D% Z! z0 }6 c4 f8 a
- #include <linux/sysctl.h>" g4 W9 T1 m/ O9 G8 n$ A4 v$ A
- #include <linux/mm.h>
+ p& m$ r5 n1 r - #include <linux/dma-mapping.h>8 h" y1 Q0 V" [0 z; ^' `1 N$ u# R
- - M6 @+ o% G! P7 S4 y8 ?' w/ s
- #include <mach/memory.h>
6 |# j# R, J( B1 m" d% F0 l - #include <mach/hardware.h>; G( _ T- U8 J" R8 O0 a
- #include <mach/irqs.h>
; O- C' u ~$ I9 E3 `$ Q4 q' q - #include <asm/hardware/edma.h>
/ ^2 ]/ i6 |$ O* g( Q - 6 X: e' B- g* ^' r
- #undef EDMA3_DEBUG; S( I8 r2 H$ k$ l
- /*#define EDMA3_DEBUG*/
4 w3 s( X; Q) l1 z - 0 z; W. A6 Z9 a: ^3 {6 u3 x
- #ifdef EDMA3_DEBUG1 r' F5 Q' m, x: R* ^: A; s" S( H6 u
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
" {! e: M4 ^, N8 K7 J& O+ p% f - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
5 H4 r4 i$ |+ q c3 [1 n4 E - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
2 |7 j* \' f9 Y. m5 M4 Q6 Y - #else$ W; |, M2 L! v; d3 V- T
- #define DMA_PRINTK( x... )* R7 f( y, F8 `3 p9 Q
- #define DMA_FN_IN
: M: M/ c, h m5 g+ w; r0 ` - #define DMA_FN_OUT
3 N8 }: b( p7 |# j/ Y; c2 P - #endif
: g4 a, Y. t7 X8 D8 f; p
# l. g" ]% [/ y" y- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- A2 ]% \% v* O8 B - #define STATIC_SHIFT 3
& T, o. `: V# e ^ - #define TCINTEN_SHIFT 203 R0 A1 t$ H M( U. T
- #define ITCINTEN_SHIFT 21
+ z2 ]7 O& ^ B - #define TCCHEN_SHIFT 22- K' I. U% O3 D' Q! i
- #define ITCCHEN_SHIFT 233 @2 ^# C/ q! G
- . z# g# e# S6 d. G; b
- static volatile int irqraised1 = 0;! c- S# @( j# L- b! G$ C4 }
- static volatile int irqraised2 = 0;
5 t1 l8 ?. L' f! q" z# \ - 5 H5 |, Q& @) I& }# j; W2 y/ d
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 D# y( q/ R! u. x- b) n
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* K9 V4 s3 V2 ]) a4 S$ [ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 I& K/ s6 p4 f. \4 I; n7 A
) w( a" @3 l7 t( ^- dma_addr_t dmaphyssrc1 = 0;! S3 l- \* {; H% R2 X# W
- dma_addr_t dmaphyssrc2 = 0;; Z1 c/ _' U8 e) b8 J! X. u
- dma_addr_t dmaphysdest1 = 0;
+ e, m! q# [: h/ E* G( g - dma_addr_t dmaphysdest2 = 0;
8 j2 Z8 T0 K. y/ Z - 7 z0 f z' ?) ]
- char *dmabufsrc1 = NULL;
0 U7 t; i: K6 t1 h - char *dmabufsrc2 = NULL;3 V( S/ l1 m: ~% e5 B1 U' N
- char *dmabufdest1 = NULL;7 K% o9 ~9 t* y) J
- char *dmabufdest2 = NULL;2 s/ } w7 i( H8 Y+ o7 Z
: ?7 j( _6 q2 o9 \% t: w1 h* d- Y& r- static int acnt = 512;
' B( Z. H6 P) d9 L - static int bcnt = 8;
& V6 a; E2 J; y7 ~2 h - static int ccnt = 8;
/ Q, n" X. |, Y, f
3 ~8 [6 d; I: I; x+ l x# l- module_param(acnt, int, S_IRUGO);
( M2 J9 z* m; O - module_param(bcnt, int, S_IRUGO);
) h9 Y' S4 y; v* I. ^7 Y: F - module_param(ccnt, int, S_IRUGO);
复制代码 ( o% f& j/ \: s# y9 Q2 r1 L) C @5 W
$ p) l6 U9 V: [; b/ P
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用/ @" S3 N# R6 e p
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
3 o7 ?3 V, f% U' U 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
6 ]* `; a" K0 |* `' u2 t$ V+ ^/ Y% a- y. c0 q) F: C6 I
* f4 a9 [. y9 K* y8 r. b
|
|