|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 @$ A( ^5 N9 }2 y- [code]EDMA sample test application
8 X9 ~( u$ @. O5 j( x2 m - /*
7 {1 P8 d) V2 K4 A& ` - * edma_test.c
8 M8 P8 V) r4 r1 H7 X8 L# E - *
1 _* h% h$ [ V3 [7 z% ^2 P - * brief EDMA3 Test Application
1 H5 s" j. t4 L$ A, g - ** m0 z# P8 ?* a# D2 m
- * This file contains EDMA3 Test code.
' b @. O, e3 ?6 ^ - */ u- G! C6 g3 x
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE7 d; L/ f* i" Z' @( X
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
9 T' b; |* P0 }$ Z: a% i4 G - * TO CHANGE.6 T' {. i& ]& m8 q4 l
- *
; u n/ u1 j6 C* ^4 [$ @3 }1 f - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
& |, z0 e) G1 s- b% T3 ?. ^+ ?; G, c - * n0 q& ~, n3 J: F
- * This program is free software; you can redistribute it and/or8 l! V9 O. A; `2 H) ^, u" {
- * modify it under the terms of the GNU General Public License as l* n: z" m6 T! h7 Q! ]; K
- * published by the Free Software Foundation version 2.6 y6 }+ h. L% `5 V* O6 F
- *
: Z& @+ a5 _5 J3 d G% y# w - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
0 L7 v% R- }; r% {' N. a' h - * kind, whether express or implied; without even the implied warranty7 n* f3 D$ r: X; Y; J; `
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" ^) T# L4 g. T - * GNU General Public License for more details.* X% `/ o" I3 u' H* Y- l/ S
- */
% H: F- p x) r2 w) Q0 t
1 @) }1 o$ k" Z: @, O ~$ ?) }0 l# i- #include <linux/module.h>
- h( t9 o8 E0 b. j - #include <linux/init.h>& H5 e' J5 `$ I4 Z; \
- #include <linux/errno.h>
5 @: Z( _; o ~! @5 i: l - #include <linux/types.h>
y7 {/ z7 J" T. X - #include <linux/interrupt.h>2 ~+ k6 g( \# c1 y! T! `
- #include <asm/io.h>
' D0 f7 O. r: k: P. w5 T2 k - #include <linux/moduleparam.h>
* d" j& b+ b( ?- O. q2 ^ - #include <linux/sysctl.h> c: S! g) ~* h2 q7 M8 [$ T3 z
- #include <linux/mm.h>. ], m9 v' k7 z) P/ S$ {
- #include <linux/dma-mapping.h>
- `& z4 n: B: U1 X- C
3 |- z. @* c, r- #include <mach/memory.h>
' U3 h3 x7 Y+ E! U+ O - #include <mach/hardware.h>5 H! z2 `4 k2 x9 ^+ n
- #include <mach/irqs.h>7 E5 Z4 e0 b' J# }& F
- #include <asm/hardware/edma.h>% U% w5 } s1 s# o2 Z
- + v: ?8 X3 u3 e! R
- #undef EDMA3_DEBUG7 L6 ], \4 ~" g5 m0 o+ ?
- /*#define EDMA3_DEBUG*/
$ t$ B% G% g M7 `; { - 7 A- y% I2 s" b+ R# ]
- #ifdef EDMA3_DEBUG
- F+ R6 ]% e0 n4 ]. ^) m - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ I* S& M/ J4 T; R( j - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
" s; @* r. | _: D$ M' M - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)+ @9 j1 {. g, B/ |+ E0 z5 ^
- #else
+ ^ E: b- e4 ?/ R: S* S( t! s - #define DMA_PRINTK( x... )
; y1 T1 w7 K7 d( U. I - #define DMA_FN_IN
6 y6 k% j( s4 D! Q# A. c" S - #define DMA_FN_OUT) Z1 B7 v7 H, `3 W
- #endif1 ^1 v$ }* h( {6 T
6 ^0 u, ^2 t) E1 }: v1 m- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" `! V2 E' r3 q! B5 L% \
- #define STATIC_SHIFT 3
8 [' W; P& C; O A* Z6 @ - #define TCINTEN_SHIFT 206 O$ d% U3 R. v- O( h$ z- J
- #define ITCINTEN_SHIFT 214 Y4 x# A: m7 t! ~
- #define TCCHEN_SHIFT 22
- V# W; P$ @2 Y9 X# v! G - #define ITCCHEN_SHIFT 23
6 h7 } I% Y* ~# B: {
4 V! V( m U3 E3 G! z; m! M: a- static volatile int irqraised1 = 0;2 `0 y; O) Y" K9 W9 ~. Y0 g+ S1 w
- static volatile int irqraised2 = 0;) a7 o/ w" J/ E! a, q
- ) F b- i) h3 J7 r6 v* P( a
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ J8 g/ n8 x, B. J) o! k" \ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* a, @- j% F! P$ q3 V - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 V _5 }3 r' |7 A/ |8 t8 A* E l
- $ a# D/ q. X! {: A( M* M1 v* m
- dma_addr_t dmaphyssrc1 = 0;" u' F, g3 d0 a" N' {0 j
- dma_addr_t dmaphyssrc2 = 0;
) k$ a6 b/ i4 n% v. O - dma_addr_t dmaphysdest1 = 0;
P# r2 d% X6 m1 Z# z# U- d - dma_addr_t dmaphysdest2 = 0;2 J; N& P c" g T5 p' ?
- # i1 l. f8 @( q5 f' b8 m' j0 X
- char *dmabufsrc1 = NULL;
4 L. H2 I% _8 C# |5 k - char *dmabufsrc2 = NULL;
9 C! Z. Q% F& h% P/ |! a% q - char *dmabufdest1 = NULL;/ |" B# B* ]1 y, Y2 \& c
- char *dmabufdest2 = NULL;
, k/ X# e; ]9 f8 o+ ?0 z
+ ^+ P# W# w: v q- static int acnt = 512;5 h+ L) r" n- k7 k k: R1 x
- static int bcnt = 8;
3 [1 c6 W" y5 J9 z6 P2 v/ x - static int ccnt = 8;
, B9 }5 o" W( |) }7 R5 ^2 F
* \& z1 q( s) h/ A! W! Q& c- module_param(acnt, int, S_IRUGO);" m6 E* x z' m8 i/ R
- module_param(bcnt, int, S_IRUGO);' k4 U2 |6 k) v) t
- module_param(ccnt, int, S_IRUGO);
复制代码 1 _- p' ?" f9 K8 K" E: L+ w9 }
. Z# c9 Q, @$ o) l5 Q- ] 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! P$ c' m. r! f3 L6 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
) i( y( B/ H3 S3 ^; v: I8 ?! n 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
5 [+ H" Z& F' p# Y& b0 m& u# p5 }2 w" G
) |* K* [" M) R) O, a3 G% Q+ F |
|