|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ) K* y* R/ j! `' N! X
- [code]EDMA sample test application
4 F! c6 h! x2 D) n0 l* c! ?$ V - /*5 i2 C! J# x+ N* X: [6 M U" r
- * edma_test.c
8 u0 R: H+ j, b u* B- M$ V6 v - *9 l& I" G! U3 ~. P
- * brief EDMA3 Test Application" A' R- E. R6 H/ j5 I% P
- *
9 m) t- Q- H: d" L% P4 L; e) L - * This file contains EDMA3 Test code.
0 S5 Q) n' }( z: P E - *
# }+ p b7 h/ y1 h& q* {5 M% y4 o - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE0 E/ Z- E( F1 N
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
2 t* [2 O& u' S6 ? - * TO CHANGE.$ q2 y8 Y/ B* z. D1 [; I' C
- *
8 d5 z4 h5 V2 k. a* J4 @+ B - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; B7 a* h. ^8 M( o& w - *- I+ X8 h/ q3 w; {) K. d
- * This program is free software; you can redistribute it and/or
9 U7 L% k# w7 D' X: \6 G- x8 s - * modify it under the terms of the GNU General Public License as
$ @3 C. {& U$ [+ V# }% |& i - * published by the Free Software Foundation version 2.
+ X% g. `8 o3 U6 U - * f1 @% A3 d3 h8 W0 Y" Q
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& u( _5 a8 z7 n# u$ R Z+ _/ l - * kind, whether express or implied; without even the implied warranty
! E3 q" O3 p" N - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' |* q n; b/ P+ e- U% V; D- s - * GNU General Public License for more details.
; `7 P! @ y* @8 r( c! [ - */
3 v( B6 S4 ]$ [. g - + C5 \" ~7 V5 ]) x3 o
- #include <linux/module.h>
8 Z, L: x! ]* @ - #include <linux/init.h>
# R3 q% k4 u9 k$ v* ], g2 J - #include <linux/errno.h>
, [. h! j2 V* \" u7 ?/ I- Z - #include <linux/types.h>0 J$ b- ?/ h" m5 \3 T' |3 J% W% `( O
- #include <linux/interrupt.h>
5 q/ ~! z; v6 Z6 U% N - #include <asm/io.h>
: A* w0 k: J$ a5 u" m/ M - #include <linux/moduleparam.h>
. @0 M) m! c3 H. ] - #include <linux/sysctl.h>7 O& o* ?* t3 w' u& u1 t; k
- #include <linux/mm.h>
/ S0 @7 u/ K- k7 d! [% x3 ? - #include <linux/dma-mapping.h>
; m6 P" R* g L8 c- C4 S - ' R" [7 k# V1 S
- #include <mach/memory.h>0 u5 f- r9 ?( J2 b
- #include <mach/hardware.h>
4 j6 a4 r! B2 s b& |! H* n - #include <mach/irqs.h>% ] U. M# h6 o% p+ a& x+ `/ ?
- #include <asm/hardware/edma.h>5 a$ C2 R0 m8 ^$ P: y0 g
- 9 i+ C+ `7 G9 {/ V6 i
- #undef EDMA3_DEBUG
8 K3 ]5 O) I" B3 z- q* h - /*#define EDMA3_DEBUG*/! |) s1 M& I# M6 p
7 \# \9 h: p8 k, M& l8 a! B- #ifdef EDMA3_DEBUG
1 C; A2 P0 [5 P; J- g7 C2 `2 @ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)3 k: W4 }' o9 A6 x+ C3 z' B
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)! e4 J( K0 p( N2 I+ u: W7 K
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
* v& S. R$ ?: s- r8 _/ t - #else
# {0 S1 |# a( g U - #define DMA_PRINTK( x... )
' [' l7 t8 s3 { - #define DMA_FN_IN
* k5 G n) v. Z) |* q - #define DMA_FN_OUT
. i$ }7 _3 T2 P4 }" l' Q/ q3 S - #endif# M$ @3 N7 n& f U
- , d F5 G* [. _' }) {. D( j4 D
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- E' x* H$ J8 \0 p9 r) n/ u - #define STATIC_SHIFT 3; |# w- I8 I C k( ?' ~( j# G; ]" j
- #define TCINTEN_SHIFT 200 Y4 h! \% F7 M Z# x! i
- #define ITCINTEN_SHIFT 215 W" V" F2 u. i! ^3 a o* [6 X
- #define TCCHEN_SHIFT 22
. t1 J9 ]* d9 i8 r+ U1 Z0 k - #define ITCCHEN_SHIFT 23
8 x, g+ t3 b! {
) M: {6 F9 ~( E2 C% L) Q r& m- static volatile int irqraised1 = 0;' X2 b: I- O# g6 V
- static volatile int irqraised2 = 0;
/ [9 R7 Y8 J8 H( t( D - $ i- p' j/ @( x
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 m, ^! E' h3 b4 J1 J0 K$ S) \ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- {: Q- M/ y' O7 o4 i - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" o5 t2 r& Z$ p9 Y8 F
- 6 l/ V) _: c0 i
- dma_addr_t dmaphyssrc1 = 0;
# W; k O2 Z: o3 T- ~( O3 L - dma_addr_t dmaphyssrc2 = 0;, r! p2 Q# s& b' G% c! o
- dma_addr_t dmaphysdest1 = 0;
( V2 i7 Z" V& r2 ]* B - dma_addr_t dmaphysdest2 = 0;" u/ D8 n# J0 N: v& A/ A2 z
- # w& H; z8 p5 [9 r) I7 w
- char *dmabufsrc1 = NULL;
0 p" ?' P7 Y) |& I - char *dmabufsrc2 = NULL;
( \: l( Z# n# B3 ^3 ~ - char *dmabufdest1 = NULL;9 P5 z7 D! e% y9 L0 \3 P
- char *dmabufdest2 = NULL;; Q" D% l7 q: H
+ D& G+ g- _2 {; w) G! t6 J5 Z7 [- static int acnt = 512;5 M% t* ^' }* j' x: k6 e
- static int bcnt = 8;
* v) i, z9 N) {% ]7 \6 V - static int ccnt = 8;
1 B+ T z# h) z. `4 W- T/ N - & c0 j# @% h2 R0 R( e+ X+ X
- module_param(acnt, int, S_IRUGO);
7 n0 C) `- W1 K - module_param(bcnt, int, S_IRUGO);
- v0 U; T# u+ M' L0 [ - module_param(ccnt, int, S_IRUGO);
复制代码 , C7 k5 G6 D7 E' S! W3 g
1 u, s5 }( E5 u8 e6 d! A& d( x7 I 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
( `" A9 t8 g( q- iarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。4 o, f# c+ \! ?7 f9 G+ g! }7 |. H9 o
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。0 t# t& e! H2 }' C
* ~! T4 v, _, Q! x. z9 x4 S3 s: k7 j) K
|
|