|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
/ W1 T6 N- K3 U9 Q/ @- [code]EDMA sample test application
9 p4 Z1 e5 s' @" z0 W" p" O - /*% K, [( J g. v! |# X0 J. B
- * edma_test.c
2 C6 J X" }+ i" F2 @ - *
3 l( t O9 P2 L% e - * brief EDMA3 Test Application
$ w6 w) q# A( l$ U3 B3 x - *
3 @8 N4 w# n9 c; k- j - * This file contains EDMA3 Test code.. b# d/ h( r5 a+ `. Q& g: J
- *
. W; P- T- j5 d+ |2 b - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
" a6 C2 v" t6 |1 q3 {* T - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; E m0 n$ k2 y# \
- * TO CHANGE.
3 m+ X0 N3 P# ^+ @' z- | - *
/ O* t% u( G" |2 c( b% g - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; X' ]+ r' u( r8 z8 | - *
' j" F& G$ k7 C$ j0 `. N - * This program is free software; you can redistribute it and/or% _) [: \4 O. S& ~, f3 @% H
- * modify it under the terms of the GNU General Public License as
1 R" S. p) q- l' [, a# w5 I - * published by the Free Software Foundation version 2.
, P: a# y* g2 {9 H, k& d+ P! x - *6 `3 K. u! v1 C
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any0 j6 o9 S b% i7 D' {) {$ v
- * kind, whether express or implied; without even the implied warranty5 f: E0 I! h' X9 `3 C
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# ^. g3 [( G( M7 L* R" e5 J( x
- * GNU General Public License for more details.
; O! g7 a) z, {8 m$ M - */
4 f! U1 D5 t; B. ]; H9 c2 H
' @4 Z1 C+ q1 Q9 m+ F/ R8 P8 R- #include <linux/module.h>; K/ k( X+ R' m6 J
- #include <linux/init.h>. t! f/ o& }- k1 g+ x8 ^" \
- #include <linux/errno.h>
2 ~/ b# S6 V4 ^. ^ - #include <linux/types.h>
b$ Z l# P" Q& K9 ` - #include <linux/interrupt.h>7 y, {! |6 H5 K! l1 L( a# |
- #include <asm/io.h> @% h# e5 O) D2 v& w
- #include <linux/moduleparam.h>
/ s% [$ G) b7 u3 K - #include <linux/sysctl.h>
1 ~# D8 N, C" j/ P5 ^ - #include <linux/mm.h>
8 N6 V3 }' O. X/ z6 B `1 i - #include <linux/dma-mapping.h>
. G [4 H: J, x$ [+ K' x - 6 B. M2 o5 C" W9 h/ R$ I
- #include <mach/memory.h>& e! ~" {9 h3 I2 f; X& I. C) f
- #include <mach/hardware.h>0 }8 s$ n; K# l8 X3 s& m [
- #include <mach/irqs.h>
3 X* {) M& y& ]& c5 ^$ I - #include <asm/hardware/edma.h>
6 ~- d! Q& _1 e& Y - * Z8 E r9 e) |) [; ?' L' B( z1 {
- #undef EDMA3_DEBUG- J3 I! R% f/ a" G
- /*#define EDMA3_DEBUG*/
9 u# h1 ^# s1 Q - + O; X( |- W5 O1 X
- #ifdef EDMA3_DEBUG: K9 f- }/ c/ y' @8 _0 P# U
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)1 h! i- O# L" G2 N0 U
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
/ T- Y" K, [1 Y9 z4 W: o+ w - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__). {! [( V# Q' g' X; j
- #else
2 p7 ^# n4 h; }7 a. w - #define DMA_PRINTK( x... )* {; y# o8 @% y1 v
- #define DMA_FN_IN
* l* n$ n9 Q* n5 N - #define DMA_FN_OUT
( T' l; R3 s0 T - #endif
6 ?* k* K- Z' s: V* _8 _ - 1 d3 _' U9 v; d+ |# m
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" G5 ~* ? F& F' K8 o7 f- | - #define STATIC_SHIFT 3
& o1 _! p) D# x6 E" i M - #define TCINTEN_SHIFT 206 j3 b+ O: p& D9 X. O# ?
- #define ITCINTEN_SHIFT 21/ X: t, e/ B G
- #define TCCHEN_SHIFT 22% F3 K. B$ G$ t1 t
- #define ITCCHEN_SHIFT 23
8 i/ E/ }6 K, A& U5 |% |( Y - 5 U4 ~4 u9 v6 `* y7 O, }( U @( Q( l
- static volatile int irqraised1 = 0;
5 Q R) w% V9 e+ Y) D - static volatile int irqraised2 = 0;
, z) b- Y4 p# G - 4 _( p# y, Y& }5 a' ^
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. {8 }8 y g& ~ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 _$ Z/ ~7 i" `
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 D6 k8 n3 r( z% u - + G2 W% D& H1 ?5 ^4 C
- dma_addr_t dmaphyssrc1 = 0;
, R. @7 v# e7 M M' B; U7 s9 V - dma_addr_t dmaphyssrc2 = 0;
/ s D6 X' T8 i& O6 g1 O - dma_addr_t dmaphysdest1 = 0;
6 A: `9 ]3 w1 R* r; L0 m - dma_addr_t dmaphysdest2 = 0;
9 h6 v/ Y7 u2 E5 o' y - + Z7 P! b) h/ m$ K0 V
- char *dmabufsrc1 = NULL;! W: r! C& g6 g
- char *dmabufsrc2 = NULL;, l' z$ b, J) w6 F1 `
- char *dmabufdest1 = NULL;
3 R+ M6 R1 K3 i$ e; g. e - char *dmabufdest2 = NULL;
2 U& ?9 R- h, Q5 C
$ m' v' w* \: ^% k: G- static int acnt = 512; t+ A% z8 c4 n$ m
- static int bcnt = 8;* A: o; i& f6 i' B. N5 T* Z
- static int ccnt = 8;
& B9 F5 T! z3 o! g3 m - ' r# q! U2 ]+ |9 d. S7 f" n4 H
- module_param(acnt, int, S_IRUGO);- L7 A; \: w8 I; ~6 c4 @0 ]5 ^
- module_param(bcnt, int, S_IRUGO);- V5 E1 E0 T8 p/ ?6 C3 r& s
- module_param(ccnt, int, S_IRUGO);
复制代码 ( y) K( ^- p- m: U- o' `
0 Q. @3 T! _( V4 q Y. V: P8 M
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
0 H3 }+ M: h- _) g2 ~% v# b( R7 larm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。8 W, ^# t" r% J0 s
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。! R( \4 g2 A8 ], Z U) @
: \- `% s8 X* i6 X- R
% k. r+ w: G- U% c/ a |
|