|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 Q9 h" L4 J3 L/ f9 P% j: ?/ ~- [code]EDMA sample test application
8 P9 i9 F& l$ n W5 W - /*
0 |0 |8 z' E8 a0 _1 I3 A - * edma_test.c
% V' \! m0 X% Q# F$ t - *. P9 C6 H& d6 e) L& R8 D
- * brief EDMA3 Test Application
# @# w' Y. y Z) X3 v - */ D( r8 D$ [$ x M& f
- * This file contains EDMA3 Test code.
' K9 A& y) N8 F5 J* W% V4 S, x - *
6 O x$ O+ i" B# T2 w5 J - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
+ Y, d$ O6 M0 d, J7 x3 M - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT( s# I" m/ Z/ A6 d
- * TO CHANGE.% R' i- g( ]# `7 Y0 o! p9 |- V2 d
- * ^ J7 d2 S9 j D6 S# R* T
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/' G! }+ Q- z& S* [- F* `. f7 M/ q! N
- *8 `/ U6 B- w2 ^3 f3 e# @; o1 \ k8 Y" ]
- * This program is free software; you can redistribute it and/or
1 g' _& O1 g& ~) b0 @* ^* [ h- _ - * modify it under the terms of the GNU General Public License as+ ]. [; I9 \6 v, v z- r
- * published by the Free Software Foundation version 2.
, z) \2 i8 @2 Z3 R8 A - */ T. L3 K+ V( e2 _3 q2 T5 h( q8 C. Z
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& |* M1 x; D+ a3 i5 q; k* A) P - * kind, whether express or implied; without even the implied warranty
' t8 W* h* c: B# C# H) R h5 b u1 P2 X* i - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the/ B# W4 _) U7 L2 f k4 D3 C
- * GNU General Public License for more details.
$ k3 ^" w( d+ O/ B) D - */8 M# ^! J5 y" u3 O: Z3 }) X: D4 ~# T$ h
* z' |, e$ G- w0 o- #include <linux/module.h># s8 {8 i1 Y# J: }
- #include <linux/init.h>: s5 `- y2 T+ l. t' [2 Z9 f
- #include <linux/errno.h>
( U& S( X. Q4 ~$ e5 W) A - #include <linux/types.h>8 g, @3 W( G( v# l8 b
- #include <linux/interrupt.h>) |3 G6 B0 \ c* E. |& S" \
- #include <asm/io.h>
( f M1 B7 q8 q7 z: Q/ t6 b - #include <linux/moduleparam.h>% Z6 O" U2 X/ l8 i1 z
- #include <linux/sysctl.h>4 g! T# G# L" X3 y- x, U
- #include <linux/mm.h># o2 [, k1 H# L" h4 S0 b" `
- #include <linux/dma-mapping.h>
1 z4 d4 a4 x o" b3 `8 q$ I
& g( x* d0 ]! P- #include <mach/memory.h>
7 v4 ?# |- w2 M# Z0 @ - #include <mach/hardware.h>
% T: p+ J0 a8 ^" o- L Y& @ - #include <mach/irqs.h>* C0 k- e) O& q% [
- #include <asm/hardware/edma.h>
2 b) Z3 h3 P6 _+ [
" q( h8 l9 Y3 V- #undef EDMA3_DEBUG
t, Z" F; P1 ?, l7 R/ A% Z0 v - /*#define EDMA3_DEBUG*/
+ U8 o5 E$ l+ n7 j% N# x K- B! ` - + @- i. {& i4 w8 N) b% E
- #ifdef EDMA3_DEBUG
5 V: k$ h+ w$ J" [7 Z - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
2 S' Y; Y/ k( B- {! e" p - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)* @. U9 Z I) X) D! H8 r$ `7 H
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
* ^) K, F: j: ` - #else
! P* ?7 \- ^1 y1 G - #define DMA_PRINTK( x... )
0 c9 ]& }& ?* x4 d* {- n7 T - #define DMA_FN_IN
$ ?3 S4 m' }: ^8 S: z) z2 h! J. D - #define DMA_FN_OUT _& o6 M3 n G. I! f
- #endif
2 X7 ~ N6 C8 _) t; l: v: `1 P - , V7 q3 p& L! o7 T' V. H
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. }5 |' M' k* f" x8 }& L4 c% G - #define STATIC_SHIFT 3
0 u. o6 x' ]4 f! _3 \ - #define TCINTEN_SHIFT 205 |6 q! h6 s) |7 X/ u* V% C7 ?; g
- #define ITCINTEN_SHIFT 21
* L1 {8 Y7 n! s1 v; J6 z+ f - #define TCCHEN_SHIFT 22
s9 W6 E7 Z9 V: ?( r) {# K - #define ITCCHEN_SHIFT 23
$ m; k/ i" S' U4 o - ' r" E- X# ~5 Z
- static volatile int irqraised1 = 0;
* ~+ j" j1 J2 u4 X) G - static volatile int irqraised2 = 0;6 a/ X% S, H# {8 [7 _* A5 Y
- + X7 b ?5 w8 t
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 Y: P1 ]" \3 N, c& J/ |
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 `* D% ?: `) K- |3 M4 R6 w - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ n7 @ K" U% M) T+ h; j - G* v8 @% p+ Q& o; t
- dma_addr_t dmaphyssrc1 = 0;& d: Z g6 @! o/ r
- dma_addr_t dmaphyssrc2 = 0;/ K5 w1 Q9 b" |4 _, s7 }
- dma_addr_t dmaphysdest1 = 0;
; q& U, }- d; A9 s! s* t0 H - dma_addr_t dmaphysdest2 = 0;
; K" G* v+ F% e; D2 _5 q
7 {! p6 Z& w8 U' I& n- l* T- char *dmabufsrc1 = NULL;
4 V; }0 Z! K8 H6 n2 M - char *dmabufsrc2 = NULL;
2 u' ^3 B( b* Z3 z# J: P. ^* c - char *dmabufdest1 = NULL;
8 C0 m. q' W! [1 G7 R; k2 R+ }; n. [ - char *dmabufdest2 = NULL;: g* e2 }+ s# W& w; @3 [
& ^* \. b7 N+ i' o, m# D- static int acnt = 512;, _% v0 Y9 N% G$ O: s- |4 ~- U5 l
- static int bcnt = 8;
- H2 l/ H2 ]1 z: G - static int ccnt = 8;( C. l& Q/ F* j
2 B: ^3 K+ @5 I' L% ]; W- module_param(acnt, int, S_IRUGO);
0 m$ J/ f, E7 A9 f$ ` h - module_param(bcnt, int, S_IRUGO);
; J' B5 ~% E Q5 v# n - module_param(ccnt, int, S_IRUGO);
复制代码
7 t& u( T4 I9 ^0 H5 k7 c
6 Z' ]8 c9 z- e' l 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
1 D& l* U Q, U- {6 ^0 U$ 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。! ~7 L) @7 F& I, W* n0 Y' n
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' e, l2 q1 P+ {
) Z' m+ q+ u0 Q+ }! l5 [; R
% }8 C! u' l) ^0 V& Q: Z |
|