|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
1 I6 [! {3 A6 I7 v8 R: l0 l- [code]EDMA sample test application
/ M( M5 N5 B( S W - /*0 E: v( e. `7 f1 R8 E
- * edma_test.c* e3 E6 ?# r! u8 L
- *
1 r$ x3 l+ Q+ ?' u. W; v - * brief EDMA3 Test Application
! ]& J) |. K7 \1 \9 A5 |( P0 y+ J - *2 m3 E5 w/ \2 K, v, i8 e. @
- * This file contains EDMA3 Test code.. F% m, ^; ?; w+ O5 ^
- *
! D2 w' R8 s Z) V - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
1 L8 w2 [; Z. Z% Q8 n* _ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT! Y1 _" o; _& M( x6 O+ t4 K
- * TO CHANGE.
; _6 A. \2 g5 B+ N: b/ z - *
& F/ V) N0 k F7 q2 V6 M; G: r% | - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
9 T: |: a0 l, [6 \" L) I$ j8 @- a - *2 ~& d' C% }$ J7 n7 m/ _2 T
- * This program is free software; you can redistribute it and/or
- x* W1 e' b. G) n0 F' @$ c. Q - * modify it under the terms of the GNU General Public License as
$ C8 R! ^3 ^( w" l1 ?0 ]% {, z - * published by the Free Software Foundation version 2.
6 G# ~& B7 ^ d0 I" F& R& ? - *; ^0 h0 M1 l. e$ Q8 L g
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any: C* w; Z% t. ?3 w
- * kind, whether express or implied; without even the implied warranty
; T3 }0 o% X, k2 D5 k- r - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 B V, I" Y8 ?! z - * GNU General Public License for more details.
- ?0 q2 R; K+ O8 ` - */( q7 ?" q( c6 {1 f6 R" \
7 z' v. {) x3 [! R( S" J- #include <linux/module.h>
! H& B) l* ^9 U! K( F - #include <linux/init.h>6 C( B J) z( Z% ^# J6 T' _
- #include <linux/errno.h>, p K+ J' u2 C8 y- ?& A& l7 Q8 o o
- #include <linux/types.h>
1 l6 |+ N9 ^, A- @ V - #include <linux/interrupt.h>' f9 I+ X8 V$ L
- #include <asm/io.h>1 a1 K5 Y6 a, q
- #include <linux/moduleparam.h>
9 t; N1 @# X9 g5 Z& a* y - #include <linux/sysctl.h>! A% w. O! D' }5 L' f% f' W
- #include <linux/mm.h>
$ x5 f9 [! O- {) x, _ - #include <linux/dma-mapping.h>: S& Y) H: Y/ f9 P1 o
- 8 y+ D2 y6 o0 `3 v
- #include <mach/memory.h>" U, _# g2 M2 P& B
- #include <mach/hardware.h>, c. [: c) K/ v6 x" n( C5 y+ h1 t
- #include <mach/irqs.h>
& [. `+ v) x- J8 j7 g - #include <asm/hardware/edma.h>) q/ ^- P7 g+ v
- ) @- Z+ v. z2 D8 H7 l2 ~
- #undef EDMA3_DEBUG
. f4 u" z& f: b E) Z - /*#define EDMA3_DEBUG*/
2 x3 h, K T1 U, g; y8 z) F
' k0 e: E9 t$ X" p/ N% j- #ifdef EDMA3_DEBUG* u: i- h" A2 ~+ S
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" E, j& a$ g" k- q% x! d* w
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
: M: m% j) ?* I5 S, ~& I& ~ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)/ g! t7 T* J; a8 L
- #else1 h6 @5 V' ~9 V; U) f7 O! d
- #define DMA_PRINTK( x... )1 u9 X$ k& E: t% b8 j
- #define DMA_FN_IN6 D2 G. s! S1 [. r" }
- #define DMA_FN_OUT
. b' o' h8 k* i/ @2 b, U6 ?% T - #endif
" g# D6 ]: K- k7 B8 v* z" N. N
: x; N. E) E! m; }- #define MAX_DMA_TRANSFER_IN_BYTES (32768)) g: U( J9 o% j2 O3 X6 A& s1 [
- #define STATIC_SHIFT 3/ M6 b, e% K5 k# g6 u% K# V
- #define TCINTEN_SHIFT 20! V( {% H: r7 W/ D& S" p& L' m
- #define ITCINTEN_SHIFT 21
, [# x( B3 Z" w h! }- V - #define TCCHEN_SHIFT 22
6 x% q" @1 ?' q/ ~' y3 l9 G - #define ITCCHEN_SHIFT 23
4 s3 z5 M* A9 y+ I' O - $ N: v% g; c5 V% j- t: f
- static volatile int irqraised1 = 0;
8 E( k* [$ t. y7 S/ n - static volatile int irqraised2 = 0;* |3 M% e! U5 w4 e/ [* A+ U
! g2 Q) W1 t0 T5 ^/ I, k- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& q8 M O$ V8 x- r; M - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& n8 O. g U) {$ F, b6 v( D
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 S! [- [6 u# \% n% n, Z; ~
( S" w2 M8 R/ K: v- dma_addr_t dmaphyssrc1 = 0;1 O% x+ ], A; Z. k- l: ~
- dma_addr_t dmaphyssrc2 = 0;
2 B7 l: z8 A' T8 w1 u - dma_addr_t dmaphysdest1 = 0;
6 x2 x" k5 I+ x! n: D - dma_addr_t dmaphysdest2 = 0;
. Z$ @8 J- j6 G! i. t
4 E6 [5 \& _; S _6 O- \- char *dmabufsrc1 = NULL;/ ~) R" a0 `: G3 P+ I+ M) v# Z) _
- char *dmabufsrc2 = NULL;5 z) R" r B' d c
- char *dmabufdest1 = NULL;; x5 ^0 e. n1 x3 ]2 r/ q
- char *dmabufdest2 = NULL;$ W1 I7 Z( H, }0 s1 P7 v7 c
6 Q6 ^+ j8 C2 }3 s8 G1 E- static int acnt = 512;0 v% s5 [6 j8 N9 |$ a1 Y
- static int bcnt = 8;
1 e0 H% y! } b# [. q% `) ? - static int ccnt = 8;
6 J$ U7 h5 G7 l - 7 f8 | @5 {& O' Y ?7 z6 E; X! Q/ f
- module_param(acnt, int, S_IRUGO);5 A# ?1 f7 f! r& O* Y5 D6 ]$ c0 n
- module_param(bcnt, int, S_IRUGO);
" d' V# i0 J9 A& w - module_param(ccnt, int, S_IRUGO);
复制代码
! z0 ~' e; _: H! E, d) `- D7 H" E! R* S2 h8 I0 t
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用/ G8 ?) _1 Z6 n' e3 T
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
/ }, A* \+ g1 I, J. \ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
! v: ^, X% [$ ?- c$ [4 K
W$ Q' c' H9 S# u) A" T5 ^( e* j7 W4 @6 t0 p2 A3 g
|
|