|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 , g' E/ S" D7 R; f5 e
- [code]EDMA sample test application" l" ^. y5 e& j7 \: g
- /*
8 q8 c3 i5 c& R$ _9 P: e" F& { - * edma_test.c
; \ ~+ C% C5 b; E - *; c$ r+ A- S0 P$ I6 Y E
- * brief EDMA3 Test Application
" P# F) H# B4 g# r - *
; f, Z9 c9 i3 e4 ? - * This file contains EDMA3 Test code.2 p f. C1 K7 m" L& H
- *
3 r' V: X% A/ Q3 f5 [. }- q8 Z - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE2 g/ H% B5 m8 E( k- s. c
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT. ~/ X$ x% C* W3 c! @# G
- * TO CHANGE.
2 y' \$ ^. x3 ~ - *
. o4 Q- D* a; |+ V' a - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* N* o8 k0 s' ]. Q - *
- Y4 O# _: ^. c9 K% V - * This program is free software; you can redistribute it and/or
: U% p, T- v/ K3 g8 z* i7 D - * modify it under the terms of the GNU General Public License as$ K( `6 |: R. n9 t
- * published by the Free Software Foundation version 2./ Q* L! u" v, Y1 D! U) ?2 o3 k
- *; j, e" x' G N" `$ N- s# ~
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any' u+ u6 o* \4 F2 g* ~& S
- * kind, whether express or implied; without even the implied warranty; A6 { |+ O6 i! |/ N
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the$ G" l* P9 u; {0 F3 o4 w' T. j% f2 V
- * GNU General Public License for more details." m Z4 l* ]9 h1 d
- */$ {, b) T1 E' x2 c* r M5 U( [
- $ J8 }. j" v! ?
- #include <linux/module.h>: Z% w4 I) {/ h5 [1 J6 N
- #include <linux/init.h>
2 ?. h, b* H% H; K4 O - #include <linux/errno.h>. O u0 j' s( K1 w2 U
- #include <linux/types.h>
8 s" R4 n0 x/ Q. u) C - #include <linux/interrupt.h>2 d. p' r& [- |: f4 l
- #include <asm/io.h>
9 H5 P9 q% A0 L) y2 l - #include <linux/moduleparam.h>0 V( q( D3 w. u6 Q s$ N4 E# n8 S
- #include <linux/sysctl.h>
( z9 n. m2 f6 l# D - #include <linux/mm.h>7 O: Z) J6 ]3 b: t# N
- #include <linux/dma-mapping.h>
" S) H: w0 k# f! {7 g* K - 5 }- R0 J, r6 {+ }7 ]. F3 d: F
- #include <mach/memory.h>9 E$ |' g8 W+ }+ T; _: L
- #include <mach/hardware.h>
# u! \$ I9 q' a v* P# W - #include <mach/irqs.h>
0 b/ ?7 f- X- D7 `- m% r - #include <asm/hardware/edma.h>
! l% e1 b& k7 @1 f" y - ( \- E3 x& \0 ~4 q; x
- #undef EDMA3_DEBUG# O/ b; o# f6 @) Z$ x: t% y' z
- /*#define EDMA3_DEBUG*/& b. u3 s1 l7 a) ?. l
- 4 F- A# _+ K5 ?
- #ifdef EDMA3_DEBUG
2 F u! x& ]3 e0 `: A$ M0 Y - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
3 D" e5 J+ a' q$ y0 p( K - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): a9 v; k- h+ D' _6 q9 \
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)0 w t& T0 ~( s
- #else
1 W# m; G/ Z3 q9 N - #define DMA_PRINTK( x... ); q1 F" f. p0 M4 M
- #define DMA_FN_IN/ l! ^3 s" e4 A# b
- #define DMA_FN_OUT
5 a# Y5 O& I6 P) u+ m* ]8 ] - #endif' R. G; S2 p8 q+ y# _
+ E5 j# u8 D8 E- f _6 b- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" d4 d1 T9 p) ]- w* t. o
- #define STATIC_SHIFT 3
+ X. s# ~; F! ^6 e6 U, h - #define TCINTEN_SHIFT 20/ S ]- S. j! ]. A* o7 `
- #define ITCINTEN_SHIFT 21
3 T( X: i9 x/ P w - #define TCCHEN_SHIFT 22
8 l7 V+ m4 |3 K+ } - #define ITCCHEN_SHIFT 23# ]. v: ]4 _ e( l( i& g2 q% \
- t j$ N! o4 I* c( l0 t; n: q
- static volatile int irqraised1 = 0;+ n+ G( ~: r8 O
- static volatile int irqraised2 = 0;6 f1 Z$ D7 O4 C6 S% T' q0 P7 r. T! n
! j' T& y; q/ \! J8 i% X- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' u0 A7 l3 i* t3 K
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ I" O4 L4 v" d" Y
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# |. j2 q" X( g: ?6 l6 @
" t5 H+ `) h4 A# E" E- dma_addr_t dmaphyssrc1 = 0;9 p% [$ R; d% B' F0 N
- dma_addr_t dmaphyssrc2 = 0;
4 ]3 y6 i" M0 F( b7 X# h9 d0 J+ E - dma_addr_t dmaphysdest1 = 0;% I( R5 W8 W, ~) J
- dma_addr_t dmaphysdest2 = 0;) e# A) `$ j/ X
9 \$ [5 |% u3 [- char *dmabufsrc1 = NULL;" _& O4 ^* ?/ D5 x, X8 l: k
- char *dmabufsrc2 = NULL;
5 Y6 s# L! {* U* s( [4 _7 Q3 R0 l - char *dmabufdest1 = NULL;
8 c6 a1 r0 A, @$ c - char *dmabufdest2 = NULL;' c6 e+ f6 t! ~- Z# r' {6 z
' f4 {; H! V) e+ V- static int acnt = 512;
. k Y0 j! R0 r5 t: l" o7 e - static int bcnt = 8;
) Q/ u1 X0 s) I# b& h$ o - static int ccnt = 8;
3 t) h8 U, W: H7 S5 R4 J# {3 P9 J* Y
* ]' Z' u" i/ r; y- module_param(acnt, int, S_IRUGO);/ @8 N+ E+ p/ r/ N0 R# D# R
- module_param(bcnt, int, S_IRUGO);3 x4 ?& L3 n5 J' Q; \, `0 }" h7 S* K
- module_param(ccnt, int, S_IRUGO);
复制代码 # D/ M- m- |7 ]3 q
. k; i# w) G% F+ Q$ v 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 [4 i5 n S a" varm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
) k. ]& V& B1 j) T/ J! P- M! F 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。# R% f, @) d4 N) q7 N9 }/ e
6 v6 P3 }: @+ ]& [; n
* p0 X( [, S# g o8 z% y |
|