|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
n1 Y* v+ N; [/ }- [code]EDMA sample test application: [6 ~7 |, }, T) }/ o. H
- /*7 m9 I' Z2 u/ U c" W& o& z/ ^% g, \
- * edma_test.c) k+ w" V3 f6 ~4 K4 c
- *9 r+ R$ K& t9 F
- * brief EDMA3 Test Application) h5 F7 L7 D# L: s2 I) h, D. N
- *
! l7 I! h$ k8 Q+ k1 @ - * This file contains EDMA3 Test code.
; d& G7 Z7 j- L7 X! E - *! S# T3 b5 z6 w! T8 U1 I
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 K! B1 m: x2 N. S( d - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT6 v) w; i% P; Z* c" o. M& X
- * TO CHANGE.
8 h) {* f% X5 J" S" e" l2 j: p - *
: W: k# R% F" ], [) t$ n6 t - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# E- A# u: x7 s( o
- *
0 |5 i# E b, W& ?; w2 { - * This program is free software; you can redistribute it and/or
, e$ t. e% @& g - * modify it under the terms of the GNU General Public License as
: Y1 E7 M q3 r _7 e- P+ g; R2 d - * published by the Free Software Foundation version 2.3 S8 y! u- K2 T" N* _ ~9 b
- *
, S% d$ D# }4 \7 q' N - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
1 j2 A& H. g; Q: ~% `* s) m - * kind, whether express or implied; without even the implied warranty# e4 r$ U% X9 |0 R; J& q
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4 E. m7 E& N4 @/ |' ^2 d - * GNU General Public License for more details.- R2 e3 c; W5 c* ~- I
- *// I ~ ^$ Y2 T. ]3 N
- 8 g6 S) E; r% I- e" M1 d3 i
- #include <linux/module.h>
, _0 t* S5 n% P0 X - #include <linux/init.h>: ~# {7 k9 d" U' X, [9 x* V4 s
- #include <linux/errno.h>9 K* H* K! e& Y% V
- #include <linux/types.h>7 o2 z& S8 z B; ^, Y7 H, G
- #include <linux/interrupt.h>+ b. m- Z5 _4 n$ P4 |5 m3 R4 j
- #include <asm/io.h>( {: d/ a7 i5 J2 ~+ E6 w
- #include <linux/moduleparam.h>
4 H8 ~0 f8 Z5 Y - #include <linux/sysctl.h>+ E: x5 u- p- e' U6 S2 Z0 V
- #include <linux/mm.h>2 j! [2 g- r# A% b
- #include <linux/dma-mapping.h>
1 S% b9 s. v" S$ o, G - 9 p7 J* K% c# }) c8 `& S$ v$ k4 M/ e
- #include <mach/memory.h>% o! e* e w1 G, h" y
- #include <mach/hardware.h>$ q; v0 w2 W3 { L( q6 |* W$ v
- #include <mach/irqs.h>3 ^0 k9 j$ V: R8 f
- #include <asm/hardware/edma.h>
* o% j- h/ P3 G7 P
+ _ i( Y5 P& L- #undef EDMA3_DEBUG0 I0 b+ D; f' ^! T6 v+ j/ h
- /*#define EDMA3_DEBUG*/
* @+ [4 c* r; A9 h- d1 b( U
1 q: L# f. B3 y4 Q# y- #ifdef EDMA3_DEBUG" x: [- s9 i: m/ `% k+ N
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS), Y9 S) M" k$ l
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
" y. K( f- K$ ]$ b7 C3 ]' g - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)1 g |: @/ o, ?* F" ^
- #else+ @2 \# o+ B5 q1 \+ a
- #define DMA_PRINTK( x... )
, ^. i# `. b! R* ^! f - #define DMA_FN_IN
6 X8 f& V m/ J) C8 q7 D! D - #define DMA_FN_OUT, ^* z# C1 j' M3 {4 N& S
- #endif# T' V' U" H, t+ A9 p4 \
- 4 w3 G0 i2 u3 o# o0 ]: d
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)4 w: C( s1 F) J& U# ]0 s
- #define STATIC_SHIFT 3
/ r7 \ |! B' e7 V3 p( N6 F& t) i6 _ - #define TCINTEN_SHIFT 20
. H& O% C. \1 E7 F - #define ITCINTEN_SHIFT 210 K& j6 K8 N X6 n
- #define TCCHEN_SHIFT 229 T) k$ I# z, e( n' d, N3 y0 O8 a
- #define ITCCHEN_SHIFT 23
( w1 V/ L6 p5 s/ \9 R
" b2 X% R( P: N% M2 Q& B- static volatile int irqraised1 = 0;
6 n$ d$ L! R. { - static volatile int irqraised2 = 0;, o( [0 P, j1 j3 p l
$ c9 b! h( g& l7 l [- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! j k5 Y( z6 u1 O' O
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& R9 B' X( S4 i1 H: {
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 @/ Y+ D( `, e
+ T8 [8 i* L9 e# y$ S$ s- dma_addr_t dmaphyssrc1 = 0;
0 Z9 R) T O! B$ [ - dma_addr_t dmaphyssrc2 = 0;
2 l+ t( }, J+ m& Z) o+ ^: `, I - dma_addr_t dmaphysdest1 = 0;
7 y1 i9 n7 P+ [0 n; Y - dma_addr_t dmaphysdest2 = 0;, v8 I/ F1 Y+ Y& m& \" v
- 3 h: I' v3 |5 @4 z' F
- char *dmabufsrc1 = NULL;
0 k3 `9 F1 W( s6 }2 p: ]5 w7 a - char *dmabufsrc2 = NULL;
; Q3 l- z0 d( d' a - char *dmabufdest1 = NULL;
; |- t* `8 m/ _7 L# u1 O; D8 f - char *dmabufdest2 = NULL;
8 o) l7 G% R. M5 T5 X
6 |5 f+ H! x1 b3 c* L, X! n- static int acnt = 512;
1 ]6 T* |' `8 \6 R/ R3 K: L) W9 { - static int bcnt = 8;# ^) X7 O; m+ o. d2 J2 F8 u: g
- static int ccnt = 8;
4 @, C2 f3 E$ X9 @+ Z& |
- p- Q9 r1 L' D. j) U. m- module_param(acnt, int, S_IRUGO);
: L% I; S5 e/ |2 R' J - module_param(bcnt, int, S_IRUGO);+ i+ o/ `6 P8 n" ]! r: H; a
- module_param(ccnt, int, S_IRUGO);
复制代码
" v& ~9 E1 } [5 l
* M$ [9 b, O8 L7 S3 C+ ] 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
3 T8 g: ] N" l" p4 P6 Q6 O* Yarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
, G' ?; T# d! s 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% P* }. Y. |! U1 m
4 S8 s8 N3 p, x0 v2 w7 @! d
6 y* L. ]- I7 J/ i- \8 \ |
|